diff mbox series

[v7,4/8] package/virglrenderer: new package

Message ID 20260515-virglrenderer-v7-4-1f1814b65ccd@gmail.com
State Changes Requested
Headers show
Series Add virglrenderer support | expand

Commit Message

Joseph Kogut May 16, 2026, 2:03 a.m. UTC
Add virglrenderer, an optional dependency of QEMU, which facilitates
acceleration of rendering and optionally video decode through
virtio-gpu.

Signed-off-by: Joseph Kogut <joseph.kogut@gmail.com>
---
 DEVELOPERS                               |   1 +
 package/Config.in                        |   1 +
 package/virglrenderer/Config.in          | 117 +++++++++++++++++++++++++++++++
 package/virglrenderer/virglrenderer.hash |   5 ++
 package/virglrenderer/virglrenderer.mk   |  60 ++++++++++++++++
 5 files changed, 184 insertions(+)

Comments

Arnout Vandecappelle May 21, 2026, 8:08 p.m. UTC | #1
On 16/05/2026 04:03, Joseph Kogut wrote:
> Add virglrenderer, an optional dependency of QEMU, which facilitates
> acceleration of rendering and optionally video decode through
> virtio-gpu.

  I'm not entirely sure how this works. Do you just have the driver for the 
host's hardware in your guest OS? So e.g. you have ti-sgx-um and virglrenderer 
in your guest OS, and voila, you get acceleration?

  Or is virglrender just the library that you have to link into qemu to enable 
this feature to begin with? What do you need in the guest then to be able to 
make use of it? Do you need the same driver in the host and the guest? What if 
they have different versions? Or can you have e.g. etnaviv in the host and 
vivante in the guest?

  Or maybe on the host you don't need anything other than virglrenderer, and the 
actual driver is purely in the guest? If that's the case, all the "default y if 
..." in this commit are incorrect.

  I looked at the test, but it doesn't help much because the test uses the same 
kernel/rootfs for the host and the guest...


  I have quite a few comments to this patch. In some cases, I expect that what 
you wrote is actually good but I misunderstood things. It would be good to add 
more explanation in the commit message about such situations.

> 
> Signed-off-by: Joseph Kogut <joseph.kogut@gmail.com>
> ---
>   DEVELOPERS                               |   1 +
>   package/Config.in                        |   1 +
>   package/virglrenderer/Config.in          | 117 +++++++++++++++++++++++++++++++
>   package/virglrenderer/virglrenderer.hash |   5 ++
>   package/virglrenderer/virglrenderer.mk   |  60 ++++++++++++++++
>   5 files changed, 184 insertions(+)
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 25a047cb3e..774eb0b746 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1765,6 +1765,7 @@ F:	package/python-xlib/
>   F:	package/sentry-cli/
>   F:	package/sentry-native/
>   F:	package/unclutter-xfixes/
> +F:	package/virglrenderer/
>   
>   N:	Joshua Henderson <joshua.henderson@microchip.com>
>   F:	package/qt5/qt5wayland/
> diff --git a/package/Config.in b/package/Config.in
> index 9cae377fb5..01263e4c44 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -365,6 +365,7 @@ comment "Graphic libraries"
>   	source "package/sdl2_ttf/Config.in"
>   	source "package/spirv-headers/Config.in"
>   	source "package/tk/Config.in"
> +	source "package/virglrenderer/Config.in"
>   	source "package/vulkan-headers/Config.in"
>   	source "package/vulkan-loader/Config.in"
>   	source "package/vulkan-sdk/Config.in"
> diff --git a/package/virglrenderer/Config.in b/package/virglrenderer/Config.in
> new file mode 100644
> index 0000000000..041bb63a1c
> --- /dev/null
> +++ b/package/virglrenderer/Config.in
> @@ -0,0 +1,117 @@
> +config BR2_PACKAGE_VIRGLRENDERER
> +	bool "virglrenderer"
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9

  We usually have a comment here why it needs GCC 4.9 - typically a minimal C++ 
standard version, or C11.

> +	depends on BR2_TOOLCHAIN_HAS_THREADS
> +	depends on BR2_USE_MMU # fork()
> +	select BR2_PACKAGE_LIBEPOXY
> +	help
> +	  A library for accelerated graphics and compute in
> +	  virtualized guests.
> +
> +	  virglrenderer can be built without virgl, venus, or DRM

  I wouldn't enumerate all the backends here but just say "can be built without 
any backend".

> +	  backends, although such a build will not provide guest
> +	  graphics or compute acceleration by itself.
> +
> +	  https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer
> +
> +if BR2_PACKAGE_VIRGLRENDERER
> +comment "virglrenderer needs virgl, venus, or a DRM backend for guest acceleration"

  We don't normally put such comments that are just a hint for people who don't 
