Skip to contentSkip to conversation

Add virglrenderer support

PATCH Superseded Joseph Kogut 2 participants 5 messages Feb 20 – Mar 11

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add virglrenderer support

Hello,

This patch series adds support for building the virglrenderer library in buildroot.

Virglrenderer is a userspace library used to support rendering and compute in virtual machines over virtio-gpu. Virglrenderer supports serialized API level access to OpenGL and Vulkan through virgl and venus respectively, as well as mediated DRM level access using host native context [0]. Notably libkrun [1] and rutabaga_gfx [2] are also capable of utilizing virglrenderer.

For v3 of the patch, I removed the dependency on (HAS_LIBEGL || HAS_LIBGL) in favor of just depending on HAS_LIBEGL. The project is intended to support both EGL and GLX, but most graphics paths nowadays use EGL, and this is a bit simpler. Support for GLX could be added in a later patch if anyone needs it.

The first patch adds the new virglrenderer package.

The second patch adds an OpenGL config for qemu, and a virglrenderer config that selects it, as virgl/venus currently require a GL accelerated display frontend. An optional config for enabling venus on virglrenderer enables vulkan passthrough, and a config for vaapi enables hardware video acceleration.

Tested with llama-bench running with the vulkan backend in a nested VM. As seen below, the nested guest is sending commands to the host through virtio-gpu twice.

        # llama-bench -m llama-2-7b.Q4_0.gguf -ngl 100 
        ggml_vulkan: Found 1 Vulkan devices:
        ggml_vulkan: 0 = Virtio-GPU Venus (Virtio-GPU Venus (AMD Radeon RX 6900 XT (RADV NAVI21))) (venus) | uma: 0 | fp16: 1 | warp size: 64 | shared memory: 65536 | int dot: 1 | matrix cores: none
        | model                          |       size |     params | backend    | ngl |            test |                  t/s |
        | ------------------------------ | ---------: | ---------: | ---------- | --: | --------------: | -------------------: |
        | llama 7B Q4_0                  |   3.56 GiB |     6.74 B | Vulkan     | 100 |           pp512 |      1220.99 ± 10.12 |
        | llama 7B Q4_0                  |   3.56 GiB |     6.74 B | Vulkan     | 100 |           tg128 |         82.24 ± 1.00 |

build: unknown (0)

More information about the benchmark and results from other hardware on the llama.cpp GitHub discussion here [3].

Feedback welcome.

[0] https://www.collabora.com/news-and-blog/blog/2025/01/15/the-state-of-gfx-virtualization-using-virglrenderer/
[1] https://github.com/containers/libkrun
[2] https://github.com/magma-gpu/rutabaga_gfx
[3] https://github.com/ggml-org/llama.cpp/discussions/10879

---
Changes in v3:
- Bump version to v1.3.0
- Add optional deps for panfrost and i915 native context (new)
- Add config for vaapi support
- Remove GLX in favor of EGL
- Update qemu docs links, as previous ones 404 [Romain]
- Fix invalid config reference in BR2_PACKAGE_QEMU_VIRGLRENDERER
[Romain]
- Select libepoxy when enabling OpenGL support in qemu [Romain]
- Add depends on gcc >= 4.1 to virglrenderer (from meson.build)
- Add depends on libgbm to virglrenderer [Romain]
- Add comments for missing dependencies to virglrenderer Kconfig
- Select vulkan-headers when venus is enabled [Romain]
- Disable venus explicitly when the symbol isn't selected
- Link to v2: https://lore.kernel.org/buildroot/[email protected]

Changes in v2:
- Rebase onto next (python-glslang patch merged)
- Bump version to v1.2.0
- Remove hidden configs for virglrenderer vDRM backends [Romain]
- Fixed typo in qemu/Config.in [Romain]
- Split up configs for qemu OpenGL and virglrenderer support [Romain]
- More detailed qemu config help messages
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Joseph Kogut (2):
package/virglrenderer: new package
package/qemu: add virglrenderer support

 DEVELOPERS                               |  1 +
 package/Config.in                        |  1 +
 package/qemu/Config.in                   | 28 ++++++++++++++++
 package/qemu/qemu.mk                     | 15 ++++++++-
 package/virglrenderer/Config.in          | 49 +++++++++++++++++++++++++++
 package/virglrenderer/virglrenderer.hash |  5 +++
 package/virglrenderer/virglrenderer.mk   | 57 ++++++++++++++++++++++++++++++++
 7 files changed, 155 insertions(+), 1 deletion(-)

