Shaders: guard memory_dirty atomics with test-before-or and coalesce page-table loads (FIND-12) #2167

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

@⁠RVZO6 on GitHub · 2026-11-25 06:50 UTC · original
RVZO6:rvzo/find12-dirty-atomics → main · +292 −59 · 4 files · 1 commits · open

Addresses FIND-12: shaders lowered through the title-memory page-table path currently issue an unconditional dx.op.atomicBinOp.i32 (Or) into the global memory_dirty bitmap on every store — twice per multi-byte store (for start and end, even when both land on the same 64 KiB page) — causing severe L2 atomic contention when many compute lanes write the same page (~2.4 s/dispatch, 4.8–6.9 s/frame reported on RTX 5080). In addition, every title-memory access re-loads memory_table[4096] (memory_null) and reads (view, start) as two separate 4-byte rawBufferLoads, and mark_view_write reads (base, phase) as two separate 4-byte rawBufferLoads and emits a second dirty mark even for single-byte stores.

The change

  • crates/victory-shader/src/emit/shader.rs: add memory_null: Option<V> and Shader::memory_null() so the null-view index at memory_table[4096 * 4] is loaded once in entry block 0 (emit_at_entry, safe even when first used inside a branch) and reused across all title-memory accesses.
  • crates/victory-shader/src/emit/lower.rs:
    • Add raw_dword2() (dx.op.rawBufferLoad.f32, mask = 3, align = 8) to coalesce the contiguous 8-byte (view, start) load in memory_entry() and (base, phase) load in mark_view_write().
    • Add mark_dirty_bits(bitmap, bits, guard):
      • Omits the 2nd dirty mark statically when bytes <= 1 (single-byte stores cannot cross a 64 KiB page boundary).
      • For multi-byte stores, checks n != bits[0] before computing the word/bit offset and loading the bitmap.
      • Guards every dirty-mark dx.op.atomicBinOp.i32 (Or) with a read-only rawBufferLoad + (old & bit) == 0 branch so already-dirty pages never serialize on L2 atomics. Uses pure 32-bit ops without WAVE_OPS (SFI0 & 0x4000 == 0).
  • crates/victory-shader/src/emit/memory_tests.rs: add memory_entry_caches_null_coalesces_loads_and_guards_dirty_atomics and dirty_mark_width_and_branch_hoisting verifying single entry-block memory_null, coalesced raw_dword2 loads, guarded dirty-mark atomics, n != bits[0] gating before bitmap load, 1-byte 2nd-mark elision, dxil.dll validation, and zero WAVE_OPS.

Not a duplicate of

FIND-12 is open in CLAIMS.md; no other open PR guards memory_dirty atomics or coalesces page-table / view-mark raw_dword2 loads in crates/victory-shader/src/emit/lower.rs.

Tested

  • Official windows-latest MSVC + Windows WARP SM 6.6 CI on fork integration stack (Run 45562558052):
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.
    • cargo test --workspace --locked: 712 passed, 0 failed, 10 ignored, including victory-shader 249 passed, 0 failed, 3 ignored (all 5 emit::memory_tests::* including title_memory_is_read_and_written_at_computed_addresses, root_views_read_their_copy_and_zeros_past_it, writes_through_views_mark_their_pages, and both new bitcode/validator tests on Windows WARP SM 6.6) and xtask (6 passed, 0 failed, repository_passes_policy).
  • Standalone branch 6ab9c98: cargo clippy (default & --all-features) -D warnings clean; Wine-10.0 + dxil.dll 1.9.2609.5 passed both new tests and emit::lower:: / emit::bitcode:: (29 passed, 0 failed).

Not run: the title; any hardware GPU (CI ran on Windows WARP SM 6.6 only). The title was not used in these tests.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