want to read the help text.

> +	depends on !BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +
> +config BR2_PACKAGE_VIRGLRENDERER_VIRGL
> +	bool "virgl"
> +	default y
> +	depends on (BR2_PACKAGE_HAS_LIBEGL && BR2_PACKAGE_HAS_LIBGBM) \
> +		|| BR2_PACKAGE_HAS_LIBGL
> +	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +	help
> +	  Enable API-level OpenGL acceleration over virtio-gpu.
> +
> +	  Say 'y' if you want to run applications with OpenGL
> +	  acceleration in virtualized guests. Requires host
> +	  support for OpenGL.

  We don't use the "Say 'y'" formulation. I also don't know what "virtualized 
guests" means - guests are always virtualized, right? And "Requires" may sound 
like a build-time dependency on the build system. So I'd just make the help text 
"Enable API-level OpenGL acceleration over virtio-gpu. Requires the 
virtualization host to support OpenGL." Similarly for the other help texts.

> +	  https://docs.mesa3d.org/drivers/virgl.html
> +
> +comment "virgl needs OpenGL or OpenGL EGL and libgbm"
> +	depends on !((BR2_PACKAGE_HAS_LIBEGL && BR2_PACKAGE_HAS_LIBGBM) \
> +		|| BR2_PACKAGE_HAS_LIBGL)
> +
> +config BR2_PACKAGE_VIRGLRENDERER_VENUS
> +	bool "venus"
> +	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER

  I don't understand this default y. Is it just that there's no other way to 
know if the hardware supports Vulkan?

> +	depends on BR2_INSTALL_LIBSTDCPP # vulkan-loader
> +	depends on !BR2_STATIC_LIBS # vulkan-loader
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # vulkan-loader
> +	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +	select BR2_PACKAGE_VULKAN_HEADERS
> +	select BR2_PACKAGE_VULKAN_LOADER
> +	help
> +	  Enable API-level Vulkan acceleration over virtio-gpu.
> +
> +	  Say 'y' if you want to run applications with Vulkan
> +	  acceleration in virtualized guests. Requires host
> +	  support for Vulkan.
> +
> +	  https://docs.mesa3d.org/drivers/venus.html
> +
> +config BR2_PACKAGE_VIRGLRENDERER_VAAPI
> +	bool "vaapi support"

  I would move this either to the beginning or the end to separate it from the 
backends. E.g.

comment "Virtio backends"

...

comment "DRM backends"

...

comment "Other options"

bool "vaapi support"


> +	depends on BR2_PACKAGE_LIBGBM_HAS_FEATURE_DMA_BUF
> +	select BR2_PACKAGE_LIBDRM
> +	select BR2_PACKAGE_LIBVA
> +	help
> +	  Enable hardware accelerated video encode/decode through
> +	  libva over virtio-gpu.
> +
> +comment "DRM backends"

  Not sure what is the distinction between virtio and DRM backends, but I don't 
suppose I really need to know :-)

