Store beside the guards: non-temporal vector stores; diagnostics name the stores not understood #4026

Open
mstrmoos wants to merge 2 commits from upstream-pr/4026 into main
mstrmoos commented 2026-11-30 14:52:42 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mstrmoos on 2026-11-30T14:52:42Z.


[pr-fix] [pr-diagnostics]

What it changes

With VICTORY_STORE_BESIDE=1, a store that faults on a guarded 64 KiB block is decoded and done through the layer's own view of the page (titlewrite::store). The guard stays on, and the block doesn't need a VirtualProtect to open it. A store the decoder doesn't understand opens the block instead. That costs a protection change on the title's thread, and another when the block is guarded again.

Most of the stores it didn't understand in play were one form: the non-temporal vector store, vmovntps / movntps / movntpd ([VEX] 0F 2B /r). For the store itself, it does what vmovaps (0F 29) does. The cache hint makes no difference to a store done once on the title's behalf.

  • decode.rs: 0F 2B is accepted next to 0F 29, in both the 128-bit and the 256-bit (VEX.L) paths. There are two cases in stores_are_told_by_their_bytes.
  • Diagnostics only: the fault handler counts stores it didn't understand by their first six code bytes, in a lock-free table. The "writes beside the guards" line lists the most frequent ones, so the next forms to teach are visible in a user's log.

How it was tested

  • GPU and profile: RTX 5080, 9800X3D, Series X profile, 2560x1440, DLSS Balanced, frame generation off, ray tracing off.
  • Test setup: 150 s measured in the same save at the same time of day (clock held), diagnostics build, VICTORY_COPY_BESIDE=1, same shader cache.
  • Before, without the decoder change: 1,765,289 stores done beside the guards, 61,667 not understood, 35,017 blocks opened for too many.
    • From a run of the counting build without the decoder change, the most frequent not-understood forms were vmovntps [rdx+rax], xmm4 (26,508), vmovntps [rdx+rax+20h], xmm2 (3,396) and vmovntps [rdx+rax+10h], xmm0 (3,375).
  • After: 1,520,179 stores done beside, 14,060 not understood (-77%), 21,514 blocks opened for too many. No 0F 2B form is left in the list.
    • The rest is mostly vpmaskmovd stores (VEX 0F38 8E), about 2 a frame, which isn't worth emulating. Then a few vextractf128 and vmovdqu8.
  • Frame time: no measurable change (42.6 ms against 41.3 ms, inside this PC's run-to-run drift). This is a correctness and coverage fix for the store path, not a speed claim.
  • No visual difference in the screenshots taken at the start, middle and end of each run.
  • cargo test --locked -p victory-gpu:
    • The titlewrite tests pass.
    • shader_cache::tests::every_switch_of_the_translator_is_in_the_key fails on main as it is (stale names, see #3210).
    • host::card_steps::tests::places_written_after_sending_are_learned failed once in the full parallel run and passes on its own. It fails intermittently on main too.
  • cargo clippy --workspace --all-targets -- -D warnings stops on main as it is in victory-shader (PAIR_MEETINGS, lane_regions, while loads) and victory-loader (unwind_copy). Nothing here touches those, and there is nothing new from these files.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2811 and #1003 use non-temporal stores in the layer's own copies, which is a different path. I found nothing else that teaches the store decoder new forms.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5567639919 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4026). Originally posted by [mstrmoos](https://github.com/mstrmoos) on 2026-11-30T14:52:42Z. --- [pr-fix] [pr-diagnostics] ## What it changes With `VICTORY_STORE_BESIDE=1`, a store that faults on a guarded 64 KiB block is decoded and done through the layer's own view of the page (`titlewrite::store`). The guard stays on, and the block doesn't need a `VirtualProtect` to open it. A store the decoder doesn't understand opens the block instead. That costs a protection change on the title's thread, and another when the block is guarded again. Most of the stores it didn't understand in play were one form: the non-temporal vector store, `vmovntps` / `movntps` / `movntpd` (`[VEX] 0F 2B /r`). For the store itself, it does what `vmovaps` (`0F 29`) does. The cache hint makes no difference to a store done once on the title's behalf. - `decode.rs`: `0F 2B` is accepted next to `0F 29`, in both the 128-bit and the 256-bit (VEX.L) paths. There are two cases in `stores_are_told_by_their_bytes`. - Diagnostics only: the fault handler counts stores it didn't understand by their first six code bytes, in a lock-free table. The "writes beside the guards" line lists the most frequent ones, so the next forms to teach are visible in a user's log. ## How it was tested - GPU and profile: RTX 5080, 9800X3D, Series X profile, 2560x1440, DLSS Balanced, frame generation off, ray tracing off. - Test setup: 150 s measured in the same save at the same time of day (clock held), diagnostics build, `VICTORY_COPY_BESIDE=1`, same shader cache. - Before, without the decoder change: 1,765,289 stores done beside the guards, **61,667 not understood**, 35,017 blocks opened for too many. - From a run of the counting build without the decoder change, the most frequent not-understood forms were `vmovntps [rdx+rax], xmm4` (26,508), `vmovntps [rdx+rax+20h], xmm2` (3,396) and `vmovntps [rdx+rax+10h], xmm0` (3,375). - After: 1,520,179 stores done beside, **14,060 not understood** (-77%), 21,514 blocks opened for too many. No `0F 2B` form is left in the list. - The rest is mostly `vpmaskmovd` stores (`VEX 0F38 8E`), about 2 a frame, which isn't worth emulating. Then a few `vextractf128` and `vmovdqu8`. - Frame time: no measurable change (42.6 ms against 41.3 ms, inside this PC's run-to-run drift). This is a correctness and coverage fix for the store path, not a speed claim. - No visual difference in the screenshots taken at the start, middle and end of each run. - `cargo test --locked -p victory-gpu`: - The `titlewrite` tests pass. - `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` fails on main as it is (stale names, see #3210). - `host::card_steps::tests::places_written_after_sending_are_learned` failed once in the full parallel run and passes on its own. It fails intermittently on main too. - `cargo clippy --workspace --all-targets -- -D warnings` stops on main as it is in `victory-shader` (`PAIR_MEETINGS`, `lane_regions`, `while loads`) and `victory-loader` (`unwind_copy`). Nothing here touches those, and there is nothing new from these files. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2811 and #1003 use non-temporal stores in the layer's own copies, which is a different path. I found nothing else that teaches the store decoder new forms.
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/4026:upstream-pr/4026'
git switch 'upstream-pr/4026'

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/4026'
git switch 'upstream-pr/4026'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4026'
git switch 'upstream-pr/4026'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4026'
git switch 'main'
git merge --squash 'upstream-pr/4026'
git switch 'main'
git merge --ff-only 'upstream-pr/4026'
git switch 'main'
git merge 'upstream-pr/4026'
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
trustno1-coder/VIctory-NVIDIA!4026
No description provided.