spirv: Check that only one offset is defined as Image Operand
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 23 Oct 2019 06:40:08 +0000 (23:40 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Thu, 24 Oct 2019 18:39:56 +0000 (11:39 -0700)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/compiler/spirv/spirv_to_nir.c

index 2de9bdf33893974688979231fd2cef08d6df6d99..d1884f48330002689905f8a214773d2444e1cffc 100644 (file)
@@ -2438,6 +2438,12 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
          (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_ddy);
       }
 
+      vtn_fail_if(util_bitcount(operands & (SpvImageOperandsConstOffsetsMask |
+                                            SpvImageOperandsOffsetMask |
+                                            SpvImageOperandsConstOffsetMask)) > 1,
+                  "At most one of the ConstOffset, Offset, and ConstOffsets "
+                  "image operands can be used on a given instruction.");
+
       if (operands & SpvImageOperandsOffsetMask ||
           operands & SpvImageOperandsConstOffsetMask)
          (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_offset);