[PATCH v4 0/7] ui/spice: Enable gl=on option for non-local or remote clients

Vivek Kasireddy posted 7 patches 7 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250515024734.758335-1-vivek.kasireddy@intel.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
There is a newer version of this series
include/ui/console.h       |   2 +
include/ui/spice-display.h |   5 +
qemu-options.hx            |  10 ++
ui/console-gl.c            |  32 ++++++
ui/egl-helpers.c           |   6 ++
ui/spice-core.c            |  27 +++++
ui/spice-display.c         | 212 ++++++++++++++++++++++++++++++++++---
7 files changed, 278 insertions(+), 16 deletions(-)
[PATCH v4 0/7] ui/spice: Enable gl=on option for non-local or remote clients
Posted by Vivek Kasireddy 7 months, 1 week ago
To address the limitation that this option is incompatible with
remote clients, this patch series adds an option to select a
preferred codec and also enable gl=on option for clients that
are connected via the network. In other words, with this option
enabled (and the below linked Spice series merged), it would be
possible to have Qemu share a dmabuf fd with Spice, which would
then forward it to a hardware or software based encoder and
eventually send the data associated with the fd to a client that
could be located on a different machine.

Essentially, this patch series provides a hardware accelerated,
opensource VDI option for users using Qemu and Spice by leveraging
the iGPU/dGPU on the host machine to encode the Guest FB via the
Gstreamer framework.

v3 -> v4 (suggestions from Marc-André):
- Add a new parameter to make max_refresh_rate configurable
- Have surface_gl_create_texture_from_fd() return bool after checking
  for errors
- Remove the check for PIXMAN_r5g6b5() in spice_gl_replace_fd_texture()
- Report errors in spice_gl_replace_fd_texture() when someting fails
- Use glGetError() correctly by adding an additional (dummy) call
  before checking for actual errors (Dmitry)
- Add a new patch to check fd values in egl_dmabuf_export_texture()
- Rebase on Qemu master

v2 -> v3:
- Check for errors after invoking glImportMemoryFdEXT() using
  glGetError() and report the error to user (Dmitry)

v1 -> v2:
- Replace the option name preferred-codec with video-codecs (Marc-André)
- Add a warning when an fd cannot be created from texture (Marc-André)
- Add a new patch to blit the scanout texture into a linear one to
  make it work with virgl
- Rebased and tested against the latest Spice master

Tested with the following Qemu parameters:
-device virtio-vga,max_outputs=1,xres=1920,yres=1080,blob=true
-spice port=3001,gl=on,disable-ticketing=on,video-codecs=gstreamer:h264

and remote-viewer --spice-debug spice://x.x.x.x:3001 on the client side.

Associated Spice server MR (merged):
https://gitlab.freedesktop.org/spice/spice/-/merge_requests/229

---
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Frediano Ziglio <freddy77@gmail.com>
Cc: Michael Scherle <michael.scherle@rz.uni-freiburg.de>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Alex Bennée <alex.bennee@linaro.org>

Vivek Kasireddy (7):
  ui/egl-helpers: Error check the fds in egl_dmabuf_export_texture()
  ui/spice: Add an option for users to provide a preferred codec
  ui/spice: Enable gl=on option for non-local or remote clients
  ui/spice: Add an option to submit gl_draw requests at fixed rate
  ui/console-gl: Add a helper to create a texture with linear memory
    layout
  ui/spice: Create a new texture with linear layout when gl=on is
    enabled
  ui/spice: Blit the scanout texture if its memory layout is not linear

 include/ui/console.h       |   2 +
 include/ui/spice-display.h |   5 +
 qemu-options.hx            |  10 ++
 ui/console-gl.c            |  32 ++++++
 ui/egl-helpers.c           |   6 ++
 ui/spice-core.c            |  27 +++++
 ui/spice-display.c         | 212 ++++++++++++++++++++++++++++++++++---
 7 files changed, 278 insertions(+), 16 deletions(-)

-- 
2.49.0


Re: [PATCH v4 0/7] ui/spice: Enable gl=on option for non-local or remote clients
Posted by Marc-André Lureau 6 months, 4 weeks ago
Hi

On Thu, May 15, 2025 at 4:49 AM Vivek Kasireddy <vivek.kasireddy@intel.com>
wrote:

