Repository navigation
Shaders: per-lane descriptors chosen by control flow (stacked on #307) - #566
Conversation
A descriptor picked without a branch, as the compiler does when it hoists both loads (invariant memory) and turns the if/else into a select, reaches the resource instruction through s_cselect_b64 per half (or s_cselect_b32 / s_cmov per dword). None of its dwords is then a load, so tracking stopped with "a descriptor neither loaded nor built" and the whole program, and every draw using it, was dropped. Such words are now split by the SCC value they all read: what each is when SCC is set (S0) and when it is clear (S1, or the old destination for s_cmov), with words not selected the same on both sides, and each side traced on its own into a new Source::Select. Selections with different conditions stop, and a choice that mixes two descriptors still stops as "a descriptor changed after loading". The lowering picks the heap index of the two loaded descriptors by SCC and creates one heap handle, as a phi of loaded descriptors already does per edge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A descriptor held in VGPRs is used through a waterfall loop: each pass
reads the first active lane's dwords with v_readfirstlane_b32, compares
them with every lane's own (v_cmp_eq), runs the access with the lanes
that match and repeats for the rest. Tracing stopped at the readfirstlane
results ("a descriptor neither loaded nor built").
The tracer now follows the read lanes' dwords to where each lane gets its
own: global_load_dword* from a table or heap at a per-lane address (an
image descriptor's two x4 loads lined up), or a v_cndmask_b32 choice per
lane between such sources (e.g. two s_load descriptors). Other sources
fail naming them (LDS read, buffer load, phi, input, computed VGPRs).
The loop's compares of those reads with their own dwords are recorded.
Lowering gives the access each lane's heap index (its load address over
the descriptor size, or a per-lane select of indices) with
createHandleFromHeap's nonUniformIndex set, lowers the recorded
readfirstlanes as the lane's own dword and their compares as true, so
the loop runs once with all lanes. Wave32 and wave64 are tested.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
The resource tally in `victory translate` matched every `Source` variant by hand, so the new `Select`, `Fetched` and `Lanes` kinds left it non-exhaustive and `cargo check -p victory` failed. A fetched descriptor is counted with the loaded ones; selections and per-lane choices are never leaves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
…a waterfall loop A descriptor read with v_readfirstlane_b32 was traced to each lane's own dwords wherever it was, so a first-lane read outside a loop, or one without the v_cmp_eq that hands every lane its turn, sampled for lanes the program skipped (reported on the PR with the back edge of the fetched waterfall test replaced by s_nop). Now: - a compare counts only when it and the v_readfirstlane it reads are in one loop (each block reaches the other); - every descriptor read from the first lane needs each of its dwords compared that way, or translation stops with "a descriptor read from the first lane outside a waterfall loop". Two tests cover the missing back edge and the missing compare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
A waterfall loop whose descriptor dwords are VGPR phis stopped with "a descriptor read from the first lane of a phi" (294 programs of the title on Marvisak#307, all at if/else joins of two s_load_dwordx4 descriptors copied into VGPRs). An EXEC if/else leaves two phis per dword: the flow block's joins an arm's dwords with what lanes that skipped the arm held before (inputs, unrelated loads and arithmetic in the title), the join after the other arm picks per path. Only lanes that never read the descriptor bring those other values, so tracing every edge fails. Tracing (resource::track now takes the program's per-lane form): - per-lane phis of one block are traced on each edge into it that the lanes accessing the descriptor can take, from structure's lane conditions (new Structured::reach, the exits' conditions, and Bools::meet, a read-only satisfiability check); the trace starts from what holds in the access's block. Edges no such lane takes are None in the new Source::LanePhi { block, args }; - every per-lane write it follows (v_mov_b32 copies, v_cndmask_b32, global_load_dword*) must run in all those lanes: a guarded one fails with "a per-lane descriptor written where some lanes may keep the old one". On Marvisak#307 an else arm without its s_cbranch_execz traced as the second descriptor for every lane; - a loop header's phi fails with "a descriptor read from the first lane of a phi at a loop header", words defined after the join with "a descriptor partly joined by control flow"; without the per-lane form (structurisation failed) the join is refused. Lowering computes each traced edge's heap index at its predecessor's end (through lane_heap_index, so loads, per-lane loads, choices and nested joins work), joins them with a phi (0 on untaken edges) and makes the handle non-uniform. The waterfall compares need no change. Tests: the if/else of two loaded image descriptors, a join of a per-lane load and a v_cndmask choice, nested arms choosing a buffer descriptor with lanes that skip both and do not load (pruned only by the access's condition), a loop header phi, and an unskipped else arm. On Marvisak#307's head the three join programs fail with "...of a phi" and the unskipped arm is traced as one descriptor for all lanes. On an RTX 5070 and WARP, each lane reads its own arm's texture or buffer; the shaders pass dxil.dll 1.8.2502.11. Reversing the phi's inputs fails validation, flipping the heap index fails the GPU check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Measured
The 182 at |
|
I hit a wrong-output case on Replacing This can go at the bottom of #[test]
fn dead_descriptor_compares_do_not_turn_a_loop_into_a_waterfall() {
use crate::resource::tests::WATERFALL_JOINED_WAVE32;
let mut words = WATERFALL_JOINED_WAVE32.to_vec();
let save = words.iter().position(|&w| w == 0xBE95_3C15).unwrap();
words[save] = 0xBE95_037E; // s_mov_b32 s21, exec_lo
let shader = build(&words, false);
let results = sampled(&shader);
assert!(!results.is_empty());
for (label, red) in results {
assert_eq!(red, vec![1.0; 32], "{label}");
}
}I ran |
|
Corpus comparison on the local Xbox Series 1.0.2.1 files, using the same
|
|
I followed up on @ifBars's dead-compare case at
The DXIL and readback checks use synthetic inputs. Coverage of the previously measured shader corpus is still open. Incremental commit on Retested |
|
@ifBars reproduced, thank you. Your test fails the same way on Two fixes have been offered, both on top of
Neither translates it to all I am reviewing the two against each other now and will push one to this PR, with credit to its author and a form of your test that expects the refusal. Until then, treat Hand-assembled test programs only; no game data used. AI-assisted. |
|
Real-title follow-up for The test helpers needed the new structure parameter and heap-guard values; after that, the three waterfall GPU tests passed. Full serial workspace verification: 310 passed, 0 failed, 4 ignored. One preceding default parallel test run had a process access violation, so this result explicitly covers the serial run. In the native title run, Only aggregate counts and error classes shared. AI-assisted (Kimi Code). |
…n review The previous commit proves that a loop's compares select the lanes of the access and that its retry keeps exactly the lanes still waiting. Every failure of that proof was reported with one reason. They now say which part failed: - the access is in no single-block loop ending in s_cbranch_execnz; - the loop is nested in another or split over blocks; - the compares do not select the access's lanes; - the retry does not keep the lanes still waiting. Without the per-lane form the proof cannot run. Nothing is emitted then, and that failure is the one reported, as before. Tests, all hand-assembled: - the case ifBars reported on upstream PR Marvisak#566 (the compares never narrow EXEC), an access under a further mask, a retry that keeps other lanes than those waiting, a wave64 retry of one half: refused, each with its reason; - the waterfall LLVM writes for GFX10 and later (a v_cmpx_eq chain, the retry as todo & !EXEC, also folded into s_andn2_wrexec) is accepted in wave32 and wave64, and each lane samples its own texture on the GPU; - one loop per operand, the sampler's inside the resource's, is refused by name. The console gives each lane its own pair there; following the outer loop's reads into the inner block is left for later. Other per-lane work in a waterfall loop is still taken to run once for each lane; marked as a shortcut. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The fix is pushed: head is now What went in
@ifBars: your program is now refused with Why not r4tedx#3, @MichaelSmithAI. I had both fixes reviewed independently and ran the counterexamples. Two things decided it, both now tests on this branch:
Thank you for the work all the same; the dead-branch case in your second commit is covered here by the retry proof. What the fix costs. One shape that A rerun would settle what matters, @EduAzevedo @miniongk, if either of you has the time: the same Tested here at |
|
Tested offline against main
AI-assisted. |
|
@iurysf thank you, that is the comparison this PR needed, and "none newly failing" with 56 mesh and 8 vertex/pixel gained matches the two earlier counts. One question decides how to read it: which head of this branch did you run? It moved from
@fuzeofficlal thank you for retesting Nothing was run for this note. AI-assisted. |
…ops over them (port of upstream PR Marvisak#566, stacked on Marvisak#307) Squashed port of Marvisak#566 (head 6c63dea), which carries Marvisak#307 (AntoninMichelq) underneath: a3d3bc9 Shaders: trace descriptors chosen by s_cselect and s_cmov ffa6635 Shaders: lower waterfall loops over per-lane descriptors in one pass 077ec8b translate: count per-lane fetched descriptors 6285e19 Shaders: take the first lane's descriptor ... 6638098 Shaders: per-lane descriptors chosen by control flow (r4tedx) b1c8306 Shaders: prove EXEC selection before collapsing a waterfall (fuzeofficial) 6c63dea Shaders: name why a loop is no waterfall, and tests (r4tedx) Adapted to linux-bringup: conflicts with the raw-view tracing, the first-lane address tracing (the PR's `first_lane_source` is `first_lane_vgpr` here), unspill and the threading retry resolved; `resource::track` keeps its three-argument form (it structures the program itself) and the per-lane form is `resource::track_lanes`, so callers outside the crate (the shader lab) keep building; the PR's `lower_with` test helper is `lower_lanes`. (cherry picked from commit 6c63dea, PR Marvisak#566 and Marvisak#307) Co-authored-by: fuzeofficial <bochunran@gmail.com> Co-authored-by: AntoninMichelq <AntoninMichelq@users.noreply.github.com>
…ux-bringup added Follow-up to the Marvisak#566 port: waterfall_tests.rs builds only with cfg(all(test, windows)) and was missed by the Linux test build.
main moved under Marvisak#307 and this branch. One conflict, in the test module of emit/lower.rs: the imports take both sides' names (Marvisak#117's `half_shift` beside `Lowered`), and Marvisak#117's `scalar_bit_tests_lower` sits after this branch's waterfall tests. No code outside the test module was touched by hand. A merge rather than a rebase so Marvisak#307's commits keep their ids. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rol flow; waterfall loops proven) Marvisak#566 is stacked on Marvisak#307, which this tree holds as its first two commits (the tree's resource.rs was identical to ffa6635's). The merge so also brings Marvisak#307's last two commits, 077ec8b and 6285e19. Git found upstream main as the base, which sets Marvisak#307's own lines against themselves; each file was merged with ffa6635 as the base instead. - crates/victory-shader/src/resource.rs: Marvisak#566's, unchanged (the tree had no edits of its own there). - crates/victory-shader/src/emit/lower.rs: no conflict on that base. The tree's lowering is kept (Marvisak#307's waterfall arm of v_readfirstlane before the console-flow form, fetched_index through Marvisak#483's heap guard), with Marvisak#566's Source::LanePhi arms and tests. lane_heap_index joins the indices heap_index and fetched_index return, so each is already guarded. Marvisak#226's annotation test passes the per-lane form to track. - crates/victory-shader/src/structure.rs: both sides' additions kept: MAX_MEMO (Marvisak#288) with MAX_MEET, and in Structured the wave64 stack's execs, others and pairs with Marvisak#566's reach and paired_masks. paired_masks is filled last, since it takes the masks pairs reads. - crates/victory-shader/src/emit/mod.rs: translate keeps Marvisak#309's spill forwarding and Marvisak#223's target, structures first and passes the per-lane form to track as Marvisak#566 does. The threading retry of emit passes its own. The tests' helpers (Marvisak#223's, Marvisak#306's, Marvisak#459's, Marvisak#48's) pass it too. - apps/victory/src/translate.rs: Marvisak#566's arm (Source::LanePhi is no leaf); the tree's fix already counted Fetched as loaded, as 077ec8b does. - docs/architecture.md: no conflict on that base; Marvisak#566's text. - emit/image_tests.rs (Marvisak#160), emit/lane_read_loop_tests.rs (Marvisak#439), sgpr_spill.rs (Marvisak#309, Marvisak#320): track takes the per-lane form. Helpers that return the error keep the order of failures (resources, I/O, then structure). - emit/waterfall_tests.rs (new, Marvisak#566): lower::Parts gets the tree's target, console_cf and per_lane_only; the dispatch fills Marvisak#483's guard dwords. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The four tests of emit/waterfall_tests.rs each dispatch on the hardware adapter and on WARP. Started together from the test threads, the test binary sometimes died of an access violation (0xC0000005) before any of them finished: 7 of 24 runs of `cargo test -p victory-shader waterfall_tests` on the integration machine (RTX 5070; 6 of the first 12, 1 of 12 later, with less else running on the PC), 3 of 8 on WARP alone, 1 of 10 with the DXIL validator left out. With `--test-threads=1` they pass. They now take a lock around their dispatches, as Marvisak#433 does for the VALU tests: 0 of 36 runs died. Which call faults was not found (no debugger on the machine). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rol flow Marvisak#566 lowers a descriptor each lane holds by the path it took (Source::LanePhi) as a DXIL phi of the heap index of each edge. That is right in the per-lane form, where a lane takes its own edges. In the console flow of the wave64 stack (Marvisak#233, Marvisak#320, Marvisak#439) every lane runs every block and comes to the join by the edge the wave took, so the phi gave every lane that edge's descriptor, without an error. Found with Marvisak#566's joined-descriptor program plus a v_readlane_b32, which with the arms' branches asks for the console flow on every host: on the RTX 5070 all 32 lanes sampled the second texture, where lanes 0 to 15 hold the first. The module passed dxil.dll. The console flow now stops such a program with `a per-lane descriptor chosen by control flow in the console flow`, and emit keeps the per-lane form where that translates, as it does for whatever else the console flow cannot lower. New test (emit/waterfall_tests.rs): both refusals by name, then each lane's own texture on the hardware adapter. The tests' lock now also covers that test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nes) By MichaelSmithAI (commit author "swarm"), written against this tree at f61acfa. The wave64 stack carries the same change as 055aef9 (upstream Marvisak#439), where its owner reviewed it and ran it on both GPUs here. No textual conflict; its new test's call of resource::track takes Marvisak#566's per-lane argument (one line, in this merge). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main merged Marvisak#566, which gives `resource::track` a fourth argument (the structured program, for per-lane descriptor tracking). No textual conflict, but this branch's image test helper called it with three and the test target no longer built on main (reported by DeerSilver on the PR). The helper now structures the program first and passes it, as main's own tests do. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
116 commits, among them Marvisak#566 (which this tree carried), upstream's CI, the AMD form of v_cmp_lg, the SGPRs the hardware initializes, the Wine upload path and the stencil-ref feature. Conflicts and what was kept: - victory-gpu list.rs: both sides in CopyResource and CopyTextureRegion (the tree's skip of mixed packed copies, then main's upload of a title-written source); the tree's `prepare_footprint_upload` stays and its plain path takes main's `defer_fill`. - native.rs: main's `initialized_sgprs` and its test beside the tree's three-component thread id and its test. - emit/shader.rs: both feature flags (tiled resources, stencil ref). - emit/mod.rs: the tree's `harmonize_row_interp`, then main's centroid position under a conservative depth output; the tree's `constant_color` for every host. - emit/lower.rs: the tree's barycentric inputs with main's zero for an SGPR the hardware does not initialize; the tree's IsNaN compares with main's `olt | ogt` for v_cmp_lg in place of `fcmp one`; Marvisak#160's sample forms in place of main's list of sample names; one test helper for both (`lower_inputs`, with `lower_words` and main's two-argument `lowers` on top of it). - emit/valu_tests.rs, emit/waterfall_tests.rs: merged item by item. All of both sides' tests; main's shared `ONE_AT_A_TIME` replaces the tree's lock inside `run_cases`, which keeps the tree's guard entries; the tree's `run` in the waterfall tests is kept. Changes where the merge was clean but did not build: - emit/lower.rs: main's immediate-offset block in the plain sample arm is dropped (it reads `offset_word`, which Marvisak#160's forms replace; Marvisak#160 handles offsets before the arm). `Module::int_value` loses its only caller with it. - New tests of main's get Marvisak#223's `Target` argument of `emit` and the `target`, `console_cf` and `per_lane_only` fields of `Parts`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rol flow Main lowers a descriptor each lane holds by the path it took (Source::LanePhi, Marvisak#566) as a DXIL phi over the edges into the join. In the console flow every lane reaches the join by the edge the wave took, so the phi gave every lane that edge's descriptor, silently: the joined if/else program of the waterfall tests, lowered in the console flow, sampled the second texture in all 32 lanes where lanes 0-15 hold the first (RTX 5070; the module passes dxil.dll). The console flow now stops with its own reason there. A program that takes the console flow only for its lane reads keeps the per-lane form where that translates; one that needs it for the host's wave size stops with the reason. Found on the testers' branch, where Marvisak#566 and the console flow first met. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…at 055aef9) Brings the black-scene branch (6d7ead4: Marvisak#489, Marvisak#294, Marvisak#346, root UAVs as bounded one-view tables, VICTORY_ROOT_SRV_MB) up to the tester tree's update 4. No file conflicted. The tree's Marvisak#566 gives `resource::track` a fourth argument, the program as one lane runs it, and this branch's tests called it with three. Adapted, tests only: - emit/valu_tests.rs: the root UAV test structures the program first and passes it; the spill-table helper keeps `emit::translate`'s order (a program that cannot be structured is still traced and fails where it did before). - resource.rs: the spill-table descriptor test passes `lanes(&p)`, as its neighbours do. - victory-gpu draw.rs: the two root-view tests structure first. - emit/waterfall_tests.rs (the tree's): its `HostShader` gets this branch's `root_uavs` field. Run once each, one process at a time on the RTX 5070 and WARP: victory-shader --lib 210 passed, 1 ignored; victory-gpu --lib 95 passed, 1 ignored. `cargo build -p victory` builds. Not run in the title. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ne-704 at 56018e8) Brings the merge of upstream Marvisak#704 at fb8ea43 (raw views for unknown-stride reads; see 70eedad for how it was fitted to Marvisak#483's guard slot and this branch's root SRV and UAV tables) and the root SRV refresh test onto the branch that already holds the tester tree at 2b1a569. No file conflicted. Adapted, tests only, where the two sides meet: - the tree's Marvisak#566 gives `resource::track` a fourth argument: the Marvisak#704 side's test helpers (emit/mod.rs, victory-gpu raw_view_tests.rs) and the refresh test's program builder in draw.rs structure the program first and pass it; - emit/waterfall_tests.rs (the tree's) fills Marvisak#704's `stride_table` field. Run once each, one process at a time, on the RTX 5070 and WARP: victory-shader --lib 214 passed, 1 ignored; victory-gpu --lib 98 passed, 1 ignored. `cargo build -p victory` builds. Not run in the title. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n review The previous commit proves that a loop's compares select the lanes of the access and that its retry keeps exactly the lanes still waiting. Every failure of that proof was reported with one reason. They now say which part failed: - the access is in no single-block loop ending in s_cbranch_execnz; - the loop is nested in another or split over blocks; - the compares do not select the access's lanes; - the retry does not keep the lanes still waiting. Without the per-lane form the proof cannot run. Nothing is emitted then, and that failure is the one reported, as before. Tests, all hand-assembled: - the case ifBars reported on upstream PR #566 (the compares never narrow EXEC), an access under a further mask, a retry that keeps other lanes than those waiting, a wave64 retry of one half: refused, each with its reason; - the waterfall LLVM writes for GFX10 and later (a v_cmpx_eq chain, the retry as todo & !EXEC, also folded into s_andn2_wrexec) is accepted in wave32 and wave64, and each lane samples its own texture on the GPU; - one loop per operand, the sampler's inside the resource's, is refused by name. The console gives each lane its own pair there; following the outer loop's reads into the inner block is left for later. Other per-lane work in a waterfall loop is still taken to run once for each lane; marked as a shortcut. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Shaders: per-lane descriptors chosen by control flow (stacked on #307)
…loops Main's heap_handle now takes whether the index may differ between lanes (#566, waterfall loops over per-lane descriptors). The 64-bit atomic path builds its own heap handle, so it passes the same answer handle() does: per lane when the descriptor load belongs to a waterfall loop. translate --validate on shaders.rpf against main 6889aa9: VS/PS 12155 -> 12673, CS 1417 -> 1419; no 64-bit image atomic refusals or "Flags must match usage" errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n review The previous commit proves that a loop's compares select the lanes of the access and that its retry keeps exactly the lanes still waiting. Every failure of that proof was reported with one reason. They now say which part failed: - the access is in no single-block loop ending in s_cbranch_execnz; - the loop is nested in another or split over blocks; - the compares do not select the access's lanes; - the retry does not keep the lanes still waiting. Without the per-lane form the proof cannot run. Nothing is emitted then, and that failure is the one reported, as before. Tests, all hand-assembled: - the case ifBars reported on upstream PR Marvisak#566 (the compares never narrow EXEC), an access under a further mask, a retry that keeps other lanes than those waiting, a wave64 retry of one half: refused, each with its reason; - the waterfall LLVM writes for GFX10 and later (a v_cmpx_eq chain, the retry as todo & !EXEC, also folded into s_andn2_wrexec) is accepted in wave32 and wave64, and each lane samples its own texture on the GPU; - one loop per operand, the sampler's inside the resource's, is refused by name. The console gives each lane its own pair there; following the outer loop's reads into the inner block is left for later. Other per-lane work in a waterfall loop is still taken to run once for each lane; marked as a shortcut. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Shaders: per-lane descriptors chosen by control flow (stacked on Marvisak#307)
docs: describe the project without naming a specific title
…aterfall changes 41 upstream pull requests merged into local/essai-3d. Conflicts resolved: - kept ours: descriptor heap sizes and capped samplers, dropped-table handling, f16 inline constants in both halves, compare NaN handling (with upstream's ordered "lg" as olt|ogt for the AMD driver), sample offsets (sample_form), the dispatch thread/twin code; - took upstream: capture formats (unorm16, 89), packed-operand int vs float inline constants, initialized SGPRs (combined with ours); - combined: descriptor heap publication, copy uploads with skipped mips. Not merged: Marvisak#566 per-lane phi and the waterfall loop (ffe310e), which rewrite the same per-lane descriptor tracking as ours. Tests: same failures as before the merge (wait cut, xmem x5, wave32 ballot, repository policy). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacked on #307 (its head
6285e19). Three commits on top are the change:6638098(per-lane descriptors chosen by control flow),b1c8306(by @fuzeofficlal: prove a waterfall loop before collapsing it) and6c63dea(a reason per failed proof, and tests). If #307 is merged first this rebases to those three; its author is welcome to take them into #307 instead.Merged with
main42361b0(heada7e60cf, 2026-11-24).mainmoved and #307 itself now conflicts with it, so this branch tookmainin as a merge commit, which keeps #307's commits and the three above at their ids. The one conflict was in the test module ofemit/lower.rs(imports, and #117's test beside this branch's); no code outside tests was edited by hand.cargo test -p victory-shaderata7e60cf: 107 passed, 1 ignored, on the RTX 5070;cargo check --workspace --all-targetsis clean.What
With #307,
a descriptor neither loaded nor builtgoes from 298 programs to 3 over the title's shaders, but 294 of them (259 mesh, 35 vertex) then stop ata descriptor read from the first lane of a phi(measured by EduAzevedo on #307). This PR handles that case.What the programs look like, from EduAzevedo's answers on #307 (counts and shapes only): every phi is at an if/else join, none at a loop header; chains are 2 phis deep in 277 programs, 5 in 10 and 7 in 7; every dword traces to one of two
s_load_dwordx4descriptors copied into VGPRs; the descriptor is 4 dwords (a buffer) and all 4 are phis of one block; other edges of the chains reach unrelated values (buffer_load_dwordx3, input VGPRs, arithmetic).Those unrelated values are the crux. An EXEC if/else leaves two phis per dword: one joins an arm's dwords with what lanes that skipped the arm held before, the other picks per path after the other arm. Only lanes that never read the descriptor bring the unrelated values, so tracing every edge cannot work; edges have to be dropped by what the accessing lanes can actually take.
resource.rs).resource::tracknow takes the program's per-lane form (Structured). Per-lane phis of one block are traced on each edge the lanes that access the descriptor can take, starting from what holds in the access's block (newStructured::reach, andBools::meet, a read-only satisfiability check). Edges no such lane takes areNonein the newSource::LanePhi { block, args }.v_mov_b32,v_cndmask_b32,global_load_dword*) must run in all those lanes; otherwisea per-lane descriptor written where some lanes may keep the old one. On Shaders: lower waterfall loops over per-lane descriptors (and s_cselect-chosen descriptors) #307's head an else arm without itss_cbranch_execzis traced as the second descriptor for every lane, with no error; a test covers it.emit/lower.rs). Each traced edge's heap index is computed at its predecessor's end throughlane_heap_index(so loads, per-lane loads, choices and nested joins work), joined with a DXIL phi (0 on untaken edges); the handle is non-uniform. The existing SGPRSource::Philowering is unchanged.Still refused, each with its reason: a phi at a loop header (
... of a phi at a loop header), some dwords joined and others defined at or after the join (a descriptor partly joined by control flow), joins in several blocks, nesting past the join limit, and programs whose structurisation failed (..., without the lanes' paths).A wrong-output defect found in review, fixed in
b1c8306and6c63deaTaking the first lane's descriptor as each lane's own is only right in a waterfall loop. The matcher this PR inherited from #307 checked that equality compares of the first lane's dwords exist in the loop, not that they select the lanes of the access or that the loop retries the others. Two reviewers showed programs it mistranslated without an error:
6638098gave lanes 16 to 31 their own. Reproduced here on a hardware adapter.b1c8306replaces the match with a proof on the per-lane masks: at each access the EXEC mask must be exactly the lanes whose descriptor equals the first lane's, on every dword, and the back edge must keep exactly the lanes that were waiting and did not perform the access. Wave64 uses both halves.6c63deagives each failure its own reason:a descriptor read from the first lane outside a waterfall loopa waterfall loop whose compares do not select the access's lanesexec_hioverwrittena waterfall loop whose retry does not keep the lanes still waitinga waterfall loop nested in another or split over blocksBoth of those programs are now refused. Neither is translated to what the console does (one descriptor for every lane, outside a waterfall); that is separate work.
An alternative fix was offered as r4tedx#3. It was not taken: an independent review found it still accepts a loop whose retry drops the waiting lanes (now the test
a_retry_that_keeps_other_lanes_than_those_waiting_is_no_waterfall), and it refuses the waterfall LLVM's AMDGPU backend writes for GFX10 and later (av_cmpx_eqchain with the retry astodo & !EXEC), which this PR accepts and tests on the GPU.Known limits
6638098accepted them. An image whose resource and sampler are both per lane, with one loop per operand and the sampler's loop inside the resource's, stops ata waterfall loop nested in another or split over blocks. In review that shape gave the right output on6638098, so this is a step back in coverage made for the proof; following the outer loop's reads into the inner block is left for a follow-up. Whether the title has such programs is not known (see the rerun asked for below).shortcut:in the code; compilers put nothing but the reads, the compares and the access there.Measured on the title's shaders (by testers, at
6638098, before the waterfall fix)victory translate --jobs 8 --listover the retail shaders, #307 at6285e19against6638098, all 26,148 programs:a descriptor read from the first lane of a phi: 294 to 0 (EduAzevedo, confirmed by miniongk).a scalar memory read as data, 38 ata descriptor read from the first lane of computed VGPRs, 8 ata descriptor partly joined by control flow, 2 ata lane mask read as data.6285e19stopped translating.shader does not translatefell from 32 to 29 with this PR, with no device removal; the run still ended in a separate null-write failure this PR does not address (miniongk).Rerun with the waterfall proof (slint6614-dev, comment;
victory translate --validate --pipelinesover the full retail shader pack, pipelines created on an AMD RX 9070, againstmain1f858b0):a descriptor neither loaded nor builtmaina scalar memory read as data573 to 740 (so 167 of them),a descriptor read from the first lane of computed VGPRs38,a waterfall loop whose compares do not select the access's lanes15,a descriptor partly joined by control flow8.Tested
Windows 11, NVIDIA RTX 5070 and WARP, hand-assembled programs only:
v_cndmask_b32choice; nested arms choosing a 4-dword buffer descriptor where lanes that skip both arms keep unrelated values and do not load; a loop-header phi (refused); an else arm without its skip branch (refused).v_cmpx_eqwaterfall accepted in wave32 and wave64, plain and folded intos_andn2_wrexec.v_cmpx_eqwaterfall; the shaders passdxil.dll1.8.2502.11.cargo test --workspaceat6c63dea: 293 passed, 4 ignored.cargo clippy -p victory-shader --all-targets: no warnings.cargo xtask policy: ok.Not checked: wave64 waterfalls were proven by tracking only, not dispatched on a 64-lane GPU in this round. Nothing was checked with the D3D12 debug layer (not installed here).
The title was not used in these tests; the counts above are the named testers'. AI-assisted.
🤖 Generated with Claude Code