nir/lower_tex: Add an assert() in nir_lower_txs_lod()
authorBoris Brezillon <boris.brezillon@collabora.com>
Wed, 19 Jun 2019 13:05:34 +0000 (15:05 +0200)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 20 Jun 2019 16:15:53 +0000 (09:15 -0700)
We don't expect the output of a TXS instruction to be wider than a
vec3. Add an assert() to make sure this never happens.

Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/compiler/nir/nir_lower_tex.c

index 8a36edf..05b46b9 100644 (file)
@@ -1011,6 +1011,7 @@ nir_lower_txs_lod(nir_builder *b, nir_tex_instr *tex)
    if (tex->is_array) {
       nir_ssa_def *comp[3];
 
+      assert(dest_size <= ARRAY_SIZE(comp));
       for (unsigned i = 0; i < dest_size - 1; i++)
          comp[i] = nir_channel(b, minified, i);