diff options
| author | cheneym2 <acheney@nvidia.com> | 2025-03-05 16:45:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-05 13:45:03 -0800 |
| commit | 0634684495f709fe3594fdcd483cfce7933e54eb (patch) | |
| tree | 7a5d99705475a885b0d22169a56678a399133d12 /source/slang/slang-compiler.h | |
| parent | 5248a0254a48382d06ecb190c9f87c0ab62ff534 (diff) | |
Support SPIR-V deferred linking option (#6500)
The new option "SkipDownstreamLinking" will defer final downstream IR
linking to the user application. This option only has an effect if
there are modules that were precompiled to the target IR using
precompileForTarget().
Until now, the default behavior for SPIR-V was to use deferred linking, and
the default behavior for DXIL was to use immediate/internal linking in Slang.
This change only affects the SPIR-V behavior such that both deferred and
non-deferred linking is supported based on the new option.
To support the non-deferred option, Slang will internally call into
SPIRV-Tools-link to reconstitute a complete SPIR-V shader program when
necessary (due to modules having been precompiled to target IR).
Otherwise, if SkipDownstreamLinking is enabled, the shader returned by
e.g. getTargetCode() or getEntryPointCode() may have import linkage to
the SPIR-V embedded in the constituent modules.
Closes #4994
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-compiler.h')
| -rw-r--r-- | source/slang/slang-compiler.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 10da32400..cfcbe816f 100644 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -1384,7 +1384,8 @@ enum class PassThroughMode : SlangPassThroughIntegral LLVM = SLANG_PASS_THROUGH_LLVM, ///< LLVM 'compiler' SpirvOpt = SLANG_PASS_THROUGH_SPIRV_OPT, ///< pass thorugh spirv to spirv-opt MetalC = SLANG_PASS_THROUGH_METAL, - Tint = SLANG_PASS_THROUGH_TINT, ///< pass through spirv to Tint API + Tint = SLANG_PASS_THROUGH_TINT, ///< pass through spirv to Tint API + SpirvLink = SLANG_PASS_THROUGH_SPIRV_LINK, ///< pass through spirv to spirv-link CountOf = SLANG_PASS_THROUGH_COUNT_OF, }; void printDiagnosticArg(StringBuilder& sb, PassThroughMode val); @@ -2886,6 +2887,12 @@ public: // removed between IR linking and target source generation. bool removeAvailableInDownstreamIR = false; + // Determines if program level compilation like getTargetCode() or getEntryPointCode() + // should return a fully linked downstream program or just the glue SPIR-V/DXIL that + // imports and uses the precompiled SPIR-V/DXIL from constituent modules. + // This is a no-op if modules are not precompiled. + bool shouldSkipDownstreamLinking(); + protected: CodeGenTarget m_targetFormat = CodeGenTarget::Unknown; ExtensionTracker* m_extensionTracker = nullptr; |