> To address the limitation that this option is incompatible with
> remote clients, this patch series adds an option to select a
> preferred codec and also enable gl=on option for clients that
> are connected via the network. In other words, with this option
> enabled (and the below linked Spice series merged), it would be
> possible to have Qemu share a dmabuf fd with Spice, which would
> then forward it to a hardware or software based encoder and
> eventually send the data associated with the fd to a client that
> could be located on a different machine.
>
> Essentially, this patch series provides a hardware accelerated,
> opensource VDI option for users using Qemu and Spice by leveraging
> the iGPU/dGPU on the host machine to encode the Guest FB via the
> Gstreamer framework.
>
>
for v5, please fix the patches to pass scripts/checkpatch.pl.


> v3 -> v4 (suggestions from Marc-André):
> - Add a new parameter to make max_refresh_rate configurable
> - Have surface_gl_create_texture_from_fd() return bool after checking
>   for errors
> - Remove the check for PIXMAN_r5g6b5() in spice_gl_replace_fd_texture()
> - Report errors in spice_gl_replace_fd_texture() when someting fails
> - Use glGetError() correctly by adding an additional (dummy) call
>   before checking for actual errors (Dmitry)
> - Add a new patch to check fd values in egl_dmabuf_export_texture()
> - Rebase on Qemu master
>
> v2 -> v3:
> - Check for errors after invoking glImportMemoryFdEXT() using
>   glGetError() and report the error to user (Dmitry)
>
> v1 -> v2:
> - Replace the option name preferred-codec with video-codecs (Marc-André)
> - Add a warning when an fd cannot be created from texture (Marc-André)
> - Add a new patch to blit the scanout texture into a linear one to
>   make it work with virgl
> - Rebased and tested against the latest Spice master
>
> Tested with the following Qemu parameters:
> -device virtio-vga,max_outputs=1,xres=1920,yres=1080,blob=true
> -spice port=3001,gl=on,disable-ticketing=on,video-codecs=gstreamer:h264
>
> and remote-viewer --spice-debug spice://x.x.x.x:3001 on the client side.
>
> Associated Spice server MR (merged):
> https://gitlab.freedesktop.org/spice/spice/-/merge_requests/229
>
> ---
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> Cc: Frediano Ziglio <freddy77@gmail.com>
> Cc: Michael Scherle <michael.scherle@rz.uni-freiburg.de>
> Cc: Dongwon Kim <dongwon.kim@intel.com>
> Cc: Alex Bennée <alex.bennee@linaro.org>
>
> Vivek Kasireddy (7):
>   ui/egl-helpers: Error check the fds in egl_dmabuf_export_texture()
>   ui/spice: Add an option for users to provide a preferred codec
>   ui/spice: Enable gl=on option for non-local or remote clients
>   ui/spice: Add an option to submit gl_draw requests at fixed rate
>   ui/console-gl: Add a helper to create a texture with linear memory
>     layout
>   ui/spice: Create a new texture with linear layout when gl=on is
>     enabled
>   ui/spice: Blit the scanout texture if its memory layout is not linear
>
>  include/ui/console.h       |   2 +
>  include/ui/spice-display.h |   5 +
>  qemu-options.hx            |  10 ++
>  ui/console-gl.c            |  32 ++++++
>  ui/egl-helpers.c           |   6 ++
>  ui/spice-core.c            |  27 +++++
>  ui/spice-display.c         | 212 ++++++++++++++++++++++++++++++++++---
>  7 files changed, 278 insertions(+), 16 deletions(-)
>
> --
> 2.49.0
>
>
RE: [PATCH v4 0/7] ui/spice: Enable gl=on option for non-local or remote clients
Posted by Kasireddy, Vivek 6 months, 3 weeks ago
Hi Marc-André,

> Subject: Re: [PATCH v4 0/7] ui/spice: Enable gl=on option for non-local or
> remote clients
> 
> Hi
> 
> On Thu, May 15, 2025 at 4:49 AM Vivek Kasireddy
> <vivek.kasireddy@intel.com <mailto:vivek.kasireddy@intel.com> > wrote:
> 
> 
> 	To address the limitation that this option is incompatible with
> 	remote clients, this patch series adds an option to select a
> 	preferred codec and also enable gl=on option for clients that
> 	are connected via the network. In other words, with this option
> 	enabled (and the below linked Spice series merged), it would be
> 	possible to have Qemu share a dmabuf fd with Spice, which would
> 	then forward it to a hardware or software based encoder and
> 	eventually send the data associated with the fd to a client that
> 	could be located on a different machine.
> 
> 	Essentially, this patch series provides a hardware accelerated,
> 	opensource VDI option for users using Qemu and Spice by leveraging
> 	the iGPU/dGPU on the host machine to encode the Guest FB via the
> 	Gstreamer framework.
> 
> 
> 
> 
> for v5, please fix the patches to pass scripts/checkpatch.pl
> <http://checkpatch.pl> .
Sure, will do this and include all your suggestions in v5.

