Fix wide shader accesses across title-memory pages #846

Open
github-bot wants to merge 1 commit from github-bot/gh-846 into main AGit
Owner

@⁠gomeaw on GitHub · 2026-11-25 10:22 UTC · original
gomeaw:fix/shader-title-memory-boundaries → main · +124 −39 · 1 files · 1 commits · open

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.

**@⁠gomeaw** on GitHub · 2026-11-25 10:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/846) `gomeaw:fix/shader-title-memory-boundaries` → `main` · +124 −39 · 1 files · 1 commits · open ### 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://git.gtahub.st/github/fxceless--victory-fork/pulls/846) - 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.
Resolve the second backing view only when a raw access crosses a 64 KiB page. Use the directory offset and fault reporting for each page, preserving a single vector access for the same-page case.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:28 +00:00
Author
Owner

@⁠Rezwo on GitHub · 2026-11-25 10:42 UTC · original

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.

**@⁠Rezwo** on GitHub · 2026-11-25 10:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/846#issuecomment-7160067523) 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.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original

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.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 12:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/846#issuecomment-7162310368) 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.
Author
Owner

@⁠ThomasHFWright on GitHub · 2026-11-25 14:45 UTC · original

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.

**@⁠ThomasHFWright** on GitHub · 2026-11-25 14:45 UTC · [original](https://github.com/fxceless/victory-fork/pull/846#issuecomment-7165765806) 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/846/head:github-bot/gh-846'
git switch 'github-bot/gh-846'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-846'
git switch 'github-bot/gh-846'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-846'
git switch 'github-bot/gh-846'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-846'
git switch 'main'
git merge --squash 'github-bot/gh-846'
git switch 'main'
git merge --ff-only 'github-bot/gh-846'
git switch 'main'
git merge 'github-bot/gh-846'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.