Mesa (master): nir: gather which images are buffers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 2 21:11:21 UTC 2020


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Thu May 21 05:13:01 2020 -0400

nir: gather which images are buffers

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5209>

---

 src/compiler/nir/nir_gather_info.c | 13 ++++++++++++-
 src/compiler/shader_info.h         |  2 ++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index df422ea21f3..5a2f8cfc06a 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -597,6 +597,7 @@ 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.last_msaa_image = -1;
 
    nir_foreach_variable(var, &shader->uniforms) {
@@ -608,7 +609,17 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
          continue;
 
       shader->info.num_textures += glsl_type_get_sampler_count(var->type);
-      shader->info.num_images += glsl_type_get_image_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);
+         }
+         shader->info.num_images += num_image_slots;
+      }
 
       /* Assuming image slots don't have holes (e.g. OpenGL) */
       if (glsl_type_is_image(var->type) &&
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 2ad86fe0493..6537008af93 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -152,6 +152,8 @@ typedef struct shader_info {
 
    /** Bitfield of which images are used */
    uint32_t images_used;
+   /** Bitfield of which images are buffers. */
+   uint32_t image_buffers;
 
    /* SPV_KHR_float_controls: execution mode for floating point ops */
    uint16_t float_controls_execution_mode;



More information about the mesa-commit mailing list