From 0634684495f709fe3594fdcd483cfce7933e54eb Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Wed, 5 Mar 2025 16:45:03 -0500 Subject: 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> --- source/slang/slang-compiler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/slang/slang-compiler.cpp') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 58cc55e71..3839e0722 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -2669,6 +2669,12 @@ bool CodeGenContext::shouldDumpIR() return getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::DumpIr); } +bool CodeGenContext::shouldSkipDownstreamLinking() +{ + return getTargetProgram()->getOptionSet().getBoolOption( + CompilerOptionName::SkipDownstreamLinking); +} + bool CodeGenContext::shouldReportCheckpointIntermediates() { return getTargetProgram()->getOptionSet().getBoolOption( -- cgit v1.2.3