[PATCH spice-protocol 2/2] Add unix GL scanout messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add 2 new messages to the display channel to stream pre-rendered GL
images of the display. This is only possible when the client supports
SPICE_DISPLAY_CAP_GL_SCANOUT capability.

The first message, SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX, sends a gl image
file handle via socket ancillary data, and can be imported in a GL
context with the help of eglCreateImageKHR(). The next
SPICE_MSG_DISPLAY_MONITORS_CONFIG will give the monitor
coordinates (x/y/w/h) within the image.

When the image is updated, either a new image replaces the current image
or a SPICE_MSG_DISPLAY_GL_SCANOUT_UPDATE message is sent with the
coordinate of the updated region.

The relation with the existing display channel messages is that all
other messages are unchanged, the last drawing command received must be
displayed, however the scanout display is all or nothing. Consequently,
if a draw is received, the display must be switched to the drawn
display. In other words, if the last message received is a GL scanout
the display should switch to the GL scanout image, if it's a draw
message the display should be switched to the client rendered canvas.

There will probably be a "gl-only" channel in the future, without all
the 2d drawing commands, and with support for other streaming methods,
but for now this is enough for experimenting with virgl and other
gpu-accelerated solutions.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 spice.proto      | 22 +++++++++++++++++++++-
 spice/enums.h    |  8 ++++++++
 spice/protocol.h |  1 +
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/spice.proto b/spice.proto
index 3bca900..b41a7fb 100644
--- a/spice.proto
+++ b/spice.proto
@@ -678,6 +678,10 @@ struct Head {
     uint32 flags;
 };
 
+flags8 gl_scanout_flags {
+    Y0TOP
+};
+
 channel DisplayChannel : BaseChannel {
  server:
     message {
@@ -915,7 +919,23 @@ channel DisplayChannel : BaseChannel {
         uint32 timeout_ms;
     } stream_activate_report;
 
- client:
+    message {
+        unix_fd fd;
+        uint32 width;
+        uint32 height;
+        uint32 stride;
+        uint32 format; /* drm fourcc */
+        gl_scanout_flags flags;
+    } gl_scanout_unix;
+
+    message {
+        uint32 x;
+        uint32 y;
+        uint32 w;
+        uint32 h;
+    } gl_scanout_update;
+
+client:
     message {
 	uint8 pixmap_cache_id;
 	int64 pixmap_cache_size; //in pixels
diff --git a/spice/enums.h b/spice/enums.h
index 16885ac..0b25b58 100644
--- a/spice/enums.h
+++ b/spice/enums.h
@@ -303,6 +303,12 @@ typedef enum SpiceResourceType {
     SPICE_RESOURCE_TYPE_ENUM_END
 } SpiceResourceType;
 
+typedef enum SpiceGlScanoutFlags {
+    SPICE_GL_SCANOUT_FLAGS_Y0TOP = (1 << 0),
+
+    SPICE_GL_SCANOUT_FLAGS_MASK = 0x1
+} SpiceGlScanoutFlags;
+
 typedef enum SpiceKeyboardModifierFlags {
     SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK = (1 << 0),
     SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK = (1 << 1),
@@ -503,6 +509,8 @@ enum {
     SPICE_MSG_DISPLAY_MONITORS_CONFIG,
     SPICE_MSG_DISPLAY_DRAW_COMPOSITE,
     SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT,
+    SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX,
+    SPICE_MSG_DISPLAY_GL_SCANOUT_UPDATE,
 
     SPICE_MSG_END_DISPLAY
 };
diff --git a/spice/protocol.h b/spice/protocol.h
index 0c265ee..3e6c624 100644
--- a/spice/protocol.h
+++ b/spice/protocol.h
@@ -136,6 +136,7 @@ enum {
     SPICE_DISPLAY_CAP_STREAM_REPORT,
     SPICE_DISPLAY_CAP_LZ4_COMPRESSION,
     SPICE_DISPLAY_CAP_PREF_COMPRESSION,
+    SPICE_DISPLAY_CAP_GL_SCANOUT,
 };
 
 enum {
-- 
2.5.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]