GPU: a window that is one run of a section's pages goes in place through our own view (VICTORY_STRETCH=1) #1124

Open
FrancescoGelosoEterea wants to merge 1 commit from upstream-pr/1127 into main
FrancescoGelosoEterea commented 2026-11-25 20:52:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by FrancescoGelosoEterea on 2026-11-25T20:52:09Z.


The title maps its streaming heaps one 64 KiB view at a time, and each view is an allocation of its own. So place_part cannot open them, and level() turns view memory down: those windows are copied, refreshed and copied back. Their pages do follow one another in their section, though. This PR opens such a window through a view of our own on the whole section, the same view VICTORY_BACK_OWN_VIEW maps:

  1. place_for asks cover(). When a window is one Cover::Run(section, offset), it goes to the new place_stretch.
  2. place_stretch rounds the window out to 64 KiB pages and checks that the rounded range is still the same run. It then commits those blocks through our view and opens the heap there with OpenExistingHeapFromAddress1. The shaders read and write the title's bytes directly: no copy, no refresh, no copy-back.
  3. Every refusal falls back to the copy and logs a warning for the first 8.

own_view() is pulled out of write_own, so both switches share one mapping per section. The inplace stats line also counts windows placed this way and the ones turned down.

The idea is VICTORY_STRETCH from Belobug/VIctory-Belobug-AMD (0434b3a), credit to them. There it works in shadow.rs with a separate MapViewOfFile per stretch. This port reuses the in-place module (cover(), OWN, Placed) instead. It is off by default.

Tested

RTX 5070 Ti (16 GB, driver 621.24), Windows 11, a save past the prologue. Three ~7-minute runs in the world, on main 465b94f plus #854 and #834. Every run used the same switches: WIDE_BACK, CARD_BUFFERS_MB=1024, INDIRECT_WINDOW, ASYNC_SUBMIT, QUEUE2, LEVELS_ON_DEMAND, JOIN_PARTS, BACK_OWN_VIEW, INDIRECT_GATHER, CARD_REHASH_RUNS and COPY_PLAIN.

run fps prep ms GPU ms copy-back ms draws windows through our view
without 5.3 68 84 17 4,890 –
VICTORY_STRETCH=1 5.1 75 90 19 3,084 80 placed, 0 turned down
VICTORY_STRETCH=1 again 5.6 62 102 16 4,292 75 placed, 0 turned down
  • It works on NVIDIA. All of the windows came from one 6,236 MB section, from 4 to 8 MiB each, and none was refused. The picture looked right live. I did not check faces closely, given the earlier report of faces breaking with a similar change.
  • On this stack it does not speed anything up. The differences are within the noise of these runs (about ±0.6 fps). With BACK_OWN_VIEW and WIDE_BACK on, copy-back is already about 17 ms a frame, against the 36 ms Belobug started from.
  • One of the two STRETCH=1 runs ended in a device loss (0x887A0006, about 10 minutes in). Two of four runs without it had the same loss on this merge, so it does not look tied to this switch.

