From e38b2adb886c09dc8177eb454633e5ecc3143eb8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 23 Jun 2022 15:49:43 -0400 Subject: [PATCH] zink: use the bigger of the variable type and interface type for bo sizing this avoids the scenario where the full bo size isn't accounted for because no variable for the block has been created cc: mesa-stable affects: KHR-GL33.shaders.uniform_block.random.all_per_block_buffers.3 Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_compiler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 147586d72b7..55601434b90 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -2074,7 +2074,10 @@ unbreak_bos(nir_shader *shader, struct zink_shader *zs, bool needs_size) const struct glsl_type *type = glsl_without_array(var->type); if (type_is_counter(type)) 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)); if (var->data.mode == nir_var_mem_ubo) max_ubo_size = MAX2(max_ubo_size, size); else