mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 03:32:55 +00:00
GL: Add R8B8_R8G8 / B8R8_G8R8 formats, tweak G8B8.
Based on how the first two swizzle, most likely G8B8 works that way too.
This commit is contained in:
parent
0e3e4c7553
commit
cf0e116a56
@ -210,7 +210,7 @@ public:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RG, GL_UNSIGNED_BYTE, pixels);
|
||||
checkForGlError("GLTexture::Init() -> glTexImage2D");
|
||||
|
||||
static const GLint swizzleMaskG8B8[] = { GL_ONE, GL_GREEN, GL_RED, GL_GREEN };
|
||||
static const GLint swizzleMaskG8B8[] = { GL_RED, GL_GREEN, GL_RED, GL_GREEN };
|
||||
glRemap = swizzleMaskG8B8;
|
||||
}
|
||||
break;
|
||||
@ -324,6 +324,58 @@ public:
|
||||
}
|
||||
break;
|
||||
|
||||
case CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8:
|
||||
{
|
||||
// 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 += 2) {
|
||||
unswizzledPixels[i * 4 + 0 + 0] = pixels[i * 2 + 3];
|
||||
unswizzledPixels[i * 4 + 0 + 1] = pixels[i * 2 + 2];
|
||||
unswizzledPixels[i * 4 + 0 + 2] = pixels[i * 2 + 0];
|
||||
unswizzledPixels[i * 4 + 0 + 3] = 255;
|
||||
|
||||
// The second pixel is the same, except for red.
|
||||
unswizzledPixels[i * 4 + 4 + 0] = pixels[i * 2 + 1];
|
||||
unswizzledPixels[i * 4 + 4 + 1] = pixels[i * 2 + 2];
|
||||
unswizzledPixels[i * 4 + 4 + 2] = pixels[i * 2 + 0];
|
||||
unswizzledPixels[i * 4 + 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_COMPRESSED_R8B8_R8G8:
|
||||
{
|
||||
// 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 += 2) {
|
||||
unswizzledPixels[i * 4 + 0 + 0] = pixels[i * 2 + 2];
|
||||
unswizzledPixels[i * 4 + 0 + 1] = pixels[i * 2 + 3];
|
||||
unswizzledPixels[i * 4 + 0 + 2] = pixels[i * 2 + 1];
|
||||
unswizzledPixels[i * 4 + 0 + 3] = 255;
|
||||
|
||||
// The second pixel is the same, except for red.
|
||||
unswizzledPixels[i * 4 + 4 + 0] = pixels[i * 2 + 0];
|
||||
unswizzledPixels[i * 4 + 4 + 1] = pixels[i * 2 + 3];
|
||||
unswizzledPixels[i * 4 + 4 + 2] = pixels[i * 2 + 1];
|
||||
unswizzledPixels[i * 4 + 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;
|
||||
|
||||
default: ConLog.Error("Init tex error: Bad tex format (0x%x | %s | 0x%x)", format,
|
||||
(is_swizzled ? "swizzled" : "linear"), tex.GetFormat() & 0x40); break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user