Skip to content

Architecture

buntatoes edited this page Nov 29, 2026 · 4 revisions

Architecture

Pisco bridges Steam Play on Linux with the standalone Vodka (0.1) Windows compatibility runtime, the standalone Bitters Direct3D/DXGI to Vulkan 1.4 layer, the early-alpha standalone Tonic SAPI 5 speech engine, and a 100% Python-free native Zig launcher, helper, and code-generator 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 per-game quirks  (quirks.zig)
  ├── probes PCI sysfs & applies per-vendor Wayland/Vulkan defaults  (gpu_vendors.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 + 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)
        ├── Native Wayland & Audio (libvodkawayland.so, libvodka_audio.so)
        ├── Cross-compiled steam.exe stub (zig/src/steam_helper/main.zig)
        ├── Graphics & Media Stack (Bitters [DXGI/D3D11/D3D10/D3D9/D3D8] / vkd3d-proton [D3D12] / GStreamer)
        └── 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 (stable branch, Apache-2.0) as its Direct3D and DXGI translation layer:

  1. Build Integration (Makefile.in): Runs zig build -Doptimize=ReleaseSafe inside bitters/ and copies multi-architecture PE DLLs (dxgi.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 11 / 11.1, Direct3D 10 / 10.1, Direct3D 9 / 9Ex, and Direct3D 8: All five PE DLLs (dxgi.dll, d3d11.dll, d3d10core.dll, d3d9.dll, d3d8.dll) are implemented from scratch on Vulkan 1.3/1.4 with built-in DXBC (SM 4–5) and DXSO (SM 1–3) to SPIR-V 1.6 shader compilers and are under active bring-up for real-world games.
    • Direct3D 12: Handled by bundled vkd3d-proton (d3d12.dll / d3d12core.dll) until Bitters' D3D12 path is ready.
  3. Loader & Prefix Routing (zig/src/pisco/main.zig, zig/src/default_pfx.zig):
    • Prepends files/lib/vodka/bitters ahead of files/lib/vkd3d 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/vkd3d-proton native overrides, falling back to Vodka's built-in graphics DLLs.

Royalty-Free Media Stack & Host Plugin Discovery

Pisco bundles only royalty-free GStreamer components in Makefile.in:

  • gstreamer, gst-orc, graphene, libsoup
  • gst-plugins-base, gst-plugins-good
  • dav1d 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.


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, lsteamclient/gen_wrapper.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/
├── 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
│   ├── 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_lsteamclient.zig# Steamworks C++/ABI wrapper generator (u32/u64/w32/w64)
│   └── gen_vrclient.zig    # OpenVR C++/ABI wrapper & flatapi.c thunk generator
├── default_pfx.zig         # Default Vodka prefix builder, Bitters 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

Three 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_lsteamclient (gen_lsteamclient.zig + clang_ffi.zig): Dynamically loads libclang via dlopen (avoiding compile-time LLVM version coupling) to parse user-supplied Steamworks SDK headers (--sdk-dir, not bundled in the repository) across versions 099u–165 and all four ABIs (u32, u64, w32, w64), emitting cpp<Class>_<Version>.cpp, win<Class>.c, and generated struct/unixlib glue.
  • gen_vrclient (gen_vrclient.zig + clang_ffi.zig): Uses the same dynamic libclang bridge 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_lsteamclient, 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.