Mesa (main): venus: swizzle the chroma channels for YVU420 to match the VkFormat
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 1 18:54:51 UTC 2022
Module: Mesa
Branch: main
Commit: 1b4784c5fbbf8fa57dd8ecb7b95e568492d8fa6f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b4784c5fbbf8fa57dd8ecb7b95e568492d8fa6f
Author: Yiwei Zhang <zzyiwei at chromium.org>
Date: Thu Jun 30 22:06:05 2022 +0000
venus: swizzle the chroma channels for YVU420 to match the VkFormat
Test:
- testVP8EncodeDecodeVideoFromBufferToSurface
- android.media.cts.DecodeAccuracyTest
Signed-off-by: Yiwei Zhang <zzyiwei at chromium.org>
Reviewed-by: Ryan Neph <ryanneph at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17323>
---
src/virtio/vulkan/vn_android.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/virtio/vulkan/vn_android.c b/src/virtio/vulkan/vn_android.c
index 67206404299..ca94d997622 100644
--- a/src/virtio/vulkan/vn_android.c
+++ b/src/virtio/vulkan/vn_android.c
@@ -104,6 +104,8 @@ struct cros_gralloc0_buffer_info {
struct vn_android_gralloc_buffer_properties {
uint32_t drm_fourcc;
uint64_t modifier;
+
+ /* plane order matches VkImageDrmFormatModifierExplicitCreateInfoEXT */
uint32_t offset[4];
uint32_t stride[4];
};
@@ -131,6 +133,18 @@ vn_android_gralloc_get_buffer_properties(
out_props->stride[i] = info.stride[i];
out_props->offset[i] = info.offset[i];
}
+
+ /* YVU420 has a chroma order of CrCb. So we must swap the planes for CrCb
+ * to align with VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM. This is to serve
+ * VkImageDrmFormatModifierExplicitCreateInfoEXT explicit plane layouts.
+ */
+ if (info.drm_fourcc == DRM_FORMAT_YVU420) {
+ out_props->stride[1] = info.stride[2];
+ out_props->offset[1] = info.offset[2];
+ out_props->stride[2] = info.stride[1];
+ out_props->offset[2] = info.offset[1];
+ }
+
out_props->modifier = info.modifier;
return true;
More information about the mesa-commit
mailing list