diff options
| author | cheneym2 <acheney@nvidia.com> | 2024-09-05 14:59:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-05 11:59:28 -0700 |
| commit | 313677160a186efebf83fab4df7d08dd119a5cd2 (patch) | |
| tree | e12e159846f0b7b0e3567d028ad4a57cd9f001aa /source/slang/slang.cpp | |
| parent | 33e8bfd43f66613f6f834fb0e1816ef43071f2e4 (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.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index b0898b1a0..91ed3de5f 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -3305,18 +3305,21 @@ SlangResult EndToEndCompileRequest::executeActionsInner() return SLANG_OK; } - // If requested, attempt to compile the translation unit all the way down to the target language - // and stash the result blob in an IR op. - if (getOptionSet().getBoolOption(CompilerOptionName::EmbedDXIL)) + // If requested, attempt to compile the translation unit all the way down to the target language(s) + // and stash the result blobs in IR. + for (auto target : getLinkage()->targets) { - auto frontEndReq = getFrontEndReq(); - - for (auto translationUnit : frontEndReq->translationUnits) + SlangCompileTarget targetEnum = SlangCompileTarget(target->getTarget()); + if (target->getOptionSet().getBoolOption(CompilerOptionName::EmbedDownstreamIR)) { - SlangCompileTarget target = SlangCompileTarget(SlangCompileTarget::SLANG_DXIL); - SLANG_RETURN_ON_FAIL(translationUnit->getModule()->precompileForTarget( - target, - nullptr)); + auto frontEndReq = getFrontEndReq(); + + for (auto translationUnit : frontEndReq->translationUnits) + { + SLANG_RETURN_ON_FAIL(translationUnit->getModule()->precompileForTarget( + targetEnum, + nullptr)); + } } } @@ -5939,9 +5942,9 @@ void EndToEndCompileRequest::setTargetGenerateWholeProgram(int targetIndex, bool getTargetOptionSet(targetIndex).set(CompilerOptionName::GenerateWholeProgram, value); } -void EndToEndCompileRequest::setEmbedDXIL(bool value) +void EndToEndCompileRequest::setTargetEmbedDownstreamIR(int targetIndex, bool value) { - getOptionSet().set(CompilerOptionName::EmbedDXIL, value); + getTargetOptionSet(targetIndex).set(CompilerOptionName::EmbedDownstreamIR, value); } void EndToEndCompileRequest::setTargetLineDirectiveMode( |
