Today Hans-Kristian Arntzen (also known as Themaister) sent us a big pull request giving RetroArch complete Vulkan support, the new graphics library API that has been unveiled and released to the public today.
See the pull request here.
Features/what has been ported
- A full-featured graphics driver for Vulkan was written.
- It should be compatible with MaterialUI/XMB and the other hardware-accelerated menu drivers that were previously GL-only.
- Overlays should work through Vulkan. (by overlays we mean the gamepad overlays in RetroArch)
- Font rendering should work through Vulkan.
- Shader support. Vulkan support will mean some changes for shaders that will be unveiled later on.
- Asynchronous GPU recording.
- Libretro cores can be written against Vulkan as well. A test core was included for this in the repo, you can find it here.
Libretro cores that use Vulkan will require an additional header, libretro_vulkan.h.
If you want to play with this with the current drivers out today, here is a short tutorial. It assumes you are running Linux, you have a Vulkan-compatible driver installed for your graphics card, and it assumes you are running a Wayland window manager. It has been successfully tested on ARM Mali GPUs and Intel HD GPUs so far.
1 – First make sure you have the necessary Vulkan headers and libraries installed for your graphics card.
2 – We are assuming you are running Linux and you have Wayland setup. DRM/KMS and GLX support will come later.
3 – Download the latest source from RetroArch (the github repository can be found here), preferably by cloning the repository with your git client.
4 – Download all the necessary submodules by doing:
git submodule init
git submodule update
This will fetch glslang which you will need in order to compile the Vulkan bits.
5 – When inside the retroarch directory, run ‘configure’.
If Vulkan was detected, you should see the following line:
‘Checking function vkCreateInstance in -lvulkan … yes”
6 – Now run make in order to compile.
7 – Once compilation is done, try running the RetroArch executable. You might have to change the video driver directly in your retroarch.cfg file by searching for the line :
and changing it to :
video_driver = “vulkan”
8 – Start up the RetroArch executable you just compiled. Assuming you are running in Wayland and assuming your Vulkan driver is working, you should now be greeted by the menu.
Some additional instructions for Intel Mesa Vulkan users
We use Mesa’s vulkan branch for testing RetroArch with Vulkan on Intel HD GPUs. The Intel driver’s support for Ivy Bridge and Haswell is currently marked as ‘experimental’, so expect bugs with it until they improve the driver. Broadwell and Skylake should be stable.
Note – you might have to compile the driver specifically with Wayland support enabled – this is not guaranteed to be enabled by default (in fact, it seems to default to X11 support if you don’t specify anything).
To recompile it with Wayland support, run this command while inside the source directory –
./configure –with-gallium-drivers= –with-egl-platforms=wayland,x11 –with-dri-drivers=i965
After that, run make again to recompile the drivers. After it has finished, copy libvulkan.so and the symlink files to your system library directory.
EDIT: So far we have been able to reproduce the following issues while testing RetroArch with the Vulkan backend on Ivy Bridge and Haswell (the GPUs that currently are not fully supported by the driver and are marked as ‘experimental’) :
Ivy Bridge – crashes at an assertion :
anv_nir_lower_push_constants.c:47: lower_push_constants_block: Assertion ‘state->is_scalar’ failed.
Haswell – gets ingame but shows a black screen instead of the menu. However, by navigating blindly to select a game – or by directly launching a game from the commandline – it will still output graphics.
We will have to wait for further driver improvements for now before it’s possible to run RetroArch with Vulkan on these slightly older GPUs.
Compiling a Vulkan core
In case you have RetroArch setup with Vulkan, you can play any of the non-libretro GL based cores. But what about a libretro core that is specifically made for Vulkan? That can be done as well.
Themaister has made a Vulkan test core as a proof of concept. You can view the source here.
Follow these steps in order to compile it and test it on your device:
1 – Go to the retroarch source directory, go to cores/libretro-test-vulkan
2 – Run make inside the directory.
3 – If everything went well, it should create a file called ‘testvulkan_libretro.so’. Move this file to the directory containing all your other libretro cores.
4 – Start up RetroArch, go to Load Core. Select the Vulkan test core. Select ‘Start Core’.