Repository navigation
Conversation
…ter the loop
The console compiler's waterfall loop (v_readfirstlane, v_cmpx_eq,
s_andn2_wrexec, s_cbranch_execnz back to the same block) is left only once
the s_andn2_wrexec leaves no lane, so the SCC it writes (EXEC != 0) is 0
wherever a block after the loop reads it. That SCC was refused with the
EXEC write ('a lane mask read as data'), and a later s_cselect or
s_cbranch_scc reading it stopped the program. It is now the constant false;
the loop's own phis taking it (a later iteration's) still refuse.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):
cargo test -p victory-shader --lib emit::valu_tests::the_scc_a_waterfall_loop_leaves_is_false: 1 passed, 0 failed (RTX 5090 hardware + WARP).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
I extended the single-thread check to groups with 1, 2, 4 and 8 distinct keys. All 1,152 lane outputs per adapter matched on the RTX 5080, Windows built-in WARP and WARP 1.0.22 at Parent The test-only commit |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Code review on 84a02d87 (static source inspection; no runtime GPU/DXIL validation executed):
- P2 — Constant-folding
SCCtofalsealso reaches the successor on loop-limiter forced exits (crates/victory-shader/src/emit/lower.rs:3571-3608, 10214-10224):leaves_with_no_lanefoldss_andn2_wrexec'sSCCoutput tofalseassuming the loop exits only whenEXEC == 0. However, whenVICTORY_SHADER_LOOP_LIMITcuts a waterfall loop short (lower.rs:10214-10224), execution exits into the same successor while pending lanes remain (soEXEC != 0andSCCis stilltrue).- Routing capped retries to the abort block (
:10287) — and verifying that thes_andn2_wrexecretry loop only retains pending lanes asresource.rs:2031-2037does — keeps the fold sound.
- Test coverage note (
crates/victory-shader/src/emit/valu_tests.rs:299-318):build_valu_cs/run_casesdispatches 1 thread per group, so thes_cbranch_execnzback edge is never taken inthe_scc_a_waterfall_loop_leaves_is_false. Adding a multi-lane case with distinct per-lane keys would actually exercise the waterfall iteration and exit.
- File size check: patched
emit/lower.rsis521,918 B(within the 512 KiB limit).
|
Measured offline on the title's shaders (the method in #1247): head It also stacks. On top of #1924 (port) + #2978 + #385 + #2999 + #1737 on |
kotekompotek
left a comment
There was a problem hiding this comment.
LGTM — the waterfall pattern match is precise: andn2_wrexec at insts[n-2], execnz at [n-1], back-edge to the same block, and SCC not consumed by own-block phis (a phi taking it mid-loop still gets the real value). Writes marked missing + SCC=false matches post-loop semantics; the test is the canonical readfirstlane/cmpx/andn2 loop.
… a loop limit it cannot reach Review on Marvisak#3016: a loop cut short by VICTORY_SHADER_LOOP_LIMIT leaves through its normal exit with lanes still pending, so its SCC is not 0. The fold now needs the loop to compare its v_readfirstlane result with the VGPR that was read (each pass then drops at least the first lane, so it runs at most 64 passes) and loop_limit() of at least 64; otherwise the old refusal stands. A second GPU test runs the loop over 32 lanes with 1, 2, 8 and 32 distinct keys, so the back edge is taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks all. @fuzeofficlal, you're right about the limiter: a
Multi-lane coverage. New Re-measured (main @zed6000: thanks for the stacked numbers. Noted on the AI-assisted (Claude Code). |
|
Re-measured the narrowed head |
…dia-translate Shaders, HLE: fold waterfall loop SCC after loop and translate \??\ NT paths in media (Marvisak#3016, Marvisak#3030)
|
VERIFY-3016: verified Review (reading). The fold matches the
Two guards make the fold safe:
I found no defects. One edge case: an Regression check. I put the PR's test hunk alone ( At head:
Not checked: the shader-pack counts (no pack here) and the differential tests. AI-assisted (Claude Code). |
|
Automated triage for the maintainers. In Suggestion, not a blocker: no test in the PR exercises the guards (a reviewer reports that removing all three leaves the suite green). Adding the phi-guard regression from the test-only commit offered in this thread would cover that. Generated by Claude Code |
…s_andn2_wrexec leaves is false after the loop
Problem
The console compiler's waterfall loop runs, one pass per distinct value, the lanes holding the first active lane's value. Its form, as this PR's test writes it:
sop()refuses any SALU that writes EXEC, and the refusal marks every value the instruction writes, its SCC included, asa lane mask read as data. When a block after the loop reads that SCC (ans_cselect,s_cbranch_scc*ors_addc), the program is refused, though nothing reads a lane mask as a number.Change
emit/lower.rs,sop(): when the instruction writing EXEC is ans_andn2_wrexec_b32/_b64that is the second-last instruction of a block whose last iss_cbranch_execnzback to the same block, its SCC is the constantfalse. The loop is left only on its not-taken edge, that is once EXEC is 0, soEXEC != 0is false wherever a later block reads it. If one of the loop block's own phis takes the SCC (a later iteration's, on the back edge), the old refusal stands. Its other writes (EXEC and the SGPR) staya lane mask read as data, as before.Tests
valu_tests::the_scc_a_waterfall_loop_leaves_is_false(GPU): the loop above overv1, thens_cselect_b32 s23, s1, s2after it;s2expected. Fails on main at lowering (a lane mask read as data); passes with this commit on an RX 9070 XT (RADV through vkd3d-proton, GE-Proton 11-14, DXC'sdxil.dll).Measured over the title's shader pack
All 25,889 distinct containers in
shaders.rpfwent throughemit::translate_withoffline, on main63bcca4and then with this commit:63bcca4a lane mask read as data827b309e779552d7,82a2ad6d07417d36,90a0692af4320129,9ffcaff533995118, all refused before)Every other program's output is byte-identical. Two of the four are the title's skinning kernels that put animated characters into the ray-tracing structures.
All four programs' DXIL converts with dxil-spirv (master). On main + #2348 + #2978 + #385 the same commit changes exactly four programs as well (
a lane mask read as data: 202 → 198 refused there), with 0 going from translated to refused.Windows test binary under Proton on the RX 9070 XT: 301 passed and 2 failed. The 2 failures (
hosts_that_do_not_fuse_are_named,stub_pipeline_is_created) fail on main in the same environment too.cargo clippy -p victory-shader -- -D warningsis clean,cargo xtask policyis ok, andlower.rsis 521,918 bytes (+1,355 B).Not run: the differential tests (no console compiler here) and NVIDIA.
🤖 Generated with Claude Code