> +
> +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_AMDGPU
> +	bool "amdgpu"
> +	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_RADEONSI
> +	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_AMD
> +	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +	select BR2_PACKAGE_LIBDRM
> +	select BR2_PACKAGE_LIBDRM_AMDGPU
> +	help
> +	  Enable DRM backend for amdgpu, used by Gallium radeonsi
> +	  and RADV vulkan drivers.
> +
> +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_INTEL
> +	bool "intel"
> +	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_I915
> +	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS
> +	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_INTEL
> +	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +	select BR2_PACKAGE_LIBDRM
> +	help
> +	  Enable DRM backend for i915, used by Gallium i915/Iris
> +	  and Intel vulkan drivers.
> +
> +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_MSM
> +	bool "msm"
> +	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_FREEDRENO
> +	depends on !BR2_arm
> +	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +	select BR2_PACKAGE_LIBDRM
> +	help
> +	  Enable DRM backend for msm, used by Gallium freedreno
> +	  driver.
> +
> +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_PANFROST
> +	bool "panfrost"
> +	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST
> +	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_PANFROST
> +	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +	select BR2_PACKAGE_LIBDRM
> +	help
> +	  Enable DRM backend for Panfrost, used by the panfrost
> +	  Gallium/vulkan drivers.
> +
> +endif
> +
> +comment "virglrenderer needs a toolchain w/ gcc >= 4.9"
> +	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
> +
> +config BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> +	bool
> diff --git a/package/virglrenderer/virglrenderer.hash b/package/virglrenderer/virglrenderer.hash
> new file mode 100644
> index 0000000000..03da595091
> --- /dev/null
> +++ b/package/virglrenderer/virglrenderer.hash
> @@ -0,0 +1,5 @@
> +# Locally calculated
> +sha256  065bc56e89e6f631f96101cd62eba0748e48eb888b434edc86e89d05395e76f3  virglrenderer-1.3.0.tar.gz
> +
> +# License
> +sha256  3b32caf16e2402c2aff2b716858713f3e1feded85c25e71bf829816ee5009402  COPYING
> diff --git a/package/virglrenderer/virglrenderer.mk b/package/virglrenderer/virglrenderer.mk
> new file mode 100644
> index 0000000000..4e7bcbb849
> --- /dev/null
> +++ b/package/virglrenderer/virglrenderer.mk
> @@ -0,0 +1,60 @@
> +################################################################################
> +#
> +# virglrenderer
> +#
> +################################################################################
> +
> +VIRGLRENDERER_VERSION = 1.3.0
> +VIRGLRENDERER_SITE = https://gitlab.freedesktop.org/virgl/virglrenderer/-/archive/$(VIRGLRENDERER_VERSION)
> +VIRGLRENDERER_LICENSE = MIT
> +VIRGLRENDERER_LICENSE_FILES = COPYING
> +VIRGLRENDERER_INSTALL_STAGING = YES
> +VIRGLRENDERER_DEPENDENCIES = \
> +	libepoxy \
> +	host-pkgconf \
> +	host-python3 \
> +	host-python-pyyaml
> +VIRGLRENDERER_CPE_ID_VALID = YES
> +
> +ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VIRGL),y)
> +ifeq ($(BR2_PACKAGE_HAS_LIBEGL)$(BR2_PACKAGE_HAS_LIBGBM),yy)
> +VIRGLRENDERER_PLATFORMS += egl
> +VIRGLRENDERER_DEPENDENCIES += libegl \
> +			      libgbm

  The indentation is a bit wonky here. Either put it all on a single line, or 
put the values on separate lines indented with a single tab (so 3 lines total).

  Regards,
  Arnout


> +endif
> +
> +ifeq ($(BR2_PACKAGE_HAS_LIBGL),y)
> +VIRGLRENDERER_PLATFORMS += glx
> +VIRGLRENDERER_DEPENDENCIES += libgl
> +endif
> +endif # BR2_PACKAGE_VIRGLRENDERER_VIRGL
> +
> +VIRGLRENDERER_CONF_OPTS += -Dplatforms=$(subst $(space),$(comma),$(VIRGLRENDERER_PLATFORMS))
> +
> +ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VENUS),y)
> +VIRGLRENDERER_CONF_OPTS += -Dvenus=true
> +VIRGLRENDERER_DEPENDENCIES += vulkan-headers \
> +			      vulkan-loader
> +else
> +VIRGLRENDERER_CONF_OPTS += -Dvenus=false
> +endif
> +
> +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_AMDGPU) += amdgpu-experimental
> +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_INTEL) += i915-experimental
> +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_MSM) += msm
> +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_PANFROST) += panfrost-experimental
> +
> +VIRGLRENDERER_CONF_OPTS += -Ddrm-renderers=$(subst $(space),$(comma),$(VIRGLRENDERER_DRM_BACKENDS-y))
> +
> +ifneq ($(VIRGLRENDERER_DRM_BACKENDS-y),)
> +VIRGLRENDERER_DEPENDENCIES += libdrm
> +endif
> +
> +ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VAAPI),y)
> +VIRGLRENDERER_CONF_OPTS += -Dvideo=true
> +VIRGLRENDERER_DEPENDENCIES += libva libdrm
> +else
> +VIRGLRENDERER_CONF_OPTS += -Dvideo=false
> +endif
> +
> +$(eval $(meson-package))
>
Joseph Kogut June 7, 2026, 8:42 p.m. UTC | #2
Hello Arnout,

Looks like I missed this message earlier while I was at Open Source
Summit NA, so I'm following up now while I'm preparing the next
version of this patch series. I think we've already covered some of
this, but I'll respond inline anyway for posterity.

On Thu, May 21, 2026 at 1:08 PM Arnout Vandecappelle <arnout@rnout.be> wrote:
>
>
>
> On 16/05/2026 04:03, Joseph Kogut wrote:
> > Add virglrenderer, an optional dependency of QEMU, which facilitates
> > acceleration of rendering and optionally video decode through
> > virtio-gpu.
>
>   I'm not entirely sure how this works. Do you just have the driver for the
> host's hardware in your guest OS? So e.g. you have ti-sgx-um and virglrenderer
> in your guest OS, and voila, you get acceleration?
>

