[Spice-devel] [PATCH v4 2/6] Add new spice-gl stubs API

Marc-André Lureau marcandre.lureau at gmail.com
Tue Feb 9 13:35:02 UTC 2016


- spice_gl_scanout() to take the current scanout

- spice_gl_draw_async() to draw the scanout, is like other Spice async
  functions, it takes a cookie and will return in the
  QXLInterface.async_complete()

Two new fields are also added to QXLState, in order to save the current
scanout, and the pending async.

A scanout can't be updated if there are pending draw atm. Discarding
outdated draws is left as a future improvement to allow updating the
scanout without waiting for draw async to be done.

Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
[make QXL function names more coherent - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-dispatcher.c  | 35 +++++++++++++++++++++++++++++++++++
 server/reds.c            |  1 +
 server/reds.h            |  2 ++
 server/spice-qxl.h       | 10 ++++++++++
 server/spice-server.syms |  6 ++++++
 5 files changed, 54 insertions(+)

diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 374d5a9..009c377 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -960,6 +960,41 @@ void spice_qxl_driver_unload(QXLInstance *instance)
     red_dispatcher_driver_unload(instance->st->dispatcher);
 }
 
+SPICE_GNUC_VISIBLE
+void spice_qxl_gl_scanout(QXLInstance *qxl,
+                          int fd,
+                          uint32_t width, uint32_t height,
+                          uint32_t stride, uint32_t format,
+                          int y_0_top)
+{
+    spice_return_if_fail(qxl != NULL);
+    spice_return_if_fail(qxl->st->gl_draw_async == NULL);
+
+    if (qxl->st->scanout.drm_dma_buf_fd != -1) {
+        close(qxl->st->scanout.drm_dma_buf_fd);
+    }
+
+    qxl->st->scanout = (SpiceMsgDisplayGlScanoutUnix) {
+        .flags = y_0_top ? SPICE_GL_SCANOUT_FLAGS_Y0TOP : 0,
+        .drm_dma_buf_fd = fd,
+        .width = width,
+        .height = height,
+        .stride = stride,
+        .drm_fourcc_format = format
+    };
+}
+
+SPICE_GNUC_VISIBLE
+void spice_qxl_gl_draw_async(QXLInstance *qxl,
+                             uint32_t x, uint32_t y,
+                             uint32_t w, uint32_t h,
+                             uint64_t cookie)
+{
+    spice_return_if_fail(qxl != NULL);
+    spice_return_if_fail(qxl->st->scanout.drm_dma_buf_fd != -1);
+    spice_return_if_fail(qxl->st->gl_draw_async == NULL);
+}
+
 void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
                                    AsyncCommand *async_command)
 {
diff --git a/server/reds.c b/server/reds.c
index 7ccf0f1..5f370c0 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3185,6 +3185,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
 
         qxl = SPICE_CONTAINEROF(sin, QXLInstance, base);
         qxl->st = spice_new0(QXLState, 1);
+        qxl->st->scanout.drm_dma_buf_fd = -1;
         qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
         red_dispatcher_init(qxl);
 
diff --git a/server/reds.h b/server/reds.h
index 8ff4491..3182382 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -36,6 +36,8 @@ extern RedsState *reds;
 struct QXLState {
     QXLInterface          *qif;
     struct RedDispatcher  *dispatcher;
+    SpiceMsgDisplayGlScanoutUnix scanout;
+    struct AsyncCommand *gl_draw_async;
 };
 
 struct TunnelWorker;
diff --git a/server/spice-qxl.h b/server/spice-qxl.h
index 3faa3a4..b8910bf 100644
--- a/server/spice-qxl.h
+++ b/server/spice-qxl.h
@@ -104,6 +104,16 @@ void spice_qxl_driver_unload(QXLInstance *instance);
 /* since spice 0.12.6 */
 void spice_qxl_set_max_monitors(QXLInstance *instance,
                                 unsigned int max_monitors);
+/* since spice 0.13.1 */
+void spice_qxl_gl_scanout(QXLInstance *instance,
+                          int fd,
+                          uint32_t width, uint32_t height,
+                          uint32_t stride, uint32_t format,
+                          int y_0_top);
+void spice_qxl_gl_draw_async(QXLInstance *instance,
+                             uint32_t x, uint32_t y,
+                             uint32_t w, uint32_t h,
+                             uint64_t cookie);
 
 typedef struct QXLDrawArea {
     uint8_t *buf;
diff --git a/server/spice-server.syms b/server/spice-server.syms
index 4137546..7987d51 100644
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -167,3 +167,9 @@ SPICE_SERVER_0.12.7 {
 global:
     spice_server_set_keepalive_timeout;
 } SPICE_SERVER_0.12.6;
+
+SPICE_SERVER_0.13.1 {
+global:
+    spice_qxl_gl_scanout;
+    spice_qxl_gl_draw_async;
+} SPICE_SERVER_0.12.7;
-- 
2.5.0



More information about the Spice-devel mailing list