Skip to content

Enable accelerated OpenGL in qemu

Alexander Kanavin openembedded-core 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest27 patches 0 repliesNew
  2. v222 patches 0 repliesSuperseded
  3. v123 patches 14 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27gtk+3: enable native/nativesdk variantmeta/recipes-gnome/gtk+/gtk+3.inc+26 -20 replies
2/27gtk+3: remove the gtk-icon-utils-native recipemeta/recipes-gnome/gtk+/gtk+3.inc meta/recipes-gnome/gtk+/gtk-icon-utils-native_3.22.30.bb meta/recipes-gnome/gtk+/gtk-icon-utils/Remove-Gdk-dependency-from-gtk-encode-symbolic-svg.patch+5 -1670 replies
3/27shared-mime-info: update the database also in native buildsmeta/recipes-support/shared-mime-info/shared-mime-info.inc+2 -00 replies
4/27pixbufcache.bbclass: remove a dependency loop introduced by enabling gtk+3-nativemeta/classes/pixbufcache.bbclass+1 -10 replies
5/27meta: add native and nativesdk variants to various recipes to enable gtk+3-native/nativesdkmeta/recipes-gnome/gdk-pixbuf/gdk-pixbuf_2.36.11.bb meta/recipes-gnome/gnome/adwaita-icon-theme_3.28.0.bb meta/recipes-gnome/hicolor-icon-theme/hicolor-icon-theme_0.17.bb +13 more+22 -80 replies
6/27libepoxy: enable native/nativesdk variantsmeta/recipes-graphics/libepoxy/libepoxy_1.5.3.bb+16 -00 replies
7/27mesa: enable native and nativesdk variantsmeta/recipes-graphics/mesa/mesa.inc+9 -30 replies
8/27virglrenderer: add a recipemeta/conf/distro/include/maintainers.inc meta/recipes-graphics/virglrenderer/virglrenderer_git.bb+18 -00 replies
9/27qemu: enable virglrenderer and glx options for native/nativesdk buildsmeta/recipes-devtools/qemu/qemu.inc+2 -20 replies
10/27qemu: drop --with-gtkabi option, as it is no longer supportedmeta/recipes-devtools/qemu/qemu.inc+1 -10 replies
11/27mesa-gl: do not enable nativesdk variant to avoid clashes with main mesa recipemeta/recipes-graphics/mesa/mesa-gl_18.1.9.bb+2 -00 replies
12/27local.conf.sample: adjust the qemu config to enable gtk+ instead of sdlmeta-poky/conf/local.conf.sample+3 -60 replies
13/27qemu: build target variant with gtk+, and nativesdk variant without sdlmeta/recipes-devtools/qemu/qemu.inc+2 -20 replies
14/27qemu: remove support for building against host sdlmeta/recipes-devtools/qemu/qemu.inc+0 -80 replies
15/27atk: disable gobject-introspection for nativesdkmeta/recipes-support/atk/atk_2.30.0.bb+2 -00 replies
16/27qemu: add a gettext-native dependency to gtk optionmeta/recipes-devtools/qemu/qemu.inc+1 -10 replies
17/27libjpeg-turbo: fix nativesdk build in same way as native builds aremeta/recipes-graphics/jpeg/libjpeg-turbo_2.0.1.bb+1 -00 replies
18/27qemu: add a patch to avoid a missing definition errormeta/recipes-devtools/qemu/qemu/0001-Add-a-missing-X11-include.patch meta/recipes-devtools/qemu/qemu/0012-fix-libcap-header-issue-on-some-distro.patch meta/recipes-devtools/qemu/qemu/0013-cpus.c-Add-error-messages-when-qemi_cpu_kick_thread-.patch +1 more+68 -20 replies
19/27qemu: add environment variable wrappers to make qemu look good with gtk frontendmeta/recipes-devtools/qemu/qemu.inc+22 -00 replies
20/27qemu: add a backported patch to fix egl-headless supportmeta/recipes-devtools/qemu/qemu/0001-egl-headless-add-egl_create_context.patch meta/recipes-devtools/qemu/qemu_3.1.0.bb+51 -00 replies
21/27runqemu: add support for virgl GL accelerationmeta/conf/machine/include/qemuboot-x86.inc scripts/runqemu+26 -10 replies
22/27runqemu: do not check for GL librariesscripts/runqemu+0 -350 replies
23/27testimage.bbclass: add support for passing runqemu paramsmeta/classes/testimage.bbclass meta/lib/oeqa/core/target/qemu.py+5 -30 replies
24/27selftest: add tests for virgl GL accelerationmeta-selftest/lib/oeqa/runtime/cases/virgl.py meta/lib/oeqa/selftest/cases/runtime_test.py+61 -00 replies
25/27kmscobe: update to latest commit, switch over to mesonmeta/recipes-graphics/kmscube/kmscube_git.bb+2 -20 replies
26/27kmscube: make gstreamer dependency optionalmeta/recipes-graphics/kmscube/kmscube_git.bb+4 -10 replies
27/27vte: allow building vte-native with gcc 4.8meta/recipes-support/vte/vte/0001-app.cc-use-old-school-asignment-to-avoid-gcc-4.8-err.patch meta/recipes-support/vte/vte_0.52.2.bb+30 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCHv3 00/27] Enable accelerated OpenGL in qemu

