summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-07-16 08:29:13 -0700
committerGitHub <noreply@github.com>2025-07-16 15:29:13 +0000
commit80f43f43466a46a5795ad44e5096d99e12c2a0da (patch)
tree8d0787e4806f3c993439a52ac8a9d71fdb5fdf5b /source
parent0bc89f27b08fa7241a7be4f80c2161f25ea3bf78 (diff)
Strip debug info only for the SpvOpExtInst of debug import type (#7779)
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index aaefdaee0..1657a2980 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -2209,6 +2209,10 @@ SlangResult emitSPIRVFromIR(
class SpirvInstructionHelper
{
public:
+ // The result id of the OpExtInstImport instruction, eg.g %2 below
+ // %2 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
+ uint32_t m_nonSemanticDebugInfoExtSetId = 0;
+
// The index of the SPIRV words in the blob.
// The first 5 words are the header as defined by the SPIRV spec.
enum SpvWordIndex
@@ -2351,6 +2355,7 @@ static SlangResult stripDbgSpirvFromArtifact(
NonSemanticShaderDebugInfo100DebugNoScope,
NonSemanticShaderDebugInfo100DebugInlinedAt,
NonSemanticShaderDebugInfo100DebugLocalVariable,
+ NonSemanticShaderDebugInfo100DebugGlobalVariable,
NonSemanticShaderDebugInfo100DebugInlinedVariable,
NonSemanticShaderDebugInfo100DebugDeclare,
NonSemanticShaderDebugInfo100DebugValue,
@@ -2395,6 +2400,15 @@ static SlangResult stripDbgSpirvFromArtifact(
return;
}
}
+ else if (inst.getOpCode() == SpvOpExtInstImport)
+ {
+ // looking for result id of "OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
+ auto importName = inst.getStringFromInst();
+ if (importName == "NonSemantic.Shader.DebugInfo.100")
+ {
+ spirvInstructionHelper.m_nonSemanticDebugInfoExtSetId = inst.getOperand(0);
+ }
+ }
});
// Iterate over the instructions from the artifact and add them to the list
@@ -2415,14 +2429,19 @@ static SlangResult stripDbgSpirvFromArtifact(
foundDebugString = true;
}
if (!foundDebugString)
+ {
return;
+ }
}
// Also check if the instruction is an extended instruction containing DebugInfo.
if (inst.getOpCode() == SpvOpExtInst)
{
- // Ignore this if the instruction contains DebugInfo.
- if (debugExtInstNumbers.contains(inst.getOperand(3)))
+ // Ignore this if the instruction contains DebugInfo and is from the debug import
+ if (debugExtInstNumbers.contains(inst.getOperand(3)) &&
+ inst.getOperand(2) == spirvInstructionHelper.m_nonSemanticDebugInfoExtSetId)
+ {
return;
+ }
}
// Otherwise this is a non-debug instruction and should be included.
spirvWordsList.addRange(