How to enable graphics acceleration on qemux86-64?


Alexander Kanavin
 

On Sun, 24 Oct 2021 at 23:29, Manuel Wagesreither <ManWag@...> wrote:
Hi all,
hi Alexander,

I solved my problems. Things work fine now. Below I'm summing things up as documentation for myself and also others in case this pops up in someones search query.

Cheers :) you should also try this on bleeding edge master, it should work the same as hardknott, but if there are issues, you can make and send patches to fix them.

Alex


Manuel Wagesreither
 

Hi all,
hi Alexander,

I solved my problems. Things work fine now. Below I'm summing things up as documentation for myself and also others in case this pops up in someones search query.

Am So, 17. Okt 2021, um 13:32, schrieb Alexander Kanavin:
On Sat, 16 Oct 2021 at 14:08, Manuel Wagesreither <ManWag@...> wrote:

Here are some updates:

Building core-image-weston on hardknott succeeded. Couldn't `runqmu kvm slirp sdl core-image-weston` first because I got an error message about 'dri.pc' being missing. Debian package search told me it's part of 'mesa-commond-dev', so I installed it on my host machine and indeed, that runqemu command above got working again. Not just that, now even OpenGL acceleration with `runqmu kvm slirp sdl gl core-image-weston` worked, altough I didn't change anything OpenGL-wise. core-image-weston feels really snappy now. Great!

I got curious and reverted back to dunfell to check if the now-installed dri.pc made a difference, but no, it didn't. `runqemu` with `sdl` started (like it did before), and with `sdl gl` it still said "OpenGL support is disabled".

You need to replicate the settings from oe-selftest (link provided previously). I think on dunfell it's not enabled out of the box, and needs to be configured explicitly.

You were are right. In hindsight, your initial post contained everything necessary. The 'PACKAGECONFIG_append_pn-<package-name>' variables tell everything necessary. I couldn't make sense of what I was reading at the beginning.

DUNFELL:
=========
Summing things up, here's what I need on Dunfell for `runqemu kvm slirp sdl gl`.

* DISTRO_FEATURES opengl
* 'weston-xwayland' in IMAGE_INSTALL.
* 'PACKAGECONFIG:append:pn-qemu-system-native = " sdl gtk+ virglrenderer glx"'. (Having opengl in DISTRO_FEATURES puts opengl in libsdl2-native PACKAGECONFIG automatically.)