Basically yes, but not just any driver. For the moment, the only
supported DRM backends are Mesa drivers. This is because modifying the
UMD to submit DRM commands over virtio-gpu is required. Virglrenderer
receives these commands on the host and submits them to the actual
device node.

>   Or is virglrender just the library that you have to link into qemu to enable
> this feature to begin with? What do you need in the guest then to be able to
> make use of it? Do you need the same driver in the host and the guest? What if
> they have different versions? Or can you have e.g. etnaviv in the host and
> vivante in the guest?
>

In the guest, you need mesa with the virtio-gpu UMD for VirGL or
Venus. VirGL requires host support for OpenGL, and venus requires host
support for Vulkan.

For lower overhead and arguably better security, you can use the
native UMD (e.g. radeonsi, freedreno) in the guest with host native
context, but this requires both Mesa and virglrenderer to have this
enabled.

>   Or maybe on the host you don't need anything other than virglrenderer, and the
> actual driver is purely in the guest? If that's the case, all the "default y if
> ..." in this commit are incorrect.
>

The virglrenderer DRM backends only require the corresponding DRM KMD
loaded on the host at runtime. If you're using a DRM backend and
running the native UMD inside a guest, you can get accelerated
render/compute in the guest without any UMD on the host.

In practice, many users will probably also have a graphics stack (UMD)
on the host, because they'll want an accelerated pipeline for
presenting rendered frames from guests. In this case, enabling e.g.
radeonsi or radv in the host Mesa build implies that the host has the
amdgpu KMD (and the hardware to use it), so we can safely enable the
amdgpu backend for virglrenderer. This enables guests to use
radeonsi/radv directly.

>   I looked at the test, but it doesn't help much because the test uses the same
> kernel/rootfs for the host and the guest...
>

I was hoping to avoid building two kernels/rootfses for expediency,
but I see how this would illustrate the setup poorly.

>   I have quite a few comments to this patch. In some cases, I expect that what
> you wrote is actually good but I misunderstood things. It would be good to add
> more explanation in the commit message about such situations.
>
> >
> > Signed-off-by: Joseph Kogut <joseph.kogut@gmail.com>
> > ---
> >   DEVELOPERS                               |   1 +
> >   package/Config.in                        |   1 +
> >   package/virglrenderer/Config.in          | 117 +++++++++++++++++++++++++++++++
> >   package/virglrenderer/virglrenderer.hash |   5 ++
> >   package/virglrenderer/virglrenderer.mk   |  60 ++++++++++++++++
> >   5 files changed, 184 insertions(+)
> >
> > diff --git a/DEVELOPERS b/DEVELOPERS
> > index 25a047cb3e..774eb0b746 100644
> > --- a/DEVELOPERS
> > +++ b/DEVELOPERS
> > @@ -1765,6 +1765,7 @@ F:      package/python-xlib/
> >   F:  package/sentry-cli/
> >   F:  package/sentry-native/
> >   F:  package/unclutter-xfixes/
> > +F:   package/virglrenderer/
> >
> >   N:  Joshua Henderson <joshua.henderson@microchip.com>
> >   F:  package/qt5/qt5wayland/
> > diff --git a/package/Config.in b/package/Config.in
> > index 9cae377fb5..01263e4c44 100644
> > --- a/package/Config.in
> > +++ b/package/Config.in
> > @@ -365,6 +365,7 @@ comment "Graphic libraries"
> >       source "package/sdl2_ttf/Config.in"
> >       source "package/spirv-headers/Config.in"
> >       source "package/tk/Config.in"
> > +     source "package/virglrenderer/Config.in"
> >       source "package/vulkan-headers/Config.in"
> >       source "package/vulkan-loader/Config.in"
> >       source "package/vulkan-sdk/Config.in"
> > diff --git a/package/virglrenderer/Config.in b/package/virglrenderer/Config.in
> > new file mode 100644
> > index 0000000000..041bb63a1c
> > --- /dev/null
> > +++ b/package/virglrenderer/Config.in
> > @@ -0,0 +1,117 @@
> > +config BR2_PACKAGE_VIRGLRENDERER
> > +     bool "virglrenderer"
> > +     depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
>
>   We usually have a comment here why it needs GCC 4.9 - typically a minimal C++
> standard version, or C11.
>

Agreed, I'll look into this again and add a comment.

> > +     depends on BR2_TOOLCHAIN_HAS_THREADS
> > +     depends on BR2_USE_MMU # fork()
> > +     select BR2_PACKAGE_LIBEPOXY
> > +     help
> > +       A library for accelerated graphics and compute in
> > +       virtualized guests.
> > +
> > +       virglrenderer can be built without virgl, venus, or DRM
>
>   I wouldn't enumerate all the backends here but just say "can be built without
> any backend".
>

