Shift Engine Docs

These docs follow the main branch and can describe changes newer than v0.3.2. Release archives and checksums are published on GitHub Releases.

Renderer, RHI & shaders

Shift Engine renders Colorado and every vehicle on one unified reverse-Z HDR pipeline spanning Vulkan 1.3, DirectX 12, Metal 3 (MoltenVK + Apple MetalFX), and WebGPU (42 WGSL shaders). Optional heavy targets allocate lazily only when enabled by the active preset.

10-Stage HDR Frame Pipeline (Renderer::draw_frame) reverse-Z · lazy targets · kFramesInFlight = 2 1. PRE-PASS & CULL • UBOs & clustered lights • Env cubemap + mirrors • WorldGpu Hi-Z cull world_cull.comp 2. CSM SHADOWS • 2/3-cascade D32 atlas • Shadow Draw Distance • Far tree shadow cutouts optional PCSS 3. HDR SCENE • Opaque + terrain blend • Grass, water, cars • Early-Z sky & stars 1×/2×/4× TBDR MSAA 4. HI-Z & PARTICLES • Depth pyramid mips • Soft smoke & skids • Debris, fireworks hiz_gen.comp 5. SCREEN-SPACE • XeGTAO & SSCS • Hi-Z SSR reflections • Volumetric sun shafts McGuire motion blur 6. OPTIONAL RT/PT • BLAS/TLAS updates • Hybrid ray queries • Path-traced Photo ReSTIR DI + SVGF 7. HDR POST CHAIN • 6-level bloom pyramid • Auto-exposure • Retail 16³ 3D LUTs filmic tonemap 8. UPSCALE & HDR10 • CAS / FSR1 / TAAU • Apple MetalFX (+FI) • FXAA & optional VRS HDR10 / scRGB 9. UI4 OVERLAY • 1-pass instanced quads • 4K VFont & SDF atlas • Tilted masks & HUD 96 B ui::Instance 10. PRESENT • Queue submit • Async resource retire • GPU timestamp query 0 DeviceWaitIdle MULTI-API RHI & SHADER TARGETS (56 SPIR-V · 42 WGSL · PERSISTENT PIPELINE CACHE) Vulkan 1.3 (Win/Lin/And) DirectX 12 (Windows) Metal 3 / MoltenVK (Mac) WebGPU WGSL (/play/)
10-stage HDR frame pipeline inside Renderer::draw_frame() and the four compiled RHI/shader targets.
Shift Engine 10-Stage HDR Frame Pipeline (Renderer::draw_frame, reverse-Z, lazy targets, kFramesInFlight=2):
1. Pre-Pass & Cull: per-frame UBOs, 24h Sky/ToD uniforms, clustered lights, amortized dynamic env cubemap + 3-band cockpit mirrors, WorldGpu frustum + Hi-Z occlusion culling (world_cull.comp, tree_cull.comp).
2. Cascaded Sun Shadows: 2/3-cascade D32 reverse-Z atlas with configurable Shadow Draw Distance (Low..Ultra/Extended), Far-cascade tree shadow cutouts, optional PCSS.
3. Main HDR Scene Pass: discard-free opaque world (early_fragment_tests), terrain/road blending, grass shells, kAnimTreeSway vegetation-only wind sway, reflective lake water, early-Z sky dome & 9,096 stars, instanced cars (PBR clearcoat, voxel damage, backlit gauges), TBDR transient 1x/2x/4x MSAA.
4. Hi-Z Pyramid & Soft Particles: hiz_gen.comp mip chain, soft tyre smoke, skidmarks, smashable debris, fireworks, lamp glows.
5. Modern Screen-Space (lazy): XeGTAO/SSAO, SSCS contact shadows, Hi-Z SSR, occluded volumetric sun shafts, motion vectors + McGuire tile motion blur.
6. Optional Hardware RT/PT: BLAS/TLAS updates, Tier-1 hybrid ray-query reflections/shadows/AO, Photo Mode / real-time path tracing with ReSTIR DI + SVGF denoiser.
7. HDR Post Chain: 6-level bloom pyramid, adaptive auto-exposure, retail 16x16x16 3D LUT color grading, filmic tonemapping.
8. Anti-Aliasing, Upscaling & Output: FXAA, CAS, FSR1, TAAU, Apple MetalFX (+ macOS 26+ Frame Interpolation), optional VRS, per-monitor HDR10/scRGB calibration.
9. UI4 Overlay Pass: single-pass instanced 96-byte ui::Instance quads, 4K VFont & 512x512 stroke SDF atlas, tilted dual-texture masks.
10. Queue Submit & Present: frame-tagged retirement ring (zero vkDeviceWaitIdle stalls), GPU timestamp queries.


