Mesa (master): nir: Allow a non-existent sampler deref in nir_lower_samplers_as_deref

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 11 15:56:04 UTC 2019


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu Jan 10 11:10:13 2019 -0800

nir: Allow a non-existent sampler deref in nir_lower_samplers_as_deref

GL_ARB_gl_spirv does not provide a sampler deref for e.g. texelFetch(),
so we can't assume that both are present and identical.  Simply lower
each if it is present.

Fixes regressions in GL_ARB_gl_spirv tests since I switched everyone to
using this pass.  Thanks to Alejandro Piñeiro for catching these.

Fixes: f003859f97c nir: Make gl_nir_lower_samplers use gl_nir_lower_samplers_as_deref

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Tested-by: Alejandro Piñeiro <apinheiro at igalia.com>

---

 src/compiler/glsl/gl_nir_lower_samplers_as_deref.c | 40 ++++++++++++----------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
index 96c751a128..719968a667 100644
--- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
+++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
@@ -196,28 +196,30 @@ lower_sampler(nir_tex_instr *instr, struct lower_samplers_as_deref_state *state,
    int sampler_idx =
       nir_tex_instr_src_index(instr, nir_tex_src_sampler_deref);
 
-   if (texture_idx < 0)
-      return false;
+   b->cursor = nir_before_instr(&instr->instr);
 
-   assert(texture_idx >= 0 && sampler_idx >= 0);
-   assert(instr->src[texture_idx].src.is_ssa);
-   assert(instr->src[sampler_idx].src.is_ssa);
-   assert(instr->src[texture_idx].src.ssa == instr->src[sampler_idx].src.ssa);
+   if (texture_idx >= 0) {
+      assert(instr->src[texture_idx].src.is_ssa);
 
-   b->cursor = nir_before_instr(&instr->instr);
+      nir_deref_instr *texture_deref =
+         lower_deref(b, state, nir_src_as_deref(instr->src[texture_idx].src));
+      /* only lower non-bindless: */
+      if (texture_deref) {
+         nir_instr_rewrite_src(&instr->instr, &instr->src[texture_idx].src,
+                               nir_src_for_ssa(&texture_deref->dest.ssa));
+      }
+   }
 
-   nir_deref_instr *texture_deref =
-      lower_deref(b, state, nir_src_as_deref(instr->src[texture_idx].src));
-   /* don't lower bindless: */
-   if (!texture_deref)
-      return false;
-   nir_instr_rewrite_src(&instr->instr, &instr->src[texture_idx].src,
-                         nir_src_for_ssa(&texture_deref->dest.ssa));
-
-   nir_deref_instr *sampler_deref =
-      lower_deref(b, state, nir_src_as_deref(instr->src[sampler_idx].src));
-   nir_instr_rewrite_src(&instr->instr, &instr->src[sampler_idx].src,
-                         nir_src_for_ssa(&sampler_deref->dest.ssa));
+   if (sampler_idx >= 0) {
+      assert(instr->src[sampler_idx].src.is_ssa);
+      nir_deref_instr *sampler_deref =
+         lower_deref(b, state, nir_src_as_deref(instr->src[sampler_idx].src));
+      /* only lower non-bindless: */
+      if (sampler_deref) {
+         nir_instr_rewrite_src(&instr->instr, &instr->src[sampler_idx].src,
+                               nir_src_for_ssa(&sampler_deref->dest.ssa));
+      }
+   }
 
    return true;
 }




More information about the mesa-commit mailing list