Mesa (main): nir: Set image_buffers and msaa_images in lower_samplers_as_deref

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 10 17:15:09 UTC 2022


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

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Fri Apr 15 15:40:13 2022 -0500

nir: Set image_buffers and msaa_images in lower_samplers_as_deref

This is where we set images_used so it's less likely that things will
accidentally get out-of-sync.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15988>

---

 src/compiler/glsl/gl_nir_lower_samplers_as_deref.c |  7 +++++++
 src/compiler/nir/nir_gather_info.c                 | 18 +-----------------
 src/mesa/state_tracker/st_glsl_to_nir.cpp          |  2 ++
 3 files changed, 10 insertions(+), 17 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 3e6c6f183e9..c19ad256bd6 100644
--- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
+++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
@@ -131,6 +131,13 @@ record_images_used(struct shader_info *info,
    unsigned mask = ((1ull << MAX2(size, 1)) - 1) << var->data.binding;
 
    info->images_used |= mask;
+
+   enum glsl_sampler_dim sampler_dim =
+      glsl_get_sampler_dim(glsl_without_array(var->type));
+   if (sampler_dim == GLSL_SAMPLER_DIM_BUF)
+      info->image_buffers |= mask;
+   if (sampler_dim == GLSL_SAMPLER_DIM_MS)
+      info->msaa_images |= mask;
 }
 
 
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index f0bdd13634d..7f16abda517 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -877,8 +877,6 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
 {
    shader->info.num_textures = 0;
    shader->info.num_images = 0;
-   shader->info.image_buffers = 0;
-   shader->info.msaa_images = 0;
    shader->info.bit_sizes_float = 0;
    shader->info.bit_sizes_int = 0;
 
@@ -891,21 +889,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
          continue;
 
       shader->info.num_textures += glsl_type_get_sampler_count(var->type);
-
-      unsigned num_image_slots = glsl_type_get_image_count(var->type);
-      if (num_image_slots) {
-         const struct glsl_type *image_type = glsl_without_array(var->type);
-
-         if (glsl_get_sampler_dim(image_type) == GLSL_SAMPLER_DIM_BUF) {
-            shader->info.image_buffers |=
-               BITFIELD_RANGE(shader->info.num_images, num_image_slots);
-         }
-         if (glsl_get_sampler_dim(image_type) == GLSL_SAMPLER_DIM_MS) {
-            shader->info.msaa_images |=
-               BITFIELD_RANGE(shader->info.num_images, num_image_slots);
-         }
-         shader->info.num_images += num_image_slots;
-      }
+      shader->info.num_images += glsl_type_get_image_count(var->type);
    }
 
    shader->info.inputs_read = 0;
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index bc187fee66e..a701894985a 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -991,6 +991,8 @@ st_nir_lower_samplers(struct pipe_screen *screen, nir_shader *nir,
       BITSET_COPY(prog->info.textures_used, nir->info.textures_used);
       BITSET_COPY(prog->info.textures_used_by_txf, nir->info.textures_used_by_txf);
       prog->info.images_used = nir->info.images_used;
+      prog->info.image_buffers = nir->info.image_buffers;
+      prog->info.msaa_images = nir->info.msaa_images;
    }
 }
 



More information about the mesa-commit mailing list