Vulkan README

The project's README from github.com/SaschaWillems/Vulkan. As one markdown file: README.md.

Vulkan C++ examples and demos

A comprehensive collection of open source C++ examples for Vulkan®, the low-level graphics and compute API from Khronos.

Donate

Table of Contents

How to Vulkan in 2026

For an introduction on how to use Vulkan for graphics in 2026, see this repository. It's esp. helpful if you haven't done much with Vulkan (yet) and want to understand how Vulkan (and in turn these samples) work.

Official Khronos Vulkan Samples

Khronos has made an official Vulkan Samples repository available to the public (press release).

You can find this repository at https://github.com/KhronosGroup/Vulkan-Samples

As I've been involved with getting the official repository up and running, I'll be mostly contributing to that repository from now, but may still add samples that don't fit there in here and I'll of course continue to maintain these samples.

Cloning

This repository contains submodules for external dependencies and assets, so when doing a fresh clone you need to clone recursively:

git clone --recursive https://github.com/SaschaWillems/Vulkan.git

Existing repositories can be updated manually:

git submodule init
git submodule update

Building

The repository contains everything required to compile and build the examples on Windows, Android, iOS and macOS (using MoltenVK) using a C++ compiler that supports C++20.

See BUILD.md for details on how to build for the different platforms.

Running

Once built, examples can be run from the bin directory. The list of available command line options can be brought up with --help:

 --help: Show help
 -h, --height: Set window height
 -v, --validation: Enable validation layers
 -vs, --vsync: Enable V-Sync
 -f, --fullscreen: Start in fullscreen mode
 -w, --width: Set window width
 -s, --shaders: Select shader type to use (glsl, slang, hlsl)
 -g, --gpu: Select GPU to run on
 -gl, --listgpus: Display a list of available Vulkan devices
 -b, --benchmark: Run example in benchmark mode
 -bw, --benchwarmup: Set warmup time for benchmark mode in seconds
 -br, --benchruntime: Set duration time for benchmark mode in seconds
 -bf, --benchfilename: Set file name for benchmark results
 -bt, --benchframetimes: Save frame times to benchmark results file
 -bfs, --benchmarkframes: Only render the given number of frames
 -rp, --resourcepath: Set path for dir where assets and shaders folder is present

Note that some examples require specific device features, and if you are on a multi-gpu system you might need to use the -gl and -g to select a gpu that supports them.

Shaders

Vulkan consumes shaders in an intermediate representation called SPIR-V. This makes it possible to use different shader languages by compiling them to that bytecode format. The primary shader language used here is GLSL, most samples also come with slang and HLSL shader sources, making it easy to compare the differences between those shading languages. The Rust GPU project maintains Rust shader sources in a separate repo.

Examples

Basics

glTF

These samples show how implement different features of the glTF 2.0 3D format 3D transmission file format in detail.

Advanced

Performance

Physically Based Rendering

Physical based rendering as a lighting technique that achieves a more realistic and dynamic look by applying approximations of bidirectional reflectance distribution functions based on measured real-world material parameters and environment lighting.

Deferred

These examples use a deferred shading setup.

Compute Shader

All Vulkan implementations support compute shaders, a more generalized way of doing workloads on the GPU. These samples demonstrate how to use those compute shaders.

Geometry Shader

Tessellation Shader

Hardware accelerated ray tracing

Vulkan supports GPUs with dedicated hardware for ray tracing. These sampples show different parts of that functionality.

Headless

Examples that run one-time tasks and don't make use of visual output (no window system integration). These can be run in environments where no user interface is available (blog entry).

User Interface

Extensions

Vulkan is an extensible api with lots of functionality added by extensions. These samples demonstrate the usage of such extensions.

Note: Certain extensions may become core functionality for newer Vulkan versions. The samples will still work with these.

Effects

Assorted samples showing graphical effects not special to Vulkan.

Misc

Credits and Attributions

See CREDITS.md for additional credits and attributions.

Vulkan (SaschaWillems/Vulkan)

Searching Database…

12.2K ·GitHub
Что это такое?Большая коллекция примеров с открытым исходным кодом на C++ для Vulkan, низкоуровневого API для графики и вычислений от Khronos. Примеры охватывают всё: от простого треугольника до PBR, отложенного рендеринга и аппаратной трассировки лучей.
Это одно приложение или много отдельных демо?Это не единое приложение, а десятки самостоятельных примеров на C++. Каждый демонстрирует одну конкретную возможность Vulkan (текстуры, тени, вычислительные шейдеры и т. д.). Их собирают и запускают независимо друг от друга из каталога bin.
Как собрать и запустить примеры?Склонируйте репозиторий рекурсивно, чтобы подтянуть подмодули, затем соберите его компилятором с поддержкой C++20, следуя инструкциям в BUILD.md для вашей платформы. После сборки запустите любой исполняемый файл примера из каталога bin (передайте --help, чтобы увидеть его параметры).
Что нужно установить перед сборкой?Компилятор с поддержкой C++20, а также Vulkan SDK и драйверы для вашей платформы. Внешние зависимости и файлы ресурсов подтягиваются автоматически через git-подмодули.
Есть ли подводные камни при запуске примеров?Некоторым примерам нужны определённые возможности устройства. На машинах с несколькими GPU может понадобиться флаги -gl и -g, чтобы выбрать видеокарту, которая их поддерживает. Кроме того, автор теперь добавляет большинство новых примеров в официальный репозиторий Khronos Vulkan Samples, а не сюда.
На каких платформах можно собрать примеры?Поддерживаются Windows, Android, iOS и macOS (через MoltenVK). Шаги сборки для каждой платформы описаны в BUILD.md.
Какие языки шейдеров можно использовать с этими примерами?Большинство примеров написано на GLSL, основном языке шейдеров, который используется здесь. Кроме того, к ним прилагаются версии тех же шейдеров на Slang и HLSL, так что все три можно сравнить.
Зачем поддерживать этот репозиторий параллельно с официальными примерами Khronos?Автор помог создать официальный репозиторий Khronos Vulkan Samples и теперь в основном вносит вклад туда, но продолжает поддерживать эту более старую коллекцию для примеров, которые не вписываются в официальный репозиторий.
Какие техники охватывают примеры?Примеры охватывают от базовых вещей, таких как наборы дескрипторов и наложение текстур, до продвинутых тем: карты теней, PBR с освещением на основе изображений, отложенный рендеринг, вычислительные шейдеры, тесселяцию, аппаратную трассировку лучей и загрузку моделей glTF 2.0.
Как выбрать GPU для примера на машине с несколькими видеокартами?Запустите пример с флагом -gl, чтобы вывести список доступных GPU, затем используйте -g, чтобы выбрать тот, который поддерживает нужные возможности устройства.
Size
223.4 MB
Stars
12.2K
Updated
CommitOct 10
Age
11y
Commits · 90 Days