Repository navigation
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
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 subdword— 4 passed, 0 failed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1(includingsubdword_buffer_stores_emit_cas_loop_and_validate)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)
Clean atomicCompareExchange CAS-loop lowering for buffer_store_byte and buffer_store_short, verified end-to-end on RTX 5090 + WARP. Looks great.
AI-assisted (Gemini 4 Neon).
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.
145 passed / 0 failed. buffer_store atomics via atomicCompareExchange CAS loop — CAS-loop lowering for buffer atomics.
Offline measurement on a retail dumpResult: no count change against I merged head 0624052 onto 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). |
|
Automated triage for the maintainers. Merge candidate. Rebased onto current In CI: passing ( Generated by Claude Code |
|
Rebased onto current Verified green on |
0624052 to
ed06257
Compare
…rrier fence, W14-07 CAS stores, W14-08 wave64 readlane Implements Wave 14 Lane 14C shader stability fixes: - W14-01 (--store-page-guard, adapted from ethan00013/keylime@650550ffa, GPL-3.0): emit lazy %store_addr_valid(heap_base, va) checking the 64 KiB page-validity bitmap at heap_base+0x170000 and GPBM control header at heap_base+0x180000 (runtime/src/gpu_page_bitmap.h) on PSB stores/atomics; default off, zero bloat on read-only shaders. - W14-05 (adapted from ethan00013/keylime@0afb8154c5, GPL-3.0): per-function tripped flag in add_loop_guards so hitting a nested inner loop cap breaks enclosing loops instead of multiplying limit*limit. - W14-06 (adapted from Marvisak/VIctory#1799 & five-star-recomp@320612a4d7, GPL-3.0): downgrade s_barrier inside switch/dispatch form, divergent guards, or non-top-level mesh blocks to OpMemoryBarrier while preserving uniform top-level CS OpControlBarrier. - W14-07 (adapted from Marvisak/VIctory#2208, GPL-3.0): replace OpAtomicAnd+OpAtomicOr in global_sub and buffer_sub with OpAtomicCompareExchange CAS loops. - W14-08 (adapted from fxceless/victory-fork#354 GPL-3.0 & brcly/TuxBox#185 Apache-2.0): tighten uniform_vgprs/wave64_halves implicit-read tracking (DPP mods, vlist, block-0 back-edges, v_fmac_f64, v_dot*c_u32_*, v_cndmask_b16) and constant-lane/uniform v_readlane_b32 lowering. - Add synthetic semantic & spirv-val regression suite tests/semantic/test_w14_shader_stability.py (zero game data).
…rmat CAS - Guard k > 0 dwords of swizzled multi-dword tbuffer_store with store_addr_valid(va_k) when step is not None and --store-page-guard is enabled (tools/rdna2spirv.py). - Upgrade 1-/2-byte tbuffer_store_format and dynamic buffer_store_format sub-dword merges from non-atomic OpAtomicAnd+OpAtomicOr to atomic_subdword_cas (Marvisak/VIctory#2208, GPL-3.0). - Add W15-05 semantic & spirv-val tests in tests/semantic/test_w14_shader_stability.py and update stale OpAtomicAnd/Or assertions in tests/semantic/test_buffer_store_format.py and tests/test_translate.py.
… buffer_store_short Sub-dword raw buffer stores previously lowered to two separate dx.op.atomicBinOp.i32 calls (AND to clear the target byte or half, then OR to set the new bits). When two lanes or threads store to the same byte or halfword concurrently, their clears and sets can interleave (AND, AND, OR, OR) and produce a bitwise-OR tear such as 0xFF or 0xFFFF. Replace the AND+OR sequence with a lock-free dx.op.atomicCompareExchange.i32 (opcode 79) CAS loop inside begin_guarded(guard): load the initial dword from the raw RWByteAddressBuffer via rawBufferLoad.f32 (no TYPED_UAV_LOADS required), loop with a phi updating only the target byte/half bits until prev == old, then advance to the exit block for mark_view_write and end_guarded. Add a zero-GPU DXIL IR/CFG + dxil.dll validation test in emit::lower covering byte/short, unguarded/guarded, and view_marks on/off, plus hardware/WARP execution tests in emit::stride_tests covering distinct-lane packing and concurrent same-slot byte/halfword races. Assisted-by: T3 Code (Antigravity, gemini-4-neon)
|
Rebased onto current |
ed06257 to
7bad309
Compare
…AS loop for buffer_store_byte and buffer_store_short # Conflicts: # crates/victory-shader/src/emit/lower.rs
…AS loop for buffer_store_byte and buffer_store_short # Conflicts: # crates/victory-shader/src/emit/lower.rs
fuzeofficlal
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (63bcca43, Windows 11 x64, Rust 1.98.1 MSVC, RTX 5090 & WARP + dxil.dll):
cargo test --locked -p victory-shader --lib subdword(VICTORY_WARP=0andVICTORY_WARP=1) — 4 passed, 0 failed (includingsubdword_buffer_stores_emit_cas_loop_and_validate,subdword_cas_shaders_lower_and_validate,subdword_buffer_stores_do_not_tear_concurrent_same_slot_writes, andsubdword_buffer_stores_pack_distinct_lanes_in_one_dword)cargo test --locked -p victory-shader --lib emit::lower::tests::(VICTORY_WARP=0andVICTORY_WARP=1) — 33 passed, 0 failedcargo test --locked -p victory-shader --lib emit::stride_tests::— 11 passed, 0 failed on WARP (VICTORY_WARP=1); 9 passed, 0 failed on RTX 5090 (--skip a_heap_buffer_read_)cargo test --locked -p victory-shader --lib constant_color_validates— 1 passed, 0 failedcargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features) — 0 warningscargo xtask policy— ok (192 files ok);emit/lower.rssize is 522,135 B (< 524,288 B)
Review notes
- Verified the CAS loop (
crates/victory-shader/src/emit/lower.rs:9618-9665):begin_guarded/end_guardedkeeps inactive (EXEC=0) lanes out of the loop, concurrent active lanes targeting different fields of the same aligned dword converge without tearing via theoldphi feedback,dx.op.atomicCompareExchange.i32(op79, raw UAV handle) andmark_view_writeare emitted cleanly, andbitcode.rsliveness/bitcode generation is sound. - Non-blocking spec notes:
- Loop termination relies solely on
prev == old; under DXIL/SM 5.1 rules, out-of-bounds or pixel-helper atomic returns are undefined (if a driver ever returned varying values on OOB/helper lanes rather than a constant like0, the loop has no retry bound). - As noted by the
shortcutcomment atlower.rs:9623, an unalignedbuffer_store_shortatoff & 3 == 3truncates its upper byte (0xFFFF << 24), matching the prior single-dword assumption.
- Loop termination relies solely on
- Minor formatting nit:
rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower/subdword_tests.rsflags the long import on line 2, extra blank line on line 15, and comment/assert wrapping.
Sub-dword raw buffer stores (
buffer_store_byteandbuffer_store_short) incrates/victory-shader/src/emit/lower.rscurrently lower to two separatedx.op.atomicBinOp.i32calls: anANDto clear the target byte or halfword followed by anORto write the new bits. When two lanes or threads store to the same byte or halfword concurrently, their clears and sets can interleave (AND,AND,OR,OR), producing a bitwise-OR tear (such as0xFFor0xFFFF).Claimed on #1633 (
https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155420630).The change
crates/victory-shader/src/emit/lower.rs:AND+ORsequence with a lock-freedx.op.atomicCompareExchange.i32(opcode79) CAS loop insidebegin_guarded(guard):rawBufferLoad.f32(noTYPED_UAV_LOADSrequired).casblock (header = exiting latch, preserving clean structured CFG) updating only the target byte/halfword bits untilprev == old.mark_view_writeandend_guarded.dxil.dllvalidation testsubdword_buffer_stores_emit_cas_loop_and_validatecovering byte/short, unguarded/guarded, andview_markson/off.crates/victory-shader/src/emit/bitcode.rs:#[cfg(test)]IR/CFG inspection helperscall_countandcas_loop_count.crates/victory-shader/src/emit/stride_tests.rs:subdword_buffer_stores_pack_distinct_lanes_in_one_dwordandsubdword_buffer_stores_do_not_tear_concurrent_same_slot_writes(64-lane same-slot byte/halfword race).Not a duplicate of
No open PR or
CLAIMS.mdentry replaces the racyAND+ORlowering ofbuffer_store_byte/buffer_store_shortwith a CAS loop.Tested
windows-latestMSVC + Windows WARP SM 6.6 CI run45570823602(Clippyclean,Clippy, diagnostics buildclean,Tests:731 passed; 0 failed; 10 ignored,victory-shader:262 passed; 0 failed; 3 ignored,xtask:6 passed; 0 failed):subdword_buffer_stores_emit_cas_loop_and_validate ... okemit::stride_tests::subdword_cas_shaders_lower_and_validate ... okemit::stride_tests::subdword_buffer_stores_pack_distinct_lanes_in_one_dword ... ok(executed on Windows WARP SM 6.6)emit::stride_tests::subdword_buffer_stores_do_not_tear_concurrent_same_slot_writes ... ok(executed on Windows WARP SM 6.6)Not run: the title; any hardware GPU. The title was not used in these tests.
AI-assisted: T3 Code (Antigravity, gemini-4-neon)