@@ -167,6 +167,34 @@ static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUDMABuf *dmabuf)
g_free(dmabuf);
}
+static VGPUDMABuf
+*virtio_gpu_find_dmabuf(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res)
+{
+ VGPUDMABuf *dmabuf, *tmp;
+
+ QTAILQ_FOREACH_SAFE(dmabuf, &g->dmabuf.bufs, next, tmp) {
+ if (dmabuf->buf.fd == res->dmabuf_fd) {
+ return dmabuf;
+ }
+ }
+
+ return NULL;
+}
+
+void virtio_gpu_resource_wait_sync(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res)
+{
+ struct virtio_gpu_scanout *scanout;
+ VGPUDMABuf *dmabuf;
+
+ dmabuf = virtio_gpu_find_dmabuf(g, res);
+ if (dmabuf && dmabuf->buf.sync) {
+ scanout = &g->parent_obj.scanout[dmabuf->scanout_id];
+ dpy_gl_wait_dmabuf(scanout->con, &dmabuf->buf);
+ }
+}
+
static VGPUDMABuf
*virtio_gpu_create_dmabuf(VirtIOGPU *g,
uint32_t scanout_id,
@@ -523,6 +523,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
console_has_gl(scanout->con)) {
dpy_gl_update(scanout->con, 0, 0, scanout->width,
scanout->height);
+ virtio_gpu_resource_wait_sync(g, res);
return;
}
}
@@ -274,6 +274,8 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g,
uint32_t scanout_id,
struct virtio_gpu_simple_resource *res,
struct virtio_gpu_framebuffer *fb);
+void virtio_gpu_resource_wait_sync(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res);
/* virtio-gpu-3d.c */
void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,