From acdbdcc53bced7ee8b0287b3eb2b7351aba7f42f Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 9 Feb 2026 21:08:05 +0100 Subject: [PATCH] vtn: set default fp_math_ctrl values for kernels The kernel capabilty has the `FPFastMathMode` decoration, but not the `FPFastMathDefault` execution mode, so a SPIR-V module not using `SPV_KHR_float_controls2` has no way of setting any defaults. Fixes: 9da2d218041 ("vtn: implement default fp_math_ctrl without using execution mode") Reviewed-by: Alyssa Rosenzweig Tested-by: Alyssa Rosenzweig (cherry picked from commit faf3a93e8fe9bf94ff3200dca9427d8d05c95f2f) [Eric: adjusted commit because of missing 46a617884e, as suggested by the author at https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39790#note_3325830] Part-of: --- .pick_status.json | 2 +- src/compiler/spirv/spirv_to_nir.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 716d2547560..e46e2102e07 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -534,7 +534,7 @@ "description": "vtn: set default fp_math_ctrl values for kernels", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "9da2d218041c1a9dd731c3f10ca4800c8b7c6773", "notes": null diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index daeb6b7ea75..65229eee740 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -5248,6 +5248,12 @@ vtn_handle_entry_point(struct vtn_builder *b, const uint32_t *w, b->interface_ids = vtn_alloc_array(b, uint32_t, b->interface_ids_count); memcpy(b->interface_ids, &w[start], b->interface_ids_count * 4); qsort(b->interface_ids, b->interface_ids_count, 4, cmp_uint32_t); + + if (stage == MESA_SHADER_KERNEL) { + b->fp_math_ctrl_fp16 |= nir_fp_preserve_sz_inf_nan; + b->fp_math_ctrl_fp32 |= nir_fp_preserve_sz_inf_nan; + b->fp_math_ctrl_fp64 |= nir_fp_preserve_sz_inf_nan; + } } static bool