From 7ce841cb71b31f6825e7e49e233bc1e2afb8da55 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 4 May 2026 15:27:34 +0200 Subject: [PATCH] nir: validate new float_mul_add options Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_validate.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 5b6c5f4c418..f22f910f296 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -2299,6 +2299,29 @@ validate_function(nir_function *func, validate_state *state) } } +static void +validate_float_mul_add(nir_float_muladd_support muladd_support, validate_state *state) +{ + if (muladd_support & nir_float_muladd_support_fuse) { + validate_assert(state, muladd_support & + (nir_float_muladd_support_has_ffma | nir_float_muladd_support_has_fmad)); + } + + if (muladd_support & nir_float_muladd_support_prefers_split) + validate_assert(state, muladd_support & nir_float_muladd_support_has_ffma); +} + +static void +validate_options(const nir_shader_compiler_options *options, validate_state *state) +{ + if (!options) + return; + + validate_float_mul_add(options->float_mul_add16, state); + validate_float_mul_add(options->float_mul_add32, state); + validate_float_mul_add(options->float_mul_add64, state); +} + static void init_validate_state(validate_state *state) { @@ -2403,6 +2426,8 @@ nir_validate_shader(nir_shader *shader, const char *when) valid_modes |= nir_var_mem_node_payload | nir_var_mem_node_payload_in; + validate_options(shader->options, &state); + exec_list_validate(&shader->variables); nir_foreach_variable_in_shader(var, shader) validate_var_decl(var, valid_modes, &state);