anv: allocate sparse descriptor buffers from the correct heap

When allocating a buffer normally, this flag gets to the allocator from
the memory requirements, but when sparse bindings are created we were
checking for them but never setting them.
Fixes sparse descriptor buffers on Xe2.
Makes the failure on TRTT more obvious.

Fixes: c6a91f1695 ("anv: add new heap/pool for descriptor buffers")
Fixes: 692e1ab2c1 ("anv: get rid of the second dynamic state heap")

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31372>
(cherry picked from commit a4cbc903a8)
This commit is contained in:
Iván Briano 2024-09-25 11:49:47 -07:00 committed by Eric Engestrom
parent bcb9c3d4c5
commit b362b71c68
2 changed files with 19 additions and 1 deletions

View file

@ -574,7 +574,7 @@
"description": "anv: allocate sparse descriptor buffers from the correct heap",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "c6a91f16952cfe9f685cc6a0a185161364fdcdcf",
"notes": null

View file

@ -5178,6 +5178,16 @@ VkResult anv_CreateBuffer(
fprintf(stderr, "=== %s %s:%d flags:0x%08x\n", __func__, __FILE__,
__LINE__, pCreateInfo->flags);
if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) &&
device->physical->sparse_type == ANV_SPARSE_TYPE_TRTT) {
VkBufferUsageFlags2KHR usages = get_buffer_usages(pCreateInfo);
if (usages & (VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT |
VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT)) {
return vk_errorf(device, VK_ERROR_UNKNOWN,
"Cannot support sparse descriptor buffers with TRTT.");
}
}
/* Don't allow creating buffers bigger than our address space. The real
* issue here is that we may align up the buffer size and we don't want
* doing so to cause roll-over. However, no one has any business
@ -5215,6 +5225,14 @@ VkResult anv_CreateBuffer(
client_address = *((const uint64_t *)opaque_info->opaqueCaptureDescriptorData);
}
/* If this buffer will be used as a descriptor buffer, make sure we
* allocate it on the correct heap.
*/
if (buffer->vk.usage & (VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT |
VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT)) {
alloc_flags |= ANV_BO_ALLOC_DYNAMIC_VISIBLE_POOL;
}
VkResult result = anv_init_sparse_bindings(device, buffer->vk.size,
&buffer->sparse_data,
alloc_flags, client_address,