venus: clarify wsi image ownership

Fix to call vn_image_bind_wsi_memory as long as the image is a wsi
image. This is needed so that we track the wsi memory in the wsi image
so that creating from swapchain info works normally on x11/wayland
platforms. This change also make it clear that ANB image owns the wsi
memory

Fixes: c4b30b604f ("venus: support VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 8")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30278>
(cherry picked from commit a27e3c5078)
This commit is contained in:
Yiwei Zhang 2024-07-19 16:00:54 -07:00 committed by Eric Engestrom
parent 5ce44462e2
commit e013c79aad
2 changed files with 12 additions and 4 deletions

View file

@ -524,7 +524,7 @@
"description": "venus: clarify wsi image ownership",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "c4b30b604fda53dfaed83bcbe1467ac1023b2c90",
"notes": null

View file

@ -431,6 +431,9 @@ vn_image_deferred_info_init(struct vn_image *img,
info->from_external_format = true;
}
} break;
case VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR:
img->wsi.is_wsi = true;
break;
default:
break;
}
@ -805,8 +808,12 @@ vn_image_bind_wsi_memory(struct vn_device *dev,
}
assert(mem && info->memory != VK_NULL_HANDLE);
if (img->wsi.is_wsi)
img->wsi.memory = mem;
#if DETECT_OS_ANDROID
assert(img->wsi.memory);
#else
assert(!img->wsi.memory);
img->wsi.memory = mem;
#endif
}
vn_async_vkBindImageMemory2(dev->primary_ring, vn_device_to_handle(dev),
@ -825,7 +832,8 @@ vn_BindImageMemory2(VkDevice device,
struct vn_device *dev = vn_device_from_handle(device);
for (uint32_t i = 0; i < bindInfoCount; i++) {
if (pBindInfos[i].memory == VK_NULL_HANDLE)
struct vn_image *img = vn_image_from_handle(pBindInfos[i].image);
if (img->wsi.is_wsi)
return vn_image_bind_wsi_memory(dev, bindInfoCount, pBindInfos);
}