From 3dbd9d865953d2b8f37474427a36bcc67f8a7b5e Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 4 Aug 2022 18:04:17 +0200 Subject: [PATCH] [d3d11] Track highest bound sampler --- src/d3d11/d3d11_context.cpp | 7 +++++-- src/d3d11/d3d11_context_state.h | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 93e0de074..65516a456 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -3788,7 +3788,7 @@ namespace dxvk { result.stages[i].cbvCount = m_state.cbv[stage].maxCount; result.stages[i].srvCount = m_state.srv[stage].maxCount; result.stages[i].uavCount = 0; - result.stages[i].samplerCount = D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; + result.stages[i].samplerCount = m_state.samplers[stage].maxCount; result.stages[i].reserved = 0; } @@ -4125,7 +4125,7 @@ namespace dxvk { const auto& bindings = m_state.samplers[Stage]; uint32_t slotId = computeSamplerBinding(Stage, 0); - for (uint32_t i = 0; i < bindings.samplers.size(); i++) + for (uint32_t i = 0; i < bindings.maxCount; i++) BindSampler(slotId + i, bindings.samplers[i]); } @@ -4319,6 +4319,9 @@ namespace dxvk { BindSampler(slotId + i, sampler); } } + + bindings.maxCount = std::clamp(StartSlot + NumSamplers, + bindings.maxCount, uint32_t(bindings.samplers.size())); } diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index 6e4e737c4..493f95c2c 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -103,9 +103,13 @@ namespace dxvk { struct D3D11ShaderStageSamplerBinding { std::array samplers = { }; + uint32_t maxCount = 0; + void reset() { - for (uint32_t i = 0; i < samplers.size(); i++) + for (uint32_t i = 0; i < maxCount; i++) samplers[i] = nullptr; + + maxCount = 0; } };