QEMU Support For Rendering Vulkan Software On The Hosts GPU In Virtual Machines Using Virgil 3D Is Underway
It is currently possible to run OpenGL applications in virtual Linux machines in QEMU and have the rendering done on the host machine's GPU. It works, and it is faster than software rendering within the virtual machine, but it is not blazing fast. It will eventually be possible to render Vulkan software the exact same way.
written by 윤채경 (Yoon Chae-kyung) 2021-03-27 - last edited 2021-03-29. © CC BY
Virgil enabled on Gentoo Linux in a QEMU virtual machine benchmarking glmark2 performance.
Virgil 3d is a collection of software for range of components such as the Linux kernel, the Mesa graphics library and the QEMU virtual machine. It can be used to run software using OpenGL rendering at a not-grinding-halt pace in a virtual Linux machine on a Linux host. It can also be used to run Linux-native OpenGL applications on Google's Chrome OS.
What You Need[edit]
The QEMU emulator has had support for Virgil for years. You do not need anything in particular to use Virgil 3d, it has built-in support. It can be enabled by running it with the virtio
display driver and GL rendering.
qemu-kvm -vga virtio -display gtk,gl=on {more options}
Kernel support within the virtual machine is required to make it work. The Linux kernel has had support for a very long time. It has to be enabled with the CONFIG_DRM_VIRTIO_GPU
configuration option.
There will be some incriminating evidence in the kernel ring buffer (dmesg
) on Linux installations running within a virtual machine if virtio-vga
is working:
[drm] pci: virtio-vga detected at 0000:00:02.0
virtio-pci 0000:00:02.0: vgaarb: deactivate vga console
[drm] features: +virgl +edid
[drm] Initialized virtio_gpu 0.1.0 0 for virtio0 on minor 0
virtio_gpu virtio0: fb0: virtio_gpudrmfb frame buffer device
Virgil is also supported by the Mesa graphics library. The Mesa library within the virtual machine needs to have the virgl
driver compiled in. It is included in a package named something like mesa-dri-drivers
on most distributions. Gentoo Linux needs VIDEO_CARDS=virgl
when compiling media-libs/mesa
.
What You Get[edit]
Virgil 3D performance on Gentoo Linux in a QEMU virtual machine benchmarked by glmark2.
glmark2 is not the world's best or most versatile benchmarking tool, but it can produce some simple numbers for a quick comparison. glmark -l
will list all the built-in scenes it has so you can run glmark2 --benchmark scenename
if you do not want to run all of them.
glmark2 --benchmark terrain -s 1920x1050
produces widely different scores on a decent 6-core machine with a AMD RX 570 depending on what it is running on. The bare metal score is a tad higher than the score produced within a QEMU virtual machine with Virgil 3D enabled.
The jellyfish
scene produces similarly dismal results.
So What's The Point?[edit]
The Virgil 3D GPU project, with a very sparse website at virgil3d.github.io, is clearly not something you can use to run demanding OpenGL games on a Linux distribution running in a QEMU virtual machine. It is not an alternative to running virtual machines with GPU pass-through where the virtual machine has sole access to a GPU. However, it does have a purpose which becomes clear if you look at the following graph:
The difference between 516 fps native and 60 using virgl in QEMU is huge. The difference between virgl and software rendering using llvmpipe is equally huge. Virgil 3D may not be good enough for most games, but it is good enough to run very simple OpenGL applications with some sparse GPU acceleration.
Vulkan Support Is Coming[edit]
Virgil 3D can currently only be used to run OpenGL applications. That's about to change. Google-employed software engineer Chia-I Wu is working on a virtio-gpu Vulkan driver. It is already at a state where it can be tested using the "VirGL virtual OpenGL renderer" virglrenderer
- which, dispite the name, can be used to render Vulkan too if you apply the right virglrenderer patches and compile it yourself. You will also have to compile a custom Mesa build with Chia-I Wus Mesa virtio-gpu Vulkan driver patches.
Google isn't funding Wu to work on this because they want GNU/Linux desktop users to be able to run Vulkan in virtual Linux machines in QEMU, they are doing it because their Chrome OS needs it to run Linux software using Vulkan. Wus work will eventually make it possible to run Windows games from Steam (thanks to Wine/Proton) on Chromebooks.
The good news for GNU/Linux users is that it won't be very hard to add Vulkan rendering support to QEMU once the required puzzle-pieces are in place in the Mesa graphics library.
GNU/Linux users will probably be able to use QEMU to run Vulkan applications on Linux distributions in virtual machines in a year or so. The foundation is laid, but there is still much work to be done, so don't expect that virgil Vulkan support will arrive next week or next month.
Enable comment auto-refresher
Intgr
Permalink |
Chaekyung
Intgr
Anonymous (143964cfd7)
Permalink |