GS: Add NO_COLOR flag to PS (depth-only)

This commit is contained in:
Connor McLaughlin 2022-03-20 18:25:25 +10:00 committed by refractionpcsx2
parent 4e6b86f8f4
commit 45682c382f
8 changed files with 27 additions and 9 deletions

View File

@ -57,9 +57,10 @@
#define PS_AUTOMATIC_LOD 0
#define PS_MANUAL_LOD 0
#define PS_TEX_IS_FB 0
#define PS_NO_COLOR 0
#define PS_NO_COLOR1 0
#define PS_NO_ABLEND 0
#define PS_ONLY_ALPHA 0
#define PS_NO_COLOR1 0
#endif
#define SW_BLEND (PS_BLEND_A || PS_BLEND_B || PS_BLEND_D)
@ -102,10 +103,12 @@ struct PS_INPUT
struct PS_OUTPUT
{
#if !PS_NO_COLOR
float4 c0 : SV_Target0;
#if !PS_NO_COLOR1
float4 c1 : SV_Target1;
#endif
#endif
#if PS_ZCLAMP
float depth : SV_Depth;
#endif
@ -859,6 +862,7 @@ PS_OUTPUT ps_main(PS_INPUT input)
ps_fbmask(C, input.p.xy);
#if !PS_NO_COLOR
output.c0 = C / 255.0f;
#if !PS_NO_COLOR1
output.c1 = (float4)(alpha_blend);
@ -872,6 +876,7 @@ PS_OUTPUT ps_main(PS_INPUT input)
// rgb isn't used
output.c0.rgb = float3(0.0f, 0.0f, 0.0f);
#endif
#endif
#if PS_ZCLAMP
output.depth = min(input.p.z, MaxDepthPS);

View File

@ -50,6 +50,7 @@ in SHADER
#endif
#endif
#if !PS_NO_COLOR
#if !defined(DISABLE_DUAL_SOURCE) && !PS_NO_COLOR1
// Same buffer but 2 colors for dual source blending
layout(location = 0, index = 0) TARGET_0_QUALIFIER vec4 SV_Target0;
@ -57,6 +58,7 @@ in SHADER
#else
layout(location = 0) TARGET_0_QUALIFIER vec4 SV_Target0;
#endif
#endif
layout(binding = 1) uniform sampler2D PaletteSampler;
@ -942,6 +944,7 @@ void ps_main()
ps_fbmask(C);
#if !PS_NO_COLOR
SV_Target0 = C / 255.0f;
#if !defined(DISABLE_DUAL_SOURCE) && !PS_NO_COLOR1
SV_Target1 = vec4(alpha_blend);
@ -955,6 +958,7 @@ void ps_main()
// rgb isn't used
SV_Target0.rgb = vec3(0.0f);
#endif
#endif
#if PS_ZCLAMP
gl_FragDepth = min(gl_FragCoord.z, MaxDepthPS);

View File

@ -1201,6 +1201,7 @@ void main()
ps_fbmask(C);
#if !PS_NO_COLOR
o_col0 = C / 255.0f;
#if !defined(DISABLE_DUAL_SOURCE) && !PS_NO_COLOR1
o_col1 = vec4(alpha_blend);
@ -1214,6 +1215,7 @@ void main()
// rgb isn't used
o_col0.rgb = vec3(0.0f);
#endif
#endif
#if PS_ZCLAMP
gl_FragDepth = min(gl_FragCoord.z, MaxDepthPS);

View File

@ -239,8 +239,9 @@ struct alignas(16) GSHWDrawConfig
u32 colclip : 1;
u32 blend_mix : 1;
u32 pabe : 1;
u32 no_ablend : 1; // output alpha blend in col0 (for no-DSB)
u32 no_color : 1; // disables color output entirely (depth only)
u32 no_color1 : 1; // disables second color output (when unnecessary)
u32 no_ablend : 1; // output alpha blend in col0 (for no-DSB)
u32 only_alpha : 1; // don't bother computing RGB
// Others ways to fetch the texture

View File

@ -195,9 +195,10 @@ void GSDevice11::SetupPS(const PSSelector& sel, const GSHWDrawConfig::PSConstant
sm.AddMacro("PS_AUTOMATIC_LOD", sel.automatic_lod);
sm.AddMacro("PS_MANUAL_LOD", sel.manual_lod);
sm.AddMacro("PS_TEX_IS_FB", sel.tex_is_fb);
sm.AddMacro("PS_NO_COLOR", sel.no_color);
sm.AddMacro("PS_NO_COLOR1", sel.no_color1);
sm.AddMacro("PS_NO_ABLEND", sel.no_ablend);
sm.AddMacro("PS_ONLY_ALPHA", sel.only_alpha);
sm.AddMacro("PS_NO_COLOR1", sel.no_color1);
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;

View File

@ -867,9 +867,8 @@ void GSRendererNew::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER, bool&
sw_blending = false; // DATE_PRIMID
// Output is Cd, set rgb write to 0.
m_conf.colormask.wr = 0;
m_conf.colormask.wg = 0;
m_conf.colormask.wb = 0;
m_conf.colormask.wrgba &= 0x8;
m_conf.ps.no_color = (m_conf.colormask.wrgba == 0);
}
else if (sw_blending)
{
@ -1522,6 +1521,7 @@ void GSRendererNew::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
else
{
m_conf.blend = {}; // No blending please
m_conf.ps.no_color = !rt || (m_conf.colormask.wrgba == 0);
m_conf.ps.no_color1 = true;
}
@ -1785,6 +1785,7 @@ void GSRendererNew::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
m_conf.alpha_second_pass.colormask.wg = g;
m_conf.alpha_second_pass.colormask.wb = b;
m_conf.alpha_second_pass.colormask.wa = a;
m_conf.alpha_second_pass.ps.no_color |= !(r || g || b || a);
}
else
{

View File

@ -1122,8 +1122,9 @@ std::string GSDeviceOGL::GetPSSource(const PSSelector& sel)
+ format("#define PS_PABE %d\n", sel.pabe)
+ format("#define PS_SCANMSK %d\n", sel.scanmsk)
+ format("#define PS_SCALE_FACTOR %d\n", GSConfig.UpscaleMultiplier)
+ format("#define PS_NO_ABLEND %d\n", sel.no_ablend)
+ format("#define PS_NO_COLOR %d\n", sel.no_color)
+ format("#define PS_NO_COLOR1 %d\n", sel.no_color1)
+ format("#define PS_NO_ABLEND %d\n", sel.no_ablend)
+ format("#define PS_ONLY_ALPHA %d\n", sel.only_alpha)
;

View File

@ -1816,8 +1816,9 @@ VkShaderModule GSDeviceVK::GetTFXFragmentShader(const GSHWDrawConfig::PSSelector
AddMacro(ss, "PS_SCANMSK", sel.scanmsk);
AddMacro(ss, "PS_SCALE_FACTOR", GSConfig.UpscaleMultiplier);
AddMacro(ss, "PS_TEX_IS_FB", sel.tex_is_fb);
AddMacro(ss, "PS_NO_ABLEND", sel.no_ablend);
AddMacro(ss, "PS_NO_COLOR", sel.no_color);
AddMacro(ss, "PS_NO_COLOR1", sel.no_color1);
AddMacro(ss, "PS_NO_ABLEND", sel.no_ablend);
AddMacro(ss, "PS_ONLY_ALPHA", sel.only_alpha);
ss << m_tfx_source;
@ -2653,10 +2654,12 @@ GSTextureVK* GSDeviceVK::SetupPrimitiveTrackingDATE(GSHWDrawConfig& config, Pipe
init_pipe.dss.zwe = false;
init_pipe.cms.wrgba = 0;
init_pipe.bs = {};
init_pipe.ps.blend_a = init_pipe.ps.blend_b = init_pipe.ps.blend_c = init_pipe.ps.blend_d = false;
init_pipe.feedback_loop = false;
init_pipe.rt = true;
init_pipe.ps.blend_a = init_pipe.ps.blend_b = init_pipe.ps.blend_c = init_pipe.ps.blend_d = false;
init_pipe.ps.date += 10;
init_pipe.ps.no_color = false;
init_pipe.ps.no_color1 = true;
if (BindDrawPipeline(init_pipe))
DrawIndexedPrimitive();