Mesa (main): zink: Fix BO size when it's not aligned to 16 bytes
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 12 13:12:10 UTC 2022
Module: Mesa
Branch: main
Commit: eb6faf329c1156ff96f884728084ba30dbf0cad2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb6faf329c1156ff96f884728084ba30dbf0cad2
Author: SoroushIMG <soroush.kashani at imgtec.com>
Date: Mon Jul 11 14:00:50 2022 +0100
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 <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17460>
---
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) {
More information about the mesa-commit
mailing list