Trying RetroArch with the Rpi4 VULKAN driver (Rpi OS 64bit)

Hi there!

This is a bit ahead of time, but I believe it’s about time to start trying, because I have high hopes in VULKAN for Pi4 performance. So let’s go:

Install dependencies (most notably, the MESON build system, Vulkan loader and headers):

sudo apt-get install --no-install-recommends flex bison python3-mako python3-setuptools libexpat1-dev libudev-dev gettext ca-certificates xz-utils  zlib1g-dev pkg-config meson libvulkan-dev libvulkan1 glslang-dev spirv-tools

Get libDRM, configure, build and install:


tar xvzpf libdrm-2.4.100.tar.gz
cd libdrm-2.4.102
mkdir build
cd build

CFLAGS="-O2 -march=armv8-a+crc+simd -mtune=cortex-a72" CXXFLAGS="-O2 -march=armv8-a+crc+simd -mtune=cortex-a72" meson -Dudev=true -Dvc4=true -Dintel=false -Dvmwgfx=false -Dradeon=false -Damdgpu=false -Dnouveau=false -Dfreedreno=false -Dinstall-test-programs=true ..

ninja -j4
sudo ninja install

Get MESA with v3dv VULKAN support, configure, build and install:

git clone mesa -b wip/igalia/v3dv --depth 1

cd mesa

mkdir build

cd build

CFLAGS="-O2 -march=armv8-a+crc+simd -mtune=cortex-a72" CXXFLAGS="-O2 -march=armv8-a+crc+simd -mtune=cortex-a72" meson -Dudev=true -Dplatforms=drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,vc4,kmsro -Dglx=disabled -Dinstall-test-programs=true -Dbuildtype=release --libdir lib ..

ninja -j4
sudo ninja install

Small “fix” so RA finds the headers it needs: sudo cp -R /usr/include/glslang/SPIRV

Configure RA for VULKAN:

CFLAGS="-O2 -march=armv8-a+crc+simd -mtune=cortex-a72 -DEGL_NO_X11" CXXFLAGS="-O2 -march=armv8-a+crc+simd -mtune=cortex-a72 -DEGL_NO_X11" ./configure --disable-ibxm --disable-vg --disable-x11 --disable-wayland --disable-sdl2 --disable-al --disable-cheevos --disable-ffmpeg --disable-networking --disable-netplaydiscovery --disable-libretrodb --enable-udev --disable-sdl --disable-pulse --disable-oss --disable-freetype --disable-7zip --disable-imageviewer --disable-rjpeg --disable-rbmp --disable-rtga --disable-flac --disable-qt --disable-materialui --disable-xmb --enable-rgui --disable-ozone --disable-gfx_widgets --disable-langextra --disable-cdrom --disable-accessibility --disable-tinyalsa --disable-builtinglslang --disable-rpiled --enable-vulkan

Export the filenames json location so the Vulkan loader can locate the Vulkan library (this could well go into /etc/profile por permanent fix)

export VK_ICD_FILENAMES=/usr/local/share/vulkan/icd.d/broadcom_icd.aarch64.json

However, RA refuses to run:

[email protected]:~/src/libretro/RetroArch-1.9.0 $ retroarch -v
[INFO] === Build =======================================
[INFO] Capabilities:  ASIMD
[INFO] Built: Oct  9 2020
[INFO] Version: 1.9.0
[INFO] =================================================
[INFO] [Overrides]: Redirecting save file to "/home/pi/.config/retroarch/saves/.srm".
[INFO] [Overrides]: Redirecting save state to "/home/pi/.config/retroarch/states/.state".
[INFO] Version of libretro API: 1
[INFO] Compiled against API: 1
[INFO] [Audio]: Set audio input rate to: 48000.00 Hz.
[INFO] [Video]: Video @ fullscreen
[INFO] [Vulkan]: Vulkan dynamic library loaded.
[ERROR] [Vulkan]: Could not find instance extensions. Will attempt without them.
[INFO] [Vulkan]: Found vulkan context: khr_display
[INFO] [Vulkan]: Detecting screen resolution 0x0.
[ERROR] [Vulkan]: Failed to enumerate physical devices.
[ERROR] [Vulkan]: Failed to create KHR_display surface.
[ERROR] [Vulkan]: Failed to set video mode.
[ERROR] [Video]: Cannot open video driver ... Exiting ...
[ERROR] Fatal error received in: "init_video()"

Any ideas on why it fails at this point?

1 Like

That usually just means the driver isn’t exposing some things it needs.

You are missing vulkan loader with headers


Aren’t those provided by the libvulkan-dev and libvulkan1 packages I mention in the dependencies?

That’s correct :+1: try adding Wayland

What does wayland to do with all this?? MESA Vulkan implementation has been built with drm platform support, no need for a graphics server, no X or Wayland is supposed to be needed here.

Try adding video_driver = “vulkan” to /storage/.config/retroarch/retroarch.cfg replacing the existing one

That’s what I am doing to select the Vulkan driver. I couldn’t have tried it if I hadn’t.

Just in case someone else is trying this, in retroarch.cfg I have these with no success:

video_driver = "vulkan"
video_context_driver = "khr_display"

@hunterk In this thread:

…you talk about khr_display which is, as far as I can understand, the glue for VULKAN on KMS. This khr_display is supposed to be implemented in MESA Vulkan drivers, isn’t it? So Vulkan-Loader should be for windowing enviroments like Mac, Windows or X11, right?