Skip to content

Shaders: groups of several console wave64s run in the console flow on 32-lane hosts (pair meetings) - #3683

Draft
neonbyte1 wants to merge 85 commits into
Marvisak:mainfrom
neonbyte1:pr/pair-meetings
Draft

neonbyte1 wants to merge 85 commits into
Marvisak:mainfrom
neonbyte1:pr/pair-meetings

Conversation

@neonbyte1

Copy link
Copy Markdown

Draft, stacked on #439 (e2d3cfd). Only the last commit is new; please review that one. I'll rebase once #439 lands.

Problem

On a host without 64-lane waves (NVIDIA), #439's console flow runs a console wave64 as two 32-lane host waves ("halves"). The halves meet at group barriers to exchange lane masks and data. A thread group holding several console waves is refused ("console wave64 lanes in a group of more than 64 threads on a host without 64-lane waves"): its console waves branch and loop differently, so no group barrier is reached by every thread. On the title's shader pack that refusal stops 44 compute programs on a 32-lane host. Among them are 19 tiled cascade and hair shadow programs, and 5 stages of the ray-tracing structure builder.

Change: pair meetings (emit/lower/pairs.rs)

The two halves of each console wave meet on their own, without a group barrier:

  • The meeting. Each console wave has an LDS counter. One lane of each half adds 1. Each half then reads the counter until it reaches the next even number. There is a group-shared fence before the count and after the wait.
  • What goes through meetings. Exchanges of masks read as data and of lane values (v_readlane, v_readfirstlane, v_mbcnt, s_bcnt1 of ballots), wave-wide branch decisions (execz/vccz/scc), and the order of the console wave's own LDS accesses (a meeting before each).
  • Exchange buffers. Two buffers of two dwords per console wave, alternating by meeting parity.
  • Title barriers. The title's s_barrier stays a group barrier. A program is refused unless every block holding one runs exactly once on every path (in no cycle, and post-dominating the entry). That keeps every barrier call in group-uniform control flow.
  • 2-D groups. A host need not give each host wave an aligned run of flat ids. So each host wave takes the next 32 console thread ids from an LDS ticket in the entry block, and each host wave holds exactly one half.
  • Safety net. A module where a value is used before the meeting that makes it is refused, not emitted (bitcode::defs_dominate_uses).
  • Refused as before: groups that aren't a whole number of console waves, and groups whose LDS leaves no room for the state (5 dwords per console wave, plus 1).
  • Switch. On by default. VICTORY_BVH_HALVES=0 (or translate --no-pair-meetings) turns it off, and the shader cache keys the two apart. Only programs that were refused before change (census below).

Why it's exact, and its limits

  • Same blocks, same order. In the console flow every branch decision is the console wave's own, exchanged, so both halves run the same blocks in the same order. When a half counts in for its k-th meeting, the counter reads 2k−2 or 2k−1, and it reaches 2k only once both halves have counted. What either half wrote to LDS before a meeting, the other reads after it.
  • Buffers aren't overwritten early. A half can't rewrite an exchange buffer before the meeting after next, and that meeting needs the other half to be past its reads.
  • Console waves are ordered only at the title's s_barrier, as on the console.
  • Poll limit (2^20). Each wait gives up after 2^20 polls, so a wait can never hang the GPU. In a correct run the limit must never trigger: the other half is at most one meeting step behind. Both halves leave a loop at LOOP_LIMIT on the same iteration, because the loop decision is exchanged [inference from the construction]. If it ever triggered, the results would be inexact. The test builder_meetings_end_far_below_the_poll_limit runs with the limit cut to 2^10 and is still exact. That bounds the waits; it doesn't instrument a give-up.
  • Forward progress. The wait is a spin on group-shared memory between two waves of one group. D3D12 doesn't promise forward progress there. It relies on the waves of a group being scheduled independently, which they are on the NVIDIA cards this is for [inference; measured only on an RTX 5090]. The 2^20 limit bounds the cost if they weren't.
  • UAV memory. Meetings fence group-shared memory only, like Shaders: one console wave sharing LDS runs in the console flow on 32-lane hosts #439's exchange and LDS barriers. A UAV or title-memory write in one half isn't ordered before a read in the other half of the same console wave. That is the same as Shaders: one console wave sharing LDS runs in the console flow on 32-lane hosts #439's console flow today; see the note on e2d3cfd below.

