From 0d16228ae22fa2e1a00e62dc099eea08da7717fe Mon Sep 17 00:00:00 2001 From: jarcherNV Date: Fri, 6 Jun 2025 14:30:06 -0700 Subject: Add command line option for separate debug info (#7178) * Add command line option for separate debug info Add command line arg -separate-debug-info which, if provided, produces both a .spv and a .dbg.spv file. The .dbg.spv file contains full debug info and the .spv file has all debug info stripped out. Also add a DebugBuildIdentifier instruction to store a unique hash in both the output files, so they can be more easily matched together. A matching API is provided to allow using the Slang API to retrieve a base and debug SPIRV as well as the debug build identifier string. --- source/slang/slang-emit-spirv.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/slang/slang-emit-spirv.cpp') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 0a3dab78a..ec9857ecf 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -2284,6 +2284,18 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex } return result; } + case kIROp_DebugBuildIdentifier: + { + ensureExtensionDeclaration(UnownedStringSlice("SPV_KHR_non_semantic_info")); + auto debugBuildIdentifier = as(inst); + return emitOpDebugBuildIdentifier( + getSection(SpvLogicalSectionID::GlobalVariables), + inst, + inst->getFullType(), + getNonSemanticDebugInfoExtInst(), + debugBuildIdentifier->getBuildIdentifier(), + debugBuildIdentifier->getFlags()); + } case kIROp_GetStringHash: return emitGetStringHash(inst); case kIROp_AttributedType: @@ -9184,6 +9196,10 @@ SlangResult emitSPIRVFromIR( { context.ensureInst(inst); } + if (as(inst)) + { + context.ensureInst(inst); + } if (shouldPreserveParams && as(inst)) { context.ensureInst(inst); -- cgit v1.2.3