Shaders: lane-indexed ops on a wide host wave use the own console wave #599

Open
NolanCotter wants to merge 4 commits from upstream-pr/599 into main
NolanCotter commented 2026-11-24 05:20:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by NolanCotter on 2026-11-24T05:20:38Z.


Depends on: #434 (uses its mask_dword half-select and the inst_lines/lower_program test helpers).

Closes #593. Same MaskData::Host family as #131 (#434): for wave32 pixel/vertex programs the host wave can be 64 lanes, whose upper half is a second console wave — but the lane-indexed ops either refused translation or read the wrong wave.

What changed (crates/victory-shader/src/emit/lower.rs)

  • v_readlane_b32: a constant lane operand took cross_lane(false) → a cross-lane operation outside compute, so the whole program was refused — including wave64 programs where a constant lane is already a valid host lane. Now: host lanes read directly (unchanged), constant lanes read k | (lane & 32) — the console lane of the lane's own wave — on wave32 programs, and plainly k on wave64.
  • v_writelane_b32: refused unconditionally on PS/VS. Now: on host lanes the me == lane test is already host-space for computed lanes; a constant lane gets the same | (lane & 32) base.
  • v_readfirstlane_b32: waveReadLaneFirst returns the host wave's first active lane — wave A's — for lanes 32-63. On wave32 programs it now finds the low set bit of the lane's own half of the exec ballot and renumbers it to a host lane, then waveReadLaneAts it.

Test

a_wave32_lane_op_uses_its_own_console_wave (synthetic wave32 GFX10 pixel program, no game files): asserts waveReadLaneAt is emitted with lane 5 | (lane & 32) for both readlane and writelane's equality test, and that readfirstlane picks the low bit of the lane's own ballot half before renumbering. The wave64 lowering of the same program is asserted to emit direct waveReadLaneAt(lane 5)/waveReadLaneFirst with no renumbering. The test fails on the pre-change lowering (the ops refuse or emit nothing).

cargo test -p victory-shader: 59/59. cargo fmt --check: clean.

