Fix wide shader accesses across title-memory pages #845

Open
gomeaw wants to merge 1 commit from upstream-pr/846 into main
gomeaw commented 2026-11-25 10:22:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by gomeaw on 2026-11-25T10:22:41Z.


Problem

The page directory maps each 64 KiB guest page to a host buffer view and byte offset. Wide global_load_dwordxN, global_store_dwordxN, and s_load_dwordxN instructions lowered through that directory previously resolved only the starting page. When a transfer straddles a boundary, it can pick up unrelated bytes from the first backing buffer or overwrite them. This path is used by compute shaders including the ray-tracing structure builder.

Change

Keep one vector access for each group of up to four dwords that fits in a page. For a straddling group, resolve the next page with the 64-bit address carry and use the appropriate backing view, byte offset, and fault handling for each portion. Root-descriptor loads and the ray-box node reader have their own lowering.

Verification

  • All 61 synthetic D3D12 WARP cases passed across global loads, global stores, and scalar loads. They cover same-page transfers, all split positions, separate backing views with nonzero byte offsets, a boundary at 4 GiB, and an unmapped second page. With the original lowering, both crossing loads returned [17, 17] where [17, 34] was expected, and a crossing store overwrote an unrelated dword beyond the first guest page. Windows WARP comparison
  • An independent RTX 2080 Ti run passed all 61 synthetic cases on physical hardware. Reverting only the shader lowering made all three test families fail. RTX 2080 Ti test report
  • The shader crate passed Windows-target Clippy with all targets and features. Native shader, formats, and xtask tests passed, along with the asset-policy check.
  • Windows workspace checks hit two existing GPU lints and a depth-bounds assertion in a test that compiles its shaders directly from HLSL. Workspace logs

The WARP fixture lives on the fork's validation branch and reuses fixture support from #33. That PR exercises ray-box node reads. This patch addresses the general memory instructions and applies alongside #33. In-game visual impact and hardware timing remain unmeasured.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6602287905 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/846). Originally posted by [gomeaw](https://github.com/gomeaw) on 2026-11-25T10:22:41Z. --- ### Problem The page directory maps each 64 KiB guest page to a host buffer view and byte offset. Wide `global_load_dwordxN`, `global_store_dwordxN`, and `s_load_dwordxN` instructions lowered through that directory previously resolved only the starting page. When a transfer straddles a boundary, it can pick up unrelated bytes from the first backing buffer or overwrite them. This path is used by compute shaders including the ray-tracing structure builder. ### Change Keep one vector access for each group of up to four dwords that fits in a page. For a straddling group, resolve the next page with the 64-bit address carry and use the appropriate backing view, byte offset, and fault handling for each portion. Root-descriptor loads and the ray-box node reader have their own lowering. ### Verification - All 61 synthetic D3D12 WARP cases passed across global loads, global stores, and scalar loads. They cover same-page transfers, all split positions, separate backing views with nonzero byte offsets, a boundary at 4 GiB, and an unmapped second page. With the original lowering, both crossing loads returned `[17, 17]` where `[17, 34]` was expected, and a crossing store overwrote an unrelated dword beyond the first guest page. [Windows WARP comparison](https://github.com/gomeaw/victory-fork/actions/runs/45594175515/job/139135779716) - An independent RTX 2080 Ti run passed all 61 synthetic cases on physical hardware. Reverting only the shader lowering made all three test families fail. [RTX 2080 Ti test report](https://github.com/fxceless/victory-fork/pull/846#issuecomment-7160067523) - The shader crate passed Windows-target Clippy with all targets and features. Native shader, formats, and xtask tests passed, along with the asset-policy check. - Windows workspace checks hit two existing GPU lints and a depth-bounds assertion in a test that compiles its shaders directly from HLSL. [Workspace logs](https://github.com/gomeaw/victory-fork/actions/runs/45593748860/job/139134308157) The WARP fixture lives on the fork's validation branch and reuses fixture support from #33. That PR exercises ray-box node reads. This patch addresses the general memory instructions and applies alongside #33. In-game visual impact and hardware timing remain unmeasured.
Rezwo commented 2026-11-25 11:10:38 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Rezwo on 2026-11-25T10:42:35Z.


