From bc10c812d6bc7eddebe89f34e12978d346aa57f4 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Fri, 20 Jun 2025 11:57:12 +0200 Subject: [PATCH] ir3/legalize: apply initial GS/TCS sync in legalize When applying the sync flags after legalize, we might run into the issue of the first instruction not supporting (ss)/(sy). We cannot insert a nop at that point anymore since jump targets have already been calculated. Fix this by applying the sync flags during legalize, where all other sync flags are also applied. Signed-off-by: Job Noorman Part-of: --- src/freedreno/ir3/ir3_compiler_nir.c | 12 ------------ src/freedreno/ir3/ir3_legalize.c | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index f56692e9b73..e37333ba935 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -5880,18 +5880,6 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, */ IR3_PASS(ir, ir3_legalize, so, &max_bary); - /* Set (ss)(sy) on first TCS and GEOMETRY instructions, since we don't - * know what we might have to wait on when coming in from VS chsh. - */ - if (so->type == MESA_SHADER_TESS_CTRL || so->type == MESA_SHADER_GEOMETRY) { - struct ir3_block *first_block = ir3_start_block(ir); - if (!list_is_empty(&first_block->instr_list)) { - struct ir3_instruction *first_instr = list_first_entry( - &first_block->instr_list, struct ir3_instruction, node); - first_instr->flags |= IR3_INSTR_SS | IR3_INSTR_SY; - } - } - if (ctx->compiler->gen >= 7 && so->type == MESA_SHADER_COMPUTE) { struct ir3_instruction *end = ir3_find_end(so->ir); struct ir3_instruction *lock = diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c index d2afdd452d5..757a579c01c 100644 --- a/src/freedreno/ir3/ir3_legalize.c +++ b/src/freedreno/ir3/ir3_legalize.c @@ -423,6 +423,15 @@ ir3_merge_pred_legalize_states(struct ir3_legalize_state *state, &state->needs_ss_or_sy_scalar_war, &pstate->needs_ss_or_sy_scalar_war); } + + gl_shader_stage stage = block->shader->type; + + if (stage == MESA_SHADER_TESS_CTRL || stage == MESA_SHADER_GEOMETRY) { + if (block == ir3_start_block(block->shader)) { + state->force_ss = true; + state->force_sy = true; + } + } } static bool