diff --git a/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp index 1a604c6f2..91da40a86 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp @@ -23,10 +23,13 @@ ******************************************************************************/ #include "d3d12_command_list.h" +#include "core/settings.h" #include "d3d12_debug.h" #include "data/hlsl/hlsl_cbuffers.h" +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_RTAuditing); + static rdcstr ToHumanStr(const D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE &el) { BEGIN_ENUM_STRINGISE(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE); @@ -1015,8 +1018,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_BuildRaytracingAccelerationStru bakedCmdInfo.state.ApplyState(m_pDevice, list); } - Unwrap4(list)->BuildRaytracingAccelerationStructure(&AccStructDesc, NumPostbuildInfoDescs, - pPostbuildInfoDescs); + if(!D3D12_Debug_RTAuditing()) + { + Unwrap4(list)->BuildRaytracingAccelerationStructure(&AccStructDesc, NumPostbuildInfoDescs, + pPostbuildInfoDescs); + } } } else @@ -1047,9 +1053,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_BuildRaytracingAccelerationStru } } - Unwrap4(pCommandList) - ->BuildRaytracingAccelerationStructure(&AccStructDesc, NumPostbuildInfoDescs, - pPostbuildInfoDescs); + if(!D3D12_Debug_RTAuditing()) + { + Unwrap4(pCommandList) + ->BuildRaytracingAccelerationStructure(&AccStructDesc, NumPostbuildInfoDescs, + pPostbuildInfoDescs); + } m_Cmd->AddEvent(); @@ -1398,15 +1407,21 @@ bool WrappedID3D12GraphicsCommandList::Serialise_CopyRaytracingAccelerationStruc { ID3D12GraphicsCommandList4 *list = Unwrap4(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID)); - list->CopyRaytracingAccelerationStructure(DestAccelerationStructureData, - SourceAccelerationStructureData, Mode); + if(!D3D12_Debug_RTAuditing()) + { + list->CopyRaytracingAccelerationStructure(DestAccelerationStructureData, + SourceAccelerationStructureData, Mode); + } } } else { - Unwrap4(pCommandList) - ->CopyRaytracingAccelerationStructure(DestAccelerationStructureData, - SourceAccelerationStructureData, Mode); + if(!D3D12_Debug_RTAuditing()) + { + Unwrap4(pCommandList) + ->CopyRaytracingAccelerationStructure(DestAccelerationStructureData, + SourceAccelerationStructureData, Mode); + } m_Cmd->AddEvent(); @@ -1701,6 +1716,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_DispatchRays(SerialiserType &se const D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state; + if(D3D12_Debug_RTAuditing()) + { + Desc.Width = Desc.Height = Desc.Depth = 0; + } + if(IsActiveReplaying(m_State)) { if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID)) diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index eefa66eca..bfebbebc9 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -24,11 +24,14 @@ #include "d3d12_command_list.h" #include +#include "core/settings.h" #include "driver/dxgi/dxgi_common.h" #include "driver/ihv/amd/official/DXExt/AmdExtD3DCommandListMarkerApi.h" #include "d3d12_command_queue.h" #include "d3d12_debug.h" +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_RTAuditing); + template bool WrappedID3D12GraphicsCommandList::Serialise_Close(SerialiserType &ser) { @@ -4090,10 +4093,16 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ExecuteIndirect( const D3D12RenderState &state = cmdInfo.state; + WrappedID3D12CommandSignature *comSig = (WrappedID3D12CommandSignature *)pCommandSignature; + + if(D3D12_Debug_RTAuditing() && comSig->sig.raytraced) + { + // only one execute is allowed per command signature, if it's ray tracing and we're auditing then turn it off + MaxCommandCount = 0; + } + if(IsActiveReplaying(m_State)) { - WrappedID3D12CommandSignature *comSig = (WrappedID3D12CommandSignature *)pCommandSignature; - uint32_t actualCount = MaxCommandCount; if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID)) @@ -4325,8 +4334,6 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ExecuteIndirect( } else { - WrappedID3D12CommandSignature *comSig = (WrappedID3D12CommandSignature *)pCommandSignature; - BarrierSet barriers; barriers.Configure(pArgumentBuffer, cmdInfo.GetState(m_pDevice, GetResID(pArgumentBuffer)), diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index 3729077e4..276ac36b7 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -39,6 +39,8 @@ RDOC_EXTERN_CONFIG(bool, Replay_Debug_SingleThreadedCompilation); RDOC_DEBUG_CONFIG(bool, D3D12_Experimental_EnableRTSupport, false, "Enable support for experimental DXR support"); +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_RTAuditing); + static RDResult DeferredPipelineCompile(ID3D12Device *device, const D3D12_GRAPHICS_PIPELINE_STATE_DESC &Descriptor, WrappedID3D12PipelineState *wrappedPipe) @@ -1322,6 +1324,18 @@ bool WrappedID3D12Device::Serialise_DynamicDescriptorWrite(SerialiserType &ser, // safe to pass an invalid heap type to Create() as these descriptors will by definition not // be undefined RDCASSERT(desc.GetType() != D3D12DescriptorType::Undefined); + + // to remove any ray query work, force AS descriptors to NULL + if(D3D12_Debug_RTAuditing() && desc.GetType() == D3D12DescriptorType::SRV) + { + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = desc.GetSRV(); + if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE) + { + srvDesc.RaytracingAccelerationStructure.Location = 0; + desc.Init(NULL, &srvDesc); + } + } + desc.Create(D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES, this, *handle); handle->GetHeap()->MarkMutableIndex(handle->GetHeapIndex()); } diff --git a/renderdoc/driver/d3d12/d3d12_initstate.cpp b/renderdoc/driver/d3d12/d3d12_initstate.cpp index a6b50a211..8953b6578 100644 --- a/renderdoc/driver/d3d12/d3d12_initstate.cpp +++ b/renderdoc/driver/d3d12/d3d12_initstate.cpp @@ -36,6 +36,8 @@ RDOC_EXTERN_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing); RDOC_CONFIG(bool, D3D12_Debug_DriverASSerialisation, false, "Use driver-side serialisation for saving and restoring ASs"); +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_RTAuditing); + template void DoSerialise(SerialiserType &ser, ASBuildData::RVAWithStride &el) { @@ -814,6 +816,23 @@ bool D3D12ResourceManager::Serialise_InitialState(SerialiserType &ser, ResourceI // only iterate over the 'real' number of descriptors, not the number after we've patched desc.NumDescriptors = heap->GetNumDescriptors(); + // to remove any ray query work, force AS descriptors to NULL + if(D3D12_Debug_RTAuditing()) + { + for(uint32_t i = 0; i < RDCMIN(numElems, desc.NumDescriptors); i++) + { + if(Descriptors[i].GetType() == D3D12DescriptorType::SRV) + { + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = Descriptors[i].GetSRV(); + if(srvDesc.ViewDimension == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE) + { + srvDesc.RaytracingAccelerationStructure.Location = 0; + Descriptors[i].Init(NULL, &srvDesc); + } + } + } + } + for(uint32_t i = 0; i < RDCMIN(numElems, desc.NumDescriptors); i++) { Descriptors[i].Create(desc.Type, m_Device, handle);