Independent Turing hardware reproduction: NVIDIA GeForce RTX 2080 Ti, Windows driver 32.0.16.2101.

I used your validation/shader-title-memory-boundaries branch at 81746e95de79ac1344f6f763c3407dd6be8f390e, including its fixture support from #33. This is not a test of the production-only PR checkout. The PR head is still df399bd998.

Local harness changes: Host::new(true) became Host::new(false), with initialization required (no skip); added actual adapter name/flags and per-case logging. The inputs and assertions were unchanged. Logs identified NVIDIA GeForce RTX 2080 Ti, flags=0.

Command:
cargo test --locked -p victory-shader --lib wide_title_memory_ -- --nocapture

Results:

  • Patched WARP fixture: 3 test families passed, exit 0.
  • Patched hardware: all 61 cases across global loads, global stores and scalar loads passed; 3 test families passed, exit 0.
  • Negative control: replaced only lower.rs with the original 9376fd60c0 version, keeping the hardware harness and test inputs. All three test families failed, exit 101.
  • Restored patched lower.rs: all 61 cases passed again, exit 0.

The original global and scalar x2 crossing loads returned [17, 17] instead of [17, 34]. The original store changed an unrelated word after the first mapped page:
actual [17, 17, 17, 20, 21, 17, 17, 17]
expected [17, 17, 17, 20, 17, 17, 17, 17]

The passing cases include the low-address carry at 4 GiB, independent backing views with byte offsets, all tested split positions, and the missing-second-page checks. Separately executed the local rollback script on a copy and verified byte-for-byte restoration of the original lowering.

No game files or in-game runs. This confirms the synthetic memory corruption and its correction on Turing, not a measured lighting/stability improvement in the title.

AI-assisted (OpenAI Codex); tests executed locally.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7160067523 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/846#issuecomment-7160067523). Originally posted by [Rezwo](https://github.com/Rezwo) on 2026-11-25T10:42:35Z. --- Independent Turing hardware reproduction: NVIDIA GeForce RTX 2080 Ti, Windows driver 32.0.16.2101. I used your validation/shader-title-memory-boundaries branch at 81746e95de79ac1344f6f763c3407dd6be8f390e, including its fixture support from #33. This is not a test of the production-only PR checkout. The PR head is still df399bd99828cf41ea2bb38390d0c881fbfad2ac. Local harness changes: Host::new(true) became Host::new(false), with initialization required (no skip); added actual adapter name/flags and per-case logging. The inputs and assertions were unchanged. Logs identified NVIDIA GeForce RTX 2080 Ti, flags=0. Command: cargo test --locked -p victory-shader --lib wide_title_memory_ -- --nocapture Results: - Patched WARP fixture: 3 test families passed, exit 0. - Patched hardware: all 61 cases across global loads, global stores and scalar loads passed; 3 test families passed, exit 0. - Negative control: replaced only lower.rs with the original 9376fd60c0ba0e76a74c39b49b1407dbac0a64c7 version, keeping the hardware harness and test inputs. All three test families failed, exit 101. - Restored patched lower.rs: all 61 cases passed again, exit 0. The original global and scalar x2 crossing loads returned [17, 17] instead of [17, 34]. The original store changed an unrelated word after the first mapped page: actual [17, 17, 17, 20, 21, 17, 17, 17] expected [17, 17, 17, 20, 17, 17, 17, 17] The passing cases include the low-address carry at 4 GiB, independent backing views with byte offsets, all tested split positions, and the missing-second-page checks. Separately executed the local rollback script on a copy and verified byte-for-byte restoration of the original lowering. No game files or in-game runs. This confirms the synthetic memory corruption and its correction on Turing, not a measured lighting/stability improvement in the title. AI-assisted (OpenAI Codex); tests executed locally.
MamaLeVrai commented 2026-11-25 13:06:01 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T12:23:33Z.


Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head df399bd into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins, depth_written, a sort; PR #841 fixes them), also with --all-features; this PR adds none. cargo test --workspace --locked: run 1: 555 passed, 0 failed, 11 ignored; run 2: 555 passed, 0 failed, 11 ignored (main alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7162310368 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/846#issuecomment-7162310368). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T12:23:33Z. --- Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `df399bd` into `main` `f85101b` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails with exactly the errors `main` itself has on this machine (`placed_filler_twins`, `depth_written`, a sort; PR #841 fixes them), also with `--all-features`; this PR adds none. `cargo test --workspace --locked`: run 1: 555 passed, 0 failed, 11 ignored; run 2: 555 passed, 0 failed, 11 ignored (`main` alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
ThomasHFWright commented 2026-11-25 15:08:34 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by ThomasHFWright on 2026-11-25T14:45:26Z.


