From c3aa7e42ba76478d9cc1550240eb9af45ece7184 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Mon, 5 Feb 2024 15:10:24 -0800 Subject: [PATCH] zink: fix bind size handling in buffer_bo_commit() What we're checking in the assertion we're changing seems to be what the OpenGL spec describes as: " must be an integer multiple of the implementation dependent constant SPARSE_BUFFER_PAGE_SIZE_ARB, and must either be a multiple of SPARSE_BUFFER_PAGE_SIZE_ARB, or extend to the end of the buffer's data store" There are two sizes in question here: the size of the VkBuffer and the size of its corresponding VkDeviceMemory. It looks like bo->base.base.size corresponds to VkDeviceMemory, while res->obj->size corresponds to VkBuffer. Here we're really talking about the VkBuffer size, so fix the assertion. On Anv, we're hitting this issue because piglit's arb_sparse_buffer-basic creates a buffer of size 32k and tries to issue a bind operation with size 32k. The catch here is that Anv requires the memory to be 64kb, so Zink gets confused and hits the assertion. Issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10220 Testcase: piglit/arb_sparse_buffer-basic Reviewed-by: Mike Blumenkrantz Signed-off-by: Paulo Zanoni Part-of: --- src/gallium/drivers/zink/zink_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c index ca9210c8ed9..ddfb566ee51 100644 --- a/src/gallium/drivers/zink/zink_bo.c +++ b/src/gallium/drivers/zink/zink_bo.c @@ -793,7 +793,7 @@ buffer_bo_commit(struct zink_context *ctx, struct zink_resource *res, uint32_t o assert(offset % ZINK_SPARSE_BUFFER_PAGE_SIZE == 0); assert(offset <= bo->base.base.size); assert(size <= bo->base.base.size - offset); - assert(size % ZINK_SPARSE_BUFFER_PAGE_SIZE == 0 || offset + size == bo->base.base.size); + assert(size % ZINK_SPARSE_BUFFER_PAGE_SIZE == 0 || offset + size == res->obj->size); struct zink_sparse_commitment *comm = bo->u.sparse.commitments;