diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c index aaed36bb90e..19c1af9854b 100644 --- a/src/compiler/spirv/vtn_alu.c +++ b/src/compiler/spirv/vtn_alu.c @@ -388,6 +388,12 @@ handle_no_contraction(struct vtn_builder *b, struct vtn_value *val, int member, b->nb.exact = true; } +void +vtn_handle_no_contraction(struct vtn_builder *b, struct vtn_value *val) +{ + vtn_foreach_decoration(b, val, handle_no_contraction, NULL); +} + nir_rounding_mode vtn_rounding_mode_to_nir(struct vtn_builder *b, SpvFPRoundingMode mode) { @@ -463,7 +469,7 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode, struct vtn_value *dest_val = vtn_untyped_value(b, w[2]); const struct glsl_type *dest_type = vtn_get_type(b, w[1])->type; - vtn_foreach_decoration(b, dest_val, handle_no_contraction, NULL); + vtn_handle_no_contraction(b, dest_val); /* Collect the various SSA sources */ const unsigned num_inputs = count - 3; diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c index af6b1330563..bba9542daf7 100644 --- a/src/compiler/spirv/vtn_glsl450.c +++ b/src/compiler/spirv/vtn_glsl450.c @@ -324,6 +324,7 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, } struct vtn_ssa_value *dest = vtn_create_ssa_value(b, dest_type); + vtn_handle_no_contraction(b, vtn_untyped_value(b, w[2])); switch (entrypoint) { case GLSLstd450Radians: dest->def = nir_radians(nb, src[0]); @@ -550,12 +551,13 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, b->shader->info.float_controls_execution_mode; bool exact; nir_op op = vtn_nir_alu_op_for_spirv_glsl_opcode(b, entrypoint, execution_mode, &exact); - b->nb.exact = exact; + /* don't override explicit decoration */ + b->nb.exact |= exact; dest->def = nir_build_alu(&b->nb, op, src[0], src[1], src[2], NULL); - b->nb.exact = false; break; } } + b->nb.exact = false; vtn_push_ssa_value(b, w[2], dest); } diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index 11b95b60f4e..f230e6e8152 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -916,6 +916,8 @@ void vtn_handle_alu(struct vtn_builder *b, SpvOp opcode, void vtn_handle_bitcast(struct vtn_builder *b, const uint32_t *w, unsigned count); +void vtn_handle_no_contraction(struct vtn_builder *b, struct vtn_value *val); + void vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode, const uint32_t *w, unsigned count);