diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index 889813c2a..622cf8ffa 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -328,7 +328,26 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR m_DisassemblyView->setText(disasm.c_str()); m_DisassemblyView->setReadOnly(true); + bool preferSourceDebug = false; + + for(const ShaderCompileFlag &flag : m_ShaderDetails->debugInfo.compileFlags.flags) + { + if(flag.name == "preferSourceDebug") + { + preferSourceDebug = true; + break; + } + } + updateDebugging(); + + // we do updateDebugging() again because the first call finds the scintilla for the current + // source file, the second time jumps to it. + if(preferSourceDebug) + { + gotoSourceDebugging(); + updateDebugging(); + } }); }); } diff --git a/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp b/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp index cdf5d222d..4122d4ce4 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp @@ -27,6 +27,7 @@ #include #include "api/app/renderdoc_app.h" #include "common/common.h" +#include "driver/dx/official/d3dcompiler.h" #include "serialise/serialiser.h" #include "strings/string_utils.h" #include "dxbc_sdbg.h" @@ -1663,6 +1664,11 @@ ShaderCompileFlags EncodeFlags(const uint32_t flags) ret.flags = {{"compileFlags", StringFormat::Fmt("%u", flags)}}; + // If D3DCOMPILE_SKIP_OPTIMIZATION is set, then prefer source-level debugging as it should be + // accurate enough to work with. + if(flags & D3DCOMPILE_SKIP_OPTIMIZATION) + ret.flags.push_back({"preferSourceDebug", "1"}); + return ret; }