anv/android: Add support for AHARDWAREBUFFER_FORMAT_YV12
The default MediaCodec software video decoder returns frames in this format. Signed-off-by: Chris Spencer <spencercw@gmail.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24388>
This commit is contained in:
@@ -119,6 +119,8 @@ vk_format_from_android(unsigned android_format, unsigned android_usage)
|
||||
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
|
||||
case HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL:
|
||||
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_YV12:
|
||||
return VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED:
|
||||
if (android_usage & BUFFER_USAGE_CAMERA_MASK)
|
||||
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
|
||||
@@ -1137,8 +1137,29 @@ add_all_surfaces_implicit_layout(
|
||||
if (ycbcr_info)
|
||||
assert(ycbcr_info->n_planes == image->n_planes);
|
||||
|
||||
unsigned num_aspects = 0;
|
||||
VkImageAspectFlagBits aspects[3];
|
||||
u_foreach_bit(b, image->vk.aspects) {
|
||||
VkImageAspectFlagBits aspect = 1 << b;
|
||||
assert(num_aspects < 3);
|
||||
aspects[num_aspects++] = 1 << b;
|
||||
}
|
||||
assert(num_aspects == image->n_planes);
|
||||
|
||||
/* The Android hardware buffer YV12 format has the planes ordered as Y-Cr-Cb,
|
||||
* while Vulkan expects VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM to be in Y-Cb-Cr.
|
||||
* Adjust the order we add the ISL surfaces accordingly so the implicit
|
||||
* offset gets calculated correctly.
|
||||
*/
|
||||
if (image->from_ahb && image->vk.format == VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM) {
|
||||
assert(num_aspects == 3);
|
||||
assert(aspects[1] == VK_IMAGE_ASPECT_PLANE_1_BIT);
|
||||
assert(aspects[2] == VK_IMAGE_ASPECT_PLANE_2_BIT);
|
||||
aspects[1] = VK_IMAGE_ASPECT_PLANE_2_BIT;
|
||||
aspects[2] = VK_IMAGE_ASPECT_PLANE_1_BIT;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < num_aspects; i++) {
|
||||
VkImageAspectFlagBits aspect = aspects[i];
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
const struct anv_format_plane plane_format =
|
||||
anv_get_format_plane(devinfo, image->vk.format, plane, image->vk.tiling);
|
||||
|
||||
Reference in New Issue
Block a user