**@⁠RVZO6** on GitHub · 2026-11-25 06:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167) `RVZO6:rvzo/find12-dirty-atomics` → `main` · +292 −59 · 4 files · 1 commits · open Addresses `FIND-12`: shaders lowered through the title-memory page-table path currently issue an unconditional `dx.op.atomicBinOp.i32` (`Or`) into the global `memory_dirty` bitmap on every store — twice per multi-byte store (for `start` and `end`, even when both land on the same 64 KiB page) — causing severe L2 atomic contention when many compute lanes write the same page (~2.4 s/dispatch, 4.8–6.9 s/frame reported on RTX 5080). In addition, every title-memory access re-loads `memory_table[4096]` (`memory_null`) and reads `(view, start)` as two separate 4-byte `rawBufferLoad`s, and `mark_view_write` reads `(base, phase)` as two separate 4-byte `rawBufferLoad`s and emits a second dirty mark even for single-byte stores. ## The change - `crates/victory-shader/src/emit/shader.rs`: add `memory_null: Option<V>` and `Shader::memory_null()` so the null-view index at `memory_table[4096 * 4]` is loaded once in entry block 0 (`emit_at_entry`, safe even when first used inside a branch) and reused across all title-memory accesses. - `crates/victory-shader/src/emit/lower.rs`: - Add `raw_dword2()` (`dx.op.rawBufferLoad.f32`, `mask = 3`, `align = 8`) to coalesce the contiguous 8-byte `(view, start)` load in `memory_entry()` and `(base, phase)` load in `mark_view_write()`. - Add `mark_dirty_bits(bitmap, bits, guard)`: - Omits the 2nd dirty mark statically when `bytes <= 1` (single-byte stores cannot cross a 64 KiB page boundary). - For multi-byte stores, checks `n != bits[0]` *before* computing the word/bit offset and loading the bitmap. - Guards every dirty-mark `dx.op.atomicBinOp.i32` (`Or`) with a read-only `rawBufferLoad` + `(old & bit) == 0` branch so already-dirty pages never serialize on L2 atomics. Uses pure 32-bit ops without `WAVE_OPS` (`SFI0 & 0x4000 == 0`). - `crates/victory-shader/src/emit/memory_tests.rs`: add `memory_entry_caches_null_coalesces_loads_and_guards_dirty_atomics` and `dirty_mark_width_and_branch_hoisting` verifying single entry-block `memory_null`, coalesced `raw_dword2` loads, guarded dirty-mark atomics, `n != bits[0]` gating before bitmap load, 1-byte 2nd-mark elision, `dxil.dll` validation, and zero `WAVE_OPS`. ## Not a duplicate of `FIND-12` is open in `CLAIMS.md`; no other open PR guards `memory_dirty` atomics or coalesces page-table / view-mark `raw_dword2` loads in `crates/victory-shader/src/emit/lower.rs`. ## Tested - Official `windows-latest` MSVC + Windows WARP SM 6.6 CI on fork integration stack ([Run 45562558052](https://github.com/RVZO6/VIctory/actions/runs/45562558052)): - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test --workspace --locked`: **712 passed, 0 failed, 10 ignored**, including `victory-shader` **249 passed, 0 failed, 3 ignored** (all 5 `emit::memory_tests::*` including `title_memory_is_read_and_written_at_computed_addresses`, `root_views_read_their_copy_and_zeros_past_it`, `writes_through_views_mark_their_pages`, and both new bitcode/validator tests on Windows WARP SM 6.6) and `xtask` (`6 passed, 0 failed`, `repository_passes_policy`). - Standalone branch `6ab9c98`: `cargo clippy` (default & `--all-features`) `-D warnings` clean; Wine-10.0 + `dxil.dll 1.9.2609.5` passed both new tests and `emit::lower::` / `emit::bitcode::` (`29 passed, 0 failed`). **Not run:** the title; any hardware GPU (CI ran on Windows WARP SM 6.6 only). The title was not used in these tests. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
Coalesce 8-byte (view, start) page-table and (base, phase) view-mark
loads via raw_dword2 (mask 3, alignment 8), cache memory_null once in
the entry block across title-memory accesses, omit the second dirty
mark statically for single-byte writes, hoist the n != bits[0] guard
before bitmap word/bit loads, and guard every dirty-mark atomicBinOp
OR with a test-before-atomic rawBufferLoad check without WAVE_OPS.

Assisted-by: T3 Code (Antigravity, gemini-4-neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:07 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 08:02 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head 6ab9c988 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 08:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7156529538) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 6ab9c988 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 08:40 UTC · original