It's interesting the gtk+ part was necessary even for `runqemu kvm slirp sdl gl`. Thought gtk+ and sdl are different solutions for the same problem. Without gtk+, it would fail with
```
qemu-system-x86_64: ../libepoxy-1.5.4/src/dispatch_common.c:863: epoxy_get_proc_address: Assertion `0 && "Couldn't find current GLX or EGL context.\n"'
```
Can't make sense of that and won't investigate any further.

HARDKNOTT:
============
Here's what I need on Hardknott:

As Alexander wrote, with Hardknott explicit configuration is no longer necessary if DISTRO_FEATURES has opengl. Think it's due to following patch: http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=7561eb32a01f7990ad4a4606ac97ebe2a659e029

Hence I need:
* DISTRO_FEATURES opengl
* 'PACKAGECONFIG:append:pn-qemu-system-native = " sdl".
* 'weston-xwayland' in IMAGE_INSTALL.
* /etc/systemd/system/default.target is a symlink to multi-user.target and shadows /lib/systemd/system/default.target which is a symlink to graphical.target. Hence, one must start graphical.target manually.
* Need to adapt weston.service to start weston with --modules=xwayland.so.

Perhaps this helps anyone.

Thanks again for your help, Alexander.

Manuel


Alexander Kanavin
 

On Sat, 16 Oct 2021 at 14:08, Manuel Wagesreither <ManWag@...> wrote:
Here are some updates:

Building core-image-weston on hardknott succeeded. Couldn't `runqmu kvm slirp sdl core-image-weston` first because I got an error message about 'dri.pc' being missing. Debian package search told me it's part of 'mesa-commond-dev', so I installed it on my host machine and indeed, that runqemu command above got working again. Not just that, now even OpenGL acceleration with `runqmu kvm slirp sdl gl core-image-weston` worked, altough I didn't change anything OpenGL-wise. core-image-weston feels really snappy now. Great!

I got curious and reverted back to dunfell to check if the now-installed dri.pc made a difference, but no, it didn't. `runqemu` with `sdl` started (like it did before), and with `sdl gl` it still said "OpenGL support is disabled".

You need to replicate the settings from oe-selftest (link provided previously). I think on dunfell it's not enabled out of the box, and needs to be configured explicitly.
 
Ok, so then I moved on to get my own image which is on hardknott now working.

I `runqemu`d my image with 'sdl' and 'gl' and it started up fine. Weston did no longer start automatically so I did manually. Ran `DISPLAY=:0 glxgears` but it told me "couldn't open display :0". Installed 'weston-xwayland' so I'd get "/usr/lib/libweston-9/xwayland.so" but that didn't change anything.

Can't yet say if `DISPLAY=:0 glxgears` works on core-image-weston as it's still building.

DISPLAY is a setting for the host, so qemu can display the sdl or gtk window. On the qemu guest you need to get weston to start first.

Alex


Manuel Wagesreither
 

Am Mi, 13. Okt 2021, um 22:56, schrieb Alexander Kanavin:
If you switch to master, it's best if you make a new build directory and dont reuse the one you have.

Alex

On Wed, 13 Oct 2021 at 22:09, Manuel Wagesreither <ManWag@...> wrote:

`export DISPLAY=:0` did the trick.

The following shows when still on poky dunfell:

* I can now boot `runqmu kvm slirp sdl core-image-weston`. But gui is still slow. I cannot even type `systemctl poweroff` in weston-terminal, it inevitably becomes `wweesssttooo[...]`.
* `runqemu kvm slirp sdl gl core-image-weston` still fails with `Failed to run qemu: qemu-system-x86_64: OpenGL support is disabled`.

Updated to current poky master, but got this: `ERROR: ParseError in configuration INHERITs: Could not inherit file classes/image-mklibs.bbclass`.

Switched to hardknott-3.3.3 which is four weeks old and perhaps a little riper. It's currently building.

Regards,
Manuel




Here are some updates:

Building core-image-weston on hardknott succeeded. Couldn't `runqmu kvm slirp sdl core-image-weston` first because I got an error message about 'dri.pc' being missing. Debian package search told me it's part of 'mesa-commond-dev', so I installed it on my host machine and indeed, that runqemu command above got working again. Not just that, now even OpenGL acceleration with `runqmu kvm slirp sdl gl core-image-weston` worked, altough I didn't change anything OpenGL-wise. core-image-weston feels really snappy now. Great!

I got curious and reverted back to dunfell to check if the now-installed dri.pc made a difference, but no, it didn't. `runqemu` with `sdl` started (like it did before), and with `sdl gl` it still said "OpenGL support is disabled".

Ok, so then I moved on to get my own image which is on hardknott now working.

I `runqemu`d my image with 'sdl' and 'gl' and it started up fine. Weston did no longer start automatically so I did manually. Ran `DISPLAY=:0 glxgears` but it told me "couldn't open display :0". Installed 'weston-xwayland' so I'd get "/usr/lib/libweston-9/xwayland.so" but that didn't change anything.

Can't yet say if `DISPLAY=:0 glxgears` works on core-image-weston as it's still building.

Regards, Manuel


Alexander Kanavin
 

If you switch to master, it's best if you make a new build directory and dont reuse the one you have.

Alex


On Wed, 13 Oct 2021 at 22:09, Manuel Wagesreither <ManWag@...> wrote:
`export DISPLAY=:0` did the trick.

The following shows when still on poky dunfell:

* I can now boot `runqmu kvm slirp sdl core-image-weston`. But gui is still slow. I cannot even type `systemctl poweroff` in weston-terminal, it inevitably becomes `wweesssttooo[...]`.
* `runqemu kvm slirp sdl gl core-image-weston` still fails with `Failed to run qemu: qemu-system-x86_64: OpenGL support is disabled`.

Updated to current poky master, but got this: `ERROR: ParseError in configuration INHERITs: Could not inherit file classes/image-mklibs.bbclass`.

Switched to hardknott-3.3.3 which is four weeks old and perhaps a little riper. It's currently building.

Regards,
Manuel


Manuel Wagesreither
 

`export DISPLAY=:0` did the trick.

The following shows when still on poky dunfell:

* I can now boot `runqmu kvm slirp sdl core-image-weston`. But gui is still slow. I cannot even type `systemctl poweroff` in weston-terminal, it inevitably becomes `wweesssttooo[...]`.
* `runqemu kvm slirp sdl gl core-image-weston` still fails with `Failed to run qemu: qemu-system-x86_64: OpenGL support is disabled`.

Updated to current poky master, but got this: `ERROR: ParseError in configuration INHERITs: Could not inherit file classes/image-mklibs.bbclass`.

Switched to hardknott-3.3.3 which is four weeks old and perhaps a little riper. It's currently building.

Regards,
Manuel


Alexander Kanavin
 

Can you check with current master (instead of dunfell) please?

You also need to run runqemu inside an X session (e.g. DISPLAY environment variable should be set to a valid X server).

If sdl does not work, enabling gtk is not going to work either.

Alex


On Wed, 13 Oct 2021 at 21:21, Manuel Wagesreither <ManWag@...> wrote:
Hi Alex,

Am Fr, 8. Okt 2021, um 11:00, schrieb Alexander Kanavin:
Something in your custom setup disables opengl in qemu-system-native.

Can you try core-image-weston with plain poky only?

This is the test we use to ensure it does work, it lists all the settings that have to be in place
(but in poky they are enabled by default, except the gtk frontend):

Interesting. Things don't work on both my Debian Buster machines.

How does opengl get set in qemu-system-native? Am Yocto novice and don't speak Python.

Am using poky repo on tag dunfell-23.0.10 = 2a848e9507.

Here's my complete test results:

* `runqemu kvm slirp core-image-weston` fails with `Failed to run qemu: Could not initialize SDL(x11 not available) - exiting`
* `runqemu kvm slirp sdl core-image-minimal` fails with `Failed to run qemu: Could not initialize SDL(x11 not available) - exiting`
* `runqemu kvm slirp sdl gl core-image-minimal` fails with `Failed to run qemu: qemu-system-x86_64: OpenGL support is disabled`
* `runqemu kvm slirp gtk core-image-minimal` fails with `Failed to run qemu: qemu-system-x86_64: Display 'gtk' is not available.`

How would I enable gtk frontend in poky?

Thanks, Manuel


Manuel Wagesreither
 

Hi Alex,

Am Fr, 8. Okt 2021, um 11:00, schrieb Alexander Kanavin:
Something in your custom setup disables opengl in qemu-system-native.

Can you try core-image-weston with plain poky only?

This is the test we use to ensure it does work, it lists all the settings that have to be in place
(but in poky they are enabled by default, except the gtk frontend):

Interesting. Things don't work on both my Debian Buster machines.

How does opengl get set in qemu-system-native? Am Yocto novice and don't speak Python.

Am using poky repo on tag dunfell-23.0.10 = 2a848e9507.

Here's my complete test results:

* `runqemu kvm slirp core-image-weston` fails with `Failed to run qemu: Could not initialize SDL(x11 not available) - exiting`
* `runqemu kvm slirp sdl core-image-minimal` fails with `Failed to run qemu: Could not initialize SDL(x11 not available) - exiting`
* `runqemu kvm slirp sdl gl core-image-minimal` fails with `Failed to run qemu: qemu-system-x86_64: OpenGL support is disabled`
* `runqemu kvm slirp gtk core-image-minimal` fails with `Failed to run qemu: qemu-system-x86_64: Display 'gtk' is not available.`

How would I enable gtk frontend in poky?

Thanks, Manuel


Alexander Kanavin
 

Something in your custom setup disables opengl in qemu-system-native.

Can you try core-image-weston with plain poky only?

This is the test we use to ensure it does work, it lists all the settings that have to be in place
(but in poky they are enabled by default, except the gtk frontend):

Alex


On Fri, 8 Oct 2021 at 10:26, Manuel Wagesreither <ManWag@...> wrote:
Hello all,

How can I enable graphics acceleration on qemux86-64? My image is using wayland with weston and the GUI is not exactly fast.

* When I do `runqemu slirp kvm gtk`, it throws the following error: `runqemu - ERROR - Failed to run qemu: qemu-system-x86_64: Display 'gtk' is not available.`
* `runqemu slirp kvm sdl` works, but the weston GUI does not seem to be accelerated.
* `runqemu slirp kvm sdl gl` emits the following: `runqemu - ERROR - Failed to run qemu: qemu-system-x86_64: OpenGL support is disabled`

Below I'm posting a snippet of `poky/scripts/runqemu` to have at hand the qemu options enabled by the runqemu options mentioned above:
```
            elif arg == 'sdl':
                if 'gl' in sys.argv[1:]:
                    self.qemu_opt_script += ' -vga virtio -display sdl,gl=on'
                elif 'gl-es' in sys.argv[1:]:
                    self.qemu_opt_script += ' -vga virtio -display sdl,gl=es'
                else:
                    self.qemu_opt_script += ' -display sdl'
            elif arg == 'gtk':
                if 'gl' in sys.argv[1:]:
                    self.qemu_opt_script += ' -vga virtio -display gtk,gl=on'
                elif 'gl-es' in sys.argv[1:]:
                    self.qemu_opt_script += ' -vga virtio -display gtk,gl=es'
                else:
                    self.qemu_opt_script += ' -display gtk'
