pan/va: Assign slots roundrobin

This should reduce false dependencies with asynchronous instructions.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16804>
This commit is contained in:
Alyssa Rosenzweig 2022-05-25 09:39:44 -04:00 committed by Marge Bot
parent aa7393f81a
commit 492f4055dd
2 changed files with 27 additions and 0 deletions

View File

@ -40,6 +40,7 @@ void va_repair_fau(bi_builder *b, bi_instr *I);
void va_fuse_add_imm(bi_instr *I);
void va_lower_constants(bi_context *ctx, bi_instr *I);
void va_lower_isel(bi_instr *I);
void va_assign_slots(bi_context *ctx);
void va_insert_flow_control_nops(bi_context *ctx);
void va_merge_flow(bi_context *ctx);
uint64_t va_pack_instr(const bi_instr *I);

View File

@ -451,3 +451,29 @@ va_insert_flow_control_nops(bi_context *ctx)
if (frag && !start->pass_flags)
bi_flow(ctx, bi_before_block(start), VA_FLOW_DISCARD);
}
/*
* Assign slots to all asynchronous instructions. A few special instructions
* require specific slots. For the rest, we assign slots in a round-robin
* fashion to reduce false dependencies when encoding waits.
*
* This should be called before va_insert_flow_control_nops.
*/
void
va_assign_slots(bi_context *ctx)
{
unsigned counter = 0;
bi_foreach_instr_global(ctx, I) {
if (I->op == BI_OPCODE_BARRIER) {
I->slot = 7;
} else if (I->op == BI_OPCODE_ZS_EMIT || I->op == BI_OPCODE_ATEST) {
I->slot = 0;
} else if (bi_opcode_props[I->op].message) {
I->slot = counter++;
if (counter == 3)
counter = 0;
}
}
}