From 675618932476ec3ee7c72fbdbb769f9c7d55ff5c Mon Sep 17 00:00:00 2001 From: Steve Karolewics Date: Tue, 5 Jan 2021 10:44:03 -0800 Subject: [PATCH] Prevent GPU hang in postvs incremental draws with many instances --- renderdoc/driver/d3d12/d3d12_postvs.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/renderdoc/driver/d3d12/d3d12_postvs.cpp b/renderdoc/driver/d3d12/d3d12_postvs.cpp index 7fdf4d1f6..1b6c67cf9 100644 --- a/renderdoc/driver/d3d12/d3d12_postvs.cpp +++ b/renderdoc/driver/d3d12/d3d12_postvs.cpp @@ -978,6 +978,20 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) list->DrawInstanced(drawcall->numIndices, inst, drawcall->vertexOffset, drawcall->instanceOffset); } + + // Instanced draws with a wild number of instances can hang the GPU, sync after every 1000 + if((inst % 1000) == 0) + { + list->Close(); + + l = list; + m_pDevice->GetQueue()->ExecuteCommandLists(1, &l); + m_pDevice->GPUSync(); + + GetDebugManager()->ResetDebugAlloc(); + + list = GetDebugManager()->ResetDebugList(); + } } list->Close();