nir: assert that nir_lower_tex runs after lowering derefs
authorRob Clark <robdclark@chromium.org>
Mon, 13 Jan 2020 19:34:53 +0000 (11:34 -0800)
committerDaniel Stone <daniel@fooishbar.org>
Mon, 13 Jan 2020 23:19:49 +0000 (23:19 +0000)
It isn't going to do the right thing, because texture_index/
sampler_index defaults to zero.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3368>

src/compiler/nir/nir_lower_tex.c

index 6c8c6aa11648b75280f5a13cab25a9eb25e2107f..191076f8c27a2e7fbc398df33b84a07b89634d1b 100644 (file)
@@ -934,6 +934,12 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
       nir_tex_instr *tex = nir_instr_as_tex(instr);
       bool lower_txp = !!(options->lower_txp & (1 << tex->sampler_dim));
 
+      /* we aren't really going to do the right thing if we haven't
+       * lowered tex/samp derefs yet:
+       */
+      assume(nir_tex_instr_src_index(tex, nir_tex_src_texture_deref) < 0);
+      assume(nir_tex_instr_src_index(tex, nir_tex_src_sampler_deref) < 0);
+
       /* mask of src coords to saturate (clamp): */
       unsigned sat_mask = 0;