mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 16:00:08 +01:00
anv: avoid leaking private binding for aliased wsi image
Aliased wsi image has to share the same private binding with the
original wsi image for memory consistency. If the private binding
exists, it needs to be released before being overridden.
Fixes: d85a9d658f ("anv/image: Call into WSI to create swapchain images")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35893>
This commit is contained in:
parent
ef0bf50ae9
commit
b21e62b71a
1 changed files with 16 additions and 10 deletions
|
|
@ -1482,14 +1482,6 @@ alloc_private_binding(struct anv_device *device,
|
|||
if (binding->memory_range.size == 0)
|
||||
return VK_SUCCESS;
|
||||
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info =
|
||||
vk_find_struct_const(create_info->pNext, IMAGE_SWAPCHAIN_CREATE_INFO_KHR);
|
||||
|
||||
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
|
||||
/* The image will be bound to swapchain memory. */
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult result = anv_device_alloc_bo(device, "image-binding-private",
|
||||
binding->memory_range.size, 0, 0,
|
||||
&binding->address.bo);
|
||||
|
|
@ -2721,6 +2713,21 @@ anv_bind_image_memory(struct anv_device *device,
|
|||
assert(image->vk.aspects == swapchain_image->vk.aspects);
|
||||
assert(mem == NULL);
|
||||
|
||||
/* Remove the internally allocated private binding since we're going
|
||||
* to replace everything with BOs from the WSI image, we don't want
|
||||
* to leak the current BO.
|
||||
*/
|
||||
struct anv_bo *private_bo =
|
||||
image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].address.bo;
|
||||
if (private_bo) {
|
||||
assert(image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].memory_range.size);
|
||||
assert(!image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].host_map);
|
||||
|
||||
ANV_DMR_BO_FREE(&image->vk.base, private_bo);
|
||||
anv_device_release_bo(device, private_bo);
|
||||
image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].address.bo = NULL;
|
||||
}
|
||||
|
||||
for (int j = 0; j < ARRAY_SIZE(image->bindings); ++j) {
|
||||
assert(memory_ranges_equal(image->bindings[j].memory_range,
|
||||
swapchain_image->bindings[j].memory_range));
|
||||
|
|
@ -2733,8 +2740,7 @@ anv_bind_image_memory(struct anv_device *device,
|
|||
/* We must bump the private binding's bo's refcount because, unlike the other
|
||||
* bindings, its lifetime is not application-managed.
|
||||
*/
|
||||
struct anv_bo *private_bo =
|
||||
image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].address.bo;
|
||||
private_bo = image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].address.bo;
|
||||
if (private_bo)
|
||||
anv_bo_ref(private_bo);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue