[Spice-devel] [RFC v2 2/5] display-channel: Extract the dmabuf fd from the scanout

Vivek Kasireddy vivek.kasireddy at intel.com
Mon Jan 23 08:41:20 UTC 2023


If the scanout has a valid dmabuf fd, then store a copy of it
in the drawable. This is one of the first steps needed to
share the dmabuf fd with the encoder.

Cc: Gerd Hoffmann <kraxel at redhat.com>
Cc: Marc-André Lureau <marcandre.lureau at redhat.com>
Cc: Dongwon Kim <dongwon.kim at intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
---
 server/display-channel.cpp | 9 +++++++++
 server/display-channel.h   | 1 +
 2 files changed, 10 insertions(+)

diff --git a/server/display-channel.cpp b/server/display-channel.cpp
index 4bd0cf41..9534bbf2 100644
--- a/server/display-channel.cpp
+++ b/server/display-channel.cpp
@@ -1273,6 +1273,8 @@ static Drawable *display_channel_get_drawable(DisplayChannel *display, uint8_t e
                                               red::shared_ptr<RedDrawable> &&red_drawable,
                                               uint32_t process_commands_generation)
 {
+    QXLInstance* qxl_instance = display->priv->qxl;
+    SpiceMsgDisplayGlScanoutUnix *scanout;
     Drawable *drawable;
 
     /* Validate all surface ids before updating counters
@@ -1299,6 +1301,13 @@ static Drawable *display_channel_get_drawable(DisplayChannel *display, uint8_t e
 
     drawable->red_drawable = red_drawable;
 
+    drawable->dmabuf_fd = -1;
+    scanout = red_qxl_get_gl_scanout(qxl_instance);
+    if (scanout != nullptr) {
+        drawable->dmabuf_fd = scanout->drm_dma_buf_fd;
+    }
+    red_qxl_put_gl_scanout(qxl_instance, scanout);
+
     /*
         surface->refs is affected by a drawable (that is
         dependent on the surface) as long as the drawable is alive.
diff --git a/server/display-channel.h b/server/display-channel.h
index c54df25c..276d015a 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -85,6 +85,7 @@ struct Drawable {
     std::array<RedSurface *, 3> surface_deps;
 
     uint32_t process_commands_generation;
+    int dmabuf_fd;
     DisplayChannel *display;
 };
 
-- 
2.37.2



More information about the Spice-devel mailing list