Module: Mesa
Branch: main
Commit: 6e666c6303bbcd810a5027efb743a6b180b6c90e
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e666c6303bbcd810a5027efb743a6b180b6c90e

Author: Karol Herbst <[email protected]>
Date:   Wed Feb 15 22:34:46 2023 +0100

nir: Skip samplers and textures in lower_explicit_io

We have specialized lowering passes dealing with most of that already:
1. gl_nir_lower_samplers_as_deref
2. nir_lower_samplers
3. nir_lower_cl_images

If we need more than that, those passes can deal with following deref
chains as well.

We _might_ need to improve nir_lower_cl_images a bit for more complex
kernels, but CL also doesn't allow indirect images, so we are always able
to optimize the entire deref chain away.

Signed-off-by: Karol Herbst <[email protected]>
Reviewed-by: Faith Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20161>

---

 src/compiler/nir/nir_lower_io.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index 608b268b5d5..bfedfc48a66 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -2115,6 +2115,15 @@ static void
 lower_explicit_io_deref(nir_builder *b, nir_deref_instr *deref,
                         nir_address_format addr_format)
 {
+   /* Ignore samplers/textures, because they are handled by other passes like 
`nir_lower_samplers`.
+    * Also do it only for those being uniforms, otherwise it will break GL 
bindless textures handles
+    * stored in UBOs.
+    */
+   if (nir_deref_mode_is_in_set(deref, nir_var_uniform) &&
+       (glsl_type_is_sampler(deref->type) ||
+        glsl_type_is_texture(deref->type)))
+      return;
+
    /* Just delete the deref if it's not used.  We can't use
     * nir_deref_instr_remove_if_unused here because it may remove more than
     * one deref which could break our list walking since we walk the list

Reply via email to