Build and test¶
This page takes you from a fresh clone to a passing test run. EquineRI builds with CMake and Ninja, with clang on Linux (Vulkan backend) and clang-cl on Windows (Vulkan and D3D12 backends).
1. Install the tools¶
- CMake 3.25 or newer, and Ninja.
- clang and clang-tidy (every standalone build runs clang-tidy, and configuring fails if it is missing).
- The Vulkan loader (your distribution's
vulkan-icd-loader, or the Vulkan SDK). The Vulkan headers are included as a git submodule. - For validation builds (
clang-debug, or any build withEQUINE_VALIDATION=ON): the Khronos validation layer (vulkan-validation-layers, or the Vulkan SDK). Creating a device stops with an unsupported error ifVK_LAYER_KHRONOS_validationis missing. - A GPU driver with Vulkan 1.3, to run the GPU tests.
- CMake 3.25 or newer, Ninja, and LLVM (clang-cl and clang-tidy).
- The Vulkan SDK (for the Vulkan loader, and the validation layer in validation builds). The Vulkan headers are included as a git submodule.
- The Windows SDK. CMake downloads the Agility SDK (the newer D3D12 runtime) at configure time, so you do not install it yourself.
- A GPU driver with Vulkan 1.3 and D3D12 shader model 6.6, to run the GPU tests.
Configuring also downloads one pinned DirectX Shader Compiler (DXC) release to build the test shaders. The DXC download and the Windows Agility SDK download are each checked against a SHA-256 hash, so the first configure needs network access.
2. Get the sources¶
The Vulkan function loader volk and the other
third-party dependencies (Vulkan-Headers, SPIRV-Reflect, and glfw) are git
submodules:
In an existing clone, fetch them with git submodule update --init --recursive. Configuring
stops with an error telling you which submodule is missing if any have not been fetched.
3. Configure and build with a preset¶
The presets in CMakePresets.json hold every setting, so one name is enough. Each preset
builds into build/<preset>.
Run these from a terminal where clang-cl is on the PATH (on Windows, a Visual Studio
developer prompt works).
| Preset (Linux / Windows) | Build type | Validation | Sanitizers | Tests |
|---|---|---|---|---|
clang-debug / clangcl-debug |
Debug | on | on | yes |
clang-release / clangcl-release |
Release | off | on | no |
clang-bench / clangcl-bench |
Release | off | off | yes |
- Validation (
EQUINE_VALIDATION) turns on the native validation layers and RI's own checks; see Validation. - Sanitizers (AddressSanitizer and UndefinedBehaviorSanitizer) are on in every
configuration except the
benchpresets, which exist only for measuring performance.
4. Run the tests¶
On Windows, use clangcl-debug instead of clang-debug. The tests come in two groups:
- GPU-free tests (
ri.*): test the error channel, validation checks, and DXIL parsing. They run anywhere, including machines without a GPU. - GPU tests (
vk.*,d3d12.*,sample.compute_readback.*): run the backend tests and sample on your real GPU. They carry thegpulabel, so you can skip them with:
Some tests abort on purpose (for example, to check what an error message looks like). They still pass because CTest checks the message they print.
5. Use RI in your own code¶
Link the backend library and include one header:
RI::Device device = RI::createDevice({.gpu = chosen});
std::printf("Device created on %s\n", device.gpu.name.c_str());
<RI/RI.hpp> makes RI:: name the backend you linked.
Code that should run on both backends is compiled twice, once per backend, in separate targets. A D3D12 executable also exports the Agility SDK
symbols and deploys its runtime; see Use RI in your project for
the full subproject setup and D3D12 device creation
for the exports.
Optional: compile the documentation snippets¶
Every code example on this site is a complete source file under docs/site/snippets/. To
check that they all compile against your build:
The snippets are compiled, never run. D3D12 snippets are compiled only when the D3D12 backend is on (Windows).