zink: further improve bo sizing
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 24 Jun 2022 15:19:14 +0000 (11:19 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 5 Jul 2022 20:01:01 +0000 (16:01 -0400)
using the attribute slot size isn't sufficient in this case, as the layout
rules may have additional effects upon sizing

instead, just use the explicit size

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17239>

src/gallium/drivers/zink/zink_compiler.c

index 6d28325..280e2d7 100644 (file)
@@ -2075,8 +2075,12 @@ unbreak_bos(nir_shader *shader, struct zink_shader *zs, bool needs_size)
          continue;
       /* be conservative: use the bigger of the interface and variable types to ensure in-bounds access */
       unsigned size = glsl_count_attribute_slots(glsl_type_is_array(var->type) ? var->type : type, false);
-      if (var->interface_type)
-         size = MAX2(size, glsl_count_attribute_slots(glsl_without_array(var->interface_type), false));
+      const struct glsl_type *interface_type = var->interface_type ? glsl_without_array(var->interface_type) : NULL;
+      if (interface_type) {
+         unsigned block_size = glsl_get_explicit_size(interface_type, true);
+         block_size /= sizeof(float) * 4;
+         size = MAX2(size, block_size);
+      }
       if (var->data.mode == nir_var_mem_ubo) {
          if (var->data.driver_location)
             max_ubo_size = MAX2(max_ubo_size, size);