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 <lionel.g.landwerlin@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26454>
This commit is contained in:
Paulo Zanoni 2023-11-30 15:44:23 -08:00 committed by Marge Bot
parent a495d437b7
commit c87f7c13fa

View file

@ -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);
}