aco/insert_exec_mask: fix top-level to-exact with non-global exact mask
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 23 Feb 2022 17:21:42 +0000 (17:21 +0000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 8 Mar 2022 12:49:59 +0000 (12:49 +0000)
After transitioning to exact after a discard, the exec stack might be:
[exact|global, wqm, exact]

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15244>

src/amd/compiler/aco_insert_exec_mask.cpp

index 62db890..5638b4e 100644 (file)
@@ -522,11 +522,13 @@ process_instructions(exec_ctx& ctx, Block* block, std::vector<aco_ptr<Instructio
          if (ctx.info[block->index].exec.size() >= 2) {
             if (needs == WQM) {
                /* Preserve the WQM mask */
-               ctx.info[block->index].exec[1].second  &= ~mask_type_global;
+               ctx.info[block->index].exec[1].second &= ~mask_type_global;
             } else if (block->kind & block_kind_top_level) {
-               assert(state == WQM);
-               /* Transition to Exact without extra instruction */
-               ctx.info[block->index].exec.pop_back();
+               /* Transition to Exact without extra instruction. Since needs != WQM, we won't need
+                * WQM again.
+                */
+               ctx.info[block->index].exec.resize(1);
+               assert(ctx.info[block->index].exec[0].second == (mask_type_exact | mask_type_global));
                current_exec = get_exec_op(ctx.info[block->index].exec.back().first);
                ctx.info[block->index].exec[0].first = Operand(bld.lm);
             }