Vulkan
C++ examples for the Vulkan graphics API
A large collection of self-contained C++ example programs for learning Vulkan GPU programming, covering topics from a basic triangle to ray tracing and physically-based rendering, with shaders in GLSL, HLSL, and Slang.
This repository is a large collection of working code examples for Vulkan, a low-level graphics and compute API developed by Khronos. Vulkan is used to write software that talks directly to a GPU, typically for games, simulations, or any application where high-performance rendering matters. Unlike higher-level graphics tools, Vulkan requires the programmer to handle many details manually, which gives more control over performance but makes it harder to learn.
The collection is organized into categories covering a wide range of topics. Basics examples start with a plain colored triangle and work up through textures, buffers, and rendering pipelines. More advanced sections cover physically-based rendering, deferred shading, compute shaders for non-graphics GPU work, geometry and tessellation shaders, hardware-accelerated ray tracing, and various visual effects. There are also examples focused on performance measurement and on using Vulkan extensions that add optional capabilities.
Each example is a self-contained C++ program. The shaders, which are the small programs that run on the GPU to control how things are drawn, are provided in three languages: GLSL, HLSL, and Slang. This makes the repository useful for comparing how the same effect is written in different shading languages. A Rust shader variant is maintained separately by the Rust GPU project.
Building the examples requires cloning the repository with its submodules included, because some dependencies and asset files are tracked as submodules. The code compiles on Windows, Android, iOS, and macOS. Once built, each example runs as a standalone program with command-line flags for resolution, fullscreen mode, GPU selection, and benchmark recording.
The author notes that Khronos, the organization behind Vulkan, now maintains its own official samples repository, and that most new samples from the author go there rather than here. This repository continues to receive maintenance and occasional additions that do not fit the official collection. The full README is longer than what was shown.
Where it fits
- Study a specific Vulkan topic, textures, deferred shading, ray tracing, by running the corresponding self-contained C++ example.
- Compare GLSL, HLSL, and Slang shader implementations side by side for the same visual effect.
- Build and run Vulkan examples on Windows, macOS, Android, or iOS to test cross-platform rendering code.
- Use the benchmark recording feature to measure GPU performance of specific rendering techniques.