Skip to content

Commit e5f0c99

Browse files
TellowKrinklelightningterror
authored andcommitted
GS: Remove depth feedback none option
Depth feedback doesn't get used most of the time anyways
1 parent af81d8b commit e5f0c99

11 files changed

Lines changed: 61 additions & 146 deletions

File tree

pcsx2/GS/Renderers/Common/GSDevice.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,6 @@ class GSDevice : public GSAlignedClass<32>
930930
Performance
931931
};
932932

933-
using DepthFeedbackSupport = GSShader::DepthFeedbackSupport;
934-
935933
// clang-format off
936934
struct FeatureSupport
937935
{
@@ -950,7 +948,7 @@ class GSDevice : public GSAlignedClass<32>
950948
bool stencil_buffer : 1; ///< Supports stencil buffer, and can use for DATE.
951949
bool cas_sharpening : 1; ///< Supports sufficient functionality for contrast adaptive sharpening.
952950
bool test_and_sample_depth: 1; ///< Supports concurrently binding the depth-stencil buffer for sampling and depth testing.
953-
DepthFeedbackSupport depth_feedback : 2; ///< Support for depth feedback loops.
951+
bool depth_feedback : 1; ///< Depth feedback loops can be done with DS directly (otherwise need to copy to separate RT).
954952
bool aa1 : 1; ///< Supports the GS AA1 feature.
955953
FeatureSupport()
956954
{

pcsx2/GS/Renderers/Common/GSShaderEnums.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ enum class VSExpand : uint8_t
1919
TriangleAA1 = 5,
2020
};
2121

22-
enum class DepthFeedbackSupport : uint32_t
23-
{
24-
None = 0, ///< No support for depth feedback loops.
25-
Depth = 1, ///< Implement depth feedback loops directly on the depth buffer.
26-
DepthAsRT = 2, ///< Implement depth feedback loops by first converting depth to a color RT.
27-
};
28-
2922
enum class PS_ATST : uint32_t
3023
{
3124
NONE = 0,

pcsx2/GS/Renderers/DX11/GSDevice11.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,7 @@ GSDevice11::GSDevice11()
6868
m_features.stencil_buffer = true;
6969
m_features.cas_sharpening = true;
7070
m_features.test_and_sample_depth = false;
71-
if (m_features.multidraw_fb_copy && (GSConfig.DepthFeedbackMode == GSDepthFeedbackMode::Auto ||
72-
GSConfig.DepthFeedbackMode == GSDepthFeedbackMode::Depth))
73-
{
74-
m_features.depth_feedback = GSDevice::DepthFeedbackSupport::Depth;
75-
}
76-
else
77-
{
78-
m_features.depth_feedback = GSDevice::DepthFeedbackSupport::None;
79-
}
71+
m_features.depth_feedback = true;
8072
}
8173

8274
GSDevice11::~GSDevice11() = default;
@@ -654,7 +646,7 @@ void GSDevice11::SetFeatures(IDXGIAdapter1* adapter)
654646
m_features.vs_expand = (!GSConfig.DisableVertexShaderExpand && m_feature_level >= D3D_FEATURE_LEVEL_11_0);
655647
m_features.cas_sharpening = (m_feature_level >= D3D_FEATURE_LEVEL_11_0);
656648
m_features.test_and_sample_depth = (m_feature_level >= D3D_FEATURE_LEVEL_11_0);
657-
m_features.aa1 = GSConfig.HWAA1 && m_features.vs_expand && (m_features.depth_feedback != GSDevice::DepthFeedbackSupport::None);
649+
m_features.aa1 = GSConfig.HWAA1 && m_features.vs_expand && m_features.multidraw_fb_copy;
658650

659651
m_max_texture_size = (m_feature_level >= D3D_FEATURE_LEVEL_11_0) ?
660652
D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION :
@@ -2961,7 +2953,7 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config)
29612953
}
29622954