Linux hardware validation of df399bd99828cf41ea2bb38390d0c881fbfad2ac: all 61 synthetic cases pass on CachyOS / RTX 5090 / NVIDIA 620.73.04, using GE-Proton 11-14 Wine, DXC/DXIL 1.9.2609 and a Windows MSVC cross-build. I used gomeaw's three-family fixture from 81746e95de79ac1344f6f763c3407dd6be8f390e, with hardware adapter selection instead of forced WARP (the logs confirm the RTX 5090).

Coverage: 13 global-load, 13 global-store and 35 scalar-load cases, including independent biased mappings, aligned split positions, 4 GiB carry, missing-page values/faults and store canaries. Negative control: retaining the tests but restoring the previous lowering makes all three families fail at the first crossing x2 case. Loads return [17,17] instead of [17,34]; the store overwrites the first buffer's canary. Fixed source restored afterward. Windows build, all-target/all-feature Clippy and asset policy pass.

Integrated with author credits in LinVictory abdae98. This verifies the transfer correction on Linux hardware; it does not establish a gameplay fix. A separate normal-rendering title trial still hit an NVIDIA Xid 13/MMU fault after approximately 127 seconds, without verified scene geometry. That branch contains other Linux fixes, so the title result is not an isolated causal comparison. No game-derived fixtures, logs or shaders are included.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7165765806 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/846#issuecomment-7165765806). Originally posted by [ThomasHFWright](https://github.com/ThomasHFWright) on 2026-11-25T14:45:26Z. --- Linux hardware validation of `df399bd99828cf41ea2bb38390d0c881fbfad2ac`: all **61 synthetic cases pass** on CachyOS / RTX 5090 / NVIDIA 620.73.04, using GE-Proton 11-14 Wine, DXC/DXIL 1.9.2609 and a Windows MSVC cross-build. I used gomeaw's three-family fixture from `81746e95de79ac1344f6f763c3407dd6be8f390e`, with hardware adapter selection instead of forced WARP (the logs confirm the RTX 5090). Coverage: 13 global-load, 13 global-store and 35 scalar-load cases, including independent biased mappings, aligned split positions, 4 GiB carry, missing-page values/faults and store canaries. Negative control: retaining the tests but restoring the previous lowering makes **all three families fail at the first crossing x2 case**. Loads return `[17,17]` instead of `[17,34]`; the store overwrites the first buffer's canary. Fixed source restored afterward. Windows build, all-target/all-feature Clippy and asset policy pass. Integrated with author credits in [LinVictory abdae98](https://github.com/ThomasHFWright/LinVictory/commit/abdae98). This verifies the transfer correction on Linux hardware; it does **not** establish a gameplay fix. A separate normal-rendering title trial still hit an NVIDIA Xid 13/MMU fault after approximately 127 seconds, without verified scene geometry. That branch contains other Linux fixes, so the title result is not an isolated causal comparison. No game-derived fixtures, logs or shaders are included.
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/846:upstream-pr/846'
git switch 'upstream-pr/846'

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/846'
git switch 'upstream-pr/846'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/846'
git switch 'upstream-pr/846'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/846'
git switch 'main'
git merge --squash 'upstream-pr/846'
git switch 'main'
git merge --ff-only 'upstream-pr/846'
git switch 'main'
git merge 'upstream-pr/846'
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!845
No description provided.