From c484cf286ceaebe3ee2271f71a7180f46b769eac Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Sat, 15 Nov 2025 05:21:04 +0100 Subject: [PATCH] GS/DX11: Don't unbind shader resource if depth stencil view is read only. We don't need to unbind conflicting srv with dsv if the dsv itself is read only, it is used for depth testing and both can be bind at the same time. Avoids re binding srv using a read only dsv. --- pcsx2/GS/Renderers/DX11/GSDevice11.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 8bb8761d27..ad96058ae8 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -2447,7 +2447,7 @@ void GSDevice11::PSUnbindConflictingSRVs(GSTexture* tex1, GSTexture* tex2) bool changed = false; for (size_t i = 0; i < m_state.ps_sr_views.size(); i++) { - if ((tex1 && m_state.ps_sr_views[i] == *(GSTexture11*)tex1) || (tex2 && m_state.ps_sr_views[i] == *(GSTexture11*)tex2)) + if ((tex1 && m_state.ps_sr_views[i] == *static_cast(tex1)) || (tex2 && m_state.ps_sr_views[i] == *static_cast(tex2))) { m_state.ps_sr_views[i] = nullptr; changed = true; @@ -2697,8 +2697,13 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config) } IASetPrimitiveTopology(topology); + // Depth testing and sampling, bind resource as dsv read only and srv at the same time without the need of a copy. + ID3D11DepthStencilView* read_only_dsv = nullptr; + if (config.tex && config.tex == config.ds) + read_only_dsv = static_cast(config.ds)->ReadOnlyDepthStencilView(); + // Should be called before changing local srv state. - PSUnbindConflictingSRVs(colclip_rt ? colclip_rt : config.rt, config.ds); + PSUnbindConflictingSRVs(colclip_rt ? colclip_rt : config.rt, read_only_dsv ? nullptr : config.ds); if (config.tex) { @@ -2714,11 +2719,6 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config) SetupVS(config.vs, &config.cb_vs); SetupPS(config.ps, &config.cb_ps, config.sampler); - // Depth testing and sampling, bind resource as dsv read only and srv at the same time without the need of a copy. - ID3D11DepthStencilView* read_only_dsv = nullptr; - if (config.tex && config.tex == config.ds) - read_only_dsv = static_cast(config.ds)->ReadOnlyDepthStencilView(); - if (primid_texture) { OMDepthStencilSelector dss = config.depth;