Thanks,
Vivek

> 
> 
> 
> 	v3 -> v4 (suggestions from Marc-André):
> 	- Add a new parameter to make max_refresh_rate configurable
> 	- Have surface_gl_create_texture_from_fd() return bool after checking
> 	  for errors
> 	- Remove the check for PIXMAN_r5g6b5() in
> spice_gl_replace_fd_texture()
> 	- Report errors in spice_gl_replace_fd_texture() when someting fails
> 	- Use glGetError() correctly by adding an additional (dummy) call
> 	  before checking for actual errors (Dmitry)
> 	- Add a new patch to check fd values in egl_dmabuf_export_texture()
> 	- Rebase on Qemu master
> 
> 	v2 -> v3:
> 	- Check for errors after invoking glImportMemoryFdEXT() using
> 	  glGetError() and report the error to user (Dmitry)
> 
> 	v1 -> v2:
> 	- Replace the option name preferred-codec with video-codecs (Marc-
> André)
> 	- Add a warning when an fd cannot be created from texture (Marc-
> André)
> 	- Add a new patch to blit the scanout texture into a linear one to
> 	  make it work with virgl
> 	- Rebased and tested against the latest Spice master
> 
> 	Tested with the following Qemu parameters:
> 	-device virtio-vga,max_outputs=1,xres=1920,yres=1080,blob=true
> 	-spice port=3001,gl=on,disable-ticketing=on,video-
> codecs=gstreamer:h264
> 
> 	and remote-viewer --spice-debug spice://x.x.x.x:3001 on the client side.
> 
> 	Associated Spice server MR (merged):
> 	https://gitlab.freedesktop.org/spice/spice/-/merge_requests/229
> 
> 	---
> 	Cc: Gerd Hoffmann <kraxel@redhat.com <mailto:kraxel@redhat.com>
> >
> 	Cc: Marc-André Lureau <marcandre.lureau@redhat.com
> <mailto:marcandre.lureau@redhat.com> >
> 	Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com
> <mailto:dmitry.osipenko@collabora.com> >
> 	Cc: Frediano Ziglio <freddy77@gmail.com
> <mailto:freddy77@gmail.com> >
> 	Cc: Michael Scherle <michael.scherle@rz.uni-freiburg.de
> <mailto:michael.scherle@rz.uni-freiburg.de> >
> 	Cc: Dongwon Kim <dongwon.kim@intel.com
> <mailto:dongwon.kim@intel.com> >
> 	Cc: Alex Bennée <alex.bennee@linaro.org
> <mailto:alex.bennee@linaro.org> >
> 
> 	Vivek Kasireddy (7):
> 	  ui/egl-helpers: Error check the fds in egl_dmabuf_export_texture()
> 	  ui/spice: Add an option for users to provide a preferred codec
> 	  ui/spice: Enable gl=on option for non-local or remote clients
> 	  ui/spice: Add an option to submit gl_draw requests at fixed rate
> 	  ui/console-gl: Add a helper to create a texture with linear memory
> 	    layout
> 	  ui/spice: Create a new texture with linear layout when gl=on is
> 	    enabled
> 	  ui/spice: Blit the scanout texture if its memory layout is not linear
> 
> 	 include/ui/console.h       |   2 +
> 	 include/ui/spice-display.h |   5 +
> 	 qemu-options.hx            |  10 ++
> 	 ui/console-gl.c            |  32 ++++++
> 	 ui/egl-helpers.c           |   6 ++
> 	 ui/spice-core.c            |  27 +++++
> 	 ui/spice-display.c         | 212 ++++++++++++++++++++++++++++++++++-
> --
> 	 7 files changed, 278 insertions(+), 16 deletions(-)
> 
> 	--
> 	2.49.0
> 
>