Mesa (master): spirv: handle NoContraction in GLSL450 alu ops
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jan 23 02:28:26 UTC 2021
Module: Mesa
Branch: master
Commit: 64fd191d8a88977067011d3727e32439e801d433
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=64fd191d8a88977067011d3727e32439e801d433
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Jul 29 10:06:46 2020 -0400
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 at arb_gpu_shader5@execution at precise@fs-fract-of-nan in zink
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6116>
---
src/compiler/spirv/vtn_alu.c | 8 +++++++-
src/compiler/spirv/vtn_glsl450.c | 6 ++++--
src/compiler/spirv/vtn_private.h | 2 ++
3 files changed, 13 insertions(+), 3 deletions(-)
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);
More information about the mesa-commit
mailing list