Skip to content

Architecture

buntatoes edited this page Nov 29, 2026 · 2 revisions

Architecture

Pisco bridges Steam Play on Linux with a full from-scratch Apache-2.0 Zig stack: the standalone Vodka (0.1) Windows compatibility runtime, the standalone Bitters Direct3D 8–12 & DXGI to Vulkan 1.4 layer, the standalone Tonic SAPI 5 speech engine, Coupe (libgraphene-1.0 C-ABI SIMD math), Potato (XR 1.1 loader + Windows↔Linux XR bridge), Tumbler (from-scratch AV1 decoder), inlined Campari / Cask / Decant subsystems, and a 100% Python-free native Zig launcher and tooling suite.


High-Level Stack

Steam Client (Steam Linux Runtime)
  β”‚  invokes "/pisco %verb%" (toolmanifest_*.vdf)
  β–Ό
pisco  (zig/src/pisco/main.zig, ELF linked against glibc 2.31)
  β”œβ”€β”€ loads user_settings.json / user_settings.py  (settings.zig)
  β”œβ”€β”€ normalizes PISCO_* -> PROTON_* & applies quirks + AppID fixes  (quirks.zig, game_fixes.zig)
  β”œβ”€β”€ probes PCI sysfs & applies per-vendor Wayland/Vulkan defaults  (gpu_vendors.zig)
  β”œβ”€β”€ optionally detects local host Steam installation at lowest DLL priority  (steam_runtime.zig)
  β”œβ”€β”€ manages prefix locking, VODKADLLPATH, VODKADLLOVERRIDES & migration  (common/filelock.zig, reg.zig)
  β”œβ”€β”€ discovers host NVIDIA NGX driver DLLs if present  (nvidia.zig)
  β”œβ”€β”€ wires bundled royalty-free GStreamer + Coupe + existing host plugin paths  (GST_PLUGIN_SYSTEM_PATH_1_0)
  └── launches Vodka runtime (files/bin/vodka + files/bin/vodkaserver)
        β”œβ”€β”€ Vodka PE/NT Runtime (libvodka_ntdll.so, vodkaserver, /dev/ntsync, Ouzo, Pumpkin)
        β”œβ”€β”€ Native Wayland & Audio (libvodkawayland.so, libvodka_audio.so)
        β”œβ”€β”€ Cross-compiled steam.exe stub (zig/src/steam_helper/main.zig)
        β”œβ”€β”€ Graphics Stack (Bitters: DXGI & D3D8–D3D12 on Vulkan 1.4, Soju/Schnapps)
        β”œβ”€β”€ XR Stack (Potato: XR 1.1 loader + vodkaopenxr; Campari: OpenVR bridge)
        β”œβ”€β”€ Media Stack (GStreamer + Coupe [libgraphene-1.0] + dav1d / Tumbler [AV1])
        └── Speech Stack (Tonic: SAPI 5 sapi.dll, Klatt TTS, MFCC/DTW ASR, optional host libspeechd)

Vodka Runtime Integration

