Skip to content

Shaders: scalars leave divergent loops and branches as the wave's last path left them - #269

Open
TheHoracio wants to merge 2 commits into
Marvisak:mainfrom
TheHoracio:fix/scalars-leave-divergent-paths
Open

TheHoracio wants to merge 2 commits into
Marvisak:mainfrom
TheHoracio:fix/scalars-leave-divergent-paths

Conversation

@TheHoracio

@TheHoracio TheHoracio commented Nov 24, 2026 •

Copy link
Copy Markdown

On the console, a wave has one set of scalar registers. A divergent loop runs until its last lane leaves, and each path of a divergent branch that some lane takes runs in code order. So after the loop or the join, every lane reads the scalars that the last iteration or path left. The lowering runs scalar code per lane, so each lane left with its own path's values. That gives wrong numbers with no error, or a refused shader:

  • Wrong without an error. A loop's exit mask (s_or_b64 s[2:3], vcc, s[2:3]) or a scalar counter (s_add_u32) read after a divergent loop came out as 1, 2, 3, … 64 across a 64-lane wave, instead of 64 in every lane.
  • Refused. A mask grown inside a divergent branch and counted after it stops with a lane mask holding lanes elsewhere read as data. In the run reported on Testers post specs and test results here #49, this was the second most common reason a shader did not translate (80 of 370).

Change (crates/victory-shader/src/emit/lower.rs, compute programs only)

  • Scalar set operations on lane masks (s_{and,or,xor,andn2,orn2,nand,nor,xnor,not,mov}_b{32,64}) get their value as a number from their sources' numbers, instead of stopping with a lane mask read as data.
  • Entering the single exit block of a loop, the scalars the loop writes and code after it reads take the value of the lanes with the highest iteration count. This uses the loop counters LOOP_LIMIT already keeps: one waveActiveOp max of the count, then one per value.
  • Entering a join that is not a loop header, its scalar phis take the value of the lanes that came by the latest path in code order (a rank phi per join, then the same two wave maxima).

Pixel, vertex and mesh programs are unchanged. Their host waves need not be the console's (an RX 7800 XT runs wave32 pixel programs 64 lanes wide, see #125), so a host wave's value could mix console waves.

Shortcuts, also in comments:

  • A value lowered after the exit block (a loop block later in reverse postorder) keeps each lane's own value.
  • A scalar that both paths of an if/else change gets the later path's own result, not that path run on the earlier one's result.
  • Loops with more than one exit block are left as they were.

Tests

Four GPU tests in valu_tests.rs. They use a new build_lanes_cs: a 64-lane wave64 compute fixture that stores v0 per lane. All synthetic, no game data.

