Module: Mesa Branch: main Commit: c87f7c13fa7146a122ce4d526e6ace36d2441afd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c87f7c13fa7146a122ce4d526e6ace36d2441afd
Author: Paulo Zanoni <[email protected]> Date: Thu Nov 30 15:44:23 2023 -0800 anv/sparse: reject binds that are not a multiple of the granularity >From the spec: "Resources can be bound at some defined (sparse block) granularity." "The sparse block size in bytes for sparse buffers and fully-resident images is reported as VkMemoryRequirements::alignment. alignment represents both the memory alignment requirement and the binding granularity (in bytes) for sparse resources." Not only the upper layer (the Spec) doesn't allow this, the lower layers (both the vm_bind ioctl and TR-TT) also work on a granularity. Just check for this case and return an error. Before this check, what would happen was: - for the vm_bind backend, the vm_bind ioctl would fail - for the TR-TT backend, we'd understimate l1_binds_capacity and fail an assertion, or we'd just silently bind 64kb instead of the original size Currently, some Zink tests such as piglit/arb_sparse_buffer-basic can trigger this behavior, but we're working to fix Zink for this case (and that commit may be merged before this one). Reviewed-by: Lionel Landwerlin <[email protected]> Signed-off-by: Paulo Zanoni <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26454> --- src/intel/vulkan/anv_sparse.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c index 933d31e84ce..15ea0e3b2df 100644 --- a/src/intel/vulkan/anv_sparse.c +++ b/src/intel/vulkan/anv_sparse.c @@ -988,6 +988,9 @@ anv_sparse_bind_resource_memory(struct anv_device *device, { struct anv_vm_bind bind = vk_bind_to_anv_vm_bind(sparse, vk_bind); + if (vk_bind->size % ANV_SPARSE_BLOCK_SIZE != 0) + return vk_error(device, VK_ERROR_VALIDATION_FAILED_EXT); + return anv_sparse_submission_add(device, submit, &bind); }
