Skip to content

Shaders: wave64 compute on 32-lane hosts, in halves and in the console flow (rebase of #233) - #1929

Closed
slatefield wants to merge 12 commits into
Marvisak:mainfrom
slatefield:up-233-rebase
Closed

slatefield wants to merge 12 commits into
Marvisak:mainfrom
slatefield:up-233-rebase

Conversation

@slatefield

@slatefield slatefield commented Nov 25, 2026 •

Copy link
Copy Markdown

Closed: r4tedx updated #233 itself onto main 940d32f (head 7147671), taking the host_shader target point from this rebase and keeping one PR open so the testers' reports stay in one place, which is the right shape. The validation done here that was useful stays in #233's thread: upipibi's RTX 3070 run of the split_tests (13 pass; the two whole-mask-read cases are still refused on 32-lane hosts, which is a real limitation of the split form), and the wall of review about the console flow's group barriers inside branches and loops.

Nothing else is open from this rebase. The branch slatefield:up-233-rebase stays on the fork for reference.

r4tedx and others added 11 commits November 25, 2026 01:03
A compute shader that reads other lanes declares the console's wave
size. NVIDIA runs waves of 32 lanes only (D3D12 reports 32..32), so a
console wave64 program of that kind was refused at pipeline creation
and its dispatches were dropped without saying why.

The host's wave range (D3D12 options 1) now goes into translation as
`emit::Target`. A shader that needs a wave size the host does not run
stops there with the reason, the shader cache keys entries by the range,
and the run logs the range once with a warning when 64-lane waves are
missing. `victory translate --host-lanes 32-32` counts these shaders
without a GPU.

This is the first step towards running these programs as two 32-lane
waves on such hosts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
How one console wave64 runs as two 32-lane host waves under our
per-lane structurisation, what has to cross halves, why exchanges need
uniform regions, how to test on a machine with both GPU kinds, and the
order of the remaining steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`emit::host::Host::on(name)` and `VICTORY_ADAPTER` choose a hardware
adapter by part of its description, and `adapters()` lists them, so a
machine with an AMD and an NVIDIA GPU can run a test on each: the
native wave64 form as the reference on the one with 64-lane waves, the
32-lane form on the other. A new test checks on every adapter that a
wave64 program reading other lanes translates exactly when the adapter
runs 64-lane waves, and that the adapter then takes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a host without 64-lane waves (NVIDIA), a console wave64 compute
program whose lanes read only their own 32-lane half (DPP, ds_swizzle)
now declares WaveSize(32) instead of failing to translate. It must
read no mask whole, test no bit of a mask held as a number, have no
whole-wave sections and use no LDS. Every other wave64 program that
depends on the lane layout still stops with the reason from the
previous step. Mask ballots, wave reductions and lane-bit tests refuse
the split form as a safety net.

New GPU tests run hand-assembled programs on every hardware adapter
and check each lane against the console's layout. On an RTX 5070 the
split form is exact for 1-D groups of 32, 64 and 128 threads and for
3-D groups up to 8x8x4. A Radeon iGPU runs the same programs natively
as the reference, and a read across halves (v_readlane 40) still needs
64-lane waves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A console wave64 program that reads masks whole or lanes of the other
half now runs on a host without 64-lane waves when its group is one
console wave (64 threads or fewer, no LDS). It runs as the console
does ("console flow"):

- `structure::structure_console` never resolves mask joins from what
  the lanes arriving know (every lane arrives); `Structured::execs`
  gives each vector instruction's EXEC bit.
- Vector instructions are guarded by EXEC. Branches are the console's
  s_cbranch_*: EXEC, VCC and mask-operation SCC tests are the console
  wave's, from both halves' ballots exchanged through group-shared
  memory between group barriers, which every thread reaches since both
  halves branch alike.
- Masks read whole are the exchanged ballots. v_readlane and
  v_readfirstlane read the owning half; v_writelane, v_mbcnt and mask
  bit tests use the console lane.

The per-lane form is tried first; a program that needs the console
flow is lowered again from the console structure.

GPU tests on an RTX 5070 are exact against the console: s_bcnt1 over
both halves (64, 48 and 32 threads), v_readlane 40, an exchange inside
a branch only the lower half takes, and a loop the halves leave at
different iterations with a lane read in each. The last one shows that
the per-lane form, which hosts with 64-lane waves get, is wrong for it
(on a Radeon iGPU): noted in docs/wave64-on-wave32.md, not changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A wave64 program split over two 32-lane waves took the DPP row index
from the host lane, so the upper half (console rows 2 and 3) read
row_mask bits 0 and 1. The row now comes from the console lane there.
New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only,
exact on an RTX 5070 (split) and a Radeon iGPU (native).

Found in review against Marvisak#189 and Marvisak#192, which both get this right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_readfirstlane reads the console wave's first lane. A wave64 program
with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane
waves, where the upper half read its own first lane: with all 64 lanes
active, lanes 32 to 63 got lane 32's value where the console gives
lane 0's (measured on an RTX 5070).

Such programs now take the console flow, which reads the first lane in
EXEC of the whole console wave (groups of at most 64 threads, no LDS),
or stop with the reason as they did before the split existed.

New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the
same program against Marvisak#192, which has the same result on both adapters.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…alar

The comment on the console flow's SCC said both write the old EXEC to
their scalar destination. Only saveexec does; wrexec writes the new EXEC
to both, so either write names the mask SCC tests.

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>
…-lane waves

The GPU tests walk every hardware adapter and expect each to take the
console's wave-size-dependent programs in one form or the other. An
integrated GPU with narrower waves (an Intel UHD reporting 16-16 was
reported on Marvisak#439) runs none of them: the translator refuses, correctly,
and 30 tests failed there for expecting a pipeline. The list now leaves
such an adapter out, by its wave range, as it already left out the
software renderer by name. An adapter no SM 6.6 device can be made on
stays listed, for its user to skip as before.

Checked on an RTX 5070 (32-32) and a Radeon iGPU (32-64): both still
listed, each_adapter_gets_what_it_runs and two split tests exact. Not
checked on a 16-lane adapter (none here).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e adapter list together

main's new create() refuses a software default adapter for the
hardware-only checks; the branch's VICTORY_ADAPTER selection stays in
front of that, so an explicitly named adapter is still taken and the
refusal only applies to the default.
@slatefield

Copy link
Copy Markdown
Author

Branch updated for main's new commit 42363ab ("hardware-only shader checks skip on a machine without a GPU"), which touched the same Host::new adapter selection. One merge commit on top, nothing else changed: main's refusal of a software default adapter stays, and the branch's VICTORY_ADAPTER name selection goes in front of it, so an explicitly named adapter is still taken and the refusal only applies to the default path. Windows-target clippy with --all-targets --all-features clean, Linux victory-shader --lib 146 passed, 2 ignored.

The other three rebases (#1922, #1923, #1924) already merge cleanly onto 42363ab.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This pull request does not merge cleanly into main. Conflicting files: apps/victory/src/translate.rs, crates/victory-gpu/src/shader_cache.rs, crates/victory-shader/src/emit/bvh_tests.rs, crates/victory-shader/src/emit/host.rs, crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/memory_tests.rs and 6 more.

It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

@0xkn0wh3r3

Copy link
Copy Markdown

A question before merge, about the console flow's group barriers on NVIDIA.

The console flow places group barriers (exchange, lower.rs 9724-9756 in this PR) inside the program's own branches and loops, through console_branch / any_lane (9503, 9578, 9647) and mask_dword (1847). That is safe as long as both host waves always take the same edges, which the design gets from exchanged ballots and SCC bits. But scc_bit (9617) accepts any scalar Val::Bit as uniform, and a scalar memory load runs once per host wave, so a value that changes during the dispatch (a flag or counter another group writes) could send the two halves different ways, with one half waiting at a barrier the other never reaches.

For reference: a fork with a similar "two host waves" form that put barriers in branches and loops (Zettrox/ztrx, commit e9765a7) lost the device on an RTX 4070 in 4 of 4 runs when the title dispatched ptfx_CS_lightAtlas_Sprite and ptfx_CS_lightAtlas_Trail, and turned that form off by default. I have not checked whether those two programs take this PR's console flow.

Could the 10 split_tests GPU tests (listed as not checked) be run on an NVIDIA card, and a title run go through those two particle programs, before this is merged?

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

The NVIDIA run asked for above. Ran on Windows 11 with an RTX 3070 (Ampere, 32-lane waves, driver 616.56), debug build, at b9b6dab, cargo test -p victory-shader --locked: 256 passed, 5 failed, 3 ignored.

  • 3 of the failures are Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744's NVIDIA failures on main (the two stride_tests heap-buffer reads and gathers_at_a_level_match_the_hardware).
  • 2 are this PR's split_tests. On this 32-lane host the translator refuses both programs instead of splitting them:
    • first_lane_reads_are_the_console_waves: DPP and v_readfirstlane: GFX10 code at 0x34: a lane mask read whole in a wave64 program split in halves is not supported (split_tests.rs:216)
    • masks_read_whole_count_both_halves: s_bcnt1 of lanes below 40: GFX10 code at 0x30: a lane mask read whole in a wave64 program split in halves is not supported (split_tests.rs:216)
  • The other 13 new split_tests / wave-size tests pass, among them lane_reads_cross_halves, exchanges_inside_a_branch_one_half_skips, loops_run_while_any_lane_of_the_console_wave_does, three_dimensional_groups_keep_the_consoles_lanes and each_adapter_gets_what_it_runs.

So on a host without 64-lane waves, the whole-mask reads (a v_readfirstlane after DPP, s_bcnt1 of the exec mask) still hit that refusal. A 64-lane host never splits, so it wouldn't show this. Not run: a title.

AI-assisted (Claude Code). Synthetic tests only.

@r4tedx

r4tedx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@slatefield, thank you for doing this; it saved real time. #233 itself is now updated with main 940d32f merged in: head 7147671 on shader/wave64-console-flow (with #223's plumbing at 02b955f under it). I used this PR as the reference for the conflicts and adopted your host_shader target point for the warm cache path (it now asks the run's own host range, the same function the runtime uses). The one place I departed is the order of the split-form refusal and the console ballot in mask_dword; the details and the three fixes on top are in the note on #233.

Since the stack is updated by merge commits rather than rebases (testers quote its hashes), the trees differ in history but should be close in content: git diff b9b6dab 7147671 -- crates/ shows what is mine. Keeping one PR open for #233 would keep testers' reports in one place, so I would suggest closing this one if the diff looks right to you, but that is your call.

AI-assisted (Claude Code).

@slatefield slatefield closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants