diff options
author | wenchangliu <wenchangliu@google.com> | 2021-09-17 14:37:58 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-09-17 14:37:58 +0000 |
commit | e23ef4b341bf51e246ee3f1a7ca83fc6e1c148da (patch) | |
tree | a2a92345f7985c278fdcabb55779ccb98c9f4d4b | |
parent | 741b5772c91919c65da49bc44b6d8a8c073b0564 (diff) | |
parent | 313da845beaba91bee8793308923ab05dcbc60f7 (diff) | |
download | gchips-e23ef4b341bf51e246ee3f1a7ca83fc6e1c148da.tar.gz |
Fix YV12 stride alignment issue am: 313da845be
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/gchips/+/15836688
Change-Id: Icb01ac6e143ab633a918baca4561538f0ffa2905
-rw-r--r-- | gralloc4/src/core/mali_gralloc_bufferallocation.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp index 53bbb6f..fe2349b 100644 --- a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp +++ b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp @@ -446,22 +446,17 @@ static void update_yv12_stride(int8_t plane, { if (plane == 0) { - /* - * Ensure luma stride is aligned to "2*lcm(hw_align, cpu_align)" so - * that chroma stride can satisfy both CPU and HW alignment - * constraints when only half luma stride (as mandated for format). - */ - *byte_stride = GRALLOC_ALIGN(luma_stride, 2 * stride_align); + *byte_stride = GRALLOC_ALIGN(luma_stride, stride_align); } else { /* * Derive chroma stride from luma and verify it is: - * 1. Aligned to lcm(hw_align, cpu_align) + * 1. Aligned to "1/2*lcm(hw_align, cpu_align)" * 2. Multiple of 16px (16 bytes) */ *byte_stride = luma_stride / 2; - assert(*byte_stride == GRALLOC_ALIGN(*byte_stride, stride_align)); + assert(*byte_stride == GRALLOC_ALIGN(*byte_stride, stride_align / 2)); assert(*byte_stride & 15 == 0); } } @@ -611,6 +606,10 @@ static void calc_allocation_size(const int width, /* * Update YV12 stride with both CPU & HW usage due to constraint of chroma stride. * Width is anyway aligned to 16px for luma and chroma (has_cpu_usage). + * + * Note: To prevent luma stride misalignment with GPU stride alignment. + * The luma plane will maintain the same `stride` size, and the chroma plane + * will align to `stride/2`. */ if (format.id == MALI_GRALLOC_FORMAT_INTERNAL_YV12 && has_hw_usage && has_cpu_usage) { |