From cf0e116a56414884eae69db2d07d3c63c03c6432 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" <checkins@unknownbrackets.org> Date: Sat, 17 May 2014 12:55:40 -0700 Subject: [PATCH] GL: Add R8B8_R8G8 / B8R8_G8R8 formats, tweak G8B8. Based on how the first two swizzle, most likely G8B8 works that way too. --- rpcs3/Emu/GS/GL/GLGSRender.h | 54 +++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index ef1dfe387e..3fd39e1498 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -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; }