From 3e843351e7dc9e034b982f7de2953c2d6cad0791 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 28 Jan 2019 13:14:35 +0000 Subject: [PATCH] Handle ExecuteIndirect setting a GPU_VA of 0 * I don't know if this is valid or not, but it seems to work without triggering any validation layer warnings or errors which is the best guess. --- .../driver/d3d12/d3d12_command_list_wrap.cpp | 30 ++++++++++++++----- renderdoc/driver/d3d12/d3d12_replay.cpp | 15 ++++++++-- renderdoc/driver/d3d12/d3d12_state.h | 12 ++++---- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index 164ec2c17..91ed5e68d 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -3658,7 +3658,6 @@ void WrappedID3D12GraphicsCommandList2::PatchExecuteIndirect(BakedCmdListInfo &i m_pDevice->GetResIDFromAddr(*addr, id, offs); ID3D12Resource *res = GetResourceManager()->GetLiveAs(id); - RDCASSERT(res); if(res) *addr = res->GetGPUVirtualAddress() + offs; @@ -4023,7 +4022,7 @@ void WrappedID3D12GraphicsCommandList2::ReplayExecuteIndirect(ID3D12GraphicsComm ResourceId id; uint64_t offs = 0; WrappedID3D12Resource::GetResIDFromAddr(*srcAddr, id, offs); - RDCASSERT(id != ResourceId()); + RDCASSERT(*srcAddr == 0 || id != ResourceId()); const uint32_t rootIdx = arg.Constant.RootParameterIndex; @@ -4035,22 +4034,37 @@ void WrappedID3D12GraphicsCommandList2::ReplayExecuteIndirect(ID3D12GraphicsComm { elemType = eRootCBV; - if(executing && id != ResourceId()) - list->SetGraphicsRootConstantBufferView(rootIdx, *srcAddr); + if(executing) + { + if(id != ResourceId()) + list->SetGraphicsRootConstantBufferView(rootIdx, *srcAddr); + else + list->SetGraphicsRootConstantBufferView(rootIdx, 0); + } } else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW) { elemType = eRootSRV; - if(executing && id != ResourceId()) - list->SetGraphicsRootShaderResourceView(rootIdx, *srcAddr); + if(executing) + { + if(id != ResourceId()) + list->SetGraphicsRootShaderResourceView(rootIdx, *srcAddr); + else + list->SetGraphicsRootShaderResourceView(rootIdx, 0); + } } else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW) { elemType = eRootUAV; - if(executing && id != ResourceId()) - list->SetGraphicsRootUnorderedAccessView(rootIdx, *srcAddr); + if(executing) + { + if(id != ResourceId()) + list->SetGraphicsRootUnorderedAccessView(rootIdx, *srcAddr); + else + list->SetGraphicsRootUnorderedAccessView(rootIdx, 0); + } } else { diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index 24bc0d90d..1a844eb1b 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -913,7 +913,10 @@ void D3D12Replay::FillRegisterSpaces(const D3D12RenderState::RootSignature &root cb.resourceId = rm->GetOriginalID(e.id); cb.byteOffset = e.offset; - cb.byteSize = uint32_t(res->GetDesc().Width - cb.byteOffset); + if(res) + cb.byteSize = uint32_t(res->GetDesc().Width - cb.byteOffset); + else + cb.byteSize = 0; } } } @@ -938,7 +941,10 @@ void D3D12Replay::FillRegisterSpaces(const D3D12RenderState::RootSignature &root view.elementByteSize = sizeof(uint32_t); view.firstElement = e.offset / sizeof(uint32_t); - view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t)); + if(res) + view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t)); + else + view.numElements = 0; } } } @@ -963,7 +969,10 @@ void D3D12Replay::FillRegisterSpaces(const D3D12RenderState::RootSignature &root view.elementByteSize = sizeof(uint32_t); view.firstElement = e.offset / sizeof(uint32_t); - view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t)); + if(res) + view.numElements = uint32_t((res->GetDesc().Width - e.offset) / sizeof(uint32_t)); + else + view.numElements = 0; } } } diff --git a/renderdoc/driver/d3d12/d3d12_state.h b/renderdoc/driver/d3d12/d3d12_state.h index 7bde29a64..470991088 100644 --- a/renderdoc/driver/d3d12/d3d12_state.h +++ b/renderdoc/driver/d3d12/d3d12_state.h @@ -92,17 +92,17 @@ struct D3D12RenderState else if(type == eRootCBV) { ID3D12Resource *res = rm->GetCurrentAs(id); - cmd->SetGraphicsRootConstantBufferView(slot, res->GetGPUVirtualAddress() + offset); + cmd->SetGraphicsRootConstantBufferView(slot, res ? res->GetGPUVirtualAddress() + offset : 0); } else if(type == eRootSRV) { ID3D12Resource *res = rm->GetCurrentAs(id); - cmd->SetGraphicsRootShaderResourceView(slot, res->GetGPUVirtualAddress() + offset); + cmd->SetGraphicsRootShaderResourceView(slot, res ? res->GetGPUVirtualAddress() + offset : 0); } else if(type == eRootUAV) { ID3D12Resource *res = rm->GetCurrentAs(id); - cmd->SetGraphicsRootUnorderedAccessView(slot, res->GetGPUVirtualAddress() + offset); + cmd->SetGraphicsRootUnorderedAccessView(slot, res ? res->GetGPUVirtualAddress() + offset : 0); } } @@ -122,17 +122,17 @@ struct D3D12RenderState else if(type == eRootCBV) { ID3D12Resource *res = rm->GetCurrentAs(id); - cmd->SetComputeRootConstantBufferView(slot, res->GetGPUVirtualAddress() + offset); + cmd->SetComputeRootConstantBufferView(slot, res ? res->GetGPUVirtualAddress() + offset : 0); } else if(type == eRootSRV) { ID3D12Resource *res = rm->GetCurrentAs(id); - cmd->SetComputeRootShaderResourceView(slot, res->GetGPUVirtualAddress() + offset); + cmd->SetComputeRootShaderResourceView(slot, res ? res->GetGPUVirtualAddress() + offset : 0); } else if(type == eRootUAV) { ID3D12Resource *res = rm->GetCurrentAs(id); - cmd->SetComputeRootUnorderedAccessView(slot, res->GetGPUVirtualAddress() + offset); + cmd->SetComputeRootUnorderedAccessView(slot, res ? res->GetGPUVirtualAddress() + offset : 0); } }