Re: [RFC v2 0/5] gstreamer-encoder: Use a dmabuf allocator if the drawable has a valid fd (v2)

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

 



Hi Frediano,

> 
> Il giorno lun 23 gen 2023 alle ore 09:01 Vivek Kasireddy
> <vivek.kasireddy@xxxxxxxxx> ha scritto:
> >
> > This patch series enables creation of Gst memory using a dmabuf fd
> > as the source. This ability is useful given that dmabuf is the
> > standard mechanism for sharing buffers between various drivers and
> > userspace in many Graphics and Media usecases. Currently, this is
> > only used/tested with Qemu and remote-viewer using the x264enc/dec
> > codec to stream the Guest desktop but it can be extended to other
> > plugins and applications.
> >
> > Here is the flow of things from the Spice server side:
> > - The application calls gl_scanout (to update the fd) and gl_draw_async
> >   and also sets the flag to indicate whether it is dealing with a local
> >   or remote client.
> 
> That's weird, it's spice that knows the clients, not Qemu
[Kasireddy, Vivek] IIUC, in this case, both of them know the type of client
as Qemu is the one that calls spice_server_set_port() to set the port. 

> 
> > - Create a new drawable and extract the dmabuf fd from the scanout
> >   as a response to QXL_CMD_DRAW cmd sent by the application.
> 
> Mumble... There's something I don't understand here. Specifically the
> APIs used by Qemu. As far as I remember when Qemu passes a dmabuf
> scanout there should be no QXL_CMD_DRAW command... has this changed?
[Kasireddy, Vivek] No, it hasn't changed but I am trying to do just that.
Let me explain my understanding:
- In the non-dmabuf case (i.e, when gl != on), Qemu gets the FB as a chunk of
memory and therefore it creates updates and sends QXL_CMD_DRAW cmds.
In response, the Spice server creates drawables to stream (assuming we are
only talking about Gstreamer encoder here) the FB to clients.

- In the dmabuf case (i.e, gl = on and local client), Qemu does not send any
QXL_CMD_DRAW cmds and instead calls gl_scanout and gl_draw_async
APIs to share the fd. In response, the Spice server just forwards the fd to
the local client(s).

- In the dmabuf  (gl=on) + remote client(s) case that I am dealing with
(which this patch series and the associated Qemu series is trying to address),
I had to find a way to prevent the Spice server from sending the fd to remote
clients and instead have it create drawables to stream the content associated
with the dmabuf fd. Therefore, in v2, I am having Qemu send
QXL_CMD_DRAW cmds and also call gl_scanout and gl_draw_async.

> That would mean 2 copies of the frame buffer, one for dmabuf and
> another for memory version.
[Kasireddy, Vivek] Right, but if the drawable has a valid dmabuf fd, then
ideally the Spice server should not be looking at the memory version.

> 
> > - Share the drawable's copy of the fd with the Encoder.
> 
> As above, this should be already done by Qemu... unless changed.
> 
> > - Send the async completion cookie to the application once the encoder
> >   is done using the fd.
> >
> 
> This should already be there too in spice-server code, just not
> supporting the remote case.
[Kasireddy, Vivek] Right, it is already there. I am just calling 
display_channel_gl_draw_done() in the callback associated with the
freeing of Gst memory.

Thanks,
Vivek

> 
> > v2:
> > - Used the already existing gl_scanout and gl_draw_async APIs instead
> >   of adding new ones.
> > - Slightly refactored and improved the commits and their messages.
> >
> > Cc: Gerd Hoffmann <kraxel@xxxxxxxxxx>
> > Cc: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> > Cc: Dongwon Kim <dongwon.kim@xxxxxxxxx>
> >
> > Vivek Kasireddy (5):
> >   gstreamer-encoder: Use a dmabuf allocator for a valid fd
> >   display-channel: Extract the dmabuf fd from the scanout
> >   display-channel: Share the drawable's copy of fd with the encoder
> >   video-stream: Force stream creation for a valid dmabuf fd
> >   red-qxl: Add a new parameter to gl_scanout and gl_draw_async
> >
> >  meson.build                |  2 +-
> >  server/dcc-send.cpp        | 30 ++++++++++++++++++++++++
> >  server/display-channel.cpp | 23 ++++++++++++++++++
> >  server/display-channel.h   |  4 ++++
> >  server/gstreamer-encoder.c | 48
> +++++++++++++++++++++++++++++++++++---
> >  server/red-qxl.cpp         | 14 +++++++----
> >  server/spice-qxl.h         |  4 ++--
> >  server/video-encoder.h     |  7 ++++++
> >  server/video-stream.cpp    | 11 ++++++++-
> >  9 files changed, 132 insertions(+), 11 deletions(-)
> >
> > --
> > 2.37.2
> >




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