Measured

Offline census. Whole shader pack, victory translate <pack> --list --validate --host-lanes 32-32, this branch against #439 e2d3cfd:

  • Compute emitted goes from 2,593 to 2,619 of 2,682; validated from 1,858 to 1,884.
  • The 26 gained programs were all refused for the group size before, and all 26 validate. 0 lost.
  • The 25,590 programs emitted by both are byte-identical, and with --no-pair-meetings every program's outcome matches the base.
  • 18 more programs get past the group-size check but stay refused for other reasons: 12 have a title barrier not met once, 2 have a value used before its meeting, 2 have an exchange outside the block being lowered, and 2 have no LDS room.

Builder. On #439's current head the five builder stages that this PR otherwise translates are still refused, by e2d3cfd's title-memory limit (question for #439 below). With that limit lifted locally, the builder dll gives 52 of 52 stages emitted and validated for a 32-lane host, against 47 of 52 without this change.

In the title, on our integration tree, not on this branch. Setup: RTX 5090 (32-lane waves), Linux, Wine 11 with GE-Proton11-14's vkd3d-proton. The tree is fork main, which has an older #439 without e2d3cfd, #2118, and this change on. Results:

  • The builder runs about 348 dispatches a frame instead of being held back.
  • Dropped draws went from 375 to 34 a frame.
  • The captured frames show ray-traced shadows and lighting.
  • 0 crashes.

Those runs also contain other unmerged changes, so they show that the mechanism holds up in the title; they don't measure this PR alone.

Tests

In emit::pair_meeting_tests (GPU tests skip unless the hardware adapter runs 32-lane waves only):

  • several_console_waves_translate_with_pair_meetings (CPU). Without pair meetings a 256-thread group is refused, as before. With them it translates, unless the program's LDS fills 32 KiB. A 32..64 target gives identical output either way. Fails on Shaders: one console wave sharing LDS runs in the console flow on 32-lane hosts #439 (refused).
  • a_lane_read_in_a_loop_each_console_wave_leaves_on_its_own (GPU). Hand-written GFX10, no title code. Groups of four console waves ([256,1] at lanes 5 and 40, [16,16], [8,16], [8,32]) run a loop each console wave leaves after a different count, with v_readlane across the halves inside it. Every lane is checked word for word against a CPU reference.
  • builder_programs_equal_the_console and builder_meetings_end_far_below_the_poll_limit (GPU). The title's five builder stages, loaded from the local disk (VICTORY_BVH_PROGRAMS, a directory of <hash>.dxbc files, never committed). They're compared against CPU references for a block scan, a digit histogram, and a block sort and scatter. Without the variable these tests skip; on Shaders: one console wave sharing LDS runs in the console flow on 32-lane hosts #439's current head they also skip, with the title-memory reason.
  • split_tests, select_tests and each_adapter_gets_what_it_runs now expect groups of whole console waves to translate. A 96-thread group is still refused.

Results on RTX 5090, Wine with vkd3d-proton:

Not tested

  • This branch in the title (only our integration tree).
  • Native Windows, WARP, AMD or Intel adapters. The GPU tests only ran on an RTX 5090 under Wine.
  • The 26 newly translating title programs dispatched one by one. They're only covered through the same operation classes in the synthetic test.
  • A UAV write in one half read by the other: not ordered, and not tested.
  • A run where the 2^20 poll limit triggers.
  • Shaders: console flow for groups of several console waves on 32-lane hosts #2214's reworked version (not up yet).

Overlap

