From 39cb74a8d3937558e54477e929bd7e45f5e48899 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 8 Mar 2015 13:12:13 -0700 Subject: [PATCH 1/5] Simplify transform in throughmode/sw (rectangles.) This should make it a bit faster, a bit less work. --- GPU/Common/SoftwareTransformCommon.cpp | 74 ++++++++++++++--------- GPU/Common/VertexDecoderCommon.h | 14 ++++- GPU/Directx9/PixelShaderGeneratorDX9.cpp | 4 +- GPU/Directx9/VertexShaderGeneratorDX9.cpp | 20 +++--- GPU/GLES/FragmentShaderGenerator.cpp | 4 +- GPU/GLES/VertexShaderGenerator.cpp | 22 ++++--- 6 files changed, 86 insertions(+), 52 deletions(-) diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 85b3b52c32..c69adabed1 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -158,7 +158,7 @@ void SoftwareTransform( // not really sure what a sensible value might be. fog_slope = fog_slope < 0.0f ? -10000.0f : 10000.0f; } - if (my_isnan(fog_slope)) { + if (my_isnan(fog_slope)) { // Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988 // Just put the fog far away at a large finite distance. // Infinities and NaNs are rather unpredictable in shaders on many GPUs @@ -170,34 +170,50 @@ void SoftwareTransform( VertexReader reader(decoded, decVtxFormat, vertType); // We flip in the fragment shader for GE_TEXMAP_TEXTURE_MATRIX. const bool flipV = gstate_c.flipTexture && gstate.getUVGenMode() != GE_TEXMAP_TEXTURE_MATRIX; - for (int index = 0; index < maxIndex; index++) { - reader.Goto(index); - - float v[3] = {0, 0, 0}; - Vec4f c0 = Vec4f(1, 1, 1, 1); - Vec4f c1 = Vec4f(0, 0, 0, 0); - float uv[3] = {0, 0, 1}; - float fogCoef = 1.0f; - - if (throughmode) { + if (throughmode) { + for (int index = 0; index < maxIndex; index++) { // Do not touch the coordinates or the colors. No lighting. - reader.ReadPos(v); + reader.Goto(index); + // TODO: Write to a flexible buffer, we don't always need all four components. + TransformedVertex &vert = transformed[index]; + reader.ReadPos(vert.pos); + if (reader.hasColor0()) { - reader.ReadColor0(&c0.x); - // c1 is already 0. + reader.ReadColor0_8888(vert.color0); } else { - c0 = Vec4f::FromRGBA(gstate.getMaterialAmbientRGBA()); + vert.color0_32 = gstate.getMaterialAmbientRGBA(); } if (reader.hasUV()) { - reader.ReadUV(uv); + reader.ReadUV(vert.uv); - uv[0] *= uscale; - uv[1] *= vscale; + vert.u *= uscale; + vert.v *= vscale; + } + else + { + vert.u = 0.0f; + vert.v = 0.0f; } - fogCoef = 1.0f; // Scale UV? - } else { + + if (flipV) { + vert.v = 1.0f - vert.v; + } + + // Ignore color1 and fog, never used in throughmode anyway. + // The w of uv is also never used (hardcoded to 1.0.) + } + } else { + for (int index = 0; index < maxIndex; index++) { + reader.Goto(index); + + float v[3] = {0, 0, 0}; + Vec4f c0 = Vec4f(1, 1, 1, 1); + Vec4f c1 = Vec4f(0, 0, 0, 0); + float uv[3] = {0, 0, 1}; + float fogCoef = 1.0f; + // We do software T&L for now float out[3]; float pos[3]; @@ -369,17 +385,17 @@ void SoftwareTransform( // Transform the coord by the view matrix. Vec3ByMatrix43(v, out, gstate.viewMatrix); fogCoef = (v[2] + fog_end) * fog_slope; - } - // TODO: Write to a flexible buffer, we don't always need all four components. - memcpy(&transformed[index].x, v, 3 * sizeof(float)); - transformed[index].fog = fogCoef; - memcpy(&transformed[index].u, uv, 3 * sizeof(float)); - if (flipV) { - transformed[index].v = 1.0f - transformed[index].v; + // TODO: Write to a flexible buffer, we don't always need all four components. + memcpy(&transformed[index].x, v, 3 * sizeof(float)); + transformed[index].fog = fogCoef; + memcpy(&transformed[index].u, uv, 3 * sizeof(float)); + if (flipV) { + transformed[index].v = 1.0f - transformed[index].v; + } + transformed[index].color0_32 = c0.ToRGBA(); + transformed[index].color1_32 = c1.ToRGBA(); } - transformed[index].color0_32 = c0.ToRGBA(); - transformed[index].color1_32 = c1.ToRGBA(); } // Here's the best opportunity to try to detect rectangles used to clear the screen, and diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index d26ea41424..225d71f78b 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -75,8 +75,18 @@ struct DecVtxFormat { // This struct too. struct TransformedVertex { - float x, y, z, fog; // in case of morph, preblend during decode - float u; float v; float w; // scaled by uscale, vscale, if there + union { + struct { + float x, y, z, fog; // in case of morph, preblend during decode + }; + float pos[4]; + }; + union { + struct { + float u; float v; float w; // scaled by uscale, vscale, if there + }; + float uv[3]; + }; union { u8 color0[4]; // prelit u32 color0_32; diff --git a/GPU/Directx9/PixelShaderGeneratorDX9.cpp b/GPU/Directx9/PixelShaderGeneratorDX9.cpp index 1f22ccb915..13a3e1376b 100644 --- a/GPU/Directx9/PixelShaderGeneratorDX9.cpp +++ b/GPU/Directx9/PixelShaderGeneratorDX9.cpp @@ -412,7 +412,7 @@ void ComputeFragmentShaderIDDX9(FragmentShaderIDDX9 *id) { // We only need one clear shader, so let's ignore the rest of the bits. id0 = 1; } else { - bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); + bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !gstate.isModeThrough(); bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough(); bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !g_Config.bDisableAlphaTest; bool alphaTestAgainstZero = IsAlphaTestAgainstZero(); @@ -497,7 +497,7 @@ void ComputeFragmentShaderIDDX9(FragmentShaderIDDX9 *id) { void GenerateFragmentShaderDX9(char *buffer) { char *p = buffer; - bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); + bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !gstate.isModeThrough(); bool doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear(); bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough() && !gstate.isModeClear(); bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !gstate.isModeClear() && !g_Config.bDisableAlphaTest; diff --git a/GPU/Directx9/VertexShaderGeneratorDX9.cpp b/GPU/Directx9/VertexShaderGeneratorDX9.cpp index fe92f7c2d3..d9dde9ed83 100644 --- a/GPU/Directx9/VertexShaderGeneratorDX9.cpp +++ b/GPU/Directx9/VertexShaderGeneratorDX9.cpp @@ -232,7 +232,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, "%s", boneWeightAttrDecl[TranslateNumBones(vertTypeGetNumBoneWeights(vertType))]); } if (doTexture && hasTexcoord) { - if (doTextureProjection) + if (doTextureProjection && !throughmode) WRITE(p, " float3 texcoord : TEXCOORD0;\n"); else WRITE(p, " float2 texcoord : TEXCOORD0;\n"); @@ -265,7 +265,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, " float2 v_texcoord: TEXCOORD0;\n"); } WRITE(p, " float4 v_color0 : COLOR0;\n"); - if (lmode) + if (lmode && !throughmode) WRITE(p, " float3 v_color1 : COLOR1;\n"); if (enableFog) { @@ -279,18 +279,22 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { // Simple pass-through of vertex data to fragment shader if (doTexture) { if (doTextureProjection) { - WRITE(p, " Out.v_texcoord = In.texcoord;\n"); + if (throughmode) { + WRITE(p, " Out.v_texcoord = float3(In.texcoord.x, In.texcoord.y, 1.0);\n"); + } else { + WRITE(p, " Out.v_texcoord = In.texcoord;\n"); + } } else { WRITE(p, " Out.v_texcoord = In.texcoord.xy;\n"); } } if (hasColor) { WRITE(p, " Out.v_color0 = In.color0;\n"); - if (lmode) + if (lmode && !throughmode) WRITE(p, " Out.v_color1 = In.color1.rgb;\n"); } else { WRITE(p, " Out.v_color0 = In.u_matambientalpha;\n"); - if (lmode) + if (lmode && !throughmode) WRITE(p, " Out.v_color1 = float3(0.0);\n"); } if (enableFog) { @@ -493,9 +497,9 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { if (lmode) { WRITE(p, " Out.v_color0 = clamp(lightSum0, 0.0, 1.0);\n"); // v_color1 only exists when lmode = 1. - if (specularIsZero) { + if (specularIsZero && !throughmode) { WRITE(p, " Out.v_color1 = float3(0, 0, 0);\n"); - } else { + } else if (!throughmode) { WRITE(p, " Out.v_color1 = clamp(lightSum1, 0.0, 1.0);\n"); } } else { @@ -512,7 +516,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { } else { WRITE(p, " Out.v_color0 = u_matambientalpha;\n"); } - if (lmode) + if (lmode && !throughmode) WRITE(p, " Out.v_color1 = float3(0, 0, 0);\n"); } diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index e7f171d079..d3b5e21de0 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -394,7 +394,7 @@ void ComputeFragmentShaderID(ShaderID *id) { // We only need one clear shader, so let's ignore the rest of the bits. id0 = 1; } else { - bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); + bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !gstate.isModeThrough(); bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough(); bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !g_Config.bDisableAlphaTest; bool alphaTestAgainstZero = IsAlphaTestAgainstZero(); @@ -568,7 +568,7 @@ void GenerateFragmentShader(char *buffer) { varying = "in"; } - bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); + bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !gstate.isModeThrough(); bool doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear(); bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough() && !gstate.isModeClear(); bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !gstate.isModeClear() && !g_Config.bDisableAlphaTest; diff --git a/GPU/GLES/VertexShaderGenerator.cpp b/GPU/GLES/VertexShaderGenerator.cpp index 854db12afe..6203c0cf76 100644 --- a/GPU/GLES/VertexShaderGenerator.cpp +++ b/GPU/GLES/VertexShaderGenerator.cpp @@ -257,14 +257,14 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf WRITE(p, "%s mediump vec3 normal;\n", attribute); if (doTexture && hasTexcoord) { - if (!useHWTransform && doTextureProjection) + if (!useHWTransform && doTextureProjection && !throughmode) WRITE(p, "%s vec3 texcoord;\n", attribute); else WRITE(p, "%s vec2 texcoord;\n", attribute); } if (hasColor) { WRITE(p, "%s lowp vec4 color0;\n", attribute); - if (lmode && !useHWTransform) // only software transform supplies color1 as vertex data + if (lmode && !useHWTransform && !throughmode) // only software transform supplies color1 as vertex data WRITE(p, "%s lowp vec3 color1;\n", attribute); } @@ -337,7 +337,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf } WRITE(p, "%s %s lowp vec4 v_color0;\n", shading, varying); - if (lmode) { + if (lmode && !throughmode) { WRITE(p, "%s %s lowp vec3 v_color1;\n", shading, varying); } if (doTexture) { @@ -362,15 +362,19 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf if (!useHWTransform) { // Simple pass-through of vertex data to fragment shader if (doTexture) { - WRITE(p, " v_texcoord = texcoord;\n"); + if (throughmode && doTextureProjection) { + WRITE(p, " v_texcoord = vec3(texcoord, 1.0);\n"); + } else { + WRITE(p, " v_texcoord = texcoord;\n"); + } } if (hasColor) { WRITE(p, " v_color0 = color0;\n"); - if (lmode) + if (lmode && !throughmode) WRITE(p, " v_color1 = color1;\n"); } else { WRITE(p, " v_color0 = u_matambientalpha;\n"); - if (lmode) + if (lmode && !throughmode) WRITE(p, " v_color1 = vec3(0.0);\n"); } if (enableFog) { @@ -580,9 +584,9 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf if (lmode) { WRITE(p, " v_color0 = clamp(lightSum0, 0.0, 1.0);\n"); // v_color1 only exists when lmode = 1. - if (specularIsZero) { + if (specularIsZero && !throughmode) { WRITE(p, " v_color1 = vec3(0.0);\n"); - } else { + } else if (!throughmode) { WRITE(p, " v_color1 = clamp(lightSum1, 0.0, 1.0);\n"); } } else { @@ -599,7 +603,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf } else { WRITE(p, " v_color0 = u_matambientalpha;\n"); } - if (lmode) + if (lmode && !throughmode) WRITE(p, " v_color1 = vec3(0.0);\n"); } From c7984dd93e4671999ee48069920837b69920019b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 8 Mar 2015 13:13:04 -0700 Subject: [PATCH 2/5] Use texture stage 3 for the palette, always. It's better to keep a stage dedicated to each thing. This also makes it easier to potentially process depal in the shader, if we do that. --- GPU/GLES/DepalettizeShader.cpp | 2 +- GPU/GLES/Framebuffer.cpp | 2 +- GPU/GLES/TextureCache.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/DepalettizeShader.cpp b/GPU/GLES/DepalettizeShader.cpp index ad935c88a0..e3de9532f4 100644 --- a/GPU/GLES/DepalettizeShader.cpp +++ b/GPU/GLES/DepalettizeShader.cpp @@ -209,7 +209,7 @@ GLuint DepalShaderCache::GetDepalettizeShader(GEBufferFormat pixelFormat) { GLint u_pal = glGetUniformLocation(program, "pal"); glUniform1i(u_tex, 0); - glUniform1i(u_pal, 1); + glUniform1i(u_pal, 3); GLint linkStatus = GL_FALSE; glGetProgramiv(program, GL_LINK_STATUS, &linkStatus); diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index ae77367f8b..23408f46e7 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -979,7 +979,7 @@ void FramebufferManager::BindFramebufferColor(int stage, VirtualFramebuffer *fra fbo_bind_color_as_texture(framebuffer->fbo, 0); } - if (stage != GL_TEXTURE1) { + if (stage != GL_TEXTURE0) { glActiveTexture(stage); } } diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 083380a60f..6bc7bfd2e9 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -1109,7 +1109,7 @@ void TextureCache::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffe glEnableVertexAttribArray(a_position); glEnableVertexAttribArray(a_texcoord0); - glActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, clutTexture); glActiveTexture(GL_TEXTURE0); From 83e4edbc7cf8927895fc9562323132f64746d03f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 8 Mar 2015 14:19:44 -0700 Subject: [PATCH 3/5] Oops, don't affect hardware transform. --- GPU/Directx9/VertexShaderGeneratorDX9.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Directx9/VertexShaderGeneratorDX9.cpp b/GPU/Directx9/VertexShaderGeneratorDX9.cpp index d9dde9ed83..f1b562617e 100644 --- a/GPU/Directx9/VertexShaderGeneratorDX9.cpp +++ b/GPU/Directx9/VertexShaderGeneratorDX9.cpp @@ -232,7 +232,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, "%s", boneWeightAttrDecl[TranslateNumBones(vertTypeGetNumBoneWeights(vertType))]); } if (doTexture && hasTexcoord) { - if (doTextureProjection && !throughmode) + if (doTextureProjection) WRITE(p, " float3 texcoord : TEXCOORD0;\n"); else WRITE(p, " float2 texcoord : TEXCOORD0;\n"); From fb071a066d19f6bcb8a6ec09f56f208ce2dbe2a6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 8 Mar 2015 18:01:00 -0700 Subject: [PATCH 4/5] d3d9: Change vertex attribute logic to match gles. --- GPU/Directx9/VertexShaderGeneratorDX9.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/GPU/Directx9/VertexShaderGeneratorDX9.cpp b/GPU/Directx9/VertexShaderGeneratorDX9.cpp index f1b562617e..4c02380bd4 100644 --- a/GPU/Directx9/VertexShaderGeneratorDX9.cpp +++ b/GPU/Directx9/VertexShaderGeneratorDX9.cpp @@ -232,10 +232,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, "%s", boneWeightAttrDecl[TranslateNumBones(vertTypeGetNumBoneWeights(vertType))]); } if (doTexture && hasTexcoord) { - if (doTextureProjection) - WRITE(p, " float3 texcoord : TEXCOORD0;\n"); - else - WRITE(p, " float2 texcoord : TEXCOORD0;\n"); + WRITE(p, " float2 texcoord : TEXCOORD0;\n"); } if (hasColor) { WRITE(p, " float4 color0 : COLOR0;\n"); @@ -249,10 +246,19 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { } else { WRITE(p, "struct VS_IN {\n"); WRITE(p, " float4 position : POSITION;\n"); - WRITE(p, " float3 texcoord : TEXCOORD0;\n"); - WRITE(p, " float4 color0 : COLOR0;\n"); + if (doTexture && hasTexcoord) { + if (doTextureProjection && !throughmode) + WRITE(p, " float3 texcoord : TEXCOORD0;\n"); + else + WRITE(p, " float2 texcoord : TEXCOORD0;\n"); + } + if (hasColor) { + WRITE(p, " float4 color0 : COLOR0;\n"); + } // only software transform supplies color1 as vertex data - WRITE(p, " float4 color1 : COLOR1;\n"); + if (lmode && !throughmode) { + WRITE(p, " float4 color1 : COLOR1;\n"); + } WRITE(p, "};\n"); } From 04eb83002cc5cce0300784e7219182cf8c207765 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 8 Mar 2015 18:03:17 -0700 Subject: [PATCH 5/5] Assume lmode does nothing in throughmode. --- GPU/Directx9/VertexShaderGeneratorDX9.cpp | 16 ++++++++-------- GPU/GLES/VertexShaderGenerator.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/GPU/Directx9/VertexShaderGeneratorDX9.cpp b/GPU/Directx9/VertexShaderGeneratorDX9.cpp index 4c02380bd4..9106d1a2f6 100644 --- a/GPU/Directx9/VertexShaderGeneratorDX9.cpp +++ b/GPU/Directx9/VertexShaderGeneratorDX9.cpp @@ -133,7 +133,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { char *p = buffer; const u32 vertType = gstate.vertType; - bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); + bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !gstate.isModeThrough(); bool doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear(); bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX; bool doShadeMapping = gstate.getUVGenMode() == GE_TEXMAP_ENVIRONMENT_MAP; @@ -256,7 +256,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, " float4 color0 : COLOR0;\n"); } // only software transform supplies color1 as vertex data - if (lmode && !throughmode) { + if (lmode) { WRITE(p, " float4 color1 : COLOR1;\n"); } WRITE(p, "};\n"); @@ -271,7 +271,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { WRITE(p, " float2 v_texcoord: TEXCOORD0;\n"); } WRITE(p, " float4 v_color0 : COLOR0;\n"); - if (lmode && !throughmode) + if (lmode) WRITE(p, " float3 v_color1 : COLOR1;\n"); if (enableFog) { @@ -296,11 +296,11 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { } if (hasColor) { WRITE(p, " Out.v_color0 = In.color0;\n"); - if (lmode && !throughmode) + if (lmode) WRITE(p, " Out.v_color1 = In.color1.rgb;\n"); } else { WRITE(p, " Out.v_color0 = In.u_matambientalpha;\n"); - if (lmode && !throughmode) + if (lmode) WRITE(p, " Out.v_color1 = float3(0.0);\n"); } if (enableFog) { @@ -503,9 +503,9 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { if (lmode) { WRITE(p, " Out.v_color0 = clamp(lightSum0, 0.0, 1.0);\n"); // v_color1 only exists when lmode = 1. - if (specularIsZero && !throughmode) { + if (specularIsZero) { WRITE(p, " Out.v_color1 = float3(0, 0, 0);\n"); - } else if (!throughmode) { + } else { WRITE(p, " Out.v_color1 = clamp(lightSum1, 0.0, 1.0);\n"); } } else { @@ -522,7 +522,7 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) { } else { WRITE(p, " Out.v_color0 = u_matambientalpha;\n"); } - if (lmode && !throughmode) + if (lmode) WRITE(p, " Out.v_color1 = float3(0, 0, 0);\n"); } diff --git a/GPU/GLES/VertexShaderGenerator.cpp b/GPU/GLES/VertexShaderGenerator.cpp index 6203c0cf76..acf8ae11d0 100644 --- a/GPU/GLES/VertexShaderGenerator.cpp +++ b/GPU/GLES/VertexShaderGenerator.cpp @@ -214,7 +214,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf boneWeightDecl = boneWeightInDecl; } - bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); + bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !gstate.isModeThrough(); bool doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear(); bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX; bool doShadeMapping = gstate.getUVGenMode() == GE_TEXMAP_ENVIRONMENT_MAP; @@ -264,7 +264,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf } if (hasColor) { WRITE(p, "%s lowp vec4 color0;\n", attribute); - if (lmode && !useHWTransform && !throughmode) // only software transform supplies color1 as vertex data + if (lmode && !useHWTransform) // only software transform supplies color1 as vertex data WRITE(p, "%s lowp vec3 color1;\n", attribute); } @@ -337,7 +337,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf } WRITE(p, "%s %s lowp vec4 v_color0;\n", shading, varying); - if (lmode && !throughmode) { + if (lmode) { WRITE(p, "%s %s lowp vec3 v_color1;\n", shading, varying); } if (doTexture) { @@ -370,11 +370,11 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf } if (hasColor) { WRITE(p, " v_color0 = color0;\n"); - if (lmode && !throughmode) + if (lmode) WRITE(p, " v_color1 = color1;\n"); } else { WRITE(p, " v_color0 = u_matambientalpha;\n"); - if (lmode && !throughmode) + if (lmode) WRITE(p, " v_color1 = vec3(0.0);\n"); } if (enableFog) { @@ -584,9 +584,9 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf if (lmode) { WRITE(p, " v_color0 = clamp(lightSum0, 0.0, 1.0);\n"); // v_color1 only exists when lmode = 1. - if (specularIsZero && !throughmode) { + if (specularIsZero) { WRITE(p, " v_color1 = vec3(0.0);\n"); - } else if (!throughmode) { + } else { WRITE(p, " v_color1 = clamp(lightSum1, 0.0, 1.0);\n"); } } else { @@ -603,7 +603,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf } else { WRITE(p, " v_color0 = u_matambientalpha;\n"); } - if (lmode && !throughmode) + if (lmode) WRITE(p, " v_color1 = vec3(0.0);\n"); }