@@ -97,6 +97,7 @@ enum virtio_gpu_base_conf_flags {
VIRTIO_GPU_FLAG_EDID_ENABLED,
VIRTIO_GPU_FLAG_DMABUF_ENABLED,
VIRTIO_GPU_FLAG_BLOB_ENABLED,
+ VIRTIO_GPU_FLAG_RENDER_SYNC_ENABLED,
VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED,
VIRTIO_GPU_FLAG_RUTABAGA_ENABLED,
};
@@ -111,6 +112,8 @@ enum virtio_gpu_base_conf_flags {
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED))
#define virtio_gpu_blob_enabled(_cfg) \
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED))
+#define virtio_gpu_render_sync_enabled(_cfg) \
+ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_RENDER_SYNC_ENABLED))
#define virtio_gpu_context_init_enabled(_cfg) \
(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED))
#define virtio_gpu_rutabaga_enabled(_cfg) \
@@ -17,7 +17,8 @@ QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t height,
uint32_t y, uint32_t backing_width,
uint32_t backing_height, uint32_t fourcc,
uint64_t modifier, int dmabuf_fd,
- bool allow_fences, bool y0_top);
+ bool allow_fences, bool y0_top,
+ bool render_sync);
void qemu_dmabuf_free(QemuDmaBuf *dmabuf);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuDmaBuf, qemu_dmabuf_free);
@@ -40,6 +41,7 @@ void *qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf);
int32_t qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf);
bool qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf);
bool qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf);
+bool qemu_dmabuf_get_render_sync(QemuDmaBuf *dmabuf);
void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint32_t texture);
void qemu_dmabuf_set_fence_fd(QemuDmaBuf *dmabuf, int32_t fence_fd);
void qemu_dmabuf_set_sync(QemuDmaBuf *dmabuf, void *sync);
@@ -285,7 +285,8 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)
m->fd_stride, 0, 0, 0, 0,
m->fd_drm_fourcc, modifier,
fd, false, m->fd_flags &
- VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP);
+ VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP,
+ false);
dpy_gl_scanout_dmabuf(con, dmabuf);
g->dmabuf[m->scanout_id] = dmabuf;
@@ -176,6 +176,7 @@ static VGPUDMABuf
struct virtio_gpu_rect *r)
{
VGPUDMABuf *dmabuf;
+ bool render_sync = virtio_gpu_render_sync_enabled(g->parent_obj.conf);
if (res->dmabuf_fd < 0) {
return NULL;
@@ -185,7 +186,7 @@ static VGPUDMABuf
dmabuf->buf = qemu_dmabuf_new(r->width, r->height, fb->stride,
r->x, r->y, fb->width, fb->height,
qemu_pixman_to_drm_format(fb->format),
- 0, res->dmabuf_fd, true, false);
+ 0, res->dmabuf_fd, true, false, render_sync);
dmabuf->scanout_id = scanout_id;
QTAILQ_INSERT_HEAD(&g->dmabuf.bufs, dmabuf, next);
@@ -1671,6 +1671,8 @@ static Property virtio_gpu_properties[] = {
256 * MiB),
DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags,
VIRTIO_GPU_FLAG_BLOB_ENABLED, false),
+ DEFINE_PROP_BIT("render_sync", VirtIOGPU, parent_obj.conf.flags,
+ VIRTIO_GPU_FLAG_RENDER_SYNC_ENABLED, true),
DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0),
DEFINE_PROP_UINT8("x-scanout-vmstate-version", VirtIOGPU, scanout_vmstate_version, 2),
DEFINE_PROP_END_OF_LIST(),
@@ -244,7 +244,8 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDevice *vdev,
dmabuf->buf = qemu_dmabuf_new(plane.width, plane.height,
plane.stride, 0, 0, plane.width,
plane.height, plane.drm_format,
- plane.drm_format_mod, fd, false, false);
+ plane.drm_format_mod, fd, false,
+ false, false);
if (plane_type == DRM_PLANE_TYPE_CURSOR) {
vfio_display_update_cursor(dmabuf, &plane);
@@ -456,7 +456,7 @@ static void dbus_scanout_texture(DisplayChangeListener *dcl,
}
dmabuf = qemu_dmabuf_new(w, h, stride, x, y, backing_width,
backing_height, fourcc, modifier, fd,
- false, backing_y_0_top);
+ false, backing_y_0_top, false);
dbus_scanout_dmabuf(dcl, dmabuf);
qemu_dmabuf_close(dmabuf);
@@ -26,6 +26,7 @@ struct QemuDmaBuf {
void *sync;
int fence_fd;
bool allow_fences;
+ bool render_sync;
bool draw_submitted;
};
@@ -34,7 +35,7 @@ QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t height,
uint32_t y, uint32_t backing_width,
uint32_t backing_height, uint32_t fourcc,
uint64_t modifier, int32_t dmabuf_fd,
- bool allow_fences, bool y0_top) {
+ bool allow_fences, bool y0_top, bool render_sync) {
QemuDmaBuf *dmabuf;
dmabuf = g_new0(QemuDmaBuf, 1);
@@ -51,6 +52,7 @@ QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t height,
dmabuf->fd = dmabuf_fd;
dmabuf->allow_fences = allow_fences;
dmabuf->y0_top = y0_top;
+ dmabuf->render_sync = render_sync;
dmabuf->fence_fd = -1;
return dmabuf;
@@ -198,6 +200,13 @@ bool qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf)
return dmabuf->draw_submitted;
}
+bool qemu_dmabuf_get_render_sync(QemuDmaBuf *dmabuf)
+{
+ assert(dmabuf != NULL);
+
+ return dmabuf->render_sync;
+}
+
void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint32_t texture)
{
assert(dmabuf != NULL);