summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-10-05 09:45:54 -0700
committerGitHub <noreply@github.com>2023-10-05 09:45:54 -0700
commit8eb504f6df544014bbcc8972cb6922e9c0f26b2e (patch)
treee09191d453f3fa0a76971727d714aba467c198dc /source/slang/slang-emit-spirv.cpp
parent9572c6049aa4cfc8239697ee89ff9aff1d4bd4cd (diff)
Use designated compiler ID in SPIRV backend. (#3261)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 0ba637978..6d71f1a2c 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -89,6 +89,9 @@ enum class SpvLogicalSectionID
Count,
};
+// The registered id for the Slang compiler.
+static const uint32_t kSPIRVSlangCompilerId = 40;
+
// While the SPIR-V module is nominally (according to the spec) just
// a flat sequence of instructions, in practice some of the instructions
// are logically in a parent/child relationship.
@@ -469,12 +472,8 @@ struct SPIRVEmitContext
m_words.add(spvVersion1_5_0);
// > Generator's magic number.
- // > Its value does not affect any semantics, and is allowed to be 0.
- //
- // TODO: We should eventually register a non-zero
- // magic number to represent Slang/slangc.
//
- m_words.add(0);
+ m_words.add(kSPIRVSlangCompilerId);
// > Bound
//
@@ -4799,6 +4798,13 @@ SlangResult emitSPIRVFromIR(
if (as<IRDebugSource>(inst))
context.ensureInst(inst);
}
+
+ // Emit source language info.
+ context.emitInst(context.getSection(SpvLogicalSectionID::DebugStringsAndSource), nullptr, SpvOpSource,
+ // TODO: update this to SpvSourceLanguageSlang when a new release of spirv-tools is available.
+ SpvLiteralInteger::from32(0), // language identifier, should be SpvSourceLanguageSlang.
+ SpvLiteralInteger::from32(1)); // language version.
+
for (auto irEntryPoint : irEntryPoints)
{
context.ensureInst(irEntryPoint);