summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-11-17 17:50:16 -0800
committerGitHub <noreply@github.com>2023-11-17 17:50:16 -0800
commitc5a6348326742aa647ae79f95cf543472d827b03 (patch)
tree80b8b379b75d52aadd0c20a80a6b7ac8fcf7f74c /source/slang/slang-emit-spirv.cpp
parent6f22477906072870d3b4a5965592b2e8bdf81381 (diff)
Add spirv intrinsic definition for `printf`. (#3340)
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 869484ab9..d071328c4 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -1144,6 +1144,21 @@ struct SPIRVEmitContext
return m_NonSemanticDebugInfoExtInst;
}
+ /// The SPIRV OpExtInstImport inst that represents the NonSemantic debug info
+ /// extended instruction set.
+ SpvInst* m_NonSemanticDebugPrintfExtInst = nullptr;
+
+ SpvInst* getNonSemanticDebugPrintfExtInst()
+ {
+ if (m_NonSemanticDebugPrintfExtInst)
+ return m_NonSemanticDebugPrintfExtInst;
+ m_NonSemanticDebugPrintfExtInst = emitOpExtInstImport(
+ getSection(SpvLogicalSectionID::ExtIntInstImports),
+ nullptr,
+ UnownedStringSlice("NonSemantic.DebugPrintf"));
+ return m_NonSemanticDebugPrintfExtInst;
+ }
+
// Now that we've gotten the core infrastructure out of the way,
// let's start looking at emitting some instructions that make
// up a SPIR-V module.
@@ -4623,6 +4638,11 @@ struct SPIRVEmitContext
emitOperand(getGLSL450ExtInst());
break;
}
+ case kIROp_SPIRVAsmOperandDebugPrintfSet:
+ {
+ emitOperand(getNonSemanticDebugPrintfExtInst());
+ break;
+ }
default:
SLANG_UNREACHABLE("Unhandled case in emitSPIRVAsm");
}