Verified head 6ab9c9880f5b8dbad7582f8a046473b4e3e659c6 merged cleanly onto main (940d32f69b) on Windows 11 x64 / AMD Radeon RX 7600 (driver 32.0.32029.2010, rustc 1.98.1, dxil.dll 1.8.2502.11):

  • cargo test -p victory-shader emit::memory_tests -- --nocapture: 5 passed, 0 failed (confirms dx.op.rawBufferLoad.f32(..., mask=3, align=8) validates against dxil.dll 1.8.2502.11 and executes on RDNA3 hardware).
  • $env:VICTORY_D3D12_DEBUG='1'; cargo test -p victory-gpu --lib memory:: -- --test-threads=1: 3 passed, 0 failed.
  • Source audit against lower.rs / shader.rs / draw.rs / memory.rs:
    • Shader::memory_null() hoisting into block 0 strictly dominates all uses in bitcode.rs SSA layout, resets cleanly on Stop::Retry, and every dispatched stage with stage.memory.is_some() binds a full page table (draw.rs:739-771).
    • mark_dirty_bits structured CFG keeps begin_guarded/end_guarded nested with zero wave ops (SFI0 & 0x4000 == 0 -> RDNA3 Wave32/64 divergence safe), non-globallycoherent L1 reads of monotonically 0 -> 1 bits are conservative, and all four write == true callers in lower.rs re-read self.cur.

Looks good to merge from this check.

AI-assisted; synthetic tests only, no game files, dumps, or captures used.

**@⁠nathanbzrr** on GitHub · 2026-11-25 08:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7157332651) Verified head `6ab9c9880f5b8dbad7582f8a046473b4e3e659c6` merged cleanly onto `main` (`940d32f69b`) on Windows 11 x64 / **AMD Radeon RX 7600** (driver `32.0.32029.2010`, `rustc 1.98.1`, `dxil.dll 1.8.2502.11`): - `cargo test -p victory-shader emit::memory_tests -- --nocapture`: **5 passed, 0 failed** (confirms `dx.op.rawBufferLoad.f32(..., mask=3, align=8)` validates against `dxil.dll 1.8.2502.11` and executes on RDNA3 hardware). - `$env:VICTORY_D3D12_DEBUG='1'; cargo test -p victory-gpu --lib memory:: -- --test-threads=1`: **3 passed, 0 failed**. - Source audit against `lower.rs` / `shader.rs` / `draw.rs` / `memory.rs`: - `Shader::memory_null()` hoisting into block `0` strictly dominates all uses in `bitcode.rs` SSA layout, resets cleanly on `Stop::Retry`, and every dispatched stage with `stage.memory.is_some()` binds a full page table (`draw.rs:739-771`). - `mark_dirty_bits` structured CFG keeps `begin_guarded`/`end_guarded` nested with zero wave ops (`SFI0 & 0x4000 == 0` -> RDNA3 Wave32/64 divergence safe), non-`globallycoherent` L1 reads of monotonically `0 -> 1` bits are conservative, and all four `write == true` callers in `lower.rs` re-read `self.cur`. Looks good to merge from this check. AI-assisted; synthetic tests only, no game files, dumps, or captures used.
Author
Owner

@⁠Slay326 on GitHub · 2026-11-25 09:45 UTC · original

Hardware data point for the contention this PR removes. I measured main (940d32f) against main + this PR (6ab9c988) with a synthetic compute test: 64 threads per group, each doing 8 global_store_dwordx4 through the title-memory page table (the shape of a node writer), GPU timestamps, 3 runs of 5 dispatches each (median per run, mean of the 3 runs). RTX 3070 8 GB, driver 32.0.16.1088, Windows 11 Pro 26200.

Written-pages bitmap in system memory (as memory::bind makes it), copy of title memory in video memory:

groups per dispatch main #2167 factor
71 585 us/group (41.6 ms) 0.18 us/group (0.013 ms) ~3,200x
1000 575 us/group (575 ms) 0.103 us/group (0.10 ms) ~5,600x
9000 559 us/group (5.03 s) 0.0965 us/group (0.87 ms) ~5,800x

