GS-hw: Move PABE shader bit to the top of sw blending.

Early return when there is no sw blending, no need to run the blend code.
Optimization.
This commit is contained in:
lightningterror 2022-01-08 18:43:28 +01:00
parent cf2b6a895f
commit 3c92054a6e
3 changed files with 27 additions and 17 deletions

View File

@ -727,6 +727,14 @@ void ps_blend(inout float4 Color, float As, float2 pos_xy)
{ {
if (SW_BLEND) if (SW_BLEND)
{ {
// PABE
if (PS_PABE)
{
// No blending so early exit
if (As < 1.0f)
return;
}
float4 RT = trunc(RtSampler.Load(int3(pos_xy, 0)) * 255.0f + 0.1f); float4 RT = trunc(RtSampler.Load(int3(pos_xy, 0)) * 255.0f + 0.1f);
float Ad = (PS_DFMT == FMT_24) ? 1.0f : RT.a / 128.0f; float Ad = (PS_DFMT == FMT_24) ? 1.0f : RT.a / 128.0f;
@ -744,10 +752,6 @@ void ps_blend(inout float4 Color, float As, float2 pos_xy)
C = min(C, (float)1.0f); C = min(C, (float)1.0f);
Color.rgb = (PS_BLEND_A == PS_BLEND_B) ? D : trunc(((A - B) * C) + D); Color.rgb = (PS_BLEND_A == PS_BLEND_B) ? D : trunc(((A - B) * C) + D);
// PABE
if (PS_PABE)
Color.rgb = (As >= 1.0f) ? Color.rgb : Cs;
} }
} }

View File

@ -656,6 +656,14 @@ void ps_color_clamp_wrap(inout vec3 C)
void ps_blend(inout vec4 Color, float As) void ps_blend(inout vec4 Color, float As)
{ {
#if SW_BLEND #if SW_BLEND
// PABE
#if PS_PABE
// No blending so early exit
if (As < 1.0f)
return;
#endif
vec4 RT = trunc(texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0) * 255.0f + 0.1f); vec4 RT = trunc(texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0) * 255.0f + 0.1f);
#if PS_DFMT == FMT_24 #if PS_DFMT == FMT_24
@ -713,11 +721,6 @@ void ps_blend(inout vec4 Color, float As)
Color.rgb = trunc((A - B) * C + D); Color.rgb = trunc((A - B) * C + D);
#endif #endif
// PABE
#if PS_PABE
Color.rgb = (As >= 1.0f) ? Color.rgb : Cs;
#endif
#endif #endif
} }

View File

@ -989,11 +989,19 @@ void ps_color_clamp_wrap(inout vec3 C)
void ps_blend(inout vec4 Color, float As) void ps_blend(inout vec4 Color, float As)
{ {
#if SW_BLEND #if SW_BLEND
// PABE
#if PS_PABE
// No blending so early exit
if (As < 1.0f)
return;
#endif
#if PS_FEEDBACK_LOOP_IS_NEEDED #if PS_FEEDBACK_LOOP_IS_NEEDED
vec4 RT = trunc(subpassLoad(RtSampler) * 255.0f + 0.1f); vec4 RT = trunc(subpassLoad(RtSampler) * 255.0f + 0.1f);
#else #else
// Not used, but we define it to make the selection below simpler. // Not used, but we define it to make the selection below simpler.
vec4 RT = vec4(0.0f); vec4 RT = vec4(0.0f);
#endif #endif
#if PS_DFMT == FMT_24 #if PS_DFMT == FMT_24
@ -1051,11 +1059,6 @@ void ps_blend(inout vec4 Color, float As)
Color.rgb = trunc((A - B) * C + D); Color.rgb = trunc((A - B) * C + D);
#endif #endif
// PABE
#if PS_PABE
Color.rgb = (As >= 1.0f) ? Color.rgb : Cs;
#endif
#endif #endif
} }