From 06c4c4520096ea32a828f87252a2a6b10857c60c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 18 May 2014 14:21:41 -0700 Subject: [PATCH 1/3] GL: Fix half-float texture formats. This matches the ps3 output/channels for these textures per the rsx/texture_formats test. --- rpcs3/Emu/GS/GL/GLGSRender.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index 1cb8869ab2..db728b910b 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -288,8 +288,14 @@ public: break; case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: // Four fp16 values - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_BGRA, GL_HALF_FLOAT, pixels); + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RGBA, GL_HALF_FLOAT, pixels); checkForGlError("GLTexture::Init() -> glTexImage2D"); + + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); break; case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: // Four fp32 values @@ -336,10 +342,16 @@ public: case CELL_GCM_TEXTURE_Y16_X16_FLOAT: // Two fp16 values { + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RG, GL_HALF_FLOAT, pixels); checkForGlError("GLTexture::Init() -> glTexImage2D"); - static const GLint swizzleMaskX32_Y16_X16_FLOAT[] = { GL_GREEN, GL_RED, GL_GREEN, GL_RED }; + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); + + static const GLint swizzleMaskX32_Y16_X16_FLOAT[] = { GL_RED, GL_GREEN, GL_RED, GL_GREEN }; glRemap = swizzleMaskX32_Y16_X16_FLOAT; } break; From 612e515317b3149bf4f46139dc791ea5768d8900 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 18 May 2014 14:39:04 -0700 Subject: [PATCH 2/3] GL: Fix X16 / Y16_X16 texture formats. Per the rsx/texture_formats test. Not sure about pitch, may need to deal with UNPACK_ROW_LENGTH... --- rpcs3/Emu/GS/GL/GLGSRender.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index db728b910b..79da1ff8ac 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -258,19 +258,31 @@ public: case CELL_GCM_TEXTURE_X16: // A 16-bit fixed-point number { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RED, GL_SHORT, pixels); + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RED, GL_UNSIGNED_SHORT, pixels); checkForGlError("GLTexture::Init() -> glTexImage2D"); - static const GLint swizzleMaskX16[] = { GL_RED, GL_ONE, GL_ONE, GL_ONE }; + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); + + static const GLint swizzleMaskX16[] = { GL_RED, GL_ONE, GL_RED, GL_ONE }; glRemap = swizzleMaskX16; } break; case CELL_GCM_TEXTURE_Y16_X16: // Two 16-bit fixed-point numbers { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RG, GL_SHORT, pixels); + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.GetWidth(), tex.GetHeight(), 0, GL_RG, GL_UNSIGNED_SHORT, pixels); checkForGlError("GLTexture::Init() -> glTexImage2D"); + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); + checkForGlError("GLTexture::Init() -> glPixelStorei"); + static const GLint swizzleMaskX32_Y16_X16[] = { GL_GREEN, GL_RED, GL_GREEN, GL_RED }; glRemap = swizzleMaskX32_Y16_X16; } From 7948f376fb0bf2db5d845fdbcaf70082d01e4ffa Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 18 May 2014 15:24:12 -0700 Subject: [PATCH 3/3] GL: Fix the compressed R8B8 / B8R8 type formats. The not-swizzled bit is always set for them. --- rpcs3/Emu/GS/GL/GLGSRender.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index 79da1ff8ac..819d95ff1c 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -368,9 +368,8 @@ public: } break; - case CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: + case CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8 & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN): { - // TODO: Probably need to actually unswizzle if is_swizzled. const u32 numPixels = tex.GetWidth() * tex.GetHeight(); unswizzledPixels = (u8 *)malloc(numPixels * 4); // TODO: Speed. @@ -394,9 +393,8 @@ public: } break; - case CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: + case CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8 & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN): { - // TODO: Probably need to actually unswizzle if is_swizzled. const u32 numPixels = tex.GetWidth() * tex.GetHeight(); unswizzledPixels = (u8 *)malloc(numPixels * 4); // TODO: Speed.