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.

Architecture & libraries

Shift Engine is a strictly acyclic stack of C++20 libraries under libs/ feeding thin application hosts under apps/. Every domain library (fh1data, shift_data, shift_cars, shift_drive, shift_audio, shift_world, shift_traffic, shift_garage, shift_freeroam, shift_race, shift_profile, shift_setup) is headless-first: zero Vulkan, DirectX 12, Metal, or SDL3 dependencies.

Library Dependency DAG & Headless Boundary strictly acyclic · C++20 TIER 5 · APPLICATIONS & PRESENTATION (SDL3 / GPU HOSTS) apps/carview (render · hud · main) apps/launcher (shift-launcher) carbake · soundbake · profile-import · drive HEADLESS DOMAIN LIBRARIES (ZERO SDL3 / WINDOWING DEPS; libs/rhi ISOLATED) TIER 4 · GAME MODES, PERSISTENCE & PLATFORM shift_freeroam signs · barns · 1000 Club shift_race events · career · Rally shift_profile saves · Pinyon/Xenia sync shift_rhi VK1.3 · DX12 · Metal 3 shift_setup GDFX/ISO · STFS · Turnip TIER 3 · WORLD, TRAFFIC, GARAGE & CUTSCENES shift_world streaming · collision · ToD sky · VFX shift_traffic road graph · traffic AI · GPS shift_garage upgrades · tuning · PI solver shift_cutscene cinematic tracks & rigs TIER 2 · CORE SIMULATION & REAL-TIME AUDIO shift_drive 360 Hz physics · tyres · 4×4 LSD · BVH8 · voxel damage · AI · FFB · UDP shift_audio lock-free 48 kHz RT thread · XMA2 · engine DSP · FEV1 · acoustics · radio TIER 1 shift_cars Disc / TU v4 / DLC source layering · merged catalog · direct-from-disc & .shiftbake loader · mods.toml overlay TIER 0 fh1data ZIP/LZX · .xds · .carbin · HEXY/.pvsz · UI4 · VFont/CJK · SPA zero internal dependencies TIER 0 shift_data read-only gamedb.slt rules & queries
6-tier C++20 library dependency DAG. Lower tiers never depend on higher tiers, and everything inside the dashed boundary builds and tests headlessly.
Shift Engine 6-Tier Acyclic C++20 Library Dependency DAG:


Tier 5 — Applications & Presentation (SDL3 / GPU Hosts):
  apps/carview (carview_render + carview_hud + carview), apps/launcher (shift-launcher),
  apps/carbake, apps/soundbake, apps/profile-import, apps/drive


--- Headless Domain Boundary (zero SDL3 or windowing dependencies; shift_rhi isolated) ---


Tier 4 — Game Modes, Persistence & Platform:
  shift_freeroam (signs, barns, outposts, 1000 Club)
  shift_race (events, career flow, showcases, Rally)
  shift_profile (atomic saves, backups, PinyonShift/Xenia import, LAN sync)
  shift_rhi (Vulkan 1.3, DirectX 12, Metal 3, RenderGraph, vis_buffer, clustered lights)
  shift_setup (GDFX/XISO extractor, STFS installer, mods, Mesa Turnip)


Tier 3 — World, Traffic, Garage & Cutscenes:
  shift_world (Colorado streaming, collision, 24h ToD sky, smashables, VFX)
  shift_traffic (road graph, free-roam traffic AI, GPS routing)
  shift_garage (garage inventory, upgrades, tuning, PI calculator)
  shift_cutscene (cinematic tracks and rig evaluation)


Tier 2 — Core Simulation & Real-Time Audio:
  shift_drive (120 Hz / 360 Hz vehicle physics, tyres, 4x4 LSD/AWD, BVH4/8, voxel damage, AI, FFB, UDP)
  shift_audio (lock-free 48 kHz RT thread, XMA2/FSB4, engine DSP, FEV1, 3D acoustics, radio, VO)


Tier 1 — Asset Resolution & Layering:
  shift_cars (disc + Title Update v4 + DLC resolver, merged catalog, direct-from-disc & .shiftbake loader, mods.toml overlay)


Tier 0 — Format Readers & Rules (zero internal dependencies):
  fh1data (ZIP/LZX, .xds, .carbin, HEXY/.pvsz, UI4 .bgf/.bsg/.fbf, VFont/CJK, SPA, NativeCache, WorkerPool)
  shift_data (read-only gamedb.slt SQLite rules & event restrictions)

Design highlights#

Headless-first C++20 libraries

Link shift_drive, fh1data, or shift_audio directly in CLI tools or ctest suites with no GPU or windowing system.

