diff options
| author | 2021-04-04 05:18:09 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:26 -0400 | |
| commit | ffca21487f9728015a2c036fa581ead7d3d074d9 (patch) | |
| tree | d467f65099cd9498bb8bf6e8587f98db7b1e784c /src/shader_recompiler/frontend/maxwell/program.cpp | |
| parent | shader: Add subgroup masks (diff) | |
| download | yuzu-ffca21487f9728015a2c036fa581ead7d3d074d9.tar.gz yuzu-ffca21487f9728015a2c036fa581ead7d3d074d9.tar.xz yuzu-ffca21487f9728015a2c036fa581ead7d3d074d9.zip | |
shader: Eliminate orphan blocks more efficiently
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/program.cpp')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/program.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/program.cpp b/src/shader_recompiler/frontend/maxwell/program.cpp index 7b08f11b0..05b7591bc 100644 --- a/src/shader_recompiler/frontend/maxwell/program.cpp +++ b/src/shader_recompiler/frontend/maxwell/program.cpp | |||
| @@ -14,20 +14,20 @@ | |||
| 14 | #include "shader_recompiler/ir_opt/passes.h" | 14 | #include "shader_recompiler/ir_opt/passes.h" |
| 15 | 15 | ||
| 16 | namespace Shader::Maxwell { | 16 | namespace Shader::Maxwell { |
| 17 | 17 | namespace { | |
| 18 | static void RemoveUnreachableBlocks(IR::Program& program) { | 18 | void RemoveUnreachableBlocks(IR::Program& program) { |
| 19 | // Some blocks might be unreachable if a function call exists unconditionally | 19 | // Some blocks might be unreachable if a function call exists unconditionally |
| 20 | // If this happens the number of blocks and post order blocks will mismatch | 20 | // If this happens the number of blocks and post order blocks will mismatch |
| 21 | if (program.blocks.size() == program.post_order_blocks.size()) { | 21 | if (program.blocks.size() == program.post_order_blocks.size()) { |
| 22 | return; | 22 | return; |
| 23 | } | 23 | } |
| 24 | const IR::BlockList& post_order{program.post_order_blocks}; | 24 | const auto begin{std::next(program.blocks.begin())}; |
| 25 | std::erase_if(program.blocks, [&](IR::Block* block) { | 25 | const auto end{program.blocks.end()}; |
| 26 | return std::ranges::find(post_order, block) == post_order.end(); | 26 | const auto pred{[](IR::Block* block) { return block->ImmediatePredecessors().empty(); }}; |
| 27 | }); | 27 | program.blocks.erase(std::remove_if(begin, end, pred), end); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static void CollectInterpolationInfo(Environment& env, IR::Program& program) { | 30 | void CollectInterpolationInfo(Environment& env, IR::Program& program) { |
| 31 | if (program.stage != Stage::Fragment) { | 31 | if (program.stage != Stage::Fragment) { |
| 32 | return; | 32 | return; |
| 33 | } | 33 | } |
| @@ -60,6 +60,7 @@ static void CollectInterpolationInfo(Environment& env, IR::Program& program) { | |||
| 60 | }(); | 60 | }(); |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | } // Anonymous namespace | ||
| 63 | 64 | ||
| 64 | IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, | 65 | IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, |
| 65 | Environment& env, Flow::CFG& cfg) { | 66 | Environment& env, Flow::CFG& cfg) { |