```

Kind regards,
Manuel




Manuel Wagesreither
 

Hello all,

How can I enable graphics acceleration on qemux86-64? My image is using wayland with weston and the GUI is not exactly fast.

* When I do `runqemu slirp kvm gtk`, it throws the following error: `runqemu - ERROR - Failed to run qemu: qemu-system-x86_64: Display 'gtk' is not available.`
* `runqemu slirp kvm sdl` works, but the weston GUI does not seem to be accelerated.
* `runqemu slirp kvm sdl gl` emits the following: `runqemu - ERROR - Failed to run qemu: qemu-system-x86_64: OpenGL support is disabled`

Below I'm posting a snippet of `poky/scripts/runqemu` to have at hand the qemu options enabled by the runqemu options mentioned above:
```
elif arg == 'sdl':
if 'gl' in sys.argv[1:]:
self.qemu_opt_script += ' -vga virtio -display sdl,gl=on'
elif 'gl-es' in sys.argv[1:]:
self.qemu_opt_script += ' -vga virtio -display sdl,gl=es'
else:
self.qemu_opt_script += ' -display sdl'
elif arg == 'gtk':
if 'gl' in sys.argv[1:]:
self.qemu_opt_script += ' -vga virtio -display gtk,gl=on'
elif 'gl-es' in sys.argv[1:]:
self.qemu_opt_script += ' -vga virtio -display gtk,gl=es'
else:
self.qemu_opt_script += ' -display gtk'
```

Kind regards,
Manuel