summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-04-04 21:02:16 -0400
committerGitHub <noreply@github.com>2025-04-05 01:02:16 +0000
commit680fb0b4e9cbb65d46677183a3f68630be1f6179 (patch)
treef6168b68bfa4e4e0e9fcd10bbb1e137cefac67b3 /source
parente3e84a1682c9e2d371f3f50f6425374c8b04828d (diff)
Fix crash when using GLSL global uniforms and varying inputs/ouputs together (#6651)
* Fix incorrect assert on mixed global uniform and varyings * add test * remove unnecessary include * fix incorrect logic * fix comment grammar * address review comments and improve test * minimize diff * fix more issues for cuda build * remove unnecessary line for diff
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-collect-global-uniforms.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/slang/slang-ir-collect-global-uniforms.cpp b/source/slang/slang-ir-collect-global-uniforms.cpp
index 372ef298e..fb2a2233c 100644
--- a/source/slang/slang-ir-collect-global-uniforms.cpp
+++ b/source/slang/slang-ir-collect-global-uniforms.cpp
@@ -179,16 +179,15 @@ struct CollectGlobalUniformParametersContext
// We expect the IR layout pass to have encoded field per-field
// layout so that the "key" for the field is the corresponding
// global shader parameter.
- //
+
+ // Save the original global param before replacement.
auto globalParam = _getGlobalParamFromLayoutFieldKey(fieldLayoutAttr->getFieldKey());
- SLANG_ASSERT(globalParam);
auto globalParamLayout = fieldLayoutAttr->getLayout();
- // Once we have decided to do replacement, we need to
- // set ourselves up to emit the replacement code.
- //
- builder->setInsertBefore(globalParam);
+ // Set insert position to a valid instruction under the global parent scope so we can
+ // create struct keys.
+ builder->setInsertAfter(fieldLayoutAttr->getFieldKey());
// This global parameter needs to be turned into a field of the global
// parameter structure type, and that field will need a key.
@@ -216,6 +215,8 @@ struct CollectGlobalUniformParametersContext
if (!globalParamLayout->getTypeLayout()->findSizeAttr(LayoutResourceKind::Uniform))
continue;
+ SLANG_ASSERT(globalParam);
+
// The new structure field will need to have whatever decorations
// had been put on the global parameter (notably including any name hint)
//