From 89d5e5637c82c5cfd03722b6703849437c3c15c3 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 24 Apr 2015 18:01:25 +0200 Subject: [PATCH] glsl: use an explicit cast insead of notEqual function If the compiler didn't optimize the code, it will be a bit faster --- plugins/GSdx/res/glsl/tfx_fs.glsl | 6 ++---- plugins/GSdx/res/glsl_source.h | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/GSdx/res/glsl/tfx_fs.glsl b/plugins/GSdx/res/glsl/tfx_fs.glsl index 818d15b201..4b5e414e47 100644 --- a/plugins/GSdx/res/glsl/tfx_fs.glsl +++ b/plugins/GSdx/res/glsl/tfx_fs.glsl @@ -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 } diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index ab76369ca7..fdc33c0ca7 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -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"