Skip to content

Shaders: console waves may end before a title barrier in the console flow in halves (on #3683) - #3759

Open
redNSF wants to merge 86 commits into
Marvisak:mainfrom
redNSF:shaders/barriers-early-ends
Open

redNSF wants to merge 86 commits into
Marvisak:mainfrom
redNSF:shaders/barriers-early-ends

Conversation

@redNSF

@redNSF redNSF commented Nov 28, 2026

Copy link
Copy Markdown

Stacked on #3683 (pair meetings, itself on #439); the last commit is this change.

Problem. With pair meetings, a wave64 program whose group holds several console waves is refused when a title s_barrier is not met exactly once on every path ("a title barrier not met once by every console wave of a group in halves"). The title's classification programs fail that only because of their first lines: threads past the count are switched off for the rest of the program, and a console wave left with none branches to s_endpgm (v_cmpx_* then s_cbranch_execz to the end), around the barriers the other waves meet.

Change. barriers_once becomes barriers_in_step: no block holding an s_barrier is in a cycle, and of any two such blocks one dominates the other. The barriers are then a chain, and each console wave meets a first stretch of it, each barrier once, up to where the wave ends or goes a way without barriers. A console wave that ends early is in no later barrier, on the console and on the host alike: both wait only for threads still running. Still refused: a barrier in a loop (nothing shows that every console wave runs the loop equally often) and barriers on different ways.

Effect. Grand Theft Auto VI, translate --list --host-lanes 32-32: compute programs that translate go from 2,619 (#3683) to 2,624 of 2,682; the 5 gained were refused for this reason, none are lost. They are the four cascadeshadows_classify programs (CS_CalcRasterClassificationListCounts, CS_CalcRTClassificationListCounts, CS_WriteRasterClassificationResults, CS_WriteRTClassificationResults) and alphaResolve:CS_AlphTransmissionPrefilterMip. 7 stay refused with the reason, now worded "title barriers not met in one order by the console waves of a group in halves" (barriers in loops).

Tests (RTX 3060, 32-lane waves only):

  • New barriers_go_on_without_the_console_waves_that_ended: a 256-thread wave64 group counts its threads below a limit through LDS between two barriers; threads from the limit on are switched off and a console wave left with none ends before the first barrier. Run on a 32-lane hardware adapter (skipped elsewhere) with limits 40, 96, 200 and 256: every thread's count and its console wave's lane count are checked, and no thread past the limit stores.
  • New console_waves_may_end_before_the_title_barriers: that program translates; with its first barrier in a loop it is refused with the reason above. Runs anywhere.
  • cargo test -p victory-shader --lib on WARP: the same 4 synthetic_tests fail here as on Shaders: groups of several console wave64s run in the console flow on 32-lane hosts (pair meetings) #3683 alone.

Not run in the title yet: this PR claims that the programs translate and that the barrier behaves as the test checks on this card.

🤖 Generated with Claude Code

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 27 commits November 25, 2026 12:03
Co-Authored-By: GPT-6.2 Sol (Codex) <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol (Codex) <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol (Codex) <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol (Codex) <noreply@openai.com>
80f5663 took SGPR spills out of the lane reads that ask for the console's
wave size, so a compute program whose only lane reads and writes are
spills lost WaveSize on every host, Target::ANY included, where main
gives the console's wave size and emulates the lane writes. Keep main's
per-lane form there: on a host that runs the console's wave size, any
v_readlane/v_writelane still asks for it. On a 32-lane host spills stay
per-lane with no wave size, and the console flow still skips them.

The test now wants WaveSize(64) on ANY and none on 32-32, both from the
first (per-lane) pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings d5f8f2c (SGPR spills keep main's wave size where the host runs
it). `whole` keeps this branch's ds_bpermute_b32 exception beside
Marvisak#320's named_lane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The one conflict was in apps/victory/src/main.rs, where main's
`--jobs` became a `NonZeroUsize` and the branch added `--host-lanes`:
`translate::run` takes both, `jobs.map(NonZeroUsize::get)` as main
passes it and the branch's `host_lanes` after it.

The `emit` and `lower::Parts` call sites main added in tests (census,
crosslane, memory, synthetic, `emit::tests`, `resource` and lower.rs's
own) pass `Target::ANY`, as the earlier merge did for the ones before
them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
…flow in halves

With pair meetings a wave64 program whose group holds several console
waves was refused unless every path met each s_barrier exactly once.
The title's classification programs fail that only at their top: threads
past the count are switched off for the rest of the program, and a
console wave left with none branches to s_endpgm, around the barriers
the other waves meet.

barriers_once becomes barriers_in_step: no block holding an s_barrier is
in a cycle, and of any two such blocks one dominates the other. The
barriers are then a chain and each console wave meets a first stretch of
it, each barrier once, up to where it ends or goes a way without
barriers. A wave that has ended is in no later barrier, on the console
and on the host alike. A barrier in a loop and barriers on different
ways stay refused.

Grand Theft Auto VI, translate --list --host-lanes 32-32: 2,619 to 2,624
compute programs (the four cascadeshadows_classify programs and
alphaResolve:CS_AlphTransmissionPrefilterMip); none lost. Seven stay
refused for barriers in loops.

Tests: a 256-thread group counting through LDS between two barriers with
console waves that end before them, run on a 32-lane hardware adapter
(RTX 3060) for four limits; the same program translates, and is refused
with its first barrier in a loop.

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

upipibi commented Nov 28, 2026

Copy link
Copy Markdown

NVIDIA row for this PR: it passes on Ampere. Its GPU test runs here, on a 32-lane card, and reads what the console computes at every limit. Without the change, both tests fail on this card, but by refusing the program, not with wrong values: the parent's code does not translate it.

RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, debug. Head 17cf775. Its parent is 82f99f7, the head of #3683, so the base for the control and the lib counts is that parent and not main.

  • cargo test --locked -p victory-shader --lib -- barriers_go_on_without_the_console_waves_that_ended console_waves_may_end_before_the_title_barriers --nocapture: 2 passed, 0 failed, 0 ignored, in 3 of 3 runs on hardware. With VICTORY_WARP=1, where every device is WARP, also 2 passed, 0 failed in 3 of 3 runs. But there the GPU test printed the hardware adapter runs 64-lane waves: nothing to test; skipped, so under WARP only the translation test checks anything.

  • The halves path: the GPU test prints nothing when it passes. So I ran it once more with two temporary eprintln!s, of Host::target() and of the readback, then restored the file.

    • On hardware it printed adapter lanes 32..32, so the test translates for a host without 64-lane waves. Each console wave64 then runs as two 32-lane waves, which is the halves path. The control below confirms it: the parent refuses this program on this card with a reason that ends "of a group in halves".

    • The readback matches the test's expected values at every limit:

      • limit 40: 40 of 256 threads stored, thread 0 80, thread 40 0;
      • limit 96: 96 stored, thread 0 160, thread 95 128, thread 96 0;
      • limit 200: 200 stored, thread 0 264, thread 199 208, thread 200 0;
      • limit 256: 256 stored, all 320.

      So the console waves with no thread below the limit (waves 1-3 at limit 40, waves 2-3 at 96) end before both barriers, and the waves that are left still meet them and count correctly. A half-empty wave (limits 96 and 200) also counts correctly.

    • Under VICTORY_WARP=1 it printed adapter lanes 4..4. WARP is skipped because its range is not 32..32, not because it runs 64 lanes, so the skip message in hardware() (from Shaders: groups of several console wave64s run in the console flow on 32-lane hosts (pair meetings) #3683) names the wrong reason here.

  • Negative control: the parent's emit/lower.rs and emit/lower/pairs.rs, with the PR's pair_meeting_tests.rs kept. The test names lower::pairs::BARRIERS_OUT_OF_STEP, which the parent lacks, so in the control that one reference is the constant's string. git diff --stat HEAD: 3 files, 29 insertions, 58 deletions (that test line is 1 of them). git diff --stat 82f99f7: only pair_meeting_tests.rs, 141 insertions.

    • Hardware: 0 passed, 2 failed, in 3 of 3 runs. Both tests fail on the same refusal, GFX10 code at 0x0: a title barrier not met once by every console wave of a group in halves is not supported:
      • console_waves_may_end_before_the_title_barriers at its first expect (waves that end before the barriers);
      • barriers_go_on_without_the_console_waves_that_ended at its emit(...).unwrap(), before any dispatch.
    • VICTORY_WARP=1: 1 passed, 1 failed, in 3 of 3 runs. The translation test fails the same way, and the GPU test skips as above.

    So on the parent this program is refused rather than wrong. The control shows the PR is what lets it translate, but no GPU result exists to compare with the parent's.

  • cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index:

    The two extra passes are the new tests. The 3 failures are the same on both, and they are the ones main has on this card: stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros and synthetic_tests::gathers_at_a_level_match_the_hardware. The skipped test crashes the binary on this card (open issue Shader tests: heap_direct_texture_reads_mark_their_heap_index kills the test process on a real GPU (RTX 5070, main 67e8ae1) #2571). On the 3070 the stack shows none of the 4 synthetic_tests failures the description reports on WARP, but I did not run the suite under WARP.

  • The last commit does not touch victory-gpu, so I did not run its lib suite. The rest of the stack does touch it.

NVIDIA-specific: this card is the case the change is for (32..32 lanes, halves). A console wave that ends before the barriers does not stop the others there, and every value matches the console's.

Not tested:

  • the description's 5 programs (cascadeshadows_classify, alphaResolve) and its census, which need game files;
  • the suite under VICTORY_WARP=1;
  • the other 7 programs still refused (barriers in loops) beyond the synthetic loop case;
  • groups other than 256 threads, 2-D groups;
  • clippy, a title run.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@cxy0072019-sketch

Copy link
Copy Markdown

I checked the exact parent 82f99f7 against 17cf775 on an RTX 5070 Ti with driver 621.24. On the same shader archive, translate --host-lanes 32-32 --validate --list went from 2,619 to 2,624 emitted compute programs and from 1,884 to 1,889 DXIL validations. All five named programs pass, including the alpha prefilter. The synthetic early-exit test executed on the hardware adapter and passed.

During a separate title startup with 17cf775, the runtime also logged successful D3D12 compute pipeline creation for 2da4beb386509b77, the alpha prefilter. This startup used the title's 3840×2160 swap chain and the captured 3D scene was still dark with the HUD visible. The result confirms pipeline creation in the title. A scene-level visual result is still open.

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.

10 participants