From 20dc389ab708c1abe2c4772ae419c76577f5587f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 20 Feb 2025 17:26:02 +0100 Subject: [PATCH] [d3d11] Skip unnecessary iterations when binding graphics UAVs Some games will unconditionally use a high index for UAVStartSlot. --- src/d3d11/d3d11_context.cpp | 8 ++++++-- src/d3d11/d3d11_context_state.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 1e5ec512a..ae2edcc49 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -5275,10 +5275,14 @@ namespace dxvk { if (unlikely(NumUAVs || m_state.om.maxUav)) { if (likely(NumUAVs != D3D11_KEEP_UNORDERED_ACCESS_VIEWS)) { - uint32_t newMaxUav = NumUAVs ? UAVStartSlot + NumUAVs : 0; + uint32_t newMinUav = NumUAVs ? UAVStartSlot : D3D11_1_UAV_SLOT_COUNT; + uint32_t newMaxUav = NumUAVs ? UAVStartSlot + NumUAVs : 0u; + + uint32_t oldMinUav = std::exchange(m_state.om.minUav, newMinUav); uint32_t oldMaxUav = std::exchange(m_state.om.maxUav, newMaxUav); - for (uint32_t i = 0; i < std::max(oldMaxUav, newMaxUav); i++) { + for (uint32_t i = std::min(oldMinUav, newMinUav); + i < std::max(oldMaxUav, newMaxUav); i++) { D3D11UnorderedAccessView* uav = nullptr; uint32_t ctr = ~0u; diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index 7e56258fb..6886dd99d 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -199,6 +199,7 @@ namespace dxvk { UINT stencilRef = D3D11_DEFAULT_STENCIL_REFERENCE; UINT maxRtv = 0u; + UINT minUav = 0u; UINT maxUav = 0u; void reset() {