From ef162f9a6f8d4dae0cfbf77b5dbff4b5aaf91d3d Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Thu, 15 Aug 2024 08:46:35 +0200 Subject: [PATCH] ir3: correctly count vectorized instructions for tex prefetch The tex prefetch heuristic simply counts the number of NIR instructions. Since a vectorized NIR instruction expands to an ir3 instruction per component, we have to take this into account while counting them. Signed-off-by: Job Noorman Part-of: --- src/freedreno/ir3/ir3_context.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/freedreno/ir3/ir3_context.c b/src/freedreno/ir3/ir3_context.c index be94323f016..695b5a6b27f 100644 --- a/src/freedreno/ir3/ir3_context.c +++ b/src/freedreno/ir3/ir3_context.c @@ -155,7 +155,15 @@ ir3_context_init(struct ir3_compiler *compiler, struct ir3_shader *shader, unsigned instruction_count = 0; nir_foreach_block (block, fxn) { - instruction_count += exec_list_length(&block->instr_list); + nir_foreach_instr (instr, block) { + /* Vectorized ALU instructions expand to one scalar instruction per + * component. + */ + if (instr->type == nir_instr_type_alu) + instruction_count += nir_instr_as_alu(instr)->def.num_components; + else + instruction_count++; + } } if (instruction_count < 50) {