OSDN Git Service

minigbm: i915: Align chroma planes of planar formats properly
authorTomasz Figa <tfiga@chromium.org>
Sat, 29 Jul 2017 06:37:58 +0000 (15:37 +0900)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 3 Aug 2017 08:11:02 +0000 (01:11 -0700)
Mesa handles planar formats with separate surface for each plane. Each
linear surface has certain width and height alignment restrictions.
However minigbm's i915 backend currently does not account for chroma plane
subsampling when calculating the alignments, so that only the luma plane
gets enough alignment. Fix this by multiplying luma plane alignment by
chroma subsampling factor, both horizonal and vertical for 3-plane
formats and only the latter for 2-plane formats.

Fixes following CTS tests on Intel platforms:
android.media.cts.VideoEncoderTest#testGoogVP8FlexArbitraryH
android.media.cts.VideoEncoderTest#testGoogVP8FlexArbitraryW
android.media.cts.VideoEncoderTest#testGoogVP8FlexNearMaxMin
android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryH
android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryW
android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMaxMin

BUG=b:63957026
TEST=./cts-tradefed run cts -m CtsMediaTestCases
 -t android.media.cts.VideoEncoderTest

Change-Id: I8459b0f5f22ba9f9936fa987a13dd99d6b245560
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/592989
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
i915.c

diff --git a/i915.c b/i915.c
index c8cd1d5..83bd738 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -207,6 +207,21 @@ static int i915_align_dimensions(struct bo *bo, uint32_t tiling, uint32_t *strid
                break;
        }
 
+       /*
+        * The alignment calculated above is based on the full size luma plane and to have chroma
+        * planes properly aligned with subsampled formats, we need to multiply luma alignment by
+        * subsampling factor.
+        */
+       switch (bo->format) {
+       case DRM_FORMAT_YVU420_ANDROID:
+       case DRM_FORMAT_YVU420:
+               horizontal_alignment *= 2;
+               /* Fall through */
+       case DRM_FORMAT_NV12:
+               vertical_alignment *= 2;
+               break;
+       }
+
        *aligned_height = ALIGN(bo->height, vertical_alignment);
        if (i915->gen > 3) {
                *stride = ALIGN(*stride, horizontal_alignment);
@@ -296,13 +311,6 @@ static int i915_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32
                return ret;
 
        /*
-        * Align the Y plane to 128 bytes so the chroma planes would be aligned
-        * to 64 byte boundaries. This is an Intel HW requirement.
-        */
-       if (format == DRM_FORMAT_YVU420)
-               stride = ALIGN(stride, 128);
-
-       /*
         * HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not be aligned.
         */
        if (format == DRM_FORMAT_YVU420_ANDROID)