diff --git a/build.sh b/build.sh index 2a95dcee411..eab9007f8c7 100755 --- a/build.sh +++ b/build.sh @@ -29,6 +29,9 @@ fi if python3 "$kit/check_inputs.py" "$src" "$kit/final-files.json" >/dev/null 2>&1; then git -C "$src" apply --unidiff-zero "$kit/followup.patch.txt" fi +if python3 "$kit/check_inputs.py" "$src" "$kit/followup-files.json" >/dev/null 2>&1; then + git -C "$src" apply "$kit/card-buffers-min-kb.patch.txt" +fi sh "$kit/verify.sh" "$src" cd "$src" exec cargo build --locked --offline --profile diag -p victory --features diagnostics --target x86_64-pc-windows-msvc diff --git a/docs/linux-notes-5090.md b/docs/linux-notes-5090.md new file mode 100644 index 00000000000..8e20f17a89f --- /dev/null +++ b/docs/linux-notes-5090.md @@ -0,0 +1,122 @@ +# Notes from a second RTX 5090 on Linux + +Findings from another CachyOS + RTX 5090 setup (also an RTX 5070 Ti), NVIDIA +620.73.04, Proton 11.0 / GE-Proton 11-14, running fxceless/victory-fork main +plus Linux fixes. All numbers are from our own runs. They are measured on a +different base than the PR995 renderer, so treat them as leads, not as +promises for this tree. No binaries, game data or captures are included. + +## Biggest single win: small buffers in the card's memory + +`VICTORY_CARD_BUFFERS_MIN_KB=64` with `VICTORY_CARD_BUFFERS_MB=1536` makes +all title-buffer copies eligible for GPU memory within the residency budget. Without it, buffers under +1 MiB stay in PC memory: thousands of small buffers, and every shader access +to them crosses the bus. On our RTX 5090 (fork main, release, desktop, world +frames 300–600 of our cell save): + +| | FPS | Waiting for the GPU | Copy-back | +|---|---:|---:|---:| +| Our previous defaults | 6.14 | 60 ms | 90 ms | +| `CARD_BUFFERS_MIN_KB=64`, `CARD_BUFFERS_MB=1536` | **8.19 (+33.5 % ± 6.4 %)** | 23 ms | 62 ms | + +Keep `CARD_BUFFERS_MB` at 1536: with `MIN_KB=64` and 1024 MB, our runs were +about 50 % slower on our setup. The [standard source build](pr995-candidate/README.md#small-buffer-copies-in-gpu-memory) +includes the threshold from fxceless's +[c36971b](https://github.com/fxceless/victory-fork/commit/c36971b213770e48f513f0d6e3ced3f1f65a32b2). + +In our earlier PR995 experiment (`438872d` plus three experimental patches, +RTX 5090, Xvfb, release, one run each), setting `MIN_KB=64`, `CARD_BUFFERS_MB=1536`, +`BACK_QUIET=1` and `DYNAMIC_SLOTS=524288` together gave 4.91 FPS. With nothing +set, it gave 4.34 FPS. That's +13 %, with copy-back down from 84 to 61 ms a +frame. The switched run paid for the cold shader translations. Neither run +had an Xid. + +One caveat: in 4 of 17 of our runs the cell came up dark with very few shader +lookups. This happened with the switch on and off, and we haven't found the +cause. Check the picture when you compare. + +## Wineserver: memory views in a tree + +[CachyOS/wine-cachyos PR #50](https://github.com/CachyOS/wine-cachyos/pull/50) +(ajsem1337, based on a version by neonbyte1) keeps each process's memory views +in a red-black tree by base address. It is the same idea as the indexed GE11-14 +wineserver used here. It touches only `server/file.h`, `server/mapping.c`, +`server/process.c` and `server/process.h` (+56/-21), with no protocol change. +It applied cleanly to Valve's Proton 11.0 wine (`e60892cc`). + +On Proton 11.0 with only the wineserver swapped: + +| | Stock wineserver | View tree | +|---|---:|---:| +| Loading the world from a save | 118–131 s | 69 s | +| Cutscene right after loading | 2.3–2.4 FPS | 4.9 FPS | +| Steady FPS in the cell | unchanged | unchanged | + +An unpatched wineserver built with the same compiler loaded like stock, so the +gain comes from the patch. Wine reuses a running wineserver for the same +prefix, so stop the old one before you switch. + +## The title's breakpoint on a new game (`0x5149aec`) + +The opening cutscene's prestreaming fills the title's 45,000-entry instance +list. The title then stops at its own breakpoint (`int3`, exit +`0x80000003`), usually 6–10 minutes into a new game. This matches the runs +here that stopped at `0x5149aec` with 45,000 of 45,000 instance slots +occupied. It is tracked in +[Marvisak/VIctory#698](https://github.com/Marvisak/VIctory/issues/698). +Starting from a save made after the intro avoids it. All our measured runs +load such a save. + +## Picture fixes we use + +- **`VICTORY_TEXTURE_BACK=1`** + ([fork PR 999](https://github.com/fxceless/victory-fork/pull/999), + cxy0072019-sketch): in Chapter 1, the boat no longer sinks. Others confirm + this on a 5080, a 3080 and an RX 9070 XT on Linux. The pre-migration + `linux-edge` tree has it, but the PR995 renderer does not. +- **Ambient stand-in** ([fork PR 917](https://github.com/fxceless/victory-fork/pull/917) + plus Belobug's SHADE/TINT commits): `VICTORY_AMBIENT=0.3`, + `VICTORY_AMBIENT_TINT=1,0.6,0.4` and `VICTORY_AMBIENT_SHADE=1.5,0.8,0.1,0.45` + came closest to PS5 reference footage at the cell window. A value of 0.6 + washed the cell out. The PR995 renderer does not include #917. +- From #995's own list of settings, `VICTORY_VIEW_GUARD=0` and + `VICTORY_COMMIT_FLOOR_MB=6144` hid the cell's left wall and the window's wire + mesh on our machine. The preset here does not set them. + +## Frame-rate settings on fork main (RTX 5090, our cell save) + +These are release builds at warm cache. Each value is the FPS over world frames +300–600 of the same save. The base averages three runs at 5.68 FPS (sd 3.3 %). +Any single run within ±6.3 % of the base is noise. + +| On top of our base | FPS | vs base | +|---|---:|---:| +| `VICTORY_CARD_HASH_WIDE=1` ([fork PR 1014](https://github.com/fxceless/victory-fork/pull/1014)) | 6.06 | +6.7 % | +| `VICTORY_TABLE_STAGES=1` (fork main `5d659e0c8`) | 6.08 | +7.1 % | +| Both, plus `VICTORY_CARD_BUFFERS_MB=1536`, `VICTORY_DYNAMIC_SLOTS=524288` and `VICTORY_BACK_QUIET=1` | **6.58** | **+15.8 %** | +| `VICTORY_LOOKUP_CACHE`, `HEAP_PASS_MARKED`, `CARD_SYNC_BATCH`, `STEP_INDEX` or `FILLS_PLAIN` (one at a time) | 5.59–5.88 | noise | + +With the combined set, the submitting thread spends 19 ms in heap sync instead +of 34 ms, and 23 ms instead of 31–36 ms on write-watch queries. The rest of +each frame now goes to waiting for the GPU. + +The combined run included two experimental renderer changes. The copy-back +experiment can clear a concurrent title write from write-watch before the +renderer sees it. The enlarged dynamic ring can let a direct shader read +select a temporary view. These switches are recorded to describe our +measurements. The source build ships the small-buffer threshold. + +`CARD_HASH_WIDE` (344 lines) and `TABLE_STAGES` (226 lines) do not apply to the +candidate without larger rework. They are listed here in case you rebase onto +fork main. + +## Face rendering on the separate fork build + +OctoAlgo reported visible facial skin, eyes and a closed jaw in the diner and +bar close-ups on a separate [fxceless build at `46bf535`](https://github.com/fxceless/victory-fork/tree/46bf5351707b1697c04e5d871c30973ebaa3e973). +Their build also included full [#854/#993 shader pairing](https://github.com/fxceless/victory-fork/pull/993), +[#938](https://github.com/fxceless/victory-fork/pull/938), +[#1002](https://github.com/fxceless/victory-fork/pull/1002) and +[#927](https://github.com/fxceless/victory-fork/pull/927). Face recovery was +observed with the combined renderer. The contributor did not bisect it. +[Original test report](https://github.com/ThomasHFWright/LinVxtory/pull/1) diff --git a/docs/pr995-candidate/README.md b/docs/pr995-candidate/README.md index 71d6ca22992..e8dc017ce48 100644 --- a/docs/pr995-candidate/README.md +++ b/docs/pr995-candidate/README.md @@ -1,7 +1,7 @@ # PR995 Linux candidate: source and reproduction kit The public renderer pin is `7406afbbd9cef0dcddef0b0a23b4855437715eb5`. -The finished source tree is `9087a7f7796671ddec0f176aa5931be73c514624`. +The finished source tree is `2806f9ebe7de5001094b06ee6f38a5ead98b81c1`. It retains the published `91b6968` checkpoint, where a player confirmed walking, camera control, conversation and mouth movement on an Xbox Wireless Controller. The texture and scheduling update changed five files. The latest @@ -189,6 +189,18 @@ with the original source patch at commit `4331d2b`. Its matched checkpoint runs measured 5.17 FPS on the historical baseline and 5.19 FPS with PR927. [Historical source kit](https://github.com/ThomasHFWright/LinVxtory/tree/4331d2b95ab2a56af74884c1b62a2966a35588b3/docs/pr995-candidate) · [Linux integration notes](../pr927-integration.md) +## Small buffer copies in GPU memory + +The standard build includes the small-buffer threshold port from fxceless. +The default floor stays at 1 MiB. For an opt-in run, set +`VICTORY_CARD_BUFFERS_MIN_KB=64` and `VICTORY_CARD_BUFFERS_MB=1536` in the +launch environment. Smaller copies then qualify for GPU memory within the +renderer’s residency budget. The build verifies the patched source before +invoking Cargo. [Upstream threshold port](https://github.com/fxceless/victory-fork/commit/c36971b213770e48f513f0d6e3ced3f1f65a32b2) + +OctoAlgo measured the threshold on their fork and ran a combined experiment +on PR995. [RTX 5090 measurements](../linux-notes-5090.md) · [Local RTX 5090 comparison](validation.md#small-buffer-eligibility-on-an-rtx-5090) + ## Linux preset and runtime [linux-preset.sh](linux-preset.sh) records the measured candidate flags without diff --git a/docs/pr995-candidate/card-buffers-files.json b/docs/pr995-candidate/card-buffers-files.json new file mode 100644 index 00000000000..ec38c8a45a2 --- /dev/null +++ b/docs/pr995-candidate/card-buffers-files.json @@ -0,0 +1,3 @@ +{ + "crates/victory-gpu/src/shadow.rs": "e2138ce61a669dcce5b756dd6a85d464c2f8b5a845fe57e22908bb8aaba19620" +} diff --git a/docs/pr995-candidate/card-buffers-min-kb.patch.txt b/docs/pr995-candidate/card-buffers-min-kb.patch.txt new file mode 100644 index 00000000000..6a9994f38cf --- /dev/null +++ b/docs/pr995-candidate/card-buffers-min-kb.patch.txt @@ -0,0 +1,29 @@ +--- a/crates/victory-gpu/src/shadow.rs ++++ b/crates/victory-gpu/src/shadow.rs +@@ -189,5 +189,25 @@ + // card's hashes too, and with that the first room's walls were + // drawn in every run. +- (mb("VICTORY_CARD_BUFFERS_MIN_MB", 1).max(1 << 20), mb("VICTORY_CARD_BUFFERS_MB", 1024)) ++ // `VICTORY_CARD_BUFFERS_MIN_KB` (not set by default) says the least ++ // size in KiB instead, so that it can go under 1 MiB: 64 is every ++ // title buffer (a copy's size is rounded up to 64 KiB). The copies ++ // under 1 MiB otherwise stay in the PC's memory, and every load, ++ // store and atomic a shader does on them crosses the bus. What it ++ // costs: 64 KiB of the card's memory a copy, and as much again for ++ // one that shaders write (fxceless/victory-fork c36971b). ++ let least_kib = std::env::var("VICTORY_CARD_BUFFERS_MIN_KB") ++ .ok() ++ .and_then(|v| v.trim().parse::().ok()); ++ let least = match least_kib.and_then(|kib| kib.checked_mul(1024)) { ++ Some(bytes) if bytes > 0 => { ++ tracing::info!( ++ kib = bytes / 1024, ++ "title buffers from this size are eligible for copies in the card's memory (VICTORY_CARD_BUFFERS_MIN_KB)" ++ ); ++ bytes ++ } ++ _ => mb("VICTORY_CARD_BUFFERS_MIN_MB", 1).max(1 << 20), ++ }; ++ (least, mb("VICTORY_CARD_BUFFERS_MB", 1024)) + }) + } diff --git a/docs/pr995-candidate/check_inputs.py b/docs/pr995-candidate/check_inputs.py index c28c0bb4d1c..d95e08cc361 100644 --- a/docs/pr995-candidate/check_inputs.py +++ b/docs/pr995-candidate/check_inputs.py @@ -7,8 +7,8 @@ kit = Path(__file__).resolve().parent source = Path(sys.argv[1]) expected = json.loads((kit / 'source-lock.json').read_text())['source_files_sha256'] -if len(sys.argv) == 3: - expected.update(json.loads(Path(sys.argv[2]).read_text())) +for overlay in sys.argv[2:]: + expected.update(json.loads(Path(overlay).read_text())) extra = {str(p.relative_to(source)) for folder in ('apps', 'crates', '.cargo') for p in (source / folder).rglob('*') if p.is_file()} - expected.keys() diff --git a/docs/pr995-candidate/validation.md b/docs/pr995-candidate/validation.md index a89614e50f3..3abdd776d19 100644 --- a/docs/pr995-candidate/validation.md +++ b/docs/pr995-candidate/validation.md @@ -38,15 +38,17 @@ OctoAlgo's unpublished combined renderer. ## Updated source verification The public pin is `7406afbbd9cef0dcddef0b0a23b4855437715eb5`. All rebuild -and upgrade paths must reach Git tree `9087a7f7796671ddec0f176aa5931be73c514624`. -The final lock contains 190 full-file digests when the 13 final overrides are -combined with the 188-input Linux baseline. [Original lock](source-lock.json) · [Final overrides](followup-files.json) +and upgrade paths must reach Git tree `2806f9ebe7de5001094b06ee6f38a5ead98b81c1`. +The final lock verifies 190 full-file digests. The small-buffer overlay +replaces the digest for the already tracked `shadow.rs`. +[Original lock](source-lock.json) · [Previous overrides](followup-files.json) · [Small-buffer overlay](card-buffers-files.json) | Layer | Source tree after applying | Patch SHA-256 | | --- | --- | --- | | Published three-PR checkpoint `91b6968` | `cc6e33fe99572a2d433e82a49e8429678b70ca5a` | `c47ca445f08f13a27d4b9b9a98b4d4e0d22ed510613ca4ad1bd50836c48b28c2` | | Five-file follow-up `f0ca006` | `0c158597c6af5254c2d29422bda9ddd9b6b34065` | `fb1113a16121e61d9ec59e3cbcf5f01b05b01f684935c453417fe4616cc596ac` | | Three-file performance follow-up | `9087a7f7796671ddec0f176aa5931be73c514624` | `2bd39cdda0174091632022ad0e075510beaa91014fa397cd6d12932fba025d36` | +| Small-buffer eligibility | `2806f9ebe7de5001094b06ee6f38a5ead98b81c1` | `072321b791027cfcf33e768951ce6a64368d3bce33da05756756885ffbc7001a` | The five-file patch changes `crates/victory-gpu/src/descriptor/host.rs`, `shadow.rs` and `texture.rs` in the GPU crate, and `lower.rs` and `mod.rs` in @@ -59,6 +61,26 @@ verifies the Linux baseline and the published checkpoint in sequence. Each verif checkout keeps its source intact. Extra arguments and edited build inputs were rejected before Cargo in the packaging checks. +### Small-buffer eligibility on an RTX 5090 + +Two cold replays used the same Windows diagnostics build, indexed GE-Proton +11-14, checkpoint, scripted inputs and 1536 MiB buffer-copy budget. Each run +used a separate cache. The sample contains presents 301–600 after the first +world shader bind. + +| Eligibility floor | FPS | Median present interval | 95th percentile | Peak GPU-resident buffer copies | +| --- | ---: | ---: | ---: | ---: | +| 1 MiB (default) | 2.61 | 330 ms | 687 ms | 98 | +| 64 KiB | 3.24 | 272.5 ms | 498 ms | 3,726 | + +The observed difference was 0.63 FPS (+24%) in this part of the replay. +The 64 KiB run presented more slowly during the first 90 seconds after the +bind (0.64 FPS vs 1.14 FPS). Both runs showed the same cell, with the wire +mesh and yard visible in overlapping views. Over the sample, the default run +turned toward the door and bunks, while the 64 KiB run remained window-facing. +The different visual workload limits what this pair can say about the setting's +effect. The 1 MiB floor remains the default. [Contributor measurements on the separate fork](../linux-notes-5090.md) + ### Published checkpoint provenance The controller-tested `three-pr.exe` from checkpoint `91b6968` has SHA-256 diff --git a/docs/pr995-candidate/verify.sh b/docs/pr995-candidate/verify.sh index 941e80d2f02..4213fe455de 100644 --- a/docs/pr995-candidate/verify.sh +++ b/docs/pr995-candidate/verify.sh @@ -5,4 +5,4 @@ if [ "$#" -ne 1 ] || [ -z "$1" ]; then exit 1 fi kit=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) -exec python3 "$kit/check_inputs.py" "$1" "$kit/followup-files.json" +exec python3 "$kit/check_inputs.py" "$1" "$kit/followup-files.json" "$kit/card-buffers-files.json"