From: Chad Versace <chadvers...@chromium.org> If this flag is set, then the image and it's bo have the same lifetime. vkDestroyImage will release the bo.
We need this for VK_ANDROID_native_buffer, because that extension creates the VkImage and imports its memory in the same call, vkCreateImage. --- src/intel/vulkan/anv_image.c | 9 ++++++++- src/intel/vulkan/anv_private.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index ba09cc4c585..d6691014552 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -451,8 +451,12 @@ anv_image_create(VkDevice _device, return VK_SUCCESS; fail: - if (image) + if (image) { + if (image->bo && image->bo_is_owned) + anv_bo_cache_release(device, &device->bo_cache, image->bo); + vk_free2(&device->alloc, alloc, image); + } return r; } @@ -481,6 +485,9 @@ anv_DestroyImage(VkDevice _device, VkImage _image, if (!image) return; + if (image->bo && image->bo_is_owned) + anv_bo_cache_release(device, &device->bo_cache, image->bo); + vk_free2(&device->alloc, pAllocator, image); } diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 16670f2ac3b..7a7f23141af 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2224,6 +2224,7 @@ struct anv_image { /* Set when bound */ struct anv_bo *bo; VkDeviceSize offset; + bool bo_is_owned; /**< When destroying the image, also free its bo. */ /** * Image subsurfaces -- 2.13.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev