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。Vulkan 是 Khronos 推出的底层图形与计算 API,内容涵盖从最基础的三角形到 PBR、延迟渲染和硬件光线追踪。
这是一个应用还是多个独立的演示?它不是单个应用,而是几十个独立的 C++ 示例程序,每个程序演示一项具体的 Vulkan 功能(如纹理、阴影、计算着色器等),可以从 bin 目录中单独构建和运行。
我该如何构建和运行这些示例?使用递归方式克隆仓库以拉取子模块,然后按照 BUILD.md 中针对你所用平台的说明,使用支持 C++20 的编译器进行构建;构建完成后,可从 bin 目录运行任意示例的可执行文件(加上 --help 可查看其选项)。
构建前需要准备什么?一个兼容 C++20 的编译器,以及你所用平台的 Vulkan SDK 和驱动程序;外部依赖和资源文件会通过 git 子模块自动获取。
运行示例时有什么要注意的吗?部分示例需要特定的设备功能;在多 GPU 机器上,你可能需要使用 -gl 和 -g 参数来选择真正支持这些功能的 GPU。另外,作者现在大多将新示例添加到 Khronos 官方的 Vulkan Samples 仓库中,而不是这里。
这些示例可以在哪些平台上构建?支持 Windows、Android、iOS 和 macOS(通过 MoltenVK),各平台的构建步骤均记录在 BUILD.md 中。
这些示例可以使用哪些着色器语言?大多数示例使用 GLSL 编写,它是这里的主要着色语言;同时,相同的着色器还提供了 Slang 和 HLSL 版本,方便你对比这三种语言。
既然有 Khronos 官方示例,为什么还要维护这个仓库?作者曾协助搭建 Khronos 官方 Vulkan Samples 仓库,现在主要在那里贡献代码;但仍继续维护这个较早的合集,用于收录不适合放进官方仓库的示例。
这些示例涵盖哪些技术?内容从描述符集、纹理映射等基础知识,到阴影贴图、基于图像的光照 PBR、延迟渲染、计算着色器、曲面细分、硬件光线追踪以及 glTF 2.0 模型加载等进阶主题。
在多 GPU 的机器上,如何选择示例使用哪块 GPU?使用 -gl 参数运行示例以列出可用的 GPU,然后使用 -g 参数选择支持所需设备功能的那一块。
Size
223.4 MB
Stars
12.2K
Updated
CommitOct 10
Age
11y
Commits · 90 Days