diff mbox series

[v1,2/5] ui: Add a helper to wait on a dmabuf sync object

Message ID 20210607232530.454435-3-vivek.kasireddy@intel.com (mailing list archive)
State New, archived
Headers show
Series virtio-gpu: Add implicit (and default) sync mechanism for blobs | expand

Commit Message

Kasireddy, Vivek June 7, 2021, 11:25 p.m. UTC
This will be called by virtio-gpu in the subsequent patches.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 include/ui/console.h |  5 +++++
 ui/console.c         | 10 ++++++++++
 2 files changed, 15 insertions(+)

Comments

Gerd Hoffmann June 8, 2021, 1:57 p.m. UTC | #1
Hi,

> +    /* optional */
> +    void (*dpy_gl_wait_dmabuf)(DisplayChangeListener *dcl,
> +                               QemuDmaBuf *dmabuf);

Hmm, a blocking wait isn't the best plan here,
it'll stall the iothread.

We already have a way to stop virtio-gpu command processing:
graphic_hw_gl_block() + graphic_hw_gl_flush()

graphic_hw_gl_block(true) will block virtio-gpu command processing.
graphic_hw_gl_block(false) will unblock virtio-gpu command processing.
graphic_hw_gl_flush() will kick virtio-gpu so it resumes command processing.

I saw in patch #5 that you just do a blocking wait for the fence, which
isn't fundamentally different from what graphic_hw_gl_block does, so it
should be possible to make the gtk ui use that instead.

You'll need an async notification for the fence then.  I think you can
simply poll the fence fd.  Failing that you can either use a timer to
check the fence or do the blocking wait in a new thread.

One little detail is different with graphic_hw_gl_block:  It'll send the
completion no matter what, then stop fetching the next command from the
queue.  So that logic needs an update to also allow delaying the command
completion.

take care,
  Gerd
diff mbox series

Patch

diff --git a/include/ui/console.h b/include/ui/console.h
index b30b63976a..c3dca61c31 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -240,6 +240,9 @@  typedef struct DisplayChangeListenerOps {
     /* optional */
     void (*dpy_gl_release_dmabuf)(DisplayChangeListener *dcl,
                                   QemuDmaBuf *dmabuf);
+    /* optional */
+    void (*dpy_gl_wait_dmabuf)(DisplayChangeListener *dcl,
+                               QemuDmaBuf *dmabuf);
     /* required if GL */
     void (*dpy_gl_update)(DisplayChangeListener *dcl,
                           uint32_t x, uint32_t y, uint32_t w, uint32_t h);
@@ -312,6 +315,8 @@  void dpy_gl_cursor_position(QemuConsole *con,
                             uint32_t pos_x, uint32_t pos_y);
 void dpy_gl_release_dmabuf(QemuConsole *con,
                            QemuDmaBuf *dmabuf);
+void dpy_gl_wait_dmabuf(QemuConsole *con,
+                        QemuDmaBuf *dmabuf);
 void dpy_gl_update(QemuConsole *con,
                    uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 
diff --git a/ui/console.c b/ui/console.c
index 2de5f4105b..b0abfd2246 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1917,6 +1917,16 @@  void dpy_gl_release_dmabuf(QemuConsole *con,
     }
 }
 
+void dpy_gl_wait_dmabuf(QemuConsole *con,
+                        QemuDmaBuf *dmabuf)
+{
+    assert(con->gl);
+
+    if (con->gl->ops->dpy_gl_wait_dmabuf) {
+        con->gl->ops->dpy_gl_wait_dmabuf(con->gl, dmabuf);
+    }
+}
+
 void dpy_gl_update(QemuConsole *con,
                    uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 {