diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 0000000..64dd140
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,7 @@
+[build]
+target = "x86_64-pc-windows-msvc"
+
+[alias]
+check-all = "check --workspace --all-targets"
+test-all = "test --workspace --all-targets"
+lint = "clippy --workspace --all-targets -- -D warnings"
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000..059d729
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,44 @@
+name: Rust validation
+
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+jobs:
+ format:
+ name: Formatting
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ components: rustfmt
+ - run: cargo fmt --all -- --check
+
+ windows:
+ name: Windows x64 build and tests
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: x86_64-pc-windows-msvc
+ components: clippy
+ - uses: Swatinem/rust-cache@v2
+ - name: Build release executable
+ run: cargo build --target x86_64-pc-windows-msvc --release -p eonacat-xsbox-engine
+ - name: Publish Windows launcher
+ run: dotnet publish launcher/windows/EonaCat.XSBOX.Launcher.csproj --configuration Release --runtime win-x64 --self-contained false --output target/x86_64-pc-windows-msvc/release/launcher
+ - name: Verify launcher output
+ run: if (!(Test-Path target/x86_64-pc-windows-msvc/release/launcher/EonaCat.XSBOX.Launcher.exe)) { throw "Launcher executable was not produced" }
+ shell: pwsh
+ - name: Run workspace tests
+ run: cargo test --target x86_64-pc-windows-msvc --workspace
+ - name: Run Clippy
+ run: cargo clippy --target x86_64-pc-windows-msvc --workspace --all-targets
+ - name: Compile CPU microbenchmarks
+ run: cargo bench --target x86_64-pc-windows-msvc -p eonacat-xsbox-gpu --bench hot_paths --no-run
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..98b9fc7
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,847 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anstream"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
+
+[[package]]
+name = "anstyle-parse"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.104"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
+
+[[package]]
+name = "arrayvec"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
+
+[[package]]
+name = "bitflags"
+version = "2.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
+
+[[package]]
+name = "blake3"
+version = "1.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae"
+dependencies = [
+ "arrayvec",
+ "cc",
+ "cfg-if",
+ "constant_time_eq",
+ "cpufeatures",
+]
+
+[[package]]
+name = "cc"
+version = "1.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "02f0e023adb368345ce0ca6cdfc0f24a06554468d0e8503e14a0841de79bfa69"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
+
+[[package]]
+name = "clap"
+version = "4.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "844c5c0b65be192cb68d570cca1b21a6444431d24e39c084dc0336177015337c"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.6.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4c174f11f949b9ca8c60580925e282b9cbd5454750e506f08648b2038080cd7"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "clap_lex"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
+
+[[package]]
+name = "constant_time_eq"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
+
+[[package]]
+name = "cpufeatures"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "eonacat-xsbox-engine"
+version = "0.0.1"
+dependencies = [
+ "anyhow",
+ "blake3",
+ "clap",
+ "eonacat-xsbox-game",
+ "eonacat-xsbox-gpu",
+ "memchr",
+ "opus-pure",
+ "tracing",
+ "walkdir",
+ "windows",
+ "windows-core",
+ "windows-sys",
+ "zlib-rs",
+]
+
+[[package]]
+name = "eonacat-xsbox-game"
+version = "0.0.1"
+dependencies = [
+ "eonacat-xsbox-gpu",
+ "memchr",
+ "thiserror",
+ "tracing",
+ "windows-sys",
+ "zlib-rs",
+]
+
+[[package]]
+name = "eonacat-xsbox-gpu"
+version = "0.0.1"
+dependencies = [
+ "anyhow",
+ "blake3",
+ "mimalloc",
+ "object",
+ "serde",
+ "tempfile",
+ "thiserror",
+ "toml",
+ "tracing",
+ "tracing-subscriber",
+ "windows",
+ "windows-sys",
+ "zlib-rs",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
+
+[[package]]
+name = "errno"
+version = "0.3.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
+dependencies = [
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
+
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.17.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "indexmap"
+version = "2.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
+dependencies = [
+ "equivalent",
+ "hashbrown",
+]
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
+
+[[package]]
+name = "lazy_static"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
+
+[[package]]
+name = "libc"
+version = "0.2.191"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
+
+[[package]]
+name = "libmimalloc-sys"
+version = "0.1.49"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+
+[[package]]
+name = "log"
+version = "0.4.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
+
+[[package]]
+name = "matchers"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
+dependencies = [
+ "regex-automata",
+]
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "mimalloc"
+version = "0.1.52"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862"
+dependencies = [
+ "libmimalloc-sys",
+]
+
+[[package]]
+name = "nu-ansi-term"
+version = "0.50.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "object"
+version = "0.41.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11dbdb66876026054e4ffc8d757d862bdf5df5aebd5c0b95a41f17832a94f7d2"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
+
+[[package]]
+name = "opus-pure"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccd077a3f06e5fc42b04bb59f70d5fe0cdb2c119eef0e240af7e287180ee23ba"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "regex-automata"
+version = "0.4.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
+
+[[package]]
+name = "rustix"
+version = "1.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys",
+]
+
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "serde_spanned"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "sharded-slab"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "smallvec"
+version = "1.16.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
+dependencies = [
+ "fastrand",
+ "getrandom",
+ "once_cell",
+ "rustix",
+ "windows-sys",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "thread_local"
+version = "1.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "toml"
+version = "1.2.2+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5426cb1b964690d913f6c5c1a1ae0b42f428ec506bb4d452876d7a209c9bca3b"
+dependencies = [
+ "indexmap",
+ "serde_core",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_parser",
+ "toml_writer",
+ "winnow",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "1.1.3+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "toml_parser"
+version = "1.1.6+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6769c452d71ba30696c6b37770c439a9cc9110f47f7d5cdbeda79840ef5ea31"
+dependencies = [
+ "winnow",
+]
+
+[[package]]
+name = "toml_writer"
+version = "1.2.0+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a"
+
+[[package]]
+name = "tracing"
+version = "0.1.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
+dependencies = [
+ "pin-project-lite",
+ "tracing-attributes",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-attributes"
+version = "0.1.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.36"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
+dependencies = [
+ "once_cell",
+ "valuable",
+]
+
+[[package]]
+name = "tracing-log"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
+dependencies = [
+ "log",
+ "once_cell",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-subscriber"
+version = "0.3.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319"
+dependencies = [
+ "matchers",
+ "nu-ansi-term",
+ "once_cell",
+ "regex-automata",
+ "sharded-slab",
+ "smallvec",
+ "thread_local",
+ "tracing",
+ "tracing-core",
+ "tracing-log",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "valuable"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
+
+[[package]]
+name = "walkdir"
+version = "2.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b42e295b7452c4604982280d8586001fcad9b8b201cac67bca9771e7a7475403"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
+[[package]]
+name = "winapi-util"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "windows"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"
+dependencies = [
+ "windows-collections",
+ "windows-core",
+ "windows-future",
+ "windows-numerics",
+]
+
+[[package]]
+name = "windows-collections"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610"
+dependencies = [
+ "windows-core",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-link",
+ "windows-result",
+ "windows-strings",
+]
+
+[[package]]
+name = "windows-future"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"
+dependencies = [
+ "windows-core",
+ "windows-link",
+ "windows-threading",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.60.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.59.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-numerics"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26"
+dependencies = [
+ "windows-core",
+ "windows-link",
+]
+
+[[package]]
+name = "windows-result"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-strings"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-threading"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "winnow"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef"
+
+[[package]]
+name = "zlib-rs"
+version = "0.6.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..86567bf
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,64 @@
+[workspace]
+resolver = "3"
+members = ["crates/graphics", "crates/game", "crates/engine"]
+
+[workspace.package]
+version = "0.0.1"
+edition = "2024"
+rust-version = "1.89"
+license = "GPL-3.0-or-later"
+publish = false
+
+[workspace.dependencies]
+
+anyhow = "1.0.104"
+thiserror = "2.0.21"
+clap = { version = "4.6.9", features = ["derive"] }
+tracing = "0.1.44"
+tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
+serde = { version = "1.0.229", features = ["derive"] }
+toml = "1.2.2"
+object = { version = "0.41.0", default-features = false, features = ["read_core", "pe", "coff", "archive", "std"] }
+windows-sys = "0.61.2"
+windows = "0.62.2"
+windows-core = "0.62.2"
+blake3 = "1.8.7"
+memchr = "2.8.3"
+zlib-rs = { version = "0.6.8", default-features = false, features = ["std"] }
+walkdir = "2.5.1"
+tempfile = "3.27.0"
+opus-pure = "0.2.4"
+
+[workspace.lints.rust]
+unsafe_op_in_unsafe_fn = "deny"
+unused_must_use = "deny"
+
+[workspace.lints.clippy]
+all = { level = "warn", priority = -1 }
+type_complexity = "allow"
+needless_range_loop = "allow"
+chunks_exact_to_as_chunks = "allow"
+sliced_string_as_bytes = "allow"
+collapsible_match = "allow"
+manual_clamp = "allow"
+implicit_saturating_sub = "allow"
+min_max = "allow"
+undocumented_unsafe_blocks = "allow"
+
+[profile.dev.package."*"]
+opt-level = 2
+
+[profile.release]
+debug = "line-tables-only"
+lto = "fat"
+codegen-units = 1
+
+[profile.diag]
+inherits = "release"
+codegen-units = 16
+
+[profile.fast]
+inherits = "release"
+lto = false
+codegen-units = 256
+incremental = true
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 494f695..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,73 +0,0 @@
-Apache License
-Version 2.0, January 2004
-http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
-"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
-
-"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
-
-"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
-
-"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
-
-"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
-
-"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
-
-"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
-
-"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
-
-"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
-
-"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
-
- (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
-
- You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
-To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
-
-Copyright 2026 EonaCat
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/README.md b/README.md
index 76f705a..71aa576 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,374 @@
-# EonaCat.XSBox
+# EonaCat XS
+**EonaCat XS** (workspace/package name: `EonaCat.XSBOX`) is a Windows-first host/runtime for the Xbox title implementation included in this repository. It provides a Windows launcher and a Rust runtime with a Direct3D 12 graphics backend. The codebase includes title/package handling, console-facing compatibility services, shader and pipeline translation, GPU resource management, input/audio integration, and performance/diagnostic tooling.
+
+> **Important:** This is an experimental compatibility project, not an official Microsoft, Xbox, Rockstar Games, NVIDIA, AMD, or Intel product. Compatibility depends on the title build, game data, Windows version, GPU, driver, runtime components, and the current state of the implementation. A successful launch does not guarantee that every scene, feature, or save operation works correctly. Use only game data that you are legally entitled to use.
+
+## Contents
+
+- [What is included](#what-is-included)
+- [Latest performance profile](#latest-performance-profile)
+- [What unlimited FPS means](#what-unlimited-fps-means)
+- [Frame generation](#frame-generation)
+- [Requirements](#requirements)
+- [Build from source](#build-from-source)
+- [First launch](#first-launch)
+- [Launcher overview](#launcher-overview)
+- [Graphics and performance tuning](#graphics-and-performance-tuning)
+- [Shader preparation and cache](#shader-preparation-and-cache)
+- [Command-line tools](#command-line-tools)
+- [Configuration and data locations](#configuration-and-data-locations)
+- [Troubleshooting](#troubleshooting)
+- [Project structure](#project-structure)
+- [Development and validation](#development-and-validation)
+- [License](#license)
+
+
+
+
+
+## What is included
+
+The repository is organized as a Rust workspace plus a separate Windows launcher:
+
+| Component | Purpose |
+|---|---|
+| `crates/engine` | Runtime entry point, process hosting, command-line interface, title execution flow, and console compatibility services |
+| `crates/graphics` | Direct3D 12/DXGI integration, GPU resources, descriptors, shaders, pipelines, memory/residency, frame scheduling, and presentation |
+| `crates/game` | Title-specific metadata, package/container handling, build identities, and compatibility hooks |
+| `launcher/windows` | Windows Forms launcher, game library, settings UI, launch workflow, and engine output log |
+| `assets` | Application icon and artwork |
+| `bindings.ini` | Default keyboard/mouse binding definitions |
+| `.github/workflows` | Windows CI workflow definitions |
+
+The Rust engine executable is named `eonacat-xsbox.exe`. The Windows launcher is published as `EonaCat.XSBOX.Launcher.exe` in the `launcher` subfolder beside the engine's profile output.
+
+## Latest performance profile
+
+This source package applies a shared CPU-submission optimisation baseline to **every in-game graphics preset** and the launcher profile. Every preset also explicitly turns Frame Generation OFF, preserving your earlier preference. The **LOW CPU (UNLIMITED / NO FRAME-GEN)** preset remains the most aggressive image-quality/performance starting point, but switching to FPS, Ultra Performance, Low, Medium, High, Very High, or Max no longer drops the command-submission optimisations or silently re-enables generated frames.
+
+The LOW CPU preset selects these image/rendering values; the shared CPU-submission optimisations and Frame Generation OFF apply to all presets:
+
+| Setting | Preset value | Meaning |
+|---|---:|---|
+| Console target | Series S | Uses the Series S configuration path exposed by the menu |
+| Output resolution | 2560 × 1440 | Display/output target |
+| Internal game resolution | 960 × 540 | Lower internal rendering resolution |
+| Upscaling | DLSS Performance | Requests the Performance upscaling mode |
+| Ray tracing | Off | Disables the menu's RT option |
+| Frame-rate cap | None (`1000` menu value) | Removes the artificial frame pacing cap |
+| Frame generation | Off (`0`) | Explicitly disables frame generation, including automatic enablement based on detected capability |
+
+Every preset now applies these resolution-independent command-submission optimizations:
+
+- Batch-checks large groups of resource refreshes rather than repeatedly checking each range against the write journal.
+- Processes refresh work in larger helper-thread chunks to reduce scheduling overhead.
+- Drops immediately repeated, byte-identical D3D12 state-setting calls before translating the list.
+- Joins up to 16 queue parts when preparing host submissions, reducing repeated per-submission setup.
+
+These changes target CPU-side work; they do not depend on whether the selected output is 720p, 1080p, 1440p, or 4K. They are intended to reduce the CPU bottleneck, not guarantee that it disappears on every scene or machine. GPU rendering, game-side CPU work, driver overhead, and memory bandwidth can still become limiting.
+
+To use it:
+
+1. Start EonaCat XS and select the game you want to launch.
+2. Open the in-game graphics/settings menu.
+3. Choose the preset that matches your image-quality preference. All presets now retain the shared CPU-submission optimisations; choose **LOW CPU (UNLIMITED / NO FRAME-GEN)** for the lowest internal resolution, uncapped frame pacing and explicit Frame Generation OFF.
+4. Save/apply the settings if the menu offers that action, then restart the title if prompted or required for the selected options to take effect.
+5. Confirm the displayed settings after restart. If you have a custom profile or external environment variables, check that they are not overriding the menu values.
+
+The preset is a starting point, not a promise of a particular frame rate or image quality. You can change individual settings afterward; doing so may make the active configuration differ from the preset described here.
+
+## What unlimited FPS means
+
+“Unlimited” means EonaCat XS does not intentionally wait to enforce a target such as 30, 60, or 120 frames per second. Internally, the menu's `NONE` value is represented by `1000`; the runtime translates that special value into a **zero-millisecond frame interval** and removes the old microsecond interval override.
+
+It does **not** mean that the game will reach 1000 FPS, or that the frame rate will be stable. Actual performance is limited by the slowest part of the workload, including:
+
+- CPU execution and translation of title instructions;
+- API/command submission and synchronization;
+- GPU rendering and memory bandwidth;
+- shader and pipeline compilation;
+- asset streaming, decompression, and storage speed;
+- driver and operating-system scheduling.
+
+An uncapped renderer can also increase CPU/GPU utilization, power draw, heat, and fan noise. If you prefer lower temperatures or more consistent frame pacing, select a finite cap such as 60 or 120 instead.
+
+## Frame generation
+
+The LOW CPU preset stores frame generation as `0` (OFF). The runtime treats an explicit saved menu value of `0` as a hard OFF state. It also explicitly sets `EONACAT_XS_FRAMEGEN_X=0` and removes the DLSS/FSR frame-generation enable switches. This is important because the graphics backend otherwise defaults an unspecified multiplier to 2×; title depth/motion-vector submissions could then turn generation back on later in the run.
+
+Frame generation is separate from the base rendering frame rate. Disabling it means the displayed frame rate will no longer include generated intermediate frames. This can make the displayed FPS number lower than a configuration that uses 2×/3×/4× generation, even when the underlying rendered-frame performance is unchanged.
+
+If you want to re-enable it, use the Frame Generation setting in the menu and choose a supported multiplier. Availability depends on the installed runtime, GPU, driver, and the implementation's current support. The preset's OFF value takes precedence until you change it.
+
+## Requirements
+
+### To run
+
+- Windows 10 or Windows 11, 64-bit.
+- A Direct3D 12-capable GPU and a current compatible graphics driver.
+- The required game/title files in a supported layout.
+- Any optional graphics runtime required by the selected upscaler/frame-generation path. The launcher includes actions for NVIDIA, AMD FSR, and D3D12 runtime setup; use only the runtime appropriate for your hardware and configuration.
+
+### To build from source
+
+- Rust stable with the `x86_64-pc-windows-msvc` target; the workspace declares Rust 1.89 or newer.
+- Visual Studio 2022 Build Tools with **Desktop development with C++** and a Windows SDK.
+- .NET 8 SDK to publish the Windows launcher.
+- .NET 8 Desktop Runtime to run the framework-dependent launcher.
+- Cargo dependencies available locally or network access for the first dependency resolution.
+- A Visual Studio Developer Command Prompt so `cl.exe` and the MSVC linker are available on `PATH`.
+
+## Build from source
+
+Open a **Visual Studio Developer Command Prompt** in the repository root and run:
+
+```bat
+build.bat release
+```
+
+Supported build profiles:
+
+```bat
+build.bat release
+build.bat fast
+build.bat diag
+```
+
+- `release` — optimized release build; the default.
+- `fast` — quicker incremental build profile for development.
+- `diag` — release-derived diagnostic build with the `diagnostics` feature enabled.
+
+The script builds the Windows x64 Rust engine and then publishes the .NET launcher. Expected output locations:
+
+```text
+target\x86_64-pc-windows-msvc\release\eonacat-xsbox.exe
+target\x86_64-pc-windows-msvc\release\launcher\EonaCat.XSBOX.Launcher.exe
+```
+
+For the `fast` and `diag` profiles, replace `release` in the paths with the selected profile name. The launcher is published as framework-dependent and therefore requires the .NET 8 Desktop Runtime on the target PC.
+
+You can also build the engine directly:
+
+```powershell
+rustup target add x86_64-pc-windows-msvc
+cargo build --target x86_64-pc-windows-msvc --profile release -p eonacat-xsbox-engine
+```
+
+Show the engine's command-line help:
+
+```powershell
+.\target\x86_64-pc-windows-msvc\release\eonacat-xsbox.exe --help
+```
+
+## First launch
+
+1. Build the project or obtain a build from a trusted source.
+2. Keep the launcher in the published `launcher` folder next to the engine executable in the profile output directory. The launcher locates the engine relative to its own location.
+3. Start `EonaCat.XSBOX.Launcher.exe`.
+4. Use **Scan for Xbox games** or **Add game folder…** to locate the game files. You can also browse directly to the executable when supported by the launcher.
+5. Select the detected game entry and review the graphics and runtime settings.
+6. Use **Save settings** before launching if you changed options.
+7. Select **Launch game** and monitor the **Installer log** tab for engine output and errors.
+
+The launcher can also run the shader-preparation workflow before gameplay. The first preparation may take several minutes; completed work is cached for later launches.
+
+## Launcher overview
+
+The Windows launcher provides:
+
+- A game library with automatic scanning and manual folder selection.
+- A selected-game view and launch action.
+- Graphics, display/statistics, frame-generation, texture/streaming, memory, controls, and advanced settings pages.
+- A quick profile action labelled **RTX 4090 - UW**. This is a preset/profile starting point; review it for your own GPU and display before applying it.
+- Save-settings and launch controls.
+- Actions to install/check NVIDIA, AMD FSR, and D3D12 runtime components.
+- Shader and pipeline preparation tools, cache maintenance, and an engine output log.
+
+Some settings require a restart to take effect. Runtime availability and the settings actually honored depend on the installed driver and hardware. Do not assume that selecting an option guarantees that the relevant vendor runtime or feature is present.
+
+## Graphics and performance tuning
+
+For a useful baseline, change one setting at a time and compare the same repeatable scene. Record both base FPS and frame time, along with CPU and GPU utilization. Generated frames should be considered separately from rendered frames.
+
+General guidance:
+
+- Lower internal resolution can reduce GPU work, but may make the image softer or expose aliasing/shimmering.
+- DLSS modes require the appropriate NVIDIA runtime and supported hardware. If unavailable, use a supported alternative or turn upscaling off.
+- Ray tracing can be expensive and is disabled in the LOW CPU preset.
+- Unlimited FPS removes the cap, not the underlying CPU/GPU bottleneck.
+- All presets enable batched refresh checks, larger refresh-worker chunks, duplicate state-call coalescing, and more queue-part joining. These are command-processing optimizations and remain active regardless of output resolution or selected quality preset.
+- More shader/pipeline worker threads may improve preparation throughput but can increase CPU contention and memory use during gameplay.
+- Avoid changing several advanced memory, synchronization, or experimental options at once; it makes regressions difficult to isolate.
+
+The runtime has conservative worker defaults. Runtime pipeline compilation defaults to a bounded number of workers based on logical processor count (and host-memory conditions). Offline shader translation and cache warming also use bounded worker counts. Relevant overrides documented in the source include:
+
+```powershell
+$env:EONACAT_XS_PIPELINE_WORKERS = "2"
+$env:EONACAT_XS_CPU_THREADS = "2"
+```
+
+These are examples, not universal recommendations. Remove the environment variables to return to the runtime's automatic defaults.
+
+## Shader preparation and cache
+
+Shader translation and pipeline creation can cause stutter the first time a scene or effect is encountered. The launcher exposes preparation and cache-maintenance actions to reduce some first-use work.
+
+- **Preload/warm:** translates or prepares shader/pipeline data ahead of gameplay where supported. It can take several minutes and uses CPU time and memory.
+- **Clear shader cache:** use only after a translator/driver change or when corruption is suspected. Clearing the cache can make the next launch slower because work must be repeated. Game saves and ordinary game settings are not intended to be removed by this action.
+- Keep the cache between normal launches; it is intended to make subsequent runs smoother.
+
+The exact amount of stutter reduction varies by title build, driver, scene, and cache state. Preloading cannot guarantee that every runtime shader or pipeline will be ready in advance.
+
+## Command-line tools
+
+The engine uses subcommands. The exact options available in a particular build are shown by `eonacat-xsbox.exe --help` and by each subcommand's `--help` output.
+
+The source currently defines these main command families:
+
+| Command | Purpose |
+|---|---|
+| `inspect` | Inspect an executable or binary file; optional import/export details |
+| `census` | Scan supplied paths and report discovered/missing items |
+| `lib-exports` | Inspect/list exports from a library |
+| `shader-info` | Inspect shader-related files; optional verbose/disassembly output |
+| `translate` | Translate shader-related input, optionally validate/list/warm pipelines, and set job count |
+| `shaders` | Run shader processing for supplied paths |
+| `warm` | Windows shader/pipeline cache warming operations |
+| `preload` | Windows preload workflow for supplied paths or selected cache scope |
+| `clear-shaders` | Windows shader-cache maintenance |
+| `play` | Windows title launch workflow |
+| `get-dlss`, `get-fsr`, `get-d3d12` | Runtime setup/check actions used by the launcher |
+| `pads` | Input/controller diagnostic command |
+| `run` | Run a supplied executable using the compatibility host |
+| `config` | Print configuration information |
+| `upscaler-check` | Windows upscaler/presentation/frame-generation diagnostics |
+
+Example help commands:
+
+```powershell
+.\eonacat-xsbox.exe play --help
+.\eonacat-xsbox.exe translate --help
+.\eonacat-xsbox.exe upscaler-check --help
+```
+
+Use the launcher for normal game selection and settings unless you specifically need a command-line workflow. Do not copy command-line switches from another build without checking that build's `--help` output.
+
+## Configuration and data locations
+
+The launcher reports that settings, shaders, caches, and game data are stored under:
+
+```text
+%LOCALAPPDATA%\EonaCat\XS
+```
+
+The engine's in-game menu settings file is selected through `EONACAT_XS_MENU_FILE`; when that variable is not set, the menu can use `EONACAT_XS_HOME` and the `eonacat-xs-settings.txt` file under that home directory. The launcher separately stores its game-library and selected-game metadata in its application data location.
+
+If you use custom environment variables, batch files, or a third-party launcher, remember that they can affect the final runtime configuration. In particular, stale values can override menu selections if a setting is explicitly read by the runtime. When troubleshooting, temporarily remove custom `EONACAT_XS_*` overrides and test with the saved menu profile only.
+
+## Troubleshooting
+
+### The game opens to a black screen
+
+1. Confirm that the selected game folder and executable belong to a title/build supported by this source version.
+2. Check the **Installer log** and the engine's console output for the first error, not only the final black-screen symptom.
+3. Temporarily use a conservative profile: Series S, lower internal resolution, ray tracing off, and frame generation off.
+4. Confirm that the Direct3D 12-capable GPU driver is current and that the required runtime components are installed.
+5. If the launcher or an external script sets `EONACAT_XS_*` variables, remove custom overrides for one test run.
+6. Keep the log from a repeatable launch attempt so the failure stage can be compared.
+
+A visible presentation test or a successful device/present check does not by itself prove that the game rendered a valid frame. A black screen can still originate earlier in title execution, resource loading, shader translation, or the graphics pipeline.
+
+### The frame rate is unexpectedly capped
+
+- Confirm that the active preset is **LOW CPU (UNLIMITED / NO FRAME-GEN)** or that **FRAME RATE CAP** is set to **NONE**.
+- Check that the saved settings are loaded after restart and that no external `EONACAT_XS_FRAME_INTERVAL_*` value is overriding them.
+- The `NONE` setting removes the artificial pacing wait; it does not remove synchronization imposed by the display, driver, or game itself.
+
+### Frame generation turns itself back on
+
+- Set **FRAME GENERATION** to **OFF** and save the menu settings.
+- Restart the title if needed.
+- The current source explicitly treats a saved menu value of `0` as a hard OFF state. If it still appears enabled, verify that the updated executable was built and that the expected settings file is being read.
+
+### First launch is slow or stutters
+
+- Allow shader and pipeline preparation to finish.
+- Keep the shader cache between launches.
+- Avoid clearing caches unless there is a specific reason.
+- Check CPU and memory pressure while shader compilation is running.
+
+### Launcher cannot find the engine
+
+- Keep `EonaCat.XSBOX.Launcher.exe` in the `launcher` folder produced by `build.bat`.
+- Keep `eonacat-xsbox.exe` in the parent profile output folder.
+- Re-run `build.bat` if the expected engine executable was not produced.
+
+### Runtime setup fails
+
+- Check the launcher log for the exact failed action and exit code.
+- Install only the runtime appropriate for your GPU and selected feature.
+- Restart the launcher/game after installing or changing graphics runtime components.
+
+## Project structure
+
+```text
+.
+├── .github/workflows/ CI workflows
+├── assets/ Icons and artwork
+├── crates/
+│ ├── engine/ Runtime, CLI, title launch, compatibility services
+│ ├── game/ Title metadata and package handling
+│ └── graphics/ D3D12/DXGI, shaders, pipelines, GPU memory/presentation
+├── docs/ Engineering and performance notes
+├── launcher/windows/ Windows Forms launcher source
+├── scripts/ Benchmarks and engineering utilities
+├── settings/ Example graphics settings/profiles
+├── bindings.ini Default input bindings
+├── Cargo.toml Rust workspace definition
+├── Cargo.lock Locked Rust dependency versions
+└── build.bat Windows build entry point
+```
+
+Some optional folders may not be present in every source archive or branch. The Rust workspace is defined by the members listed in the root `Cargo.toml`.
+
+## Development and validation
+
+Useful checks from a Windows Developer Command Prompt:
+
+```powershell
+cargo fmt --all -- --check
+cargo check --workspace --target x86_64-pc-windows-msvc
+cargo test --workspace --target x86_64-pc-windows-msvc
+cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc
+```
+
+The repository also contains a Windows CI workflow and a graphics hot-path benchmark script when present in the checkout. Benchmarks of individual CPU routines are not substitutes for full-game CPU/GPU profiling.
+
+For performance investigations, capture:
+
+- Base/rendered FPS and frame time;
+- CPU utilization and per-core load;
+- GPU utilization, GPU frame time, and VRAM use;
+- RAM/commit use;
+- shader/pipeline compilation activity;
+- the exact title build, settings profile, driver version, and log.
+
+Change one variable at a time and compare the same repeatable scene. Avoid interpreting frame-generation output as the base rendering rate.
+
+## License
+
+The root `Cargo.toml` declares `GPL-3.0-or-later`. The archive may not include a root `LICENSE` file, so verify that the corresponding license text and any required third-party notices are included before redistribution. Do not assume that the game files, firmware, vendor runtimes, or other separately supplied assets are covered by this repository's license.
+
+---
+
+**Project:** EonaCat XS / EonaCat.XSBOX
+**Engine executable:** `eonacat-xsbox.exe`
+**Windows launcher:** `EonaCat.XSBOX.Launcher.exe`
+
+
+## In-game menu and overlays (F9 / F10 / F11)
+
+- **F9** opens the branded EonaCat XS control center.
+- **F10** toggles the performance advisor. It is **off by default**, including on the first launch of a new build.
+- **F11** toggles the statistics panel.
diff --git a/assets/eonacat-logo.ico b/assets/eonacat-logo.ico
new file mode 100644
index 0000000..2065fcb
Binary files /dev/null and b/assets/eonacat-logo.ico differ
diff --git a/assets/eonacat-logo.svg b/assets/eonacat-logo.svg
new file mode 100644
index 0000000..74f8e77
--- /dev/null
+++ b/assets/eonacat-logo.svg
@@ -0,0 +1,930 @@
+
+
+
diff --git a/bindings.ini b/bindings.ini
new file mode 100644
index 0000000..11f953b
--- /dev/null
+++ b/bindings.ini
@@ -0,0 +1,27 @@
+# Edit while the game is closed, or save for your next launch.
+# Multiple keys for one button are separated by commas. Mouse1 = left, Mouse2 = right.
+# A-Z, 0-9, named keys below, or Windows virtual key codes such as 0xA2.
+# WheelUp and WheelDown are the mouse wheel: each notch is one short press (about 70 ms,
+# 40 ms apart when queued), e.g. "DpadUp = Up, WheelUp". Bound to nothing by default.
+# Sensitivity is stick deflection per cursor pixel over an 8 ms polling interval.
+Sensitivity = 0.135
+MoveUp = W
+MoveDown = S
+MoveLeft = A
+MoveRight = D
+RT = Mouse1
+LT = Mouse2
+A = Shift, Enter
+B = R, Backspace
+X = Space
+Y = F
+LB = Tab
+RB = Q
+LS = Ctrl
+RS = Mouse3
+Menu = Esc
+View = V
+DpadUp = Up
+DpadDown = Down
+DpadLeft = Left
+DpadRight = Right
diff --git a/build.bat b/build.bat
new file mode 100644
index 0000000..ab2a9c7
--- /dev/null
+++ b/build.bat
@@ -0,0 +1,42 @@
+@echo off
+setlocal EnableExtensions
+cd /d "%~dp0"
+title EonaCat.XSBOX - Build
+set "PROFILE=release"
+set "FEATURES="
+if /i "%~1"=="fast" set "PROFILE=fast"
+if /i "%~1"=="diag" (
+ set "PROFILE=diag"
+ set "FEATURES=--features diagnostics"
+)
+if not "%~1"=="" if /i not "%~1"=="fast" if /i not "%~1"=="diag" if /i not "%~1"=="release" (
+ echo Usage: build.bat [release^|fast^|diag]
+ exit /b 2
+)
+where cargo >nul 2>nul || (echo [ERROR] Install Rust from https://rustup.rs/ & exit /b 10)
+where rustc >nul 2>nul || (echo [ERROR] rustc is missing. & exit /b 11)
+where dotnet >nul 2>nul || (echo [ERROR] Install the .NET 8 SDK to build the Windows launcher. & exit /b 12)
+where cl >nul 2>nul || (
+ echo [ERROR] Run from a Visual Studio Developer Command Prompt with the MSVC C++ build tools installed.
+ exit /b 13
+)
+rustup target add x86_64-pc-windows-msvc
+if errorlevel 1 exit /b 14
+echo Building EonaCat.XSBOX engine (%PROFILE%)...
+cargo build --target x86_64-pc-windows-msvc --profile %PROFILE% -p eonacat-xsbox-engine %FEATURES%
+if errorlevel 1 exit /b 20
+set "OUTPUT=target\x86_64-pc-windows-msvc\%PROFILE%"
+if not exist "%OUTPUT%\eonacat-xsbox.exe" (
+ echo [ERROR] Engine executable was not produced.
+ exit /b 21
+)
+echo Building EonaCat.XSBOX Windows launcher...
+dotnet publish "launcher\windows\EonaCat.XSBOX.Launcher.csproj" --configuration Release --runtime win-x64 --self-contained false --output "%OUTPUT%\launcher"
+if errorlevel 1 exit /b 22
+if exist "assets\eonacat-logo.ico" copy /y "assets\eonacat-logo.ico" "%OUTPUT%\launcher\eonacat-logo.ico" >nul
+echo.
+echo BUILD SUCCESS
+echo Engine: %OUTPUT%\eonacat-xsbox.exe
+echo Launcher: %OUTPUT%\launcher\EonaCat.XSBOX.Launcher.exe
+echo Requires the .NET 8 Desktop Runtime to run the framework-dependent launcher.
+exit /b 0
diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml
new file mode 100644
index 0000000..91e1700
--- /dev/null
+++ b/crates/engine/Cargo.toml
@@ -0,0 +1,45 @@
+[package]
+name = "eonacat-xsbox-engine"
+description = "EonaCat XS engine and command-line host."
+version.workspace = true
+edition.workspace = true
+rust-version.workspace = true
+license.workspace = true
+publish.workspace = true
+
+[[bin]]
+name = "eonacat-xsbox"
+path = "src/main.rs"
+
+[dependencies]
+eonacat-xsbox-game = { path = "../game" }
+eonacat-xsbox-gpu = { path = "../graphics", features = ["host"] }
+anyhow.workspace = true
+blake3.workspace = true
+memchr.workspace = true
+clap.workspace = true
+walkdir.workspace = true
+opus-pure.workspace = true
+zlib-rs.workspace = true
+tracing.workspace = true
+
+[target.'cfg(windows)'.dependencies]
+windows-sys = { workspace = true, features = [
+ "Win32_Devices_DeviceAndDriverInstallation", "Win32_Devices_HumanInterfaceDevice",
+ "Win32_Foundation", "Win32_Globalization", "Win32_Graphics_Dwm", "Win32_Graphics_Gdi",
+ "Win32_Media", "Win32_Security", "Win32_Security_Cryptography", "Win32_Storage_FileSystem",
+ "Win32_System_Console", "Win32_System_Diagnostics_Debug", "Win32_System_Diagnostics_ToolHelp",
+ "Win32_System_IO", "Win32_System_Ioctl", "Win32_System_LibraryLoader", "Win32_System_Memory",
+ "Win32_System_Power", "Win32_System_ProcessStatus", "Win32_System_Registry",
+ "Win32_System_SystemInformation", "Win32_System_Threading", "Win32_UI_HiDpi", "Win32_UI_Input",
+ "Win32_UI_Input_KeyboardAndMouse", "Win32_UI_Input_XboxController", "Win32_UI_WindowsAndMessaging"
+] }
+windows = { workspace = true, features = ["Win32_Foundation", "Win32_Graphics_Direct3D12", "Win32_Graphics_Imaging", "Win32_Media_Audio", "Win32_System_Com", "Win32_System_Com_StructuredStorage", "Win32_System_Threading", "Win32_System_Variant"] }
+windows-core.workspace = true
+
+[features]
+diagnostics = ["eonacat-xsbox-gpu/diagnostics"]
+ab = ["eonacat-xsbox-gpu/ab"]
+
+[lints]
+workspace = true
diff --git a/crates/engine/build.rs b/crates/engine/build.rs
new file mode 100644
index 0000000..b0c15b2
--- /dev/null
+++ b/crates/engine/build.rs
@@ -0,0 +1,22 @@
+
+
+fn main() {
+ match std::env::var("CARGO_CFG_TARGET_ENV").as_deref() {
+ Ok("msvc") => {
+ println!("cargo:rustc-link-arg-bins=/HIGHENTROPYVA:NO");
+ println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKVersion,DATA");
+ println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKPath,DATA");
+ println!("cargo:rustc-link-arg-bins=/DELAYLOAD:d3d12.dll");
+ println!("cargo:rustc-link-arg-bins=delayimp.lib");
+ }
+ _ => {
+ let out = std::env::var("OUT_DIR").expect("cargo sets OUT_DIR");
+ let def = std::path::Path::new(&out).join("eonacat-xs-exports.def");
+ std::fs::write(&def, "EXPORTS\nD3D12SDKVersion DATA\nD3D12SDKPath DATA\n")
+ .expect("the .def is written into OUT_DIR");
+ println!("cargo:rustc-link-arg-bins={}", def.display());
+
+ println!("cargo:rustc-link-arg-bins=-Wl,--disable-high-entropy-va");
+ }
+ }
+}
\ No newline at end of file
diff --git a/crates/engine/src/census.rs b/crates/engine/src/census.rs
new file mode 100644
index 0000000..9cbad7e
--- /dev/null
+++ b/crates/engine/src/census.rs
@@ -0,0 +1,170 @@
+
+
+use std::collections::{BTreeMap, BTreeSet};
+use std::io::{self, Read};
+use std::path::{Path, PathBuf};
+
+use anyhow::{Context, Result};
+use crate::hle::{HleResolver, HostPolicy};
+use eonacat_xsbox_gpu::loader::Provenance;
+use eonacat_xsbox_gpu::pe::{ImageInfo, ImportSymbol};
+
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+enum FunctionKey {
+ Name(String),
+ Ordinal(u16),
+}
+
+impl From<&ImportSymbol> for FunctionKey {
+ fn from(symbol: &ImportSymbol) -> Self {
+ match symbol {
+ ImportSymbol::Name { name, .. } => Self::Name(name.clone()),
+ ImportSymbol::Ordinal(ordinal) => Self::Ordinal(*ordinal),
+ }
+ }
+}
+
+#[derive(Default)]
+struct DllStats {
+ functions: BTreeSet,
+ hle: usize,
+ host: usize,
+ missing: usize,
+ images: BTreeSet,
+}
+
+pub fn run(paths: Vec, strict: bool, list_missing: bool) -> Result<()> {
+ let paths = crate::default_paths(paths)?;
+ let resolver = HleResolver::new(if strict {
+ HostPolicy::none()
+ } else {
+ HostPolicy::default()
+ });
+
+ let mut images = 0usize;
+ let mut seen = BTreeSet::new();
+ let mut failed = Vec::new();
+ let mut dlls: BTreeMap = BTreeMap::new();
+ let mut missing: BTreeMap<(String, String), BTreeSet> = BTreeMap::new();
+
+ for root in &paths {
+ for entry in walkdir::WalkDir::new(root) {
+ let entry = match entry {
+ Ok(entry) => entry,
+ Err(error) if error.depth() == 0 => {
+ return Err(error).context("cannot scan census input");
+ }
+ Err(error) => {
+ failed.push(error.to_string());
+ continue;
+ }
+ };
+ let path = entry.path();
+ if !entry.file_type().is_file() {
+ continue;
+ }
+ match looks_like_pe(path) {
+ Ok(true) => {}
+ Ok(false) => continue,
+ Err(error) => {
+ failed.push(format!("{}: {error}", path.display()));
+ continue;
+ }
+ }
+
+ let identity = path.canonicalize().unwrap_or_else(|_| path.to_path_buf());
+ if !seen.insert(identity) {
+ continue;
+ }
+ let info = match std::fs::read(path)
+ .map_err(anyhow::Error::from)
+ .and_then(|d| ImageInfo::parse(&d).map_err(anyhow::Error::from))
+ {
+ Ok(info) => info,
+ Err(e) => {
+ failed.push(format!("{}: {e}", path.display()));
+ continue;
+ }
+ };
+ images += 1;
+ tally_image(path, &info, &resolver, &mut dlls, &mut missing);
+ }
+ }
+
+ println!("{images} images scanned, {} unreadable", failed.len());
+ for error in &failed {
+ println!(" skipped {error}");
+ }
+ println!(
+ "\n{:<56} {:>6} {:>6} {:>6} {:>8} {:>7}",
+ "dll", "funcs", "hle", "host", "missing", "images"
+ );
+ let (mut f, mut h, mut o, mut m) = (0, 0, 0, 0);
+ for (dll, s) in &dlls {
+ println!(
+ "{dll:<56} {:>6} {:>6} {:>6} {:>8} {:>7}",
+ s.functions.len(),
+ s.hle,
+ s.host,
+ s.missing,
+ s.images.len()
+ );
+ f += s.functions.len();
+ h += s.hle;
+ o += s.host;
+ m += s.missing;
+ }
+ println!("{:<56} {f:>6} {h:>6} {o:>6} {m:>8}", "TOTAL");
+
+ if list_missing {
+ let mut rows: Vec<_> = missing.into_iter().collect();
+ rows.sort_by(|a, b| b.1.len().cmp(&a.1.len()).then_with(|| a.0.cmp(&b.0)));
+ println!("\nmissing (by number of images using it)");
+ for ((dll, sym), users) in rows {
+ println!(" {:>4} {dll}!{sym}", users.len());
+ }
+ }
+ Ok(())
+}
+
+fn looks_like_pe(path: &Path) -> io::Result {
+ let mut magic = [0u8; 2];
+ match std::fs::File::open(path)?.read_exact(&mut magic) {
+ Ok(()) => Ok(&magic == b"MZ"),
+ Err(error) if error.kind() == io::ErrorKind::UnexpectedEof => Ok(false),
+ Err(error) => Err(error),
+ }
+}
+
+fn tally_image(
+ path: &Path,
+ info: &ImageInfo,
+ resolver: &HleResolver,
+ dlls: &mut BTreeMap,
+ missing: &mut BTreeMap<(String, String), BTreeSet>,
+) {
+ for module in info.imports.iter().chain(&info.delay_imports) {
+ let key = module.dll.to_ascii_lowercase();
+ let stats = dlls.entry(key.clone()).or_default();
+ stats.images.insert(path.to_path_buf());
+ for e in &module.entries {
+ let class = resolver.classify(&module.dll, &e.symbol);
+ if class.is_none() {
+ missing
+ .entry((key.clone(), e.symbol.to_string()))
+ .or_default()
+ .insert(path.to_path_buf());
+ }
+
+ if stats.functions.insert(FunctionKey::from(&e.symbol)) {
+ match class {
+ Some(Provenance::Hle) => stats.hle += 1,
+ Some(Provenance::Host) => stats.host += 1,
+ Some(Provenance::Title) => unreachable!("census maps no title DLLs"),
+ None => stats.missing += 1,
+ }
+ }
+ }
+ }
+}
+
diff --git a/crates/engine/src/cpu_budget.rs b/crates/engine/src/cpu_budget.rs
new file mode 100644
index 0000000..055c15b
--- /dev/null
+++ b/crates/engine/src/cpu_budget.rs
@@ -0,0 +1,39 @@
+
+
+use std::num::NonZeroUsize;
+
+pub(crate) fn workers(requested: Option, work_items: Option) -> usize {
+ let available = std::thread::available_parallelism().map_or(2, NonZeroUsize::get);
+ let configured = std::env::var("EONACAT_XS_CPU_THREADS")
+ .ok()
+ .and_then(|value| value.trim().parse::().ok())
+ .filter(|&value| value > 0);
+
+ let count = requested
+ .filter(|&value| value > 0)
+ .or(configured)
+ .unwrap_or_else(|| (available / 2).max(1));
+
+ work_items.map_or(count, |items| count.min(items))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn never_returns_zero() {
+ assert!(workers(Some(0), None) >= 1);
+ assert_eq!(workers(Some(8), Some(0)), 0);
+ }
+
+ #[test]
+ fn explicit_value_is_not_silently_overridden() {
+ assert_eq!(workers(Some(3), Some(8)), 3);
+ }
+
+ #[test]
+ fn work_count_bounds_workers() {
+ assert_eq!(workers(Some(8), Some(2)), 2);
+ }
+}
diff --git a/crates/engine/src/embedded/get-amd-fsr.ps1.txt b/crates/engine/src/embedded/get-amd-fsr.ps1.txt
new file mode 100644
index 0000000..3b991a9
--- /dev/null
+++ b/crates/engine/src/embedded/get-amd-fsr.ps1.txt
@@ -0,0 +1,57 @@
+# Fetches the AMD files FSR 3 frame generation needs (about 30 MB) from AMD's own GitHub (the FidelityFX SDK,
+# GPUOpen-LibrariesAndSDKs/FidelityFX-SDK) into a fidelityfx folder: by default amd-sdk\FidelityFX\bin here
+# (git-ignored), where the EonaCat XS launcher looks for them; `eonacat-xsbox get-fsr` names one under
+# %LOCALAPPDATA%\EonaCat\XS. They are AMD's, under AMD's licence (saved beside them: read it); this repository does
+# not carry them, so each person gets them from AMD directly. Each file is checked against the SHA-256 of the
+# copy this fork was tested with, and the game loads them only with AMD's valid signature.
+param(
+ [string]$Tag = 'v2.4.0',
+ [string]$To = ''
+)
+$ProgressPreference = 'SilentlyContinue'
+[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
+$bin = if ($To) { $To } else { Join-Path (Resolve-Path (Join-Path $PSScriptRoot '..')).Path 'amd-sdk\FidelityFX\bin' }
+$base = "https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/$Tag/Kits/FidelityFX"
+# What the game loads, and the SHA-256 of the copies tested (FidelityFX SDK v2.4.0).
+$files = [ordered]@{
+ 'amd_fidelityfx_loader_dx12.dll' = 'E2191D3C0828BE45EB8AFFD4E3EC0378F2293ADC345B772A7170EDCF3B021ECB'
+ 'amd_fidelityfx_framegeneration_dx12.dll' = 'E6843252F58B0341A0D80F6A20BC0D840643EE95BC48C22CAC08745344577BB6'
+}
+
+function Get-File([string]$Url, [string]$To) {
+ New-Item -ItemType Directory -Force (Split-Path $To) | Out-Null
+ $part = "$To.part"
+ if (Get-Command curl.exe -ErrorAction SilentlyContinue) {
+ & curl.exe --location --fail --silent --show-error --progress-bar --output $part $Url
+ if ($LASTEXITCODE -ne 0) { Remove-Item $part -ErrorAction SilentlyContinue; throw "could not get $Url" }
+ } else {
+ Invoke-WebRequest -Uri $Url -OutFile $part -UseBasicParsing -ErrorAction Stop
+ }
+ $part
+}
+
+Write-Host "AMD FSR 3 frame generation (FidelityFX SDK $Tag), from github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK (about 30 MB):"
+New-Item -ItemType Directory -Force $bin | Out-Null
+foreach ($name in $files.Keys) {
+ $to = Join-Path $bin $name
+ if ((Test-Path $to) -and (Get-FileHash $to -Algorithm SHA256).Hash -eq $files[$name]) {
+ Write-Host " $name already there"
+ continue
+ }
+ $part = Get-File "$base/signedbin/$name" $to
+ $hash = (Get-FileHash $part -Algorithm SHA256).Hash
+ if ($hash -ne $files[$name]) {
+ Remove-Item $part -Force
+ throw "$name is not the file this build was tested with (SHA-256 $hash); not kept"
+ }
+ Move-Item $part $to -Force
+ $len = (Get-Item $to).Length
+ Write-Host (" {0} {1}" -f $name, $(if ($len -ge 1MB) { '{0:N1} MB' -f ($len / 1MB) } else { '{0:N0} KB' -f ($len / 1KB) }))
+}
+try {
+ $lic = Get-File "$base/docs/license.md" (Join-Path $bin 'amd-fidelityfx-license.md')
+ Move-Item $lic (Join-Path $bin 'amd-fidelityfx-license.md') -Force
+ Write-Host " licence: $(Join-Path $bin 'amd-fidelityfx-license.md')"
+} catch { Write-Host " (AMD's licence text could not be fetched: $($_.Exception.Message))" }
+Write-Host ''
+Write-Host 'Done. They are used from the next start.'
diff --git a/crates/engine/src/embedded/get-d3d12.ps1.txt b/crates/engine/src/embedded/get-d3d12.ps1.txt
new file mode 100644
index 0000000..a0cdf3d
--- /dev/null
+++ b/crates/engine/src/embedded/get-d3d12.ps1.txt
@@ -0,0 +1,62 @@
+# Fetches Microsoft's newer Direct3D 12 runtime (the D3D12 Agility SDK, D3D12Core.dll, from Microsoft's own
+# NuGet package Microsoft.Direct3D.D3D12, about 22 MB) into a D3D12 folder: by default the one beside
+# target\release\eonacat-xsbox.exe; `eonacat-xsbox play` names the one beside itself. Windows 10's own Direct3D 12 stops at
+# shader model 6.5, and every shader the layer translates is 6.6: without this runtime each pipeline is refused
+# and the game closes within seconds. eonacat-xsbox.exe asks Windows for this runtime (it exports D3D12SDKVersion = 614
+# and D3D12SDKPath = .\D3D12\); Windows uses it only where its own is older. It is Microsoft's, under Microsoft's
+# licence (saved beside it: read it); this repository does not carry it. The package and the DLL are checked
+# against the SHA-256 of the copies this fork was tested with, and the DLL against Microsoft's signature.
+param(
+ [string]$Version = '1.614.1',
+ [string]$To = ''
+)
+$ErrorActionPreference = 'Stop'
+$ProgressPreference = 'SilentlyContinue'
+[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
+$dir = if ($To) { $To } else { Join-Path (Resolve-Path (Join-Path $PSScriptRoot '..')).Path 'target\release\D3D12' }
+# The SHA-256 of the copies tested: D3D12Core.dll 1.614.1.0 first, since launchers take the first hash after
+# that name as the DLL's (VILauncher's "Fix and verify" took the package's and then refused every package).
+$core = '8A23D826B25B4329522FF451CB52B7F2B34D7F2913CFEB878371CE8BD765FE2D'
+# The package it comes in, Microsoft.Direct3D.D3D12 1.614.1.
+$package = '9880AA91602DD51DD6CF7911A2BCA7A2323513B15338573CDE014B3356EEAFF2'
+$url = "https://api.nuget.org/v3-flatcontainer/microsoft.direct3d.d3d12/$Version/microsoft.direct3d.d3d12.$Version.nupkg"
+
+$target = Join-Path $dir 'D3D12Core.dll'
+if ((Test-Path $target) -and (Get-FileHash $target -Algorithm SHA256).Hash -eq $core) {
+ Write-Host "Microsoft's Direct3D 12 runtime $Version is already in $dir"
+ exit 0
+}
+Write-Host "Microsoft's Direct3D 12 runtime $Version (the Agility SDK), from nuget.org (about 22 MB):"
+New-Item -ItemType Directory -Force $dir | Out-Null
+$part = Join-Path $dir "microsoft.direct3d.d3d12.$Version.nupkg.part"
+try {
+ if (Get-Command curl.exe -ErrorAction SilentlyContinue) {
+ & curl.exe --location --fail --silent --show-error --progress-bar --output $part $url
+ if ($LASTEXITCODE -ne 0) { throw "could not get $url" }
+ } else {
+ Invoke-WebRequest -Uri $url -OutFile $part -UseBasicParsing
+ }
+ $hash = (Get-FileHash $part -Algorithm SHA256).Hash
+ if ($hash -ne $package) { throw "the package is not the one this build was tested with (SHA-256 $hash); not kept" }
+ Add-Type -AssemblyName System.IO.Compression.FileSystem
+ $zip = [IO.Compression.ZipFile]::OpenRead($part)
+ try {
+ $entry = $zip.Entries | Where-Object FullName -eq 'build/native/bin/x64/D3D12Core.dll'
+ if (-not $entry) { throw 'the package has no build/native/bin/x64/D3D12Core.dll' }
+ $dll = "$target.part"
+ [IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $dll, $true)
+ $lic = $zip.Entries | Where-Object FullName -eq 'LICENSE.txt'
+ if ($lic) { [IO.Compression.ZipFileExtensions]::ExtractToFile($lic, (Join-Path $dir 'microsoft-d3d12-license.txt'), $true) }
+ } finally { $zip.Dispose() }
+ $hash = (Get-FileHash $dll -Algorithm SHA256).Hash
+ if ($hash -ne $core) { Remove-Item $dll -Force; throw "D3D12Core.dll is not the file this build was tested with (SHA-256 $hash); not kept" }
+ $sig = Get-AuthenticodeSignature $dll
+ if ($sig.Status -ne 'Valid' -or $sig.SignerCertificate.Subject -notlike 'CN=Microsoft Corporation,*') {
+ Remove-Item $dll -Force; throw "D3D12Core.dll is not validly signed by Microsoft ($($sig.Status)); not kept"
+ }
+ Move-Item $dll $target -Force
+} finally {
+ Remove-Item $part -Force -ErrorAction SilentlyContinue
+}
+Write-Host (' D3D12Core.dll {0:N1} MB, signed by Microsoft' -f ((Get-Item $target).Length / 1MB))
+Write-Host " in $dir (licence: microsoft-d3d12-license.txt beside it)"
diff --git a/crates/engine/src/embedded/get-nvidia-sdks.ps1.txt b/crates/engine/src/embedded/get-nvidia-sdks.ps1.txt
new file mode 100644
index 0000000..143759b
--- /dev/null
+++ b/crates/engine/src/embedded/get-nvidia-sdks.ps1.txt
@@ -0,0 +1,159 @@
+# Fetches the NVIDIA files DLSS and DLSS frame generation need (about 70 MB) from NVIDIA's own GitHub into
+# nvidia-sdk\Streamline\bin\x64 here (git-ignored), where the EonaCat XS launcher looks for them. They are
+# NVIDIA's, under NVIDIA's licences (saved beside them: read them); this repository does not and may not carry
+# them, so each person gets them from NVIDIA directly. the launcher invokes this embedded installer through the engine command.
+# Nothing of NVIDIA's is needed to build the layer: the files are loaded when the game runs.
+param(
+ [string]$StreamlineTag = 'v2.14.16',
+ # Another folder for them than nvidia-sdk here (`eonacat-xsbox get-dlss` names one under %LOCALAPPDATA%\EonaCat\XS).
+ [string]$To = '',
+ # Skip the signature check below (only if NVIDIA's files fail it for a reason you have looked into).
+ [switch]$SkipSignatureCheck
+)
+$ProgressPreference = 'SilentlyContinue' # Invoke-WebRequest's progress bar makes it many times slower
+[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
+$sdk = if ($To) { $To } else { Join-Path (Resolve-Path (Join-Path $PSScriptRoot '..')).Path 'nvidia-sdk' }
+$sl = Join-Path $sdk 'Streamline'
+$bin = Join-Path $sl 'bin\x64'
+# What is loaded when the game runs: Streamline's interposer and plugins, DLSS and the frame generation model.
+$dlls = 'sl.interposer.dll', 'sl.common.dll', 'sl.dlss.dll', 'sl.dlss_g.dll', 'sl.reflex.dll', 'sl.pcl.dll', 'nvngx_dlss.dll', 'nvngx_dlssg.dll'
+
+# One file from a URL, with curl's progress line where Windows has curl (it has since Windows 10 1803).
+function Get-File([string]$Url, [string]$To) {
+ New-Item -ItemType Directory -Force (Split-Path $To) | Out-Null
+ $part = "$To.part"
+ if (Get-Command curl.exe -ErrorAction SilentlyContinue) {
+ & curl.exe --location --fail --silent --show-error --progress-bar --output $part $Url
+ if ($LASTEXITCODE -ne 0) { Remove-Item $part -ErrorAction SilentlyContinue; throw "could not get $Url" }
+ } else {
+ Invoke-WebRequest -Uri $Url -OutFile $part -UseBasicParsing -ErrorAction Stop
+ }
+ Move-Item $part $To -Force
+}
+
+# Bytes first..last of a URL.
+function Get-Range([string]$Url, [long]$First, [long]$Last) {
+ $q = [Net.HttpWebRequest]::Create($Url)
+ $q.UserAgent = 'get-nvidia-sdks'
+ $q.AddRange($First, $Last)
+ $r = $q.GetResponse()
+ try {
+ if ([int]$r.StatusCode -ne 206) { throw 'the server does not give parts of the file' }
+ $m = New-Object IO.MemoryStream
+ $r.GetResponseStream().CopyTo($m)
+ , $m.ToArray()
+ } finally { $r.Close() }
+}
+
+# Takes the named files out of a zip on a server without downloading the whole zip: its directory is at
+# its end, and each file in it can be asked for by its place. $Want: a regex on the paths in the zip.
+# Each goes into $Into under the part of its path after the SDK's top folder.
+function Get-FromZip([string]$Url, [string]$Want, [string]$Into) {
+ # Where the file really is (the download address redirects), and how long it is.
+ $h = [Net.HttpWebRequest]::Create($Url); $h.Method = 'HEAD'; $h.UserAgent = 'get-nvidia-sdks'
+ $r = $h.GetResponse(); $real = $r.ResponseUri.AbsoluteUri; $length = $r.ContentLength; $r.Close()
+ $tailLen = [Math]::Min($length, 2MB)
+ $tail = Get-Range $real ($length - $tailLen) ($length - 1)
+ $end = -1
+ for ($i = $tail.Length - 22; $i -ge 0; $i--) {
+ if ($tail[$i] -eq 0x50 -and $tail[$i + 1] -eq 0x4b -and $tail[$i + 2] -eq 5 -and $tail[$i + 3] -eq 6) { $end = $i; break }
+ }
+ if ($end -lt 0) { throw 'no zip directory found' }
+ $dirSize = [BitConverter]::ToUInt32($tail, $end + 12)
+ $dirAt = [BitConverter]::ToUInt32($tail, $end + 16)
+ if ($dirAt -eq [uint32]::MaxValue) { throw 'a zip64 archive' }
+ $dir = if ($dirAt -ge $length - $tailLen) {
+ $from = [int]($dirAt - ($length - $tailLen)); , $tail[$from..($from + $dirSize - 1)]
+ } else { Get-Range $real $dirAt ($dirAt + $dirSize - 1) }
+ $got = 0
+ $at = 0
+ while ($at + 46 -le $dir.Length -and [BitConverter]::ToUInt32($dir, $at) -eq 0x02014b50) {
+ $method = [BitConverter]::ToUInt16($dir, $at + 10)
+ $packed = [BitConverter]::ToUInt32($dir, $at + 20)
+ $size = [BitConverter]::ToUInt32($dir, $at + 24)
+ $nameLen = [BitConverter]::ToUInt16($dir, $at + 28)
+ $extraLen = [BitConverter]::ToUInt16($dir, $at + 30)
+ $noteLen = [BitConverter]::ToUInt16($dir, $at + 32)
+ $headerAt = [BitConverter]::ToUInt32($dir, $at + 42)
+ $name = [Text.Encoding]::UTF8.GetString($dir, $at + 46, $nameLen)
+ $at += 46 + $nameLen + $extraLen + $noteLen
+ if ($name -notmatch $Want) { continue }
+ # The file's own header (its extra field may be longer than the directory's), then its bytes.
+ $piece = Get-Range $real $headerAt ($headerAt + 30 + $nameLen + 2048 + $packed - 1)
+ if ([BitConverter]::ToUInt32($piece, 0) -ne 0x04034b50) { throw "no file header for $name" }
+ $dataAt = 30 + [BitConverter]::ToUInt16($piece, 26) + [BitConverter]::ToUInt16($piece, 28)
+ if ($dataAt + $packed -gt $piece.Length) { throw "the header of $name is longer than expected" }
+ $out = [IO.MemoryStream]::new()
+ if ($method -eq 0) { $out.Write($piece, $dataAt, [int]$packed) }
+ elseif ($method -eq 8) {
+ $in = [IO.MemoryStream]::new($piece, $dataAt, [int]$packed)
+ $z = [IO.Compression.DeflateStream]::new($in, [IO.Compression.CompressionMode]::Decompress)
+ $z.CopyTo($out); $z.Close()
+ } else { throw "$name is packed in a way this script does not know ($method)" }
+ if ($out.Length -ne $size) { throw "$name came out $($out.Length) bytes long, not $size" }
+ $rel = ($name -replace '^.*?(?=(bin/x64/|license\.txt$))', '') -replace '/', '\'
+ $to = Join-Path $Into $rel
+ New-Item -ItemType Directory -Force (Split-Path $to) | Out-Null
+ [IO.File]::WriteAllBytes($to, $out.ToArray())
+ Write-Host (" {0} {1:N1} MB" -f $rel, ($size / 1MB))
+ $got++
+ }
+ $got
+}
+
+# These DLLs are loaded into the game's process, so each one must carry a valid Authenticode signature
+# from NVIDIA before it is kept. A file that fails is deleted, so a bad download is never used by accident.
+function Assert-NvidiaSigned([string[]]$Names) {
+ if ($SkipSignatureCheck) { Write-Host ' signature check skipped (-SkipSignatureCheck)'; return }
+ $bad = @()
+ foreach ($n in $Names) {
+ $f = Join-Path $bin $n
+ if (-not (Test-Path $f)) { continue }
+ $sig = Get-AuthenticodeSignature -FilePath $f
+ $who = if ($sig.SignerCertificate) { $sig.SignerCertificate.Subject } else { '' }
+ if ($sig.Status -ne 'Valid' -or $who -notmatch 'NVIDIA') {
+ $bad += "$n ($($sig.Status)$(if ($who) { ', ' + $who }))"
+ Remove-Item $f -Force -ErrorAction SilentlyContinue
+ }
+ }
+ if ($bad) { throw "Not signed by NVIDIA, removed: $($bad -join '; '). Run again, or see -SkipSignatureCheck." }
+ Write-Host ' signatures: all valid, signed by NVIDIA'
+}
+
+Write-Host "NVIDIA Streamline $StreamlineTag with DLSS and frame generation, from github.com/NVIDIA-RTX/Streamline (about 70 MB):"
+$missing = @($dlls | Where-Object { -not (Test-Path (Join-Path $bin $_)) })
+if (-not $missing) {
+ Write-Host " all there already: $bin"
+} else {
+ $url = "https://github.com/NVIDIA-RTX/Streamline/releases/download/$StreamlineTag/streamline-sdk-$StreamlineTag.zip"
+ $names = ($dlls | ForEach-Object { [regex]::Escape($_) }) -join '|'
+ $want = "(^|/)bin/x64/($names|[^/]*license[^/]*\.txt)$|^([^/]+/)?license\.txt$"
+ try { [void](Get-FromZip $url $want $sl) }
+ catch { Write-Host " Taking the files out of the archive in place did not work ($($_.Exception.Message))." }
+ if (@($dlls | Where-Object { -not (Test-Path (Join-Path $bin $_)) })) {
+ # The whole archive then (263 MB).
+ Write-Host ' Getting the whole archive instead (263 MB) ...'
+ $zip = Join-Path $sdk "streamline-sdk-$StreamlineTag.zip"
+ Get-File $url $zip
+ $into = Join-Path $sdk 'streamline-unpacked'
+ Expand-Archive -Path $zip -DestinationPath $into -Force -ErrorAction Stop
+ $found = Get-ChildItem $into -Recurse -Filter 'sl.interposer.dll' |
+ Where-Object { $_.FullName -match '\\bin\\x64\\sl\.interposer\.dll$' -and $_.FullName -notmatch '\\development\\' } |
+ Select-Object -First 1
+ if (-not $found) { throw 'The Streamline archive has no bin\x64\sl.interposer.dll.' }
+ $top = Split-Path (Split-Path (Split-Path $found.FullName))
+ New-Item -ItemType Directory -Force $bin | Out-Null
+ Get-ChildItem (Join-Path $top 'bin\x64') -File |
+ Where-Object { $dlls -contains $_.Name -or $_.Name -match 'license.*\.txt$' } |
+ Copy-Item -Destination $bin -Force
+ Copy-Item (Join-Path $top 'license.txt') $sl -Force -ErrorAction SilentlyContinue
+ Remove-Item $into -Recurse -Force -ErrorAction SilentlyContinue
+ Remove-Item $zip -Force
+ }
+}
+Assert-NvidiaSigned $dlls
+$still = @($dlls | Where-Object { -not (Test-Path (Join-Path $bin $_)) })
+if ($still) { throw "Not there after all: $($still -join ', ')" }
+Write-Host " licences: $(Join-Path $sl 'license.txt') (Streamline) and the *.license.txt files in $bin (DLSS, Reflex)"
+Write-Host ''
+Write-Host 'Done. They are used from the next start.'
\ No newline at end of file
diff --git a/crates/engine/src/heap_budget.rs b/crates/engine/src/heap_budget.rs
new file mode 100644
index 0000000..60eb798
--- /dev/null
+++ b/crates/engine/src/heap_budget.rs
@@ -0,0 +1,127 @@
+
+
+use anyhow::{Context, Result, ensure};
+use eonacat_xsbox_gpu::loader::PreparedImage;
+
+use super::native_1440p::{RETAIL_BUILD, same};
+
+const SERIES_X_TABLE: u32 = 0x0618_6250 + 0x50;
+
+const RT_HEAP: u32 = SERIES_X_TABLE + 8 + 2 * 8;
+const STOCK_TOTAL: u64 = 13_312 << 20;
+const STOCK_RT_HEAP: u64 = 2_199 << 20;
+
+pub(super) fn rt_heap_asked() -> Option {
+ let mb: u64 = std::env::var("EONACAT_XS_RT_HEAP_MB").ok()?.trim().parse().ok()?;
+ let bytes = mb.checked_mul(1 << 20)?;
+ (bytes > STOCK_RT_HEAP && mb <= 24 * 1024).then_some(bytes)
+}
+
+pub(super) fn prepare_rt_heap(image: &mut PreparedImage, bytes: u64) -> Result<()> {
+ ensure!(
+ image.original_hash.to_hex().as_str() == RETAIL_BUILD,
+ "the render-target heap is only known for the retail build {RETAIL_BUILD}"
+ );
+ let total = u64::from_le_bytes(*field::<8>(image, SERIES_X_TABLE)?);
+ let heap = u64::from_le_bytes(*field::<8>(image, RT_HEAP)?);
+ ensure!(
+ total == STOCK_TOTAL && heap == STOCK_RT_HEAP,
+ "the Series X heap table is not the stock one (total {total:#x}, heap 2 {heap:#x})"
+ );
+ ensure!(bytes > heap, "the render-target heap asked for is not bigger than the stock one");
+ *field::<8>(image, RT_HEAP)? = bytes.to_le_bytes();
+ *field::<8>(image, SERIES_X_TABLE)? = (total + (bytes - heap)).to_le_bytes();
+ Ok(())
+}
+
+const SCENE_POOL_UNITS: u32 = 0x01d4_88ac;
+const STOCK_SCENE_POOL: &str = "24ee573f2d52472e3a964bcf583618cb9f02f00ec4d9d98735fdab6bd3034a88";
+const STOCK_UNITS: u32 = 0x2c60;
+
+pub(super) fn scene_pool_asked() -> Option {
+ let mb: u32 = std::env::var("EONACAT_XS_SCENE_POOL_MB").ok()?.trim().parse().ok()?;
+ let units = mb.checked_mul(16)?;
+ (units > STOCK_UNITS && units <= 0xffff).then_some(units)
+}
+
+pub(super) fn prepare_scene_pool(image: &mut PreparedImage, units: u32) -> Result {
+ ensure!(
+ image.original_hash.to_hex().as_str() == RETAIL_BUILD,
+ "the scene pool is only known for the retail build {RETAIL_BUILD}"
+ );
+ ensure!(units > STOCK_UNITS && units <= 0xffff, "the scene pool asked for is not bigger than the stock one");
+ ensure!(same(&field::<10>(image, SCENE_POOL_UNITS)?[..], STOCK_SCENE_POOL), "unexpected scene pool unit counts");
+ let array = relocate_unit_array(image, units)?;
+ field::<10>(image, SCENE_POOL_UNITS)?[6..10].copy_from_slice(&units.to_le_bytes());
+ Ok(array)
+}
+
+const UNIT_ARRAY_LEAS: [(u32, &str); 4] = [
+ (0x0247_3fa1, "b7518a48bc0007deaa9966263959502315c9561f0fbc5ef8bb2623f6f104ab2a"),
+ (0x0247_4079, "16882fd85dc4b9c44488bb550045230deb00eadcb0221819e2a1b67b845321bb"),
+ (0x0247_40ec, "4a927d3bf20744b6f3eb7094de6a6ac4fb05b379da6857c8e201b614de915c4a"),
+ (0x05eb_278d, "91f9b4974217482cdbfa4505b428080afa2e8b1fb49d5e8b22983da0ef30bdf8"),
+];
+
+fn relocate_unit_array(image: &mut PreparedImage, units: u32) -> Result {
+ for &(rva, stock) in &UNIT_ARRAY_LEAS {
+ ensure!(same(&field::<7>(image, rva)?[..], stock), "the scene pool's array is not taken where the stock image takes it (+{rva:#x})");
+ }
+ let section = add_section(image, b".vicpool", units as usize * 8 + 0x1000)?;
+ for &(rva, _) in &UNIT_ARRAY_LEAS {
+ let disp = i32::try_from(i64::from(section) - (i64::from(rva) + 7)).context("the new array is out of reach")?;
+ field::<7>(image, rva)?[3..7].copy_from_slice(&disp.to_le_bytes());
+ }
+ Ok(section)
+}
+
+fn add_section(image: &mut PreparedImage, name: &[u8; 8], size: usize) -> Result {
+ const UNINITIALISED_READ_WRITE: u32 = 0xc000_0080;
+ let b = &mut image.bytes;
+ let u16_at = |b: &[u8], o: usize| b.get(o..o + 2).map(|v| u16::from_le_bytes([v[0], v[1]]));
+ let u32_at = |b: &[u8], o: usize| b.get(o..o + 4).map(|v| u32::from_le_bytes([v[0], v[1], v[2], v[3]]));
+ let short = "incomplete image headers";
+ let pe = u32_at(b, 0x3c).context(short)? as usize;
+ ensure!(b.get(pe..pe + 4) == Some(b"PE\0\0".as_slice()), "no PE header");
+ let file = pe + 4;
+ let count = usize::from(u16_at(b, file + 2).context(short)?);
+ let optional = file + 20;
+ ensure!(u16_at(b, optional) == Some(0x20b), "not a PE32+ image");
+ let align = u32_at(b, optional + 32).context(short)?;
+ ensure!(align.is_power_of_two(), "unexpected section alignment");
+ let size_of_image_at = optional + 56;
+ let headers = u32_at(b, optional + 60).context(short)? as usize;
+ let table = optional + usize::from(u16_at(b, file + 16).context(short)?);
+ let slot = table + count * 40;
+ ensure!(slot + 40 <= headers && headers <= b.len(), "no room in the headers for another section");
+ ensure!(b[slot..slot + 40].iter().all(|&x| x == 0), "the next section header slot is not empty");
+
+ let end = (0..count)
+ .filter_map(|i| u32_at(b, table + i * 40 + 12)?.checked_add(u32_at(b, table + i * 40 + 8)?))
+ .max()
+ .context("no sections")?;
+ let rva = end.checked_next_multiple_of(align).context("image too big")?;
+ ensure!(Some(rva) == u32_at(b, size_of_image_at), "the last section does not end at the image's size");
+ let virtual_size = u32::try_from(size).ok().and_then(|s| s.checked_next_multiple_of(align)).context("section too big")?;
+ let new_size = rva.checked_add(virtual_size).context("image too big")?;
+ b[slot..slot + 8].copy_from_slice(name);
+ b[slot + 8..slot + 12].copy_from_slice(&virtual_size.to_le_bytes());
+ b[slot + 12..slot + 16].copy_from_slice(&rva.to_le_bytes());
+
+ b[slot + 36..slot + 40].copy_from_slice(&UNINITIALISED_READ_WRITE.to_le_bytes());
+ b[file + 2..file + 4].copy_from_slice(&u16::try_from(count + 1).context("too many sections")?.to_le_bytes());
+ b[size_of_image_at..size_of_image_at + 4].copy_from_slice(&new_size.to_le_bytes());
+ image.info.size_of_image = new_size;
+ Ok(rva)
+}
+
+fn field(image: &mut PreparedImage, rva: u32) -> Result<&mut [u8; N]> {
+ let offset = image.info.rva_to_file_offset(rva).context("memory budget field missing")? as usize;
+ image
+ .bytes
+ .get_mut(offset..offset + N)
+ .context("incomplete memory budget field")?
+ .try_into()
+ .context("invalid memory budget field length")
+}
+
diff --git a/crates/engine/src/hle/awake.rs b/crates/engine/src/hle/awake.rs
new file mode 100644
index 0000000..da1c641
--- /dev/null
+++ b/crates/engine/src/hle/awake.rs
@@ -0,0 +1,83 @@
+
+
+pub fn asked() -> bool {
+ asked_for(std::env::var("EONACAT_XS_KEEP_AWAKE").ok().as_deref())
+}
+
+fn asked_for(value: Option<&str>) -> bool {
+ value != Some("0")
+}
+
+#[cfg(windows)]
+#[must_use = "the request is let go as soon as the guard is dropped"]
+pub struct Awake {
+ request: *mut std::ffi::c_void,
+}
+
+#[cfg(not(windows))]
+#[must_use = "the request is let go as soon as the guard is dropped"]
+pub struct Awake;
+
+#[cfg(windows)]
+pub fn hold() -> Option {
+ use windows_sys::Win32::Foundation::CloseHandle;
+ use windows_sys::Win32::System::Power::{
+ PowerCreateRequest, PowerRequestDisplayRequired, PowerRequestSystemRequired,
+ PowerSetRequest,
+ };
+ use windows_sys::Win32::System::Threading::{
+ POWER_REQUEST_CONTEXT_SIMPLE_STRING, REASON_CONTEXT,
+ };
+
+ let mut reason: Vec = "eonacat-xs: the title is running\0".encode_utf16().collect();
+ let mut context = REASON_CONTEXT {
+ Flags: POWER_REQUEST_CONTEXT_SIMPLE_STRING,
+ ..Default::default()
+ };
+ context.Reason.SimpleReasonString = reason.as_mut_ptr();
+
+ let request = unsafe { PowerCreateRequest(&context) };
+ if request.is_null() || request as isize == -1 {
+ tracing::info!("the screen's power request was not created");
+ return None;
+ }
+ for flag in [PowerRequestDisplayRequired, PowerRequestSystemRequired] {
+
+ if unsafe { PowerSetRequest(request, flag) } == 0 {
+ tracing::info!(flag, "the screen's power request was refused");
+
+ unsafe {
+ windows_sys::Win32::System::Power::PowerClearRequest(
+ request,
+ PowerRequestDisplayRequired,
+ );
+ CloseHandle(request);
+ }
+ return None;
+ }
+ }
+ Some(Awake { request })
+}
+
+#[cfg(not(windows))]
+pub fn hold() -> Option {
+ None
+}
+
+#[cfg(windows)]
+impl Drop for Awake {
+ fn drop(&mut self) {
+ use windows_sys::Win32::Foundation::CloseHandle;
+ use windows_sys::Win32::System::Power::{
+ PowerClearRequest, PowerRequestDisplayRequired, PowerRequestSystemRequired,
+ };
+
+ unsafe {
+ for flag in [PowerRequestDisplayRequired, PowerRequestSystemRequired] {
+ PowerClearRequest(self.request, flag);
+ }
+ CloseHandle(self.request);
+ }
+ }
+}
+
diff --git a/crates/engine/src/hle/console_window.rs b/crates/engine/src/hle/console_window.rs
new file mode 100644
index 0000000..36f58ef
--- /dev/null
+++ b/crates/engine/src/hle/console_window.rs
@@ -0,0 +1,82 @@
+
+
+use windows_sys::Win32::Foundation::{GENERIC_READ, GENERIC_WRITE, INVALID_HANDLE_VALUE};
+use windows_sys::Win32::Storage::FileSystem::{CreateFileW, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING};
+use windows_sys::Win32::System::Console::{
+ AllocConsole, FreeConsole, GetConsoleWindow, STD_ERROR_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
+ SetStdHandle,
+};
+use windows_sys::Win32::UI::WindowsAndMessaging::{
+ SW_HIDE, SW_RESTORE, SW_SHOW, SetForegroundWindow, ShowWindow,
+};
+use windows_sys::core::w;
+
+pub fn hide() {
+ if std::env::var_os("EONACAT_XS_CONSOLE").is_some_and(|v| v == "1") {
+ return;
+ }
+
+ unsafe {
+ let hwnd = GetConsoleWindow();
+ if hwnd.is_null() {
+ return;
+ }
+ ShowWindow(hwnd, SW_HIDE);
+ }
+ tracing::info!("console hidden (F5 shows it)");
+}
+
+pub fn show() {
+
+ unsafe {
+ let mut hwnd = GetConsoleWindow();
+ if hwnd.is_null() {
+
+ FreeConsole();
+ if AllocConsole() == 0 {
+ tracing::warn!("F5: could not open a console window");
+ return;
+ }
+ attach_std_handles();
+ hwnd = GetConsoleWindow();
+ if hwnd.is_null() {
+ return;
+ }
+ }
+ ShowWindow(hwnd, SW_SHOW);
+ ShowWindow(hwnd, SW_RESTORE);
+ SetForegroundWindow(hwnd);
+ }
+ tracing::info!("console shown (F5)");
+}
+
+unsafe fn attach_std_handles() {
+
+ unsafe {
+ let out = CreateFileW(
+ w!("CONOUT$"),
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ std::ptr::null(),
+ OPEN_EXISTING,
+ 0,
+ std::ptr::null_mut(),
+ );
+ if out != INVALID_HANDLE_VALUE {
+ SetStdHandle(STD_OUTPUT_HANDLE, out);
+ SetStdHandle(STD_ERROR_HANDLE, out);
+ }
+ let input = CreateFileW(
+ w!("CONIN$"),
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ std::ptr::null(),
+ OPEN_EXISTING,
+ 0,
+ std::ptr::null_mut(),
+ );
+ if input != INVALID_HANDLE_VALUE {
+ SetStdHandle(STD_INPUT_HANDLE, input);
+ }
+ }
+}
diff --git a/crates/engine/src/hle/host.rs b/crates/engine/src/hle/host.rs
new file mode 100644
index 0000000..efcda82
--- /dev/null
+++ b/crates/engine/src/hle/host.rs
@@ -0,0 +1,165 @@
+
+
+use eonacat_xsbox_gpu::pe::ImportSymbol;
+
+#[derive(Debug, Clone)]
+pub struct HostPolicy {
+
+ pub allow: Vec,
+}
+
+impl Default for HostPolicy {
+ fn default() -> Self {
+ let allow = [
+ "api-ms-win-core-*",
+ "api-ms-win-eventing-*",
+ "api-ms-win-security-*",
+ "api-ms-win-crt-*",
+ "kernel32.dll",
+ "kernelbase.dll",
+ "ntdll.dll",
+ "ucrtbase.dll",
+ "vcruntime140*",
+ "msvcp140*",
+
+ "ws2_32.dll",
+ "bcrypt.dll",
+ "crypt32.dll",
+ "ncrypt.dll",
+ "winhttp.dll",
+ "sspicli.dll",
+ "cabinet.dll",
+ "avrt.dll",
+
+ "ext-ms-win-rtcore-ntuser-*",
+ "api-ms-win-shcore-*",
+ "msvcp_win.dll",
+ "ole32.dll",
+ "advapi32.dll",
+ "iphlpapi.dll",
+
+ "dbghelp.dll",
+
+ "xaudio2_9.dll",
+ "mfplat.dll",
+ "mfreadwrite.dll",
+ ];
+ HostPolicy {
+ allow: allow.iter().map(|s| s.to_string()).collect(),
+ }
+ }
+}
+
+pub(crate) fn is_bare_dll_name(dll: &str) -> bool {
+ !dll.is_empty() && dll != "." && dll != ".." && !dll.contains(['\\', '/', ':', '\0'])
+}
+
+impl HostPolicy {
+
+ pub fn none() -> Self {
+ HostPolicy { allow: Vec::new() }
+ }
+
+ pub fn allows(&self, dll: &str) -> bool {
+ if !is_bare_dll_name(dll) {
+ return false;
+ }
+ let dll = dll.to_ascii_lowercase();
+ self.allow
+ .iter()
+ .any(|pattern| match pattern.strip_suffix('*') {
+ Some(prefix) => dll.starts_with(prefix),
+ None => dll == *pattern,
+ })
+ }
+
+ pub(crate) fn resolve(&self, dll: &str, symbol: &ImportSymbol) -> Option {
+ if !self.allows(dll) {
+ return None;
+ }
+ let address = imp::resolve(dll, symbol)?;
+
+ #[cfg(windows)]
+ if let ImportSymbol::Name { name, .. } = symbol {
+ let ours = eonacat_xsbox_gpu::titlewrite::import(name, address);
+
+ let ours = eonacat_xsbox_gpu::heap_hooks::import(name, ours);
+ if ours != address {
+ return Some(ours);
+ }
+ }
+
+ #[cfg(all(windows, feature = "diagnostics"))]
+ if let ImportSymbol::Name { name, .. } = symbol {
+ return Some(eonacat_xsbox_gpu::timeline::import(name, address));
+ }
+ Some(address)
+ }
+}
+
+pub(crate) fn function(dll: &str, name: &str) -> Option {
+ let name = ImportSymbol::Name {
+ hint: 0,
+ name: name.into(),
+ };
+ imp::resolve(dll, &name)
+}
+
+#[cfg(windows)]
+mod imp {
+ use std::collections::HashMap;
+ use std::ffi::CString;
+ use std::sync::{LazyLock, Mutex};
+
+ use eonacat_xsbox_gpu::pe::ImportSymbol;
+ use windows_sys::Win32::System::LibraryLoader::{
+ GetProcAddress, LOAD_LIBRARY_SEARCH_SYSTEM32, LoadLibraryExA,
+ };
+
+ static MODULES: LazyLock>> = LazyLock::new(Default::default);
+
+ pub(super) fn resolve(dll: &str, symbol: &ImportSymbol) -> Option {
+ let module = module(dll)?;
+ let proc = match symbol {
+ ImportSymbol::Name { name, .. } => {
+ let name = CString::new(name.as_str()).ok()?;
+
+ unsafe { GetProcAddress(module as _, name.as_ptr().cast()) }
+ }
+
+ ImportSymbol::Ordinal(o) => unsafe { GetProcAddress(module as _, *o as usize as _) },
+ };
+ proc.map(|f| f as *const () as usize)
+ }
+
+ fn module(dll: &str) -> Option {
+ if !super::is_bare_dll_name(dll) {
+ return None;
+ }
+ let key = dll.to_ascii_lowercase();
+ let cache = || MODULES.lock().unwrap_or_else(|e| e.into_inner());
+ let cached = cache().get(&key).copied();
+ if cached.is_some() {
+ return cached;
+ }
+ let name = CString::new(key.as_str()).ok()?;
+
+ let handle = unsafe {
+ LoadLibraryExA(
+ name.as_ptr().cast(),
+ std::ptr::null_mut(),
+ LOAD_LIBRARY_SEARCH_SYSTEM32,
+ )
+ } as usize;
+
+ (handle != 0).then(|| *cache().entry(key).or_insert(handle))
+ }
+
+}
+
+#[cfg(not(windows))]
+mod imp {
+ pub(super) fn resolve(_dll: &str, _symbol: &eonacat_xsbox_gpu::pe::ImportSymbol) -> Option {
+ None
+ }
+}
diff --git a/crates/engine/src/hle/image_watch.rs b/crates/engine/src/hle/image_watch.rs
new file mode 100644
index 0000000..ab04670
--- /dev/null
+++ b/crates/engine/src/hle/image_watch.rs
@@ -0,0 +1,123 @@
+
+
+use std::time::Duration;
+
+struct Word {
+ name: String,
+ offset: usize,
+ bytes: usize,
+}
+
+fn words(text: &str) -> Vec {
+ text.split(',')
+ .filter_map(|part| {
+ let (name, rest) = part.trim().split_once('=')?;
+ let (offset, bytes) = rest.split_once(':').unwrap_or((rest, "8"));
+ let offset = usize::from_str_radix(offset.trim().trim_start_matches("0x"), 16).ok()?;
+ let bytes = bytes.trim().parse().ok().filter(|n| matches!(n, 1 | 2 | 4 | 8))?;
+ Some(Word { name: name.trim().to_owned(), offset, bytes })
+ })
+ .collect()
+}
+
+fn held(text: &str) -> Vec<(Word, u64)> {
+ text.split(',')
+ .filter_map(|part| {
+ let (word, value) = part.trim().rsplit_once('=')?;
+ let value = value.trim();
+ let value = match value.strip_prefix("0x") {
+ Some(hex) => u64::from_str_radix(hex, 16).ok()?,
+ None => value.parse().ok()?,
+ };
+ Some((words(word).pop()?, value))
+ })
+ .collect()
+}
+
+fn write(base: usize, word: &Word, value: u64) -> bool {
+ use windows_sys::Win32::System::Diagnostics::Debug::WriteProcessMemory;
+ use windows_sys::Win32::System::Threading::GetCurrentProcess;
+ let bytes = value.to_le_bytes();
+
+ let ok = unsafe {
+ WriteProcessMemory(GetCurrentProcess(), (base + word.offset) as *mut _, bytes.as_ptr().cast(), word.bytes, std::ptr::null_mut())
+ };
+ ok != 0
+}
+
+fn hold(base: usize) {
+ let Ok(text) = std::env::var("EONACAT_XS_IMAGE_HOLD") else {
+ return;
+ };
+ let held = held(&text);
+ if base == 0 || held.is_empty() {
+ return;
+ }
+ let names: Vec = held.iter().map(|(word, value)| format!("{}={value}", word.name)).collect();
+ tracing::info!("the title's image: holding {} (EONACAT_XS_IMAGE_HOLD)", names.join(" "));
+ let _ = std::thread::Builder::new().name("eonacat-xs-image-hold".into()).spawn(move || {
+ let mut failed = false;
+ loop {
+ for (word, value) in &held {
+ if !write(base, word, *value) && !failed {
+ failed = true;
+ tracing::warn!(word = %word.name, "the title's image: a held word cannot be written (EONACAT_XS_IMAGE_HOLD)");
+ }
+ }
+ std::thread::sleep(Duration::from_millis(100));
+ }
+ });
+}
+
+fn read(base: usize, word: &Word) -> Option {
+ use windows_sys::Win32::System::Diagnostics::Debug::ReadProcessMemory;
+ use windows_sys::Win32::System::Threading::GetCurrentProcess;
+ let mut value = [0u8; 8];
+
+ let ok = unsafe {
+ ReadProcessMemory(
+ GetCurrentProcess(),
+ (base + word.offset) as *const _,
+ value.as_mut_ptr().cast(),
+ word.bytes,
+ std::ptr::null_mut(),
+ )
+ };
+ (ok != 0).then(|| u64::from_le_bytes(value))
+}
+
+pub(crate) fn start(base: usize) {
+ static HOLDING: std::sync::Once = std::sync::Once::new();
+ HOLDING.call_once(|| hold(base));
+ let Ok(text) = std::env::var("EONACAT_XS_IMAGE_WATCH") else {
+ return;
+ };
+ let words = words(&text);
+ if base == 0 || words.is_empty() {
+ return;
+ }
+ static STARTED: std::sync::Once = std::sync::Once::new();
+ STARTED.call_once(|| {
+ let _ = std::thread::Builder::new().name("eonacat-xs-image-watch".into()).spawn(move || {
+ let mut last = Vec::new();
+ loop {
+ std::thread::sleep(Duration::from_secs(1));
+ let now: Vec