+1

> > +       backends, although such a build will not provide guest
> > +       graphics or compute acceleration by itself.
> > +
> > +       https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer
> > +
> > +if BR2_PACKAGE_VIRGLRENDERER
> > +comment "virglrenderer needs virgl, venus, or a DRM backend for guest acceleration"
>
>   We don't normally put such comments that are just a hint for people who don't
> want to read the help text.
>
> > +     depends on !BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_VIRGL
> > +     bool "virgl"
> > +     default y
> > +     depends on (BR2_PACKAGE_HAS_LIBEGL && BR2_PACKAGE_HAS_LIBGBM) \
> > +             || BR2_PACKAGE_HAS_LIBGL
> > +     select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +     help
> > +       Enable API-level OpenGL acceleration over virtio-gpu.
> > +
> > +       Say 'y' if you want to run applications with OpenGL
> > +       acceleration in virtualized guests. Requires host
> > +       support for OpenGL.
>
>   We don't use the "Say 'y'" formulation. I also don't know what "virtualized
> guests" means - guests are always virtualized, right? And "Requires" may sound
> like a build-time dependency on the build system. So I'd just make the help text
> "Enable API-level OpenGL acceleration over virtio-gpu. Requires the
> virtualization host to support OpenGL." Similarly for the other help texts.
>

Yep, I think that's clearer.

> > +       https://docs.mesa3d.org/drivers/virgl.html
> > +
> > +comment "virgl needs OpenGL or OpenGL EGL and libgbm"
> > +     depends on !((BR2_PACKAGE_HAS_LIBEGL && BR2_PACKAGE_HAS_LIBGBM) \
> > +             || BR2_PACKAGE_HAS_LIBGL)
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_VENUS
> > +     bool "venus"
> > +     default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER
>
>   I don't understand this default y. Is it just that there's no other way to
> know if the hardware supports Vulkan?
>

As above, Venus requires Vulkan support on the host. It makes sense to
enable virglrenderer support when we know we have it, even though this
isn't the only Vulkan provider. If somebody is using, for example, the
proprietary Nvidia vulkan driver, they can explicitly select this
config to enable Venus support.

> > +     depends on BR2_INSTALL_LIBSTDCPP # vulkan-loader
> > +     depends on !BR2_STATIC_LIBS # vulkan-loader
> > +     depends on BR2_TOOLCHAIN_HAS_THREADS # vulkan-loader
> > +     select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +     select BR2_PACKAGE_VULKAN_HEADERS
> > +     select BR2_PACKAGE_VULKAN_LOADER
> > +     help
> > +       Enable API-level Vulkan acceleration over virtio-gpu.
> > +
> > +       Say 'y' if you want to run applications with Vulkan
> > +       acceleration in virtualized guests. Requires host
> > +       support for Vulkan.
> > +
> > +       https://docs.mesa3d.org/drivers/venus.html
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_VAAPI
> > +     bool "vaapi support"
>
>   I would move this either to the beginning or the end to separate it from the
> backends. E.g.
>
> comment "Virtio backends"
>
> ...
>
> comment "DRM backends"
>
> ...
>
> comment "Other options"
>
> bool "vaapi support"
>
>

+1

