Shaders: console threads of 2-D groups on NVIDIA from a group counter (port of Vice-Tay c125c0c, #1243) #30

Manually merged
github merged 2 commits from github-bot/gh-30 into main 2026-11-27 13:49:41 +00:00 AGit
Owner

@⁠regiumlepidi on GitHub · 2026-11-27 10:24 UTC · original
regiumlepidi:pr-thread-ticket → main · +125 −9 · 3 files · 2 commits · merged 2026-11-27 13:40 UTC

What

On NVIDIA, a translated program with console lanes (v_mbcnt, DPP, permlane…) in a compute group larger than one host wave could hand the same console thread ids to two host waves. NVIDIA (and RDNA in 32-lane waves) fill 2-D groups from 16 × 2 tiles, so the host wave's first flat id rounded down to the wave size is not a wave-aligned base: in a 32 × 2 group both waves round down to the same base, and half of the group's threads get the other half's ids (fxceless/victory-fork issue #1243).

This is a port of Vice-Tay's fix (c125c0c, author Garu667) to this tree:

  • such programs now take their console threads from an LDS counter (wave_base), as wave64-in-halves programs already did; a full wave takes the next aligned block from the low 16 bits, a partial wave its lane count from the high 16 bits past the full blocks, so it cannot shift a full wave off its alignment;
  • lanes are placed by their rank among the active lanes;
  • VICTORY_THREAD_TICKET=0 restores the old rounding; the switch is part of the shader cache key.

The code around wave_base differs from Vice-Tay's tree (the pairs meeting counters here), so this was merged by hand, not cherry-picked.

Measured

The ported hardware test (the_console_threads_of_a_two_dimensional_group_are_each_given_once, a console wave32 program in a 32 × 2 group storing 1 at dword 32y + x), on an RTX 5070 Ti (driver 617.42):

the old rounding on this device: 32 of 64 dwords written
ran on the hardware device: 64 of 64 console threads, each once

So on Blackwell the old path really loses half of such a group's work. cargo test -p victory-shader: 289 passed, 0 failed. cargo clippy reports nothing in the touched files. (Two victory-gpu tests, indirect::tests::host_list_budget_starts_empty_at_each_submission and warp_batch_charges_every_execution, fail on main as well, with or without this change.)

In game (Series X, 1440p, DLSS Quality) it runs without new errors or refused pipelines. I have not yet been able to tie it to one visible artifact by A/B, so I'm not claiming a specific visual fix — the test above is the evidence.

Notes

  • No game files, captures or logs are included.
  • This was written with an AI assistant (Claude Code) and reviewed, built and tested on my machine before sending.

🤖 Generated with Claude Code

**@⁠regiumlepidi** on GitHub · 2026-11-27 10:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/30) `regiumlepidi:pr-thread-ticket` → `main` · +125 −9 · 3 files · 2 commits · merged 2026-11-27 13:40 UTC ## What On NVIDIA, a translated program with console lanes (`v_mbcnt`, DPP, permlane…) in a compute group larger than one host wave could hand **the same console thread ids to two host waves**. NVIDIA (and RDNA in 32-lane waves) fill 2-D groups from 16 × 2 tiles, so the host wave's first flat id rounded down to the wave size is not a wave-aligned base: in a 32 × 2 group both waves round down to the same base, and half of the group's threads get the other half's ids (fxceless/victory-fork issue #1243). This is a port of Vice-Tay's fix (`c125c0c`, author Garu667) to this tree: - such programs now take their console threads from an LDS counter (`wave_base`), as wave64-in-halves programs already did; a full wave takes the next aligned block from the low 16 bits, a partial wave its lane count from the high 16 bits past the full blocks, so it cannot shift a full wave off its alignment; - lanes are placed by their rank among the active lanes; - `VICTORY_THREAD_TICKET=0` restores the old rounding; the switch is part of the shader cache key. The code around `wave_base` differs from Vice-Tay's tree (the `pairs` meeting counters here), so this was merged by hand, not cherry-picked. ## Measured The ported hardware test (`the_console_threads_of_a_two_dimensional_group_are_each_given_once`, a console wave32 program in a 32 × 2 group storing 1 at dword 32y + x), on an **RTX 5070 Ti** (driver 617.42): ``` the old rounding on this device: 32 of 64 dwords written ran on the hardware device: 64 of 64 console threads, each once ``` So on Blackwell the old path really loses half of such a group's work. `cargo test -p victory-shader`: 289 passed, 0 failed. `cargo clippy` reports nothing in the touched files. (Two `victory-gpu` tests, `indirect::tests::host_list_budget_starts_empty_at_each_submission` and `warp_batch_charges_every_execution`, fail on `main` as well, with or without this change.) In game (Series X, 1440p, DLSS Quality) it runs without new errors or refused pipelines. I have not yet been able to tie it to one visible artifact by A/B, so I'm not claiming a specific visual fix — the test above is the evidence. ## Notes - No game files, captures or logs are included. - This was written with an AI assistant (Claude Code) and reviewed, built and tested on my machine before sending. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
NVIDIA fills 2-D compute groups from 16 x 2 tiles, so rounding a host wave's
first flat id down to the wave size gives two waves of a 32 x 2 group the
same base. Such programs now take their console threads from an LDS counter
(wave_base), as wave64-in-halves programs already did; lanes are placed by
their rank among the active lanes. VICTORY_THREAD_TICKET=0 restores the old
rounding (part of the shader cache key).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On an RTX 5070 Ti the old rounding writes 32 of 64 dwords; with the group
counter all 64, each once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 10:44:57 +00:00
github manually merged commit d12eb1b23d into main 2026-11-27 13:49:41 +00:00
Author
Owner

@⁠rafaconvaitis on GitHub · 2026-11-27 16:15 UTC · original

Validated the two-dimensional compute group fixture on a native Windows 11 build 26300 with a GeForce RTX 4070 12 GB and driver 616.64. I ported the thread-ticket change onto Foxhound v0.2.0-pre.2 (9f8838b1) and ran the_console_threads_of_a_two_dimensional_group_are_each_given_once against both lowering paths on the hardware device.

  • Previous rounding wrote 32 of 64 dwords.
  • Thread tickets wrote all 64 expected dwords.

The fixture passed and reproduces the mapping correction on Ada. This comparison uses generated inputs.

**@⁠rafaconvaitis** on GitHub · 2026-11-27 16:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/30#issuecomment-7223037353) Validated the two-dimensional compute group fixture on a native Windows 11 build 26300 with a GeForce RTX 4070 12 GB and driver 616.64. I ported the thread-ticket change onto Foxhound v0.2.0-pre.2 (`9f8838b1`) and ran `the_console_threads_of_a_two_dimensional_group_are_each_given_once` against both lowering paths on the hardware device. - Previous rounding wrote 32 of 64 dwords. - Thread tickets wrote all 64 expected dwords. The fixture passed and reproduces the mapping correction on Ada. This comparison uses generated inputs.
This discussion has been locked. Commenting is limited to contributors.
No description provided.