From 9c599dff88054404ce8615db33d25e8b625d8969 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 19 Jun 2023 13:03:37 +0300 Subject: [PATCH] anv: avoid private buffer allocations in vkGetDeviceImageMemoryRequirementsKHR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whole point of vkGetDeviceImageMemoryRequirementsKHR is to avoid creating an image so we should completely avoid any allocation like the private binding. Signed-off-by: Lionel Landwerlin Fixes: 4075dd16ab ("anv: implement vkGetDeviceImageMemoryRequirementsKHR") Reviewed-by: Tapani Pälli Part-of: (cherry picked from commit 0e728ea7b0779e299cec948d7ba06ab591c04992) --- .pick_status.json | 2 +- src/intel/vulkan/anv_image.c | 17 +++++++++++------ src/intel/vulkan/anv_private.h | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ca41a05f8ee..7aab705a7f1 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -337,7 +337,7 @@ "description": "anv: avoid private buffer allocations in vkGetDeviceImageMemoryRequirementsKHR", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "4075dd16ab8ceb1abd852e685118e88a8c4cd749" }, diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index d2720652532..6c4b34aa305 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1436,9 +1436,11 @@ anv_image_init(struct anv_device *device, struct anv_image *image, goto fail; } - r = alloc_private_binding(device, image, pCreateInfo); - if (r != VK_SUCCESS) - goto fail; + if (!create_info->no_private_binding_alloc) { + r = alloc_private_binding(device, image, pCreateInfo); + if (r != VK_SUCCESS) + goto fail; + } check_memory_bindings(device, image); @@ -1498,7 +1500,8 @@ anv_swapchain_get_image(VkSwapchainKHR swapchain, static VkResult anv_image_init_from_create_info(struct anv_device *device, struct anv_image *image, - const VkImageCreateInfo *pCreateInfo) + const VkImageCreateInfo *pCreateInfo, + bool no_private_binding_alloc) { const VkNativeBufferANDROID *gralloc_info = vk_find_struct_const(pCreateInfo->pNext, NATIVE_BUFFER_ANDROID); @@ -1508,6 +1511,7 @@ anv_image_init_from_create_info(struct anv_device *device, struct anv_image_create_info create_info = { .vk_info = pCreateInfo, + .no_private_binding_alloc = no_private_binding_alloc, }; /* For dmabuf imports, configure the primary surface without support for @@ -1555,7 +1559,8 @@ VkResult anv_CreateImage( return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); VkResult result = anv_image_init_from_create_info(device, image, - pCreateInfo); + pCreateInfo, + false); if (result != VK_SUCCESS) { vk_object_free(&device->vk, pAllocator, image); return result; @@ -1747,7 +1752,7 @@ void anv_GetDeviceImageMemoryRequirementsKHR( struct anv_image image = { 0 }; ASSERTED VkResult result = - anv_image_init_from_create_info(device, &image, pInfo->pCreateInfo); + anv_image_init_from_create_info(device, &image, pInfo->pCreateInfo, true); assert(result == VK_SUCCESS); VkImageAspectFlags aspects = diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index a9650bf4129..18bf4d537e8 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -4057,6 +4057,9 @@ struct anv_image_create_info { /** An opt-in stride, should be 0 for implicit layouts */ uint32_t stride; + + /** Whether to allocate private binding */ + bool no_private_binding_alloc; }; VkResult anv_image_init(struct anv_device *device, struct anv_image *image,