From c54299f63f3dd70efe1f9c6182fe7e7bf139449c Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Thu, 9 May 2024 07:35:56 +0100 Subject: [PATCH] Added "DXBCContainerDebugger" to wrap DXBC or DXIL shader debugger DXBC and DXIL Shader Debugger's inherit from "DXBCContainerDebugger : public ShaderDebugger". "DXBCContainerDebugger" has member variable "isDXIL" to be able to choose if DXIL or DXBC ShaderDebugger is active and allow the correct cast from "ShaderDebugger" to be made. Added stub of DXILDebug::Debugger in new files "drivers/shaders/dxil/dxil_debug.[h,cpp]" --- renderdoc/driver/d3d12/d3d12_shaderdebug.cpp | 22 +++++++---- renderdoc/driver/shaders/dxbc/dxbc_common.h | 6 +++ renderdoc/driver/shaders/dxbc/dxbc_debug.h | 3 +- renderdoc/driver/shaders/dxil/dxil_debug.cpp | 31 +++++++++++++++ renderdoc/driver/shaders/dxil/dxil_debug.h | 38 +++++++++++++++++++ .../shaders/dxil/renderdoc_dxil.vcxproj | 2 + .../dxil/renderdoc_dxil.vcxproj.filters | 2 + 7 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 renderdoc/driver/shaders/dxil/dxil_debug.cpp create mode 100644 renderdoc/driver/shaders/dxil/dxil_debug.h diff --git a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp index 29db6ebca..893e85ce5 100644 --- a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp +++ b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp @@ -25,6 +25,7 @@ #include "driver/dx/official/d3dcompiler.h" #include "driver/dxgi/dxgi_common.h" #include "driver/shaders/dxbc/dxbc_debug.h" +#include "driver/shaders/dxil/dxil_debug.h" #include "maths/formatpacking.h" #include "strings/string_utils.h" #include "d3d12_command_queue.h" @@ -2804,17 +2805,24 @@ ShaderDebugTrace *D3D12Replay::DebugThread(uint32_t eventId, rdcarray D3D12Replay::ContinueDebug(ShaderDebugger *debugger) { - DXBCDebug::InterpretDebugger *interpreter = (DXBCDebug::InterpretDebugger *)debugger; - - if(!interpreter) + if(!debugger) return {}; - D3D12DebugAPIWrapper apiWrapper(m_pDevice, interpreter->dxbc, interpreter->global, - interpreter->eventId); + if(((DXBCContainerDebugger *)debugger)->isDXIL) + { + return {}; + } + else + { + DXBCDebug::InterpretDebugger *interpreter = (DXBCDebug::InterpretDebugger *)debugger; - D3D12MarkerRegion region(m_pDevice->GetQueue()->GetReal(), "ContinueDebug Simulation Loop"); + D3D12DebugAPIWrapper apiWrapper(m_pDevice, interpreter->dxbc, interpreter->global, + interpreter->eventId); - return interpreter->ContinueDebug(&apiWrapper); + D3D12MarkerRegion region(m_pDevice->GetQueue()->GetReal(), "ContinueDebug Simulation Loop"); + + return interpreter->ContinueDebug(&apiWrapper); + } } void D3D12Replay::FreeDebugger(ShaderDebugger *debugger) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_common.h b/renderdoc/driver/shaders/dxbc/dxbc_common.h index afe2cb86f..35c8c5ff2 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_common.h +++ b/renderdoc/driver/shaders/dxbc/dxbc_common.h @@ -30,6 +30,12 @@ #include "api/replay/rdcstr.h" #include "api/replay/shader_types.h" +struct DXBCContainerDebugger : public ShaderDebugger +{ + DXBCContainerDebugger(bool dxil) : isDXIL(dxil){}; + const bool isDXIL; +}; + namespace DXBCBytecode { class Program; diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.h b/renderdoc/driver/shaders/dxbc/dxbc_debug.h index b44e0ccc9..1c647dae3 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.h +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.h @@ -330,8 +330,9 @@ private: rdcarray m_accessedUAVs; }; -struct InterpretDebugger : public ShaderDebugger +struct InterpretDebugger : public DXBCContainerDebugger { + InterpretDebugger() : DXBCContainerDebugger(false){}; ShaderDebugTrace *BeginDebug(const DXBC::DXBCContainer *dxbcContainer, const ShaderReflection &refl, int activeIndex); diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.cpp b/renderdoc/driver/shaders/dxil/dxil_debug.cpp new file mode 100644 index 000000000..b5a3b7bda --- /dev/null +++ b/renderdoc/driver/shaders/dxil/dxil_debug.cpp @@ -0,0 +1,31 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2024 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#pragma once + +#include "dxil_debug.h" + +namespace DXILDebug +{ +}; // namespace DXILDebug diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.h b/renderdoc/driver/shaders/dxil/dxil_debug.h new file mode 100644 index 000000000..60c1a34c5 --- /dev/null +++ b/renderdoc/driver/shaders/dxil/dxil_debug.h @@ -0,0 +1,38 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2024 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#pragma once + +#include "common/common.h" +#include "driver/shaders/dxbc/dxbc_container.h" +#include "dxil_bytecode.h" + +namespace DXILDebug +{ +struct Debugger : public DXBCContainerDebugger +{ + Debugger() : DXBCContainerDebugger(true){}; +}; + +}; // namespace DXILDebug diff --git a/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj b/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj index 54fd840d1..7e701eefe 100644 --- a/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj +++ b/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj @@ -104,6 +104,7 @@ + @@ -117,6 +118,7 @@ + diff --git a/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj.filters b/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj.filters index fd1d81a2e..9864a68d9 100644 --- a/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj.filters +++ b/renderdoc/driver/shaders/dxil/renderdoc_dxil.vcxproj.filters @@ -12,6 +12,7 @@ + @@ -26,6 +27,7 @@ +