---
base-commit: 6c83a0b8e5658b901dd35ae23217075f035af998
change-id: 20260219-virglrenderer-c4dad969ad89

Best regards,

Signature · 6 lines
Joseph Kogut <[email protected]>

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v3 1/2 package/virglrenderer: new package

Add virglrenderer, an optional dependency of QEMU, which facilitates acceleration of rendering and optionally video decode through virtio-gpu.

---
 DEVELOPERS                               |  1 +
 package/Config.in                        |  1 +
 package/virglrenderer/Config.in          | 49 +++++++++++++++++++++++++++
 package/virglrenderer/virglrenderer.hash |  5 +++
 package/virglrenderer/virglrenderer.mk   | 57 ++++++++++++++++++++++++++++++++
 5 files changed, 113 insertions(+)
DEVELOPERS +1 -0
index 9e983ae113..2c5624c1c1 100644
@@ -1766,6 +1766,7 @@ F:	package/python-xlib/
 F:	package/sentry-cli/
 F:	package/sentry-native/
 F:	package/unclutter-xfixes/
+F:	package/virglrenderer/
 
 N:	Joshua Henderson <[email protected]>
 F:	package/qt5/qt5wayland/
package/Config.in +1 -0
index 371a1c33e1..15a1bc7a25 100644
@@ -1793,6 +1793,7 @@ menu "Graphics"
 	source "package/stb/Config.in"
 	source "package/tiff/Config.in"
 	source "package/unclutter-xfixes/Config.in"
+	source "package/virglrenderer/Config.in"
 	source "package/waffle/Config.in"
 	source "package/wayland/Config.in"
 	source "package/wayland-protocols/Config.in"
package/virglrenderer/Config.in new file +49 -0

49 lines not on this page · raw message

package/virglrenderer/virglrenderer.hash new file +5 -0
new file mode 100644
index 0000000000..03da595091
@@ -0,0 +1,5 @@
+# Locally calculated
+sha256  065bc56e89e6f631f96101cd62eba0748e48eb888b434edc86e89d05395e76f3  virglrenderer-1.3.0.tar.gz
+
+# License
+sha256  3b32caf16e2402c2aff2b716858713f3e1feded85c25e71bf829816ee5009402  COPYING
package/virglrenderer/virglrenderer.mk new file +57 -0

57 lines not on this page · raw message

Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH v3 2/2 package/qemu: add virglrenderer support

In reply to Joseph Kogut

Add optional virglrenderer support, along with enabling OpenGL when necessary.

https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer

---
 package/qemu/Config.in | 28 ++++++++++++++++++++++++++++
 package/qemu/qemu.mk   | 15 ++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)
package/qemu/Config.in +28 -0
index e16eafe446..25921368e9 100644
@@ -116,6 +116,34 @@ config BR2_PACKAGE_QEMU_SDL
 	  Say 'y' to enable the SDL frontend, that is, a graphical
 	  window presenting the VM's display.
 
+comment "OpenGL and virglrenderer need an OpenGL and/or OpenGL EGL backend"
+	depends on !(BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL)
+
+config BR2_PACKAGE_QEMU_OPENGL
+	bool "Enable OpenGL"
+	depends on BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL # libepoxy
+	select BR2_PACKAGE_LIBEPOXY
+	help
+	  Say 'y' to enable OpenGL accelerated display frontend support.
+	  This is necessary to efficiently display frames rendered in a
+	  guest on the host.
+
+	  Run qemu with `-display sdl,gl=on`
+
+config BR2_PACKAGE_QEMU_VIRGLRENDERER
+	bool "Enable virglrenderer"
+	depends on BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL # virglrenderer
+	select BR2_PACKAGE_QEMU_OPENGL
+	select BR2_PACKAGE_VIRGLRENDERER
+	help
+	  Say 'y' to enable virglrenderer, enabling GL and Vulkan
+	  passthrough from the host to the guest through virtio-gpu.
+	  This enables the guest to have accelerated GL and/or Vulkan.
+
+	  Run qemu with `-device virtio-gpu-gl`
+
+	  https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer
+
 config BR2_PACKAGE_QEMU_FDT
 	bool "Enable FDT"
 	select BR2_PACKAGE_DTC
