Mesa (master): spirv: Use the right bit-size for spec constant ops

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 26 16:46:00 UTC 2018


Module: Mesa
Branch: master
Commit: 8fa70cfcfdda1094bc19e9707eb9333477a2d2bf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fa70cfcfdda1094bc19e9707eb9333477a2d2bf

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Fri Oct 19 19:08:58 2018 -0500

spirv: Use the right bit-size for spec constant ops

Previously, we would always pull the bit size from the destination which
is wrong for opcodes like nir_ilt where the sources are variable-sized
but the destination is a fixed size.  We were getting lucky before
because nir_op_ilt returns a 32-bit value and basically everyone who
uses spec constants uses 32-bit ones.

Cc: mesa-stable at lists.freedesktop.org
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/compiler/spirv/spirv_to_nir.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 5bac3dc0e1..96ff09c365 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1798,11 +1798,17 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
          nir_const_value src[4];
 
          for (unsigned i = 0; i < count - 4; i++) {
-            nir_constant *c =
-               vtn_value(b, w[4 + i], vtn_value_type_constant)->constant;
+            struct vtn_value *src_val =
+               vtn_value(b, w[4 + i], vtn_value_type_constant);
+
+            /* If this is an unsized source, pull the bit size from the
+             * source; otherwise, we'll use the bit size from the destination.
+             */
+            if (!nir_alu_type_get_type_size(nir_op_infos[op].input_types[i]))
+               bit_size = glsl_get_bit_size(src_val->type->type);
 
             unsigned j = swap ? 1 - i : i;
-            src[j] = c->values[0];
+            src[j] = src_val->constant->values[0];
          }
 
          val->constant->values[0] =




More information about the mesa-commit mailing list