From 76f2735fe23a48296564310eada98d2db790e52f Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 15 Jul 2025 10:20:59 +0200 Subject: [PATCH] etnaviv: nir: Enable vectorization with 4-component width limit Add a custom ALU width callback that returns 4 to enable vectorization of scalar operations up to 4 components. Without this callback, the nir_lower_alu_width pass generates excessive scalar code instead of utilizing etnaviv's vector capabilities. 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c index 071fdf3e116..e6aaabe5e9e 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c @@ -1181,6 +1181,12 @@ fill_vs_mystery(struct etna_shader_variant *v) VIVS_VS_LOAD_BALANCING_D(0x0f); } +static uint8_t +alu_width_cb(UNUSED const nir_instr *instr, UNUSED const void *cb_data) +{ + return 4; +} + bool etna_compile_shader(struct etna_shader_variant *v) { @@ -1260,7 +1266,7 @@ etna_compile_shader(struct etna_shader_variant *v) NIR_PASS(_, s, nir_lower_vars_to_ssa); NIR_PASS(_, s, nir_lower_indirect_derefs, nir_var_all, UINT32_MAX); NIR_PASS(_, s, etna_nir_lower_texture, &v->key, v->shader->info); - NIR_PASS(_, s, nir_lower_alu_width, NULL, NULL); + NIR_PASS(_, s, nir_lower_alu_width, alu_width_cb, NULL); NIR_PASS(_, s, nir_lower_alu_to_scalar, etna_alu_to_scalar_filter_cb, c->info); if (c->info->halti >= 2) {