[pr-fix][memory] Windows tile by tile by adapter and class; failed materialisation is retried #221

Open
hingeowl wants to merge 1 commit from hingeowl:pr/tile-by-tile-windows into main
Contributor

Re-submitted from the previous CodeFloe repository (original commit 9ea701e019e4663ec541eb8ccfcce6e186bd1693, preserving original authorship by vilaris) so it is not lost after the forge move.

What it changes

Decides whether a window in PC memory is held tile by tile in darner-gpu (pagebuf::windows_direct) based on adapter capabilities and class, and hardens direct-window failure paths:

  • No memory for the mirror at first shader write: window stays direct and nothing is landed from an uncommitted mirror.
  • No tile in PC memory: retried at the next send, then falls back to a two-sided copy.
  • No tile anywhere: tiles are no longer left marked as mapped.
  • CPU write during transition goes to the mirror.
  • Adapters that cannot map a heap are queried once rather than per window.

Notes

  • Rebased cleanly onto main (f3840d7).
  • Submitted primarily to preserve the patch on GTA Hub for review/testing; standalone verification on current main has not been run yet.
Re-submitted from the previous CodeFloe repository (original commit `9ea701e019e4663ec541eb8ccfcce6e186bd1693`, preserving original authorship by vilaris) so it is not lost after the forge move. ### What it changes Decides whether a window in PC memory is held tile by tile in `darner-gpu` (`pagebuf::windows_direct`) based on adapter capabilities and class, and hardens direct-window failure paths: - No memory for the mirror at first shader write: window stays direct and nothing is landed from an uncommitted mirror. - No tile in PC memory: retried at the next send, then falls back to a two-sided copy. - No tile anywhere: tiles are no longer left marked as mapped. - CPU write during transition goes to the mirror. - Adapters that cannot map a heap are queried once rather than per window. ### Notes - Rebased cleanly onto `main` (`f3840d7`). - Submitted primarily to preserve the patch on GTA Hub for review/testing; standalone verification on current `main` has not been run yet.
Whether a window that would be one buffer in the PC's memory is held tile by
tile is now decided in darner-gpu (pagebuf::windows_direct): the switch unset,
3 or 4, tiled resources tier 2, copies with two sides, and a heap the CPU can
map. `darner play` already sets mode 3 on every PC; runs without that setting
get the same windows.

Failure paths of the direct window:
- no memory for the mirror at the first shader write: the window stays direct
  and nothing is landed from an uncommitted mirror
- no tile in the PC's memory: retried at the next send, then the window becomes
  a copy with two sides
- no tile anywhere: the tiles are no longer left marked as mapped
- a CPU write during the transition goes to the mirror
- an adapter that cannot map a heap is asked once, not at every window

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
(cherry picked from commit 9ea701e019e4663ec541eb8ccfcce6e186bd1693)
First-time contributor

CHANGES NEEDED

Review of 2644ff597.

a_window_written_straight_into_its_tiles_round_trip_in_mode_three snapshots the process-global STATS[25] counter and expects it not to change (crates/darner-gpu/src/shadow/page_buffer_tests.rs:365-399). Running the ignored page_buffer_tests selector with its default parallelism failed this assertion (observed delta: 393,472 bytes); the test passes in isolation and when the selector is serialized. Other concurrent GPU tests can update the same global counter, making this test order-dependent. Please serialize the tests sharing this counter or make the assertion use per-test accounting.

Windows validation: G1 PASS; G2 PASS; cargo xtask policy PASS (555 files ok); serialized ignored page-buffer tests — 6 passed, 0 failed (two mode-specific cases logged as skipped); ignored pagebuf tests — 5 passed, 0 failed. The default-parallel page-buffer selector had the failure described above.

Not run in-game.

AI-assisted: yes (GitHub Copilot, Auto mode).

**CHANGES NEEDED** Review of `2644ff597`. `a_window_written_straight_into_its_tiles_round_trip_in_mode_three` snapshots the process-global `STATS[25]` counter and expects it not to change (`crates/darner-gpu/src/shadow/page_buffer_tests.rs:365-399`). Running the ignored `page_buffer_tests` selector with its default parallelism failed this assertion (observed delta: 393,472 bytes); the test passes in isolation and when the selector is serialized. Other concurrent GPU tests can update the same global counter, making this test order-dependent. Please serialize the tests sharing this counter or make the assertion use per-test accounting. Windows validation: G1 PASS; G2 PASS; `cargo xtask policy` PASS (`555 files ok`); serialized ignored page-buffer tests — 6 passed, 0 failed (two mode-specific cases logged as skipped); ignored `pagebuf` tests — 5 passed, 0 failed. The default-parallel page-buffer selector had the failure described above. Not run in-game. AI-assisted: yes (GitHub Copilot, Auto mode).
First-time contributor

Replay A/B on RTX 5070 Ti: no measurable difference with DARNER_PAGE_BUFFERS=3

