diff options
| author | Yong He <yonghe@outlook.com> | 2024-06-12 09:27:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 09:27:14 -0700 |
| commit | fa8c11ebe8f9b1bf2174a5a4dbe92a34c16811c8 (patch) | |
| tree | 1da9ed028486e9de5a2129143ea436014a063d7c /source/slang/slang-ir-link.cpp | |
| parent | 3fe4a77287345c303aeb985e24ee237f272e8eca (diff) | |
Add option to preserve shader parameter declaration in output SPIRV. (#4344)
* Add option to preserve shader parameter declarations in output.
* Add test.
Diffstat (limited to 'source/slang/slang-ir-link.cpp')
| -rw-r--r-- | source/slang/slang-ir-link.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp index eb660c8a7..5bb485b22 100644 --- a/source/slang/slang-ir-link.cpp +++ b/source/slang/slang-ir-link.cpp @@ -1830,12 +1830,16 @@ LinkedIR linkIR( } } + bool shouldCopyGlobalParams = linkage->m_optionSet.getBoolOption(CompilerOptionName::PreserveParameters); + for (IRModule* irModule : irModules) { for (auto inst : irModule->getGlobalInsts()) { - // Is it (HLSL) `export` clone - if (_isHLSLExported(inst)) + // We need to copy over exported symbols, + // and any global parameters if preserve-params option is set. + if (_isHLSLExported(inst) || + shouldCopyGlobalParams && as<IRGlobalParam>(inst)) { auto cloned = cloneValue(context, inst); if (!cloned->findDecorationImpl(kIROp_KeepAliveDecoration)) |