29632955
if (draw_ds && (config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) &&
2964-
m_features.depth_feedback == GSDevice::DepthFeedbackSupport::Depth && config.ps.IsFeedbackLoopDepth())
2956+
m_features.depth_feedback && config.ps.IsFeedbackLoopDepth())
29652957
{
29662958
// Requires a copy of the DS.
29672959
draw_ds_clone = CreateTexture(rtsize.x, rtsize.y, 1, draw_ds->GetFormat(), true);

pcsx2/GS/Renderers/DX12/GSDevice12.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,17 +1405,8 @@ bool GSDevice12::CheckFeatures(const u32& vendor_id)
14051405
m_features.cas_sharpening = true;
14061406
m_features.test_and_sample_depth = true;
14071407
m_features.vs_expand = !GSConfig.DisableVertexShaderExpand;
1408-
if (m_features.texture_barrier && (GSConfig.DepthFeedbackMode == GSDepthFeedbackMode::Auto ||
1409-
GSConfig.DepthFeedbackMode == GSDepthFeedbackMode::DepthAsRT))
1410-
{
1411-
m_features.depth_feedback = GSDevice::DepthFeedbackSupport::DepthAsRT;
1412-
}
1413-
else
1414-
{
1415-
m_features.depth_feedback = GSDevice::DepthFeedbackSupport::None;
1416-
}
1417-
1418-
m_features.aa1 = GSConfig.HWAA1 && m_features.vs_expand && (m_features.depth_feedback != GSDevice::DepthFeedbackSupport::None);
1408+
m_features.depth_feedback = false;
1409+
m_features.aa1 = GSConfig.HWAA1 && m_features.vs_expand && m_features.texture_barrier;
14191410

14201411
m_features.dxt_textures = SupportsTextureFormat(DXGI_FORMAT_BC1_UNORM) &&
14211412
SupportsTextureFormat(DXGI_FORMAT_BC2_UNORM) &&

pcsx2/GS/Renderers/HW/GSRendererHW.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5796,7 +5796,7 @@ void GSRendererHW::EmulateZbufferAA1()
57965796
{
57975797
const GSDevice::FeatureSupport& features = g_gs_device->Features();
57985798

5799-
pxAssert(!features.aa1 || features.depth_feedback != GSDevice::DepthFeedbackSupport::None);
5799+
pxAssert(!features.aa1 || features.texture_barrier || features.multidraw_fb_copy);
58005800

58015801
if (IsCoverageAlphaSupported())
58025802
{
@@ -6149,8 +6149,7 @@ void GSRendererHW::DetermineBarriers(GSTextureCache::Target* rt)
61496149

61506150
// If we use depth feedback directly, we must use barriers for the depth texture.
61516151
// If we use depth-as-color feedback, then FB fetch can be used for depth also.
6152-
bool need_barriers_for_depth = m_conf.ps.IsFeedbackLoopDepth() &&
6153-
(features.depth_feedback == GSDevice::DepthFeedbackSupport::Depth);
6152+
bool need_barriers_for_depth = m_conf.ps.IsFeedbackLoopDepth() && features.depth_feedback;
61546153

61556154
if (!need_barriers_for_depth)
61566155
{
@@ -6952,8 +6951,7 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, DATEOptio
69526951
}
69536952
}
69546953

6955-
if (m_conf.alpha_test == GSHWDrawConfig::AlphaTestMode::FEEDBACK &&
6956-
features.depth_feedback == GSDevice::DepthFeedbackSupport::DepthAsRT)
6954+
if (m_conf.alpha_test == GSHWDrawConfig::AlphaTestMode::FEEDBACK && !features.depth_feedback)
69576955
{
69586956
// If we are doing feedback alpha test with a second RT we must use SW blending to avoid
69596957
// mixing dual source blending with multiple render targets.
@@ -8435,7 +8433,7 @@ void GSRendererHW::EmulateAlphaTest(DATEOptions& date_options)
84358433
const bool free_fbfetch_feedback = features.framebuffer_fetch && !afail_needs_depth;
84368434

84378435
// Determine if we have the correct features for depth feedback.
8438-
const bool depth_feedback_supported = features.depth_feedback != GSDevice::DepthFeedbackSupport::None;
8436+
const bool depth_feedback_supported = features.texture_barrier || features.multidraw_fb_copy;
84398437

84408438
// We need depth feedback but do not have the correct features.
84418439
const bool avoid_feedback = afail_needs_depth && !depth_feedback_supported;
@@ -8929,7 +8927,7 @@ __ri void GSRendererHW::DrawPrims(GSTextureCache::Target* rt, GSTextureCache::Ta
89298927

89308928
SetupIA(rtscale, vs_scale_x, vs_scale_y, m_channel_shuffle_width != 0);
89318929

8932-
if (m_conf.ds && m_conf.ps.IsFeedbackLoopDepth() && g_gs_device->Features().depth_feedback == GSDevice::DepthFeedbackSupport::DepthAsRT)
8930+
if (m_conf.ds && m_conf.ps.IsFeedbackLoopDepth() && !g_gs_device->Features().depth_feedback)
89338931
{
89348932
GL_PUSH("HW: Creating temporary R32 RT for depth feedback");
89358933

pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -870,18 +870,17 @@ static void OnMainThread(Fn&& fn)
870870
return ret;
871871
}
872872

873-
static GSDevice::DepthFeedbackSupport getDepthFeedback(const GSMTLDevice& dev, bool fbfetch)
873+
static bool getDepthFeedback(const GSMTLDevice& dev, bool fbfetch)
874874
{
875875
switch (GSConfig.DepthFeedbackMode)
876876
{
877-
case GSDepthFeedbackMode::None: return GSDevice::DepthFeedbackSupport::None;
878-
case GSDepthFeedbackMode::Auto: return dev.features.preferred_depth_feedback;
879-
case GSDepthFeedbackMode::DepthAsRT: return GSDevice::DepthFeedbackSupport::DepthAsRT;
877+
case GSDepthFeedbackMode::Auto:
878+
return dev.features.depth_feedback;
880879
case GSDepthFeedbackMode::Depth:
881-
if (!fbfetch)
882-
return GSDevice::DepthFeedbackSupport::Depth;
883-
else
884-
return GSDevice::DepthFeedbackSupport::DepthAsRT; // Depth + FBFetch not supported
880+
// Depth feedback + FBFetch not supported
881+
return !fbfetch;
882+
default:
883+
return false;
885884
}
886885
}
887886

@@ -977,7 +976,7 @@ static void OnMainThread(Fn&& fn)
977976
// Init metal stuff
978977
m_fn_constants = MRCTransfer([MTLFunctionConstantValues new]);
979978
setFnConstantB(m_fn_constants, m_features.framebuffer_fetch, GSMTLConstantIndex_FRAMEBUFFER_FETCH);
980-
setFnConstantI(m_fn_constants, m_features.depth_feedback, GSMTLConstantIndex_DEPTH_FEEDBACK);
979+
setFnConstantB(m_fn_constants, m_features.depth_feedback, GSMTLConstantIndex_DEPTH_FEEDBACK);
981980

982981
m_draw_sync_fence = MRCTransfer([m_dev.dev newFence]);
983982
[m_draw_sync_fence setLabel:@"Draw Sync Fence"];
@@ -1018,7 +1017,7 @@ static void OnMainThread(Fn&& fn)
10181017
const bool depth = i & 2;
10191018
const bool stencil = i & 4;
10201019
const bool rt1 = i & 8;
1021-
if (rt1 && m_features.depth_feedback != GSDevice::DepthFeedbackSupport::DepthAsRT)
1020+
if (rt1 && m_features.depth_feedback)
10221021
continue;
10231022
if (rt1 && !depth)
10241023
continue;
@@ -1332,6 +1331,7 @@ static void OnMainThread(Fn&& fn)
13321331
desc += "\n Framebuffer Fetch: " + std::string(m_dev.features.framebuffer_fetch ? "Supported" : "Unsupported");
13331332
desc += "\n Memoryless Textures: " + std::string(m_dev.features.memoryless_textures ? "Supported" : "Unsupported");
13341333
desc += "\n Primitive ID: " + std::string(m_dev.features.primid ? "Supported" : "Unsupported");
1334+
desc += "\n Depth Feedback: " + std::string(m_dev.features.depth_feedback ? "Supported" : "Unsupported");
13351335
desc += "\n Shader Version: " + std::string(to_string(m_dev.features.shader_version));
13361336
desc += "\n Max Texture Size: " + std::to_string(m_dev.features.max_texsize);
13371337
return desc;
@@ -2380,7 +2380,7 @@ static bool usesStencil(GSHWDrawConfig::DestinationAlphaMode dstalpha)
23802380
}
23812381

23822382
const bool feedback_depth = config.ps.IsFeedbackLoopDepth();
2383-
const bool rt1 = feedback_depth && m_features.depth_feedback == GSDevice::DepthFeedbackSupport::DepthAsRT;
2383+
const bool rt1 = feedback_depth && !m_features.depth_feedback;
23842384
BeginRenderPass(@"RenderHW", rt, MTLLoadActionLoad, config.ds, MTLLoadActionLoad, stencil, MTLLoadActionLoad, rt1);
23852385
id<MTLRenderCommandEncoder> mtlenc = m_current_render.encoder;
23862386
FlushDebugEntries(mtlenc);
@@ -2391,8 +2391,7 @@ static bool usesStencil(GSHWDrawConfig::DestinationAlphaMode dstalpha)
23912391
MRESetTexture(rt, GSMTLTextureIndexRenderTarget);
23922392
if (feedback_depth)
23932393
{
2394-
bool depth_as_rt = m_features.depth_feedback == GSDevice::DepthFeedbackSupport::DepthAsRT;
2395-
GSTexture* tex = depth_as_rt && !m_features.framebuffer_fetch ? m_ds_as_rt : config.ds;
2394+
GSTexture* tex = !m_features.depth_feedback && !m_features.framebuffer_fetch ? m_ds_as_rt : config.ds;
23962395
MRESetTexture(tex, GSMTLTextureIndexDepthTarget);
23972396
}
23982397
if (primid_tex)

pcsx2/GS/Renderers/Metal/GSMTLDeviceInfo.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ struct GSMTLDevice
2424
Metal23, ///< Metal 2.3 (macOS 11, iOS 14)
2525
};
2626

27-
using DepthFeedbackSupport = GSShader::DepthFeedbackSupport;
28-
2927
struct Features
3028
{
3129
bool unified_memory : 1;
@@ -35,8 +33,8 @@ struct GSMTLDevice
3533
bool slow_color_compression : 1; ///< Color compression seems to slow down rt read on AMD
3634
bool has_fast_half : 1;
3735
bool memoryless_textures : 1;
36+
bool depth_feedback : 1;
3837
MetalVersion shader_version;
39-
DepthFeedbackSupport preferred_depth_feedback : 8;
4038
int max_texsize;
4139
};
4240

pcsx2/GS/Renderers/Metal/GSMTLDeviceInfo.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static DetectionResult detectIntelGPU(id<MTLDevice> dev, id<MTLLibrary> lib)
164164
if (features.primid && !detectPrimIDSupport(dev, shaders))
165165
features.primid = false;
166166

167-
features.preferred_depth_feedback = DepthFeedbackSupport::DepthAsRT;
167+
features.depth_feedback = false;
168168

169169
NSString* name = [dev name];
170170
if ([name containsString:@"Intel"])
@@ -175,7 +175,7 @@ static DetectionResult detectIntelGPU(id<MTLDevice> dev, id<MTLLibrary> lib)
175175
{
176176
case DetectionResult::HaswellOrNotIntel:
177177
// Older Intel GPUs seem to be fine with depth feedback
178-
features.preferred_depth_feedback = DepthFeedbackSupport::Depth;
178+
features.depth_feedback = true;
179179
break;
180180
case DetectionResult::Broadwell:
181181
features.primid = false; // Broken
@@ -192,12 +192,12 @@ static DetectionResult detectIntelGPU(id<MTLDevice> dev, id<MTLLibrary> lib)
192192
// RDNA+ seems to work fine with depth feedback
193193
if (@available(macOS 13, iOS 16, *))
194194
if ([dev supportsFamily:MTLGPUFamilyMetal3])
195-
features.preferred_depth_feedback = DepthFeedbackSupport::Depth;
195+
features.depth_feedback = true;
196196
}
197197
else if ([name containsString:@"NVIDIA"])
198198
{
199199
// macOS only supports Kepler, which seems to work fine with depth feedback
200-
features.preferred_depth_feedback = DepthFeedbackSupport::Depth;
200+
features.depth_feedback = true;
201201
}
202202
else if ([name containsString:@"Apple"])
203203
{

pcsx2/GS/Renderers/Metal/tfx.metal

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ constant uint SHUFFLE_READ = 1;
1212
constant uint SHUFFLE_READWRITE = 3;
1313

1414
constant bool HAS_FBFETCH [[function_constant(GSMTLConstantIndex_FRAMEBUFFER_FETCH)]];
15-
constant uint DEPTH_FEEDBACK_RAW [[function_constant(GSMTLConstantIndex_DEPTH_FEEDBACK)]];
15+
constant bool DEPTH_FEEDBACK [[function_constant(GSMTLConstantIndex_DEPTH_FEEDBACK)]];
1616
constant bool FST [[function_constant(GSMTLConstantIndex_FST)]];
1717
constant bool IIP [[function_constant(GSMTLConstantIndex_IIP)]];
1818
constant bool VS_POINT_SIZE [[function_constant(GSMTLConstantIndex_VS_POINT_SIZE)]];
@@ -74,12 +74,10 @@ constant bool PS_REGION_RECT [[function_constant(GSMTLConstantIndex_PS_RE
7474
constant uint PS_SCANMSK [[function_constant(GSMTLConstantIndex_PS_SCANMSK)]];
7575
constant uint PS_SW_ANISO [[function_constant(GSMTLConstantIndex_PS_SW_ANISO)]];
7676

77-
using GSShader::DepthFeedbackSupport;
7877
using GSShader::VSExpand;
7978
using AFAIL = GSShader::PS_AFAIL;
8079
using ATST = GSShader::PS_ATST;
8180
using GSShader::ZTST;
82-
constant DepthFeedbackSupport DEPTH_FEEDBACK = static_cast<DepthFeedbackSupport>(DEPTH_FEEDBACK_RAW);
8381
constant VSExpand VS_EXPAND_TYPE = static_cast<VSExpand>(VS_EXPAND_TYPE_RAW);
8482
constant AFAIL PS_AFAIL = static_cast<AFAIL>(PS_AFAIL_RAW);
8583
constant ATST PS_ATST = static_cast<ATST>(PS_ATST_RAW);
@@ -121,7 +119,7 @@ constant bool PS_COLOR1 = !PS_NO_COLOR1;
121119
constant bool PS_ZOUTPUT = PS_ZCLAMP || PS_ZFLOOR || SW_DEPTH;
122120
constant bool PS_ZOUTPUT_LESS = PS_ZOUTPUT && !SW_DEPTH;
123121
constant bool PS_ZOUTPUT_ANY = PS_ZOUTPUT && SW_DEPTH;
124-
constant bool PS_ZOUTPUT_COLOR = PS_ZOUTPUT_ANY && DEPTH_FEEDBACK == DepthFeedbackSupport::DepthAsRT;
122+
constant bool PS_ZOUTPUT_COLOR = PS_ZOUTPUT_ANY && !DEPTH_FEEDBACK;
125123

126124
struct MainVSIn
127125
{
@@ -1406,14 +1404,14 @@ fragment float4 fbfetch_test(float4 in [[color(0), raster_order_group(0)]])
14061404

14071405
constant bool NEEDS_RT_TEX = NEEDS_RT && !HAS_FBFETCH;
14081406
constant bool NEEDS_RT_FBF = NEEDS_RT && HAS_FBFETCH;
1409-
constant bool NEEDS_DS_FBF = SW_DEPTH && HAS_FBFETCH && DEPTH_FEEDBACK == DepthFeedbackSupport::DepthAsRT;
1407+
constant bool NEEDS_DS_FBF = SW_DEPTH && HAS_FBFETCH && !DEPTH_FEEDBACK;
14101408
#else
14111409
constant bool NEEDS_RT_TEX = NEEDS_RT;
14121410
constant bool NEEDS_DS_FBF = false;
14131411
constant float ds_fbf = 0;
14141412
#endif
1415-
constant bool NEEDS_DS_TEX = SW_DEPTH && DEPTH_FEEDBACK == DepthFeedbackSupport::DepthAsRT && !NEEDS_DS_FBF;
1416-
constant bool NEEDS_DS_DEPTH = SW_DEPTH && DEPTH_FEEDBACK == DepthFeedbackSupport::Depth || NEEDS_DS_FBF;
1413+
constant bool NEEDS_DS_TEX = SW_DEPTH && !DEPTH_FEEDBACK && !NEEDS_DS_FBF;
1414+
constant bool NEEDS_DS_DEPTH = SW_DEPTH && DEPTH_FEEDBACK || NEEDS_DS_FBF;
14171415

14181416
fragment MainPSOut ps_main(
14191417
MainPSIn in [[stage_in]],
@@ -1453,22 +1451,12 @@ fragment MainPSOut ps_main(
14531451

14541452
if (SW_DEPTH)
14551453
{
1456-
switch (DEPTH_FEEDBACK)
1457-
{
1458-
case DepthFeedbackSupport::Depth:
1459-
main.current_depth = ds_depth.read(coord);
1460-
break;
1461-
case DepthFeedbackSupport::DepthAsRT:
1462-
if (NEEDS_DS_FBF)
1463-
main.current_depth = ds_fbf < 0 ? ds_depth.read(coord) : ds_fbf;
1464-
else
1465-
main.current_depth = ds_tex.read(coord).x;
1466-
break;
1467-
case DepthFeedbackSupport::None:
1468-
// Should never happen
1469-
main.current_depth = 0;
1470-
break;
1471-
}
1454+
if (DEPTH_FEEDBACK)
1455+
main.current_depth = ds_depth.read(coord);
1456+
else if (NEEDS_DS_FBF)
1457+
main.current_depth = ds_fbf < 0 ? ds_depth.read(coord) : ds_fbf;
1458+
else
1459+
main.current_depth = ds_tex.read(coord).x;
14721460
}
14731461

14741462
if (NEEDS_RT)

0 commit comments

Comments
 (0)