summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/intel/vulkan/anv_android.c2
-rw-r--r--src/intel/vulkan/anv_image.c2
-rw-r--r--src/intel/vulkan/vk_format_info.h12
3 files changed, 13 insertions, 3 deletions
diff --git a/src/intel/vulkan/anv_android.c b/src/intel/vulkan/anv_android.c
index aee11ccacd2..8c785323d36 100644
--- a/src/intel/vulkan/anv_android.c
+++ b/src/intel/vulkan/anv_android.c
@@ -126,7 +126,7 @@ get_ahw_buffer_format_properties(
/* 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;
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index dcb570238ba..9170ed313e5 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -835,7 +835,7 @@ resolve_ahw_image(struct anv_device *device,
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,
diff --git a/src/intel/vulkan/vk_format_info.h b/src/intel/vulkan/vk_format_info.h
index 1369f54ee38..006e1f4a6ad 100644
--- a/src/intel/vulkan/vk_format_info.h
+++ b/src/intel/vulkan/vk_format_info.h
@@ -32,8 +32,13 @@
/* 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:
@@ -50,6 +55,11 @@ vk_format_from_android(unsigned android_format)
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;