[Spice-commits] 2 commits - python_modules/demarshal.py python_modules/ptypes.py python_modules/spice_parser.py spice/enums.h spice.proto spice/protocol.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Jan 14 08:27:38 PST 2016


 python_modules/demarshal.py    |    4 ++++
 python_modules/ptypes.py       |    9 +++++++++
 python_modules/spice_parser.py |    3 ++-
 spice.proto                    |   24 ++++++++++++++++++++++++
 spice/enums.h                  |    9 +++++++++
 spice/protocol.h               |    1 +
 6 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit 3fc2221e965623c5a7e50d95f1623269a067c2d3
Author: Marc-Andre Lureau <marcandre.lureau at gmail.com>
Date:   Tue Dec 22 16:08:09 2015 +0100

    protocol: add unix GL scanout messages
    
    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() (as with the 2d canvas, the
    SPICE_MSG_DISPLAY_MONITORS_CONFIG will give the monitors
    coordinates (x/y/w/h) within the image). There can be only one scanount
    per display channel.
    
    A SPICE_MSG_DISPLAY_GL_DRAW message is sent with the coordinate of the
    region within the scanount to (re)draw on the client display. For each
    draw, once the client is done with the rendering, it must acknowldge it
    by sending a SPICE_MSGC_DISPLAY_GL_DRAW_DONE message, in order to
    release the context (it is expected to improve this in the future with a
    cross-process GL fence).
    
    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 2d canvas draw is received, the display must be switched to the
    drawn canvas. In other words, if the last message received is a GL draw
    the display should switch to the GL display, if it's a 2d draw message
    the display should be switched to the client 2d canvas.
    
    (there will probably be a stipped-down "gl-only" channel in the future,
    or support for other streaming methods, but this protocol change should
    be enough for basic virgl or other gpu-accelerated support)
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/spice.proto b/spice.proto
index 3bca900..af970f2 100644
--- a/spice.proto
+++ b/spice.proto
@@ -678,6 +678,10 @@ struct Head {
     uint32 flags;
 };
 
+flags32 gl_scanout_flags {
+    Y0TOP
+};
+
 channel DisplayChannel : BaseChannel {
  server:
     message {
@@ -915,6 +919,23 @@ channel DisplayChannel : BaseChannel {
         uint32 timeout_ms;
     } stream_activate_report;
 
+    message {
+        unix_fd drm_dma_buf_fd;
+        uint32 width;
+        uint32 height;
+        uint32 stride;
+        /* specifies the format of drm_dma_buf_fd defined in drm_fourcc.h */
+        uint32 drm_fourcc_format;
+        gl_scanout_flags flags;
+    } gl_scanout_unix;
+
+    message {
+        uint32 x;
+        uint32 y;
+        uint32 w;
+        uint32 h;
+    } gl_draw;
+
  client:
     message {
 	uint8 pixmap_cache_id;
@@ -937,6 +958,9 @@ channel DisplayChannel : BaseChannel {
     message {
         image_compression image_compression;
     } preferred_compression;
+
+    message {
+    } gl_draw_done;
 };
 
 flags16 keyboard_modifier_flags {
diff --git a/spice/enums.h b/spice/enums.h
index 16885ac..613db52 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_DRAW,
 
     SPICE_MSG_END_DISPLAY
 };
@@ -511,6 +519,7 @@ enum {
     SPICE_MSGC_DISPLAY_INIT = 101,
     SPICE_MSGC_DISPLAY_STREAM_REPORT,
     SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION,
+    SPICE_MSGC_DISPLAY_GL_DRAW_DONE,
 
     SPICE_MSGC_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 {
commit 267391c8fd7c90c067b3e4845ff0227a2580e2e2
Author: Marc-Andre Lureau <marcandre.lureau at gmail.com>
Date:   Tue Dec 22 16:08:08 2015 +0100

    protocol: learn to describe fd passing in messages
    
    Add a new type, "unix_fd", used to describe file descriptor sharing via
    socket ancillary data (these messages are local only).
    
    The marshaller/demarshaller can't serialize this in memory (consume_fd
    implementation is empty), so it is the responsability of the marshaller
    user to handle sending and receiving the handles, which are appended at
    the end of the message with an extra stream byte (because some Unix
    requires sending at least a byte with ancillary data).
    
    Even if there is no fd to send (or if the fd is invalid etc), the
    receiver side expects an extra byte anyway.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 209eafc..2252f37 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -72,6 +72,10 @@ def write_parser_helpers(writer):
             writer.statement("return val")
             writer.end_block()
 
+    writer.function("SPICE_GNUC_UNUSED consume_fd", "int", "uint8_t **ptr", True)
+    writer.statement("return -1")
+    writer.end_block()
+
     writer.newline()
     writer.statement("typedef struct PointerInfo PointerInfo")
     writer.statement("typedef void (*message_destructor_t)(uint8_t *message)")
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 7ab2771..9c10b57 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -1119,6 +1119,14 @@ class ProtocolType(Type):
 
         return self
 
+class FdType(IntegerType):
+
+    def primitive_type(self):
+        return "fd"
+
+    def c_type(self):
+        return "int"
+
 int8 = IntegerType(8, True)
 uint8 = IntegerType(8, False)
 int16 = IntegerType(16, True)
@@ -1127,3 +1135,4 @@ int32 = IntegerType(32, True)
 uint32 = IntegerType(32, False)
 int64 = IntegerType(64, True)
 uint64 = IntegerType(64, False)
+unix_fd = FdType(1, True)
diff --git a/python_modules/spice_parser.py b/python_modules/spice_parser.py
index 97af8b2..db3cc8d 100644
--- a/python_modules/spice_parser.py
+++ b/python_modules/spice_parser.py
@@ -56,6 +56,7 @@ def SPICE_BNF():
         uint32_    = Keyword("uint32").setParseAction(replaceWith(ptypes.uint32))
         int64_     = Keyword("int64").setParseAction(replaceWith(ptypes.int64))
         uint64_    = Keyword("uint64").setParseAction(replaceWith(ptypes.uint64))
+        unix_fd_   = Keyword("unix_fd").setParseAction(replaceWith(ptypes.unix_fd))
 
         # keywords
         enum32_    = Keyword("enum32").setParseAction(replaceWith(32))
@@ -108,7 +109,7 @@ def SPICE_BNF():
 
         # have to use longest match for type, in case a user-defined type name starts with a keyword type, like "channel_type"
         typeSpec << ( structSpec ^ int8_ ^ uint8_ ^ int16_ ^ uint16_ ^
-                     int32_ ^ uint32_ ^ int64_ ^ uint64_ ^
+                     int32_ ^ uint32_ ^ int64_ ^ uint64_ ^ unix_fd_ ^
                      typename).setName("type")
 
         flagsBody = enumBody = Group(lbrace + delimitedList(Group (enumname + Optional(equals + integer))) + Optional(comma) + rbrace)


More information about the Spice-commits mailing list