No game files. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5466598315 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599). Originally posted by [NolanCotter](https://github.com/NolanCotter) on 2026-11-24T05:20:38Z. --- Depends on: #434 (uses its `mask_dword` half-select and the `inst_lines`/`lower_program` test helpers). Closes #593. Same `MaskData::Host` family as #131 (#434): for wave32 pixel/vertex programs the host wave can be 64 lanes, whose upper half is a second console wave — but the lane-indexed ops either refused translation or read the wrong wave. ### What changed (`crates/victory-shader/src/emit/lower.rs`) - **`v_readlane_b32`**: a constant lane operand took `cross_lane(false)` → `a cross-lane operation outside compute`, so the whole program was refused — including wave64 programs where a constant lane is already a valid host lane. Now: host lanes read directly (unchanged), constant lanes read `k | (lane & 32)` — the console lane of the lane's own wave — on wave32 programs, and plainly `k` on wave64. - **`v_writelane_b32`**: refused unconditionally on PS/VS. Now: on host lanes the `me == lane` test is already host-space for computed lanes; a constant lane gets the same `| (lane & 32)` base. - **`v_readfirstlane_b32`**: `waveReadLaneFirst` returns the *host* wave's first active lane — wave A's — for lanes 32-63. On wave32 programs it now finds the low set bit of the lane's own half of the exec ballot and renumbers it to a host lane, then `waveReadLaneAt`s it. ### Test `a_wave32_lane_op_uses_its_own_console_wave` (synthetic wave32 GFX10 pixel program, no game files): asserts `waveReadLaneAt` is emitted with lane `5 | (lane & 32)` for both readlane and writelane's equality test, and that readfirstlane picks the low bit of the lane's own ballot half before renumbering. The wave64 lowering of the same program is asserted to emit direct `waveReadLaneAt(lane 5)`/`waveReadLaneFirst` with no renumbering. The test fails on the pre-change lowering (the ops refuse or emit nothing). `cargo test -p victory-shader`: 59/59. `cargo fmt --check`: clean. No game files. AI-assisted.
LAKSHYA-cmd-tech commented 2026-11-24 06:32:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:32:43Z.

Review: COMMENTED


Tested on Windows 11 with MSVC Rust 1.98.1. All 72 unit tests pass!

However, cargo clippy -p victory-shader --tests -- -D warnings surfaces two warnings in the new unit test in crates/victory-shader/src/emit/lower.rs:

  1. Line 6813: unused variable i:
    ust .filter(|(_i, s)| {
  2. Line 6889: clippy::useless_format:
    ust .any(|i| i.starts_with("call f") && i.contains("k117, ")),

Once those two warnings are resolved, this is ready to approve!

<!-- greyfinch-sync:Marvisak/VIctory:review:6034708063 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#pullrequestreview-6034708063). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:32:43Z. **Review:** COMMENTED --- Tested on Windows 11 with MSVC Rust 1.98.1. All 72 unit tests pass! However, cargo clippy -p victory-shader --tests -- -D warnings surfaces two warnings in the new unit test in crates/victory-shader/src/emit/lower.rs: 1. Line 6813: unused variable i: ` ust .filter(|(_i, s)| { ` 2. Line 6889: clippy::useless_format: ` ust .any(|i| i.starts_with("call f") && i.contains("k117, ")), ` Once those two warnings are resolved, this is ready to approve!
iurysf commented 2026-11-24 06:56:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T06:16:59Z.


Tested offline against main d2a4bae with victory translate --list --validate over the title's shaders.rpf + executable (26,096 programs), dxil.dll 1.9.2602.17:

  • Translation failures: 3,733 on main -> 3,718 with this PR (-15). "a cross-lane operation outside compute" disappears (46 -> 0). The freed pixel programs mostly stop next at "a 64-bit image atomic" (653 -> 669) and "a lane mask read as data" (206 -> 217).
  • Emitted: vertex+pixel 12,284 -> 12,299 (+15, all validated); compute and mesh unchanged.
  • Validation: 185 modules rejected on both; no program that validated on main fails now. It also merges and builds on main without #434.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7123773048 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7123773048). Originally posted by [iurysf](https://github.com/iurysf) on 2026-11-24T06:16:59Z. --- Tested offline against main `d2a4bae` with `victory translate --list --validate` over the title's `shaders.rpf` + executable (26,096 programs), dxil.dll 1.9.2602.17: - Translation failures: 3,733 on main -> 3,718 with this PR (-15). "a cross-lane operation outside compute" disappears (46 -> 0). The freed pixel programs mostly stop next at "a 64-bit image atomic" (653 -> 669) and "a lane mask read as data" (206 -> 217). - Emitted: vertex+pixel 12,284 -> 12,299 (+15, all validated); compute and mesh unchanged. - Validation: 185 modules rejected on both; no program that validated on main fails now. It also merges and builds on main without #434. AI-assisted.
Lyrnc commented 2026-11-24 06:56:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-24T06:18:25Z.


GPU check of the three lane ops on two hosts: correct on every pixel, but both hosts ran the pixel program 32 lanes wide, so the 64-lane case is still unexercised.

What ran. This head (on #434) merged with main d2a4bae, plus #94 to pick the adapter. A local test (not pushed) draws a synthetic wave32 pixel program over 64×64 pixels through lower + Host::draw. The program is v_mbcnt_lo(-1) as the lane, v_readlane_b32 s, v, 5, v_readfirstlane_b32, and v_writelane_b32 v, s, 5. Each pixel checks readlane(5) = (lane & 32) | 5, that writelane hit exactly the lanes with (lane & 31) == 5, and that readfirstlane is in the lane's own half and not above it.

Host Widest pixel wave seen Wrong pixels of 4096 (readlane / writelane / readfirstlane)
RTX 5080, driver 610.88 32 lanes 0 / 0 / 0
AMD Radeon iGPU (gfx1036), driver 32.0.21042.62 32 lanes 0 / 0 / 0
(main + #94, same program) refused: a cross-lane operation outside compute

So the PR turns a refused program into one that gives the right lanes on 32-lane hosts, NVIDIA and AMD. This RDNA2 iGPU's driver picked 32-lane waves for the pixel shader, unlike the RDNA3 card in #125, so the | (lane & 32) and own-half ballot paths did not run with a second console wave here. A 64-lane-PS host (RDNA3, or an RDNA2 dGPU like the 6700 XT in #145) is still needed for that. a_wave32_lane_op_uses_its_own_console_wave and a_wave32_mask_read_takes_its_ballot_half pass.

AI use: Claude Code (Claude Opus 5.5) wrote the local test, ran it on both GPUs and drafted this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7123797635 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7123797635). Originally posted by [Lyrnc](https://github.com/Lyrnc) on 2026-11-24T06:18:25Z. --- GPU check of the three lane ops on two hosts: **correct on every pixel**, but both hosts ran the pixel program 32 lanes wide, so the 64-lane case is still unexercised. **What ran.** This head (on #434) merged with `main` `d2a4bae`, plus #94 to pick the adapter. A local test (not pushed) draws a synthetic wave32 pixel program over 64×64 pixels through `lower` + `Host::draw`. The program is `v_mbcnt_lo(-1)` as the lane, `v_readlane_b32 s, v, 5`, `v_readfirstlane_b32`, and `v_writelane_b32 v, s, 5`. Each pixel checks readlane(5) = `(lane & 32) | 5`, that writelane hit exactly the lanes with `(lane & 31) == 5`, and that readfirstlane is in the lane's own half and not above it. | Host | Widest pixel wave seen | Wrong pixels of 4096 (readlane / writelane / readfirstlane) | |---|---|---| | RTX 5080, driver 610.88 | 32 lanes | 0 / 0 / 0 | | AMD Radeon iGPU (gfx1036), driver 32.0.21042.62 | 32 lanes | 0 / 0 / 0 | | (`main` + #94, same program) | | refused: `a cross-lane operation outside compute` | So the PR turns a refused program into one that gives the right lanes on 32-lane hosts, NVIDIA and AMD. This RDNA2 iGPU's driver picked 32-lane waves for the pixel shader, unlike the RDNA3 card in #125, so the `| (lane & 32)` and own-half ballot paths did not run with a second console wave here. A 64-lane-PS host (RDNA3, or an RDNA2 dGPU like the 6700 XT in #145) is still needed for that. `a_wave32_lane_op_uses_its_own_console_wave` and `a_wave32_mask_read_takes_its_ballot_half` pass. AI use: Claude Code (Claude Opus 5.5) wrote the local test, ran it on both GPUs and drafted this comment.
LAKSHYA-cmd-tech commented 2026-11-24 07:51:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T07:51:53Z.

Review: APPROVED


Tested and verified on Windows 11 MSVC (Rust 1.98.1).

  • \_wave32_lane_op_uses_its_own_console_wave\ passes cleanly.
  • Constant console lanes now correctly compute the 32-lane base (\k | (lane & 32)) for wide host waves on wave32 graphics stages, and \ _readfirstlane\ correctly resolves the low bit of its own ballot half.
  • Eliminates erroneous \ cross-lane operation outside compute\ refusals.
  • Asset policy is 100% compliant (\cargo xtask policy\ ok: 151 files).
<!-- greyfinch-sync:Marvisak/VIctory:review:6035504675 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#pullrequestreview-6035504675). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T07:51:53Z. **Review:** APPROVED --- Tested and verified on Windows 11 MSVC (Rust 1.98.1). - \_wave32_lane_op_uses_its_own_console_wave\ passes cleanly. - Constant console lanes now correctly compute the 32-lane base (\k | (lane & 32)\) for wide host waves on wave32 graphics stages, and \ _readfirstlane\ correctly resolves the low bit of its own ballot half. - Eliminates erroneous \ cross-lane operation outside compute\ refusals. - Asset policy is 100% compliant (\cargo xtask policy\ ok: 151 files).
qntic commented 2026-11-24 08:02:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qntic on 2026-11-24T07:36:22Z.


Tested this stack on an RX 6600 XT (RDNA 2, driver 32.0.21045.5002), Ryzen 5 5600X, Windows 11 22631, Rust 1.98.1.

Confirmed that pixel shaders run in wave64 on this GPU. Added 11 regression tests covering wave32 mask and lane operations, partial coverage and divergent control flow, with pixel-by-pixel validation against expected wave32 semantics.

Results on actual hardware

Branch Passed Failed
main (d2a4bae) 1 10
#145 1 10
#434 2 9
#599 11 0

With #599, all translated test programs produced zero incorrect pixels.

Stability: 20/20 regression suite runs and 10/10 full shader library suite runs (83 tests), without hangs.

Interestingly, #145 makes the EXEC count worse on this GPU, returning 64 instead of 32.

Regression tests

Tests only, stacked on #599: github.com/qntic/VIctory@614f68b

Happy to submit these tests upstream or have them cherry-picked into this PR.


No game data used. Title behavior not tested.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7125172405 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7125172405). Originally posted by [qntic](https://github.com/qntic) on 2026-11-24T07:36:22Z. --- Tested this stack on an **RX 6600 XT** (RDNA 2, driver 32.0.21045.5002), **Ryzen 5 5600X**, Windows 11 22631, Rust 1.98.1. Confirmed that pixel shaders run in **wave64** on this GPU. Added **11 regression tests** covering wave32 mask and lane operations, partial coverage and divergent control flow, with pixel-by-pixel validation against expected wave32 semantics. ### Results on actual hardware | Branch | Passed | Failed | |---|---:|---:| | `main` (d2a4bae) | 1 | 10 | | #145 | 1 | 10 | | #434 | 2 | 9 | | #599 | **11** | **0** | With #599, all translated test programs produced **zero incorrect pixels**. **Stability:** 20/20 regression suite runs and 10/10 full shader library suite runs (83 tests), without hangs. Interestingly, #145 makes the EXEC count worse on this GPU, returning **64 instead of 32**. ### Regression tests Tests only, stacked on #599: https://github.com/qntic/VIctory/commit/614f68b Happy to submit these tests upstream or have them cherry-picked into this PR. --- No game data used. Title behavior not tested.
Zilumz1 commented 2026-11-24 09:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zilumz1 on 2026-11-24T08:49:12Z.


#599 + qntic's wave_tests on a GPU that is always 64 lanes (Polaris)

All the GPU results so far ran the pixel stage 32 lanes wide (@Lyrnc's RTX 5080 / gfx1036) or on RDNA2, where the driver chooses a wave size per shader (@qntic's 6600 XT). This card can't run 32 lanes: GCN reports WaveLaneCountMin = Max = 64. So every translated wave32 pixel program really gets two console waves in one host wave, which is the case #593 is about.

Setup: Windows 10 Pro, RX 580 2048SP (Polaris / GCN4), driver 31.0.21925.1001. Rust 1.98.1. SM 6.6 comes from Agility 1.620.2, using #486's test-only opt-in applied locally (not committed). Validator: dxil.dll 1.9.2602.17, so every translated program below passed validation before being drawn. qntic's tests are qntic/VIctory@614f68b (wave-tests-on-599, on top of #599's head 3823462). Each test was run alone (--exact). The layout probe confirms 64-lane pixel waves, so no test skipped.

Results (wrong pixels out of 4096 for the full target; the partial triangle shows the same pattern)

Test main ba7d873 (first / lane / value) #599 3823462 (first / lane / value)
exec counts and ranks 2048 / 2048 / 2048 0 / 2048 / 2048
compare masks 2048 / 2048 / 2009 0 / 2048 / 2048
first set lane (s_ff1) 2048 / 2048 / 1472 0 / 2048 / 0
readlane (constant lane) not translated: "a cross-lane operation outside compute" 0 / 2048 / 0
narrowed exec (s_and_saveexec) 2048 / 2048 / 764 0 / 2048 / 764
readlane at a computed lane 2048 / 2048 / 2048 driver crash (see 3)
writelane not translated 0 / 2048 / 64
any / all 2048 / 2048 / 736 0 / 2048 / 0
mbcnt lo / hi 2048 / 2048 / 2048 0 / 2048 / 2048
lanes leaving a loop 2048 / 2048 / 1102 0 / 2048 / 0
encodings ok ok

What this shows

1. #599 is a big improvement on a true 64-lane host.

  • v_readfirstlane / first lane is now right on every pixel (2048 wrong before, 0 now).
  • Constant-lane readlane and writelane now translate instead of being refused.
  • The s_ff1, any/all and loop values are now all correct.

2. Every remaining "lane" error is exactly +32, in the upper half of the host wave. Example: pixel 256, got [256, 32, 2080], wanted [256, 0, 2048]. That's #599's documented choice in the v_mbcnt lowering ("lane numbers stay host lanes: a second wave's rank takes its 32-lane base"), while qntic's tests expect console lanes 0–31. The mbcnt, exec-rank and compare values are off by the same 32. It would help to settle which convention is intended:

  • Console code that uses v_mbcnt_lo(mask) as a rank (stream compaction, base + rank into LDS or a UAV) would write 32 slots too far in the second console wave.
  • Keeping host numbering does make computed-lane readlane/writelane work without remapping, but see the next point.

3. The two numbering conventions conflict, with a concrete failure. In writelane_writes_the_console_waves_lane, the lane comes from s_ff1(vcc). That result is console-space (the ff1 test's values are right), but the writelane me == lane test is host-space. So the upper console wave never matches. The 64 wrong values are exactly the upper half's targeted lanes: pixel 256 got 0, wanted 9.

4. AMD driver crash on #599's computed-lane v_readlane. readlane_at_a_computed_lane_reads_the_console_waves_lane crashes with STATUS_ACCESS_VIOLATION (0xC0000005) inside CreateGraphicsPipelineState for the translated pixel shader. Instrumented: both layout-probe pipelines are created and drawn, then the process dies creating the third pipeline. The DXIL passes dxil.dll 1.9.2602.17, so this is a driver bug, but it's reproducible. On main the same program creates its pipeline and draws (with wrong values). So it's #599's new waveReadLaneAt with a per-lane-computed lane, or the own-half ballot path, that this compiler can't handle. Worth knowing because a crash in pipeline creation takes down the whole app, not just one draw. A workaround might be to make the lane wave-uniform before waveReadLaneAt (e.g. waveReadLaneFirst of the lane within each half), which may also be what the driver expects.

5. Why the 6600 XT passed 11/11 (a guess). RDNA2 picks wave32 or wave64 per shader. qntic's layout_ps can run 64 wide while the translated program runs 32 wide, in which case the upper-half paths never run. Only GCN (or forcing wave64) guarantees they do. I haven't verified this.

Happy to rerun on this card after changes, or to test a minimal shader for the crash in (4).

AI-assisted (test runs, analysis and write-up); every number above is from a real run on my machine, with no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7126602878 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7126602878). Originally posted by [Zilumz1](https://github.com/Zilumz1) on 2026-11-24T08:49:12Z. --- ## #599 + qntic's `wave_tests` on a GPU that is **always 64 lanes** (Polaris) All the GPU results so far ran the pixel stage 32 lanes wide (@Lyrnc's RTX 5080 / gfx1036) or on RDNA2, where the driver chooses a wave size per shader (@qntic's 6600 XT). This card can't run 32 lanes: GCN reports `WaveLaneCountMin = Max = 64`. So every translated wave32 pixel program really gets two console waves in one host wave, which is the case #593 is about. **Setup:** Windows 10 Pro, **RX 580 2048SP (Polaris / GCN4)**, driver 31.0.21925.1001. Rust 1.98.1. SM 6.6 comes from Agility 1.620.2, using #486's test-only opt-in applied locally (not committed). Validator: dxil.dll 1.9.2602.17, so every translated program below **passed validation** before being drawn. qntic's tests are `qntic/VIctory@614f68b` (`wave-tests-on-599`, on top of #599's head `3823462`). Each test was run alone (`--exact`). The layout probe confirms 64-lane pixel waves, so no test skipped. ### Results (wrong pixels out of 4096 for the full target; the partial triangle shows the same pattern) | Test | `main` `ba7d873` (first / lane / value) | #599 `3823462` (first / lane / value) | |---|---|---| | exec counts and ranks | 2048 / 2048 / 2048 | 0 / 2048 / 2048 | | compare masks | 2048 / 2048 / 2009 | 0 / 2048 / 2048 | | first set lane (`s_ff1`) | 2048 / 2048 / 1472 | 0 / 2048 / **0** | | readlane (constant lane) | not translated: "a cross-lane operation outside compute" | 0 / 2048 / **0** | | narrowed exec (`s_and_saveexec`) | 2048 / 2048 / 764 | 0 / 2048 / 764 | | readlane at a computed lane | 2048 / 2048 / 2048 | **driver crash** (see 3) | | writelane | not translated | 0 / 2048 / 64 | | any / all | 2048 / 2048 / 736 | 0 / 2048 / **0** | | `mbcnt` lo / hi | 2048 / 2048 / 2048 | 0 / 2048 / 2048 | | lanes leaving a loop | 2048 / 2048 / 1102 | 0 / 2048 / **0** | | encodings | ok | ok | ### What this shows **1. #599 is a big improvement on a true 64-lane host.** - `v_readfirstlane` / first lane is now right on every pixel (2048 wrong before, 0 now). - Constant-lane readlane and writelane now translate instead of being refused. - The `s_ff1`, any/all and loop values are now all correct. **2. Every remaining "lane" error is exactly +32, in the upper half of the host wave.** Example: pixel 256, `got [256, 32, 2080]`, `wanted [256, 0, 2048]`. That's #599's documented choice in the `v_mbcnt` lowering ("lane numbers stay host lanes: a second wave's rank takes its 32-lane base"), while qntic's tests expect console lanes 0–31. The `mbcnt`, exec-rank and compare values are off by the same 32. It would help to settle which convention is intended: - Console code that uses `v_mbcnt_lo(mask)` as a **rank** (stream compaction, `base + rank` into LDS or a UAV) would write 32 slots too far in the second console wave. - Keeping host numbering does make computed-lane `readlane`/`writelane` work without remapping, but see the next point. **3. The two numbering conventions conflict, with a concrete failure.** In `writelane_writes_the_console_waves_lane`, the lane comes from `s_ff1(vcc)`. That result is console-space (the ff1 test's values are right), but the writelane `me == lane` test is host-space. So the upper console wave never matches. The 64 wrong values are exactly the upper half's targeted lanes: pixel 256 `got 0, wanted 9`. **4. AMD driver crash on #599's computed-lane `v_readlane`.** `readlane_at_a_computed_lane_reads_the_console_waves_lane` crashes with `STATUS_ACCESS_VIOLATION` (0xC0000005) inside `CreateGraphicsPipelineState` for the translated pixel shader. Instrumented: both layout-probe pipelines are created and drawn, then the process dies creating the third pipeline. The DXIL passes dxil.dll 1.9.2602.17, so this is a driver bug, but it's reproducible. On `main` the same program creates its pipeline and draws (with wrong values). So it's #599's new `waveReadLaneAt` with a per-lane-computed lane, or the own-half ballot path, that this compiler can't handle. Worth knowing because a crash in pipeline creation takes down the whole app, not just one draw. A workaround might be to make the lane wave-uniform before `waveReadLaneAt` (e.g. `waveReadLaneFirst` of the lane within each half), which may also be what the driver expects. **5. Why the 6600 XT passed 11/11 (a guess).** RDNA2 picks wave32 or wave64 per shader. qntic's `layout_ps` can run 64 wide while the translated program runs 32 wide, in which case the upper-half paths never run. Only GCN (or forcing wave64) guarantees they do. I haven't verified this. Happy to rerun on this card after changes, or to test a minimal shader for the crash in (4). AI-assisted (test runs, analysis and write-up); every number above is from a real run on my machine, with no game data.
qntic commented 2026-11-24 10:03:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qntic on 2026-11-24T09:31:42Z.


Thanks for running my tests on Polaris! This is exactly the kind of cross-architecture validation I was hoping for.

Your findings regarding per-shader wave size selection on RDNA2 are particularly interesting. I'll investigate whether the translated shaders actually execute in wave32 or wave64 on my RX 6600 XT, rather than relying solely on the layout probe.

The +32 lane numbering mismatch and the writelane inconsistency definitely deserve further investigation.

Thanks for the detailed results!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7127537574 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7127537574). Originally posted by [qntic](https://github.com/qntic) on 2026-11-24T09:31:42Z. --- Thanks for running my tests on Polaris! This is exactly the kind of cross-architecture validation I was hoping for. Your findings regarding per-shader wave size selection on RDNA2 are particularly interesting. I'll investigate whether the translated shaders actually execute in wave32 or wave64 on my RX 6600 XT, rather than relying solely on the layout probe. The +32 lane numbering mismatch and the writelane inconsistency definitely deserve further investigation. Thanks for the detailed results!
Zilumz1 commented 2026-11-24 10:03:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zilumz1 on 2026-11-24T09:56:17Z.


@qntic, anything discovered so far based on my tests along with yours?

<!-- greyfinch-sync:Marvisak/VIctory:comment:7128090671 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7128090671). Originally posted by [Zilumz1](https://github.com/Zilumz1) on 2026-11-24T09:56:17Z. --- @qntic, anything discovered so far based on my tests along with yours?
qntic commented 2026-11-24 11:04:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qntic on 2026-11-24T10:06:44Z.


the layout probe confirmed wave64 but i havent checked the wave size inside each translated shader yet. gonna test that and see if your theory is right

<!-- greyfinch-sync:Marvisak/VIctory:comment:7128330644 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7128330644). Originally posted by [qntic](https://github.com/qntic) on 2026-11-24T10:06:44Z. --- the layout probe confirmed wave64 but i havent checked the wave size inside each translated shader yet. gonna test that and see if your theory is right
qntic commented 2026-11-24 12:04:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qntic on 2026-11-24T11:06:00Z.


you were right, i added wave size instrumentation inside each translated pixel shader. on my 6600 xt main reports wave64 but #599 reports wave32 across all tested pixel programs.

so my previous 11/11 result didnt actually cover the two console waves in one host wave case. ive updated the tests to report that case as not exercised.

thanks for catching this

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129654297 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7129654297). Originally posted by [qntic](https://github.com/qntic) on 2026-11-24T11:06:00Z. --- you were right, i added wave size instrumentation inside each translated pixel shader. on my 6600 xt main reports wave64 but #599 reports wave32 across all tested pixel programs. so my previous 11/11 result didnt actually cover the two console waves in one host wave case. ive updated the tests to report that case as not exercised. thanks for catching this
Zilumz1 commented 2026-11-24 12:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zilumz1 on 2026-11-24T11:18:04Z.


Thank you for validating my theory, i appreciate it alot. Makes me happy lol :)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129919597 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7129919597). Originally posted by [Zilumz1](https://github.com/Zilumz1) on 2026-11-24T11:18:04Z. --- Thank you for validating my theory, i appreciate it alot. Makes me happy lol :)
qntic commented 2026-11-24 12:04:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qntic on 2026-11-24T11:39:10Z.


No problem man 😁

<!-- greyfinch-sync:Marvisak/VIctory:comment:7130373175 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7130373175). Originally posted by [qntic](https://github.com/qntic) on 2026-11-24T11:39:10Z. --- No problem man 😁
qntic commented 2026-11-24 14:04:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qntic on 2026-11-24T13:27:13Z.


for reference, here's the instrumentation behind my previous wave size results.

github.com/qntic/VIctory@76ac076

it replaces the pixel shader's w output with WaveGetLaneCount() in test builds. measured wave64 on main and wave32 on this pr.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132850824 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7132850824). Originally posted by [qntic](https://github.com/qntic) on 2026-11-24T13:27:13Z. --- for reference, here's the instrumentation behind my previous wave size results. https://github.com/qntic/VIctory/commit/76ac076 it replaces the pixel shader's w output with WaveGetLaneCount() in test builds. measured wave64 on main and wave32 on this pr.
Marvisak commented 2026-11-25 01:07:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:29:58Z.


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.

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


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148571809 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7148571809). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:29:58Z. --- <!-- victory-triage v1 head=38234626c7c17cb6966a51c2ecba89e0bd1f78a7 verdict=needs-rebase at=2026-11-25T00:13:20Z --> 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`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
ColorMeBoom commented 2026-11-27 06:19:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T06:19:01Z.


RDNA1 run of @qntic's wave tests, and why they skip on AMD under this PR. AMD RX 5700 XT (Navi 10), driver 32.0.21045.29003, Windows 11 26200; synthetic programs only, no game data.

The AMD driver picks the pixel wave size from the shader's code, and this PR's v_readfirstlane lowering tips it to 32. I drew four hand-built pixel shaders that differ only in one lane read, and recorded WaveGetLaneCount() over a 64×64 target, twice:

Pixel shader contains Wave size the RX 5700 XT runs it at
no lane read 64
WaveReadLaneFirst(x) 64
WaveReadLaneAt(x, 5) 64
WaveReadLaneAt(x, WaveGetLaneIndex() & 32) 32

The new v_readfirstlane_b32 lowering here reads waveReadLaneAt at a lane computed from waveGetLaneIndex (the own half's first lane). Every program in wave_tests.rs starts with a v_readfirstlane in its prologue, so the driver runs all of them 32 lanes wide, and no host wave holds two console waves. That's the same result @qntic saw on the RX 6600 XT.

The tests, same files, on four trees (wave size from the LANE_COUNT_IN_W instrumentation; "fails" = first-lane, lane and value mismatches as the tests define them):

Tree Translated pixel waves Result
wave-tests-on-599 (76ac076, #434 + #599 on d2a4bae) 32 lanes, all 5,408 pixels 11 pass, 10 of them "NOT EXERCISED"
d2a4bae + the two test commits only (no #434/#599) 64 1 pass, 10 fail
main 63bcca4, tests ported 64 1 pass, 10 fail
#145 rebased on main (branch), tests ported 64 1 pass, 10 fail (these tests assume this PR's split, not #145's whole-wave reading)

So the second line is the control: same base, same tests, 64 lanes. Adding #434 and #599 is what makes the driver choose 32. The port to main only moves resource::track after structure (it takes Some(&st) now) and fills HostShader's new fields.

What this means for the PR: on AMD, programs that contain a lane-varying waveReadLaneAt run 32 lanes wide and are trivially per-console-wave. Programs without one can still run 64 lanes wide and take the | (lane & 32) and own-half ballot paths. The tests never cover that second case on RDNA1 or RDNA2. A test program whose prologue gets its first-lane id without v_readfirstlane (or keeps v_readfirstlane out of the program under test) would run 64 lanes wide here and exercise those paths. Polaris (always 64, @Zilumz1's run) is the only host so far where they ran.

The probe (four lane-read variants of layout_ps) is a local test only. I can send it if useful.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the probe and drafted this; the machine and the decision to post are the reporter's.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7211416608 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/599#issuecomment-7211416608). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-27T06:19:01Z. --- **RDNA1 run of @qntic's wave tests, and why they skip on AMD under this PR.** AMD RX 5700 XT (Navi 10), driver 32.0.21045.29003, Windows 11 26200; synthetic programs only, no game data. **The AMD driver picks the pixel wave size from the shader's code, and this PR's `v_readfirstlane` lowering tips it to 32.** I drew four hand-built pixel shaders that differ only in one lane read, and recorded `WaveGetLaneCount()` over a 64×64 target, twice: | Pixel shader contains | Wave size the RX 5700 XT runs it at | |---|---| | no lane read | 64 | | `WaveReadLaneFirst(x)` | 64 | | `WaveReadLaneAt(x, 5)` | 64 | | `WaveReadLaneAt(x, WaveGetLaneIndex() & 32)` | **32** | The new `v_readfirstlane_b32` lowering here reads `waveReadLaneAt` at a lane computed from `waveGetLaneIndex` (the own half's first lane). Every program in `wave_tests.rs` starts with a `v_readfirstlane` in its prologue, so the driver runs all of them 32 lanes wide, and no host wave holds two console waves. That's the same result @qntic saw on the RX 6600 XT. **The tests, same files, on four trees** (wave size from the `LANE_COUNT_IN_W` instrumentation; "fails" = first-lane, lane and value mismatches as the tests define them): | Tree | Translated pixel waves | Result | |---|---|---| | `wave-tests-on-599` (`76ac076`, #434 + #599 on `d2a4bae`) | 32 lanes, all 5,408 pixels | 11 pass, 10 of them "NOT EXERCISED" | | `d2a4bae` + the two test commits only (no #434/#599) | 64 | 1 pass, 10 fail | | `main` `63bcca4`, tests ported | 64 | 1 pass, 10 fail | | #145 rebased on `main` ([branch](https://github.com/ColorMeBoom/VIctory/tree/pr145-rebase)), tests ported | 64 | 1 pass, 10 fail (these tests assume this PR's split, not #145's whole-wave reading) | So the second line is the control: same base, same tests, 64 lanes. Adding #434 and #599 is what makes the driver choose 32. The port to `main` only moves `resource::track` after `structure` (it takes `Some(&st)` now) and fills `HostShader`'s new fields. **What this means for the PR:** on AMD, programs that contain a lane-varying `waveReadLaneAt` run 32 lanes wide and are trivially per-console-wave. Programs without one can still run 64 lanes wide and take the `| (lane & 32)` and own-half ballot paths. The tests never cover that second case on RDNA1 or RDNA2. A test program whose prologue gets its first-lane id without `v_readfirstlane` (or keeps `v_readfirstlane` out of the program under test) would run 64 lanes wide here and exercise those paths. Polaris (always 64, @Zilumz1's run) is the only host so far where they ran. The probe (four lane-read variants of `layout_ps`) is a local test only. I can send it if useful. AI use: Claude Code (Claude Opus 5.5) ran the tests and the probe and drafted this; the machine and the decision to post are the reporter's.
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/599:upstream-pr/599'
git switch 'upstream-pr/599'

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/599'
git switch 'upstream-pr/599'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/599'
git switch 'upstream-pr/599'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/599'
git switch 'main'
git merge --squash 'upstream-pr/599'
git switch 'main'
git merge --ff-only 'upstream-pr/599'
git switch 'main'
git merge 'upstream-pr/599'
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!599
No description provided.