summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authorcheneym2 <acheney@nvidia.com>2024-09-05 14:59:28 -0400
committerGitHub <noreply@github.com>2024-09-05 11:59:28 -0700
commit313677160a186efebf83fab4df7d08dd119a5cd2 (patch)
treee12e159846f0b7b0e3567d028ad4a57cd9f001aa /source/slang/slang-emit-spirv.cpp
parent33e8bfd43f66613f6f834fb0e1816ef43071f2e4 (diff)
Initial -embed-spirv support (#4974)
* Initial -embed-spirv support Add support for SPIR-V precompilation using the framework established for DXIL. Work on #4883 * SLANG_UNUSED * Add linkage attributes to exported spirv functions * Combine DXIL and SPIRV paths * Whitespace fix * Merge remaining precompiled spirv/dxil paths * Change inst accessors to return codegentarget * Add unit test for precompiled spirv --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 9088e959a..a2da4801e 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -3933,6 +3933,17 @@ struct SPIRVEmitContext
}
break;
}
+ case kIROp_DownstreamModuleExportDecoration:
+ {
+ requireSPIRVCapability(SpvCapabilityLinkage);
+ auto name = decoration->getParent()->findDecoration<IRExportDecoration>()->getMangledName();
+ emitInst(getSection(SpvLogicalSectionID::Annotations),
+ decoration,
+ SpvOpDecorate,
+ dstID,
+ SpvDecorationLinkageAttributes, name, SpvLinkageTypeExport);
+ break;
+ }
// ...
}
@@ -6847,12 +6858,27 @@ SlangResult emitSPIRVFromIR(
#endif
auto shouldPreserveParams = codeGenContext->getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::PreserveParameters);
+ auto generateWholeProgram = codeGenContext->getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::GenerateWholeProgram);
for (auto inst : irModule->getGlobalInsts())
{
if (as<IRDebugSource>(inst))
+ {
context.ensureInst(inst);
+ }
if (shouldPreserveParams && as<IRGlobalParam>(inst))
+ {
context.ensureInst(inst);
+ }
+ if (generateWholeProgram)
+ {
+ if (auto func = as<IRFunc>(inst))
+ {
+ if (func->findDecoration<IRDownstreamModuleExportDecoration>())
+ {
+ context.ensureInst(inst);
+ }
+ }
+ }
}
// Emit source language info.