anv: allow NV12 <--> AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 inter-op
authorGurchetan Singh <gurchetansingh@chromium.org>
Wed, 5 Jun 2019 16:51:07 +0000 (09:51 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Thu, 6 Jun 2019 16:20:03 +0000 (09:20 -0700)
AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 is an implementation defined
flexible YUV format.  Most of the times, it's NV12 or YV12.
On Intel, NV12 is preferred since it can be used by the display
engine.  

This API adds a dependency between gralloc and buffer consumers,
unfortunately.  Right now, the code seems to work for i915 gralloc,
but not cros_gralloc.  Add a preprocessor flag to fix this.

TEST=android.graphics.cts.MediaVulkanGpuTest#testMediaImportAndRendering

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/intel/vulkan/vk_format_info.h

index 2e126645763e3cd44111b8bdc8b49c93da753613..1369f54ee3881af62a3f0a1257a12e350934f33f 100644 (file)
@@ -47,6 +47,7 @@ vk_format_from_android(unsigned android_format)
       return VK_FORMAT_R16G16B16A16_SFLOAT;
    case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
       return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
+   case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
    case HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL:
       return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
    case AHARDWAREBUFFER_FORMAT_BLOB:
@@ -70,7 +71,11 @@ android_format_from_vk(unsigned vk_format)
    case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
       return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;
    case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
+#ifdef HAVE_CROS_GRALLOC
+      return AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420;
+#else
       return HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL;
+#endif
    default:
       return AHARDWAREBUFFER_FORMAT_BLOB;
    }