From 004abdc76700422d5a85b8db66627d3b43030fb7 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 1 Jul 2025 20:37:27 +0200 Subject: [PATCH] etnaviv: nir: Preserve dot product instructions Modify the ALU width callback to return 0 for dot product operations, preventing nir_lower_alu_width from decomposing them into multiply-add chains. This preserves fdot2, fdot3, and fdot4 as single instructions rather than expanding them into multiple fmul+fadd operations. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13531 Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach Part-of: --- src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c index e6aaabe5e9e..f7c9d732e65 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c @@ -1182,8 +1182,17 @@ fill_vs_mystery(struct etna_shader_variant *v) } static uint8_t -alu_width_cb(UNUSED const nir_instr *instr, UNUSED const void *cb_data) +alu_width_cb(const nir_instr *instr, UNUSED const void *cb_data) { + if (instr->type == nir_instr_type_alu) { + nir_alu_instr *alu = nir_instr_as_alu(instr); + + if (alu->op == nir_op_fdot2 || + alu->op == nir_op_fdot3 || + alu->op == nir_op_fdot4) + return 0; + } + return 4; }