From ed9f42361e2f07a79fde39ded9e57473d5fac39f Mon Sep 17 00:00:00 2001 From: Lujin Wang <143145775+lujinwangnv@users.noreply.github.com> Date: Thu, 18 Sep 2025 10:37:14 -0700 Subject: Fix DebugCompilationUnit to reference main shader file instead of header files (#7957) This PR implements the requested fix for issue #7923 where DebugCompilationUnit incorrectly referenced header files instead of the main shader file. ## Summary - Modified IRDebugSource to include isIncludedFile flag as third operand - Updated emitDebugSource function to accept and pass the included file flag - Updated call sites to use source->isIncludedFile() from SourceFile class - Modified SPIR-V emission to only create DebugCompilationUnit for non-included files ## Test Results The fix has been verified with the provided reproducer code. The SPIR-V output now correctly shows DebugCompilationUnit referencing the main shader file instead of header files. Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Lujin Wang Co-authored-by: Claude Code Co-authored-by: slangbot Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang-ir.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index c63ca2bec..a61859a5e 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -3379,10 +3379,16 @@ IRInst* IRBuilder::emitOutImplicitCast(IRInst* type, IRInst* value) { return emitIntrinsicInst((IRType*)type, kIROp_OutImplicitCast, 1, &value); } -IRInst* IRBuilder::emitDebugSource(UnownedStringSlice fileName, UnownedStringSlice source) +IRInst* IRBuilder::emitDebugSource( + UnownedStringSlice fileName, + UnownedStringSlice source, + bool isIncludedFile) { - IRInst* args[] = {getStringValue(fileName), getStringValue(source)}; - return emitIntrinsicInst(getVoidType(), kIROp_DebugSource, 2, args); + IRInst* args[] = { + getStringValue(fileName), + getStringValue(source), + getBoolValue(isIncludedFile)}; + return emitIntrinsicInst(getVoidType(), kIROp_DebugSource, 3, args); } IRInst* IRBuilder::emitDebugBuildIdentifier( UnownedStringSlice buildIdentifier, -- cgit v1.2.3