package/qemu/qemu.mk +14 -1
index 97f8e22091..e250128dfa 100644
@@ -274,6 +274,20 @@ else
 QEMU_OPTS += --disable-usb-redir
 endif
 
+ifeq ($(BR2_PACKAGE_QEMU_OPENGL),y)
+QEMU_OPTS += --enable-opengl
+QEMU_DEPENDENCIES += libepoxy
+else
+QEMU_OPTS += --disable-opengl
+endif
+
+ifeq ($(BR2_PACKAGE_QEMU_VIRGLRENDERER),y)
+QEMU_OPTS += --enable-virglrenderer
+QEMU_DEPENDENCIES += virglrenderer
+else
+QEMU_OPTS += --disable-virglrenderer
+endif
+
 ifeq ($(BR2_STATIC_LIBS),y)
 QEMU_OPTS += --static
 endif
@@ -330,7 +344,6 @@ define QEMU_CONFIGURE_CMDS
 			--disable-membarrier \
 			--disable-mpath \
 			--disable-netmap \
-			--disable-opengl \
 			--disable-oss \
 			--disable-pa \
 			--disable-plugins \
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH v3 2/2] package/qemu: add virglrenderer support

Hello Joseph, All,

Le 20/02/2026 à 02:23, Joseph Kogut a écrit :

Quoted 16 lines

Add optional virglrenderer support, along with enabling OpenGL when necessary.

https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer

---
 package/qemu/Config.in | 28 ++++++++++++++++++++++++++++
 package/qemu/qemu.mk   | 15 ++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)
package/qemu/Config.in +0 -0
index e16eafe446..25921368e9 100644

package/qemu/Config.in config BR2_PACKAGE_QEMU_SDL · line 120

Quoted 5 lines
package/qemu/Config.in +2 -0
@@ -116,6 +116,34 @@ config BR2_PACKAGE_QEMU_SDL
 	  Say 'y' to enable the SDL frontend, that is, a graphical
 	  window presenting the VM's display.
 
+comment "OpenGL and virglrenderer need an OpenGL and/or OpenGL EGL backend"
+	depends on !(BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL)

One comment per option, especially since BR2_PACKAGE_VIRGLRENDERER actually depends on BR2_PACKAGE_HAS_LIBGL only (see bellow).

package/qemu/Config.in config BR2_PACKAGE_QEMU_SDL · line 131

Quoted 11 lines
package/qemu/Config.in +11 -0
+
+config BR2_PACKAGE_QEMU_OPENGL
+	bool "Enable OpenGL"
+	depends on BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL # libepoxy
+	select BR2_PACKAGE_LIBEPOXY
+	help
+	  Say 'y' to enable OpenGL accelerated display frontend support.
+	  This is necessary to efficiently display frames rendered in a
+	  guest on the host.
+
+	  Run qemu with `-display sdl,gl=on`

The two new option should be added in two separate commit.

package/qemu/Config.in config BR2_PACKAGE_QEMU_SDL · line 137

Quoted 5 lines
package/qemu/Config.in +5 -0
+
+config BR2_PACKAGE_QEMU_VIRGLRENDERER
+	bool "Enable virglrenderer"
+	depends on BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL # virglrenderer> +	select BR2_PACKAGE_QEMU_OPENGL
+	select BR2_PACKAGE_VIRGLRENDERER

If BR2_PACKAGE_QEMU_VIRGLRENDERER is selected with only BR2_PACKAGE_HAS_LIBGL enabled, you can't select BR2_PACKAGE_VIRGLRENDERER here since it depends on libegl only.

"libegl is in the dependency chain of virglrenderer that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in."

Best regards,
Romain

Quoted 39 lines
package/qemu/Config.in +9 -0
+	help
+	  Say 'y' to enable virglrenderer, enabling GL and Vulkan
+	  passthrough from the host to the guest through virtio-gpu.
+	  This enables the guest to have accelerated GL and/or Vulkan.
+
+	  Run qemu with `-device virtio-gpu-gl`
+
+	  https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer
+
 config BR2_PACKAGE_QEMU_FDT
 	bool "Enable FDT"
 	select BR2_PACKAGE_DTC
