From ea8a0654f5bb171904b17fcd1ba8228c50343837 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 24 Jun 2022 11:19:14 -0400 Subject: [PATCH] zink: further improve bo sizing 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 Part-of: --- src/gallium/drivers/zink/zink_compiler.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 6d2832588ce..280e2d750e1 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -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);