Repository navigation
Shaders: follow lane writes and scalar steps in whole-wave sections - #308
AntoninMichelq wants to merge 3 commits into
Conversation
Values a whole-wave section leaves were unknown when the section used a
step the simulation did not model ("a whole-wave section step the
simulation does not follow"). The simulation now also follows:
- v_writelane_b32 (a constant or known-uniform lane takes the scalar,
whatever EXEC holds): the exclusive prefix sum that carries lane 15 into
lane 16 (and 31/47 into 32/48 on Wave64) with v_readlane/v_writelane.
- scalar ALU on uniforms: s_mov_b32 copies, and s_add/min/max/and/or/xor
combining two v_readlane results (the halves of a Wave64 reduction read
at lanes 0 and 32); s_mov copies of a mask derived from the saved EXEC.
- v_readlane_b32 with an SGPR lane the simulation knows, lane bits masked
to the wave size, and v_readfirstlane_b32 (the first lane EXEC holds).
A lane's own value of a VGPR from before the section moved to another
lane (DPP, v_permlanex16, v_readlane) was still taken as the reading
lane's own value; it is now unknown.
The lowering computes a value the simulation found no shape for, when the
steps that make it read no other lane (scalar code and loads scheduled
into the section, lane-local vector code without DPP, permutes or lane
reads/writes, and no EXEC operand), as it would outside a section: the
lanes active on entry compute it as under their own EXEC.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
|
Tested PR #308 at head
Behavior covered: Checks scalar carry propagation inside whole-wave sections and lane-write prefix behavior in the wave lowering path. |
…llow lane writes and scalar steps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged onto Checked with CI's steps (both clippy runs with |
Since 25b0f88 on main the helper takes the program's rsrc2; the whole-wave scalar test passed only the words (reported on upstream PR 308). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
|
@AntoninMichelq rechecked |
|
@AntoninMichelq the all-lanes case is still right on This one panics. Wave32: llvm-mc gfx1030 matches those words. VIctory/crates/victory-shader/src/emit/wave.rs Lines 383 to 392 in 6b30384 Wave32 uses only EXEC bits 31-0; the upper half is ignored. With exec_lo clear, EXEC is zero, and AI-assisted; llvm-mc gfx1030 and a Linux shader-lib probe, run on this machine. |
Where a fork-only change duplicates upstream's own version of a feature, upstream's is kept and the fork's dropped: - victory-shader is upstream's crate with the fork-only merges replayed onto it oldest first; those that do not apply onto upstream are dropped (37 of 63: among them Marvisak#704/raw views, gather4_l, the lane-mask and Marvisak#308 ports, Marvisak#947, Marvisak#1022, Marvisak#1112, Marvisak#1090, Marvisak#1182). Marvisak#284 (legacy fused madds) and Marvisak#98 (permlane16 in whole-wave sections) are dropped too: the first disagrees with upstream's hardware-checked model, the second refused 46 programs upstream translates. - translate: upstream's --cache replaces Marvisak#254's write-cache and work queue; Marvisak#378, Marvisak#517, Marvisak#673 and the victory.toml console are re-applied. - victory-gpu: upstream's stride table, page table and heap views replace the fork's Marvisak#704/stride-table wiring; fork-only fixes re-applied on top. Package (shaders.rpf, translate --validate --list, counts): vertex/pixel emitted 12559 -> 14295 of 14337, compute 2359 -> 2628 validated, mesh 2730 -> 2811 validated. Tests: the failures left (rect fourth corner, two stride tests, row order, gather4 at a level, memory table, dynamic heap slots) fail on upstream main as well on this host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
Requested by 4nto · project thread
Summary
The whole-wave section simulation now follows more of the steps the console compiler uses in wave reductions and prefix sums. Lane-local code that the compiler schedules into a section is lowered as it would be outside one. Before, these programs failed with "a whole-wave section step the simulation does not follow".
What changed
emit/wave.rs: the simulation now also follows:v_writelane_b32with a constant or known-uniform lane. This covers the exclusive prefix sum that carries lane 15 into lane 16 (and 31/47 into 32/48 on Wave64).s_mov_b32copies;s_add/min/max/and/or/xorcombining twov_readlaneresults (the two halves of a Wave64 reduction, read at lanes 0 and 32);s_movcopies of a mask derived from the saved EXEC.v_readlane_b32with an SGPR lane the simulation knows (lane bits masked to the wave size), andv_readfirstlane_b32.A lane's own value from before the section, once moved to another lane by DPP,
v_permlanex16orv_readlane, is now unknown. Before, it was wrongly taken as the reading lane's own value.emit/lower.rs: some values have no shape in the simulation but are computed only by steps that read no other lane: scalar code and loads, or vector code without DPP, permutes, lane reads/writes or EXEC operands. The lanes active on entry now compute those values under their own EXEC.Adapted to main: main does not model
v_permlane16(#98 adds it), so only thev_permlanex16arm is touched. No dependency on other open PRs.How it was tested
cargo test -p victory-shaderon Linux: all tests pass. New tests:emit::wave::tests::writelane_carries_a_row_total_into_an_exclusive_prefixemit::wave::tests::wave64_halves_combine_in_a_scalar_addemit::wave::tests::another_lanes_own_value_is_not_the_lanes_ownemit::lower::tests::scalar_code_inside_a_whole_wave_section_is_loweredAll test programs were assembled with llvm-mc for gfx1030.
cargo check -p victory-shader --target x86_64-pc-windows-msvcpasses.On the game's 26,148 programs, "a whole-wave section step the simulation does not follow" went from 51 to 14. This was measured with
victory translateon the integration stack.Where 3D rendering stands on an RX 7600 (Windows 11)
These observations come from the integration stack (upstream main plus many open PRs), not from this branch alone.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66