Merge branch 'spirv/fma' into 'main'

vtn,rusticl: support fma terribly

See merge request mesa/mesa!40737
This commit is contained in:
Karol Herbst 2026-05-08 00:10:19 +00:00
commit b33d2b131d
3 changed files with 12 additions and 0 deletions

View file

@ -80,6 +80,7 @@ static const struct spirv_capabilities implemented_capabilities = {
.Float16Buffer = true,
.Float64 = true,
.FloatControls2 = true,
.FMAKHR = true,
.FragmentBarycentricKHR = true,
.FragmentDensityEXT = true,
.FragmentFullyCoveredEXT = true,
@ -6979,6 +6980,7 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
case SpvOpFSub:
case SpvOpIMul:
case SpvOpFMul:
case SpvOpFmaKHR:
case SpvOpUDiv:
case SpvOpSDiv:
case SpvOpFDiv:

View file

@ -805,6 +805,14 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
nir_fdot(&b->nb, src[0], src[1]);
break;
case SpvOpFmaKHR:
const unsigned save_fp_math_ctrl = b->nb.fp_math_ctrl;
b->nb.fp_math_ctrl |= nir_fp_exact;
dest->def = nir_ffma(&b->nb, src[0], src[1], src[2]);
b->nb.fp_math_ctrl = save_fp_math_ctrl;
break;
case SpvOpIAddCarry:
vtn_assert(glsl_type_is_struct_or_ifc(dest_type));
dest->elems[0]->def = nir_iadd(&b->nb, src[0], src[1]);

View file

@ -637,6 +637,7 @@ impl DeviceBase {
add_spirv(c"SPV_KHR_bit_instructions");
add_spirv(c"SPV_KHR_expect_assume");
add_spirv(c"SPV_KHR_float_controls");
add_spirv(c"SPV_KHR_fma");
add_spirv(c"SPV_KHR_integer_dot_product");
add_spirv(c"SPV_KHR_no_integer_wrap_decoration");
@ -647,6 +648,7 @@ impl DeviceBase {
add_cap(SpvCapability::SpvCapabilityDotProductInput4x8BitPacked);
add_cap(SpvCapability::SpvCapabilityExpectAssumeKHR);
add_cap(SpvCapability::SpvCapabilityFloat16Buffer);
add_cap(SpvCapability::SpvCapabilityFMAKHR);
add_cap(SpvCapability::SpvCapabilityInt8);
add_cap(SpvCapability::SpvCapabilityInt16);
add_cap(SpvCapability::SpvCapabilityLinkage);