Bitmap in video memory (as in #2175), same test: 0.62 us/group on main, 0.096 us/group with #2167 (9000 groups). With #2167 the bitmap's location no longer matters for the marks (0.0965 vs 0.096). On WARP (same test, bitmap in system memory, 1000 groups) it is 10.3 us/group on main and 0.86 us/group with #2167.

The marked pages are identical on both branches in every variant and every run (9 of 9, 125 of 125, 1125 of 1125 pages). cargo test -p victory-shader and -p victory-gpu give the same failures on main and on main + #2167 (3 hardware-comparison tests in stride_tests/synthetic_tests, and 2 heap-size tests in victory-gpu; they fail identically without this PR, and all other tests pass).

With #1890 and other local changes (so not main; title 1.0.2.1): one list of the XboxBvhBuilder passes (a node writer with 12 stores per thread over ~140,000 groups) ran for more than 535 s and never finished. With the same guard in place (our equivalent of this PR) the same passes take a median of 25 ms and 19 ms of GPU time per frame and no list stalls (300 s run, 42 world intervals).

On correctness: the bitmap only goes from 0 to 1 during a submission, and the host clears it (defer_after, mem::take) only after execute has waited for the lists. A stale load can therefore only see a bit as clear (an extra, harmless OR), never a cleared bit as set. Two lanes that both see a clear bit both OR it, which is idempotent. A list named twice in one submission shares the bitmap, and the union is read after both runs, so skipped atomics lose nothing. So globallycoherent is not needed.

AI-assisted.

**@⁠Slay326** on GitHub · 2026-11-25 09:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7158756560) Hardware data point for the contention this PR removes. I measured main (940d32f) against main + this PR (6ab9c988) with a synthetic compute test: 64 threads per group, each doing 8 `global_store_dwordx4` through the title-memory page table (the shape of a node writer), GPU timestamps, 3 runs of 5 dispatches each (median per run, mean of the 3 runs). RTX 3070 8 GB, driver 32.0.16.1088, Windows 11 Pro 26200. Written-pages bitmap in system memory (as `memory::bind` makes it), copy of title memory in video memory: | groups per dispatch | main | #2167 | factor | |---|---|---|---| | 71 | 585 us/group (41.6 ms) | 0.18 us/group (0.013 ms) | ~3,200x | | 1000 | 575 us/group (575 ms) | 0.103 us/group (0.10 ms) | ~5,600x | | 9000 | 559 us/group (5.03 s) | 0.0965 us/group (0.87 ms) | ~5,800x | Bitmap in video memory (as in #2175), same test: 0.62 us/group on main, 0.096 us/group with #2167 (9000 groups). With #2167 the bitmap's location no longer matters for the marks (0.0965 vs 0.096). On WARP (same test, bitmap in system memory, 1000 groups) it is 10.3 us/group on main and 0.86 us/group with #2167. The marked pages are identical on both branches in every variant and every run (9 of 9, 125 of 125, 1125 of 1125 pages). `cargo test -p victory-shader` and `-p victory-gpu` give the same failures on main and on main + #2167 (3 hardware-comparison tests in `stride_tests`/`synthetic_tests`, and 2 heap-size tests in `victory-gpu`; they fail identically without this PR, and all other tests pass). With #1890 and other local changes (so not `main`; title 1.0.2.1): one list of the XboxBvhBuilder passes (a node writer with 12 stores per thread over ~140,000 groups) ran for more than 535 s and never finished. With the same guard in place (our equivalent of this PR) the same passes take a median of 25 ms and 19 ms of GPU time per frame and no list stalls (300 s run, 42 world intervals). On correctness: the bitmap only goes from 0 to 1 during a submission, and the host clears it (`defer_after`, `mem::take`) only after `execute` has waited for the lists. A stale load can therefore only see a bit as clear (an extra, harmless OR), never a cleared bit as set. Two lanes that both see a clear bit both OR it, which is idempotent. A list named twice in one submission shares the bitmap, and the union is read after both runs, so skipped atomics lose nothing. So `globallycoherent` is not needed. AI-assisted.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 10:44 UTC · original

@⁠RVZO6 a data point from the title on an RTX 5080 (Linux, Proton, vkd3d-proton 3.2.0), on our stack with #439.

At world load, the title issues one list of about 7,000 direct dispatches of Microsoft's XboxBvhBuilder.dll rehydration passes (Box32Rehydration 28918b7150a7aad5, Box16Rehydration caa78b8ca62bc3d6, DecompressHeader 4ddd6f9702fab2a7). Most are 1 to 11 groups, and Box32 goes up to about 1,800. Without this PR the GPU worked through about 200 of them per second (measured with the breadcrumbs from #2310), so the list ran past the driver's timeout: NVRM: Xid 109 CTX SWITCH TIMEOUT, then the title's watchdog. We had to skip those three passes.

