History

drm/virtgpu api: blob resources

This makes blob resources available to guest userspace. They are needed for GL4.5, Vulkan and zero-copy virtio-gpu. For Mesa, blob resources have been tested with Piglit's ARB_buffer_storage tests and apitraces. Apitraces of GL4.5 games show we're between 70% to 80% of host performance on Iris, based on a apitrace of a 2013 GL4.5 game: 11.204 FPS (guest) 15.947 FPS (host) This is still better than the status quo, when said game was unplayable with Virgl due to an inefficient GL4.3 fallback. But there's still room for improvement if we want to match HW-assisted virtualization. For Vulkan, blob resources have been tested with dEQP.vk.memory* and running Vulkan applications in production with the "Cuttlefish" virtual Android device. This has been done with Lingfeng Yang's "gfxstream" Vulkan implementation, which virtualizes Vulkan across many Google products.

Gurchetan Singh committed 6 years ago

Commit eda3e101 parent e5cd6cb1 file · +36 −1Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/drm/virtgpu_drm.h+36−1
@@ -46,6 +46,7 @@ extern "C" { · 45 unmodified lines
4646 #define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07
4747 #define DRM_VIRTGPU_WAIT 0x08
4848 #define DRM_VIRTGPU_GET_CAPS 0x09
49+#define DRM_VIRTGPU_RESOURCE_CREATE_BLOB 0x0a
4950
5051 #define VIRTGPU_EXECBUF_FENCE_FD_IN 0x01
5152 #define VIRTGPU_EXECBUF_FENCE_FD_OUT 0x02
@@ -71,6 +72,7 @@ struct drm_virtgpu_execbuffer { · 19 unmodified lines
7172
7273 #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
7374 #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
75+#define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */
7476
7577 struct drm_virtgpu_getparam {
7678 __u64 param;
@@ -100,7 +102,7 @@ struct drm_virtgpu_resource_info { · 23 unmodified lines
100102 __u32 bo_handle;
101103 __u32 res_handle;
102104 __u32 size;
103− __u32 stride;
105+ __u32 blob_mem;
104106 };
105107
106108 struct drm_virtgpu_3d_box {
@@ -117,6 +119,8 @@ struct drm_virtgpu_3d_transfer_to_host { · 10 unmodified lines
117119 struct drm_virtgpu_3d_box box;
118120 __u32 level;
119121 __u32 offset;
122+ __u32 stride;
123+ __u32 layer_stride;
120124 };
121125
122126 struct drm_virtgpu_3d_transfer_from_host {
@@ -124,6 +128,8 @@ struct drm_virtgpu_3d_transfer_from_host { · 1 unmodified line
124128 struct drm_virtgpu_3d_box box;
125129 __u32 level;
126130 __u32 offset;
131+ __u32 stride;
132+ __u32 layer_stride;
127133 };
128134
129135 #define VIRTGPU_WAIT_NOWAIT 1 /* like it */
@@ -140,6 +146,31 @@ struct drm_virtgpu_get_caps { · 10 unmodified lines
140146 __u32 pad;
141147 };
142148
149+struct drm_virtgpu_resource_create_blob {
150+#define VIRTGPU_BLOB_MEM_GUEST 0x0001
151+#define VIRTGPU_BLOB_MEM_HOST3D 0x0002
152+#define VIRTGPU_BLOB_MEM_HOST3D_GUEST 0x0003
153+
154+#define VIRTGPU_BLOB_FLAG_USE_MAPPABLE 0x0001
155+#define VIRTGPU_BLOB_FLAG_USE_SHAREABLE 0x0002
156+#define VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
157+ /* zero is invalid blob_mem */
158+ __u32 blob_mem;
159+ __u32 blob_flags;
160+ __u32 bo_handle;
161+ __u32 res_handle;
162+ __u64 size;
163+
164+ /*
165+ * for 3D contexts with VIRTGPU_BLOB_MEM_HOST3D_GUEST and
166+ * VIRTGPU_BLOB_MEM_HOST3D otherwise, must be zero.
167+ */
168+ __u32 pad;
169+ __u32 cmd_size;
170+ __u64 cmd;
171+ __u64 blob_id;
172+};
173+
143174 #define DRM_IOCTL_VIRTGPU_MAP \
144175 DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
145176
@@ -175,6 +206,10 @@ struct drm_virtgpu_get_caps { · 29 unmodified lines
175206 DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
176207 struct drm_virtgpu_get_caps)
177208
209+#define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB \
210+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE_BLOB, \
211+ struct drm_virtgpu_resource_create_blob)
212+
178213 #if defined(__cplusplus)
179214 }
180215 #endif