Skip to content

Use RI in your project

RI is meant to be pulled into another repository as a git submodule and added with add_subdirectory. When included as a subproject, RI does not rewrite your cached compiler flags, and it leaves clang-tidy and sanitizers disabled unless you enable them.

1. Add the submodule

git submodule add https://github.com/Raven33/EquineRI.git external/EquineRI
git submodule update --init --recursive    # RI's own submodules: Vulkan-Headers, volk, ...

2. CMake

cmake_minimum_required(VERSION 3.25)
project(MyApp LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)

# Pick the backend(s) before adding RI. D3D12 is Windows only.
set(EQUINE_VULKAN_BACKEND ON)
# set(EQUINE_D3D12_BACKEND ON)
# set(EQUINE_VALIDATION ON)   # native layers + RI's checks: use it in debug builds
add_subdirectory(external/EquineRI)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE EquineVulkanBackend EquineHelpersVulkan)
# D3D12: target_link_libraries(my_app PRIVATE EquineD3D12Backend EquineHelpersD3D12)
#        and the Agility SDK steps of section 4.

# Compile shaders with RI's rule (SPIR-V and DXIL) at build time.
equine_add_shaders(my_app PROFILE cs_6_6 SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/shaders/fill.hlsl")

With a checkout outside your source tree, give add_subdirectory a binary folder too: add_subdirectory(<path to EquineRI> EquineRI).

Windows runtime library: as a subproject without sanitizers, RI inherits your project's MSVC runtime library (CMake defaults to /MDd in Debug and /MD in Release). If you enable EQUINE_SANITIZERS, RI sets CMAKE_MSVC_RUNTIME_LIBRARY to MultiThreadedDLL (required by clang-cl's AddressSanitizer), so set CMAKE_MSVC_RUNTIME_LIBRARY to MultiThreadedDLL in your project as well so both sides link.

Each backend is a separate static library (EquineVulkanBackend or EquineD3D12Backend) that selects its backend at compile time, so you cannot link both into the same executable. To target both backends, define one executable target per backend and link each to its own backend library.

Option Default as a subproject Meaning
EQUINE_VULKAN_BACKEND, EQUINE_D3D12_BACKEND OFF The backends to build (EQUINE_D3D12_BACKEND is Windows-only).
EQUINE_VALIDATION OFF Native validation layers and RI's own checks (validation).
EQUINE_BUILD_HELPERS ON Builds the helpers (EquineHelpersVulkan and EquineHelpersD3D12). RI ships no window library, so bring your own (RI::Window).
EQUINE_SANITIZERS OFF Enables AddressSanitizer and UndefinedBehaviorSanitizer on RI's code; enable them for your whole build too so the sanitizer runtimes link cleanly.
EQUINE_CLANG_TIDY OFF Runs clang-tidy on RI's sources.
EQUINE_BUILD_TESTS, EQUINE_BUILD_SAMPLES, EQUINE_BUILD_DOC_SNIPPETS OFF Builds RI's own tests, samples, and doc snippets.

3. Shaders

equine_add_shaders(<target> PROFILE <profile> SOURCES <files>) compiles each shader at build time using the pinned DXC release (downloaded at configure time). For standard shader profiles, it outputs both <name>.spv and <name>.dxil into shaders/ inside your top-level build directory regardless of which backend is enabled, and defines EQUINE_SHADER_DIR on <target> with that directory path. Library profiles (lib_*, such as lib_6_8 for work graphs) are D3D12-only and compile to .dxil only.

Load the .spv or .dxil file matching your active backend and pass its bytecode to createComputePipeline or createGraphicsPipeline. Shaders can include <equine/root.hlsli> to declare root data with EQ_ROOT_DATA (compiling shaders). To compile shaders at run time instead, use the shader compiler helper.

4. D3D12 executables: the Agility SDK

D3D12 loads RI's Agility SDK only when the executable exports two symbols. In exactly one .cpp of each D3D12 executable, at namespace scope:

#include <D3D12AgilityExports.hpp>
EQUINE_D3D12_AGILITY_SDK_EXPORTS()

and in CMake:

equine_deploy_agility_sdk(my_app)   # copies the runtime to <exe dir>/D3D12/

If either step is missing, Windows loads the system D3D12 runtime instead of the pinned Agility SDK, which can cause listGpus to return no GPUs. Either way, listGpus prints [EquineRI] Agility SDK not loaded … to stderr, naming the missing step.

Next

Your first compute dispatch walks through a complete program.