diff options
author | wenchangliu <wenchangliu@google.com> | 2021-09-17 15:13:09 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-09-17 15:13:09 +0000 |
commit | 84d9aaa8ebf79bc33700eba9a235f4758107ec1f (patch) | |
tree | a2a92345f7985c278fdcabb55779ccb98c9f4d4b | |
parent | 8b7a7f9f89cbdc6377242f217338b4141540be7c (diff) | |
parent | ae4e8232fea166b0ec47ca104d8ca6cb17e530b0 (diff) | |
download | gchips-84d9aaa8ebf79bc33700eba9a235f4758107ec1f.tar.gz |
Fix YV12 stride alignment issue am: 313da845be am: e23ef4b341 am: ae4e8232fe
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/gchips/+/15836688
Change-Id: I41422c124ebd20049df9caaf00f12d9c536b75e8
-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) { |