Multi-API RHI targets: Vulkan 1.3 (Windows/Linux/Android, split bindless 1x sampler + 4096 sampled images), DirectX 12 (Windows), Metal 3 via bundled MoltenVK (macOS), WebGPU (42 WGSL shaders from 56 GLSL/SPIR-V sources).

Key rendering subsystems#

Multi-API RHI (libs/rhi)

Explicit Device, Swapchain, CommandList, RenderGraph, clustered local lights, visibility buffer, and GPU Xenos detiling. Select with --backend auto|vulkan|dx12|metal or inspect via --list-backends.

GPU-driven WorldGpu & TBDR

Persistent world/tree arenas culled by compute frustum + Hi-Z occlusion using split bindless (1× sampler + 4096 images), transient on-chip MSAA for tile GPUs, persistent VkPipelineCache, and zero-stall retirement rings.

24h Sky, Terrain, Water & Shadows

Calibrated TimeOfDayA (110 curves, 16 zones, 22 retail 16³ LUTs, 9,096 stars), terrain/road blending, grass shells, LAKE_* water, vegetation-only kAnimTreeSway, and live Shadow Draw Distance (Low..Extended) including Far tree shadows.

Modern post & optional RT/PT

Lazy-allocated XeGTAO, SSCS, Hi-Z SSR, volumetric shafts, McGuire motion blur, optional Vulkan RT/PT (ReSTIR DI + SVGF), CAS/FSR1/TAAU/MetalFX, VRS, and per-monitor HDR10/scRGB output.

Platform notes#

PlatformWorld cullingPipeline / memory optimizations
Windows / LinuxGPU-driven WorldGpu + Hi-Z computePersistent VkPipelineCache, optional VRS (-18% GPU at 1080p on RTX 4080), optional Vulkan RT/PT.
macOS (Apple Silicon)CPU-culled direct draws (gpu_world=0 avoids MoltenVK indirect bugs; 0.66–1.35 ms CPU p50 on M4 Pro)Split offscreen/present queues, TBDR transient MSAA, persistent VkPipelineCache, Apple MetalFX (+ Frame Interpolation on macOS 26+).
Android (arm64)Split bindless on Turnip; CPU-culled fallback on stock driversBundled Mesa Turnip (rootless via libadrenotools), TBDR transient MSAA, VRS + ADPF presets.
WebGPU (/play/)CPU frustum culling into indexed draws42 native WGSL shaders, BC compressed textures, WASM SIMD128 + pthreads.

Authoring & regenerating shaders#

Source GLSL lives in apps/carview/shaders/, prebuilt SPIR-V in apps/carview/shaders/prebuilt/ (56 shaders), and generated WGSL in apps/carview/webgpu/wgsl/ (42 shaders). After any shader edit, run all three checks before committing:

python tools/regenerate-shaders.py [--compiler /path/to/glslc]
python tools/generate-wgsl.py
python tools/check-shader-portability.py --check-manifest
libs/rhi headers: rhi/rhi.h, rhi/rhi_types.h (Device, Swapchain, CommandList, BindGroup, BindlessTable, BufferDesc, TextureDesc, SamplerDesc, QueryPool, AccelStruct, create_device), rhi/render_graph.h (RenderGraph with wait_for_last_execution guard), rhi/vis_buffer.h, rhi/meshlet.h, rhi/clustered_lights.h, rhi/xenos_detile_gpu.h, rhi/post_fx_compute.h. apps/carview renderer modules: renderer_device, renderer_resources, renderer_swapchain, renderer_frame, renderer_modern_setup, renderer_modern_record, renderer_post, renderer_ui; showroom_car_load, showroom_car_state, showroom_pipelines, showroom_upload, showroom_world_stream, showroom_world_gpu, showroom_shadows, showroom_env, showroom_sky, showroom_lights, showroom_vfx, showroom_actors, showroom_draw; world_gpu, rt_scene, rt_pipeline. Key portability details: split bindless (1 immutable sampler + 4096 sampled images), VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT with DONT_CARE store ops for TBDR MSAA, vk_pipeline_cache.bin validated by vendor/device/UUID, kAnimTreeSway material flag restricting wind sway to foliage so static banners (G-SHOCK, bunting) never Z-fight, and Far-cascade tree shadow cutouts enabled across Windows/Linux/macOS when Shadow Draw Distance scales up.