gallivm: handle texture arrays in non-fragment shaders with lod.
authorDave Airlie <airlied@redhat.com>
Fri, 7 May 2021 01:26:35 +0000 (11:26 +1000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 7 May 2021 02:41:29 +0000 (02:41 +0000)
We have to unwind the lod into the scalar path correctly.

Fixes a crash with renderdoc demo

Fixes: e168d148d76d ("gallivm/nir: handle non-uniform texture offsets")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10676>

src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c

index 6a390ec..05e5208 100644 (file)
@@ -1421,10 +1421,10 @@ static void emit_tex(struct lp_build_nir_context *bld_base,
                                  LLVMGetUndef(bld_base->base.vec_type),
                                  LLVMGetUndef(bld_base->base.vec_type),
                                  LLVMGetUndef(bld_base->base.vec_type) };
-      LLVMValueRef texel[4], orig_offset;
+      LLVMValueRef texel[4], orig_offset, orig_lod;
       unsigned i;
       orig_texel_ptr = params->texel;
-
+      orig_lod = params->lod;
       for (i = 0; i < 5; i++) {
          coords[i] = params->coords[i];
       }
@@ -1443,6 +1443,8 @@ static void emit_tex(struct lp_build_nir_context *bld_base,
                                                                 idx, "");
          params->type = lp_elem_type(bld_base->base.type);
 
+         if (orig_lod)
+            params->lod = LLVMBuildExtractElement(gallivm->builder, orig_lod, idx, "");
          params->texel = texel;
          bld->sampler->emit_tex_sample(bld->sampler,
                                        gallivm,