From 754e0e217654ba9724206e2caeb1cee4937fc18c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 11 May 2023 12:43:00 +0300 Subject: [PATCH] anv: put private binding BOs into execlists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not doing so all the reads/writes go to the scratch page on i915. Signed-off-by: Lionel Landwerlin Fixes: f9fa09ec92 ("anv/image: Add ANV_IMAGE_MEMORY_BINDING_PRIVATE") Reviewed-by: Tapani Pälli Part-of: (cherry picked from commit 7f7b2fc53ab430a05fa284b209ab71c57b21c548) --- .pick_status.json | 2 +- src/intel/vulkan/anv_device.c | 1 + src/intel/vulkan/anv_image.c | 19 +++++++++++++++---- src/intel/vulkan/anv_private.h | 6 ++++++ src/intel/vulkan/i915/anv_batch_chain.c | 12 ++++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ad679816a30..1d9c73fc23c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1606,7 +1606,7 @@ "description": "anv: put private binding BOs into execlists", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f9fa09ec92f68a5c05a7019bde6e620d25e8ba48" }, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 50b3b3b569d..53007130001 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3131,6 +3131,7 @@ VkResult anv_CreateDevice( HIGH_HEAP_MIN_ADDRESS); list_inithead(&device->memory_objects); + list_inithead(&device->image_private_objects); if (pthread_mutex_init(&device->mutex, NULL) != 0) { result = vk_error(device, VK_ERROR_INITIALIZATION_FAILED); diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 5fff72dbb88..745b8e6761e 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1328,9 +1328,16 @@ alloc_private_binding(struct anv_device *device, return VK_SUCCESS; } - return anv_device_alloc_bo(device, "image-binding-private", - binding->memory_range.size, 0, 0, - &binding->address.bo); + VkResult result = anv_device_alloc_bo(device, "image-binding-private", + binding->memory_range.size, 0, 0, + &binding->address.bo); + if (result == VK_SUCCESS) { + pthread_mutex_lock(&device->mutex); + list_addtail(&image->link, &device->image_private_objects); + pthread_mutex_unlock(&device->mutex); + } + + return result; } VkResult @@ -1470,8 +1477,12 @@ anv_image_finish(struct anv_image *image) } struct anv_bo *private_bo = image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].address.bo; - if (private_bo) + if (private_bo) { + pthread_mutex_lock(&device->mutex); + list_del(&image->link); + pthread_mutex_unlock(&device->mutex); anv_device_release_bo(device, private_bo); + } vk_image_finish(&image->vk); } diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 39fbe0b66c6..dedba30b55a 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1134,6 +1134,9 @@ struct anv_device { /** List of all anv_device_memory objects */ struct list_head memory_objects; + /** List of anv_image objects with a private binding for implicit CCS */ + struct list_head image_private_objects; + struct anv_bo_pool batch_bo_pool; struct anv_bo_pool utrace_bo_pool; @@ -3641,6 +3644,9 @@ struct anv_image { } planes[3]; struct anv_image_memory_range vid_dmv_top_surface; + + /* Link in the anv_device.image_private_objects list */ + struct list_head link; }; static inline bool diff --git a/src/intel/vulkan/i915/anv_batch_chain.c b/src/intel/vulkan/i915/anv_batch_chain.c index ab3497b2053..ff6e7d1ae94 100644 --- a/src/intel/vulkan/i915/anv_batch_chain.c +++ b/src/intel/vulkan/i915/anv_batch_chain.c @@ -378,6 +378,18 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, return result; } + /* Add all the private BOs from images because we can't track after binding + * updates of VK_EXT_descriptor_indexing. + */ + list_for_each_entry(struct anv_image, image, + &device->image_private_objects, link) { + struct anv_bo *private_bo = + image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].address.bo; + result = anv_execbuf_add_bo(device, execbuf, private_bo, NULL, 0); + if (result != VK_SUCCESS) + return result; + } + struct anv_batch_bo *first_batch_bo = list_first_entry(&cmd_buffers[0]->batch_bos, struct anv_batch_bo, link);