native: vertex and pixel programs read root views through the page table #207
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/207"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T00:40:26Z.
Vertex fetch through root SRVs read the wrong memory when a vertex buffer's range ran past its 64 KiB mapping. Found and verified on a real game run (Apple M5 Pro, 48 GB, Series S, windowed).
Why.
addr::root_viewhands a shader a view pair that is linear in the pool, starting from the mapping that holds the root address. Accesses past the end of that mapping land in whatever pool pages follow, not in the title's next mapping. The title maps consecutive pages at non-adjacent pool offsets, often in descending order (e.g. title0x849fb0000→ pool0x2e9b0000,0x849fc0000→ pool0x2e9a0000).Diagnostic (first commit, off by default):
VICTORY_TRACE_ROOT_SPAN[=<bytes>]logs each root view whose address range stays pool-contiguous for less than the given bytes from its start (1 MiB by default), once per case, with the shader hashes and whether the next title page is mapped elsewhere. It's documented in docs/native-host.md, andaddr::linear_runhas a unit test.On a world-frame run it found 117 such root views, all vertex shaders' root SRVs (root parameter 3, vertex fetch). 30 of them have a next title page elsewhere in pool 10, so those draws fetched wrong vertices. There were no dispatches and no root UAVs, so this is not the prologue crash.
Fix (second commit): with
zero_copy_memory, vertex and pixel programs read their root views through the title-memory page table, the path compute already uses for computed addresses (root_memoryinlower.rs). Compute programs keep the linear view: none had a short run.Tests.
addr_tests::a_vertex_root_view_follows_the_title_across_pages_apart_in_the_pool(Metal): two consecutive title pages mapped to non-adjacent pool offsets, and a root SRV 8 bytes before the end of the first, so vertex 0 is in page 1 and vertices 1 and 2 are in page 2. On main nothing is drawn; with the fix the triangle is drawn. As a sanity check, it passes on main when the two pages are pool-contiguous.cargo xtask policypass.In game, with
VICTORY_TRACE_ROOT_SPAN=16 MiB: every vertex root view logged now goesthrough="table"(123 cases, all 64 KiB mappings). There are 0 linearpaircases, where there were 117 before (30 of them wrong). No GPU errors, and no slowdown: frames 2300→2700 took 22 s, against 26 s on the earlier base.Cost: one page-table lookup per vertex fetch in graphics programs. It didn't show in the frame times above. Note that the change retranslates every graphics shader with root views once, so the first run after it is a cold one.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T00:57:36Z.
Review: APPROVED
Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!