virgl: honor winsys supplied metadata
authorGurchetan Singh <gurchetansingh@chromium.org>
Wed, 25 Sep 2019 17:44:44 +0000 (10:44 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Thu, 3 Oct 2019 00:57:59 +0000 (17:57 -0700)
To truly to do this correctly, we'll have to fix the discrepancy between
drm_virtgpu_3d_transfer_to_host and virtio_gpu_transfer_host_3d. However,
this is a good starting point.

Since virtio-gpu only supports self-import and export, this should be fine.
Let's only do WINSYS_HANDLE_TYPE_FD for this currently.

Reviewed by: Robert Tarasov <tutankhamen@chromium.org>

src/gallium/winsys/virgl/drm/virgl_drm_winsys.c

index 01e1f51d757487bb22511e5181c0ff9ea061cc0f..0fe61bbe4659a635cb6c8c95d5aeedb5bcd6938f 100644 (file)
@@ -313,10 +313,15 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws,
    struct virgl_hw_res *res = NULL;
    uint32_t handle = whandle->handle;
 
-   if (whandle->offset != 0) {
+   if (whandle->offset != 0 && whandle->type == WINSYS_HANDLE_TYPE_SHARED) {
       _debug_printf("attempt to import unsupported winsys offset %u\n",
                     whandle->offset);
       return NULL;
+   } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) {
+      *plane = whandle->plane;
+      *stride = whandle->stride;
+      *plane_offset = whandle->offset;
+      *modifier = whandle->modifier;
    }
 
    mtx_lock(&qdws->bo_handles_mutex);