In .gitmodules, Pisco points the Vodka submodule at https://github.com/buntatoes/vodka.git (Vodka_Stable branch, 0.1). In Makefile.in, the vodka target builds Vodka directly with Zig:

  1. Runs zig build -Doptimize=ReleaseSafe -Dglibc-compat=true inside Vodka/.
  2. Installs built runtime binaries (files/bin/*, including vodka, vodka64, vodkaserver, vodkaboot, vodkapath), shared libraries (files/lib/libvodka_*.so, files/lib/libvodkawayland.so), PE/Unix module directories (files/lib/vodka/), and data files (files/share/vodka/, including vodka.inf) directly into dist/files/.
  3. Exports VODKAPREFIX, VODKALOADER, VODKASERVER, VODKADLLPATH, and VODKADLLOVERRIDES at launch in zig/src/pisco/main.zig.

For full internals of Vodka's preloaders, vodkaserver RPC daemon, PE64/WoW64 loader, Wayland/Vulkan stack, and Win32 DLLs, see the Vodka Wiki.


Bitters Graphics Layer & Direct3D Routing

On pisco-unstable, Pisco integrates Bitters (Apache-2.0) as its unified Direct3D and DXGI translation layer:

  1. Build Integration: Runs zig build -Doptimize=ReleaseSafe inside bitters/ and copies multi-architecture PE DLLs (dxgi.dll, d3d12.dll, d3d12core.dll, d3d11.dll, d3d10core.dll, d3d9.dll, d3d8.dll) into files/lib/vodka/bitters/{x86_64,i386,aarch64}-windows/.
  2. Implementation Status (Early Alpha):
    • DXGI & Direct3D 8–12: All seven PE DLLs (dxgi.dll, d3d12.dll, d3d12core.dll, d3d11.dll, d3d10core.dll, d3d9.dll, d3d8.dll) are implemented from scratch on Vulkan 1.3/1.4 with built-in DXIL (SM 6.x), DXBC (SM 4–5), and DXSO (SM 1–3) to SPIR-V 1.6 shader compilers, plus inlined Soju (Vulkan 1.4 / SPIR-V 1.6 bindings) and Schnapps (reserved future GLSL frontend).
  3. Loader & Prefix Routing (zig/src/pisco/main.zig, zig/src/default_pfx.zig):
    • Prepends files/lib/vodka/bitters ahead of files/lib/vodka/tonic and files/lib/vodka in VODKADLLPATH.
    • Symlinks/copies Bitters DLLs into drive_c/windows/system32 and drive_c/windows/syswow64 and injects native overrides in VODKADLLOVERRIDES (unless PROTON_USE_VODKAGFX=1 or explicit user builtin overrides such as dxgi=b / d3d8=b are set).
    • Setting PROTON_USE_VODKAGFX=1 (compat config vodkagfx) omits Bitters from VODKADLLPATH and disables Bitters native overrides, falling back to Vodka's built-in graphics DLLs.

Companion C-ABI & XR Libraries (Coupe, Potato, Tumbler)

  • Coupe (Apache-2.0): Replaces graphene from scratch in Zig using @Vector(4, f32) SIMD, exporting 100% gst-plugins-base libgraphene-1.0 C-ABI parity (libgraphene-1.0.so + headers) for GStreamer's OpenGL pipeline.
  • Potato (Apache-2.0): Replaces OpenXR-SDK and wineopenxr from scratch in Zig with a native Linux XR 1.1 loader (libopenxr_loader.so) and Windows-to-Linux XR bridge (vodkaopenxr).
  • Tumbler (Apache-2.0 + PATENTS.AV1): From-scratch Zig + Assembly AV1 decoder exporting a drop-in libdav1d C ABI, built to replace dav1d inside Pisco as it reaches full frame-decode parity.

Royalty-Free Media Stack & Host Plugin Discovery

Pisco bundles only royalty-free media components:

  • gstreamer, gst-orc, Coupe (libgraphene-1.0 C-ABI drop-in), libsoup
  • gst-plugins-base, gst-plugins-good
  • dav1d (while Tumbler matures to full frame-decode parity) and gst-plugins-rs (gst-plugin-dav1d for AV1 decoding)

Patented codec bundles (ffmpeg, gst-libav, gst-plugins-bad, gst-plugins-ugly) are intentionally excluded. At launch, zig/src/pisco/main.zig builds GST_PLUGIN_SYSTEM_PATH_1_0 with Pisco's bundled GStreamer plugin directories first, then automatically appends existing host Linux GStreamer 1.0 plugin directories (/usr/lib/gstreamer-1.0, /usr/lib64/gstreamer-1.0, /usr/lib/x86_64-linux-gnu/gstreamer-1.0, /usr/lib/aarch64-linux-gnu/gstreamer-1.0, and matching 32-bit paths when multi-arch is enabled) with deduplication. Set PISCO_NO_HOST_GST_PLUGINS=1 to restrict GStreamer strictly to Pisco's bundled plugins.


Local Host Steam Runtime Detection (steam_runtime.zig)

Pisco never bundles or redistributes proprietary Steam client binaries or SDK files. Instead, zig/src/pisco/steam_runtime.zig optionally discovers the user's existing local Steam installation at launch time:

  • Detects STEAM_COMPAT_CLIENT_INSTALL_PATH (or standard Linux Steam directories under $HOME).
  • Optionally locates an existing local Steam Play runtime library directory (or honors an explicit PISCO_STEAM_RUNTIME_LIB_DIR path) and appends it at the lowest search priority in VODKADLLPATH so Vodka, Bitters, and Tonic always take precedence.
  • Set PISCO_NO_HOST_STEAM_RUNTIME=1 (or PROTON_NO_HOST_STEAM_RUNTIME=1) to disable host Steam runtime library discovery completely.

Inlined Subsystems (Campari, Cask, Decant)

To avoid repository sprawl while removing legacy C/Python/Docker build dependencies, Pisco inlines three Zig subsystems directly under zig/src/ (see docs/INLINED_SUBSYSTEMS.md):

  • Campari (zig/src/campari/): From-scratch Zig + inline assembly OpenVR client ABI bridge replacing vrclient_x64 and vendored jsoncpp.
  • Cask (zig/src/cask/): Zig-native rootless container/sysroot SDK and reproducible build orchestrator replacing docker/ and legacy make/*.mk scripts.
  • Decant (zig/src/decant/ + zig/src/font_merge.zig): Pure-Zig OpenType / TrueType / CFF / TTC / SFD font compiler and table patcher replacing fontforge, afdko, and Python fontTools.

Tonic SAPI 5 Speech Engine (Early Alpha)

Tonic (stable branch, Apache-2.0, early alpha) is integrated into Pisco via Makefile.in (files/lib/vodka/tonic/{x86_64,i386,aarch64}-windows/sapi.dll, libtonic.so, and tonic CLI), default_pfx.zig, and pisco/main.zig (VODKADLLPATH + sapi=n override), replacing GPL-3.0 espeak-ng and prebuilt onnxruntime binaries:

Component Responsibility
Klatt Formant TTS (src/tts/) Pure-Zig English text normalizer, rule-based G2P, and 22050 Hz Klatt-style formant synthesizer (cascaded biquad resonators, SAPI rate/volume controls, RIFF WAV output).
Finite-Grammar ASR (src/asr/) Pure-Zig 512-point FFT, 26-band Mel filterbank, 13-coefficient MFCC extraction, energy VAD, and Sakoe-Chiba banded DTW recognition for closed-vocabulary game command grammars (not unconstrained open dictation).
Optional Host Bridge (src/host/bridge.zig) Runtime dlopen probe for host libspeechd.so.2 (speech-dispatcher) when TONIC_NO_HOST_SPEECH is unset, falling back to Tonic's built-in formant synthesizer when unavailable.
SAPI 5 Frontend (src/sapi/) Multi-architecture Windows PE sapi.dll (x86_64-windows, i386-windows, aarch64-windows) plus native Linux tonic CLI and libtonic.so, implementing core ISpVoice, ISpRecognizer, ISpRecoContext, ISpRecoGrammar, and token enumeration COM interfaces.

Zero-Python Native Zig Launcher & Tooling

Upstream Proton relies on Python 3 at both runtime (proton, filelock.py, user_settings.py) and build time (default_pfx.py, steampipe_fixups.py, fonts/scripts/merge.py, vrclient_x64/gen_wrapper.py, OpenXR code generation), plus standalone C helpers (steam_helper/steam.c, symstore/symstore.c, media/make_blank_ptna.c).

Pisco eliminates Python completely and consolidates all launcher, build, packaging, and code-generation utilities into a single build.zig workspace under zig/src/:

zig/src/
β”œβ”€β”€ campari/                # Inlined Zig + asm OpenVR client ABI bridge
β”œβ”€β”€ cask/                   # Inlined Zig-native rootless container/sysroot SDK & build orchestrator
β”œβ”€β”€ decant/                 # Inlined pure-Zig OpenType/TrueType/CFF/TTC/SFD font compiler
β”œβ”€β”€ common/                 # Shared utilities imported across all native tools
β”‚   β”œβ”€β”€ root.zig            # Module root exporting common submodules
β”‚   β”œβ”€β”€ filelock.zig        # POSIX flock() advisory lock (replaces filelock.py)
β”‚   β”œβ”€β”€ fs_util.zig         # Filesystem traversal, symlinks, atomic file helpers
β”‚   β”œβ”€β”€ pe.zig              # Pure-Zig PE/COFF parser (bitness, builtin detection, SymSrv keys)
β”‚   └── steampipe.zig       # SteamPipe manifest generation & permission/dir restoration
β”œβ”€β”€ pisco/                  # Native Steam Play launcher (builds -> zig-out/bin/pisco)
β”‚   β”œβ”€β”€ main.zig            # Verb dispatch, prefix setup, Bitters/GStreamer routing, Wayland toggle
β”‚   β”œβ”€β”€ game_fixes.zig      # Compartmentalized per-AppID game fix registry
β”‚   β”œβ”€β”€ steam_runtime.zig   # Optional local host Steam client & runtime library path discovery
β”‚   β”œβ”€β”€ quirks.zig          # Structured per-AppID / per-GameID compatibility tables
β”‚   β”œβ”€β”€ gpu_vendors.zig     # PCI sysfs GPU classification & per-vendor Wayland/Vulkan defaults
β”‚   β”œβ”€β”€ settings.zig        # Zero-Python parser for user_settings.json & user_settings.py
β”‚   β”œβ”€β”€ reg.zig             # Atomic Vodka .reg reader/updater
β”‚   └── nvidia.zig          # Dynamic libGLX_nvidia.so.0 linkmap lookup for host nvngx.dll
β”œβ”€β”€ steam_helper/
β”‚   └── main.zig            # Cross-compiled Windows PE steam.exe (x86_64, i386, aarch64)
β”œβ”€β”€ generators/             # Build-time ABI & header code generators
β”‚   β”œβ”€β”€ xml.zig             # Arena-friendly XML DOM parser for Khronos xr.xml
β”‚   β”œβ”€β”€ clang_ffi.zig       # Dynamic dlopen() bindings for LLVM libclang C API
β”‚   β”œβ”€β”€ make_openxr.zig     # OpenXR header & Unix/loader thunk generator (vodkaopenxr)
β”‚   └── gen_vrclient.zig    # OpenVR C++/ABI wrapper & flatapi.c thunk generator
β”œβ”€β”€ default_pfx.zig         # Default Vodka prefix builder, Bitters/Tonic symlinks & registry sanitizer
β”œβ”€β”€ steampipe_fixups.zig    # CLI frontend for SteamPipe process/restore manifests
β”œβ”€β”€ font_merge.zig          # Pure-Zig SFNT TrueType subsetter, merger, and renamer
β”œβ”€β”€ symstore.zig            # Microsoft SymSrv-compatible PE symbol store indexer
└── make_blank_ptna.zig     # RFC 7845 .ptna Opus audio stream generator (links libopus)

In dist/, Pisco installs the compiled binary at pisco and symlinks proton -> pisco. Both toolmanifest_x86_64.vdf (requiring Steam Runtime appid 4183110) and toolmanifest_arm64.vdf (requiring appid 4185400) declare "commandline" "/pisco %verb%".


Code Generators Architecture

Two build-time generators under zig/src/generators/ replace complex Python code-generation scripts:

  • make_openxr (make_openxr.zig + xml.zig): Parses Khronos OpenXR xr.xml (pinned to XR_XML_VERSION = "1.1.63") using a pure-Zig XML DOM parser with zero external libraries. Generates vodkaopenxr.h, vodkaopenxr.json, openxr_thunks.{h,c}, and loader_thunks.{h,c}.
  • gen_vrclient (gen_vrclient.zig + clang_ffi.zig): Dynamically loads libclang via dlopen (avoiding compile-time LLVM version coupling) across OpenVR SDK v0.9.0–v2.15.6 and all four ABIs (u32, u64, w32, w64), generating vtable wrappers, FnTable flat C constructors/destructors, and flatapi.c assembly thunks.

glibc 2.31 Steam Linux Runtime Compatibility

Steam executes compatibility tools inside the Steam Linux Runtime (SteamRT) container environment, whose baseline glibc version is older than rolling-release Linux hosts (such as Arch Linux or Fedora).

To guarantee that host-compiled Pisco binaries run reliably inside SteamRT and on older distributions, build.zig provides -Dglibc-compat=true:

const target = if (glibc_compat and default_target.result.os.tag == .linux)
    b.resolveTargetQuery(.{
        .cpu_arch = default_target.result.cpu.arch,
        .os_tag = .linux,
        .abi = .gnu,
        .glibc_version = .{ .major = 2, .minor = 31, .patch = 0 },
    })
else
    default_target;
  • Both Makefile (make zig) and Makefile.in (zig-tools) pass -Doptimize=ReleaseSafe -Dglibc-compat=true.
  • All Linux ELF binaries (pisco, default_pfx, steampipe_fixups, font_merge, symstore, make_openxr, gen_vrclient) bind exclusively to glibc <= 2.31 symbols.
  • make_blank_ptna links against host libopus using default_target and can be toggled off inside container builds via -Dwith-opus=false.
  • steam.exe cross-compiles directly to x86_64-windows, i386-windows, and aarch64-windows PE executables using Zig's built-in Windows target support, requiring no host MinGW toolchain or external C headers.