Shaders: compute threads that read other lanes keep unique ids in 2-D groups (NVIDIA) #2126

Open
github-bot wants to merge 3 commits from github-bot/gh-2126 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 05:40 UTC · original
0xkn0wh3r3:shader/host-wave-lane-probe → main · +607 −23 · 6 files · 3 commits · open

The problem

Some console compute programs read values from other lanes of their wave (v_mbcnt, v_readlane, DPP, ds_swizzle and similar). For those to work on a PC GPU, each thread's lane on the host must be its lane on the console. VIctory arranges that by renumbering the threads of such programs (Lower::thread_id): a thread's flat id becomes

(first flat id in my host wave, rounded down to 32) + my host lane

That gives every thread a different id only if each host wave holds 32 consecutive flat ids, starting at a multiple of 32, which is how the console fills its waves.

NVIDIA does not always do that. Probed on an RTX 5070 Ti (driver 621.24), for 2-D groups 24, 32 or 64 threads wide, or not a power of two wide, the driver fills a wave with a 16x2 tile of the group instead of a row:

group 32x2:   wave 0 holds ids 0-15 and 32-47
              wave 1 holds ids 16-31 and 48-63

Both waves round down to the same base (0 and 16 both round to 0), so two threads end up with every id and half the ids are never used. The program then computes and stores the same results twice and never writes the other half. Measured with a translated program that stores 1 at its own thread id:

group shape ids stored on main
64x1, 8x8, 16x16 all (these shapes are laid out in rows)
32x2 32 of 64
32x8 128 of 256
64x4 128 of 256
24x8 128 of 192
12x12 96 of 144
10x10 68 of 100

XCL's public notes report that an AMD RX 9070 lays 2-D groups out as 2x2 quads, which would break 8x8 groups there too.

The fix

The renumbering no longer guesses from where a wave starts. It hands each wave its block of 32 ids explicitly:

  • 1-D groups ([n, 1, 1]) keep the old rounding. Every host measured fills them in order, and the new test checks that it does.
  • 2-D and 3-D groups take their ids by ticket:
    1. Every thread writes 0 to a counter in group-shared memory, then waits at a group barrier.
    2. In each full wave, the first lane adds 32 to the counter; the value it read is the wave's base, and the wave shares it (WaveReadLaneFirst).
    3. The group's one partial wave (its last threads, which hosts put in lanes 0 and up) takes the last block.
    4. A thread's id is its wave's base plus its host lane.

Each wave gets a different block, so every id is used exactly once however the GPU arranges the threads. It is computed once, at the start of the program; the cost is one barrier and one group-shared atomic per wave, and only in 2-D and 3-D programs that read other lanes.

Testing

