diff --git a/plugins/GSdx/res/glsl/tfx_fs.glsl b/plugins/GSdx/res/glsl/tfx_fs.glsl index 0567d52c92..24cd3cd324 100644 --- a/plugins/GSdx/res/glsl/tfx_fs.glsl +++ b/plugins/GSdx/res/glsl/tfx_fs.glsl @@ -277,30 +277,30 @@ vec4 sample_color(vec2 st, float q) return t; } -// FIXME Precompute the factor 255/128 in VS vec4 tfx(vec4 t, vec4 c) { - vec4 c_out = c; + vec4 c_out; + // Note: It will be possible to precompute the factor 255/128 in the VS/GS + // However, I didn't see real speedup and it might make the code more difficult + // to support proper rounding + vec4 FxT = c * t * 255.0f / 128.0f; + #if (PS_TFX == 0) - if(PS_TCC != 0) - c_out = c * t * 255.0f / 128.0f; - else - c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f; + c_out = FxT; #elif (PS_TFX == 1) - if(PS_TCC != 0) - c_out = t; - else - c_out.rgb = t.rgb; + c_out = t; #elif (PS_TFX == 2) - c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a; - - if(PS_TCC != 0) - c_out.a += t.a; + c_out.rgb = FxT.rgb + c.a; + c_out.a = t.a + c.a; #elif (PS_TFX == 3) - c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a; + c_out.rgb = FxT.rgb + c.a; + c_out.a = t.a; +#else + c_out = c; +#endif - if(PS_TCC != 0) - c_out.a = t.a; +#if (PS_TCC == 0) + c_out.a = c.a; #endif return c_out; diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 8df29ac112..49c0e6234a 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -1138,30 +1138,30 @@ static const char* tfx_fs_all_glsl = " return t;\n" "}\n" "\n" - "// FIXME Precompute the factor 255/128 in VS\n" "vec4 tfx(vec4 t, vec4 c)\n" "{\n" - " vec4 c_out = c;\n" + " vec4 c_out;\n" + " // Note: It will be possible to precompute the factor 255/128 in the VS/GS\n" + " // However, I didn't see real speedup and it might make the code more difficult\n" + " // to support proper rounding\n" + " vec4 FxT = c * t * 255.0f / 128.0f;\n" + "\n" "#if (PS_TFX == 0)\n" - " if(PS_TCC != 0)\n" - " c_out = c * t * 255.0f / 128.0f;\n" - " else\n" - " c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f;\n" + " c_out = FxT;\n" "#elif (PS_TFX == 1)\n" - " if(PS_TCC != 0)\n" - " c_out = t;\n" - " else\n" - " c_out.rgb = t.rgb;\n" + " c_out = t;\n" "#elif (PS_TFX == 2)\n" - " c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a;\n" - "\n" - " if(PS_TCC != 0)\n" - " c_out.a += t.a;\n" + " c_out.rgb = FxT.rgb + c.a;\n" + " c_out.a = t.a + c.a;\n" "#elif (PS_TFX == 3)\n" - " c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a;\n" + " c_out.rgb = FxT.rgb + c.a;\n" + " c_out.a = t.a;\n" + "#else\n" + " c_out = c;\n" + "#endif\n" "\n" - " if(PS_TCC != 0)\n" - " c_out.a = t.a;\n" + "#if (PS_TCC == 0)\n" + " c_out.a = c.a;\n" "#endif\n" "\n" " return c_out;\n"