From 1b192083233bac4e49e29f881599dec3f9a5ad29 Mon Sep 17 00:00:00 2001 From: Dylan Barrie Date: Wed, 1 Sep 2021 13:02:27 -0700 Subject: [PATCH] Fixes for GS output in the Mesh Viewer in D3D12 - Ensure there is space for the Stream Out counters at the beginning of the SO buffer - Fix use-after-Unmap of the SO statistics data - Reset the state correctly after syncing every 1000 instances - Unmap the SO buffer when no output instances are found --- renderdoc/driver/d3d12/d3d12_postvs.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_postvs.cpp b/renderdoc/driver/d3d12/d3d12_postvs.cpp index 0890ef0bb..8aa78ac5b 100644 --- a/renderdoc/driver/d3d12/d3d12_postvs.cpp +++ b/renderdoc/driver/d3d12/d3d12_postvs.cpp @@ -911,7 +911,9 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) range.End = 0; m_SOStagingBuffer->Unmap(0, &range); - uint64_t outputSize = data->PrimitivesStorageNeeded * 3 * stride; + // reserve space for enough 'buffer filled size' locations + UINT64 SizeCounterBytes = AlignUp(uint64_t(action->numInstances * sizeof(UINT64)), 64ULL); + uint64_t outputSize = SizeCounterBytes + result.PrimitivesStorageNeeded * 3 * stride; if(m_SOBufferSize < outputSize) { @@ -961,8 +963,6 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) rs.ApplyGraphicsRootElements(list); } - // reserve space for enough 'buffer filled size' locations - UINT64 SizeCounterBytes = AlignUp(uint64_t(action->numInstances * sizeof(UINT64)), 64ULL); view.BufferLocation = m_SOBuffer->GetGPUVirtualAddress() + SizeCounterBytes; view.SizeInBytes = m_SOBufferSize - SizeCounterBytes; @@ -1000,6 +1000,16 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) GetDebugManager()->ResetDebugAlloc(); list = GetDebugManager()->ResetDebugList(); + + rs.ApplyState(m_pDevice, list); + + list->SetPipelineState(pipe); + + if(soSig) + { + list->SetGraphicsRootSignature(soSig); + rs.ApplyGraphicsRootElements(list); + } } } @@ -1178,6 +1188,7 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) if(numBytesWritten == 0) { SAFE_RELEASE(soSig); + m_SOStagingBuffer->Unmap(0, &range); return; }