From d797d9233dff75774780a52dc50d59135097d695 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Tue, 17 Oct 2023 11:53:55 -0700 Subject: [PATCH] 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 Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_batch_chain.c | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 911ad23fe21..35896db00bb 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -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: