Mesa (master): nir: don't count samplers and images in interface blocks

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


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue May 26 04:36:33 2020 -0400

nir: don't count samplers and images in interface blocks

Acked-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 |  7 +++++--
 src/compiler/nir_types.cpp         | 10 ++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index d1c3e6168cf..df422ea21f3 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -600,8 +600,11 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
    shader->info.last_msaa_image = -1;
 
    nir_foreach_variable(var, &shader->uniforms) {
-      /* Bindless textures and images don't use non-bindless slots. */
-      if (var->data.bindless)
+      /* Bindless textures and images don't use non-bindless slots.
+       * Interface blocks imply inputs, outputs, UBO, or SSBO, which can only
+       * mean bindless.
+       */
+      if (var->data.bindless || var->interface_type)
          continue;
 
       shader->info.num_textures += glsl_type_get_sampler_count(var->type);
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index ac610488814..25043acaca7 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -756,7 +756,10 @@ glsl_type_get_sampler_count(const struct glsl_type *type)
               glsl_type_get_sampler_count(glsl_without_array(type)));
    }
 
-   if (glsl_type_is_struct_or_ifc(type)) {
+   /* Ignore interface blocks - they can only contain bindless samplers,
+    * which we shouldn't count.
+    */
+   if (glsl_type_is_struct(type)) {
       unsigned count = 0;
       for (unsigned i = 0; i < glsl_get_length(type); i++)
          count += glsl_type_get_sampler_count(glsl_get_struct_field(type, i));
@@ -777,7 +780,10 @@ glsl_type_get_image_count(const struct glsl_type *type)
               glsl_type_get_image_count(glsl_without_array(type)));
    }
 
-   if (glsl_type_is_struct_or_ifc(type)) {
+   /* Ignore interface blocks - they can only contain bindless images,
+    * which we shouldn't count.
+    */
+   if (glsl_type_is_struct(type)) {
       unsigned count = 0;
       for (unsigned i = 0; i < glsl_get_length(type); i++)
          count += glsl_type_get_image_count(glsl_get_struct_field(type, i));



More information about the mesa-commit mailing list