With this PR merged (cleanly; one fix-up commit so the Windows test helper builds on #439's Parts/Lower), the whole list finishes and the run gets past it. Breadcrumbs stop pointing at these passes. The next stall is a different program, in the title's hair system, which we're looking at separately. The translated Box32 drops from 274 to 233 raw loads, and every dirty-mark atomic now sits behind the bit test.

Thanks. This turned the world load on NVIDIA from "times out" to "goes through" for us.

**@⁠desplmfao** on GitHub · 2026-11-25 10:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7160112605) @⁠RVZO6 a data point from the title on an RTX 5080 (Linux, Proton, vkd3d-proton 3.2.0), on our stack with #439. At world load, the title issues one list of about 7,000 direct dispatches of Microsoft's `XboxBvhBuilder.dll` rehydration passes (`Box32Rehydration` `28918b7150a7aad5`, `Box16Rehydration` `caa78b8ca62bc3d6`, `DecompressHeader` `4ddd6f9702fab2a7`). Most are 1 to 11 groups, and Box32 goes up to about 1,800. Without this PR the GPU worked through about 200 of them per second (measured with the breadcrumbs from #2310), so the list ran past the driver's timeout: `NVRM: Xid 109 CTX SWITCH TIMEOUT`, then the title's watchdog. We had to skip those three passes. With this PR merged (cleanly; one fix-up commit so the Windows test helper builds on #439's `Parts`/`Lower`), the whole list finishes and the run gets past it. Breadcrumbs stop pointing at these passes. The next stall is a different program, in the title's hair system, which we're looking at separately. The translated Box32 drops from 274 to 233 raw loads, and every dirty-mark atomic now sits behind the bit test. Thanks. This turned the world load on NVIDIA from "times out" to "goes through" for us.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:37 UTC · original · edited 2026-11-26 01:21 UTC

Automated triage for the maintainers.

Merge candidate (re-checked after the rebase onto 63bcca4, head 3cb308d). It merges cleanly again. In crates/victory-shader/src/emit/lower.rs, Lower::memory now marks both its first page and the straddling page from main's 256 MiB / 4 GiB fix through the new mark_dirty_bit. That function loads the bitmap word first and issues the atomicOr only when the bit is clear, the same pattern mark_view_write already used on main. Other changes:

  • mark_view_write skips the second mark for 1-byte writes.
  • The (view, start) and (base, phase) pairs are read with one 8-byte-aligned raw_dword2.
  • Shader::memory_null loads the null index once in the entry block, as memory_handle does.

Which pages end up marked is the same as on main, by my reading.

Performance results are mixed: one tester reports a large speedup, another sees no change in W's time on an RTX 3070 Ti. Either way, the change only removes atomics for bits that are already set. #2755 adds wave-level coalescing on top of the same pre-check, so the maintainer may want to land this first and rebase that one. Optional: lower/mark_tests.rs and the bitcode reader in memory_tests.rs are not rustfmt-formatted.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7162624243) · edited 2026-11-26 01:21 UTC <!-- victory-triage v1 head=3cb308dd76c8b7e7617590e637ab99d005b31f90 verdict=merge-candidate at=2026-11-26T01:21:44Z --> Automated triage for the maintainers. **Merge candidate (re-checked after the rebase onto `63bcca4`, head `3cb308d`).** It merges cleanly again. In `crates/victory-shader/src/emit/lower.rs`, `Lower::memory` now marks both its first page and the straddling page from `main`'s 256 MiB / 4 GiB fix through the new `mark_dirty_bit`. That function loads the bitmap word first and issues the `atomicOr` only when the bit is clear, the same pattern `mark_view_write` already used on `main`. Other changes: - `mark_view_write` skips the second mark for 1-byte writes. - The `(view, start)` and `(base, phase)` pairs are read with one 8-byte-aligned `raw_dword2`. - `Shader::memory_null` loads the null index once in the entry block, as `memory_handle` does. Which pages end up marked is the same as on `main`, by my reading. Performance results are mixed: one tester reports a large speedup, another sees no change in W's time on an RTX 3070 Ti. Either way, the change only removes atomics for bits that are already set. #2755 adds wave-level coalescing on top of the same pre-check, so the maintainer may want to land this first and rebase that one. Optional: `lower/mark_tests.rs` and the bitcode reader in `memory_tests.rs` are not rustfmt-formatted. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠RVZO6 on GitHub · 2026-11-25 17:20 UTC · original

