From: Marek Olšák <marek.ol...@amd.com> - We have to use the linear layout, otherwise the offsets can't be modified. - The GBM image has only 1 plane, so the gbm functions can't be used for other planes. - Don't manipulate with the stride. It has to be the same. --- .../piglit-framework-gl/piglit_drm_dma_buf.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c b/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c index d2182c48c..c8adc35a4 100644 --- a/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c +++ b/tests/util/piglit-framework-gl/piglit_drm_dma_buf.c @@ -323,21 +323,22 @@ piglit_gbm_buf_create(unsigned w, unsigned h, unsigned fourcc, buf_w = w / 2; buf_h = h * 2; /* U/V not interleaved */ src_stride = w; cpp = 1; break; default: fprintf(stderr, "invalid fourcc: %.4s\n", (char *)&fourcc); return false; } - bo = gbm_bo_create(gbm, buf_w, buf_h, format, GBM_BO_USE_RENDERING); + bo = gbm_bo_create(gbm, buf_w, buf_h, format, + GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR); if (!bo) return false; dst_data = gbm_bo_map(bo, 0, 0, buf_w, buf_h, GBM_BO_TRANSFER_WRITE, &dst_stride, &map_data); if (!dst_data) { fprintf(stderr, "Failed to map GBM bo\n"); gbm_bo_destroy(bo); return NULL; } @@ -354,38 +355,38 @@ piglit_gbm_buf_create(unsigned w, unsigned h, unsigned fourcc, src_data + i * src_stride, w * cpp); } switch (fourcc) { case DRM_FORMAT_NV12: for (i = 0; i < h/2; ++i) { memcpy(((char *)dst_data + dst_stride * h) + i * dst_stride, (src_data + (w*h)) + i * src_stride, w); } - buf->offset[1] = gbm_bo_get_offset(bo, 1); - buf->stride[1] = gbm_bo_get_stride_for_plane(bo, 1); + buf->offset[1] = buf->stride[0] * h; + buf->stride[1] = buf->stride[0]; break; case DRM_FORMAT_YUV420: case DRM_FORMAT_YVU420: for (i = 0; i < h/2; ++i) { - memcpy(((char *)dst_data + dst_stride * h) + i * dst_stride / 2, + memcpy(((char *)dst_data + dst_stride * h) + i * dst_stride, (src_data + (w*h)) + i * src_stride / 2, w / 2); } - unsigned cpu_offset2 = dst_stride * h + (dst_stride * h / 2 / 2); + unsigned cpu_offset2 = dst_stride * h + dst_stride * h / 2; for (i = 0; i < h/2; ++i) { - memcpy(((char *)dst_data + cpu_offset2) + i * dst_stride / 2, + memcpy(((char *)dst_data + cpu_offset2) + i * dst_stride, (src_data + (w*h) + (w*h/4)) + i * src_stride / 2, w / 2); } - buf->offset[1] = gbm_bo_get_offset(bo, 1); - buf->stride[1] = gbm_bo_get_stride_for_plane(bo, 1); - buf->offset[2] = gbm_bo_get_offset(bo, 2); - buf->stride[2] = gbm_bo_get_stride_for_plane(bo, 2); + buf->offset[1] = buf->stride[0] * h; + buf->stride[1] = buf->stride[0]; + buf->offset[2] = buf->stride[0] * h + buf->stride[0] * h / 2; + buf->stride[2] = buf->stride[1]; break; default: break; } gbm_bo_unmap(bo, map_data); return true; } -- 2.17.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit