From 7e237b33b7611dc63676d1037df2e213e8859492 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 4 Aug 2022 18:17:23 +0200 Subject: [PATCH] [d3d11] Track highest bound unordered access view --- src/d3d11/d3d11_context.cpp | 15 +++++++++++---- src/d3d11/d3d11_context_state.h | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index c0b49bbf..88a0a4c4 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -2126,6 +2126,9 @@ namespace dxvk { ResolveCsSrvHazards(uav); } } + + m_state.uav.maxCount = std::clamp(StartSlot + NumUAVs, + m_state.uav.maxCount, uint32_t(m_state.uav.views.size())); } @@ -3795,8 +3798,8 @@ namespace dxvk { result.stages[i].reserved = 0; } - result.stages[uint32_t(DxbcProgramType::PixelShader)].uavCount = D3D11_1_UAV_SLOT_COUNT; - result.stages[uint32_t(DxbcProgramType::ComputeShader)].uavCount = D3D11_1_UAV_SLOT_COUNT; + result.stages[uint32_t(DxbcProgramType::PixelShader)].uavCount = m_state.om.maxUav; + result.stages[uint32_t(DxbcProgramType::ComputeShader)].uavCount = m_state.uav.maxCount; result.vbCount = m_state.ia.maxVbCount; result.soCount = D3D11_SO_BUFFER_SLOT_COUNT; @@ -4151,10 +4154,14 @@ namespace dxvk { ? m_state.uav.views : m_state.om.uavs; - uint32_t uavSlotId = computeUavBinding (Stage, 0); + uint32_t maxCount = Stage == DxbcProgramType::ComputeShader + ? m_state.uav.maxCount + : m_state.om.maxUav; + + uint32_t uavSlotId = computeUavBinding(Stage, 0); uint32_t ctrSlotId = computeUavCounterBinding(Stage, 0); - for (uint32_t i = 0; i < views.size(); i++) { + for (uint32_t i = 0; i < maxCount; i++) { BindUnorderedAccessView( uavSlotId + i, views[i].ptr(), ctrSlotId + i, ~0u); diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index 6c11ff15..8e67b53d 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -127,11 +127,14 @@ namespace dxvk { D3D11ShaderStageUavBinding views = { }; DxvkBindingSet mask = { }; + uint32_t maxCount = 0; + void reset() { - for (uint32_t i = 0; i < views.size(); i++) + for (uint32_t i = 0; i < maxCount; i++) views[i] = nullptr; mask.clear(); + maxCount = 0; } };