Rebased onto current main (13f91ca, head 87e9805; resolved the end-of-file test-append conflict in memory_tests.rs).

Verified green on windows-latest MSVC + WARP SM 6.6 CI (Run 45662428628) and Wine + dxil.dll 1.9.2609.5.

Thanks to @⁠Slay326 for the RTX 3070 timestamp benchmark (~3,200x–5,800x; 535 s -> 19–25 ms in title) and @⁠desplmfao for confirming it resolves the RTX 5080 world-load timeout.

**@⁠RVZO6** on GitHub · 2026-11-25 17:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7169354041) Rebased onto current `main` (`13f91ca`, head `87e9805`; resolved the end-of-file test-append conflict in `memory_tests.rs`). Verified green on `windows-latest` MSVC + WARP SM 6.6 CI ([Run 45662428628](https://github.com/RVZO6/VIctory/actions/runs/45662428628)) and Wine + `dxil.dll 1.9.2609.5`. Thanks to @⁠Slay326 for the RTX 3070 timestamp benchmark (~3,200x–5,800x; 535 s -> 19–25 ms in title) and @⁠desplmfao for confirming it resolves the RTX 5080 world-load timeout.
Author
Owner

@⁠davesousa on GitHub · 2026-11-25 20:08 UTC · original

In-game check against W on Windows NVIDIA (W is FIND-12's 16x16x16 dispatch, [compute 00167d58cc5a78d7] in #1968): RTX 3070 Ti 8 GB, driver 621.40, Windows 11 26200. main 13f91ca + #2319, with and without this PR (87e9805, merges cleanly; memory_tests 5/5 pass here, skipping the #2571 crash), shader cache rebuilt for each translator.

Build W, per host submission that contains it (slow host submission ms=)
13f91ca + #2319 + #1906 10.1-11.6 s (21 submissions, average 11.3 s)
13f91ca + #2319 + this PR 11.3, 11.6 s (2 submissions)
13f91ca + #2319 + #1906 + this PR 11.4-11.6 s (3 submissions)

On this card W's time does not change with this PR. With VICTORY_GPU_TIMING=1 (base 13f91ca + #2319), W alone is 11.4-11.6 s as one list command (4 times), so the time is in W itself, not the lists around it. W was issued in every run that got to world loading (6 of 6), in the first submission with heavy compute and then about once per world frame (FIND-15).

One observation I could not attribute: with both #1906 and this PR, 2 of 3 runs ended at boot with the title's own 0xc0000005 write to 0 at image+0x258b000 (before the first menu). The third reached the world. With only one of the two PRs, 3 of 3 booted. That is too few runs to blame either PR; I note it in case someone sees the same offset.

AI-assisted (Claude Code); the runs are on my machine.

**@⁠davesousa** on GitHub · 2026-11-25 20:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7173244528) In-game check against W on Windows NVIDIA (W is FIND-12's 16x16x16 dispatch, `[compute 00167d58cc5a78d7]` in #1968): RTX 3070 Ti 8 GB, driver 621.40, Windows 11 26200. `main` `13f91ca` + #2319, with and without this PR (`87e9805`, merges cleanly; `memory_tests` 5/5 pass here, skipping the #2571 crash), shader cache rebuilt for each translator. | Build | W, per host submission that contains it (`slow host submission ms=`) | |---|---| | `13f91ca` + #2319 + #1906 | 10.1-11.6 s (21 submissions, average 11.3 s) | | `13f91ca` + #2319 + this PR | 11.3, 11.6 s (2 submissions) | | `13f91ca` + #2319 + #1906 + this PR | 11.4-11.6 s (3 submissions) | On this card W's time does not change with this PR. With `VICTORY_GPU_TIMING=1` (base `13f91ca` + #2319), W alone is 11.4-11.6 s as one list command (4 times), so the time is in W itself, not the lists around it. W was issued in every run that got to world loading (6 of 6), in the first submission with heavy compute and then about once per world frame (FIND-15). One observation I could not attribute: with both #1906 and this PR, 2 of 3 runs ended at boot with the title's own `0xc0000005` write to 0 at `image+0x258b000` (before the first menu). The third reached the world. With only one of the two PRs, 3 of 3 booted. That is too few runs to blame either PR; I note it in case someone sees the same offset. AI-assisted (Claude Code); the runs are on my machine.
Author
Owner

@⁠RVZO6 on GitHub · 2026-11-26 00:21 UTC · original

Rebased onto current main (63bcca4, head 3cb308d). Preserved 63bcca4's 256 MiB / 4 GiB straddling-write fix in Lower::memory (applying test-before-OR mark_dirty_bit to both primary and straddling-page marks) and moved synthetic_mark_dxil into crates/victory-shader/src/emit/lower/mark_tests.rs so lower.rs stays below the 512 KiB asset-policy limit. Verified green on windows-latest MSVC + WARP SM 6.6 CI (clippy, xtask policy, full workspace tests): https://github.com/RVZO6/VIctory/actions/runs/45727774760.

**@⁠RVZO6** on GitHub · 2026-11-26 00:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#issuecomment-7178664696) Rebased onto current `main` (`63bcca4`, head `3cb308d`). Preserved `63bcca4`'s 256 MiB / 4 GiB straddling-write fix in `Lower::memory` (applying test-before-OR `mark_dirty_bit` to both primary and straddling-page marks) and moved `synthetic_mark_dxil` into `crates/victory-shader/src/emit/lower/mark_tests.rs` so `lower.rs` stays below the 512 KiB asset-policy limit. Verified green on `windows-latest` MSVC + WARP SM 6.6 CI (clippy, xtask policy, full workspace tests): https://github.com/RVZO6/VIctory/actions/runs/45727774760.
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 07:03 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib emit::memory_tests:: — 5 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean test-before-or guard on memory_dirty atomics and coalesced page-table loads (FIND-12), verified end-to-end on hardware and WARP. Looks great.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 07:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#pullrequestreview-6053209540) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib emit::memory_tests::` — **5 passed, 0 failed** on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean test-before-or guard on `memory_dirty` atomics and coalesced page-table loads (`FIND-12`), verified end-to-end on hardware and WARP. Looks great. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 07:24 UTC · original · approved these changes

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. memory_dirty atomics guarded with test-before-or — atomic guard correctness fix.

**@⁠catminou4** on GitHub · 2026-11-25 07:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#pullrequestreview-6053419741) · **approved these changes** Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. memory_dirty atomics guarded with test-before-or — atomic guard correctness fix.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 17:01 UTC · original · approved these changes

Verified 3cb308dd76c8b7e7617590e637ab99d005b31f90 merged cleanly onto 63bcca43 on Windows 11 with an RTX 5090, WARP, dxil.dll (Windows SDK 10.0.26100.0), and VICTORY_D3D12_DEBUG=1.

Code review

  • Shader::memory_null() (crates/victory-shader/src/emit/shader.rs:398) emits the memory_table[4096 * 4] load once in entry block 0 after memory_handle(), strictly dominating all uses including accesses inside conditional branches.
  • Lower::raw_dword2 (crates/victory-shader/src/emit/lower.rs:4549) issues an 8-byte-aligned rawBufferLoad.f32 (mask = 3, align = 8) for both (base, phase) at index * 8 (mark_view_write, lower.rs:4601) and (view, start) at (entry << 3) + 4096 * 4 (memory_entry, lower.rs:4785); both offsets and backing D3D12 buffers satisfy 8-byte alignment.
  • mark_dirty_bit (lower.rs:4559) and mark_dirty_bits (lower.rs:4581) guard every dirty-mark atomicBinOp.i32 (Or) with a read-only load and (old & bit) == 0 branch without introducing WAVE_OPS. Since submission dirty bitmaps transition monotonically 0 -> 1 until host copy-back clears them after fence completion, a stale L1 load can only trigger a redundant idempotent OR and never drop a mark.
  • Lower::memory (lower.rs:4688-4738) properly reloads let c = self.cur at lower.rs:4717 before emitting the straddling-page check and guards both the primary and straddling-page marks; mark_view_write statically omits the second mark for bytes <= 1 and checks n != bits[0] before loading the bitmap for multi-byte writes.
  • crates/victory-shader/src/emit/lower.rs stays within the 512 KiB asset-policy limit at 520,860 bytes (and 520,942 bytes when co-merged with #2229, with zero conflict).

Verification

  • cargo xtask policy: 192 files ok.
  • cargo clippy --locked -p victory-shader -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
  • RTX 5090 + WARP + dxil.dll + VICTORY_D3D12_DEBUG=1:
    • emit::memory_tests:: (skipping pre-existing #2571 NVIDIA crash in heap_direct_texture_reads_mark_their_heap_index): 6 passed, 0 failed (including memory_entry_caches_null_coalesces_loads_and_guards_dirty_atomics, dirty_mark_width_and_branch_hoisting validated by dxil.dll, and straddling_writes_across_256mib_and_4gib_boundaries_mark_exact_pages on both hardware and WARP).
    • victory-gpu memory::tests::: 7/7 passed on RTX 5090 (skipping pre-existing 1M-cap lists_share_a_table_and_copies_keep_their_views) and 8/8 passed on WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1).
**@⁠fuzeofficlal** on GitHub · 2026-11-26 17:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/2167#pullrequestreview-6077994544) · **approved these changes** Verified `3cb308dd76c8b7e7617590e637ab99d005b31f90` merged cleanly onto `63bcca43` on Windows 11 with an RTX 5090, WARP, `dxil.dll` (Windows SDK 10.0.26100.0), and `VICTORY_D3D12_DEBUG=1`. ### Code review - `Shader::memory_null()` (`crates/victory-shader/src/emit/shader.rs:398`) emits the `memory_table[4096 * 4]` load once in entry block `0` after `memory_handle()`, strictly dominating all uses including accesses inside conditional branches. - `Lower::raw_dword2` (`crates/victory-shader/src/emit/lower.rs:4549`) issues an 8-byte-aligned `rawBufferLoad.f32` (`mask = 3, align = 8`) for both `(base, phase)` at `index * 8` (`mark_view_write`, `lower.rs:4601`) and `(view, start)` at `(entry << 3) + 4096 * 4` (`memory_entry`, `lower.rs:4785`); both offsets and backing D3D12 buffers satisfy 8-byte alignment. - `mark_dirty_bit` (`lower.rs:4559`) and `mark_dirty_bits` (`lower.rs:4581`) guard every dirty-mark `atomicBinOp.i32` (`Or`) with a read-only load and `(old & bit) == 0` branch without introducing `WAVE_OPS`. Since submission dirty bitmaps transition monotonically `0 -> 1` until host copy-back clears them after fence completion, a stale L1 load can only trigger a redundant idempotent OR and never drop a mark. - `Lower::memory` (`lower.rs:4688-4738`) properly reloads `let c = self.cur` at `lower.rs:4717` before emitting the straddling-page check and guards both the primary and straddling-page marks; `mark_view_write` statically omits the second mark for `bytes <= 1` and checks `n != bits[0]` before loading the bitmap for multi-byte writes. - `crates/victory-shader/src/emit/lower.rs` stays within the 512 KiB asset-policy limit at `520,860` bytes (and `520,942` bytes when co-merged with `#2229`, with zero conflict). ### Verification - `cargo xtask policy`: `192 files ok`. - `cargo clippy --locked -p victory-shader -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. - RTX 5090 + WARP + `dxil.dll` + `VICTORY_D3D12_DEBUG=1`: - `emit::memory_tests::` (skipping pre-existing `#2571` NVIDIA crash in `heap_direct_texture_reads_mark_their_heap_index`): **6 passed, 0 failed** (including `memory_entry_caches_null_coalesces_loads_and_guards_dirty_atomics`, `dirty_mark_width_and_branch_hoisting` validated by `dxil.dll`, and `straddling_writes_across_256mib_and_4gib_boundaries_mark_exact_pages` on both hardware and WARP). - `victory-gpu` `memory::tests::`: **7/7 passed** on RTX 5090 (skipping pre-existing 1M-cap `lists_share_a_table_and_copies_keep_their_views`) and **8/8 passed** on WARP (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`).
This pull request can be merged automatically.
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/2167/head:github-bot/gh-2167'
git switch 'github-bot/gh-2167'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2167'
git switch 'github-bot/gh-2167'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2167'
git switch 'github-bot/gh-2167'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2167'
git switch 'main'
git merge --squash 'github-bot/gh-2167'
git switch 'main'
git merge --ff-only 'github-bot/gh-2167'
git switch 'main'
git merge 'github-bot/gh-2167'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2167
No description provided.