mirror of https://github.com/PCSX2/pcsx2.git
glsl: disable computing of extra alpha coeff in SW blending
Hum, I'm curious of the impact to enable only this code when it is actually used.
This commit is contained in:
parent
784822a5c2
commit
e3751f6cd9
|
@ -35,7 +35,9 @@ in SHADER
|
||||||
|
|
||||||
// Same buffer but 2 colors for dual source blending
|
// Same buffer but 2 colors for dual source blending
|
||||||
layout(location = 0, index = 0) out vec4 SV_Target0;
|
layout(location = 0, index = 0) out vec4 SV_Target0;
|
||||||
|
#if !SW_BLEND
|
||||||
layout(location = 0, index = 1) out vec4 SV_Target1;
|
layout(location = 0, index = 1) out vec4 SV_Target1;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_BINDLESS_TEX
|
#ifdef ENABLE_BINDLESS_TEX
|
||||||
layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;
|
layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;
|
||||||
|
@ -218,6 +220,7 @@ mat4 sample_4p(uvec4 u)
|
||||||
|
|
||||||
vec4 sample_color(vec2 st, float q)
|
vec4 sample_color(vec2 st, float q)
|
||||||
{
|
{
|
||||||
|
//FIXME: maybe we can set gl_Position.w = q in VS
|
||||||
#if (PS_FST == 0)
|
#if (PS_FST == 0)
|
||||||
st /= q;
|
st /= q;
|
||||||
#endif
|
#endif
|
||||||
|
@ -287,6 +290,7 @@ vec4 sample_color(vec2 st, float q)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME Precompute the factor 255/128 in VS
|
||||||
#ifndef SUBROUTINE_GL40
|
#ifndef SUBROUTINE_GL40
|
||||||
vec4 tfx(vec4 t, vec4 c)
|
vec4 tfx(vec4 t, vec4 c)
|
||||||
{
|
{
|
||||||
|
@ -552,17 +556,29 @@ void ps_main()
|
||||||
c.rb = c.rr;
|
c.rb = c.rr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// FIXME precompute my_TA & 0x80
|
||||||
|
|
||||||
// Write GA part. Mask will take care of the correct destination
|
// Write GA part. Mask will take care of the correct destination
|
||||||
|
// Note: GLSL 4.50/GL_EXT_shader_integer_mix support a mix instruction to select a component\n"
|
||||||
|
// However Nvidia emulate it with an if (at least on kepler arch) ...\n"
|
||||||
#if PS_READ_BA
|
#if PS_READ_BA
|
||||||
if (bool(denorm_c.a & 0x80u))
|
if (bool(denorm_c.a & 0x80u))
|
||||||
c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);
|
c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);
|
||||||
else
|
else
|
||||||
c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);
|
c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if (bool(denorm_c.g & 0x80u))
|
if (bool(denorm_c.g & 0x80u))
|
||||||
c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);
|
c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);
|
||||||
else
|
else
|
||||||
c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);
|
c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);
|
||||||
|
|
||||||
|
// Nice idea but step/mix requires 4 instructions
|
||||||
|
// set / trunc / I2F / Mad
|
||||||
|
//
|
||||||
|
// float sel = step(128.0f/255.0f, c.g);
|
||||||
|
// vec2 c_shuffle = vec2((denorm_c.gg & 0x7Fu) | (denorm_TA & 0x80u)) / 255.0f;
|
||||||
|
// c.ga = mix(c_shuffle.xx, c_shuffle.yy, sel);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -601,7 +617,9 @@ void ps_main()
|
||||||
ps_fbmask(c);
|
ps_fbmask(c);
|
||||||
|
|
||||||
SV_Target0 = c;
|
SV_Target0 = c;
|
||||||
|
#if !SW_BLEND
|
||||||
SV_Target1 = vec4(alpha_blend);
|
SV_Target1 = vec4(alpha_blend);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -928,7 +928,9 @@ static const char* tfx_fs_all_glsl =
|
||||||
"\n"
|
"\n"
|
||||||
"// Same buffer but 2 colors for dual source blending\n"
|
"// Same buffer but 2 colors for dual source blending\n"
|
||||||
"layout(location = 0, index = 0) out vec4 SV_Target0;\n"
|
"layout(location = 0, index = 0) out vec4 SV_Target0;\n"
|
||||||
|
"#if !SW_BLEND\n"
|
||||||
"layout(location = 0, index = 1) out vec4 SV_Target1;\n"
|
"layout(location = 0, index = 1) out vec4 SV_Target1;\n"
|
||||||
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#ifdef ENABLE_BINDLESS_TEX\n"
|
"#ifdef ENABLE_BINDLESS_TEX\n"
|
||||||
"layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n"
|
"layout(bindless_sampler, location = 0) uniform sampler2D TextureSampler;\n"
|
||||||
|
@ -1111,6 +1113,7 @@ static const char* tfx_fs_all_glsl =
|
||||||
"\n"
|
"\n"
|
||||||
"vec4 sample_color(vec2 st, float q)\n"
|
"vec4 sample_color(vec2 st, float q)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
" //FIXME: maybe we can set gl_Position.w = q in VS\n"
|
||||||
"#if (PS_FST == 0)\n"
|
"#if (PS_FST == 0)\n"
|
||||||
" st /= q;\n"
|
" st /= q;\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
|
@ -1180,6 +1183,7 @@ 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"
|
||||||
"#ifndef SUBROUTINE_GL40\n"
|
"#ifndef SUBROUTINE_GL40\n"
|
||||||
"vec4 tfx(vec4 t, vec4 c)\n"
|
"vec4 tfx(vec4 t, vec4 c)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -1445,17 +1449,29 @@ static const char* tfx_fs_all_glsl =
|
||||||
" c.rb = c.rr;\n"
|
" c.rb = c.rr;\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" // FIXME precompute my_TA & 0x80\n"
|
||||||
|
"\n"
|
||||||
" // Write GA part. Mask will take care of the correct destination\n"
|
" // Write GA part. Mask will take care of the correct destination\n"
|
||||||
|
" // Note: GLSL 4.50/GL_EXT_shader_integer_mix support a mix instruction to select a component\\n\"\n"
|
||||||
|
" // However Nvidia emulate it with an if (at least on kepler arch) ...\\n\"\n"
|
||||||
"#if PS_READ_BA\n"
|
"#if PS_READ_BA\n"
|
||||||
" if (bool(denorm_c.a & 0x80u))\n"
|
" if (bool(denorm_c.a & 0x80u))\n"
|
||||||
" c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);\n"
|
" c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);\n"
|
||||||
" else\n"
|
" else\n"
|
||||||
" c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);\n"
|
" c.ga = vec2(float((denorm_c.a & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);\n"
|
||||||
|
"\n"
|
||||||
"#else\n"
|
"#else\n"
|
||||||
" if (bool(denorm_c.g & 0x80u))\n"
|
" if (bool(denorm_c.g & 0x80u))\n"
|
||||||
" c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);\n"
|
" c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.y & 0x80u)) / 255.0f);\n"
|
||||||
" else\n"
|
" else\n"
|
||||||
" c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);\n"
|
" c.ga = vec2(float((denorm_c.g & 0x7Fu) | (denorm_TA.x & 0x80u)) / 255.0f);\n"
|
||||||
|
"\n"
|
||||||
|
" // Nice idea but step/mix requires 4 instructions\n"
|
||||||
|
" // set / trunc / I2F / Mad\n"
|
||||||
|
" //\n"
|
||||||
|
" // float sel = step(128.0f/255.0f, c.g);\n"
|
||||||
|
" // vec2 c_shuffle = vec2((denorm_c.gg & 0x7Fu) | (denorm_TA & 0x80u)) / 255.0f;\n"
|
||||||
|
" // c.ga = mix(c_shuffle.xx, c_shuffle.yy, sel);\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
|
@ -1494,7 +1510,9 @@ static const char* tfx_fs_all_glsl =
|
||||||
" ps_fbmask(c);\n"
|
" ps_fbmask(c);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" SV_Target0 = c;\n"
|
" SV_Target0 = c;\n"
|
||||||
|
"#if !SW_BLEND\n"
|
||||||
" SV_Target1 = vec4(alpha_blend);\n"
|
" SV_Target1 = vec4(alpha_blend);\n"
|
||||||
|
"#endif\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
|
|
Loading…
Reference in New Issue