Measured 2644ff5977 merged on top of release v2026.12.03.02, against the plain release, on a ~6.5 minute replay route (same save, recorded controller input) through a cutscene, a scene cut and a stretch of free play. The launcher's settings on this bench include DARNER_PAGE_BUFFERS=3, so the direct-window path this PR changes was in use in both builds.

Build fps (range) CPU prep ms median ms p95 ms p99 ms frames over 100 ms per run
v2026.12.03.02 (3 runs) 38.30 (38.17-38.46) 9.57 26.8 29.8 37.8 20 / 11 / 8
+ PR 221 (2 runs) 38.47 (38.42-38.51) 9.55 26.8 28.6 34.5 10 / 4

Crashes: none in any run (no device loss, no host GPU failure). Fps means are within the release's own run-to-run spread, so: no measurable difference on this route. With only 3 release runs, that spread is not well known yet; differences under ~2-3% can't be resolved here.

Config: RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11; scripts\play-nvidia.ps1 -Build release (Series X, 1440p native, DLSS Quality, no frame generation, fullscreen, no fps cap). Each build had one unmeasured warm-up run first. The release base excludes its first measured run, which was still compiling shaders (about 3,300 compiles during the route).

Measured unattended on a replay bench (same save, recorded controller input); numbers and text prepared with Claude.

### Replay A/B on RTX 5070 Ti: no measurable difference with DARNER_PAGE_BUFFERS=3 Measured `2644ff5977` merged on top of release v2026.12.03.02, against the plain release, on a ~6.5 minute replay route (same save, recorded controller input) through a cutscene, a scene cut and a stretch of free play. The launcher's settings on this bench include `DARNER_PAGE_BUFFERS=3`, so the direct-window path this PR changes was in use in both builds. | Build | fps (range) | CPU prep ms | median ms | p95 ms | p99 ms | frames over 100 ms per run | |---|---:|---:|---:|---:|---:|---:| | v2026.12.03.02 (3 runs) | 38.30 (38.17-38.46) | 9.57 | 26.8 | 29.8 | 37.8 | 20 / 11 / 8 | | + PR 221 (2 runs) | 38.47 (38.42-38.51) | 9.55 | 26.8 | 28.6 | 34.5 | 10 / 4 | Crashes: none in any run (no device loss, no host GPU failure). Fps means are within the release's own run-to-run spread, so: **no measurable difference** on this route. With only 3 release runs, that spread is not well known yet; differences under ~2-3% can't be resolved here. Config: RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11; `scripts\play-nvidia.ps1 -Build release` (Series X, 1440p native, DLSS Quality, no frame generation, fullscreen, no fps cap). Each build had one unmeasured warm-up run first. The release base excludes its first measured run, which was still compiling shaders (about 3,300 compiles during the route). Measured unattended on a replay bench (same save, recorded controller input); numbers and text prepared with Claude.
Author
Contributor

Fixed in ec83a00: serialized the GPU tests in crates/darner-gpu/src/shadow/page_buffer_tests.rs with a module-level SERIAL: Mutex<()> so sibling tests cannot perturb process-global STATS[..] snapshots when run with default parallelism.

Validation on ec83a00:

  • DARNER_ADAPTER=4090 DARNER_PAGE_BUFFERS=3 cargo test -p darner-gpu --lib --locked -- page_buffer_tests --ignored --nocapture (default parallelism) — 6 passed, 0 failed.
  • cargo clippy -p darner-gpu --all-targets --all-features --locked -- -D warnings — passed.

Ready for re-review.

Fixed in `ec83a00`: serialized the GPU tests in `crates/darner-gpu/src/shadow/page_buffer_tests.rs` with a module-level `SERIAL: Mutex<()>` so sibling tests cannot perturb process-global `STATS[..]` snapshots when run with default parallelism. Validation on `ec83a00`: - `DARNER_ADAPTER=4090 DARNER_PAGE_BUFFERS=3 cargo test -p darner-gpu --lib --locked -- page_buffer_tests --ignored --nocapture` (default parallelism) — 6 passed, 0 failed. - `cargo clippy -p darner-gpu --all-targets --all-features --locked -- -D warnings` — passed. Ready for re-review.
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/tile-by-tile-windows:hingeowl-pr/tile-by-tile-windows'
git switch 'hingeowl-pr/tile-by-tile-windows'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'hingeowl-pr/tile-by-tile-windows'
git switch 'hingeowl-pr/tile-by-tile-windows'
git rebase 'main'
git switch 'main'
git merge --ff-only 'hingeowl-pr/tile-by-tile-windows'
git switch 'hingeowl-pr/tile-by-tile-windows'
git rebase 'main'
git switch 'main'
git merge --no-ff 'hingeowl-pr/tile-by-tile-windows'
git switch 'main'
git merge --squash 'hingeowl-pr/tile-by-tile-windows'
git switch 'main'
git merge --ff-only 'hingeowl-pr/tile-by-tile-windows'
git switch 'main'
git merge 'hingeowl-pr/tile-by-tile-windows'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!221
No description provided.