nir: don't count samplers and images in interface blocks
authorMarek Olšák <marek.olsak@amd.com>
Tue, 26 May 2020 08:36:33 +0000 (04:36 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 2 Jun 2020 20:47:49 +0000 (20:47 +0000)
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5209>

src/compiler/nir/nir_gather_info.c
src/compiler/nir_types.cpp

index d1c3e6168cfd9ed318e0d9b4ac4050cbb8c5a3c7..df422ea21f3e3a117094ff06875a17b040fa2239 100644 (file)
@@ -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);
index ac61048881419e7be0f226652628f59fc484e28b..25043acaca713b24c9e9f6d9f4eda93298938f25 100644 (file)
@@ -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));