From eb6faf329c1156ff96f884728084ba30dbf0cad2 Mon Sep 17 00:00:00 2001 From: SoroushIMG Date: Mon, 11 Jul 2022 14:00:50 +0100 Subject: [PATCH] zink: Fix BO size when it's not aligned to 16 bytes glsl_get_explicit_size can return non-16 byte aligned sizes. Therefore, make sure the sure the size isrounded up so that OOB does not happen. Fixes: ea8a0654f5b ("zink: further improve bo sizing") Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/zink_compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 103b7e0ffbe..fbf2acbc171 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -2157,7 +2157,7 @@ unbreak_bos(nir_shader *shader, struct zink_shader *zs, bool needs_size) 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; + block_size = DIV_ROUND_UP(block_size, sizeof(float) * 4); size = MAX2(size, block_size); } if (var->data.mode == nir_var_mem_ubo) {