aco: set loop_info::has_discard for demotes

We need the loop header phis for the outer exec masks. Needed for
dEQP-VK.glsl.demote.dynamic_loop_texture

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
This commit is contained in:
Rhys Perry 2019-09-26 10:33:43 +01:00
parent 237c7636ca
commit b711e62e61
3 changed files with 9 additions and 5 deletions

View file

@ -72,7 +72,7 @@ struct loop_info {
uint8_t needs; uint8_t needs;
bool has_divergent_break; bool has_divergent_break;
bool has_divergent_continue; bool has_divergent_continue;
bool has_discard; bool has_discard; /* has a discard or demote */
loop_info(Block* b, uint16_t num, uint8_t needs, bool breaks, bool cont, bool discard) : loop_info(Block* b, uint16_t num, uint8_t needs, bool breaks, bool cont, bool discard) :
loop_header(b), num_exec_masks(num), needs(needs), has_divergent_break(breaks), loop_header(b), num_exec_masks(num), needs(needs), has_divergent_break(breaks),
has_divergent_continue(cont), has_discard(discard) {} has_divergent_continue(cont), has_discard(discard) {}
@ -279,7 +279,8 @@ void calculate_wqm_needs(exec_ctx& exec_ctx)
ever_again_needs |= exec_ctx.info[i].block_needs & ~Exact_Branch; ever_again_needs |= exec_ctx.info[i].block_needs & ~Exact_Branch;
if (block.kind & block_kind_discard || if (block.kind & block_kind_discard ||
block.kind & block_kind_uses_discard_if) block.kind & block_kind_uses_discard_if ||
block.kind & block_kind_uses_demote)
ever_again_needs |= Exact; ever_again_needs |= Exact;
/* don't propagate WQM preservation further than the next top_level block */ /* don't propagate WQM preservation further than the next top_level block */
@ -629,6 +630,7 @@ void process_instructions(exec_ctx& ctx, Block* block,
(ctx.info[block->index].block_needs & state) != (ctx.info[block->index].block_needs & state) !=
(ctx.info[block->index].block_needs & (WQM | Exact))) || (ctx.info[block->index].block_needs & (WQM | Exact))) ||
block->kind & block_kind_uses_discard_if || block->kind & block_kind_uses_discard_if ||
block->kind & block_kind_uses_demote ||
block->kind & block_kind_needs_lowering; block->kind & block_kind_needs_lowering;
if (!process) { if (!process) {
std::vector<aco_ptr<Instruction>>::iterator it = std::next(block->instructions.begin(), idx); std::vector<aco_ptr<Instruction>>::iterator it = std::next(block->instructions.begin(), idx);
@ -811,7 +813,8 @@ void add_branch_code(exec_ctx& ctx, Block* block)
needs |= ctx.info[i].block_needs; needs |= ctx.info[i].block_needs;
if (loop_block.kind & block_kind_uses_discard_if || if (loop_block.kind & block_kind_uses_discard_if ||
loop_block.kind & block_kind_discard) loop_block.kind & block_kind_discard ||
loop_block.kind & block_kind_uses_demote)
has_discard = true; has_discard = true;
if (loop_block.loop_nest_depth != loop_nest_depth) if (loop_block.loop_nest_depth != loop_nest_depth)
continue; continue;

View file

@ -5831,7 +5831,7 @@ void visit_intrinsic(isel_context *ctx, nir_intrinsic_instr *instr)
} }
case nir_intrinsic_demote: case nir_intrinsic_demote:
bld.pseudo(aco_opcode::p_demote_to_helper); bld.pseudo(aco_opcode::p_demote_to_helper);
ctx->block->kind |= block_kind_needs_lowering; ctx->block->kind |= block_kind_uses_demote;
ctx->program->needs_exact = true; ctx->program->needs_exact = true;
break; break;
case nir_intrinsic_demote_if: { case nir_intrinsic_demote_if: {
@ -5839,7 +5839,7 @@ void visit_intrinsic(isel_context *ctx, nir_intrinsic_instr *instr)
as_divergent_bool(ctx, get_ssa_temp(ctx, instr->src[0].ssa), false), as_divergent_bool(ctx, get_ssa_temp(ctx, instr->src[0].ssa), false),
Operand(exec, s2)); Operand(exec, s2));
bld.pseudo(aco_opcode::p_demote_to_helper, cond); bld.pseudo(aco_opcode::p_demote_to_helper, cond);
ctx->block->kind |= block_kind_needs_lowering; ctx->block->kind |= block_kind_uses_demote;
ctx->program->needs_exact = true; ctx->program->needs_exact = true;
break; break;
} }

View file

@ -924,6 +924,7 @@ enum block_kind {
block_kind_invert = 1 << 11, block_kind_invert = 1 << 11,
block_kind_uses_discard_if = 1 << 12, block_kind_uses_discard_if = 1 << 12,
block_kind_needs_lowering = 1 << 13, block_kind_needs_lowering = 1 << 13,
block_kind_uses_demote = 1 << 14,
}; };