From: Vivek Kasireddy <vivek.kasireddy@intel.com>
To: qemu-devel@nongnu.org
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH v3 15/20] virtio-gpu: Add dmabuf helpers for synchronization
Date: Tue, 11 May 2021 01:08:13 -0700 [thread overview]
Message-ID: <20210511080818.366985-16-vivek.kasireddy@intel.com> (raw)
In-Reply-To: <20210511080818.366985-1-vivek.kasireddy@intel.com>
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 | 42 +++++++++++++++++++++++++++++++++
include/hw/virtio/virtio-gpu.h | 4 ++++
include/ui/console.h | 6 +++++
ui/console.c | 10 ++++++++
4 files changed, 62 insertions(+)
diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c
index a9cb83d686..57bddd4d01 100644
--- a/hw/display/virtio-gpu-udmabuf.c
+++ b/hw/display/virtio-gpu-udmabuf.c
@@ -178,6 +178,47 @@ 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) {
+ scanout = &g->parent_obj.scanout[dmabuf->scanout_id];
+ dpy_gl_wait_dmabuf(scanout->con, &dmabuf->buf);
+ }
+}
+
+bool virtio_gpu_resource_has_sync(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res)
+{
+ VGPUDMABuf *dmabuf;
+
+ dmabuf = virtio_gpu_find_dmabuf(g, res);
+ if (dmabuf && dmabuf->buf.sync) {
+ return true;
+ }
+
+ return false;
+}
+
static VGPUDMABuf
*virtio_gpu_create_dmabuf(VirtIOGPU *g,
uint32_t scanout_id,
@@ -196,6 +237,7 @@ static VGPUDMABuf
dmabuf->buf.stride = fb->stride;
dmabuf->buf.fourcc = qemu_pixman_to_drm_format(fb->format);
dmabuf->buf.fd = res->dmabuf_fd;
+ dmabuf->buf.sync = NULL;
dmabuf->scanout_id = scanout_id;
QTAILQ_INSERT_HEAD(&g->dmabuf.bufs, dmabuf, next);
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 4a827454f5..41f74e9286 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -277,6 +277,10 @@ 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);
+bool virtio_gpu_resource_has_sync(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res);
/* virtio-gpu-3d.c */
void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
diff --git a/include/ui/console.h b/include/ui/console.h
index b30b63976a..3b0e377923 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -168,6 +168,7 @@ typedef struct QemuDmaBuf {
uint64_t modifier;
uint32_t texture;
bool y0_top;
+ void *sync;
} QemuDmaBuf;
typedef struct DisplayState DisplayState;
@@ -240,6 +241,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 +316,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)
{
--
2.30.2
next prev parent reply other threads:[~2021-05-11 8:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 8:07 [PATCH v3 00/20] virtio-gpu: Add support for Blob resources Vivek Kasireddy
2021-05-11 8:07 ` [PATCH v3 01/20] ui: Get the fd associated with udmabuf driver Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 02/20] headers: Add udmabuf.h Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 03/20] virtio-gpu: Add udmabuf helpers Vivek Kasireddy
2021-05-11 11:22 ` Gerd Hoffmann
2021-05-11 8:08 ` [PATCH v3 04/20] virtio-gpu: Add virtio_gpu_find_check_resource Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 05/20] virtio-gpu: Refactor virtio_gpu_set_scanout Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 06/20] virtio-gpu: Refactor virtio_gpu_create_mapping_iov Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 07/20] virtio-gpu: Add initial definitions for blob resources Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 08/20] virtio-gpu: Add virtio_gpu_resource_create_blob Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 09/20] ui/pixman: Add qemu_pixman_to_drm_format() Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 10/20] virtio-gpu: Add helpers to create and destroy dmabuf objects Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 11/20] virtio-gpu: Factor out update scanout Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 12/20] virtio-gpu: Add virtio_gpu_set_scanout_blob Vivek Kasireddy
2021-05-11 11:39 ` Gerd Hoffmann
2021-05-11 22:42 ` Kasireddy, Vivek
2021-05-11 8:08 ` [PATCH v3 13/20] virtio-gpu: Update cursor data using blob Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 14/20] virtio-gpu: Add initial definitions for explict flush feature Vivek Kasireddy
2021-05-11 11:42 ` Gerd Hoffmann
2021-05-11 8:08 ` Vivek Kasireddy [this message]
2021-05-11 8:08 ` [PATCH v3 16/20] virtio-gpu: Add virtio_gpu_wait_flush API Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 17/20] ui: Add egl helpers for synchronization Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 18/20] ui/gtk-egl: Wait for the draw signal for dmabuf blobs Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 19/20] ui/gtk: Create a common release_dmabuf helper Vivek Kasireddy
2021-05-11 8:08 ` [PATCH v3 20/20] virtio-gpu: Add gl_flushed callback Vivek Kasireddy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210511080818.366985-16-vivek.kasireddy@intel.com \
--to=vivek.kasireddy@intel.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).