mirror of https://github.com/PCSX2/pcsx2.git
glsl: rewrite tfx function to ease future update
No need to put lots of ifdef, compiler will optimize everything It increases a bit the readability
This commit is contained in:
parent
ea9e608288
commit
5f247a6e16
|
@ -277,30 +277,30 @@ vec4 sample_color(vec2 st, float q)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME Precompute the factor 255/128 in VS
|
|
||||||
vec4 tfx(vec4 t, vec4 c)
|
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_TFX == 0)
|
||||||
if(PS_TCC != 0)
|
c_out = FxT;
|
||||||
c_out = c * t * 255.0f / 128.0f;
|
|
||||||
else
|
|
||||||
c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f;
|
|
||||||
#elif (PS_TFX == 1)
|
#elif (PS_TFX == 1)
|
||||||
if(PS_TCC != 0)
|
c_out = t;
|
||||||
c_out = t;
|
|
||||||
else
|
|
||||||
c_out.rgb = t.rgb;
|
|
||||||
#elif (PS_TFX == 2)
|
#elif (PS_TFX == 2)
|
||||||
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 + c.a;
|
||||||
if(PS_TCC != 0)
|
|
||||||
c_out.a += t.a;
|
|
||||||
#elif (PS_TFX == 3)
|
#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)
|
#if (PS_TCC == 0)
|
||||||
c_out.a = t.a;
|
c_out.a = c.a;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return c_out;
|
return c_out;
|
||||||
|
|
|
@ -1138,30 +1138,30 @@ static const char* tfx_fs_all_glsl =
|
||||||
" return t;\n"
|
" return t;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"// FIXME Precompute the factor 255/128 in VS\n"
|
|
||||||
"vec4 tfx(vec4 t, vec4 c)\n"
|
"vec4 tfx(vec4 t, vec4 c)\n"
|
||||||
"{\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_TFX == 0)\n"
|
||||||
" if(PS_TCC != 0)\n"
|
" c_out = FxT;\n"
|
||||||
" c_out = c * t * 255.0f / 128.0f;\n"
|
|
||||||
" else\n"
|
|
||||||
" c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f;\n"
|
|
||||||
"#elif (PS_TFX == 1)\n"
|
"#elif (PS_TFX == 1)\n"
|
||||||
" if(PS_TCC != 0)\n"
|
" c_out = t;\n"
|
||||||
" c_out = t;\n"
|
|
||||||
" else\n"
|
|
||||||
" c_out.rgb = t.rgb;\n"
|
|
||||||
"#elif (PS_TFX == 2)\n"
|
"#elif (PS_TFX == 2)\n"
|
||||||
" c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a;\n"
|
" c_out.rgb = FxT.rgb + c.a;\n"
|
||||||
"\n"
|
" c_out.a = t.a + c.a;\n"
|
||||||
" if(PS_TCC != 0)\n"
|
|
||||||
" c_out.a += t.a;\n"
|
|
||||||
"#elif (PS_TFX == 3)\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"
|
"\n"
|
||||||
" if(PS_TCC != 0)\n"
|
"#if (PS_TCC == 0)\n"
|
||||||
" c_out.a = t.a;\n"
|
" c_out.a = c.a;\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
" return c_out;\n"
|
" return c_out;\n"
|
||||||
|
|
Loading…
Reference in New Issue