V2 changes: addressed feedback from the first review round V3 changes:
- better fix for missing qemu X11 include, as discussed with upstream
- maintainers.inc entry for virglrenderer
- egl-headless support (see below for details)
- improvements to kmscube recipe
- fix to vte-native to allow building it with gcc 4.8

Why this? Why now?

1. I think we are heading towards a reality where some kind of working GL is a 'must' for any kind of UI work.
2. Typically people build images and then transfer them to the NUC or even target boards for testing - using qemu would be less awkward.
3. Current qemu configuration is basically useless here, as it only provides a very slow software GL driver from mesa.

0. TLDR:

a) Gtk UI frontend

$ . oe-init-build-env build-virgl
$ bitbake core-image-sato-sdk
$ runqemu kvm gl
$$ run glxgears or any other GL-capable binary inside qemu

b) egl-headless

$ . oe-init-build-env build-virgl
$ bitbake core-image-sato-sdk
$ runqemu kvm egl-headless publicvnc
$ <connect with a vnc viewer to 127.0.0.1:5900>
$$ run glxgears or any other GL-capable binary inside qemu

1. For the local UI, qemu is switched over to use gtk frontend. I simply couldn't get SDL frontend to work properly, it only displays a blank black window or doesn't start at all. Same thing happens with qemu binaries provided by Fedora and opensuse (Ubuntu's qemu lacks virgl support). Seems like SDL support has regressed.

2. What is egl-headless?

In this variant, Qemu does not open a UI window at all. Instead, it renders all graphics, including GL, into a memory buffer, which can be seen with a vnc or spice client (over a TCP socket). This has the following advantages:

- no need to be physically present at the host machine, output (including GL bits!) can be seen remotely
- no need for the host machine to run an X session

3. While the components are built against the most minimum necessary mesa-native set (gbm, egl, dri with no drivers), libepoxy loads and uses the host GL implementation (through a chrpath hack). This is both to save build times, and because the host is likely to have a set of drivers more appropriate for the physical machine (e.g. proprietary nvidia stack, although I didn't test that).

4. I tested this with
- glamor X server
- weston compositor with drm backend (build core-image-weston, then edit weston.ini in the image to use drm backed instead of fbdev).
- kmscube
- glxgears
- https://www.geeks3d.com/gputest/

The latter two show FPS that is similar to running them directly on the host.

5. Some things I am not sure about:

- how much of a 'default' should this be for running qemu. It works for me,
but other people might find it less stable compared to the existing sdl-vmware-swrast setup.

- what other tests and demos could be run

- how could this be tested on the autobuilder. I wrote two oe-selftests for this (gtk, egl-headless), but one of them does require an X session, and both require ability to create opengl contexts on the host.

The following changes since commit 4211a7497886561e9607f18dd4d81d0d41eaadfa:

dev-manual: Added some clarification for nographic qemu option. (2019-01-16 15:35:57 +0000)

are available in the Git repository at:

git://git.yoctoproject.org/poky-contrib akanavin/virgl-gtk
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=akanavin/virgl-gtk

Alexander Kanavin (27):
gtk+3: enable native/nativesdk variant
gtk+3: remove the gtk-icon-utils-native recipe
shared-mime-info: update the database also in native builds pixbufcache.bbclass: remove a dependency loop introduced by enabling
gtk+3-native
meta: add native and nativesdk variants to various recipes to enable
gtk+3-native/nativesdk
libepoxy: enable native/nativesdk variants
mesa: enable native and nativesdk variants
virglrenderer: add a recipe
qemu: enable virglrenderer and glx options for native/nativesdk builds
qemu: drop --with-gtkabi option, as it is no longer supported
mesa-gl: do not enable nativesdk variant to avoid clashes with main
mesa recipe
local.conf.sample: adjust the qemu config to enable gtk+ instead of
sdl
qemu: build target variant with gtk+, and nativesdk variant without
sdl
qemu: remove support for building against host sdl
atk: disable gobject-introspection for nativesdk
qemu: add a gettext-native dependency to gtk option
libjpeg-turbo: fix nativesdk build in same way as native builds are
qemu: add a patch to avoid a missing definition error
qemu: add environment variable wrappers to make qemu look good with
gtk frontend
qemu: add a backported patch to fix egl-headless support
runqemu: add support for virgl GL acceleration
runqemu: do not check for GL libraries
testimage.bbclass: add support for passing runqemu params
selftest: add tests for virgl GL acceleration
kmscobe: update to latest commit, switch over to meson
kmscube: make gstreamer dependency optional
vte: allow building vte-native with gcc 4.8

 meta-poky/conf/local.conf.sample              |   9 +-
 meta-selftest/lib/oeqa/runtime/cases/virgl.py |  17 +++
 meta/classes/pixbufcache.bbclass              |   2 +-
 meta/classes/testimage.bbclass                |   4 +-
 meta/conf/distro/include/maintainers.inc      |   1 +
 meta/conf/machine/include/qemuboot-x86.inc    |   2 +-
 meta/lib/oeqa/core/target/qemu.py             |   4 +-
 meta/lib/oeqa/selftest/cases/runtime_test.py  |  44 ++++++++
 meta/recipes-devtools/qemu/qemu.inc           |  38 ++++---
 .../qemu/0001-Add-a-missing-X11-include.patch |  65 +++++++++++
 ...-egl-headless-add-egl_create_context.patch |  50 +++++++++
 ...x-libcap-header-issue-on-some-distro.patch |   2 +-
 ...-messages-when-qemi_cpu_kick_thread-.patch |   2 +-
 meta/recipes-devtools/qemu/qemu_3.1.0.bb      |   2 +
 .../gdk-pixbuf/gdk-pixbuf_2.36.11.bb          |   2 +-
 .../gnome/adwaita-icon-theme_3.28.0.bb        |   2 +
 meta/recipes-gnome/gtk+/gtk+3.inc             |  31 +++++-
 .../gtk+/gtk-icon-utils-native_3.22.30.bb     |  63 -----------
 ...endency-from-gtk-encode-symbolic-svg.patch | 102 ------------------
 .../hicolor-icon-theme_0.17.bb                |   2 +
 meta/recipes-graphics/cairo/cairo_1.14.12.bb  |   2 +-
 .../harfbuzz/harfbuzz_2.2.0.bb                |   2 +-
 .../jpeg/libjpeg-turbo_2.0.1.bb               |   3 +-
 meta/recipes-graphics/kmscube/kmscube_git.bb  |   9 +-
 .../libepoxy/libepoxy_1.5.3.bb                |  16 +++
 meta/recipes-graphics/mesa/mesa-gl_18.1.9.bb  |   2 +
 meta/recipes-graphics/mesa/mesa.inc           |  12 ++-
 meta/recipes-graphics/pango/pango_1.42.4.bb   |   2 +-
 .../ttf-fonts/liberation-fonts_2.00.1.bb      |   2 +
 .../virglrenderer/virglrenderer_git.bb        |  17 +++
 .../xorg-lib/libxcomposite_0.4.4.bb           |   2 +-
 .../xorg-lib/libxdamage_1.1.4.bb              |   2 +-
 meta/recipes-graphics/xorg-lib/libxi_1.7.9.bb |   2 +
 .../xorg-lib/libxtst_1.2.3.bb                 |   1 +
 .../recipes-support/atk/at-spi2-atk_2.30.0.bb |   2 +
 .../atk/at-spi2-core_2.30.0.bb                |   1 +
 meta/recipes-support/atk/atk_2.30.0.bb        |   4 +-
 .../shared-mime-info/shared-mime-info.inc     |   2 +
 ...chool-asignment-to-avoid-gcc-4.8-err.patch |  27 +++++
 meta/recipes-support/vte/vte_0.52.2.bb        |   7 +-
 scripts/runqemu                               |  60 +++++------
 41 files changed, 378 insertions(+), 243 deletions(-)
 create mode 100644 meta-selftest/lib/oeqa/runtime/cases/virgl.py
 create mode 100644 meta/recipes-devtools/qemu/qemu/0001-Add-a-missing-X11-include.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/0001-egl-headless-add-egl_create_context.patch
 delete mode 100644 meta/recipes-gnome/gtk+/gtk-icon-utils-native_3.22.30.bb
 delete mode 100644 meta/recipes-gnome/gtk+/gtk-icon-utils/Remove-Gdk-dependency-from-gtk-encode-symbolic-svg.patch
 create mode 100644 meta/recipes-graphics/virglrenderer/virglrenderer_git.bb
 create mode 100644 meta/recipes-support/vte/vte/0001-app.cc-use-old-school-asignment-to-avoid-gcc-4.8-err.patch
Signature · 1 line
2.17.1