Test main d2a4bae This PR
loop_exit_mask_counted_after_the_loop fails: every lane reads 1 (only the last iteration's ballot) passes, 64
scalar_counted_in_a_divergent_loop_read_after_it fails: lane i reads i+1 passes, 64
mask_grown_inside_a_branch_counted_after_it refused: a lane mask holding lanes elsewhere read as data passes, 32
scalar_counted_in_nested_divergent_loops fails: each lane reads its own outer × inner count (1, 2, … 16) passes, 16

Tested

  • AMD Radeon RX 7800 XT (RDNA3), driver 32.0.32015.7029; Ryzen 7 9800X3D; Windows 11 Pro 10.0.26300; toolchain 1.98.1 (rust-toolchain.toml); debug.
  • cargo test --workspace --no-fail-fast: 268 passed, 0 failed, 4 ignored (main: 264 / 0 / 4).
  • cargo clippy -p victory-shader --all-targets: no warnings. cargo fmt --check -p victory-shader: clean. cargo xtask policy: 151 files ok.

Not tested

  • In the title. I have no copy I can use for this, so I can't say how many shaders it changes or what it does to a frame. Running victory translate --validate on your own pack, before and after, would show how many more compute shaders translate.
  • NVIDIA and Intel (wave32-only hosts run these compute programs through their own paths), RDNA2, RDNA4, and a release build.

AI use

  • Claude Code (Claude Opus 5.5) found the bug with the synthetic tests, wrote the change and the tests, and drafted this description. A person reviewed it and opened the PR.

🤖 Generated with Claude Code

TheHoracio and others added 2 commits November 24, 2026 02:55
…t path left them

The console runs a divergent loop until its last lane leaves, and each path
of a divergent branch that some lane takes, with one set of scalar
registers. After the loop or the join every lane reads the scalars the last
iteration or path left. The lowering ran scalar code per lane, so each lane
left with its own path's values: a loop's exit mask or a scalar counter read
after the loop came out as 1, 2, 3, ... across a 64-lane wave instead of 64,
with no error.

For compute programs (their host waves are the console's):
- Scalar set operations on lane masks (s_and/or/xor/andn2/orn2/nand/nor/
  xnor/not/mov) get their value as a number from their sources' numbers,
  instead of stopping with "a lane mask read as data". A mask grown inside a
  branch no longer stops with "a lane mask holding lanes elsewhere read as
  data".
- Entering the single exit block of a loop, the scalars the loop wrote and
  code after it reads take the value of the lanes with the highest iteration
  count (the loop counters LOOP_LIMIT already keeps).
- Entering a join that is not a loop header, its scalar phis take the value
  of the lanes that came the latest path in code order.

Pixel, vertex and mesh programs are unchanged: their host waves need not be
the console's, so a host wave's value could mix console waves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The inner loop's exit runs inside the outer loop's body, and the outer
loop's next iteration reads the inner loop's final value through its
header phi. On main each lane reads its own outer times inner count
(1, 2, ... 16); with the loop exit values every lane reads the wave's 16.

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

MisaXz commented Nov 24, 2026 •

Copy link
Copy Markdown

Test report on NVIDIA, which the description lists as not tested: the four new tests fail on a 32-lane host.

Tested

  • NVIDIA GeForce RTX 5080, driver 621.14 (32-lane waves only); Ryzen 7 9800X3D; Windows 11 Pro 26300; Rust 1.98.1; debug
  • This PR at 9356bee (base d2a4bae): cargo test --workspace --no-fail-fast: 264 passed, 4 failed, 4 ignored. main d2a4bae on the same machine: 264 passed, 0 failed, 4 ignored.
  • The same four fail in 3 of 3 further runs of cargo test -q -p victory-shader --lib (69 passed, 4 failed).
Test Result here
scalar_counted_in_a_divergent_loop_read_after_it lanes 0-31 read 32, lanes 32-63 read 64 (expected 64 everywhere)
scalar_counted_in_nested_divergent_loops lanes 0-31 read 8, lanes 32-63 read 16 (expected 16 everywhere)
loop_exit_mask_counted_after_the_loop host.compute_pipeline fails: pipeline: "The parameter is incorrect." (valu_tests.rs:780)
mask_grown_inside_a_branch_counted_after_it same pipeline error (valu_tests.rs:859)

The two wrong-value results are what each 32-lane half would count on its own: lanes 0-31 loop at most 32 times (and at most 2 inner x 4 outer = 8 in the nested test), lanes 32-63 at most 64 (4 x 4 = 16). So the 64-thread group runs here as two host waves that each stop at their own last lane.

For the two pipeline failures I have only a guess, not checked: both programs count a 64-bit mask with s_bcnt1_i32_b64, and the host cannot make a 64-lane pipeline.

Two of the tests also unwrap() Host::new(false) where the first one skips, in case that matters for hosts without an SM 6.6 device.

Not tested


Follow-up: together with #233 (same machine, local only)

Test #233 + this PR, via emit_for
mask_grown_inside_a_branch_counted_after_it passes
loop_exit_mask_counted_after_the_loop translation: Unsupported { offset: 24, what: "a lane-mask join of an untracked mask" }
scalar_counted_in_a_divergent_loop_read_after_it unchanged: 32 for lanes 0-31, 64 for lanes 32-63
scalar_counted_in_nested_divergent_loops unchanged: 8 for lanes 0-31, 16 for lanes 32-63

So on a 32-lane host the split in #233 does not by itself give the scalar-in-a-divergent-loop result this PR checks: those two programs read no other lane, so they are split in halves and each half stops at its own last lane. That experiment is my change to the test helper, not part of either PR.
AI use

  • Claude Code (Claude Fable 5.2) ran the tests and wrote this report from their output.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
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>
@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

A result from an AMD GPU that forms 32-lane waves, following the NVIDIA report above.

Tested

  • AMD Radeon iGPU (RDNA2, D3D12 wave range 32..64) and NVIDIA RTX 5070 (32..32) in one machine; Windows 11; Rust 1.98.1; debug.
  • This PR at 9356bee, with a local patch only so the test host picks an adapter by name:
Test Radeon iGPU RTX 5070
loop_exit_mask_counted_after_the_loop passes pipeline refused
mask_grown_inside_a_branch_counted_after_it passes pipeline refused
scalar_counted_in_a_divergent_loop_read_after_it lanes 0-31 read 32, lanes 32-63 read 64 the same
scalar_counted_in_nested_divergent_loops lanes 0-31 read 8, lanes 32-63 read 16 the same

So it is not only hosts without 64-lane waves: this Radeon driver runs a compute shader that declares no wave size in waves of 32 although it offers 64 (the RX 7800 XT in the description evidently forms 64). The two scalar programs read no mask as a number and no other lane, so they declare no wave size, and the maxima are taken per host wave. The two mask tests pass on the Radeon because reading a mask as data makes the program declare WaveSize(64).

A possible fix inside this PR: make a program the new code applies to declare the console's wave size (the same condition that sets console_lanes for masks read as data), so the host wave is the console wave wherever the pipeline is accepted. On a 32..32 host that then refuses the pipeline, as the two mask tests show.

For those hosts there is an alternative I tried: #233 / #320 add a "console flow" (every lane runs every block, branches taken wave-wide), where scalars are the wave's own by construction. With a local switch sending these four programs through it, all four are exact on both adapters here, the RTX 5070 in two 32-lane halves. Details in my reply on #233. Neither PR selects that form for these programs today, so this is a note on how the two could fit together, not a claim that they already do.

Not tested: release build, the title (no game files used).

AI-assisted.

@BlueMew

BlueMew commented Nov 24, 2026

Copy link
Copy Markdown

Test report on AMD RDNA4 and Windows 10, with the before/after count the description asks for.

Tested

  • AMD Radeon RX 9070 (RDNA4), driver 32.0.31041.1004; Ryzen 7 5700X3D; Windows 10 Home 22H2 (19045); Rust 1.98.1 from rust-toolchain.toml; release builds.
  • main d2a4bae and this PR at 9356bee: victory translate --validate --list over a retail dump, validator dxil.dll from Windows SDK 10.0.26100.
main d2a4bae This PR 9356bee
Compute programs emitted / validated (of 2,581) 1,693 / 1,670 1,698 / 1,670
Mesh programs validated (of 8,506) 8,129 8,129
Vertex and pixel programs validated (of 14,013) 12,184 12,184

Per-program diff of the two --list outputs: 268 programs change outcome, all compute. None is newly validated and none loses validation.

  • a lane mask holding lanes elsewhere read as data: 276 → 8.
  • The 268 now stop further on: 242 at a descriptor read only as data, 10 at a structured buffer of unknown stride, 5 emit but fail validation (Entry function performs some operation that is incompatible with the shader stage or other entry properties), 4 at a select on an untracked mask, 3 at a descriptor's address or format read as data, 2 at a lane-mask join of an untracked mask, 1 at s_getpc_b64, 1 at a scalar memory read as data.

So on this title the change clears this blocker, but on its own it brings no compute program to validation yet; a descriptor read only as data is next for 242 of the 268. The count cannot show the PR's other effect: programs that already translate and whose scalars read after a divergent loop now get the wave's value.

Not tested

  • In the title at run time.
  • The four new GPU tests: on Windows 10 a test binary gets no SM 6.6 device (the inbox D3D12 runtime lacks it, and only an exe exporting the Agility SDK symbols gets the newer one), so valu_tests fail here on main too.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and the comparison and drafted this report; I reviewed it before posting.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
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>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
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>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
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>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
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>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
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>
@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@BlueMew, your before/after counts clarify what to compare with the console-flow experiment on #233. The mask refusal clears for 268 compute programs, and 242 then stop at descriptor reads. Validation counts measure that next blocker. The scalar result after a divergent loop still needs the execution check from the four synthetic programs. Thanks for reporting the two measurements separately.

AI-assisted (Codex).

@qntic

qntic commented Nov 24, 2026

Copy link
Copy Markdown

tested this on my rx 6600 xt. 2 of the 4 gpu tests failed because the translated compute shader ran in wave32 instead of the required wave64.

added a fix that requests the console wave size when emitting wave reductions. all 4 tests now pass across 10 consecutive runs.

fix:
https://github.com/qntic/VIctory/tree/pub/269-console-wave-size

@qntic

qntic commented Nov 24, 2026

Copy link
Copy Markdown

tried integrating this pr with main ffe310e. 7 waterfall tests from #307/#566 fail after the merge.

gpu values are still correct, but unexpected wave operations appear in the translated code. reverted #269 from my integration branch for now.

something to check

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
… the wave's last path left them

Conflicts: the new tests sit after the f16 class compare tests. As in
the merge of this PR into shader/compute (2e03f3cb), scalars taken
wave-wide after divergent loops and joins (and lane masks combined
there) need a host wave that is the console wave: a wave64 program
split into two 32-lane halves takes the console flow instead, or fails
where only per-lane code is allowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Upstream PR #298 (lane masks spilled to VGPR lanes and read back), the
two mesh commits (a lane mask's "has lanes" test and reductions over the
host's wave) and PR #269 (scalars leave divergent loops and branches as
the wave's last path left them). #269's new tests pass here on the RTX
4060 Ti (32 lanes), so none is ignored.

Conflicts:
- lower.rs: both sides' fields and helpers (guard_slots and mask_sccs
  with #298's mask_spills, mask_set_op and only_scc_read); the lane-read
  test skips both our SGPR spills (`dead`) and #298's mask spills; the
  mask SCC arm and #298's LANE_MASK arm side by side; data joins try
  the lazy barycentric first, then take #269's loop finals.
- structure.rs: our console_pending with #269's idom; paired_masks stays
  where our tree sets it last.
- valu_tests.rs: both test sets.
- sgpr_spill.rs: a spilled else-mask that the per-lane form refused
  unforwarded now lowers there, since #298 takes the reload for the mask
  itself; the test asks for that, and for the console flow or the
  per-lane form when the lowering may choose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…ng once

Head 3ca9456 (TG0000). Conflicts:
- structure.rs: #999's normalised ite and direct-mapped memo keep our
  node-overflow bail-out (no memo writes after it); our memo cap
  (MAX_MEMO) goes, the cache is bounded by itself.
- lower.rs: missing_phis judges each edge as our fill_phis does: lazy
  barycentrics first, a loop's final value on edges from outside it
  (#269), and a descriptor's dword left undefined (descriptor_dword)
  instead of a redo. fill_phis keeps its own redo arms, one phi each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…wers in pixel and vertex programs

Head 986fa6d (undeadhuman37). Conflict in fill_phis: the edge keeps our
lazy barycentrics and #269's loop finals, then #1073's ballot. #999's
missing_phis (merged before) would redo such a phi before fill_phis
ever reaches the ballot, so it now makes the ballots first and takes a
mask dword that has one as a value. #1073's test passes the host
target to emit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Taken from try/wave64:
- #189 Wave64Mode (native / wave32 / emulate) and its LDS emulation of
  64-lane waves (its helpers in emit/lower/wave64.rs, keeping lower.rs
  under the 512 KiB policy limit), selected with VICTORY_WAVE64_EMULATE
  (emulate|1|force, wave32|32, native|0, auto). Default (auto) is Native,
  which keeps our Target-based path; the mode is part of the shader cache
  key. Their wave64 tests (wave64_tests.rs, host recommendation test).
- #940 mesh lanes counted the host's way when an emulate mode is chosen.
- Wave scalars and whole-wave sections: sections skip dead SGPR spills
  as ours did; wave scalars stay off under the emulate modes.
- Translator inferences: a descriptor read only as data, and a scalar use
  point, infer the view (ported onto our descriptor_data).
- 1 MiB windows for title memory outside buffers (shadow.rs).
- Trace every mesh draw (draw.rs); WARP adapter check in the test host.
- #737 mip drop floor: VICTORY_TEXTURE_MIP_DROP_MIN_SIZE now defaults to
  2048 (spares the 1920x1080 artwork).

Kept from our side:
- Target (--host-lanes, host wave sizes), split halves, console flow,
  whole-wave sections with SGPR-spill (dead) filtering, lane-mask
  lowering, #298, #269, waterfall, wave scalars (off under emulate modes).
- Our VICTORY_TEXTURE_MIP_DROP (#1296: auto for <= 8 GB, NPOT exemption,
  subresource mapping and copy routing around dropped mips, SRV mip
  adjustment): list.rs, resource.rs, texture.rs, descriptor/host.rs are
  ours apart from the floor default.
- Shader cache: VSH3 magic, KeySpec/store for offline warming, cache
  errors after a good translation, target key (+ wave64 mode byte).
- Write-watch journal, CommittedRegions, bindless plans, copystat
  counters, compute early start, #1388 queue thread, #1418, #704 raw
  view pool/stride table, the 16 MiB stack in build.rs.

Left out: #729 Agility SDK opt-in (build.rs exports, agility.rs, README
note): without D3D12Core.dll beside the exe the runtime throws
D3D12_ERROR_INVALID_REDISTRIBUTABLE at startup, and Windows 11 needs none.
Their host-recommended Wave32 default (it never remapped lanes on NVIDIA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
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 #233 that tried #269's programs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
itsonlysimbo pushed a commit to itsonlysimbo/VIctory that referenced this pull request Nov 24, 2026
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>
AntoninMichelq pushed a commit to AntoninMichelq/VIctory-forkAMD that referenced this pull request Nov 24, 2026
…arvisak#269)

A guarded texture in view memory that the guard saw no write to was
hashed every eighth frame only. A texture the title rewrites through
another view (the startup screens, video frames) changes where the guard
cannot see it, so it was shown up to eight frames stale: repeated frames
and flicker at startup and in the intro, gone with
VICTORY_TEXTURE_GUARD=0.

Each hash that finds a texture changed now notes the frame (`Last::rehash`,
used by every hashing path), and for 16 frames after that the guard does
not skip the texture. One that keeps changing is hashed at every check;
one that stops goes back to taking turns, so still textures keep the
guard's saving. The skip decision is a function (`guard_skips`) with unit
tests.

Not yet checked in the game: the change is to when a texture is hashed,
not to what is read.

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

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/valu_tests.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

brunofgmag pushed a commit to brunofgmag/VIctory that referenced this pull request Nov 25, 2026
…arvisak#269)

A guarded texture in view memory that the guard saw no write to was
hashed every eighth frame only. A texture the title rewrites through
another view (the startup screens, video frames) changes where the guard
cannot see it, so it was shown up to eight frames stale: repeated frames
and flicker at startup and in the intro, gone with
VICTORY_TEXTURE_GUARD=0.

Each hash that finds a texture changed now notes the frame (`Last::rehash`,
used by every hashing path), and for 16 frames after that the guard does
not skip the texture. One that keeps changing is hashed at every check;
one that stops goes back to taking turns, so still textures keep the
guard's saving. The skip decision is a function (`guard_skips`) with unit
tests.

Not yet checked in the game: the change is to when a texture is hashed,
not to what is read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alex3112 pushed a commit to alex3112/VIctory that referenced this pull request Nov 25, 2026
…nches as the wave's last path left them) into the integration

Both sides' arms and tests kept. Waterfall loops are left out of the wave-wide scalars (each lane runs them once with its own descriptor), and a set operation's mask gets a number only where the program reads one (mask_numbers), so if/else masks take no ballots nothing reads. The spilled else-mask test now expects the unforwarded program to translate too: its number comes from the set operation's sources.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
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