venus: implement image creation for ahb handle type
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10960>
This commit is contained in:
@@ -947,3 +947,28 @@ vn_android_get_drm_format_modifier_info(
|
||||
AHardwareBuffer_release(ahb);
|
||||
return true;
|
||||
}
|
||||
|
||||
VkResult
|
||||
vn_android_image_from_ahb(struct vn_device *dev,
|
||||
const VkImageCreateInfo *create_info,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
struct vn_image **out_img)
|
||||
{
|
||||
const VkExternalFormatANDROID *ext_info =
|
||||
vk_find_struct_const(create_info->pNext, EXTERNAL_FORMAT_ANDROID);
|
||||
|
||||
VkImageCreateInfo local_info;
|
||||
if (ext_info && ext_info->externalFormat) {
|
||||
assert(create_info->format == VK_FORMAT_UNDEFINED);
|
||||
assert(create_info->imageType == VK_IMAGE_TYPE_2D);
|
||||
assert(create_info->usage == VK_IMAGE_USAGE_SAMPLED_BIT);
|
||||
assert(create_info->tiling == VK_IMAGE_TILING_OPTIMAL);
|
||||
|
||||
local_info = *create_info;
|
||||
local_info.format =
|
||||
vn_android_ahb_format_to_vk_format(ext_info->externalFormat);
|
||||
create_info = &local_info;
|
||||
}
|
||||
|
||||
return vn_image_create_deferred(dev, create_info, alloc, out_img);
|
||||
}
|
||||
|
@@ -61,6 +61,12 @@ uint64_t
|
||||
vn_android_get_ahb_usage(const VkImageUsageFlags usage,
|
||||
const VkImageCreateFlags flags);
|
||||
|
||||
VkResult
|
||||
vn_android_image_from_ahb(struct vn_device *dev,
|
||||
const VkImageCreateInfo *create_info,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
struct vn_image **out_img);
|
||||
|
||||
#else
|
||||
|
||||
static inline VkResult
|
||||
@@ -108,6 +114,15 @@ vn_android_get_ahb_usage(UNUSED const VkImageUsageFlags usage,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline VkResult
|
||||
vn_android_image_from_ahb(UNUSED struct vn_device *dev,
|
||||
UNUSED const VkImageCreateInfo *create_info,
|
||||
UNUSED const VkAllocationCallbacks *alloc,
|
||||
UNUSED struct vn_image **out_img)
|
||||
{
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
#endif /* ANDROID */
|
||||
|
||||
#endif /* VN_ANDROID_H */
|
||||
|
@@ -391,6 +391,13 @@ vn_CreateImage(VkDevice device,
|
||||
vn_wsi_find_wsi_image_create_info(pCreateInfo);
|
||||
const VkNativeBufferANDROID *anb_info =
|
||||
vn_android_find_native_buffer(pCreateInfo);
|
||||
const VkExternalMemoryImageCreateInfo *external_info =
|
||||
vk_find_struct_const(pCreateInfo->pNext,
|
||||
EXTERNAL_MEMORY_IMAGE_CREATE_INFO);
|
||||
const bool ahb_info =
|
||||
external_info &&
|
||||
external_info->handleTypes ==
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
|
||||
|
||||
if (wsi_info) {
|
||||
assert(wsi_info->scanout);
|
||||
@@ -398,6 +405,8 @@ vn_CreateImage(VkDevice device,
|
||||
} else if (anb_info) {
|
||||
result =
|
||||
vn_android_image_from_anb(dev, pCreateInfo, anb_info, alloc, &img);
|
||||
} else if (ahb_info) {
|
||||
result = vn_android_image_from_ahb(dev, pCreateInfo, alloc, &img);
|
||||
} else {
|
||||
result = vn_image_create(dev, pCreateInfo, alloc, &img);
|
||||
}
|
||||
|
Reference in New Issue
Block a user