Not tested: together with VICTORY_WINDOW_UPLOAD from 79cfdd9. This branch is rebased on 085ee7c (clean cherry-pick, no clippy warning in inplace.rs, 182 of 183 unit tests pass; the one failure, indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, fails the same way on 085ee7c without this commit)

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:6613521154 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1127). Originally posted by [FrancescoGelosoEterea](https://github.com/FrancescoGelosoEterea) on 2026-11-25T20:52:09Z. --- The title maps its streaming heaps one 64 KiB view at a time, and each view is an allocation of its own. So `place_part` cannot open them, and `level()` turns view memory down: those windows are copied, refreshed and copied back. Their pages do follow one another in their section, though. This PR opens such a window through a view of our own on the whole section, the same view `VICTORY_BACK_OWN_VIEW` maps: 1. `place_for` asks `cover()`. When a window is one `Cover::Run(section, offset)`, it goes to the new `place_stretch`. 2. `place_stretch` rounds the window out to 64 KiB pages and checks that the rounded range is still the same run. It then commits those blocks through our view and opens the heap there with `OpenExistingHeapFromAddress1`. The shaders read and write the title's bytes directly: no copy, no refresh, no copy-back. 3. Every refusal falls back to the copy and logs a warning for the first 8. `own_view()` is pulled out of `write_own`, so both switches share one mapping per section. The `inplace` stats line also counts windows placed this way and the ones turned down. The idea is `VICTORY_STRETCH` from Belobug/VIctory-Belobug-AMD (0434b3a), credit to them. There it works in `shadow.rs` with a separate `MapViewOfFile` per stretch. This port reuses the in-place module (`cover()`, `OWN`, `Placed`) instead. It is **off by default**. ### Tested RTX 5070 Ti (16 GB, driver 621.24), Windows 11, a save past the prologue. Three ~7-minute runs in the world, on main 465b94f plus #854 and #834. Every run used the same switches: `WIDE_BACK`, `CARD_BUFFERS_MB=1024`, `INDIRECT_WINDOW`, `ASYNC_SUBMIT`, `QUEUE2`, `LEVELS_ON_DEMAND`, `JOIN_PARTS`, `BACK_OWN_VIEW`, `INDIRECT_GATHER`, `CARD_REHASH_RUNS` and `COPY_PLAIN`. | run | fps | prep ms | GPU ms | copy-back ms | draws | windows through our view | |---|---|---|---|---|---|---| | without | 5.3 | 68 | 84 | 17 | 4,890 | – | | `VICTORY_STRETCH=1` | 5.1 | 75 | 90 | 19 | 3,084 | 80 placed, 0 turned down | | `VICTORY_STRETCH=1` again | 5.6 | 62 | 102 | 16 | 4,292 | 75 placed, 0 turned down | - It works on NVIDIA. All of the windows came from one 6,236 MB section, from 4 to 8 MiB each, and none was refused. The picture looked right live. I did not check faces closely, given the earlier report of faces breaking with a similar change. - On this stack it does not speed anything up. The differences are within the noise of these runs (about ±0.6 fps). With `BACK_OWN_VIEW` and `WIDE_BACK` on, copy-back is already about 17 ms a frame, against the 36 ms Belobug started from. - One of the two `STRETCH=1` runs ended in a device loss (`0x887A0006`, about 10 minutes in). Two of four runs without it had the same loss on this merge, so it does not look tied to this switch. Not tested: together with `VICTORY_WINDOW_UPLOAD` from 79cfdd9. This branch is rebased on 085ee7c (clean cherry-pick, no clippy warning in `inplace.rs`, 182 of 183 unit tests pass; the one failure, `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, fails the same way on 085ee7c without this commit) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Filip722 commented 2026-11-26 00:06:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-25T23:16:30Z.


I tested the Address1 path from e417d0b in a synthetic 2 MiB memory fixture on Bazzite 44, RTX 5060 Laptop 8 GB, NVIDIA 615.78.08 and GE-Proton11-14/vkd3d-proton cae8353ed7959c4+.

ID3D12Device13 was available. The existing partial import of private anonymous memory passed both CPU-to-GPU and GPU-to-CPU checks at a nonzero offset. With the same writable file mapping flags and ext4 scratch backing used for our #830 test, the own-view commitment required by #1127 returned ERROR_ACCESS_DENIED. In the fixture only, I also tried the underlying Address1 call after that failure. The heap and placed resource were created, but writes in either direction were invisible to the other view. The regular copy remains necessary for this file-backed case.

The fixture used generated bytes only. Test and report prepared with assistance from OpenAI Codex.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7177345539 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1127#issuecomment-7177345539). Originally posted by [Filip722](https://github.com/Filip722) on 2026-11-25T23:16:30Z. --- I tested the Address1 path from `e417d0b` in a synthetic 2 MiB memory fixture on Bazzite 44, RTX 5060 Laptop 8 GB, NVIDIA 615.78.08 and GE-Proton11-14/vkd3d-proton `cae8353ed7959c4+`. `ID3D12Device13` was available. The existing partial import of private anonymous memory passed both CPU-to-GPU and GPU-to-CPU checks at a nonzero offset. With the same writable file mapping flags and ext4 scratch backing used for our #830 test, the own-view commitment required by #1127 returned `ERROR_ACCESS_DENIED`. In the fixture only, I also tried the underlying Address1 call after that failure. The heap and placed resource were created, but writes in either direction were invisible to the other view. The regular copy remains necessary for this file-backed case. The fixture used generated bytes only. Test and report prepared with assistance from OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1127:upstream-pr/1127'
git switch 'upstream-pr/1127'

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 'upstream-pr/1127'
git switch 'upstream-pr/1127'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1127'
git switch 'upstream-pr/1127'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1127'
git switch 'main'
git merge --squash 'upstream-pr/1127'
git switch 'main'
git merge --ff-only 'upstream-pr/1127'
git switch 'main'
git merge 'upstream-pr/1127'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!1124
No description provided.