Hot car swaps (~213 ms)

DriveWorldHost outlives DriveSession. Swapping cars in My Garage keeps the Vulkan device, pipeline cache, world arenas, and BVH resident.

Bounded explicit concurrency

4 clear thread roles: Main/Render, fh1::WorkerPool streaming/AI, deferred GPU resource reaper (0 vkDeviceWaitIdle stalls), and lock-free RT audio.

Clean-room provenance

Independently authored from format and behavioral specs; every push is verified by tools/check-provenance.py.

Embedding a headless library#

Link any domain target in CMake to run physics sweeps, inspect archives, or render offline audio with zero game data required for synthetic defaults:

add_executable(my_physics_probe main.cpp)
target_link_libraries(my_physics_probe PRIVATE shift_drive)
#include <cstdio>
#include "drive/vehicle.h"

int main() {
  drive::CarParams params;        // default-constructed synthetic car
  drive::Vehicle car(params);
  drive::FlatGround ground(0.0);

  car.reset({0.0, 0.0, 0.0}, 0.0);
  car.settle_on_ground(ground);

  drive::Input in{};
  in.throttle = 1.0;
  for (int i = 0; i < 120 * 5; ++i) car.step(in, ground);

  std::printf("5s launch: %.1f km/h, gear %d, %.0f rpm\n",
              car.speed() * 3.6, car.gear(), car.rpm());
}

With a local disc mounted, drive::params_from_physics() loads per-car tables from gamedb.slt + physics.zip, and drive::MeshGround replaces FlatGround with Colorado's SIMD BVH mesh.

Library & runtime map#

TargetPathRole
fh1data / shift_datalibs/fh1data, libs/dataFormat readers (ZIP/LZX, .xds, .carbin, HEXY/.pvsz, UI4, VFont/CJK, SPA) and read-only gamedb.slt rules.
shift_carslibs/carsDisc + TU v4 + DLC resolver, direct-from-disc & .shiftbake car loader, mods.toml overlay.
shift_drivelibs/drive360 Hz vehicle physics, tyres, 4×4 LSD/AWD, BVH4/BVH8 collision, voxel damage, AI, cameras, FFB, UDP telemetry.
shift_audiolibs/audioLock-free 48 kHz RT audio thread, in-process XMA2/FSB4, engine DSP, FEV1, 3D acoustics, radio, VO.
shift_world / traffic / garagelibs/world, traffic, garageColorado cell streaming, collision, 24h sky, VFX, road graph & traffic AI, upgrades/tuning/PI solver.
shift_freeroam / race / profilelibs/freeroam, race, profileCollectibles, barn finds, 1000 Club, race events, Horizon Rally, atomic saves, PinyonShift/Xenia import.
shift_rhi / shift_setuplibs/rhi, libs/setupMulti-API RHI (Vulkan 1.3, DX12, Metal 3) + clean-room GDFX/ISO, STFS, mod, and Turnip installers.
carview / shift-launcherapps/carview, apps/launcherMain runtime (carview_render + carview_hud + carview), native GUI launcher, and CLI tools.
Thread ownership: 1. Main / Render thread: SDL3 window and event pump, 120 Hz fixed-step simulation, AI/race/free-roam orchestration, UI4 layout, Vulkan/RHI command recording (kFramesInFlight = 2), swapchain present. 2. World streaming & worker pool (fh1::WorkerPool): off-thread ZIP/LZX decompression, .xds texture decoding, Colorado cell/prop/collision gathering, multi-car AI physics fan-out. 3. GPU resource reaper: destroys retired Vulkan buffers, images, and descriptor pools only after frames_done >= retire_tag (zero vkDeviceWaitIdle stalls). 4. Dedicated Audio render thread (audio::AudioEngine): allocation-free, mutex-free 48 kHz stereo mixing fed via lock-free SPSC command queues and TripleBuffer snapshots; background decoder threads decode FSB4/XMA2/MP3 off-thread. Windowed frame order: SDL_PollEvent -> menu/overlay/campaign dispatch -> fixed-step simulation -> lock-free audio snapshot push -> world streaming poll & GPU upload -> camera/frustum/shadow/cubemap placement -> UI4 build -> Renderer::draw_frame() 10 stages -> queue submit & present. apps/carview CMake targets: carview_render (static library shared with shift-launcher and tests), carview_hud (static library), carview (executable / Android libmain.so / WebGPU WASM). Runtime shell: showroom_main -> DriveApp (persists across reloads) -> DriveWorldHost (persists across hot car swaps via Showroom::reload_car) -> DriveSession.

Deep dives#