[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 20/20] virtio-gpu: Add gl_flushed callback
From: |
Vivek Kasireddy |
Subject: |
[PATCH v3 20/20] virtio-gpu: Add gl_flushed callback |
Date: |
Tue, 11 May 2021 01:08:18 -0700 |
Adding this callback provides a way to determine when the UI
has submitted the buffer to the Host windowing system. Making
the guest wait for this event will ensure that the dmabuf/buffer
updates are synchronized.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
hw/display/virtio-gpu.c | 47 +++++++++++++++++++++++++++++++++-
include/hw/virtio/virtio-gpu.h | 1 +
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 59cbc2b1df..47b3b2b244 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1016,7 +1016,8 @@ void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
break;
}
- if (!cmd->finished) {
+ if ((!cmd->finished && !(cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_FENCE)) ||
+ (cmd->finished && (cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_FENCE))) {
virtio_gpu_ctrl_response_nodata(g, cmd, cmd->error ? cmd->error :
VIRTIO_GPU_RESP_OK_NODATA);
}
@@ -1074,6 +1075,49 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
g->processing_cmdq = false;
}
+static void virtio_gpu_signal_fence(VirtIOGPU *g,
+ struct virtio_gpu_ctrl_command *cmd,
+ enum virtio_gpu_ctrl_type type)
+{
+ struct virtio_gpu_simple_resource *res;
+ struct virtio_gpu_wait_flush wf;
+
+ VIRTIO_GPU_FILL_CMD(wf);
+ virtio_gpu_bswap_32(&wf, sizeof(wf));
+
+ res = virtio_gpu_find_check_resource(g, wf.resource_id, true,
+ __func__, &cmd->error);
+ if (res && virtio_gpu_resource_has_sync(g, res)) {
+ virtio_gpu_resource_wait_sync(g, res);
+ }
+
+ virtio_gpu_ctrl_response_nodata(g, cmd, VIRTIO_GPU_RESP_OK_NODATA);
+}
+
+static void virtio_gpu_process_fenceq(VirtIOGPU *g)
+{
+ struct virtio_gpu_ctrl_command *cmd, *tmp;
+
+ QTAILQ_FOREACH_SAFE(cmd, &g->fenceq, next, tmp) {
+ trace_virtio_gpu_fence_resp(cmd->cmd_hdr.fence_id);
+ virtio_gpu_signal_fence(g, cmd, VIRTIO_GPU_RESP_OK_NODATA);
+ QTAILQ_REMOVE(&g->fenceq, cmd, next);
+
+ g_free(cmd);
+ g->inflight--;
+ if (virtio_gpu_stats_enabled(g->parent_obj.conf)) {
+ fprintf(stderr, "inflight: %3d (-)\r", g->inflight);
+ }
+ }
+}
+
+static void virtio_gpu_gl_flushed(VirtIOGPU *g)
+{
+ if (virtio_gpu_expflush_enabled(g->parent_obj.conf)) {
+ virtio_gpu_process_fenceq(g);
+ }
+}
+
static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOGPU *g = VIRTIO_GPU(vdev);
@@ -1445,6 +1489,7 @@ static void virtio_gpu_class_init(ObjectClass *klass,
void *data)
vgc->handle_ctrl = virtio_gpu_handle_ctrl;
vgc->process_cmd = virtio_gpu_simple_process_cmd;
vgc->update_cursor_data = virtio_gpu_update_cursor_data;
+ vgc->gl_flushed = virtio_gpu_gl_flushed;
vdc->realize = virtio_gpu_device_realize;
vdc->reset = virtio_gpu_reset;
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 41f74e9286..59edd6da7f 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -202,6 +202,7 @@ struct VirtIOGPUClass {
void (*update_cursor_data)(VirtIOGPU *g,
struct virtio_gpu_scanout *s,
uint32_t resource_id);
+ void (*gl_flushed)(VirtIOGPU *g);
};
struct VirtIOGPUGL {
--
2.30.2
- [PATCH v3 12/20] virtio-gpu: Add virtio_gpu_set_scanout_blob, (continued)
- [PATCH v3 12/20] virtio-gpu: Add virtio_gpu_set_scanout_blob, Vivek Kasireddy, 2021/05/11
- [PATCH v3 13/20] virtio-gpu: Update cursor data using blob, Vivek Kasireddy, 2021/05/11
- [PATCH v3 11/20] virtio-gpu: Factor out update scanout, Vivek Kasireddy, 2021/05/11
- [PATCH v3 09/20] ui/pixman: Add qemu_pixman_to_drm_format(), Vivek Kasireddy, 2021/05/11
- [PATCH v3 14/20] virtio-gpu: Add initial definitions for explict flush feature, Vivek Kasireddy, 2021/05/11
- [PATCH v3 15/20] virtio-gpu: Add dmabuf helpers for synchronization, Vivek Kasireddy, 2021/05/11
- [PATCH v3 16/20] virtio-gpu: Add virtio_gpu_wait_flush API, Vivek Kasireddy, 2021/05/11
- [PATCH v3 18/20] ui/gtk-egl: Wait for the draw signal for dmabuf blobs, Vivek Kasireddy, 2021/05/11
- [PATCH v3 17/20] ui: Add egl helpers for synchronization, Vivek Kasireddy, 2021/05/11
- [PATCH v3 19/20] ui/gtk: Create a common release_dmabuf helper, Vivek Kasireddy, 2021/05/11
- [PATCH v3 20/20] virtio-gpu: Add gl_flushed callback,
Vivek Kasireddy <=