From e8e7ad711a08038f5d6e298ed8e81271a7ad9813 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 26 Oct 2016 18:30:48 +0200 Subject: [PATCH] Don't set stale table root signature entries for non-current heaps * The problem is we need to keep current state for both graphics and compute because while setting a root signature invalidates bindings, setting compute doesn't invalidate graphics and vice-versa. * However it can be invalid to try and re-apply in one go if we're only drawing and not dispatching and some of the compute elements are invalid. * Rather than try to figure out which one *should* be valid, instead we just skip invalid binds that don't have matching heaps. --- renderdoc/driver/d3d12/d3d12_state.cpp | 30 ++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_state.cpp b/renderdoc/driver/d3d12/d3d12_state.cpp index 790529067..00487e264 100644 --- a/renderdoc/driver/d3d12/d3d12_state.cpp +++ b/renderdoc/driver/d3d12/d3d12_state.cpp @@ -205,7 +205,20 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd) GetResourceManager()->GetCurrentAs(graphics.rootsig)); for(size_t i = 0; i < graphics.sigelems.size(); i++) - graphics.sigelems[i].SetToGraphics(GetResourceManager(), cmd, (UINT)i); + { + // just don't set tables that aren't in the descriptor heaps, since it's invalid and can crash + // and is probably just from stale bindings that aren't going to be used + if(graphics.sigelems[i].type == eRootTable || + std::find(heaps.begin(), heaps.end(), graphics.sigelems[i].id) != heaps.end()) + { + graphics.sigelems[i].SetToGraphics(GetResourceManager(), cmd, (UINT)i); + } + else + { + RDCDEBUG("Skipping setting possibly stale graphics root table referring to heap %llu", + graphics.sigelems[i].id); + } + } } if(compute.rootsig != ResourceId()) @@ -214,6 +227,19 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd) GetResourceManager()->GetCurrentAs(compute.rootsig)); for(size_t i = 0; i < compute.sigelems.size(); i++) - compute.sigelems[i].SetToCompute(GetResourceManager(), cmd, (UINT)i); + { + // just don't set tables that aren't in the descriptor heaps, since it's invalid and can crash + // and is probably just from stale bindings that aren't going to be used + if(compute.sigelems[i].type != eRootTable || + std::find(heaps.begin(), heaps.end(), compute.sigelems[i].id) != heaps.end()) + { + compute.sigelems[i].SetToCompute(GetResourceManager(), cmd, (UINT)i); + } + else + { + RDCDEBUG("Skipping setting possibly stale compute root table referring to heap %llu", + compute.sigelems[i].id); + } + } } } \ No newline at end of file