/* Fill properties fields based on description. */
VkAndroidHardwareBufferFormatPropertiesANDROID *p = pProperties;
- p->format = vk_format_from_android(desc.format);
+ p->format = vk_format_from_android(desc.format, desc.usage);
const struct anv_format *anv_format = anv_get_format(p->format);
p->externalFormat = (uint64_t) (uintptr_t) anv_format;
vk_tiling == VK_IMAGE_TILING_OPTIMAL);
/* Check format. */
- VkFormat vk_format = vk_format_from_android(desc.format);
+ VkFormat vk_format = vk_format_from_android(desc.format, desc.usage);
enum isl_format isl_fmt = anv_get_isl_format(&device->info,
vk_format,
VK_IMAGE_ASPECT_COLOR_BIT,
/* See i915_private_android_types.h in minigbm. */
#define HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL 0x100
+enum {
+ /* Usage bit equal to GRALLOC_USAGE_HW_CAMERA_MASK */
+ AHARDWAREBUFFER_USAGE_CAMERA_MASK = 0x00060000U,
+};
+
static inline VkFormat
-vk_format_from_android(unsigned android_format)
+vk_format_from_android(unsigned android_format, unsigned android_usage)
{
switch (android_format) {
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
case HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL:
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
+ case AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED:
+ if (android_usage & AHARDWAREBUFFER_USAGE_CAMERA_MASK)
+ return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
+ else
+ return VK_FORMAT_R8G8B8_UNORM;
case AHARDWAREBUFFER_FORMAT_BLOB:
default:
return VK_FORMAT_UNDEFINED;