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 <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 4 years ago
parent 9dac27a026
commit ad2e9c49da
  1. 6
      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;

Loading…
Cancel
Save