vulkan/android: add new helpers for aliased ANB support (spec v8+)

Reviewed-by: Lucas Fryzek <lfryzek@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40384>
This commit is contained in:
Yiwei Zhang 2025-06-06 01:17:54 -07:00 committed by Marge Bot
parent f863fc962c
commit bd916d9de9
2 changed files with 20 additions and 0 deletions

View file

@ -113,6 +113,13 @@ vk_image_init(struct vk_device *device,
image->android_buffer_type = ANDROID_BUFFER_NATIVE;
}
const VkImageSwapchainCreateInfoKHR *swapchain_info =
vk_find_struct_const(pCreateInfo->pNext, IMAGE_SWAPCHAIN_CREATE_INFO_KHR);
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
assert(image->android_buffer_type == ANDROID_BUFFER_NONE);
image->android_buffer_type = ANDROID_BUFFER_NATIVE_ALIAS;
}
const VkExternalFormatANDROID *ext_format =
vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_FORMAT_ANDROID);
if (ext_format && ext_format->externalFormat != 0) {

View file

@ -32,6 +32,7 @@
enum android_buffer_type {
ANDROID_BUFFER_NONE = 0,
ANDROID_BUFFER_NATIVE,
ANDROID_BUFFER_NATIVE_ALIAS,
ANDROID_BUFFER_HARDWARE,
};
#endif
@ -422,12 +423,24 @@ vk_image_is_android_native_buffer(struct vk_image *image)
{
return image->android_buffer_type == ANDROID_BUFFER_NATIVE;
}
static inline bool
vk_image_is_android_native_buffer_alias(struct vk_image *image)
{
return image->android_buffer_type == ANDROID_BUFFER_NATIVE_ALIAS;
}
#else
static inline bool
vk_image_is_android_native_buffer(struct vk_image *image)
{
return false;
}
static inline bool
vk_image_is_android_native_buffer_alias(struct vk_image *image)
{
return false;
}
#endif /* VK_USE_PLATFORM_ANDROID_KHR */
#if defined(VK_USE_PLATFORM_ANDROID_KHR) && ANDROID_API_LEVEL >= 26