Environment Variables

Goldy reads several environment variables at runtime for backend selection, validation, debugging, and Slang configuration.

General

VariableValuesDefaultDescription
GOLDY_BACKENDvulkan, vk, dx12, d3d12, directx, metal, mtlPlatform default (macOS → Metal, Windows → DX12, Linux → Vulkan)Override backend selection at runtime.
GOLDY_SLANG_PATHFile path(not set)Override the path to the Slang shared library (slang.dll / libslang.dylib / libslang.so). Bypasses the default search order (vendored next to executable → extracted from embedded).

Validation

VariableValuesDefaultDescription
GOLDY_VALIDATIONComma/semicolon/whitespace-separated list: api, layout, layouts, all; or 1 / true / yes(not set)Enable validation categories. api enables GPU API validation (Vulkan validation layers, Metal shader validation). layout enables Rust/Slang struct layout and buffer stride checks. all enables both. The shorthand 1 / true / yes enables GPU API only (layout stays opt-in).
GOLDY_VALIDATE_LAYOUTS1, true, yes(not set)Legacy toggle for layout validation only. Equivalent to GOLDY_VALIDATION=layout.

Validation Examples

# GPU API validation only (Vulkan validation layers, Metal shader validation)
GOLDY_VALIDATION=api cargo run --example triangle

# Layout + stride checks only
GOLDY_VALIDATION=layout cargo run --example triangle

# Everything
GOLDY_VALIDATION=all cargo run --example triangle

# Shorthand for GPU API only
GOLDY_VALIDATION=1 cargo run --example triangle

DX12-Specific

VariableValuesDefaultDescription
GOLDY_DX12_DEBUG1, trueOn in debug buildsEnable the D3D12 debug layer. On by default in debug builds; set explicitly for release builds.
GOLDY_DX12_NO_DEBUG1, true(not set)Force-disable the D3D12 debug layer even in debug builds. Useful to avoid debug-layer crashes in parallel test threads.
GOLDY_DX12_GBV1, true(not set)Enable D3D12 GPU-Based Validation. Catches UAV/SRV descriptor mismatches, resource state errors, and out-of-bounds access on the GPU timeline. Very slow — use for targeted debugging only.
GOLDY_DX12_FORCE_WARP1, true(not set)Force the DX12 backend to use the WARP software rasterizer, even when hardware GPUs are present. Use for headless CI or reproducing WARP-specific rendering bugs.
GOLDY_DX12_ALLOW_WARP1, true(not set)Allow the WARP adapter to appear in device enumeration. Without this or GOLDY_DX12_FORCE_WARP, WARP is hidden.

Debugging

VariableValuesDefaultDescription
GOLDY_DUMP_SHADERSDirectory path(not set)Dump compiled shader bytecode (SPIR-V, DXIL, MSL) to the specified directory. Files are written at shader compilation time. Useful for inspecting what Slang produces for each backend.

Interop with System Variables

Goldy also respects these non-Goldy environment variables:

VariableBackendDescription
VK_INSTANCE_LAYERSVulkanIf set to include VK_LAYER_KHRONOS_validation, Goldy enables Vulkan validation regardless of GOLDY_VALIDATION.
VK_LAYER_PATHVulkanStandard Vulkan loader variable for locating validation layer manifests.
MTL_SHADER_VALIDATIONMetalWhen GOLDY_VALIDATION enables API validation and this variable is unset, Goldy sets it to 1 before creating the first Metal device. If you set it yourself, Goldy does not override it.