[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 7/8] virtio-gpu: Add dmabuf helpers for synchronization
From: |
Vivek Kasireddy |
Subject: |
[PATCH v2 7/8] virtio-gpu: Add dmabuf helpers for synchronization |
Date: |
Thu, 10 Jun 2021 15:48:36 -0700 |
These helpers will be used in the next subsequent patches to
wait until a dmabuf object (via a texture) has been used
by the UI to render and submit its buffer.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
hw/display/virtio-gpu-udmabuf.c | 28 ++++++++++++++++++++++++++++
include/hw/virtio/virtio-gpu.h | 2 ++
stubs/virtio-gpu-udmabuf.c | 6 ++++++
3 files changed, 36 insertions(+)
diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c
index 33e329e8aa..8c1b6f8763 100644
--- a/hw/display/virtio-gpu-udmabuf.c
+++ b/hw/display/virtio-gpu-udmabuf.c
@@ -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,
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index bcf54d970f..9b9b499d06 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -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,
diff --git a/stubs/virtio-gpu-udmabuf.c b/stubs/virtio-gpu-udmabuf.c
index 81f661441a..59dab1a66c 100644
--- a/stubs/virtio-gpu-udmabuf.c
+++ b/stubs/virtio-gpu-udmabuf.c
@@ -25,3 +25,9 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g,
/* nothing (stub) */
return 0;
}
+
+void virtio_gpu_resource_wait_sync(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res)
+{
+ /* nothing (stub) */
+}
--
2.30.2
- [PATCH v2 0/8] virtio-gpu: Add a default synchronization mechanism for blobs, Vivek Kasireddy, 2021/06/10
- [PATCH v2 1/8] ui/gtk: Create a common release_dmabuf helper, Vivek Kasireddy, 2021/06/10
- [PATCH v2 3/8] ui: Add a helper to wait on a dmabuf sync object, Vivek Kasireddy, 2021/06/10
- [PATCH v2 2/8] ui/egl: Add egl helpers to help with synchronization, Vivek Kasireddy, 2021/06/10
- [PATCH v2 4/8] ui/gtk: Implement wait_dmabuf function, Vivek Kasireddy, 2021/06/10
- [PATCH v2 6/8] ui/gtk-egl: Wait for the draw signal for dmabuf blobs, Vivek Kasireddy, 2021/06/10
- [PATCH v2 5/8] ui: Create sync objects only for blobs, Vivek Kasireddy, 2021/06/10
- [PATCH v2 7/8] virtio-gpu: Add dmabuf helpers for synchronization,
Vivek Kasireddy <=
- [PATCH v2 8/8] virtio-gpu: Add gl_flushed callback, Vivek Kasireddy, 2021/06/10
- Re: [PATCH v2 0/8] virtio-gpu: Add a default synchronization mechanism for blobs, no-reply, 2021/06/14