spirv: handle NoContraction in GLSL450 alu ops

we were dropping this when it was set, leading to incorrect algebraic
optimizations that broke various types of tests, e.g., running
spec@arb_gpu_shader5@execution@precise@fs-fract-of-nan in zink

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6116>
This commit is contained in:
Mike Blumenkrantz 2020-07-29 10:06:46 -04:00 committed by Marge Bot
parent 3c3764f7df
commit 64fd191d8a
3 changed files with 13 additions and 3 deletions

View file

@ -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;

View file

@ -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);
}

View file

@ -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);