anv/sparse: process image binds before opaque image binds

When sparse images are being used, applications normally use
non-opaque binds and leave opaque binds just for the miptail part.

Since miptails are always at the end of the array layers, processing
the opaque binds after processing the non-opaque binds increases the
chance that anv_sparse_submission_add() will join the miptail bind
operation with the last non-opaque opreration, especially if the user
is trying to bind the last few non-miptail levels and the miptail in
the same vkQueueBindSparse opration.

In the real world this case does happen, so we're able to save a bind
operation every once in a while in Steam games.

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/25512>
This commit is contained in:
Paulo Zanoni
2023-10-17 11:53:55 -07:00
committed by Marge Bot
parent 040063c156
commit d797d9233d
+16 -16
View File
@@ -1460,6 +1460,22 @@ anv_queue_submit_sparse_bind_locked(struct anv_queue *queue,
}
}
for (uint32_t i = 0; i < submit->image_bind_count; i++) {
VkSparseImageMemoryBindInfo *bind_info = &submit->image_binds[i];
ANV_FROM_HANDLE(anv_image, image, bind_info->image);
assert(anv_image_is_sparse(image));
assert(image->vk.create_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT);
for (uint32_t j = 0; j < bind_info->bindCount; j++) {
result = anv_sparse_bind_image_memory(queue, image,
&bind_info->pBinds[j],
&sparse_submit);
if (result != VK_SUCCESS)
goto out_free_submit;
}
}
for (uint32_t i = 0; i < submit->image_opaque_bind_count; i++) {
VkSparseImageOpaqueMemoryBindInfo *bind_info =
&submit->image_opaque_binds[i];
@@ -1479,22 +1495,6 @@ anv_queue_submit_sparse_bind_locked(struct anv_queue *queue,
}
}
for (uint32_t i = 0; i < submit->image_bind_count; i++) {
VkSparseImageMemoryBindInfo *bind_info = &submit->image_binds[i];
ANV_FROM_HANDLE(anv_image, image, bind_info->image);
assert(anv_image_is_sparse(image));
assert(image->vk.create_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT);
for (uint32_t j = 0; j < bind_info->bindCount; j++) {
result = anv_sparse_bind_image_memory(queue, image,
&bind_info->pBinds[j],
&sparse_submit);
if (result != VK_SUCCESS)
goto out_free_submit;
}
}
result = anv_sparse_bind(device, &sparse_submit);
out_free_submit: