vkFast

vkFast is a fully open source Vulkan 1.0-based GPU API inspired by OpenGL 1.4 display lists and Mantle API.

thumb

A full-blown step-by-step video tutorial on how to use vkFast is here! 😅 Go watch it!

https://www.youtube.com/watch?v=XYz3erNX5VM

Another video tutorial on how to printf in GPU compute shaders in vkFast on Linux:

https://www.youtube.com/watch?v=mlU35k1CufY

Tested on real hardware

The examples are tested on Intel i3 12100 CPU and Nvidia RTX 2060 (Turing) GPU, AMD Radeon Pro V520 (RDNA 1.0) GPU, AMD Radeon RX 550 (GCN 4.0, 2gb model) GPU, Intel Arc B580 GPU and Intel UHD Graphics 730 iGPU.

Install instructions for Windows 10+

Open a PowerShell terminal window and run the following command to install Git:

winget install --id Git.Git -e --source winget

Then run the following command to install Visual Studio Community 2019 and cl C/C++ compiler:

winget install --id Microsoft.VisualStudio.2019.Community --override "--passive --wait --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended"

Re-run the PowerShell terminal for git command to work, and clone the following REDGPU SDK repositories like this:

git clone https://github.com/redgpu/redgpu --depth 1
git clone https://github.com/redgpu/redgpu2 --depth 1

Copy RedGpuSDK folders from both redgpu and redgpu2 folders we just cloned to the C:\ drive:

Get-ChildItem -Path "redgpu\RedGpuSDK\*" | Copy-Item -Destination "C:\RedGpuSDK\" -Recurse -Force
Get-ChildItem -Path "redgpu2\RedGpuSDK\*" | Copy-Item -Destination "C:\RedGpuSDK\" -Recurse -Force

And now you can open and run in Visual Studio Community 2019 the .vcxproj files from the examples folder, like this:

Start-Process "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe" '"vkfast\examples\02 150 Lines Of Code\vs2019\main.vcxproj"'

Install instructions for Ubuntu

First, open a terminal and run:

sudo apt install build-essential procps curl file git

Then go to https://brew.sh/ and install Homebrew.

DO NOT CLOSE THE TERMINAL when brew will be finished installing! You'll see similar to the following commands that you need to run:

echo >> ~/.bashrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> ~/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"

Run brew help to see if Homebrew was installed successfully.

Then run the following command to make /home/linuxbrew/ folder writable:

sudo chown -R $(whoami):$(id -g) /home/linuxbrew

You also need the latest REDGPU SDK placed in /home/linuxbrew/ folder, you can do it like so:

git clone https://github.com/redgpu/redgpu --depth 1
git clone https://github.com/redgpu/redgpu2 --depth 1
cp -r redgpu/RedGpuSDK/ /home/linuxbrew/
cp -r redgpu2/RedGpuSDK/ /home/linuxbrew/

To compile and run the examples/00 Hello Compute/main.c file, install these dependencies with brew:

brew install libx11 vulkan-loader

A note on "No Padding" struct members combinations

Here are all the 6 ways to perfectly pack a 16-byte window with zero wasted space:

32-bit scalars:

  • float a; float b; float c; float d;

vec2:

  • vec2 ab; float c; float d;
  • float a; float b; vec2 cd;
  • vec2 ab; vec2 cd;

vec3:

  • vec3 abc; float d;

vec4:

  • vec4 abcd;