From 9cc29b194a67d7b4bc402133810d185b1335a42a Mon Sep 17 00:00:00 2001 From: David Stevens Date: Fri, 6 Sep 2019 17:51:24 +0900 Subject: [PATCH] virgl/gbm: Account for bpp in planar stride MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When transferring to/from a planar buffer, multiply by bytes-per-pixel when computing each plane's stride from stride0. In particular, this is necessary when transferring to/from biplanar yuv buffers. Signed-off-by: David Stevens Reviewed-by: Gurchetan Singh --- src/virgl_gbm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/virgl_gbm.c b/src/virgl_gbm.c index 06013b7..4f926e8 100644 --- a/src/virgl_gbm.c +++ b/src/virgl_gbm.c @@ -336,8 +336,12 @@ int virgl_gbm_transfer(struct gbm_bo *bo, uint32_t direction, struct iovec *iove uint32_t subsampled_width = info->box->width / layout->horizontal_subsampling[plane]; uint32_t subsampled_height = info->box->height / layout->vertical_subsampling[plane]; uint32_t plane_height = height / layout->vertical_subsampling[plane]; - uint32_t guest_plane_stride = guest_stride0 / layout->horizontal_subsampling[plane]; - uint32_t host_plane_stride = host_map_stride0 / layout->horizontal_subsampling[plane]; + + uint32_t plane_byte_ratio = layout->bytes_per_pixel[plane] / layout->bytes_per_pixel[0]; + uint32_t guest_plane_stride = (guest_stride0 * plane_byte_ratio) + / layout->horizontal_subsampling[plane]; + uint32_t host_plane_stride = (host_map_stride0 * plane_byte_ratio) + / layout->horizontal_subsampling[plane]; uint32_t guest_resource_offset = guest_plane_offset + (subsampled_y * guest_plane_stride) + subsampled_x * layout->bytes_per_pixel[plane];