Shaders: console threads of 2-D and 3-D groups come from the wave counter (#216, a-publier) #442

Open
github-bot wants to merge 1 commit from github-bot/gh-442 into a-publier AGit
Owner

@⁠TinkerBell-90 on GitHub · 2026-11-27 01:55 UTC · original
TinkerBell-90:console-ids-tickets → a-publier · +111 −11 · 2 files · 1 commits · open

Related to #216, on a-publier.

On a-publier, a console-lane compute program in a 2-D or 3-D group of more than one host wave still gets its console thread from its host wave's first flat id, rounded down to the wave size. @⁠j-fuxa's probes in #216 (RTX 4060 Laptop, Radeon 780M) and @⁠adrianmjim's (RX 7900 XT, 2 x 2 quads) show host waves that do not hold an aligned run of flat ids in such groups, so two waves get the same ids. @⁠loyodea's #236 fixes this on main. Nothing does it on a-publier yet.

a-publier already has what the fix needs: wave_base, the LDS counter from which each 32-lane host wave of a console wave64 program takes its block of console threads. This PR uses it for console lanes in 2-D and 3-D groups of more than one host wave too. Such a program gets one more LDS dword, one group barrier and one LDS atomic in the entry block. 1-D groups and groups of one host wave are unchanged.

Writing the test showed a second problem, in the counter itself: it gave every host wave a block of 32, a partial one too. In a group that is not whole waves, the partial wave could take a block in the middle. A full wave now adds the wave size, and a partial wave takes the last block, which is what the console's last wave holds. I have not checked which of the title's programs have a group that is not whole host waves; @⁠adrianmjim's census on #236 found none among the 2-D and 3-D ones.

Tested on an RX 9070 XT under Linux: Wine 10 + vkd3d-proton 3.1 with DXVK's dxgi, Mesa 26.0.8 RADV, at a-publier 4eb6cfd. Not Windows, and nothing was run in game.

New GPU test console_threads_of_multidimensional_groups_are_one_each: each thread adds 1 + lane 0's flat id at its own flat id, so every dword must get exactly one add, of 1 + its console wave's first id. It covers console waves of 32 on host waves of 32, of 64 on 64, and of 64 on 32, in groups of W x 2 (W the console wave size), 32 x 2 x 2, 10 x 10, 12 x 12 and 24 x 8. All 15 ran on the card.

test, 20 runs each passed failed
4eb6cfd + the test only 3 17, all at console wave64 on host waves of 32, 10 x 10: ids 68 to 95 never written
this PR 20 0

The failure depends on the order the waves reach the counter, which is why 3 runs passed.

Without the change, a probe of 30 shapes gave exact ids in every form on this card, so I could not reproduce the 2 x 2 case of #216 here. That part of the fix is tested here only for not changing results, so a run of the new test on Windows or on an NVIDIA card would be welcome.

Full victory-shader --lib, one binary per row. This PR does not need #363; I added #363's first commit only to run the suite in the 32-lane form too (VICTORY_TEST_HOST_WAVE=32):

default (64-lane form) VICTORY_TEST_HOST_WAVE=32
4eb6cfd + #363's first commit 301 passed, 1 failed, 4 ignored 300 passed, 2 failed, 4 ignored
+ this PR 302 passed, 1 failed, 4 ignored 301 passed, 2 failed, 4 ignored

The failures left are stub_pipeline_is_created (vkd3d-proton accepts the zero-digest DXIL) and, in the 32-lane form, the ds_bpermute refusal that #363's second commit fixes. a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loop crashes RADV's compiler on this machine and was skipped in every row.

  • cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-gnu -- -D warnings is clean; rustfmt reports nothing on the changed lines.
  • @⁠adrianmjim asked on #236 why split keeps the rounding there. On a-publier, wave64 programs on 32-lane hosts already take their block from this counter, so that case is covered here, and the partial-wave fix applies to it.

If @⁠loyodea would rather port #236 itself, I will close this one.

AI-assisted.

**@⁠TinkerBell-90** on GitHub · 2026-11-27 01:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/442) `TinkerBell-90:console-ids-tickets` → `a-publier` · +111 −11 · 2 files · 1 commits · open Related to #216, on `a-publier`. On `a-publier`, a console-lane compute program in a 2-D or 3-D group of more than one host wave still gets its console thread from its host wave's first flat id, rounded down to the wave size. @⁠j-fuxa's probes in #216 (RTX 4060 Laptop, Radeon 780M) and @⁠adrianmjim's (RX 7900 XT, 2 x 2 quads) show host waves that do not hold an aligned run of flat ids in such groups, so two waves get the same ids. @⁠loyodea's #236 fixes this on `main`. Nothing does it on `a-publier` yet. `a-publier` already has what the fix needs: `wave_base`, the LDS counter from which each 32-lane host wave of a console wave64 program takes its block of console threads. This PR uses it for console lanes in 2-D and 3-D groups of more than one host wave too. Such a program gets one more LDS dword, one group barrier and one LDS atomic in the entry block. 1-D groups and groups of one host wave are unchanged. Writing the test showed a second problem, in the counter itself: it gave every host wave a block of 32, a partial one too. In a group that is not whole waves, the partial wave could take a block in the middle. A full wave now adds the wave size, and a partial wave takes the last block, which is what the console's last wave holds. I have not checked which of the title's programs have a group that is not whole host waves; @⁠adrianmjim's census on #236 found none among the 2-D and 3-D ones. **Tested** on an RX 9070 XT under Linux: Wine 10 + vkd3d-proton 3.1 with DXVK's dxgi, Mesa 26.0.8 RADV, at `a-publier` `4eb6cfd`. Not Windows, and nothing was run in game. New GPU test `console_threads_of_multidimensional_groups_are_one_each`: each thread adds 1 + lane 0's flat id at its own flat id, so every dword must get exactly one add, of 1 + its console wave's first id. It covers console waves of 32 on host waves of 32, of 64 on 64, and of 64 on 32, in groups of W x 2 (W the console wave size), 32 x 2 x 2, 10 x 10, 12 x 12 and 24 x 8. All 15 ran on the card. | test, 20 runs each | passed | failed | |---|---|---| | `4eb6cfd` + the test only | 3 | 17, all at console wave64 on host waves of 32, 10 x 10: ids 68 to 95 never written | | this PR | 20 | 0 | The failure depends on the order the waves reach the counter, which is why 3 runs passed. Without the change, a probe of 30 shapes gave exact ids in every form on this card, so I could not reproduce the 2 x 2 case of #216 here. That part of the fix is tested here only for not changing results, so a run of the new test on Windows or on an NVIDIA card would be welcome. Full `victory-shader --lib`, one binary per row. This PR does not need #363; I added #363's first commit only to run the suite in the 32-lane form too (`VICTORY_TEST_HOST_WAVE=32`): | | default (64-lane form) | `VICTORY_TEST_HOST_WAVE=32` | |---|---|---| | `4eb6cfd` + #363's first commit | 301 passed, 1 failed, 4 ignored | 300 passed, 2 failed, 4 ignored | | + this PR | 302 passed, 1 failed, 4 ignored | 301 passed, 2 failed, 4 ignored | The failures left are `stub_pipeline_is_created` (vkd3d-proton accepts the zero-digest DXIL) and, in the 32-lane form, the `ds_bpermute` refusal that #363's second commit fixes. `a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loop` crashes RADV's compiler on this machine and was skipped in every row. - `cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-gnu -- -D warnings` is clean; rustfmt reports nothing on the changed lines. - @⁠adrianmjim asked on #236 why `split` keeps the rounding there. On `a-publier`, wave64 programs on 32-lane hosts already take their block from this counter, so that case is covered here, and the partial-wave fix applies to it. If @⁠loyodea would rather port #236 itself, I will close this one. AI-assisted.
A console-lane program in a 2-D or 3-D group of more than one host wave
rounded its host wave's first flat id down to the wave size. That is
exact only when every host wave holds an aligned run of flat ids, which
GPUs that fill such groups in 2 x 2 quads do not give (#216). These
programs now take their console threads from wave_base's LDS counter, as
console wave64 programs on host waves of 32 already do.

The counter gave every host wave a block of 32, a partial wave too, so
in a group that is not whole waves the partial wave could take a block
in the middle: with a console wave64 program in a 10 x 10 group on host
waves of 32, ids 68 to 95 were never produced. A full wave now adds the
wave size, and a partial wave takes the last block, which the console's
last wave holds.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:16:07 +00:00
Author
Owner

@⁠Something6411 on GitHub · 2026-11-27 01:57 UTC · original

This is completely unrelated but how do you get the dump

**@⁠Something6411** on GitHub · 2026-11-27 01:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/442#issuecomment-7207710939) This is completely unrelated but how do you get the dump
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 03:55 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At a023216: cargo test --release -p victory-shader --lib 304 passed, 0 failed, 4 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 03:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/442#issuecomment-7209383442) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `a023216`: `cargo test --release -p victory-shader --lib` 304 passed, 0 failed, 4 ignored. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 06:27 UTC · original

Tested #442 (a023216) against a-publier 4eb6cfd on an RX 7900 XT (RDNA3, Windows 11, driver 32.0.32029.2010), release builds. WARP too.

New test, 20 runs each, on the card

passed failed
4eb6cfd + the test only 0 20, all at the first case, console wave32 on host waves of 32, 32 x 2: both host waves got ids 0 to 31 (dwords 0-31 got two adds, 32-63 none)
this PR 20 0 (all 15 cases ran on the hardware device)
  • So the 2 x 2 case of #216 reproduces here on every run. The test stops at its first failing case, so the other base cases were not reached; the probe below covers them.

Probe

The console program from my #216 comment, translated by each branch: 22 shapes, one group per dispatch, 16 dispatches per case.

mode 4eb6cfd this PR
console wave32, 64-lane host (WaveSize(32)) 11 shapes wrong in 16/16 runs (32x2: 32/64 ids, 10x10: 68/100, 6x6: 32/36) 22/22 exact, 16/16
console wave64, 64-lane host (WaveSize(64)) 5 shapes wrong in 16/16 runs (64x2, 64x4, 24x8, 10x10, 12x12) 22/22 exact, 16/16
console wave64, 32-lane host waves (counter) 3 partial-wave shapes: 10x10 9/16 exact (fewest 72/100), 12x12 7/16 (128/144), 6x6 11/16 (8/36); an earlier run gave 5/16, 7/16, 5/16 22/22 exact, 16/16
console wave32, 32-lane host waves not run 22/22 exact, 16/16
  • 6x6 is not in the PR's test. It is exact with this PR.
  • The probe's assertion form (every mode and shape, one dispatch) passes on this PR.

Archive programs

  • Whole-archive translate (25889 programs), default host wave and VICTORY_HOST_WAVE=32: no program changes state against 4eb6cfd. Cs 2682/2682 validated.
  • Emitted DXIL changes for 27 compute programs at the default host wave and 8 at 32. All 35 validate and create pipelines on the card (translate --validate --pipelines).
    • Default: 24 console wave64 2-D programs (16x16, 8x16, 32x32 at 64) and the 3 native wave32 8x8 programs (CS_GatherRaymarchedLocalLights, both CS_TAA2_Resolve).
    • Host wave 32: the same 3; terrainshadows CS_ComputeTerrainVisibility; and 4 programs whose group is a single partial host wave (LuminanceFromHDRBinkCS 1x1x1, CS_GenerateDisturbOverlappingPairs 1x1x1, CS_FoamTestDecal 1x1x1, CS_SSSTileClassification 4x4x1).
  • On the body's open question: on a-publier at host wave 32, one 2-D group of more than one host wave is not whole host waves: terrainshadows CS_ComputeTerrainVisibility, console wave64 6x6 (32 + 4 threads). My census on #236 was main.
  • The 4 single-wave programs above now carry the extra WaveAllBitCount and select. From reading the code their console ids stay the same, so "groups of one host wave are unchanged" holds for the ids, not for the emitted code.

Full victory-shader --lib on the card, default form, one binary per row

result
4eb6cfd + the test only 303 passed, 1 failed (the new test), 4 ignored
this PR 304 passed, 0 failed, 4 ignored

WARP

  • WARP reports a wave lane count of 4. It refuses every WaveSize(32) and WaveSize(64) pipeline, with and without this PR: E_INVALIDARG for the probe and the 35 archive programs, and the new test's cases are refused too.
  • The new test still passes on WARP because it skips cases the device does not take (its "ran on the hardware device" list is empty). A WARP pass says nothing here.

Not tested: VICTORY_TEST_HOST_WAVE=32 suite form, NVIDIA, anything in game.

**@⁠adrianmjim** on GitHub · 2026-11-27 06:27 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/442#issuecomment-7211547585) Tested #442 (`a023216`) against `a-publier` `4eb6cfd` on an RX 7900 XT (RDNA3, Windows 11, driver 32.0.32029.2010), release builds. WARP too. **New test, 20 runs each, on the card** | | passed | failed | |---|---|---| | `4eb6cfd` + the test only | 0 | 20, all at the first case, console wave32 on host waves of 32, 32 x 2: both host waves got ids 0 to 31 (dwords 0-31 got two adds, 32-63 none) | | this PR | 20 | 0 (all 15 cases ran on the hardware device) | - So the 2 x 2 case of #216 reproduces here on every run. The test stops at its first failing case, so the other base cases were not reached; the probe below covers them. **Probe** The console program from my #216 comment, translated by each branch: 22 shapes, one group per dispatch, 16 dispatches per case. | mode | `4eb6cfd` | this PR | |---|---|---| | console wave32, 64-lane host (WaveSize(32)) | 11 shapes wrong in 16/16 runs (32x2: 32/64 ids, 10x10: 68/100, 6x6: 32/36) | 22/22 exact, 16/16 | | console wave64, 64-lane host (WaveSize(64)) | 5 shapes wrong in 16/16 runs (64x2, 64x4, 24x8, 10x10, 12x12) | 22/22 exact, 16/16 | | console wave64, 32-lane host waves (counter) | 3 partial-wave shapes: 10x10 9/16 exact (fewest 72/100), 12x12 7/16 (128/144), 6x6 11/16 (8/36); an earlier run gave 5/16, 7/16, 5/16 | 22/22 exact, 16/16 | | console wave32, 32-lane host waves | not run | 22/22 exact, 16/16 | - 6x6 is not in the PR's test. It is exact with this PR. - The probe's assertion form (every mode and shape, one dispatch) passes on this PR. **Archive programs** - Whole-archive translate (25889 programs), default host wave and `VICTORY_HOST_WAVE=32`: no program changes state against `4eb6cfd`. Cs 2682/2682 validated. - Emitted DXIL changes for 27 compute programs at the default host wave and 8 at 32. All 35 validate and create pipelines on the card (`translate --validate --pipelines`). - Default: 24 console wave64 2-D programs (16x16, 8x16, 32x32 at 64) and the 3 native wave32 8x8 programs (CS_GatherRaymarchedLocalLights, both CS_TAA2_Resolve). - Host wave 32: the same 3; terrainshadows CS_ComputeTerrainVisibility; and 4 programs whose group is a single partial host wave (LuminanceFromHDRBinkCS 1x1x1, CS_GenerateDisturbOverlappingPairs 1x1x1, CS_FoamTestDecal 1x1x1, CS_SSSTileClassification 4x4x1). - On the body's open question: on `a-publier` at host wave 32, one 2-D group of more than one host wave is not whole host waves: terrainshadows CS_ComputeTerrainVisibility, console wave64 6x6 (32 + 4 threads). My census on #236 was `main`. - The 4 single-wave programs above now carry the extra WaveAllBitCount and select. From reading the code their console ids stay the same, so "groups of one host wave are unchanged" holds for the ids, not for the emitted code. **Full `victory-shader --lib` on the card, default form, one binary per row** | | result | |---|---| | `4eb6cfd` + the test only | 303 passed, 1 failed (the new test), 4 ignored | | this PR | 304 passed, 0 failed, 4 ignored | **WARP** - WARP reports a wave lane count of 4. It refuses every WaveSize(32) and WaveSize(64) pipeline, with and without this PR: E_INVALIDARG for the probe and the 35 archive programs, and the new test's cases are refused too. - The new test still passes on WARP because it skips cases the device does not take (its "ran on the hardware device" list is empty). A WARP pass says nothing here. Not tested: `VICTORY_TEST_HOST_WAVE=32` suite form, NVIDIA, anything in game.
Author
Owner

@⁠TinkerBell-90 on GitHub · 2026-11-27 06:57 UTC · original

@⁠Something6411 hey bro, pm me , or mail in my bio ✌️

**@⁠TinkerBell-90** on GitHub · 2026-11-27 06:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/442#issuecomment-7212008380) @⁠Something6411 hey bro, pm me , or mail in my bio ✌️
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/442/head:github-bot/gh-442'
git switch 'github-bot/gh-442'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-442'
git switch 'github-bot/gh-442'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-442'
git switch 'github-bot/gh-442'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-442'
git switch 'a-publier'
git merge --squash 'github-bot/gh-442'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-442'
git switch 'a-publier'
git merge 'github-bot/gh-442'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.