anv: avoid private buffer allocations in vkGetDeviceImageMemoryRequirementsKHR

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 <lionel.g.landwerlin@intel.com>
Fixes: 4075dd16ab ("anv: implement vkGetDeviceImageMemoryRequirementsKHR")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23720>
(cherry picked from commit 0e728ea7b0)
This commit is contained in:
Lionel Landwerlin 2023-06-19 13:03:37 +03:00 committed by Eric Engestrom
parent db633a8caa
commit 9c599dff88
3 changed files with 15 additions and 7 deletions

View file

@ -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"
},

View file

@ -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 =

View file

@ -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,