> > +     depends on BR2_PACKAGE_LIBGBM_HAS_FEATURE_DMA_BUF
> > +     select BR2_PACKAGE_LIBDRM
> > +     select BR2_PACKAGE_LIBVA
> > +     help
> > +       Enable hardware accelerated video encode/decode through
> > +       libva over virtio-gpu.
> > +
> > +comment "DRM backends"
>
>   Not sure what is the distinction between virtio and DRM backends, but I don't
> suppose I really need to know :-)
>
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_AMDGPU
> > +     bool "amdgpu"
> > +     default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_RADEONSI
> > +     default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_AMD
> > +     select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +     select BR2_PACKAGE_LIBDRM
> > +     select BR2_PACKAGE_LIBDRM_AMDGPU
> > +     help
> > +       Enable DRM backend for amdgpu, used by Gallium radeonsi
> > +       and RADV vulkan drivers.
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_INTEL
> > +     bool "intel"
> > +     default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_I915
> > +     default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS
> > +     default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_INTEL
> > +     select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +     select BR2_PACKAGE_LIBDRM
> > +     help
> > +       Enable DRM backend for i915, used by Gallium i915/Iris
> > +       and Intel vulkan drivers.
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_MSM
> > +     bool "msm"
> > +     default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_FREEDRENO
> > +     depends on !BR2_arm
> > +     select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +     select BR2_PACKAGE_LIBDRM
> > +     help
> > +       Enable DRM backend for msm, used by Gallium freedreno
> > +       driver.
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_PANFROST
> > +     bool "panfrost"
> > +     default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST
> > +     default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_PANFROST
> > +     select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +     select BR2_PACKAGE_LIBDRM
> > +     help
> > +       Enable DRM backend for Panfrost, used by the panfrost
> > +       Gallium/vulkan drivers.
> > +
> > +endif
> > +
> > +comment "virglrenderer needs a toolchain w/ gcc >= 4.9"
> > +     depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
> > +
> > +config BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
> > +     bool
> > diff --git a/package/virglrenderer/virglrenderer.hash b/package/virglrenderer/virglrenderer.hash
> > new file mode 100644
> > index 0000000000..03da595091
> > --- /dev/null
> > +++ b/package/virglrenderer/virglrenderer.hash
> > @@ -0,0 +1,5 @@
> > +# Locally calculated
> > +sha256  065bc56e89e6f631f96101cd62eba0748e48eb888b434edc86e89d05395e76f3  virglrenderer-1.3.0.tar.gz
> > +
> > +# License
> > +sha256  3b32caf16e2402c2aff2b716858713f3e1feded85c25e71bf829816ee5009402  COPYING
> > diff --git a/package/virglrenderer/virglrenderer.mk b/package/virglrenderer/virglrenderer.mk
> > new file mode 100644
> > index 0000000000..4e7bcbb849
> > --- /dev/null
> > +++ b/package/virglrenderer/virglrenderer.mk
> > @@ -0,0 +1,60 @@
> > +################################################################################
> > +#
> > +# virglrenderer
> > +#
> > +################################################################################
> > +
> > +VIRGLRENDERER_VERSION = 1.3.0
> > +VIRGLRENDERER_SITE = https://gitlab.freedesktop.org/virgl/virglrenderer/-/archive/$(VIRGLRENDERER_VERSION)
> > +VIRGLRENDERER_LICENSE = MIT
> > +VIRGLRENDERER_LICENSE_FILES = COPYING
> > +VIRGLRENDERER_INSTALL_STAGING = YES
> > +VIRGLRENDERER_DEPENDENCIES = \
> > +     libepoxy \
> > +     host-pkgconf \
> > +     host-python3 \
> > +     host-python-pyyaml
> > +VIRGLRENDERER_CPE_ID_VALID = YES
> > +
> > +ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VIRGL),y)
> > +ifeq ($(BR2_PACKAGE_HAS_LIBEGL)$(BR2_PACKAGE_HAS_LIBGBM),yy)
> > +VIRGLRENDERER_PLATFORMS += egl
> > +VIRGLRENDERER_DEPENDENCIES += libegl \
> > +                           libgbm
>
>   The indentation is a bit wonky here. Either put it all on a single line, or
> put the values on separate lines indented with a single tab (so 3 lines total).
>

Yes, it is... I'll fix it, thanks for the feedback.

>   Regards,
>   Arnout
>
>
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_HAS_LIBGL),y)
> > +VIRGLRENDERER_PLATFORMS += glx
> > +VIRGLRENDERER_DEPENDENCIES += libgl
> > +endif
> > +endif # BR2_PACKAGE_VIRGLRENDERER_VIRGL
> > +
> > +VIRGLRENDERER_CONF_OPTS += -Dplatforms=$(subst $(space),$(comma),$(VIRGLRENDERER_PLATFORMS))
> > +
> > +ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VENUS),y)
> > +VIRGLRENDERER_CONF_OPTS += -Dvenus=true
> > +VIRGLRENDERER_DEPENDENCIES += vulkan-headers \
> > +                           vulkan-loader
> > +else
> > +VIRGLRENDERER_CONF_OPTS += -Dvenus=false
> > +endif
> > +
> > +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_AMDGPU) += amdgpu-experimental
> > +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_INTEL) += i915-experimental
> > +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_MSM) += msm
> > +VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_PANFROST) += panfrost-experimental
> > +
> > +VIRGLRENDERER_CONF_OPTS += -Ddrm-renderers=$(subst $(space),$(comma),$(VIRGLRENDERER_DRM_BACKENDS-y))
> > +
> > +ifneq ($(VIRGLRENDERER_DRM_BACKENDS-y),)
> > +VIRGLRENDERER_DEPENDENCIES += libdrm
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VAAPI),y)
> > +VIRGLRENDERER_CONF_OPTS += -Dvideo=true
> > +VIRGLRENDERER_DEPENDENCIES += libva libdrm
> > +else
> > +VIRGLRENDERER_CONF_OPTS += -Dvideo=false
> > +endif
> > +
> > +$(eval $(meson-package))
> >
>