Two new tests in emit::lane_order_tests:

  • relabelled_threads_each_get_their_own_id: translates a console wave32 program that reads lanes (v_mbcnt) and stores 1 at its thread id, runs it in the nine shapes above, and checks every id is stored exactly once. It fails on main (the table above) and passes with the change.
  • host_waves_keep_what_the_relabelling_relies_on: probes the GPU itself with a plain HLSL program (built with the Windows SDK's dxc.exe; VICTORY_PC_DXC points elsewhere) and prints each shape's wave layout. It checks the two things the fix relies on: 1-D groups fill waves in order, and each group has at most one partial wave, filled from lane 0. Skipped without dxc; WARP refuses WaveSize(32) and is skipped.

cargo test -p victory-shader --lib on the RTX 5070 Ti passes except the three tests that fail on main there too (two stride_tests and gathers_at_a_level_match_the_hardware, fixed by #1887 and #1777). Clippy is clean with and without diagnostics.

Not checked on AMD hardware or in a title run.

#2117 renumbers the threads of the programs it lets drop their WaveSize using the same "waves hold aligned runs" assumption, so the shapes above break there too. Whichever of the two lands second should take its ids the same way.

Rebased onto f3578e3

  • The only conflict was in the test-only fields of Lowered. Both upstream's and this branch's are kept.
  • With the rebase, lower.rs grew past the 512 KiB that cargo xtask policy allows a source file. A new commit moves Lower::console_flat and Lower::ticket unchanged into lower/thread_ids.rs, next to lower/bvh.rs. The group-shared size they check against moves with them.
  • Since ec653f6, a program whose LDS already takes the host's whole 32 KiB keeps the old rounding, because the ticket's extra dword would fail validation (programs_with_all_the_lds_keep_the_rounding).
  • cargo test -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index on the RTX 5070 Ti: 301 passed. The same three tests fail on f3578e3 itself: the two stride_tests and gathers_at_a_level_match_the_hardware. Clippy is clean with and without --features diagnostics, and so is cargo xtask policy.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 05:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126) `0xkn0wh3r3:shader/host-wave-lane-probe` → `main` · +607 −23 · 6 files · 3 commits · open ## The problem Some console compute programs read values from other lanes of their wave (`v_mbcnt`, `v_readlane`, DPP, `ds_swizzle` and similar). For those to work on a PC GPU, each thread's lane on the host must be its lane on the console. VIctory arranges that by **renumbering the threads** of such programs (`Lower::thread_id`): a thread's flat id becomes ``` (first flat id in my host wave, rounded down to 32) + my host lane ``` That gives every thread a different id only if **each host wave holds 32 consecutive flat ids, starting at a multiple of 32**, which is how the console fills its waves. NVIDIA does not always do that. Probed on an RTX 5070 Ti (driver 621.24), for 2-D groups 24, 32 or 64 threads wide, or not a power of two wide, the driver fills a wave with a 16x2 tile of the group instead of a row: ``` group 32x2: wave 0 holds ids 0-15 and 32-47 wave 1 holds ids 16-31 and 48-63 ``` Both waves round down to the same base (0 and 16 both round to 0), so **two threads end up with every id and half the ids are never used**. The program then computes and stores the same results twice and never writes the other half. Measured with a translated program that stores 1 at its own thread id: | group shape | ids stored on main | |---|---| | 64x1, 8x8, 16x16 | all (these shapes are laid out in rows) | | 32x2 | 32 of 64 | | 32x8 | 128 of 256 | | 64x4 | 128 of 256 | | 24x8 | 128 of 192 | | 12x12 | 96 of 144 | | 10x10 | 68 of 100 | XCL's public notes report that an AMD RX 9070 lays 2-D groups out as 2x2 quads, which would break 8x8 groups there too. ## The fix The renumbering no longer guesses from where a wave starts. It hands each wave its block of 32 ids explicitly: - **1-D groups** (`[n, 1, 1]`) keep the old rounding. Every host measured fills them in order, and the new test checks that it does. - **2-D and 3-D groups** take their ids **by ticket**: 1. Every thread writes 0 to a counter in group-shared memory, then waits at a group barrier. 2. In each full wave, the first lane adds 32 to the counter; the value it read is the wave's base, and the wave shares it (`WaveReadLaneFirst`). 3. The group's one partial wave (its last threads, which hosts put in lanes 0 and up) takes the last block. 4. A thread's id is its wave's base plus its host lane. Each wave gets a different block, so every id is used exactly once however the GPU arranges the threads. It is computed once, at the start of the program; the cost is one barrier and one group-shared atomic per wave, and only in 2-D and 3-D programs that read other lanes. ## Testing Two new tests in `emit::lane_order_tests`: - `relabelled_threads_each_get_their_own_id`: translates a console wave32 program that reads lanes (`v_mbcnt`) and stores 1 at its thread id, runs it in the nine shapes above, and checks every id is stored exactly once. It fails on main (the table above) and passes with the change. - `host_waves_keep_what_the_relabelling_relies_on`: probes the GPU itself with a plain HLSL program (built with the Windows SDK's `dxc.exe`; `VICTORY_PC_DXC` points elsewhere) and prints each shape's wave layout. It checks the two things the fix relies on: 1-D groups fill waves in order, and each group has at most one partial wave, filled from lane 0. Skipped without `dxc`; WARP refuses `WaveSize(32)` and is skipped. `cargo test -p victory-shader --lib` on the RTX 5070 Ti passes except the three tests that fail on main there too (two `stride_tests` and `gathers_at_a_level_match_the_hardware`, fixed by #1887 and #1777). Clippy is clean with and without `diagnostics`. Not checked on AMD hardware or in a title run. ## Related #2117 renumbers the threads of the programs it lets drop their `WaveSize` using the same "waves hold aligned runs" assumption, so the shapes above break there too. Whichever of the two lands second should take its ids the same way. ### Rebased onto f3578e3 - The only conflict was in the test-only fields of `Lowered`. Both upstream's and this branch's are kept. - With the rebase, `lower.rs` grew past the 512 KiB that `cargo xtask policy` allows a source file. A new commit moves `Lower::console_flat` and `Lower::ticket` unchanged into `lower/thread_ids.rs`, next to `lower/bvh.rs`. The group-shared size they check against moves with them. - Since ec653f6, a program whose LDS already takes the host's whole 32 KiB keeps the old rounding, because the ticket's extra dword would fail validation (`programs_with_all_the_lds_keep_the_rounding`). - `cargo test -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index` on the RTX 5070 Ti: 301 passed. The same three tests fail on `f3578e3` itself: the two `stride_tests` and `gathers_at_a_level_match_the_hardware`. Clippy is clean with and without `--features diagnostics`, and so is `cargo xtask policy`.
A compute program that reads other lanes is relabelled so that each
thread's host lane is its console lane (`Lower::thread_id`): its flat id
was its wave's first flat id rounded down to the wave size, plus its lane
index. That is a bijection only while each host wave holds one aligned
run of flat ids. Measured on an RTX 5070 Ti (driver 621.24), it does not
for 2-D groups 24, 32 or 64 wide or not a power of two wide: the driver
fills waves with 16 by 2 tiles (ids 0-15 and 32-47 in one wave), so two
waves round to one base. A 32 by 2 group gave its 64 threads 32 ids;
32 by 8, 64 by 4, 24 by 8, 12 by 12 and 10 by 10 lost a quarter to a half
of theirs, threads computing and storing for the same console thread.
(XCL's public notes report 2 by 2 quads on an RX 9070, which would break
8 by 8 groups too.)

1-D groups keep the rounding: hosts put them into waves in order. Other
groups take ids by ticket: every thread zeroes a group-shared counter,
a barrier, then each full wave's first lane adds the wave size to it and
the wave takes the old value as its base; the one partial wave (the
group's last threads, its lanes from 0) takes the last run. Computed
once, in the entry block.

New tests (`emit::lane_order_tests`):
- `relabelled_threads_each_get_their_own_id` translates a console wave32
  program that reads lanes and stores 1 at its thread's flat id, in nine
  group shapes, and checks every id is stored once. On main six shapes
  fail (32 by 2: 32 of 64); with the change all pass.
- `host_waves_keep_what_the_relabelling_relies_on` probes the host with a
  plain HLSL program (the Windows SDK's dxc), printing each shape's wave
  layout, and checks 1-D groups are aligned runs and each group has at
  most one partial wave, its lanes from 0. Skipped without dxc.
The ticket that gives relabelled threads in 2-D and 3-D groups their ids
is one more dword of group-shared memory. A program that reads lanes and
already allocates the host's whole 32 KiB would then fail validation
("Total Thread Group Shared Memory storage is 32772, exceeded 32768")
where it translated before. Such programs keep the old rounding of the
wave's first flat id (`Lower::ticket`), noted as a shortcut: they
translate as they did, with the ids it repeats on hosts that put several
rows into one wave.

`programs_with_all_the_lds_keep_the_rounding` lowers the 8 by 8 program
of `lane_order_tests` with 32 KiB of LDS (the rounding) and with 31.5 KiB
(the ticket), and validates both where dxil.dll is found; with the ticket
forced, the first fails validation.

`relabelled_threads_each_get_their_own_id` now skips on a host that runs
no waves of 32 (D3D12_FEATURE_D3D12_OPTIONS1's lane range, read by the new
`Host::wave_lanes`) or that refuses the 1-D program, which takes no ticket,
as an Intel UHD (Xe-LP, waves of 16) did with "The parameter is
incorrect".
`Lower::console_flat` and `Lower::ticket`, with the group-shared size
they check against, move from `lower.rs` to `lower/thread_ids.rs`,
unchanged. With them `lower.rs` grew past the 512 KiB the asset policy
allows a source file.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:32 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 06:02 UTC · original

I ran the two lane_order_tests on native Windows with a Ryzen 9 7900X Radeon iGPU (32.0.11024.2) and an RTX 4070 Ti (621.01). I changed only the local test adapter selector to choose each GPU explicitly and verified the D3D12 device’s adapter LUID.

Retaining the PR’s tests but using the parent 940d32f lowering, both GPUs missed the same six of nine group shapes. For example, 32×2 marked 32/64 IDs, 24×8 marked 128/192, and 10×10 marked 68/100. With e214ce4, both tests passed on each GPU, and all nine shapes marked every ID.

Synthetic tests only. WARP refused WaveSize(32) and was skipped.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-25 06:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7154374402) I ran the two `lane_order_tests` on native Windows with a Ryzen 9 7900X Radeon iGPU (32.0.11024.2) and an RTX 4070 Ti (621.01). I changed only the local test adapter selector to choose each GPU explicitly and verified the D3D12 device’s adapter LUID. Retaining the PR’s tests but using the parent `940d32f` lowering, both GPUs missed the same six of nine group shapes. For example, `32×2` marked 32/64 IDs, `24×8` marked 128/192, and `10×10` marked 68/100. With `e214ce4`, both tests passed on each GPU, and all nine shapes marked every ID. Synthetic tests only. WARP refused `WaveSize(32)` and was skipped. *AI-assisted with Codex.*
Author
Owner

@⁠fiestorra on GitHub · 2026-11-25 06:10 UTC · original

This and #2126 rewrite the same arithmetic, they conflict, and one may be a precondition of the other

Two pull requests in the same window are changing how a thread's lane is arranged for cross-lane reads, and they are not independent.

Measured: they conflict, in the one file where it matters:

#2126 + #2117  → conflict in crates/victory-shader/src/emit/lower.rs

#2126 (console_flat, "compute threads that read other lanes keep unique ids in 2-D groups") changes how a thread's console flat id is derived, using a group-shared ticket, because a host may put threads of several rows into one wave; #2117 changes whether a wave size is declared at all, adding min_lanes and a Stop::Wide re-lowering for programs that only read within aligned groups of 4, 8, 16 or 32.

The question that decides how they land is about your premise for narrow groups. The argument for "an aligned group of k lanes never straddles a host wave" needs the host to fill its waves from consecutive flat ids in group order. #2126's description says that is not what some hosts do: an RTX 5070 Ti fills 2-D groups in 16 × 2 tiles ("24, 32 or 64 wide or not a power of two wide"), and XCL's notes report 2 × 2 quads on an RX 9070. If threads of one aligned group land in different host waves, then a narrow-group read is not within one wave after all, and #2126's ticket is what makes the ids line up again.

So:

  • if that is right, #2126 is a precondition for #2117 on those hosts and the order is 2126 then 2117, with the conflict resolved in favour of the ticket;
  • if the aligned-group argument holds without the ticket — because the group is small enough that a tile never splits it, which may well be true for 4 and 8 while false for 16 and 32 — then say which sizes are safe on which tiling, because that is precisely the boundary the code has to get right, and #2117's own fallback (Stop::Wide) is where it goes wrong if it is.

I am not asking for both to be merged together; I am asking for the sentence that says which mechanism owns the 2-D case. At the moment two of them claim it and they disagree by construction.

A note on the evidence, since it decides what a reviewer can check: translate --validate will not show this. A declared or missing WaveSize is refused by the host when the pipeline is created, so the number that moves is the --pipelines count (or a boot), not the validated count. If either description has a before/after of that count on a host whose lane count differs from the console's, it would settle the review in one line; on this machine (NVIDIA, 32 lanes, 32.0.16.2124) I can measure it for whichever of the two lands first, and for the pair once they agree.

No game data is involved: file names, hosts and counts.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-25 06:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7154526936) **This and #2126 rewrite the same arithmetic, they conflict, and one may be a precondition of the other** Two pull requests in the same window are changing how a thread's lane is arranged for cross-lane reads, and they are not independent. **Measured**: they conflict, in the one file where it matters: ``` #2126 + #2117 → conflict in crates/victory-shader/src/emit/lower.rs ``` #2126 (`console_flat`, "compute threads that read other lanes keep unique ids in 2-D groups") changes how a thread's console flat id is derived, using a group-shared ticket, because a host may put threads of several rows into one wave; #2117 changes *whether a wave size is declared at all*, adding `min_lanes` and a `Stop::Wide` re-lowering for programs that only read within aligned groups of 4, 8, 16 or 32. **The question that decides how they land** is about your premise for narrow groups. The argument for "an aligned group of `k` lanes never straddles a host wave" needs the host to fill its waves from consecutive flat ids in group order. #2126's description says that is **not** what some hosts do: an RTX 5070 Ti fills 2-D groups in 16 × 2 tiles ("24, 32 or 64 wide or not a power of two wide"), and XCL's notes report 2 × 2 quads on an RX 9070. If threads of one aligned group land in *different* host waves, then a narrow-group read is not within one wave after all, and #2126's ticket is what makes the ids line up again. So: - if that is right, **#2126 is a precondition for #2117 on those hosts** and the order is 2126 then 2117, with the conflict resolved in favour of the ticket; - if the aligned-group argument holds without the ticket — because the group is small enough that a tile never splits it, which may well be true for 4 and 8 while false for 16 and 32 — then say which sizes are safe on which tiling, because that is precisely the boundary the code has to get right, and #2117's own fallback (`Stop::Wide`) is where it goes wrong if it is. I am not asking for both to be merged together; I am asking for the sentence that says which mechanism owns the 2-D case. At the moment two of them claim it and they disagree by construction. **A note on the evidence**, since it decides what a reviewer can check: `translate --validate` will not show this. A declared or missing `WaveSize` is refused by the **host** when the pipeline is created, so the number that moves is the `--pipelines` count (or a boot), not the validated count. If either description has a before/after of that count on a host whose lane count differs from the console's, it would settle the review in one line; on this machine (NVIDIA, 32 lanes, `32.0.16.2124`) I can measure it for whichever of the two lands first, and for the pair once they agree. No game data is involved: file names, hosts and counts. Written with an AI assistant.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 07:21 UTC · original

@⁠DrDarkDK thanks. A Radeon iGPU missing the same six shapes as the 4070 Ti means this isn't NVIDIA-only.

@⁠fiestorra, on which mechanism owns the 2-D case: the ticket does, and it covers #2117's narrow groups too, whatever G is.

The failure isn't a lane group straddling host waves. Once ids are relabelled, a console lane is a host lane: a thread's id is its wave's base plus waveGetLaneIndex. So an aligned group of G ≤ host-lanes console lanes is always G lanes of one host wave, on any tiling. What breaks on a tiled host is the base. With 16×2 tiles, wave 0 starts at flat id 0 and wave 1 at flat id 16. Rounding both down to the wave width gives both the same base, so every id appears twice and half are never used. That happens for every G. It even happens with no cross-lane read beyond v_mbcnt, which is why the test here stores at its own id and reads nothing else.

So no size is safe without the ticket on a host that tiles 2-D groups. #2117's relabelling ("a host wave holds an aligned run of flat thread ids") makes the same assumption as thread_id on main, and shares the failure. On the conflict: keep the ticket, and in #2117's narrow path take the block size from waveGetLaneCount() instead of the console's N. Each host wave then takes one block of host-lane-count ids, and #2117's G argument holds as written. 1-D groups can keep the rounding, since every host probed fills them in order. Either order works; whichever lands second makes that change.

On the evidence: #2126 doesn't change whether WaveSize is declared, so --pipelines won't move for it. Its before/after is the stored-id count in relabelled_threads_each_get_their_own_id, which you can measure on any host that tiles. So far it fails on main and passes here on an RTX 5070 Ti, an RTX 4070 Ti and a Radeon iGPU, and it passes here on an RTX 5090.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 07:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7155768315) @⁠DrDarkDK thanks. A Radeon iGPU missing the same six shapes as the 4070 Ti means this isn't NVIDIA-only. @⁠fiestorra, on which mechanism owns the 2-D case: the ticket does, and it covers #2117's narrow groups too, whatever G is. The failure isn't a lane group straddling host waves. Once ids are relabelled, a console lane *is* a host lane: a thread's id is its wave's base plus `waveGetLaneIndex`. So an aligned group of G ≤ host-lanes console lanes is always G lanes of one host wave, on any tiling. What breaks on a tiled host is the **base**. With 16×2 tiles, wave 0 starts at flat id 0 and wave 1 at flat id 16. Rounding both down to the wave width gives both the same base, so every id appears twice and half are never used. That happens for every G. It even happens with no cross-lane read beyond `v_mbcnt`, which is why the test here stores at its own id and reads nothing else. So no size is safe without the ticket on a host that tiles 2-D groups. #2117's relabelling ("a host wave holds an aligned run of flat thread ids") makes the same assumption as `thread_id` on `main`, and shares the failure. On the conflict: keep the ticket, and in #2117's narrow path take the block size from `waveGetLaneCount()` instead of the console's N. Each host wave then takes one block of host-lane-count ids, and #2117's G argument holds as written. 1-D groups can keep the rounding, since every host probed fills them in order. Either order works; whichever lands second makes that change. On the evidence: #2126 doesn't change whether `WaveSize` is declared, so `--pipelines` won't move for it. Its before/after is the stored-id count in `relabelled_threads_each_get_their_own_id`, which you can measure on any host that tiles. So far it fails on `main` and passes here on an RTX 5070 Ti, an RTX 4070 Ti and a Radeon iGPU, and it passes here on an RTX 5090.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:47 UTC · original · edited 2026-11-26 00:26 UTC

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. Rebased onto current main (63bcca4), and it merges cleanly.

What it does: in crates/victory-shader/src/emit/lower/thread_ids.rs, Lower::console_flat keeps the round-down for 1-D groups. 2-D and 3-D groups that read other lanes instead give each full host wave a 32-id block from a group-shared ticket (zeroed by every thread before a barrier; the wave's first lane does the add and waveReadLaneFirst shares the result). The single partial wave takes the last block. Programs whose LDS already fills 32 KiB keep the rounding (Lower::ticket), which programs_with_all_the_lds_keep_the_rounding covers. Moving the code to lower/thread_ids.rs keeps lower.rs under the policy's size limit. The evidence is hardware measurements, not a guess: the stored-id test fails on main and passes here on an RTX 5070 Ti, an RTX 4070 Ti, an RTX 5090 and a Radeon iGPU, and chippy01 measured the same tiling on an RTX 3070 Ti and RDNA2.

For the maintainer:

  • lane_order_tests::host_waves_keep_what_the_relabelling_relies_on runs an external dxc.exe through std::process::Command (VICTORY_PC_DXC, else the Windows SDK's). diff_tests.rs, flow_tests.rs and emit/mod.rs on main already do the same, so this is a quick call.
  • Order with #2117 and #2633: whichever lands second should take its relabelled ids from the ticket, as described in this thread.

On your reply: confirmed. The rebase keeps both sets of Lowered test fields, and the 16-lane skip from ec653f6 is in place.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7160178021) · edited 2026-11-26 00:26 UTC <!-- victory-triage v1 head=256079ef5862cd5fdc9a13963e266b4e49c02de2 verdict=needs-work at=2026-11-26T00:26:26Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** Rebased onto current `main` (`63bcca4`), and it merges cleanly. What it does: in `crates/victory-shader/src/emit/lower/thread_ids.rs`, `Lower::console_flat` keeps the round-down for 1-D groups. 2-D and 3-D groups that read other lanes instead give each full host wave a 32-id block from a group-shared ticket (zeroed by every thread before a barrier; the wave's first lane does the add and `waveReadLaneFirst` shares the result). The single partial wave takes the last block. Programs whose LDS already fills 32 KiB keep the rounding (`Lower::ticket`), which `programs_with_all_the_lds_keep_the_rounding` covers. Moving the code to `lower/thread_ids.rs` keeps `lower.rs` under the policy's size limit. The evidence is hardware measurements, not a guess: the stored-id test fails on `main` and passes here on an RTX 5070 Ti, an RTX 4070 Ti, an RTX 5090 and a Radeon iGPU, and chippy01 measured the same tiling on an RTX 3070 Ti and RDNA2. For the maintainer: - `lane_order_tests::host_waves_keep_what_the_relabelling_relies_on` runs an external `dxc.exe` through `std::process::Command` (`VICTORY_PC_DXC`, else the Windows SDK's). `diff_tests.rs`, `flow_tests.rs` and `emit/mod.rs` on `main` already do the same, so this is a quick call. - Order with #2117 and #2633: whichever lands second should take its relabelled ids from the ticket, as described in this thread. On your reply: confirmed. The rebase keeps both sets of `Lowered` test fields, and the 16-lane skip from ec653f6 is in place. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠KainanP on GitHub · 2026-11-25 12:30 UTC · original

On an Intel UHD (Xe-LP, 16-lane waves), head e214ce40 merged onto main 940d32f makes relabelled_threads_each_get_their_own_id panic with [64, 1]: The parameter is incorrect instead of skipping, because the WaveSize(32) pipeline is refused on that host. Your probe's hardware leg ran there and shows most 2-D groups in 4×4 tiles. The layouts are in item 5 of #1829

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

**@⁠KainanP** on GitHub · 2026-11-25 12:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7162472666) On an Intel UHD (Xe-LP, 16-lane waves), head `e214ce40` merged onto `main` `940d32f` makes `relabelled_threads_each_get_their_own_id` panic with `[64, 1]: The parameter is incorrect` instead of skipping, because the `WaveSize(32)` pipeline is refused on that host. Your probe's `hardware` leg ran there and shows most 2-D groups in 4×4 tiles. The layouts are in item 5 of https://git.gtahub.st/github/Marvisak--VIctory/issues/1829 _AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this._
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 18:40 UTC · original

Thanks both. Fixed in ec653f6.

  • Groupshared: you were right. With the full 32 KiB already allocated, the ticket's extra dword makes the validator refuse the program ("Total Thread Group Shared Memory storage is 32772, exceeded 32768"). Such programs now keep the old rounding (Lower::ticket, noted as a shortcut), so they translate as they do on main. programs_with_all_the_lds_keep_the_rounding checks both sides of the limit (32 KiB keeps the rounding, 31.5 KiB takes the ticket) and validates the output where dxil.dll is found.
  • @⁠KainanP: relabelled_threads_each_get_their_own_id now reads the host's wave lane range (D3D12_OPTIONS1) and skips with a printed reason when 32 is outside it. It also skips if the host refuses the 1-D program, which takes no ticket, so a refusal there can only be about the wave size. On your UHD it should now skip instead of panicking. A rerun to confirm would be welcome, as I have no 16-lane host here. Your 4×4 tiles are one more layout the ticket handles where rounding doesn't.

The dxc.exe test is left for the maintainer's decision.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 18:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7171230944) Thanks both. Fixed in ec653f6. - **Groupshared:** you were right. With the full 32 KiB already allocated, the ticket's extra dword makes the validator refuse the program ("Total Thread Group Shared Memory storage is 32772, exceeded 32768"). Such programs now keep the old rounding (`Lower::ticket`, noted as a shortcut), so they translate as they do on `main`. `programs_with_all_the_lds_keep_the_rounding` checks both sides of the limit (32 KiB keeps the rounding, 31.5 KiB takes the ticket) and validates the output where `dxil.dll` is found. - @⁠KainanP: `relabelled_threads_each_get_their_own_id` now reads the host's wave lane range (`D3D12_OPTIONS1`) and skips with a printed reason when 32 is outside it. It also skips if the host refuses the 1-D program, which takes no ticket, so a refusal there can only be about the wave size. On your UHD it should now skip instead of panicking. A rerun to confirm would be welcome, as I have no 16-lane host here. Your 4×4 tiles are one more layout the ticket handles where rounding doesn't. The `dxc.exe` test is left for the maintainer's decision.
Author
Owner

@⁠chippy01 on GitHub · 2026-11-25 23:45 UTC · original

Same measurement on AMD, from #2633 (wave64 in 32-lane halves, which uses the same relabelling). A program stores 1 at its own relabelled id; the table counts how many ids get stored. Hardware: RTX 3070 Ti (driver 32.0.16.2124) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2, driver 32.0.21045):

group RTX 3070 Ti, waves of 32 Radeon, waves of 32 Radeon, waves of 64
32x2 32 / 64 32 / 64 64 / 64
32x8 128 / 256 128 / 256 256 / 256
64x4 128 / 256 128 / 256 128 / 256
32x32 512 / 1024 512 / 1024 1024 / 1024
32x2x2 64 / 128 64 / 128 128 / 128
8x4, 4x4, 8x8, 16x2, 16x4, 8x16, 16x16, 4x4x4, 2x2x16, 8x8x4, 64x1 all all all

So the Radeon tiles as well: waves of 32 for rows 32 threads wide or more, and waves of 64 for 64-wide rows. That means main's own wave64 programs on AMD lose ids in a 64x4 group today. Your tickets cover that case too.

#2633 now refuses those shapes in halves. Once this lands, halves can take its ids from your tickets instead (each host wave gets its own 32-aligned block, which is all halves need).

**@⁠chippy01** on GitHub · 2026-11-25 23:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7178009937) Same measurement on AMD, from #2633 (wave64 in 32-lane halves, which uses the same relabelling). A program stores 1 at its own relabelled id; the table counts how many ids get stored. Hardware: RTX 3070 Ti (driver 32.0.16.2124) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2, driver 32.0.21045): | group | RTX 3070 Ti, waves of 32 | Radeon, waves of 32 | Radeon, waves of 64 | |---|---|---|---| | 32x2 | 32 / 64 | 32 / 64 | 64 / 64 | | 32x8 | 128 / 256 | 128 / 256 | 256 / 256 | | 64x4 | 128 / 256 | 128 / 256 | **128 / 256** | | 32x32 | 512 / 1024 | 512 / 1024 | 1024 / 1024 | | 32x2x2 | 64 / 128 | 64 / 128 | 128 / 128 | | 8x4, 4x4, 8x8, 16x2, 16x4, 8x16, 16x16, 4x4x4, 2x2x16, 8x8x4, 64x1 | all | all | all | So the Radeon tiles as well: waves of 32 for rows 32 threads wide or more, and waves of 64 for 64-wide rows. That means `main`'s own wave64 programs on AMD lose ids in a 64x4 group today. Your tickets cover that case too. #2633 now refuses those shapes in halves. Once this lands, halves can take its ids from your tickets instead (each host wave gets its own 32-aligned block, which is all halves need).
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 23:52 UTC · original

@⁠chippy01 thanks, that settles the AMD side. The Radeon iGPU tiles 2-D groups too: waves of 32 for rows 32 or more wide, and waves of 64 for 64-wide rows, so main's own wave64 programs lose ids in a 64x4 group on AMD today. The ticket gives each host wave a block of the host wave's width, so it covers both. For #2633: yes, once this lands, halves can take their ids from the ticket (each host wave's 32-aligned block) instead of refusing those shapes. The branch is rebased onto current main (256079e).

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 23:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2126#issuecomment-7178163100) @⁠chippy01 thanks, that settles the AMD side. The Radeon iGPU tiles 2-D groups too: waves of 32 for rows 32 or more wide, and waves of 64 for 64-wide rows, so `main`'s own wave64 programs lose ids in a 64x4 group on AMD today. The ticket gives each host wave a block of the host wave's width, so it covers both. For #2633: yes, once this lands, halves can take their ids from the ticket (each host wave's 32-aligned block) instead of refusing those shapes. The branch is rebased onto current `main` (256079e).
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/2126/head:github-bot/gh-2126'
git switch 'github-bot/gh-2126'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2126'
git switch 'github-bot/gh-2126'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2126'
git switch 'github-bot/gh-2126'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2126'
git switch 'main'
git merge --squash 'github-bot/gh-2126'
git switch 'main'
git merge --ff-only 'github-bot/gh-2126'
git switch 'main'
git merge 'github-bot/gh-2126'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2126
No description provided.