mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-10-11 22:49:56 +00:00
GS:HW: Denormalize RT color when shuffling while blending.
This commit is contained in:
@@ -1177,7 +1177,15 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy)
|
||||
As_rgba.rgb = (float3)1.0f;
|
||||
}
|
||||
|
||||
float4 RT = SW_BLEND_NEEDS_RT ? RtLoad(int2(pos_xy)) : (float4)0.0f;
|
||||
float4 RT = (float4)0.0f;
|
||||
if (SW_BLEND_NEEDS_RT)
|
||||
{
|
||||
RT = RtLoad(int2(pos_xy));
|
||||
float color_multi = PS_COLCLIP_HW ? 65535.0f : 255.0f;
|
||||
float alpha_multi = PS_RTA_CORRECTION ? 128.0f : 255.0f;
|
||||
RT.rgb = trunc(RT.rgb * color_multi + 0.1f);
|
||||
RT.a = trunc(RT.a * alpha_multi + 0.1f);
|
||||
}
|
||||
|
||||
if (PS_SHUFFLE && SW_BLEND_NEEDS_RT)
|
||||
{
|
||||
@@ -1198,9 +1206,8 @@ void ps_blend(inout float4 Color, inout float4 As_rgba, float2 pos_xy)
|
||||
}
|
||||
}
|
||||
|
||||
float Ad = PS_RTA_CORRECTION ? trunc(RT.a * 128.0f + 0.1f) / 128.0f : trunc(RT.a * 255.0f + 0.1f) / 128.0f;
|
||||
float color_multi = PS_COLCLIP_HW ? 65535.0f : 255.0f;
|
||||
float3 Cd = trunc(RT.rgb * color_multi + 0.1f);
|
||||
float Ad = RT.a / 128.0f;
|
||||
float3 Cd = RT.rgb;
|
||||
float3 Cs = Color.rgb;
|
||||
|
||||
float3 A = (PS_BLEND_A == 0) ? Cs : ((PS_BLEND_A == 1) ? Cd : (float3)0.0f);
|
||||
|
||||
@@ -1026,18 +1026,24 @@ float As = As_rgba.a;
|
||||
|
||||
#if SW_BLEND_NEEDS_RT
|
||||
vec4 RT = sample_from_rt();
|
||||
#if PS_COLCLIP_HW
|
||||
float color_multi = 65535.0f;
|
||||
#else
|
||||
float color_multi = 255.0f;
|
||||
#endif
|
||||
#if PS_RTA_CORRECTION
|
||||
float alpha_multi = 128.0f;
|
||||
#else
|
||||
float alpha_multi = 255.0f;
|
||||
#endif
|
||||
RT.rgb = trunc(RT.rgb * color_multi + 0.1f);
|
||||
RT.a = trunc(RT.a * alpha_multi + 0.1f);
|
||||
#else
|
||||
// Not used, but we define it to make the selection below simpler.
|
||||
vec4 RT = vec4(0.0f);
|
||||
#endif
|
||||
|
||||
#if PS_RTA_CORRECTION
|
||||
float Ad = trunc(RT.a * 128.0f + 0.1f) / 128.0f;
|
||||
#else
|
||||
float Ad = trunc(RT.a * 255.0f + 0.1f) / 128.0f;
|
||||
#endif
|
||||
|
||||
#if PS_SHUFFLE && SW_BLEND_NEEDS_RT
|
||||
#if PS_SHUFFLE && SW_BLEND_NEEDS_RT
|
||||
uvec4 denorm_rt = uvec4(RT);
|
||||
#if (PS_PROCESS_BA & SHUFFLE_WRITE)
|
||||
RT.r = float((denorm_rt.b << 3) & 0xF8u);
|
||||
@@ -1050,14 +1056,10 @@ float As = As_rgba.a;
|
||||
RT.b = float((denorm_rt.g << 1) & 0xF8u);
|
||||
RT.a = float(denorm_rt.g & 0x80u);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Let the compiler do its jobs !
|
||||
#if PS_COLCLIP_HW == 1
|
||||
vec3 Cd = trunc(RT.rgb * 65535.0f);
|
||||
#else
|
||||
vec3 Cd = trunc(RT.rgb * 255.0f + 0.1f);
|
||||
#endif
|
||||
float Ad = RT.a / 128.0f;
|
||||
vec3 Cd = RT.rgb;
|
||||
vec3 Cs = Color.rgb;
|
||||
|
||||
#if PS_BLEND_A == 0
|
||||
|
||||
@@ -1544,20 +1544,26 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba)
|
||||
As_rgba.rgb = vec3(1.0f);
|
||||
#endif
|
||||
|
||||
#if PS_FEEDBACK_LOOP_IS_NEEDED_RT
|
||||
#if SW_BLEND_NEEDS_RT
|
||||
vec4 RT = sample_from_rt();
|
||||
#if PS_COLCLIP_HW
|
||||
float color_multi = 65535.0f;
|
||||
#else
|
||||
float color_multi = 255.0f;
|
||||
#endif
|
||||
#if PS_RTA_CORRECTION
|
||||
float alpha_multi = 128.0f;
|
||||
#else
|
||||
float alpha_multi = 255.0f;
|
||||
#endif
|
||||
RT.rgb = trunc(RT.rgb * color_multi + 0.1f);
|
||||
RT.a = trunc(RT.a * alpha_multi + 0.1f);
|
||||
#else
|
||||
// Not used, but we define it to make the selection below simpler.
|
||||
vec4 RT = vec4(0.0f);
|
||||
#endif
|
||||
|
||||
#if PS_RTA_CORRECTION
|
||||
float Ad = trunc(RT.a * 128.0f + 0.1f) / 128.0f;
|
||||
#else
|
||||
float Ad = trunc(RT.a * 255.0f + 0.1f) / 128.0f;
|
||||
#endif
|
||||
|
||||
#if PS_SHUFFLE && PS_FEEDBACK_LOOP_IS_NEEDED_RT
|
||||
#if PS_SHUFFLE && SW_BLEND_NEEDS_RT
|
||||
uvec4 denorm_rt = uvec4(RT);
|
||||
#if (PS_PROCESS_BA & SHUFFLE_WRITE)
|
||||
RT.r = float((denorm_rt.b << 3) & 0xF8u);
|
||||
@@ -1572,12 +1578,8 @@ void ps_blend(inout vec4 Color, inout vec4 As_rgba)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Let the compiler do its jobs !
|
||||
#if PS_COLCLIP_HW == 1
|
||||
vec3 Cd = trunc(RT.rgb * 65535.0f);
|
||||
#else
|
||||
vec3 Cd = trunc(RT.rgb * 255.0f + 0.1f);
|
||||
#endif
|
||||
float Ad = RT.a / 128.0f;
|
||||
vec3 Cd = RT.rgb;
|
||||
vec3 Cs = Color.rgb;
|
||||
|
||||
#if PS_BLEND_A == 0
|
||||
|
||||
@@ -1393,28 +1393,37 @@ struct PSMain
|
||||
As_rgba.rgb = float3(1.f);
|
||||
}
|
||||
|
||||
float Ad = PS_RTA_CORRECTION ? trunc(current_color.a * 128.1f) / 128.f : trunc(current_color.a * 255.1f) / 128.f;
|
||||
|
||||
if (PS_SHUFFLE && NEEDS_RT)
|
||||
float4 RT = float4(0.f);
|
||||
if (NEEDS_RT_FOR_BLEND)
|
||||
{
|
||||
uint4 denorm_rt = uint4(current_color);
|
||||
RT = current_color;
|
||||
float color_multi = PS_COLCLIP_HW ? 65535.f : 255.f;
|
||||
float alpha_multi = PS_RTA_CORRECTION ? 128.f : 255.f;
|
||||
RT.rgb = trunc(RT.rgb * color_multi + 0.1f);
|
||||
RT.a = trunc(RT.a * alpha_multi + 0.1f);
|
||||
}
|
||||
|
||||
if (PS_SHUFFLE && NEEDS_RT_FOR_BLEND)
|
||||
{
|
||||
uint4 denorm_rt = uint4(RT);
|
||||
if (PS_PROCESS_BA & SHUFFLE_WRITE)
|
||||
{
|
||||
current_color.r = float((denorm_rt.b << 3) & 0xF8);
|
||||
current_color.g = float(((denorm_rt.b >> 2) & 0x38) | ((denorm_rt.a << 6) & 0xC0));
|
||||
current_color.b = float((denorm_rt.a << 1) & 0xF8);
|
||||
current_color.a = float(denorm_rt.a & 0x80);
|
||||
RT.r = float((denorm_rt.b << 3) & 0xF8);
|
||||
RT.g = float(((denorm_rt.b >> 2) & 0x38) | ((denorm_rt.a << 6) & 0xC0));
|
||||
RT.b = float((denorm_rt.a << 1) & 0xF8);
|
||||
RT.a = float(denorm_rt.a & 0x80);
|
||||
}
|
||||
else
|
||||
{
|
||||
current_color.r = float((denorm_rt.r << 3) & 0xF8);
|
||||
current_color.g = float(((denorm_rt.r >> 2) & 0x38) | ((denorm_rt.g << 6) & 0xC0));
|
||||
current_color.b = float((denorm_rt.g << 1) & 0xF8);
|
||||
current_color.a = float(denorm_rt.g & 0x80);
|
||||
RT.r = float((denorm_rt.r << 3) & 0xF8);
|
||||
RT.g = float(((denorm_rt.r >> 2) & 0x38) | ((denorm_rt.g << 6) & 0xC0));
|
||||
RT.b = float((denorm_rt.g << 1) & 0xF8);
|
||||
RT.a = float(denorm_rt.g & 0x80);
|
||||
}
|
||||
}
|
||||
float multi = PS_COLCLIP_HW ? 65535.0 : 255.5;
|
||||
float3 Cd = trunc(current_color.rgb * multi);
|
||||
|
||||
float Ad = RT.a / 128.f;
|
||||
float3 Cd = RT.rgb;
|
||||
float3 Cs = Color.rgb;
|
||||
|
||||
float3 A = pick(PS_BLEND_A, Cs, Cd, float3(0.f));
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
/// Version number for GS and other shaders. Increment whenever any of the contents of the
|
||||
/// shaders change, to invalidate the cache.
|
||||
static constexpr u32 SHADER_CACHE_VERSION = 117; // Last changed in PR 15005
|
||||
static constexpr u32 SHADER_CACHE_VERSION = 118; // Last changed in PR 14987
|
||||
|
||||
Reference in New Issue
Block a user