Skip to content

Debugging

EquineRI provides debugging aids that range from always-on object names and command markers to validation-only crash diagnostics, shader printf, and GPU-assisted validation.

Always on: names and markers

Object names and command markers are active in every build, including release builds. Give objects a name at creation or rename them with RI::setName, and group commands into nested regions with RI::cmdBeginMarker and RI::cmdEndMarker. GPU debuggers (RenderDoc, PIX, Nsight) and validation messages then show those names instead of raw handles: see RI::setName, RI::cmdBeginMarker.

// Names appear in RenderDoc, PIX, Nsight and in validation messages. Give
// them at creation: in the desc, or as the last argument where there is none.
RI::Memory memory = RI::allocateMemory(device, RI::MemoryKind::eGPU, 1 << 20, nullptr, "scene memory");
RI::Buffer particles = RI::createBuffer(
    device, memory, 0, {.size = 4096, .usage = RI::BufferUsage::eCopyDst, .name = "particles"});
RI::CommandList cmd = RI::createCommandList(device, "frame commands");
// setName renames, for example a command list reused for another pass.
RI::setName(device, cmd, "frame 1 commands");

Validation builds: crash diagnostics

When the GPU crashes (for example from a hang or a page fault caused by an invalid address or index), the next queue submission, wait, or swapchain operation reports a device lost error on the error channel. In a validation build, the error message also includes backend diagnostic details:

  • D3D12: Device Removed Extended Data (DRED) is enabled. The message lists each command list that did not finish—showing how many of its operations completed and the next operation—and, for a page fault, the faulting GPU address together with any existing or recently freed allocations at that address. Both command lists and allocations appear under the names you gave them.
  • Vulkan: VK_EXT_device_fault is enabled when the GPU supports it. The message includes the driver's description, any faulting addresses, and vendor-specific fault details.

Validation builds: shader printf (Vulkan)

On Vulkan, printf in a shader prints to standard output in validation builds through the validation layer (printf_enable and printf_to_stdout). DXIL does not support printf yet, so guard the call for SPIR-V:

#ifdef __spirv__
    printf("pixel %u %u: depth %f", id.x, id.y, depth);
#endif

A buffer-backed D3D12 version is planned as a helper. In release builds, the validation layer is not loaded, so the call still compiles on Vulkan but prints nothing.

Validation builds: GPU-assisted validation

Because bindless indices and GPU buffer addresses are resolved on the GPU, CPU-side validation cannot catch an out-of-range descriptor slot, a descriptor of the wrong type, or an out-of-bounds buffer address. Validation builds therefore enable each backend's GPU-instrumented checks by default: Vulkan GPU-AV (layer setting gpuav_enable) and D3D12 GPU-based validation. Errors are sent to the error channel as programmer errors, and you can disable these GPU-side checks by setting EQUINE_GPU_VALIDATION=0 in the environment. RI::gpuValidationEnabled() reads that variable: it is false when the variable is 0 and true otherwise, in every build, so the checks run when it is true in a validation build. It matters for device.limits.indirectRootData (indirect Level 2): in a validation build with GPU-AV on, Vulkan turns that limit off on NVIDIA because its driver faults with both.

// <RI/RI.hpp>, namespace RI
bool gpuValidationEnabled();

From the header: Validation builds (P53 (4)): GPU-assisted validation (Vulkan GPU-AV, D3D12 GPU-based validation) is on unless the environment variable EQUINE_GPU_VALIDATION is "0", a switch for isolating driver problems.

These checks add overhead: shaders are instrumented when pipelines are created, and device creation takes longer on Vulkan. Release builds omit all of them.