From ad2e9c49da5af9296f5ef2e32b4a4871aef27675 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 4 Dec 2020 18:12:17 -0800 Subject: [PATCH] vrend: fix gbm transfer to subregion The bo contents may be undefined when only GBM_BO_TRANSFER_WRITE is set (e.g., with radeonsi). When transferring to a subregion, we need to set GBM_BO_TRANSFER_READ as well. gbm_bo_map2 does allow us to map a subregion, but not all implementations work correctly. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/vrend_winsys_gbm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vrend_winsys_gbm.c b/src/vrend_winsys_gbm.c index 2ee5917..578086d 100644 --- a/src/vrend_winsys_gbm.c +++ b/src/vrend_winsys_gbm.c @@ -336,6 +336,12 @@ int virgl_gbm_transfer(struct gbm_bo *bo, uint32_t direction, const struct iovec host_map_stride0 = 0; uint32_t map_flags = (direction == VIRGL_TRANSFER_TO_HOST) ? GBM_BO_TRANSFER_WRITE : GBM_BO_TRANSFER_READ; + /* XXX remove this and map just the region when single plane and GBM honors the region */ + if (direction == VIRGL_TRANSFER_TO_HOST && + !(info->box->x == 0 && info->box->y == 0 && + info->box->width == width && info->box->height == height)) + map_flags |= GBM_BO_TRANSFER_READ; + void *addr = gbm_bo_map(bo, 0, 0, width, height, map_flags, &host_map_stride0, &map_data); if (!addr) return -1;