diff options
| author | Yong He <yonghe@outlook.com> | 2021-12-06 14:50:42 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-06 14:50:42 -0800 |
| commit | ef4ee0b2d42b1fe9ce36c67526cf853343d98ea0 (patch) | |
| tree | 15d4c441cb407a4f4d39318f525e471a98ff1d87 /source | |
| parent | 5cbd61774c6ef2209fa0afc79b1dbbb68514346b (diff) | |
Fix shader-toy example. (#2047)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-clone.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/slang/slang-ir-clone.cpp b/source/slang/slang-ir-clone.cpp index f4dc81991..a6c462501 100644 --- a/source/slang/slang-ir-clone.cpp +++ b/source/slang/slang-ir-clone.cpp @@ -139,6 +139,17 @@ static void _cloneInstDecorationsAndChildren( builder->sharedBuilder = sharedBuilder; builder->setInsertInto(newInst); + // If `newInst` already has non-decoration children, we want to + // insert the new children between the existing decoration and non-decoration children + // so that we maintain the invariant that all decorations are defined before non-decorations. + if (auto lastDecor = newInst->getLastDecoration()) + { + if (auto nextInstBeforeLastDecor = lastDecor->getNextInst()) + { + builder->setInsertBefore(nextInstBeforeLastDecor); + } + } + // When applying the first phase of cloning to // children, we will keep track of those that // require the second phase. |