Credit: the idea of half-wave pair meetings comes from trustno1-coder/VIctory-NVIDIA (fork PR #12; with_pair_meetings, Lower::meet, exchange_first; 2-D relabelling after wave_base, Vice-Tay c125c0c). It's re-implemented here on #439's console flow. That fork's FIRSTLANE_OWN shortcut (the host wave's own first lane taken as the console wave's) is not used; values are exchanged instead.

AI-assisted (Claude); measured on my machine, no game data shared.

r4tedx and others added 30 commits November 24, 2026 11:20
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>
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>
`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>
…the console flow

On the console v_readlane and v_writelane ignore EXEC, and a wave runs a
loop while any of its lanes does. The per-lane form runs branches and
loops per lane, so a lane that left a loop or skipped a branch is not
there to be read or written, and never sees the scalars set inside
(Marvisak#225):

- a loop lane t runs t times, reading lane L in each iteration: 12 of
  32 lanes wrong in waves of 32 (RTX 5070, Radeon iGPU), 24 of 64 in
  waves of 64 (Radeon);
- v_writelane to lane 40 inside a branch only lanes below 20 take: lane
  40 was never written.

A compute program with v_readlane or v_writelane, a branch that is not
uniform, no ds_(b)permute and no whole-wave sections now runs in the
console flow on every host. Where the host runs the console's wave
size, one host wave is the console wave: ballots are the wave's own and
nothing is exchanged, so any group size and LDS are fine. A program the
console flow cannot lower keeps the per-lane form
(`Parts::per_lane_only`), so nothing that translated before is refused.

Both cases are now exact on an RTX 5070 (wave32 natively, wave64 in two
halves) and on a Radeon iGPU (both natively).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The loop form compilers emit keeps the lanes that are done in an exit
mask that starts as 0 (s_mov_b64 s[2:3], 0; in the loop s_or_b64
s[2:3], vcc, s[2:3] and s_andn2_b64 exec, exec, s[2:3]). In the console
flow every mask join is a phi, and its incoming values had to be masks
derived from EXEC or a VALU result, so such a loop stopped with "a
lane-mask join of an untracked mask".

`Structured::others` gives the lane's bit of the other values read as
masks (constants, uniform selects, opaque ones), and the console flow's
mask joins take them. The per-lane form is unchanged.

New test: a loop in that form with a lane read in every iteration and
the exit mask counted afterwards. It was refused on an RTX 5070 before
and is exact there (in two halves) and on a Radeon iGPU now.

Found through the test report on Marvisak#233 that tried Marvisak#269's programs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Drivers create pipelines from some modules the DXIL validator refuses
(D3D12 checks only the container hash we write). The hand-assembled
split and console-flow programs now go through dxil.dll's validator
before pipeline creation, where one is installed. All of them pass.

Prompted by a report on Marvisak#233 of pipelines created from modules that
fail validation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On the console one wave shares LDS without s_barrier, because it runs
an instruction in all 64 lanes before the next. A wave64 program of one
console wave per group that uses LDS stopped on hosts without 64-lane
waves (`a wave64 group sharing LDS without barriers`), and so did such
a program with cross-lane reads.

Both now take the console flow there. The halves reach every LDS
access together, and a group barrier before each access puts it after
every earlier one, whichever half made it.

What still stops says why: a group of more than 64 threads, ds_permute
across the halves, or a whole-wave section.

Two new tests (LDS written and read across the halves, one with the
lower half kept busy first) are exact on an RTX 5070 and a Radeon iGPU.
They also pass on the RTX 5070 with the barrier left out, so they check
the result, not that the barrier is needed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The validator's message for an operation the stage or the entry's
properties do not allow ("Entry function performs some operation that
is incompatible with the shader stage or other entry properties") names
neither the operation nor the property, and it is the only message when
the call is in the entry function itself.

`victory translate --validate` now adds to each validator failure what
our own module declares and calls: its thread-group size, its wave size
and its dx.op operations (`emit::last_module_summary`, kept per thread
when a module is finished). Nothing of the console program is in it, so
a report of counts per reason is enough to see what the refused modules
have in common.

Prompted by a report on Marvisak#233: modules that fail validation with that
message and still create pipelines, 20 of them new with Marvisak#320, which I
cannot reproduce with hand-assembled programs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The scan test of the previous commit goes through the carry of a prefix
sum only. These cover the other branch, where each half's reduction is
exchanged and combined: the sum of the lane ids, their maximum (in the
upper half), their minimum (in the lower half) and their bitwise or,
and a sum over a mask of lanes below 40, which straddles the halves.
A group with a partial upper half, or none, still stops with the
section's reason.

All exact on an RTX 5070 (two halves) and a Radeon iGPU (native).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
One console wave with no s_barrier whose LDS write and read sit in
different exec-masked blocks: every lane (or, after a 4096-iteration
loop, only lanes 32..63) writes dword t, then lanes 0..31 read dword
t + 32. A third case has the same masks with no branch around either
access. Hand-assembled; exact on an RTX 5070 (two 32-lane waves, console
flow) and a Radeon iGPU (one 64-lane wave).

The pattern is the one a reviewer measured stale reads for on Marvisak#189. The
console flow orders the first two cases twice: a branch on EXEC is
decided by both halves through an exchange (a group barrier), and each
LDS access has a group barrier before it, so they also pass with the
second left out. The third has no branch, and with the barrier before
each LDS access left out the lower half of the RTX 5070 reads 0 in 20 of
20 runs (exact in 20 of 20 with it): the first test here that fails
without that barrier.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The startup warning on hosts without 64-lane waves still said every
console wave64 compute program that reads other lanes is dropped, and its
literal carried a run of spaces from a lost line continuation. It now
says such programs run as two 32-lane waves where there is a form for
them, and that the rest do not translate.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Cases for the ds_bpermute_b32 lowering of the commit before, each lane
checked on an RTX 5070 (two 32-lane waves) and a Radeon iGPU (one
64-lane wave): EXEC over part of each half, two console waves per group,
groups of 48 and 32 threads (a source lane that is not there reads 0),
and beside a v_readlane across the halves, which takes the console flow
on a host without 64-lane waves.

Also formats that commit's new lines for this crate's line width, and
the plan now lists ds_bpermute as an in-half read; ds_permute stays
open.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
In the console flow on a host without 64-lane waves, a whole-wave section
that leaves a float sum, minimum or maximum stopped with "a
floating-point whole-wave operation across 32-lane halves". Each half's
result now crosses as its bits, like the integer ones: minimum and
maximum through FMin / FMax, a sum as the two halves' sums added last,
and a prefix sum in the upper half adds the lower half's total. Groups of
exactly 64 threads, as for integers.

A sum's additions are in one more order than the console's and the host
wave's own, so its last bits may differ, as they already may in one host
wave.

Tests (hand-assembled, each lane checked on an RTX 5070 and a Radeon
iGPU): the lane ids as floats, their sum, maximum (in the upper half) and
minimum (in the lower half) with identities 0.0, -inf and +inf, a sum
over a mask that straddles the halves, and an inclusive prefix sum.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The wave64 plan had per-console-wave arrival counters with a bounded wait
for groups of more than 64 threads. A wait is met only if the partner
half runs meanwhile, which D3D12 does not promise and an RTX 5070 does not
do in the LDS tests, so that plan is dropped. For programs without LDS,
each console wave becomes a host group of its own (64 threads, the
dispatch's x count multiplied), which is the console flow as it is.
Groups that share LDS stay open, with the candidates named.

The group sizes and counts come from an offline translate over a local
copy of the title's shaders; no program content is in the document.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A v_cndmask_b32 whose selector derives from neither EXEC nor a compare (a
constant, a number built from scalars) stopped with "a select on an
untracked mask". In compute the lane can test its own bit of such a mask
by its console lane, as guards on such masks already do: the select now
takes the lane's bit from the structure's other masks, and a program
with such a select declares the console's wave size like the ones that
guard on them. Other stages are unchanged.

The high dword of a wave64 mask held as a number was found only when one
instruction wrote both dwords; written by two (s_mov_b32 each), lanes 32
to 63 tested the low dword's bits. The structure pass now records the
pair a mask's reader takes, and that is used where no single writer
exists. This applied to guards on such masks too.

Test (hand-assembled, each lane checked on an RTX 5070 and a Radeon
iGPU): a select on a mask of two constants and on one with a bit that
depends on the group, as a wave64 and as a wave32 program, in groups of
64 and 32 threads.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A loop-carried EXEC phi can depend on a latch phi that is not otherwise used. Discover deferred inputs before emitting mask phis, including inputs discovered while walking the deferred worklist. Extend the authored lane-read loop fixture by adding a second predecessor of the latch.
The test of the commit before dispatched on WARP only, which has no
32-lane waves, so it checked emission alone. It now runs like the other
lane-read loop test: emitted for each hardware adapter's waves,
validated, dispatched, and every lane compared (lane t stores t + 40).
Exact on an RTX 5070 (two 32-lane waves) and a Radeon iGPU; without the
structure change it stops with "a lane-mask join of an untracked mask".

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

Two defects found with a contributor's fixture (a waterfall loop over
lane classes with a whole-wave section inside, reported on Marvisak#439).

A mask copied dword by dword (EXEC restored with two s_mov_b32) is held
as a number, and that number is known only as the mask's own dword. In
the console flow the lowering followed that in a circle until the stack
ran out, which takes the process with it. It now stops with "an opaque
lane mask".

On a host that runs the console's wave size, a program with a lane read
in a divergent branch took the console flow only if it had no whole-wave
section, so one with both stopped with "a lane mask holding lanes
elsewhere read as data" there while a 32-lane host ran it. The rule
counted the lane reads sections make themselves; it now looks for a lane
read or write outside the sections and lets sections be, which the
console flow lowers as wave operations like the per-lane form. Such
programs fall back to the per-lane form as before if the console flow
cannot lower them.

Tests (hand-assembled): a lane read in a branch beside a whole-wave sum,
each lane checked on an RTX 5070 and a Radeon iGPU; and a mask copied
dword by dword, which overflowed the stack before and stops now.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A compute program with a numeric select declared the console's wave size
whether or not anything read the select's result. On a host without
64-lane waves that refused a wave64 program in a group of more than 64
threads only for a select nothing consumes, where it translated before
selects on numeric masks were lowered.

The ordinary lowering now runs first. Only when it stops on a select
with an untracked mask is the program lowered again with numeric selects
counted among the masks held as numbers.

From r4tedx#5 (MichaelSmithAI). Picked onto shader/console-flow-lds
by r4.: the selector scan iterates every instruction here (the tester
tree's `live()` filter is another PR's), and the new lines are formatted
for this crate.
The in-half form cannot read the high word of a numeric mask. Let an unused select drop out and use the existing full-wave retry when its result is needed. Exercise both cases alongside a live swizzle and DPP read.
Keep the host wave target and console-flow lowering while bringing in per-lane waterfall resource tracking. Use the structured program for resource tracking in translation and tests, and prefer proved per-lane descriptor reads before the general console read-first-lane path.
r4tedx and others added 17 commits November 26, 2026 06:52
A pure move, so that the merge of main (63bcca4) keeps emit/lower.rs
under the asset policy's 512 KiB limit: the inline `mod tests` becomes
`mod tests;` beside `mod bvh;`, and its body, one indent level less and
otherwise unchanged, is emit/lower/tests.rs. Its `super::` paths still
name `lower`.

Moving the tests out of lower.rs is desplmfao's idea (Marvisak#2309).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… flow

Conflicts, resolved with kawaii-shakal's notes on Marvisak#439:

- emit/host.rs: main's process-wide WARP device (`SharedDevice`,
  `WARP_LOCK`, `lock_warp`, `from_device`) is kept, and its
  `create_device` takes an optional adapter for the branch's
  `VICTORY_ADAPTER` and `Host::on`.
- emit/lower.rs: `console_read_lane` stays beside main's new
  `helpers_read` doc; main's `uniform_join` sits above `never_taken`,
  which keeps the branch's console-flow note.
- Lane-mask joins: main's path for data joined with masks at a uniform
  join (the BVH walks pop masks from memory) stays beside the console
  flow's masks; `lane_bit` now returns a `Result`, so it takes `?`.
  `no_mask_lane_on_edge` is kept out of the console flow, whose lanes go
  along the wave's edges.
- emit/lower/tests.rs (lower.rs's tests, moved out before this merge):
  main's test changes are ported there. Its `lowers` helper calls
  `lower` directly, so it now lowers a program again in the console flow
  when the first try asks for it, as `emit_with` does
  (`a_scalar_result_needs_no_exec`).
- The `lower::Parts` sites main added in tests (crosslane, memory,
  synthetic, lower's) pass `console_cf: false`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… branch

Conflicts:

- emit/lower.rs, lane-mask joins: the branch's console-flow masks
  (constants and masks built from scalars, `st.other`) feed main's
  `match`, which keeps main's path for data joined with masks at a
  uniform join (the BVH walks) and keeps `no_mask_lane_on_edge` out of
  the console flow, after kawaii-shakal's notes on Marvisak#439.
- emit/lower.rs's tests now live in emit/lower/tests.rs (moved on the
  console flow branch): the branch's `per_lane_only: false` lines are
  ported there, and the `lowers` helper keeps the per-lane form where
  the console flow cannot lower a program, as `emit_with` does here.
- The `lower::Parts` sites main added in tests (crosslane, memory,
  synthetic, lower's) pass `per_lane_only: false`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… LDS branch

Conflicts:

- emit/lower.rs: the branch's `numeric` and main's `scalar_def`,
  `sgpr_operand` and `scalar_constant` were added side by side; both
  are kept.
- `ds_bpermute_b32`: main's lowering, which adds the reader's half as
  the base only for wave64 programs, so a wave32 program reads no
  `waveGetLaneIndex` (main's
  `ds_bpermute_wave64_preserves_32_lane_half`), as kawaii-shakal
  noted. The lane is the same as the branch's in both cases. The
  comment keeps main's ISA reference and the branch's note on programs
  split in halves.
- lower.rs's tests now live in emit/lower/tests.rs (moved on the
  console flow branch): the branch's one change to them (`lower_wave`
  names `crate::emit::Target::ANY`) is ported there. The branch's
  `select_tests` module stays in lower.rs, as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's view-mark test builds emit::Options by hand; this branch adds a
target field to Options, so the test now fills the rest from Default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's placed-UAV diagnostics test calls emit::emit with the six arguments
it had before this branch added the target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Machad3x reported the missing-upper-half minimum and proposed skipping the exchange at 32 threads or fewer in Marvisak#2214. Exercise a nonzero minimum and both sides of the host-wave boundary on the current Marvisak#439 stack.

(cherry picked from commit 9cc76b8)
…gh bits

Machad3x proposed the split f16 reduction in Marvisak#2214. Exercise both halves of the packed source word for full, lower-forty and upper-half EXEC masks.

(cherry picked from commit 591c51c)
The split-halves f16 sum test dispatches only on hardware adapters, so
CI and WARP runs check its translation, not which lane gives the high
half. Assert that the scan ending in lane 31 leaves Shape::Half with
lane 31 (and 63 for the other form), and that the sum translates for
groups of 32 and 48 threads as well as 64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le memory

On a host without 64-lane waves, a wave64 program that reaches title
memory by address (root_memory) no longer takes the console flow in
halves when it also shares LDS, has whole-wave sections or permutes
lanes; it stops with a reason instead. Programs that only exchange
lanes or read masks whole keep the console flow, and hosts with
64-lane waves are unchanged.

latentdev found the limit (patch on Marvisak#439 against 87d1f42): without it
the ray-tracing structure builder stages caa78b8ca62bc3d6 and
28918b7150a7aad5 translated, part of the builder ran and the GPU hung
on an RTX 4090. Offline at 32-32 the XboxBvhBuilder.dll programs at
0x25c40 and 0x28770 (those two) validated before and are refused now;
the other 50 programs are unchanged.

The check lives in emit/lower/console.rs (lower.rs is near the file
size limit). The test builds an LDS program with and without a load
from an address it makes: refused at 32-32 only with the load, both
translate with 64-lane waves.

Co-authored-by: latentdev <3763127+latentdev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nsole flow on 32-lane hosts (pair meetings)

On a host without 64-lane waves the console flow (Marvisak#233, Marvisak#320, Marvisak#439) runs a
console wave64 as two 32-lane host waves that meet at group barriers. A
group of several console waves was refused ("console wave64 lanes in a
group of more than 64 threads"): its console waves branch and loop
differently, so no group barrier is reached by all threads.

With pair meetings (emit/lower/pairs.rs) the two halves of each console
wave meet on their own instead: an LDS counter per console wave that one
lane of each half counts up and both read until the other half has
counted (group-shared fences only, no group barrier in divergent code).
Exchanges of lane masks and data, wave-wide branch decisions, lane reads
and the order of the console wave's LDS accesses go through these
meetings; the title's s_barrier stays a group barrier and is required to
run once on every path (in no cycle, post-dominating the entry). Threads
of 2-D groups take their console thread ids from an LDS ticket, so each
host wave holds one half. A safety net refuses a module whose values are
used before the meeting that makes them. A group whose LDS leaves no room
for the meetings' state (5 dwords per console wave and one) stays
refused as before.

Only programs refused before change: VICTORY_BVH_HALVES=0 (or translate
--no-pair-meetings) turns pair meetings off, and the shader cache keys
translations made with them apart.

Idea from the half-wave pair meetings of trustno1-coder/VIctory-NVIDIA
(with_pair_meetings, meet, exchange_first; wave_base after Vice-Tay
c125c0c), re-implemented on the console flow.

Tests: emit::pair_meeting_tests (a per-console-wave loop with cross-half
lane reads in groups of four console waves, 1-D and 2-D, word for word on
a 32-lane GPU; the BVH builder's five such programs from containers on the
local disk, VICTORY_BVH_PROGRAMS, skipped without it). split_tests,
select_tests and each_adapter_gets_what_it_runs now expect groups of whole
console waves to translate.
@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the pair-meeting tests at 82f99f7 (draft, stacked on #439) on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

cargo test -p victory-shader --lib pair_meeting_tests -- --test-threads=1
4 passed; 0 failed; 0 ignored; 0 measured; 351 filtered out      (exit 0)

All four tests pass on a genuine 32-lane host, including several console waves translating with pair meetings and the builder meetings staying below the poll limit. They are translation-level tests; I did not run the title's 44 affected programs or a dispatch. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti.

Not tested: the title's shadow/builder shaders, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@neonbyte1

Copy link
Copy Markdown
Author

@Aniseto thanks, the first run on another card. Two notes on what the four tests cover:

  • a_lane_read_in_a_loop_each_console_wave_leaves_on_its_own does dispatch: when Host::new finds an SM 6.6 NVIDIA adapter, it runs on the GPU and compares against the expected values. If it can't find one, it prints skipped and passes. -- --nocapture shows which of the two happened on your 5070 Ti.
  • The two builder tests need the title's builder programs (VICTORY_BVH_PROGRAMS). Without them they print VICTORY_BVH_PROGRAMS not set; skipped, which is the right call with no game data.

A gap I found since opening this, which affects this PR and #439's console flow. Meetings and console-flow barriers fence group-shared memory only. A UAV write by one half of a console wave isn't ordered before a later read of the same address by the other half, though on the console that's plain program order. I wrote a synthetic test: lane 5 stores, then lane 40 loads the same dword, and the reverse. It ran 1024 groups × 16 dispatches per shape on an RTX 5090:

group stale reads, before with fix
64 threads (one console wave, console flow) 131 / 383 of 16384 0
128 threads (pair meetings) 13840 / 16455 of 32768 0
256 threads (pair meetings) 24384 / 34820 of 65536 0

The fix finds each UAV access that conflicts with an earlier one with no barrier between them, on any path. Before each such access the halves now meet with a group-scope UAV fence. Programs that don't write UAVs stay byte-identical. Over the whole pack: 0 programs lost, 308 compute programs change, and the rest are byte-identical. A switch VICTORY_UAV_ORDER=raw keeps only the read-after-write meetings (167 programs) as a cheaper second arm. The builder's programs read before they write, so the results above for them stand.

Branch (on my fork's integration, which carries #439 and these meetings): https://github.com/neonbyte1/VIctory/tree/suggest/console-flow-uav-order, commits 7797c99d9 and 5df170e23. I haven't measured its in-game cost yet. I'll fold it into this PR after an A/B, and report it on #439 too.

AI-assisted (Claude); measured on my machine, no game data shared.

@neonbyte1

Copy link
Copy Markdown
Author

In-game cost of the UAV-order fix I reported earlier. RTX 5090, Wine 11.22 + vkd3d-proton, A-B-A-B with 420 s per run on a quiet machine, same exe, switched with VICTORY_UAV_ORDER:

arm runs (ms per frame) average
off (no extra meetings) 210.2, 206.2 208.2
raw (read-after-write only) 212.9, 203.9 208.4
all (read-after-write, write-after-read, write-after-write) 213.1, 209.2 211.2

So all costs about 3 ms a frame (1.4 %), and raw costs no measurable time. Pictures and refusals were the same in every run.

Since then, the fix also covers the per-lane form and plain split halves. Both were exposed too: before the fix, 536 to 22,732 stale reads per shape in the synthetic test; after, 0. Programs with a conflict go to the console flow where it's allowed (about 460), and a small address analysis drops conflicts that provably can't alias. Over the pack: 0 programs lost, 785 compute programs change.

Branch: https://github.com/neonbyte1/VIctory/tree/suggest/uav-order-all-forms (its 3 commits on top of my fork's main).

AI-assisted (Claude); measured on my machine, no game data shared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants