mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-24 11:43:05 +01:00
GL: Add support for R6G5B5.
This commit is contained in:
parent
2f8e31cddd
commit
86d35d58df
@ -62,6 +62,24 @@ public:
|
|||||||
return GL_REPEAT;
|
return GL_REPEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static u8 Convert4To8(u8 v)
|
||||||
|
{
|
||||||
|
// Swizzle bits: 00012345 -> 12345123
|
||||||
|
return (v << 4) | (v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static u8 Convert5To8(u8 v)
|
||||||
|
{
|
||||||
|
// Swizzle bits: 00012345 -> 12345123
|
||||||
|
return (v << 3) | (v >> 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static u8 Convert6To8(u8 v)
|
||||||
|
{
|
||||||
|
// Swizzle bits: 00123456 -> 12345612
|
||||||
|
return (v << 2) | (v >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
void Init(RSXTexture& tex)
|
void Init(RSXTexture& tex)
|
||||||
{
|
{
|
||||||
Bind();
|
Bind();
|
||||||
@ -78,8 +96,8 @@ public:
|
|||||||
int format = tex.GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
|
int format = tex.GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
|
||||||
bool is_swizzled = !(tex.GetFormat() & CELL_GCM_TEXTURE_LN);
|
bool is_swizzled = !(tex.GetFormat() & CELL_GCM_TEXTURE_LN);
|
||||||
|
|
||||||
char* pixels = (char*)Memory.GetMemFromAddr(GetAddress(tex.GetOffset(), tex.GetLocation()));
|
u8* pixels = (u8*)Memory.GetMemFromAddr(GetAddress(tex.GetOffset(), tex.GetLocation()));
|
||||||
char* unswizzledPixels;
|
u8* unswizzledPixels;
|
||||||
static const GLint glRemapStandard[4] = {GL_ALPHA, GL_RED, GL_GREEN, GL_BLUE};
|
static const GLint glRemapStandard[4] = {GL_ALPHA, GL_RED, GL_GREEN, GL_BLUE};
|
||||||
// NOTE: This must be in ARGB order in all forms below.
|
// NOTE: This must be in ARGB order in all forms below.
|
||||||
const GLint *glRemap = glRemapStandard;
|
const GLint *glRemap = glRemapStandard;
|
||||||
@ -124,7 +142,7 @@ public:
|
|||||||
u32 *src, *dst;
|
u32 *src, *dst;
|
||||||
u32 log2width, log2height;
|
u32 log2width, log2height;
|
||||||
|
|
||||||
unswizzledPixels = (char*)malloc(tex.GetWidth() * tex.GetHeight() * 4);
|
unswizzledPixels = (u8*)malloc(tex.GetWidth() * tex.GetHeight() * 4);
|
||||||
src = (u32*)pixels;
|
src = (u32*)pixels;
|
||||||
dst = (u32*)unswizzledPixels;
|
dst = (u32*)unswizzledPixels;
|
||||||
|
|
||||||
@ -181,6 +199,27 @@ public:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CELL_GCM_TEXTURE_R6G5B5:
|
||||||
|
{
|
||||||
|
// TODO: Probably need to actually unswizzle if is_swizzled.
|
||||||
|
const u32 numPixels = tex.GetWidth() * tex.GetHeight();
|
||||||
|
unswizzledPixels = (u8 *)malloc(numPixels * 4);
|
||||||
|
// TODO: Speed.
|
||||||
|
for (u32 i = 0; i < numPixels; ++i) {
|
||||||
|
u16 c = reinterpret_cast<const be_t<u16> *>(pixels)[i];
|
||||||
|
unswizzledPixels[i * 4 + 0] = Convert6To8((c >> 10) & 0x3F);
|
||||||
|
unswizzledPixels[i * 4 + 1] = Convert5To8((c >> 5) & 0x1F);
|
||||||
|
unswizzledPixels[i * 4 + 2] = Convert5To8((c >> 0) & 0x1F);
|
||||||
|
unswizzledPixels[i * 4 + 3] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, unswizzledPixels);
|
||||||
|
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
||||||
|
|
||||||
|
free(unswizzledPixels);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case CELL_GCM_TEXTURE_DEPTH24_D8: // 24-bit unsigned fixed-point number and 8 bits of garbage
|
case CELL_GCM_TEXTURE_DEPTH24_D8: // 24-bit unsigned fixed-point number and 8 bits of garbage
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, tex.GetWidth(), tex.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, tex.GetWidth(), tex.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, pixels);
|
||||||
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
||||||
|
Loading…
Reference in New Issue
Block a user