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:

  "<offset> must be an integer multiple of the implementation
   dependent constant SPARSE_BUFFER_PAGE_SIZE_ARB, and <size> 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 <michael.blumenkrantz@gmail.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26410>
This commit is contained in:
Paulo Zanoni
2024-02-05 15:10:24 -08:00
committed by Marge Bot
parent 83895d4025
commit c3aa7e42ba
+1 -1
View File
@@ -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;