diff options
author | Nataraj Deshpande <[email protected]> | 2019-06-11 08:01:50 -0700 |
---|---|---|
committer | Tapani Pälli <[email protected]> | 2019-06-24 08:28:18 +0300 |
commit | d94fca54203edc0b7fece6aa2dc8703ad4e93c79 (patch) | |
tree | 298f0f813200bb3b12aa0d16ea14be6848e5bb42 | |
parent | 3b6d787e404181758227e205eda03600b25c1fd9 (diff) |
anv: Add HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in vk_format
When HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
gralloc module will select a format based on the usage flags provided by
the camera device and the other endpoint of the stream.
The patch fixes crash in vulkan when the test is run with camera stream
set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
Test: android.graphics.cts.CameraVulkanGpuTest#testCameraImportAndRendering
on chromebook with camera HAL3.
v2: use AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED and take
AHARDWAREBUFFER_USAGE_CAMERA_MASK in to account (Gurchetan)
Fixes: f1654fa7e31 "anv/android: support creating images from external format"
Signed-off-by: Nataraj Deshpande <[email protected]>
Signed-off-by: Gurchetan Singh <[email protected]>
Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Reviewed-by: Gurchetan Singh <[email protected]>
Acked-by: Lionel Landwerlin <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
-rw-r--r-- | src/intel/vulkan/anv_android.c | 2 | ||||
-rw-r--r-- | src/intel/vulkan/anv_image.c | 2 | ||||
-rw-r--r-- | src/intel/vulkan/vk_format_info.h | 12 |
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; |