[Mesa-dev] [PATCH 1/2] nir: skip lowering sampler if there is no dereference

Timothy Arceri tarceri at itsqueeze.com
Wed Nov 1 01:43:45 UTC 2017


This avoids a crash on the output of nir_lower_bitmap().
---
 src/compiler/nir/nir_lower_samplers_as_deref.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_lower_samplers_as_deref.c b/src/compiler/nir/nir_lower_samplers_as_deref.c
index bdbd8672f4..3e819f7fa7 100644
--- a/src/compiler/nir/nir_lower_samplers_as_deref.c
+++ b/src/compiler/nir/nir_lower_samplers_as_deref.c
@@ -150,22 +150,24 @@ lower_deref(nir_deref_var *deref,
       _mesa_hash_table_insert_pre_hashed(state->remap_table, hash, path, var);
    }
 
    deref->var = var;
 }
 
 static bool
 lower_sampler(nir_tex_instr *instr, struct lower_samplers_as_deref_state *state,
               nir_builder *b)
 {
+   if (!instr->texture)
+      return false;
+
    /* In GLSL, we only fill out the texture field.  The sampler is inferred */
-   assert(instr->texture != NULL);
    assert(instr->sampler == NULL);
 
    b->cursor = nir_before_instr(&instr->instr);
    lower_deref(instr->texture, state, b);
 
    if (instr->op != nir_texop_txf_ms &&
        instr->op != nir_texop_txf_ms_mcs &&
        instr->op != nir_texop_samples_identical) {
       nir_instr_rewrite_deref(&instr->instr, &instr->sampler,
                               nir_deref_var_clone(instr->texture, instr));
-- 
2.14.3



More information about the mesa-dev mailing list