Best,
Joseph
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 25a047cb3e..774eb0b746 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1765,6 +1765,7 @@  F:	package/python-xlib/
 F:	package/sentry-cli/
 F:	package/sentry-native/
 F:	package/unclutter-xfixes/
+F:	package/virglrenderer/
 
 N:	Joshua Henderson <joshua.henderson@microchip.com>
 F:	package/qt5/qt5wayland/
diff --git a/package/Config.in b/package/Config.in
index 9cae377fb5..01263e4c44 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -365,6 +365,7 @@  comment "Graphic libraries"
 	source "package/sdl2_ttf/Config.in"
 	source "package/spirv-headers/Config.in"
 	source "package/tk/Config.in"
+	source "package/virglrenderer/Config.in"
 	source "package/vulkan-headers/Config.in"
 	source "package/vulkan-loader/Config.in"
 	source "package/vulkan-sdk/Config.in"
diff --git a/package/virglrenderer/Config.in b/package/virglrenderer/Config.in
new file mode 100644
index 0000000000..041bb63a1c
--- /dev/null
+++ b/package/virglrenderer/Config.in
@@ -0,0 +1,117 @@ 
+config BR2_PACKAGE_VIRGLRENDERER
+	bool "virglrenderer"
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_USE_MMU # fork()
+	select BR2_PACKAGE_LIBEPOXY
+	help
+	  A library for accelerated graphics and compute in
+	  virtualized guests.
+
+	  virglrenderer can be built without virgl, venus, or DRM
+	  backends, although such a build will not provide guest
+	  graphics or compute acceleration by itself.
+
+	  https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer
+
+if BR2_PACKAGE_VIRGLRENDERER
+comment "virglrenderer needs virgl, venus, or a DRM backend for guest acceleration"
+	depends on !BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+
+config BR2_PACKAGE_VIRGLRENDERER_VIRGL
+	bool "virgl"
+	default y
+	depends on (BR2_PACKAGE_HAS_LIBEGL && BR2_PACKAGE_HAS_LIBGBM) \
+		|| BR2_PACKAGE_HAS_LIBGL
+	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+	help
+	  Enable API-level OpenGL acceleration over virtio-gpu.
+
+	  Say 'y' if you want to run applications with OpenGL
+	  acceleration in virtualized guests. Requires host
+	  support for OpenGL.
+
+	  https://docs.mesa3d.org/drivers/virgl.html
+
+comment "virgl needs OpenGL or OpenGL EGL and libgbm"
+	depends on !((BR2_PACKAGE_HAS_LIBEGL && BR2_PACKAGE_HAS_LIBGBM) \
+		|| BR2_PACKAGE_HAS_LIBGL)
+
+config BR2_PACKAGE_VIRGLRENDERER_VENUS
+	bool "venus"
+	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER
+	depends on BR2_INSTALL_LIBSTDCPP # vulkan-loader
+	depends on !BR2_STATIC_LIBS # vulkan-loader
+	depends on BR2_TOOLCHAIN_HAS_THREADS # vulkan-loader
+	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+	select BR2_PACKAGE_VULKAN_HEADERS
+	select BR2_PACKAGE_VULKAN_LOADER
+	help
+	  Enable API-level Vulkan acceleration over virtio-gpu.
+
+	  Say 'y' if you want to run applications with Vulkan
+	  acceleration in virtualized guests. Requires host
+	  support for Vulkan.
+
+	  https://docs.mesa3d.org/drivers/venus.html
+
+config BR2_PACKAGE_VIRGLRENDERER_VAAPI
+	bool "vaapi support"
+	depends on BR2_PACKAGE_LIBGBM_HAS_FEATURE_DMA_BUF
+	select BR2_PACKAGE_LIBDRM
+	select BR2_PACKAGE_LIBVA
+	help
+	  Enable hardware accelerated video encode/decode through
+	  libva over virtio-gpu.
+
+comment "DRM backends"
+
+config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_AMDGPU
+	bool "amdgpu"
+	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_RADEONSI
+	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_AMD
+	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+	select BR2_PACKAGE_LIBDRM
+	select BR2_PACKAGE_LIBDRM_AMDGPU
+	help
+	  Enable DRM backend for amdgpu, used by Gallium radeonsi
+	  and RADV vulkan drivers.
+
+config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_INTEL
+	bool "intel"
+	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_I915
+	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS
+	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_INTEL
+	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+	select BR2_PACKAGE_LIBDRM
+	help
+	  Enable DRM backend for i915, used by Gallium i915/Iris
+	  and Intel vulkan drivers.
+
+config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_MSM
+	bool "msm"
+	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_FREEDRENO
+	depends on !BR2_arm
+	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+	select BR2_PACKAGE_LIBDRM
+	help
+	  Enable DRM backend for msm, used by Gallium freedreno
+	  driver.
+
+config BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_PANFROST
+	bool "panfrost"
+	default y if BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_PANFROST
+	default y if BR2_PACKAGE_MESA3D_VULKAN_DRIVER_PANFROST
+	select BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+	select BR2_PACKAGE_LIBDRM
+	help
+	  Enable DRM backend for Panfrost, used by the panfrost
+	  Gallium/vulkan drivers.
+
+endif
+
+comment "virglrenderer needs a toolchain w/ gcc >= 4.9"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
+
+config BR2_PACKAGE_VIRGLRENDERER_HAS_BACKEND
+	bool
diff --git a/package/virglrenderer/virglrenderer.hash b/package/virglrenderer/virglrenderer.hash
new file mode 100644
index 0000000000..03da595091
--- /dev/null
+++ b/package/virglrenderer/virglrenderer.hash
@@ -0,0 +1,5 @@ 
+# Locally calculated
+sha256  065bc56e89e6f631f96101cd62eba0748e48eb888b434edc86e89d05395e76f3  virglrenderer-1.3.0.tar.gz
+
+# License
+sha256  3b32caf16e2402c2aff2b716858713f3e1feded85c25e71bf829816ee5009402  COPYING
diff --git a/package/virglrenderer/virglrenderer.mk b/package/virglrenderer/virglrenderer.mk
new file mode 100644
index 0000000000..4e7bcbb849
--- /dev/null
+++ b/package/virglrenderer/virglrenderer.mk
@@ -0,0 +1,60 @@ 
+################################################################################
+#
+# virglrenderer
+#
+################################################################################
+
+VIRGLRENDERER_VERSION = 1.3.0
+VIRGLRENDERER_SITE = https://gitlab.freedesktop.org/virgl/virglrenderer/-/archive/$(VIRGLRENDERER_VERSION)
+VIRGLRENDERER_LICENSE = MIT
+VIRGLRENDERER_LICENSE_FILES = COPYING
+VIRGLRENDERER_INSTALL_STAGING = YES
+VIRGLRENDERER_DEPENDENCIES = \
+	libepoxy \
+	host-pkgconf \
+	host-python3 \
+	host-python-pyyaml
+VIRGLRENDERER_CPE_ID_VALID = YES
+
+ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VIRGL),y)
+ifeq ($(BR2_PACKAGE_HAS_LIBEGL)$(BR2_PACKAGE_HAS_LIBGBM),yy)
+VIRGLRENDERER_PLATFORMS += egl
+VIRGLRENDERER_DEPENDENCIES += libegl \
+			      libgbm
+endif
+
+ifeq ($(BR2_PACKAGE_HAS_LIBGL),y)
+VIRGLRENDERER_PLATFORMS += glx
+VIRGLRENDERER_DEPENDENCIES += libgl
+endif
+endif # BR2_PACKAGE_VIRGLRENDERER_VIRGL
+
+VIRGLRENDERER_CONF_OPTS += -Dplatforms=$(subst $(space),$(comma),$(VIRGLRENDERER_PLATFORMS))
+
+ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VENUS),y)
+VIRGLRENDERER_CONF_OPTS += -Dvenus=true
+VIRGLRENDERER_DEPENDENCIES += vulkan-headers \
+			      vulkan-loader
+else
+VIRGLRENDERER_CONF_OPTS += -Dvenus=false
+endif
+
+VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_AMDGPU) += amdgpu-experimental
+VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_INTEL) += i915-experimental
+VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_MSM) += msm
+VIRGLRENDERER_DRM_BACKENDS-$(BR2_PACKAGE_VIRGLRENDERER_DRM_BACKEND_PANFROST) += panfrost-experimental
+
+VIRGLRENDERER_CONF_OPTS += -Ddrm-renderers=$(subst $(space),$(comma),$(VIRGLRENDERER_DRM_BACKENDS-y))
+
+ifneq ($(VIRGLRENDERER_DRM_BACKENDS-y),)
+VIRGLRENDERER_DEPENDENCIES += libdrm
+endif
+
+ifeq ($(BR2_PACKAGE_VIRGLRENDERER_VAAPI),y)
+VIRGLRENDERER_CONF_OPTS += -Dvideo=true
+VIRGLRENDERER_DEPENDENCIES += libva libdrm
+else
+VIRGLRENDERER_CONF_OPTS += -Dvideo=false
+endif
+
+$(eval $(meson-package))