From c7718e5952c06667a8e93fa2e71f4037a462802e Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 18 Nov 2019 18:38:27 +0100 Subject: [PATCH] [d3d11] Zero-initialize UAV counters Fixes a hang in Dirt Rally on RADV. --- src/d3d11/d3d11_device.cpp | 4 +++- src/d3d11/d3d11_initializer.cpp | 18 ++++++++++++++++++ src/d3d11/d3d11_initializer.h | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index e78c125c5..3f5a5fb69 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -427,7 +427,9 @@ namespace dxvk { return S_FALSE; try { - *ppUAView = ref(new D3D11UnorderedAccessView(this, pResource, &desc)); + auto uav = new D3D11UnorderedAccessView(this, pResource, &desc); + m_initializer->InitUavCounter(uav); + *ppUAView = ref(uav); return S_OK; } catch (const DxvkError& e) { Logger::err(e.message()); diff --git a/src/d3d11/d3d11_initializer.cpp b/src/d3d11/d3d11_initializer.cpp index 0aa298db5..916165c9c 100644 --- a/src/d3d11/d3d11_initializer.cpp +++ b/src/d3d11/d3d11_initializer.cpp @@ -47,6 +47,24 @@ namespace dxvk { } + void D3D11Initializer::InitUavCounter( + D3D11UnorderedAccessView* pUav) { + auto counterBuffer = pUav->GetCounterSlice(); + + if (!counterBuffer.defined()) + return; + + std::lock_guard lock(m_mutex); + + const uint32_t zero = 0; + m_context->updateBuffer( + counterBuffer.buffer(), + 0, sizeof(zero), &zero); + + FlushImplicit(); + } + + void D3D11Initializer::InitDeviceLocalBuffer( D3D11Buffer* pBuffer, const D3D11_SUBRESOURCE_DATA* pInitialData) { diff --git a/src/d3d11/d3d11_initializer.h b/src/d3d11/d3d11_initializer.h index 96a094d6a..de6e60995 100644 --- a/src/d3d11/d3d11_initializer.h +++ b/src/d3d11/d3d11_initializer.h @@ -34,6 +34,9 @@ namespace dxvk { void InitTexture( D3D11CommonTexture* pTexture, const D3D11_SUBRESOURCE_DATA* pInitialData); + + void InitUavCounter( + D3D11UnorderedAccessView* pUav); private: