diff options
| author | Yong He <yonghe@outlook.com> | 2024-11-12 21:01:47 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-12 21:01:47 -0800 |
| commit | 0754abee603c1afa7803a444124acc9d268d2f0a (patch) | |
| tree | 016bf4c03ff58595c62ec94e902137b1191e5960 /source/slang/slang-emit.cpp | |
| parent | 567c7e09b6df36b535c4ffbccd6a3658d18e04c2 (diff) | |
Push buffer load to end of access chain. (#5544)
* Push buffer load to end of access chain.
* Update test.
* Fix.
* Fix.
* Fix.
* Make more robust.
* Fix.
Diffstat (limited to 'source/slang/slang-emit.cpp')
| -rw-r--r-- | source/slang/slang-emit.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 1950f251c..05bb12ecc 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -30,6 +30,7 @@ #include "slang-ir-com-interface.h" #include "slang-ir-composite-reg-to-mem.h" #include "slang-ir-dce.h" +#include "slang-ir-defer-buffer-load.h" #include "slang-ir-defunctionalization.h" #include "slang-ir-diff-call.h" #include "slang-ir-dll-export.h" @@ -951,6 +952,11 @@ Result linkAndOptimizeIR( // Inline calls to any functions marked with [__unsafeInlineEarly] or [ForceInline]. performForceInlining(irModule); + // Push `structuredBufferLoad` to the end of access chain to avoid loading unnecessary data. + if (isKhronosTarget(targetRequest) || isMetalTarget(targetRequest) || + isWGPUTarget(targetRequest)) + deferBufferLoad(irModule); + // Specialization can introduce dead code that could trip // up downstream passes like type legalization, so we // will run a DCE pass to clean up after the specialization. |
