mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-10-11 22:49:56 +00:00
GS: Clean up feedback shader flags
No more checking 3 different flags to decide one thing
This commit is contained in:
committed by
lightningterror
parent
95b50e7f81
commit
c1aa19c306
@@ -32,6 +32,7 @@
|
||||
#define AFAIL_ZB_ONLY 2
|
||||
#define AFAIL_RGB_ONLY 3
|
||||
#define AFAIL_RGB_ONLY_DSB 4
|
||||
#define AFAIL_RGB_ONLY_SW_Z 5
|
||||
#endif
|
||||
|
||||
#ifndef PS_ATST_NONE
|
||||
@@ -93,7 +94,6 @@
|
||||
#define PS_DITHER_ADJUST 0
|
||||
#define PS_ZCLAMP 0
|
||||
#define PS_ZFLOOR 0
|
||||
#define PS_ZWRITE 0
|
||||
#define PS_SCANMSK 0
|
||||
#define PS_AUTOMATIC_LOD 0
|
||||
#define PS_MANUAL_LOD 0
|
||||
@@ -102,15 +102,16 @@
|
||||
#define PS_NO_COLOR1 0
|
||||
#define PS_DATE 0
|
||||
#define PS_TEX_IS_FB 0
|
||||
#define PS_COLOR_FEEDBACK 0
|
||||
#define PS_DEPTH_FEEDBACK 0
|
||||
#endif
|
||||
|
||||
#define SW_BLEND (PS_BLEND_A || PS_BLEND_B || PS_BLEND_D)
|
||||
#define SW_BLEND_NEEDS_RT (SW_BLEND && (PS_BLEND_A == 1 || PS_BLEND_B == 1 || PS_BLEND_C == 1 || PS_BLEND_D == 1))
|
||||
#define SW_AD_TO_HW (PS_BLEND_C == 1 && PS_A_MASKED)
|
||||
#define AFAIL_NEEDS_RT (PS_AFAIL == AFAIL_ZB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#define AFAIL_NEEDS_DEPTH (PS_AFAIL == AFAIL_FB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#define NEEDS_RT_FOR_AFAIL (PS_AFAIL == AFAIL_ZB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
#define NEEDS_DEPTH_FOR_AFAIL (PS_AFAIL == AFAIL_FB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
#define NEEDS_DEPTH_FOR_ZTST (PS_ZTST == ZTST_GEQUAL || PS_ZTST == ZTST_GREATER)
|
||||
#define SW_DEPTH (NEEDS_DEPTH_FOR_AFAIL || NEEDS_DEPTH_FOR_ZTST)
|
||||
#define ZWRITE (PS_ZFLOOR || PS_ZCLAMP || SW_DEPTH)
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
@@ -168,16 +169,16 @@ struct PS_OUTPUT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if PS_ZWRITE
|
||||
#if ZWRITE
|
||||
// In DX12 we do depth feedback loops with a color copy.
|
||||
#if PS_DEPTH_FEEDBACK && PS_NO_COLOR1 && DX12
|
||||
#if SW_DEPTH && PS_NO_COLOR1 && DX12
|
||||
#if NUM_RTS > 0
|
||||
float depth_color : SV_Target1;
|
||||
#else
|
||||
float depth_color : SV_Target0;
|
||||
#endif
|
||||
#endif
|
||||
#if PS_HAS_CONSERVATIVE_DEPTH && !PS_DEPTH_FEEDBACK
|
||||
#if PS_HAS_CONSERVATIVE_DEPTH && !SW_DEPTH
|
||||
float depth : SV_DepthLessEqual;
|
||||
#else
|
||||
float depth : SV_Depth;
|
||||
@@ -1067,16 +1068,13 @@ PS_OUTPUT ps_main(PS_INPUT input)
|
||||
input.p.z = floor(input.p.z * exp2(32.0f)) * exp2(-32.0f);
|
||||
#endif
|
||||
|
||||
#if PS_DEPTH_FEEDBACK && (PS_ZTST == ZTST_GEQUAL || PS_ZTST == ZTST_GREATER)
|
||||
#if PS_ZTST == ZTST_GEQUAL
|
||||
if (input.p.z < DepthTexture.Load(int3(input.p.xy, 0)).r)
|
||||
discard;
|
||||
#elif PS_ZTST == ZTST_GREATER
|
||||
if (input.p.z <= DepthTexture.Load(int3(input.p.xy, 0)).r)
|
||||
discard;
|
||||
#endif
|
||||
#endif // PS_ZTST
|
||||
|
||||
#if PS_ZTST == ZTST_GEQUAL
|
||||
if (input.p.z < DepthTexture.Load(int3(input.p.xy, 0)).r)
|
||||
discard;
|
||||
#elif PS_ZTST == ZTST_GREATER
|
||||
if (input.p.z <= DepthTexture.Load(int3(input.p.xy, 0)).r)
|
||||
discard;
|
||||
#endif
|
||||
float4 C = ps_color(input);
|
||||
|
||||
#if PS_FIXED_ONE_A
|
||||
@@ -1257,19 +1255,17 @@ PS_OUTPUT ps_main(PS_INPUT input)
|
||||
#endif
|
||||
|
||||
// Alpha test with feedback
|
||||
#if (PS_AFAIL == AFAIL_FB_ONLY) && PS_DEPTH_FEEDBACK && PS_ZWRITE
|
||||
#if PS_AFAIL == AFAIL_FB_ONLY
|
||||
if (!atst_pass)
|
||||
input.p.z = DepthTexture.Load(int3(input.p.xy, 0)).r;
|
||||
#elif (PS_AFAIL == AFAIL_ZB_ONLY) && PS_COLOR_FEEDBACK
|
||||
#elif PS_AFAIL == AFAIL_ZB_ONLY
|
||||
if (!atst_pass)
|
||||
output.c0 = RtTexture.Load(int3(input.p.xy, 0));
|
||||
#elif (PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#elif PS_AFAIL == AFAIL_RGB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z
|
||||
if (!atst_pass)
|
||||
{
|
||||
#if PS_COLOR_FEEDBACK
|
||||
output.c0.a = RtTexture.Load(int3(input.p.xy, 0)).a;
|
||||
#endif
|
||||
#if PS_DEPTH_FEEDBACK && PS_ZWRITE
|
||||
output.c0.a = RtTexture.Load(int3(input.p.xy, 0)).a;
|
||||
#if PS_AFAIL == AFAIL_RGB_ONLY_SW_Z
|
||||
input.p.z = DepthTexture.Load(int3(input.p.xy, 0)).r;
|
||||
#endif
|
||||
}
|
||||
@@ -1283,8 +1279,8 @@ PS_OUTPUT ps_main(PS_INPUT input)
|
||||
input.p.z = min(input.p.z, MaxDepthPS);
|
||||
#endif
|
||||
|
||||
#if PS_ZWRITE
|
||||
#if PS_DEPTH_FEEDBACK && PS_NO_COLOR1 && DX12
|
||||
#if ZWRITE
|
||||
#if SW_DEPTH && PS_NO_COLOR1 && DX12
|
||||
// Output color clone for feedback as well as real depth.
|
||||
output.depth_color = input.p.z;
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define AFAIL_ZB_ONLY 2
|
||||
#define AFAIL_RGB_ONLY 3
|
||||
#define AFAIL_RGB_ONLY_DSB 4
|
||||
#define AFAIL_RGB_ONLY_SW_Z 5
|
||||
#endif
|
||||
|
||||
#ifndef PS_ATST_NONE
|
||||
@@ -46,13 +47,14 @@
|
||||
#define SW_AD_TO_HW (PS_BLEND_C == 1 && PS_A_MASKED)
|
||||
#define PS_PRIMID_INIT (PS_DATE == 1 || PS_DATE == 2)
|
||||
#define NEEDS_RT_EARLY (PS_TEX_IS_FB == 1 || PS_DATE >= 5)
|
||||
#define NEEDS_RT_FOR_AFAIL (PS_AFAIL == PS_ZB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#define NEEDS_DEPTH_FOR_AFAIL (PS_AFAIL == AFAIL_FB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#define NEEDS_RT_FOR_AFAIL (PS_AFAIL == PS_ZB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
#define NEEDS_DEPTH_FOR_AFAIL (PS_AFAIL == AFAIL_FB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
#define NEEDS_DEPTH_FOR_ZTST (PS_ZTST == ZTST_GEQUAL || PS_ZTST == ZTST_GREATER)
|
||||
|
||||
#define NEEDS_RT (NEEDS_RT_EARLY || NEEDS_RT_FOR_AFAIL || (!PS_PRIMID_INIT && (PS_FBMASK || SW_BLEND_NEEDS_RT || SW_AD_TO_HW)) || PS_COLOR_FEEDBACK)
|
||||
#define NEEDS_TEX (PS_TFX != 4)
|
||||
#define NEEDS_DEPTH (PS_DEPTH_FEEDBACK && (NEEDS_DEPTH_FOR_AFAIL || NEEDS_DEPTH_FOR_ZTST))
|
||||
#define SW_DEPTH (NEEDS_DEPTH_FOR_AFAIL || NEEDS_DEPTH_FOR_ZTST)
|
||||
#define ZWRITE (SW_DEPTH || PS_ZCLAMP || PS_ZFLOOR)
|
||||
|
||||
layout(std140, binding = 0) uniform cb21
|
||||
{
|
||||
@@ -124,7 +126,7 @@ in SHADER
|
||||
|
||||
// Depth feedback mode 2 is for depth as color.
|
||||
// Use FB fetch for the feedback if it's available.
|
||||
#if NEEDS_DEPTH && PS_NO_COLOR1 && (DEPTH_FEEDBACK_SUPPORT == 2)
|
||||
#if SW_DEPTH && PS_NO_COLOR1 && (DEPTH_FEEDBACK_SUPPORT == 2)
|
||||
#if HAS_FRAMEBUFFER_FETCH
|
||||
layout(location = 1) inout float SV_Target1;
|
||||
#else
|
||||
@@ -148,11 +150,11 @@ layout(binding = 3) uniform sampler2D img_prim_min;
|
||||
// Depth feedback mode 1 binds depth buffer directly as a texture.
|
||||
// Depth feedback mode 2 (depth as color) can use FB fetch for the feedback,
|
||||
// in which case we don't need to explicitly bind depth as a texture.
|
||||
#if (DEPTH_FEEDBACK_SUPPORT == 1 || (DEPTH_FEEDBACK_SUPPORT == 2 && !HAS_FRAMEBUFFER_FETCH)) && NEEDS_DEPTH
|
||||
#if (DEPTH_FEEDBACK_SUPPORT == 1 || (DEPTH_FEEDBACK_SUPPORT == 2 && !HAS_FRAMEBUFFER_FETCH)) && SW_DEPTH
|
||||
layout(binding = 4) uniform sampler2D DepthSampler;
|
||||
#endif
|
||||
|
||||
#if PS_ZWRITE && PS_HAS_CONSERVATIVE_DEPTH && !NEEDS_DEPTH
|
||||
#if ZWRITE && PS_HAS_CONSERVATIVE_DEPTH && !SW_DEPTH
|
||||
layout(depth_less) out float gl_FragDepth;
|
||||
#endif
|
||||
|
||||
@@ -169,7 +171,7 @@ vec4 sample_from_rt()
|
||||
|
||||
vec4 sample_from_depth()
|
||||
{
|
||||
#if !NEEDS_DEPTH
|
||||
#if !SW_DEPTH
|
||||
return vec4(0.0);
|
||||
#elif HAS_FRAMEBUFFER_FETCH && (DEPTH_FEEDBACK_SUPPORT == 2)
|
||||
return SV_Target1;
|
||||
@@ -1040,15 +1042,13 @@ void ps_main()
|
||||
input_z = floor(input_z * exp2(32.0f)) * exp2(-32.0f);
|
||||
#endif
|
||||
|
||||
#if NEEDS_DEPTH && (PS_ZTST == ZTST_GEQUAL || PS_ZTST == ZTST_GREATER)
|
||||
#if PS_ZTST == ZTST_GEQUAL
|
||||
if (input_z < sample_from_depth().r)
|
||||
discard;
|
||||
#elif PS_ZTST == ZTST_GREATER
|
||||
if (input_z <= sample_from_depth().r)
|
||||
discard;
|
||||
#endif
|
||||
#endif // PS_ZTST
|
||||
#if PS_ZTST == ZTST_GEQUAL
|
||||
if (input_z < sample_from_depth().r)
|
||||
discard;
|
||||
#elif PS_ZTST == ZTST_GREATER
|
||||
if (input_z <= sample_from_depth().r)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#if PS_SCANMSK & 2
|
||||
// fail depth test on prohibited lines
|
||||
@@ -1215,19 +1215,17 @@ void ps_main()
|
||||
#endif
|
||||
|
||||
// Alpha test with feedback
|
||||
#if (PS_AFAIL == AFAIL_FB_ONLY) && NEEDS_DEPTH && PS_ZWRITE
|
||||
#if PS_AFAIL == AFAIL_FB_ONLY
|
||||
if (!atst_pass)
|
||||
input_z = sample_from_depth().r;
|
||||
#elif (PS_AFAIL == AFAIL_ZB_ONLY) && NEEDS_RT
|
||||
#elif PS_AFAIL == AFAIL_ZB_ONLY
|
||||
if (!atst_pass)
|
||||
C = sample_from_rt();
|
||||
#elif (PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#elif (PS_AFAIL == AFAIL_RGB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
if (!atst_pass)
|
||||
{
|
||||
#if NEEDS_RT
|
||||
C.a = sample_from_rt().a;
|
||||
#endif
|
||||
#if NEEDS_DEPTH && PS_ZWRITE
|
||||
C.a = sample_from_rt().a;
|
||||
#if PS_AFAIL == AFAIL_RGB_ONLY_SW_Z
|
||||
input_z = sample_from_depth().r;
|
||||
#endif
|
||||
}
|
||||
@@ -1246,8 +1244,8 @@ void ps_main()
|
||||
input_z = min(input_z, MaxDepthPS);
|
||||
#endif
|
||||
|
||||
#if PS_ZWRITE
|
||||
#if NEEDS_DEPTH && PS_NO_COLOR1 && (DEPTH_FEEDBACK_SUPPORT == 2)
|
||||
#if ZWRITE
|
||||
#if SW_DEPTH && PS_NO_COLOR1 && (DEPTH_FEEDBACK_SUPPORT == 2)
|
||||
// Depth as color write. For depth as color feedback we write to both
|
||||
// color copy and real depth to avoid having to copy back to real depth.
|
||||
// Warning: do not write SV_Target1 until the end since the value might
|
||||
|
||||
@@ -256,6 +256,7 @@ void main()
|
||||
#define AFAIL_ZB_ONLY 2
|
||||
#define AFAIL_RGB_ONLY 3
|
||||
#define AFAIL_RGB_ONLY_DSB 4
|
||||
#define AFAIL_RGB_ONLY_SW_Z 5
|
||||
#endif
|
||||
|
||||
#ifndef PS_ATST_NONE
|
||||
@@ -310,7 +311,6 @@ void main()
|
||||
#define PS_DITHER_ADJUST 0
|
||||
#define PS_ZCLAMP 0
|
||||
#define PS_ZFLOOR 0
|
||||
#define PS_ZWRITE 0
|
||||
#define PS_SCANMSK 0
|
||||
#define PS_AUTOMATIC_LOD 0
|
||||
#define PS_MANUAL_LOD 0
|
||||
@@ -319,19 +319,18 @@ void main()
|
||||
#define PS_NO_COLOR1 0
|
||||
#define PS_DATE 0
|
||||
#define PS_TEX_IS_FB 0
|
||||
#define PS_COLOR_FEEDBACK 0
|
||||
#define PS_DEPTH_FEEDBACK 0
|
||||
#endif
|
||||
|
||||
#define SW_BLEND (PS_BLEND_A || PS_BLEND_B || PS_BLEND_D)
|
||||
#define SW_BLEND_NEEDS_RT (SW_BLEND && (PS_BLEND_A == 1 || PS_BLEND_B == 1 || PS_BLEND_C == 1 || PS_BLEND_D == 1))
|
||||
#define SW_AD_TO_HW (PS_BLEND_C == 1 && PS_A_MASKED)
|
||||
#define AFAIL_NEEDS_RT (PS_AFAIL == AFAIL_ZB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#define AFAIL_NEEDS_DEPTH (PS_AFAIL == AFAIL_FB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#define AFAIL_NEEDS_RT (PS_AFAIL == AFAIL_ZB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
#define AFAIL_NEEDS_DEPTH (PS_AFAIL == AFAIL_FB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
#define ZTST_NEEDS_DEPTH (PS_ZTST == ZTST_GEQUAL || PS_ZTST == ZTST_GREATER)
|
||||
|
||||
#define PS_FEEDBACK_LOOP_IS_NEEDED_RT (PS_TEX_IS_FB == 1 || AFAIL_NEEDS_RT || PS_FBMASK || SW_BLEND_NEEDS_RT || SW_AD_TO_HW || (PS_DATE >= 5) || PS_COLOR_FEEDBACK)
|
||||
#define PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH (PS_DEPTH_FEEDBACK && (AFAIL_NEEDS_DEPTH || ZTST_NEEDS_DEPTH))
|
||||
#define PS_FEEDBACK_LOOP_IS_NEEDED_RT (PS_TEX_IS_FB == 1 || AFAIL_NEEDS_RT || PS_FBMASK || SW_BLEND_NEEDS_RT || SW_AD_TO_HW || (PS_DATE >= 5) || AFAIL_NEEDS_RT)
|
||||
#define PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH (AFAIL_NEEDS_DEPTH || ZTST_NEEDS_DEPTH)
|
||||
#define ZWRITE (PS_ZCLAMP || PS_ZFLOOR || PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH)
|
||||
|
||||
#define NEEDS_TEX (PS_TFX != 4)
|
||||
|
||||
@@ -411,7 +410,7 @@ layout(set = 1, binding = 1) uniform texture2D Palette;
|
||||
layout(set = 1, binding = 3) uniform texture2D PrimMinTexture;
|
||||
#endif
|
||||
|
||||
#if PS_ZWRITE && !PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH
|
||||
#if ZWRITE && !PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH
|
||||
layout(depth_less) out float gl_FragDepth;
|
||||
#endif
|
||||
|
||||
@@ -1291,15 +1290,13 @@ void main()
|
||||
input_z = floor(input_z * exp2(32.0f)) * exp2(-32.0f);
|
||||
#endif
|
||||
|
||||
#if PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH && (PS_ZTST == ZTST_GEQUAL || PS_ZTST == ZTST_GREATER)
|
||||
#if PS_ZTST == ZTST_GEQUAL
|
||||
if (input_z < sample_from_depth().r)
|
||||
discard;
|
||||
#elif PS_ZTST == ZTST_GREATER
|
||||
if (input_z <= sample_from_depth().r)
|
||||
discard;
|
||||
#endif
|
||||
#endif // PS_ZTST
|
||||
#if PS_ZTST == ZTST_GEQUAL
|
||||
if (input_z < sample_from_depth().r)
|
||||
discard;
|
||||
#elif PS_ZTST == ZTST_GREATER
|
||||
if (input_z <= sample_from_depth().r)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#if PS_SCANMSK & 2
|
||||
// fail depth test on prohibited lines
|
||||
@@ -1466,19 +1463,17 @@ void main()
|
||||
#endif
|
||||
|
||||
// Alpha test with feedback
|
||||
#if (PS_AFAIL == AFAIL_FB_ONLY) && PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH && PS_ZWRITE
|
||||
#if PS_AFAIL == AFAIL_FB_ONLY
|
||||
if (!atst_pass)
|
||||
input_z = sample_from_depth().r;
|
||||
#elif (PS_AFAIL == AFAIL_ZB_ONLY) && PS_FEEDBACK_LOOP_IS_NEEDED_RT
|
||||
#elif PS_AFAIL == AFAIL_ZB_ONLY
|
||||
if (!atst_pass)
|
||||
o_col0 = sample_from_rt();
|
||||
#elif (PS_AFAIL == AFAIL_RGB_ONLY)
|
||||
#elif (PS_AFAIL == AFAIL_RGB_ONLY || PS_AFAIL == AFAIL_RGB_ONLY_SW_Z)
|
||||
if (!atst_pass)
|
||||
{
|
||||
#if PS_FEEDBACK_LOOP_IS_NEEDED_RT
|
||||
o_col0.a = sample_from_rt().a;
|
||||
#endif
|
||||
#if PS_FEEDBACK_LOOP_IS_NEEDED_DEPTH && PS_ZWRITE
|
||||
o_col0.a = sample_from_rt().a;
|
||||
#if PS_AFAIL == AFAIL_RGB_ONLY_SW_Z
|
||||
input_z = sample_from_depth().r;
|
||||
#endif
|
||||
}
|
||||
@@ -1489,7 +1484,7 @@ void main()
|
||||
input_z = min(input_z, MaxDepthPS);
|
||||
#endif
|
||||
|
||||
#if PS_ZWRITE
|
||||
#if ZWRITE
|
||||
gl_FragDepth = input_z;
|
||||
#endif
|
||||
#endif // PS_DATE
|
||||
|
||||
@@ -1191,11 +1191,12 @@ static const char* GetPSAFAILName(GSShader::PS_AFAIL afail)
|
||||
using GSShader::PS_AFAIL;
|
||||
switch (afail)
|
||||
{
|
||||
case PS_AFAIL::KEEP: return "KEEP";
|
||||
case PS_AFAIL::FB_ONLY: return "FB_ONLY";
|
||||
case PS_AFAIL::ZB_ONLY: return "ZB_ONLY";
|
||||
case PS_AFAIL::RGB_ONLY: return "RGB_ONLY";
|
||||
case PS_AFAIL::RGB_ONLY_DSB: return "RGB_ONLY_DSB";
|
||||
case PS_AFAIL::KEEP: return "KEEP";
|
||||
case PS_AFAIL::FB_ONLY: return "FB_ONLY";
|
||||
case PS_AFAIL::ZB_ONLY: return "ZB_ONLY";
|
||||
case PS_AFAIL::RGB_ONLY: return "RGB_ONLY";
|
||||
case PS_AFAIL::RGB_ONLY_DSB: return "RGB_ONLY_DSB";
|
||||
case PS_AFAIL::RGB_ONLY_SW_Z: return "RGB_ONLY_SW_Z";
|
||||
};
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
@@ -402,7 +402,6 @@ struct alignas(16) GSHWDrawConfig
|
||||
// Depth writing
|
||||
u32 zclamp : 1;
|
||||
u32 zfloor : 1;
|
||||
u32 zwrite : 1;
|
||||
|
||||
// Hack
|
||||
u32 tcoffsethack : 1;
|
||||
@@ -416,10 +415,6 @@ struct alignas(16) GSHWDrawConfig
|
||||
|
||||
// Scan mask
|
||||
u32 scanmsk : 2;
|
||||
|
||||
// Feedback
|
||||
u32 color_feedback : 1;
|
||||
u32 depth_feedback : 1;
|
||||
};
|
||||
|
||||
struct
|
||||
@@ -438,12 +433,15 @@ struct alignas(16) GSHWDrawConfig
|
||||
{
|
||||
const u32 sw_blend_bits = blend_a | blend_b | blend_d;
|
||||
const bool sw_blend_needs_rt = (sw_blend_bits != 0 && ((sw_blend_bits | blend_c) & 1u)) || ((a_masked & blend_c) != 0);
|
||||
return color_feedback || channel_fb || tex_is_fb || fbmask || (date >= 5) || sw_blend_needs_rt;
|
||||
const bool afail_needs_rt = afail == PS_AFAIL::ZB_ONLY || afail == PS_AFAIL::RGB_ONLY || afail == PS_AFAIL::RGB_ONLY_SW_Z;
|
||||
return channel_fb || tex_is_fb || fbmask || (date >= 5) || sw_blend_needs_rt || afail_needs_rt;
|
||||
}
|
||||
|
||||
__fi bool IsFeedbackLoopDepth() const
|
||||
{
|
||||
return depth_feedback;
|
||||
const bool afail_needs_depth = afail == PS_AFAIL::FB_ONLY || afail == PS_AFAIL::RGB_ONLY_SW_Z;
|
||||
const bool ztst_needs_depth = ztst == ZTST_GEQUAL || ztst == ZTST_GREATER;
|
||||
return afail_needs_depth || ztst_needs_depth;
|
||||
}
|
||||
|
||||
/// Disables color output from the pixel shader, this is done when all channels are masked.
|
||||
|
||||
@@ -26,14 +26,15 @@ enum class PS_ATST : uint32_t
|
||||
NOTEQUAL = 4
|
||||
};
|
||||
|
||||
// Identical with the usual GS enum except for the RGB_ONLY_DSB
|
||||
// Identical to the usual GS enum except for RGB_ONLY_DSB and RGB_ONLY_SW_Z
|
||||
enum class PS_AFAIL : uint32_t
|
||||
{
|
||||
KEEP = 0,
|
||||
FB_ONLY = 1,
|
||||
ZB_ONLY = 2,
|
||||
RGB_ONLY = 3,
|
||||
RGB_ONLY_DSB = 4 // RGB only with dual source blend.
|
||||
KEEP = 0, ///< Hardware discard
|
||||
FB_ONLY = 1, ///< FB only with software Z discard
|
||||
ZB_ONLY = 2, ///< ZB only with software RGBA discard
|
||||
RGB_ONLY = 3, ///< RGB only with hardware Z discard and software A discard
|
||||
RGB_ONLY_DSB = 4, ///< RGB only with dual source blend
|
||||
RGB_ONLY_SW_Z = 5, ///< RGB only with software Z discard
|
||||
};
|
||||
|
||||
} // namespace GSShader
|
||||
|
||||
@@ -1826,7 +1826,6 @@ void GSDevice11::SetupPS(const PSSelector& sel, const GSHWDrawConfig::PSConstant
|
||||
sm.AddMacro("PS_DITHER_ADJUST", sel.dither_adjust);
|
||||
sm.AddMacro("PS_ZCLAMP", sel.zclamp);
|
||||
sm.AddMacro("PS_ZFLOOR", sel.zfloor);
|
||||
sm.AddMacro("PS_ZWRITE", sel.zwrite);
|
||||
sm.AddMacro("PS_SCANMSK", sel.scanmsk);
|
||||
sm.AddMacro("PS_AUTOMATIC_LOD", sel.automatic_lod);
|
||||
sm.AddMacro("PS_MANUAL_LOD", sel.manual_lod);
|
||||
@@ -1834,8 +1833,6 @@ void GSDevice11::SetupPS(const PSSelector& sel, const GSHWDrawConfig::PSConstant
|
||||
sm.AddMacro("PS_NO_COLOR", sel.no_color);
|
||||
sm.AddMacro("PS_NO_COLOR1", sel.no_color1);
|
||||
sm.AddMacro("PS_ZTST", sel.ztst);
|
||||
sm.AddMacro("PS_COLOR_FEEDBACK", sel.color_feedback);
|
||||
sm.AddMacro("PS_DEPTH_FEEDBACK", sel.depth_feedback);
|
||||
|
||||
wil::com_ptr_nothrow<ID3D11PixelShader> ps = m_shader_cache.GetPixelShader(m_dev.get(), m_tfx_source, sm.GetPtr(), "ps_main");
|
||||
i = m_ps.try_emplace(sel, std::move(ps)).first;
|
||||
|
||||
@@ -3150,7 +3150,6 @@ const ID3DBlob* GSDevice12::GetTFXPixelShader(const GSHWDrawConfig::PSSelector&
|
||||
sm.AddMacro("PS_DITHER_ADJUST", sel.dither_adjust);
|
||||
sm.AddMacro("PS_ZCLAMP", sel.zclamp);
|
||||
sm.AddMacro("PS_ZFLOOR", sel.zfloor);
|
||||
sm.AddMacro("PS_ZWRITE", sel.zwrite);
|
||||
sm.AddMacro("PS_SCANMSK", sel.scanmsk);
|
||||
sm.AddMacro("PS_AUTOMATIC_LOD", sel.automatic_lod);
|
||||
sm.AddMacro("PS_MANUAL_LOD", sel.manual_lod);
|
||||
@@ -3158,8 +3157,6 @@ const ID3DBlob* GSDevice12::GetTFXPixelShader(const GSHWDrawConfig::PSSelector&
|
||||
sm.AddMacro("PS_NO_COLOR", sel.no_color);
|
||||
sm.AddMacro("PS_NO_COLOR1", sel.no_color1);
|
||||
sm.AddMacro("PS_ZTST", sel.ztst);
|
||||
sm.AddMacro("PS_COLOR_FEEDBACK", sel.color_feedback);
|
||||
sm.AddMacro("PS_DEPTH_FEEDBACK", sel.depth_feedback);
|
||||
|
||||
ComPtr<ID3DBlob> ps(m_shader_cache.GetPixelShader(m_tfx_source, sm.GetPtr(), "ps_main"));
|
||||
it = m_tfx_pixel_shaders.emplace(sel, std::move(ps)).first;
|
||||
|
||||
@@ -5227,9 +5227,6 @@ void GSRendererHW::EmulateZbuffer(const GSTextureCache::Target* ds)
|
||||
m_conf.ps.zclamp = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Enables writing to depth (e.g. SV_Depth or gl_FragDepth) in the pixel shader.
|
||||
m_conf.ps.zwrite = m_conf.ps.zfloor || m_conf.ps.zclamp;
|
||||
}
|
||||
|
||||
void GSRendererHW::CalculateAlphaRange(GSTextureCache::Target* rt, GSTextureCache::Target* ds,
|
||||
@@ -8004,7 +8001,7 @@ void GSRendererHW::EmulateAlphaTest(DATEOptions& date_options)
|
||||
|
||||
// Determine where RT and/or depth are needed for the feedback methods.
|
||||
const bool afail_needs_rt = (afail == AFAIL_ZB_ONLY) || (afail == AFAIL_RGB_ONLY);
|
||||
const bool afail_needs_depth = (afail == AFAIL_FB_ONLY) || ((afail == AFAIL_RGB_ONLY) && zwe);
|
||||
const bool afail_needs_depth = (afail == AFAIL_FB_ONLY || afail == AFAIL_RGB_ONLY) && zwe;
|
||||
|
||||
// Determine whether the feedback methods require a single pass.
|
||||
const bool feedback_one_pass = simple_fb_only || simple_rgb_only || simple_zb_only;
|
||||
@@ -8022,11 +8019,6 @@ void GSRendererHW::EmulateAlphaTest(DATEOptions& date_options)
|
||||
// Determine if we have the correct features for depth feedback.
|
||||
const bool depth_feedback_supported = features.depth_feedback != GSDevice::DepthFeedbackSupport::None;
|
||||
|
||||
// Determine if the method for doing depth feedback uses multiple render targets.
|
||||
// This should not be used in conjunction with dual source blend.
|
||||
const bool depth_as_rt_feedback = afail_needs_depth &&
|
||||
(features.depth_feedback == GSDevice::DepthFeedbackSupport::DepthAsRT);
|
||||
|
||||
// We need depth feedback but do not have the correct features.
|
||||
const bool avoid_feedback = afail_needs_depth && !depth_feedback_supported;
|
||||
|
||||
@@ -8048,20 +8040,19 @@ void GSRendererHW::EmulateAlphaTest(DATEOptions& date_options)
|
||||
m_conf.cb_ps.FogColor_AREF.a = ps_aref;
|
||||
m_conf.ps.afail = static_cast<PS_AFAIL>(afail);
|
||||
|
||||
m_conf.ps.color_feedback |= afail_needs_rt;
|
||||
m_conf.ps.depth_feedback |= afail_needs_depth;
|
||||
|
||||
if (!free_fbfetch_feedback && (features.texture_barrier || features.multidraw_fb_copy))
|
||||
if ((afail_needs_rt || afail_needs_depth) && (features.texture_barrier || features.multidraw_fb_copy))
|
||||
{
|
||||
m_conf.require_one_barrier |= feedback_one_pass;
|
||||
m_conf.require_full_barrier |= !feedback_one_pass;
|
||||
}
|
||||
|
||||
// Handle SW depth writing and/or testing.
|
||||
if (afail_needs_depth && zwe)
|
||||
if (afail_needs_depth)
|
||||
{
|
||||
pxAssert(zwe);
|
||||
GL_INS("Enable SW depth write for depth feedback");
|
||||
m_conf.ps.zwrite = true; // Make sure pixel shader writes to depth.
|
||||
if (afail == AFAIL_RGB_ONLY)
|
||||
m_conf.ps.afail = PS_AFAIL::RGB_ONLY_SW_Z;
|
||||
|
||||
if (m_cached_ctx.DepthRead())
|
||||
{
|
||||
@@ -8070,6 +8061,11 @@ void GSRendererHW::EmulateAlphaTest(DATEOptions& date_options)
|
||||
m_conf.depth.ztst = ZTST_ALWAYS; // Disable HW Z test.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Should have early exited
|
||||
pxAssert(afail != AFAIL_FB_ONLY);
|
||||
}
|
||||
|
||||
m_conf.alpha_test = GSHWDrawConfig::AlphaTestMode::FEEDBACK;
|
||||
}
|
||||
|
||||
@@ -1550,7 +1550,6 @@ std::string GSDeviceOGL::GetPSSource(const PSSelector& sel)
|
||||
+ fmt::format("#define PS_DITHER_ADJUST {}\n", sel.dither_adjust)
|
||||
+ fmt::format("#define PS_ZCLAMP {}\n", sel.zclamp)
|
||||
+ fmt::format("#define PS_ZFLOOR {}\n", sel.zfloor)
|
||||
+ fmt::format("#define PS_ZWRITE {}\n", sel.zwrite)
|
||||
+ fmt::format("#define PS_BLEND_MIX {}\n", sel.blend_mix)
|
||||
+ fmt::format("#define PS_ROUND_INV {}\n", sel.round_inv)
|
||||
+ fmt::format("#define PS_FIXED_ONE_A {}\n", sel.fixed_one_a)
|
||||
@@ -1559,8 +1558,6 @@ std::string GSDeviceOGL::GetPSSource(const PSSelector& sel)
|
||||
+ fmt::format("#define PS_NO_COLOR {}\n", sel.no_color)
|
||||
+ fmt::format("#define PS_NO_COLOR1 {}\n", sel.no_color1)
|
||||
+ fmt::format("#define PS_ZTST {}\n", sel.ztst)
|
||||
+ fmt::format("#define PS_COLOR_FEEDBACK {}\n", sel.color_feedback)
|
||||
+ fmt::format("#define PS_DEPTH_FEEDBACK {}\n", sel.depth_feedback)
|
||||
;
|
||||
|
||||
std::string src = GenGlslHeader("ps_main", GL_FRAGMENT_SHADER, macro);
|
||||
|
||||
@@ -4849,15 +4849,12 @@ VkShaderModule GSDeviceVK::GetTFXFragmentShader(const GSHWDrawConfig::PSSelector
|
||||
AddMacro(ss, "PS_DITHER_ADJUST", sel.dither_adjust);
|
||||
AddMacro(ss, "PS_ZCLAMP", sel.zclamp);
|
||||
AddMacro(ss, "PS_ZFLOOR", sel.zfloor);
|
||||
AddMacro(ss, "PS_ZWRITE", sel.zwrite);
|
||||
AddMacro(ss, "PS_PABE", sel.pabe);
|
||||
AddMacro(ss, "PS_SCANMSK", sel.scanmsk);
|
||||
AddMacro(ss, "PS_TEX_IS_FB", sel.tex_is_fb);
|
||||
AddMacro(ss, "PS_NO_COLOR", sel.no_color);
|
||||
AddMacro(ss, "PS_NO_COLOR1", sel.no_color1);
|
||||
AddMacro(ss, "PS_ZTST", sel.ztst);
|
||||
AddMacro(ss, "PS_COLOR_FEEDBACK", sel.color_feedback);
|
||||
AddMacro(ss, "PS_DEPTH_FEEDBACK", sel.depth_feedback);
|
||||
ss << m_tfx_source;
|
||||
|
||||
VkShaderModule mod = g_vulkan_shader_cache->GetFragmentShader(ss.str());
|
||||
|
||||
@@ -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 = 84;
|
||||
static constexpr u32 SHADER_CACHE_VERSION = 85; // Last changed in PR 14195
|
||||
|
||||
Reference in New Issue
Block a user