From ef6c21af908ad72a04c6d7d22ad9cd189a44f2e3 Mon Sep 17 00:00:00 2001 From: Lujin Wang <143145775+lujinwangnv@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:03:29 -0700 Subject: Use 1-based argument index for DebugLocalVariable (#7438) * Use 1-based argument index for DebugLocalVariable GLSLANG/DXC NSDI uses 1-based index of the argument. Slang should follow this convention like other SPIR-V generators. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang-emit-spirv-ops-debug-info-ext.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/slang/slang-emit-spirv-ops-debug-info-ext.h b/source/slang/slang-emit-spirv-ops-debug-info-ext.h index 90a0d44a8..138204af7 100644 --- a/source/slang/slang-emit-spirv-ops-debug-info-ext.h +++ b/source/slang/slang-emit-spirv-ops-debug-info-ext.h @@ -513,6 +513,13 @@ SpvInst* emitOpDebugLocalVariable( { static_assert(isSingular); if (argIndex) + { + // Note +1 logic for argIndex is to follow the convention that + // 1-based index of the argument is used by GLSLANG/DXC NSDI. + IRBuilder builder(argIndex); + IRInst* newArgIndex = + builder.getIntValue(builder.getUIntType(), as(argIndex)->getValue() + 1); + return emitInst( parent, inst, @@ -528,7 +535,8 @@ SpvInst* emitOpDebugLocalVariable( col, scope, flags, - argIndex); + newArgIndex); + } return emitInst( parent, inst, -- cgit v1.2.3