From 48efe87d89148f206c50ab70a90c11ef0592cb0e Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sun, 15 Dec 2024 06:41:22 +0000 Subject: [PATCH] DXIL Added DXIL::ShouldIgnoreSourceMapping() bool DXIL::ShouldIgnoreSourceMapping(const Instruction &inst) Currently implemented as ignoring source mapping for handle creation instructions CreateHandle CreateHandleFromBinding CreateHandleFromHeap AnnotateHandle --- renderdoc/driver/shaders/dxil/dxil_bytecode.h | 1 + .../driver/shaders/dxil/dxil_disassemble.cpp | 24 +++++++++++++++++++ .../driver/shaders/dxil/dxil_reflect.cpp | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode.h b/renderdoc/driver/shaders/dxil/dxil_bytecode.h index 150b9fb11..07c81ae46 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode.h +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode.h @@ -1752,6 +1752,7 @@ DXILDebug::Id GetSSAId(const DXIL::Value *value); bool IsDXCNop(const Instruction &inst); bool IsLLVMDebugCall(const Instruction &inst); bool IsLLVMIntrinsicCall(const Instruction &inst); +bool ShouldIgnoreSourceMapping(const Instruction &inst); bool isUndef(const Value *v); diff --git a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp index a1b041b8b..8d4b927b0 100644 --- a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp @@ -111,6 +111,30 @@ bool DXIL::IsLLVMIntrinsicCall(const Instruction &inst) (inst.getFuncCall()->family == FunctionFamily::LLVMInstrinsic)); } +bool DXIL::ShouldIgnoreSourceMapping(const Instruction &inst) +{ + // Do not set source mapping for handle creation instructions + if(inst.op == Operation::Call) + { + rdcstr funcCallName = inst.getFuncCall()->name; + if(funcCallName.beginsWith("dx.op.")) + { + DXOp dxOpCode = DXOp::NumOpCodes; + RDCASSERT(getival(inst.args[0], dxOpCode)); + RDCASSERT(dxOpCode < DXOp::NumOpCodes, dxOpCode, DXOp::NumOpCodes); + switch(dxOpCode) + { + case DXOp::CreateHandle: + case DXOp::CreateHandleFromBinding: + case DXOp::CreateHandleFromHeap: + case DXOp::AnnotateHandle: return true; + default: break; + } + } + } + return false; +} + // true if the Value is an SSA value i.e. from an instruction, not a constant etc. bool DXIL::IsSSA(const Value *dxilValue) { diff --git a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp index 370941c42..e34f8d20f 100644 --- a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp @@ -2035,7 +2035,7 @@ void Program::GetLineInfo(size_t instruction, uintptr_t offset, LineColumnInfo & if(getLineInfo) { const Instruction *const inst = f.instructions[instruction]; - uint32_t dbgLoc = inst->debugLoc; + uint32_t dbgLoc = ShouldIgnoreSourceMapping(*inst) ? ~0U : inst->debugLoc; if(dbgLoc != ~0U) { const DebugLocation &debugLoc = m_DebugLocations[dbgLoc];