package/qemu/qemu.mk +14 -0
index 97f8e22091..e250128dfa 100644
@@ -274,6 +274,20 @@ else
 QEMU_OPTS += --disable-usb-redir
 endif
 
+ifeq ($(BR2_PACKAGE_QEMU_OPENGL),y)
+QEMU_OPTS += --enable-opengl
+QEMU_DEPENDENCIES += libepoxy
+else
+QEMU_OPTS += --disable-opengl
+endif
+
+ifeq ($(BR2_PACKAGE_QEMU_VIRGLRENDERER),y)
+QEMU_OPTS += --enable-virglrenderer
+QEMU_DEPENDENCIES += virglrenderer
+else
+QEMU_OPTS += --disable-virglrenderer
+endif
+
 ifeq ($(BR2_STATIC_LIBS),y)
 QEMU_OPTS += --static
 endif

package/qemu/qemu.mk define QEMU_CONFIGURE_CMDS · line 349

Quoted 7 lines
package/qemu/qemu.mk +0 -1
@@ -330,7 +344,6 @@ define QEMU_CONFIGURE_CMDS
 			--disable-membarrier \
 			--disable-mpath \
 			--disable-netmap \
-			--disable-opengl \
 			--disable-oss \
 			--disable-pa \
 			--disable-plugins \

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

Re: [Buildroot] [PATCH v3 2/2] package/qemu: add virglrenderer support

Hello Romain,

Quoted 29 lines · Romain Naour

Hello Joseph, All,

Quoted 16 lines · Joseph Kogut

Add optional virglrenderer support, along with enabling OpenGL when necessary.

https://qemu.readthedocs.io/en/v10.0.3/system/devices/virtio-gpu.html#virtio-gpu-virglrenderer

---
 package/qemu/Config.in | 28 ++++++++++++++++++++++++++++
 package/qemu/qemu.mk   | 15 ++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)
package/qemu/Config.in +0 -0
index e16eafe446..25921368e9 100644

package/qemu/Config.in config BR2_PACKAGE_QEMU_SDL · line 120

Quoted 5 lines
package/qemu/Config.in +2 -0
@@ -116,6 +116,34 @@ config BR2_PACKAGE_QEMU_SDL
        Say 'y' to enable the SDL frontend, that is, a graphical
        window presenting the VM's display.
 
+comment "OpenGL and virglrenderer need an OpenGL and/or OpenGL EGL backend"
+     depends on !(BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL)

One comment per option, especially since BR2_PACKAGE_VIRGLRENDERER actually depends on BR2_PACKAGE_HAS_LIBGL only (see bellow).

Quoted 14 lines

package/qemu/Config.in config BR2_PACKAGE_QEMU_SDL · line 131

Quoted 11 lines
package/qemu/Config.in +11 -0
+
+config BR2_PACKAGE_QEMU_OPENGL
+     bool "Enable OpenGL"
+     depends on BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL # libepoxy
+     select BR2_PACKAGE_LIBEPOXY
+     help
+       Say 'y' to enable OpenGL accelerated display frontend support.
+       This is necessary to efficiently display frames rendered in a
+       guest on the host.
+
+       Run qemu with `-display sdl,gl=on`

The two new option should be added in two separate commit.

Good suggestion, that's a cleaner structure.

Quoted 10 lines

package/qemu/Config.in config BR2_PACKAGE_QEMU_SDL · line 137

Quoted 5 lines
package/qemu/Config.in +5 -0
+
+config BR2_PACKAGE_QEMU_VIRGLRENDERER
+     bool "Enable virglrenderer"
+     depends on BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBGL # virglrenderer> +   select BR2_PACKAGE_QEMU_OPENGL
+     select BR2_PACKAGE_VIRGLRENDERER

If BR2_PACKAGE_QEMU_VIRGLRENDERER is selected with only BR2_PACKAGE_HAS_LIBGL enabled, you can't select BR2_PACKAGE_VIRGLRENDERER here since it depends on libegl only.

Quoted 3 lines

"libegl is in the dependency chain of virglrenderer that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in."

Thanks for pointing this out, I missed that. I'll follow up shortly.

Thanks for the review.

Best,
Joseph
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot