spirv: map float control2 to fine grained nir flags instead of exact

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40872>
This commit is contained in:
Georg Lehmann 2026-04-09 17:48:25 +02:00 committed by Marge Bot
parent a42ac8dec6
commit ed50cf29f3
2 changed files with 19 additions and 15 deletions

View file

@ -6042,13 +6042,19 @@ vtn_handle_execution_mode_id(struct vtn_builder *b, struct vtn_value *entry_poin
if (!fp_math_ctrl)
vtn_fail("Unkown float type for FPFastMathDefault");
SpvFPFastMathModeMask can_fast_math =
SpvFPFastMathModeAllowRecipMask |
SpvFPFastMathModeAllowContractMask |
SpvFPFastMathModeAllowReassocMask |
SpvFPFastMathModeAllowTransformMask;
if ((flags & can_fast_math) != can_fast_math)
*fp_math_ctrl |= nir_fp_exact;
if (!(flags & SpvFPFastMathModeAllowContractMask))
*fp_math_ctrl |= nir_fp_no_contract;
if (!(flags & SpvFPFastMathModeAllowReassocMask))
*fp_math_ctrl |= nir_fp_no_reassoc;
if (!(flags & SpvFPFastMathModeAllowTransformMask))
*fp_math_ctrl |= nir_fp_no_transform;
/* XXX maybe SpvFPFastMathModeAllowRecipMask
* should do something for CL?
* It's always allowed for VK/GL.
*/
if (!(flags & SpvFPFastMathModeNotNaNMask))
*fp_math_ctrl |= nir_fp_preserve_nan;

View file

@ -397,16 +397,14 @@ handle_fp_fast_math(struct vtn_builder *b, UNUSED struct vtn_value *val,
if (dec->decoration != SpvDecorationFPFastMathMode)
return;
SpvFPFastMathModeMask can_fast_math =
SpvFPFastMathModeAllowRecipMask |
SpvFPFastMathModeAllowContractMask |
SpvFPFastMathModeAllowReassocMask |
SpvFPFastMathModeAllowTransformMask;
/* Decoration overrides defaults. */
b->nb.fp_math_ctrl = 0;
if ((dec->operands[0] & can_fast_math) != can_fast_math)
b->nb.fp_math_ctrl |= nir_fp_exact;
if (!(dec->operands[0] & SpvFPFastMathModeAllowContractMask))
b->nb.fp_math_ctrl |= nir_fp_no_contract;
if (!(dec->operands[0] & SpvFPFastMathModeAllowReassocMask))
b->nb.fp_math_ctrl |= nir_fp_no_reassoc;
if (!(dec->operands[0] & SpvFPFastMathModeAllowTransformMask))
b->nb.fp_math_ctrl |= nir_fp_no_transform;
if (!(dec->operands[0] & SpvFPFastMathModeNSZMask))
b->nb.fp_math_ctrl |= nir_fp_preserve_signed_zero;
if (!(dec->operands[0] & SpvFPFastMathModeNotNaNMask))