Vulkan SDK on Rpi 4

Does anyone know how to get the SDK for RPi4? I imagine someone would have to compile it themselves as it is not offered on the main downloads page. My long-term goal is to get vkQuake 2 (https://github.com/kondrak/vkQuake2) built on my Pi 4, but it depends on the Vulkan SDK to build, and I can’t seem to find anyone that has gotten it working on the Pi to ask how they compiled (either without the SDK or by making it themselves?). Any help would be appreciated!

There’s no need for the Vulkan SDK to built vkQuake2. It only requires the Vulkan headers and loader, which can be built manually from source.

So to get this working on the Pi you only need:

And then:

  • Build the loader for the Pi
  • Change the vulkan-1.lib include to the vulkan-1.lib built from the loader repo
  • Change the include path to your copy of the Vulkan header repo

Thanks for the info. Would someone be willing to hold my hand through building Vulkan-Loader? The headers compiled with no fuss, but when I tried to build the loader (making sure to point to the headers)

cmake -DVULKAN_HEADERS_INSTALL_DIR=/home/pi/Vulkan-Headers/build/install …

and I try to run the tests,

./run_all_tests.sh
./run_loader_tests.sh: line 136: ./vk_loader_validation_tests: No such file or directory

It is returning this error. I installed to the best of my knowledge the Google Test framework, but obviously I am doing something wrong.

I am sorry if I am a noob, but I am trying to learn as fast as possible… I am also confused by the instruction “Change the vulkan-1.lib include to the vulkan-1.lib built from the loader repo”. There are some basics I am failing to grasp. I would be grateful for any help. Here is basically what I have already tried in a nutshell:

Install cmake and git (tools we will need)
1 - get cmake
sudo apt-get install cmake -y
2 - get vulkan headers to build
a. get “git” = sudo apt-get install git
3. clone Vulkan-Headers
cd~
git clone GitHub - KhronosGroup/Vulkan-Headers: Vulkan header files and API registry
install vulkan headers:
build instructions:
cd Vulkan-Headers
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install …
make install

Build Vulkan-Loader
get all required dependancies : sudo apt-get install git build-essential libx11-xcb-dev
libxkbcommon-dev libwayland-dev libxrandr-dev
cd~
git clone GitHub - KhronosGroup/Vulkan-Loader: Vulkan Loader
cmake -DVULKAN_HEADERS_INSTALL_DIR=/home/pi/Vulkan-Headers/build/install …
make -j4

Okay, so I think I have successfully compiled Vulkan-Loader… but I am still a bit lost. here is the steps line by line that I took and some notes as to the intention behind them, also, I have a bunch of failures generated by the “run_all_tests.sh” script from the Vulkan-Loader/build/tests folder. I am still too new on the forums to do a direct link but hopefully this will do: "pastebin “dot " com / RwPGkT7A”

Step 1: Getting Vulkan-Headers

Get cmake:

sudo apt-get install cmake -y

Get “git”:

sudo apt-get install git -y

Clone Vulkan-Headers Github:

cd ~
git clone https://github.com/KhronosGroup/Vulkan-Headers

Create Vulkan-Headers makefile:

cd ~
cd Vulkan-Headers
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install ..

compile Vulkan-Headers

make install

Note that Vulkan-Headers install folder is “/home/pi/Vulkan-Headers/build/install”

Step 2: Getting Vulkan-Loader
Get all required dependancies for Vulkan-Loader:

sudo apt-get install git build-essential libx11-xcb-dev \
    libxkbcommon-dev libwayland-dev libxrandr-dev

Clone Vulkan-Loader Github:

cd ~
git clone https://github.com/KhronosGroup/Vulkan-Headers

Clone Google Test Github:

cd ~/Vulkan-Loader
git clone https://github.com/google/googletest.git external/googletest
cd external/googletest
git checkout tags/release-1.8.1

Create Vulkan-Loader makefile:

cd ~/Vulkan-Loader
mkdir build
cd build

Note that -DVULKAN_HEADERS_INSTALL_DIR=/home/pi/Vulkan-Headers/build/install
and that -CMAKE_BUILD_TYPE=Release

cmake -DCMAKE_BUILD_TYPE=Release \
      -DVULKAN_HEADERS_INSTALL_DIR=/home/pi/Vulkan-Headers/build/install \
      -DCMAKE_INSTALL_PREFIX=install .. 

Compile Vulkan-Loader:

sudo make -j4

Note that sudo or no sudo on compiling Vulkan-Loader doesn’t seem to change test outcome?

Running test script:

cd tests
./run_all_tests.sh

Output of test here: "pastebin “dot " com / RwPGkT7A”

it looks like vkQuake 2 needs to link to these directories it refers to from the Vulkan SDK… I’m not sure how to resolve this with the output files and folders from Vulkan-Headers…

vkQuake 2 compiling instructions wants to add these lines to ~/.bashrc:

export VULKAN_SDK=/home/user/VulkanSDK/1.2.148.1/x86_64
export PATH=$VULKAN_SDK/bin:$PATH
export LD_LIBRARY_PATH=$VULKAN_SDK/lib:$LD_LIBRARY_PATH
export VK_LAYER_PATH=$VULKAN_SDK/etc/explicit_layer.d

Looking at the Linux make file, the easiest way seems to mimic the SDK structure. Just create a dummy SDK folder, point $VULKAN_SDK to that folder and put the required files where the make file expects them:

  • The loader’s .lib in $VULKAN_SDK\lib or $VULKAN_SDK\lib64 (depending on your target)
  • The headers in $VULKAN_SDK\include

The other option would be changing the Makefile to point at other directories.

It looks like the only output files generated by Vulkan-Loader are:

libvulkan.so
libvulkan.so.1
libvulkan.so.1.2.165

am I missing something, or does it generate “The loader’s .lib” in another directory? I can’t seem to locate any .lib’s associated with the build. Thank you for your help, I feel like I am missing something obvious.

Also, should I be concerned about what the built in test is failing?

  1. [----------] Global test environment tear-down

    1. [==========] 39 tests from 14 test cases ran. (540 ms total)

    2. [ PASSED ] 18 tests.

    3. [ FAILED ] 21 tests, listed below:

    4. [ FAILED ] CreateInstance.LayerPresent

    5. [ FAILED ] EnumeratePhysicalDevices.OneCall

    6. [ FAILED ] EnumeratePhysicalDevices.TwoCall

    7. [ FAILED ] EnumeratePhysicalDevices.MatchOneAndTwoCallNumbers

    8. [ FAILED ] EnumeratePhysicalDevices.TwoCallIncomplete

    9. [ FAILED ] EnumerateDeviceLayers.LayersMatch

    10. [ FAILED ] CreateDevice.ExtensionNotPresent

    11. [ FAILED ] CreateDevice.LayersNotPresent

    12. [ FAILED ] EnumerateDeviceLayerProperties.PropertyCountLessThanAvailable

    13. [ FAILED ] EnumerateDeviceExtensionProperties.PropertyCountLessThanAvailable

    14. [ FAILED ] EnumerateDeviceExtensionProperties.DeviceExtensionEnumerated

    15. [ FAILED ] WrapObjects.Insert

    16. [ FAILED ] Allocation.EnumeratePhysicalDevices

    17. [ FAILED ] Allocation.InstanceAndDevice

    18. [ FAILED ] Allocation.InstanceButNotDevice

    19. [ FAILED ] Allocation.DeviceButNotInstance

    20. [ FAILED ] Allocation.CreateDeviceIntentionalAllocFail

    21. [ FAILED ] Allocation.CreateInstanceDeviceIntentionalAllocFail

    22. [ FAILED ] EnumeratePhysicalDeviceGroupsKHR.OneCall

    23. [ FAILED ] EnumeratePhysicalDeviceGroupsKHR.TwoCall

    24. [ FAILED ] EnumeratePhysicalDeviceGroupsKHR.TwoCallIncomplete

    • 21 FAILED TESTS
    1. Environment Variable Path test PASSED

    2. CreateInstance insertion test FAILED - test layer not detected in instance layers

Sorry, mixed up Windows and Linux. The output files you posted are the loader stubs, so that should be the one you need to point the linker too. Or use the install target and have them put into your LD_PATH should work too afaik.

As for the test failures: Just ignore them. The loader is mostly a stub, that passes calls to the driver.

Do you think this would work?

# export LD_LIBRARY_PATH=/home/pi/Vulkan-Loader/build/loader
# export VK_LAYER_PATH=/home/pi/Vulkan-Headers/build/install/include/vulkan

VK_LAYER_PATH isn’t used by the makefile. But it checks $(VULKAN_SDK)/include for the headers. So it’s probably easiest to set VULKAN_SDK to the path where you put the headers.

Thanks for the reply. I’m sorry, but I’m struggling to understand. From your previous instructions, I have two “builds” and output files for the Headers and Loaders.

loader:
/home/pi/Vulkan-Loader/build/loader
this is the directory that has libvulkan.so,libvulkan.so.1 and libvulkan.so.1.2.165
and

headers:
/home/pi/Vulkan-Headers/build/install/include/vulkan
this includes a bunch of .h files, including “vulkan_core.h”

If I am understanding, you are saying the buildfile is looking for “$(VULKAN_SDK)/include” for the headers, and the “LD_PATH” is where the makefile is looking for the loaders. I may be wrong about this, but trying to follow along. I understand that the goal is to configure my directories and export(s) correctly for this to make sense to the make file.

I think my confusion is coming from having two directory locations, but four export lines to make sense of.

Looking at what exports the instructions call for,
export VULKAN_SDK=/home/user/VulkanSDK/1.2.148.1/x86_64
is this the call that is going to reference the location of the loader? If so,

export PATH=$VULKAN_SDK/bin:$PATH
what does the make file want at “$VULKAN_SDK/bin”?

export LD_LIBRARY_PATH=$VULKAN_SDK/lib:$LD_LIBRARY_PATH
and at “$VULKAN_SDK/lib?”

export VK_LAYER_PATH=$VULKAN_SDK/etc/explicit_layer.d
the last one looks like it is calling a specific file?

sorry if this is making you re-explain things, I am just trying to understand to the best of my ability.

Said more simply, if I were to mimic the directory structure for the files it is looking for, how would I arrange the files and directories for the makefile to find all it is looking for?
Example:

“export VULKAN_SDK=/home/pi/vulkanbuildfiles”
/home/pi/vulkanbuildfiles
/home/pi/vulkanbuildfiles/lib/ === put library files here?
/home/pi/vulkanbuildfiles/include/ === put headers here?
/home/pi/vulkanbuildfiles/bin/ === ??
/home/pi/vulkanbuildfiles/etc/ == ??

Judging by the Linux make file you only need the lib and include paths. So your above layout should work. Layers e.g. can be ignored if you don’t want to run with validation enabled.

1 Like

I’m getting some errors. This might be out of the scope of this thread, but

pi@raspberrypi:~/vkQuake2/linux/releasearmv7l $ ./quake2
couldn't exec default.cfg
couldn't exec config.cfg
Console initialized.

------- sound initialization -------
Setting up ALSA driver .....
Low Performance 11KHz.
sound sampling rate: 11025
------------------------------------
------- Loading ref_vk.so -------
LoadLibrary("/home/pi/vkQuake2/linux/releasearmv7l/ref_vk.so")
ref_vk version: Vulkan (vkQuake2 v1.5.5)
Initializing Vulkan display
...setting mode 11: 1920 1080
Using XFree86-VidModeExtension Version 2.2
Enabled extensions: VK_KHR_surface VK_KHR_xlib_surface 
...created Vulkan instance
...created Vulkan surface
...found 1 Vulkan-capable device(s)
./quake2: symbol lookup error: /home/pi/vkQuake2/linux/releasearmv7l/ref_vk.so: undefined symbol: __atomic_store_8

That error sounds like either the project or the Vulkan implementation was compiled without support for atomics.

What is atomics? any clues as to how to correct for this?

It’s a compiler feature (atomic operations). You may need to link against the atomic library, usually -latomic.

I am trying to build the headers, loader and vkQuake2 with that flag. I’ll see if it helps.

This didn’t seem to make a difference unfortunately.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.