From 08b403f65507f4beac47d7d6816bad243cd811e9 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 26 Nov 2018 17:16:29 +0100 Subject: [PATCH] [d3d11] Fix potential UAV binding issue When rebinding an already active UAV, we still need to update the counter unless the app passed a value of -1. Ref #712. --- src/d3d11/d3d11_context.cpp | 16 ++++++++++------ src/d3d11/d3d11_context.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index f69c3d16..4c8e2506 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -2976,8 +2976,8 @@ namespace dxvk { void D3D11DeviceContext::BindUnorderedAccessView( UINT UavSlot, - UINT CtrSlot, D3D11UnorderedAccessView* pUav, + UINT CtrSlot, UINT Counter) { EmitCs([ cUavSlotId = UavSlot, @@ -3129,11 +3129,14 @@ namespace dxvk { for (uint32_t i = 0; i < NumUAVs; i++) { auto uav = static_cast(ppUnorderedAccessViews[i]); + auto ctr = pUAVInitialCounts ? pUAVInitialCounts[i] : ~0u; - if (Bindings[StartSlot + i] != uav) { + if (Bindings[StartSlot + i] != uav || ctr != ~0u) { Bindings[StartSlot + i] = uav; - BindUnorderedAccessView(uavSlotId + i, ctrSlotId + i, uav, - pUAVInitialCounts ? pUAVInitialCounts[i] : ~0u); + + BindUnorderedAccessView( + uavSlotId + i, uav, + ctrSlotId + i, ctr); } } } @@ -3285,8 +3288,9 @@ namespace dxvk { for (uint32_t i = 0; i < Bindings.size(); i++) { BindUnorderedAccessView( - uavSlotId + i, ctrSlotId + i, - Bindings[i].ptr(), ~0u); + uavSlotId + i, + Bindings[i].ptr(), + ctrSlotId + i, ~0u); } } diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 052c552b..7ce4375d 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -716,8 +716,8 @@ namespace dxvk { void BindUnorderedAccessView( UINT UavSlot, - UINT CtrSlot, D3D11UnorderedAccessView* pUav, + UINT CtrSlot, UINT Counter); void DiscardBuffer(