glsl: use an explicit cast insead of notEqual function

If the compiler didn't optimize the code, it will be a bit faster
This commit is contained in:
Gregory Hainaut 2015-04-24 18:01:25 +02:00
parent 56836561f4
commit 89d5e5637c
2 changed files with 4 additions and 8 deletions

View File

@ -283,12 +283,10 @@ vec4 sample_color(vec2 st, float q)
// PERF: see the impact of the exansion before/after the interpolation
for (int i = 0; i < 4; i++)
{
// FIXME GLSL any only support bvec so try to mix it with notEqual
bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );
#if ((PS_FMT & ~FMT_PAL) == FMT_24)
c[i].a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
c[i].a = ( (PS_AEM == 0) || any(bvec3(c[i].rgb)) ) ? TA.x : 0.0f;
#elif ((PS_FMT & ~FMT_PAL) == FMT_16)
c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(bvec3(c[i].rgb)) ) ? TA.x : 0.0f;
#endif
}

View File

@ -1034,12 +1034,10 @@ static const char* tfx_fs_all_glsl =
" // PERF: see the impact of the exansion before/after the interpolation\n"
" for (int i = 0; i < 4; i++)\n"
" {\n"
" // FIXME GLSL any only support bvec so try to mix it with notEqual\n"
" bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );\n"
"#if ((PS_FMT & ~FMT_PAL) == FMT_24)\n"
" c[i].a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" c[i].a = ( (PS_AEM == 0) || any(bvec3(c[i].rgb)) ) ? TA.x : 0.0f;\n"
"#elif ((PS_FMT & ~FMT_PAL) == FMT_16)\n"
" c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(bvec3(c[i].rgb)) ) ? TA.x : 0.0f;\n"
"#endif\n"
" }\n"
"\n"