From 2146e09962a7fb9ff53ec18e39a5b6b7e11541b8 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 19 May 2026 18:56:32 +0200 Subject: [PATCH] zink: keep ffma_weak and use GLSLstd450Fma for it This pushes the decision down to Vulkan drivers and they can do whatever they think is best. Reviewed-by: Georg Lehmann Part-of: --- src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 7 +++++++ src/gallium/drivers/zink/zink_compiler.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 95cea1b7168..21cad796814 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -2290,6 +2290,13 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) break; } + case nir_op_ffma_weak: { + assert(nir_op_infos[alu->op].num_inputs == 3); + result = emit_builtin_triop(ctx, GLSLstd450Fma, dest_type, + src[0], src[1], src[2]); + break; + } + default: fprintf(stderr, "emit_alu: not implemented (%s)\n", nir_op_infos[alu->op].name); diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 17e8b9a5ffc..45da5317670 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1304,6 +1304,7 @@ zink_screen_init_compiler(struct zink_screen *screen) .lower_mul_2x32_64 = true, .support_16bit_alu = true, /* not quite what it sounds like */ .max_unroll_iterations = 0, + .float_mul_add32 = nir_float_muladd_support_keep_weak_ffma, }; screen->nir_options = default_options; @@ -1318,8 +1319,13 @@ zink_screen_init_compiler(struct zink_screen *screen) * stop Vulkan drivers from unrolling the loops. */ screen->nir_options.max_unroll_iterations_fp64 = 32; + } else { + screen->nir_options.float_mul_add64 |= nir_float_muladd_support_keep_weak_ffma; } + if (screen->base.caps.fp16) + screen->nir_options.float_mul_add16 |= nir_float_muladd_support_keep_weak_ffma; + /* XXX: do any drivers need different estimates? */ screen->nir_options.varying_expression_max_cost = amd_varying_expression_max_cost;