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 from upstream-pr/3759 into main
redNSF commented 2026-11-28 16:07:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by redNSF on 2026-11-28T16:07:01Z.


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 #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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5542084060 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3759). Originally posted by [redNSF](https://github.com/redNSF) on 2026-11-28T16:07:01Z. --- 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 #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](https://claude.com/claude-code)
upipibi commented 2026-11-28 17:04:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T17:04:00Z.


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 #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:

    • this PR: 350 passed, 3 failed, 3 ignored;
    • parent 82f99f7 (#3683): 348 passed, 3 failed, 3 ignored.

    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 #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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242727161 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3759#issuecomment-7242727161). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T17:04:00Z. --- 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 #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`: - this PR: 350 passed, 3 failed, 3 ignored; - parent `82f99f7` (#3683): 348 passed, 3 failed, 3 ignored. 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 #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 commented 2026-11-28 17:45:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cxy0072019-sketch on 2026-11-28T17:45:44Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7243266901 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3759#issuecomment-7243266901). Originally posted by [cxy0072019-sketch](https://github.com/cxy0072019-sketch) on 2026-11-28T17:45:44Z. --- 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3759:upstream-pr/3759'
git switch 'upstream-pr/3759'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3759'
git switch 'upstream-pr/3759'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3759'
git switch 'upstream-pr/3759'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3759'
git switch 'main'
git merge --squash 'upstream-pr/3759'
git switch 'main'
git merge --ff-only 'upstream-pr/3759'
git switch 'main'
git merge 'upstream-pr/3759'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3759
No description provided.