Wave32 pixel shaders read the wrong half of a 64-lane subgroup on AMD (agc_driver_pixel_helper_lanes fails on RDNA4) #487

Closed
opened 2026-10-04 03:43:30 +00:00 by QDarkRex · 5 comments
QDarkRex commented 2026-10-04 03:43:30 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-10-04T03:43:30Z.


agc_driver_pixel_helper_lanes fails on every run on an AMD GPU on main (33a2f90). The wave64 passes succeed; the wave32 pass fails:

AGC graphics: pixel helper lanes wave32: the wave whose first lane is pixel 584 has 26 covered pixels, but EXEC holds 24 lanes

It is deterministic (6 of 6 runs, same wave). CI skips this test because lavapipe's subgroup is narrower than 32, and NVIDIA's subgroup is 32, so a wave32 shader there fills a subgroup exactly.

Host: Windows 11, Ryzen 7 5700X, Radeon RX 9060 XT (RDNA4), AMD driver 26.9.2 (LLPC), Vulkan 1.4.355, MinGW-w64 GCC 15.2.0. The device reports subgroupSize = 64 (min 32, max 64; subgroupSizeControl and requiredSubgroupSizeStages include fragment).

The failing wave, dumped with a local print in Check() (rank = v_mbcnt in EXEC, exec = s_bcnt1 of EXEC, all 26 pixels read pixel 584 through v_readfirstlane):

Pixels Ranks exec
24 pixels from two triangles (x 8–13 / y 3–7 and x 48–51 / y 24–25) 0 … 23 24
pixel 4660 (52, 24) 24 24
pixel 5040 (48, 26) 24 24

Two lanes have rank 24 in a 24-lane EXEC. That fits the upper half of a 64-lane subgroup seeing the lower half's EXEC: its covered lanes get the lower half's first lane and count, and a rank of all 24 lower bits.

Likely cause (from reading the code, not yet confirmed by a fix): for WaveSize() == 32, EmitBallotLaneActiveBool (SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp) reads only component 0 of the ballot, and the lane is the subgroup invocation ID. Nothing splits a 64-lane subgroup into two 32-lane waves, and no requiredSubgroupSize is requested. The opposite case, wave64 on a 32-lane subgroup, is handled with laneHalf. Pipeline creation also has a pairing case for wave64 on a 32-lane subgroup, but nothing for wave32 on a 64-lane one.

Possible directions, none tried: request a 32-lane subgroup for wave32 stages through VK_EXT_subgroup_size_control where the device allows it, or split the subgroup into two waves as laneHalf does for the opposite case.

If this holds, it is not limited to the test: any wave32 pixel shader in a title that uses EXEC counts, v_mbcnt or v_readfirstlane would see mixed lanes on AMD GPUs that run 64-wide subgroups. I can run builds or diagnostics on this card.

@oneandonlydean, since the test comes from 7ed138d.

Investigated with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5695967699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/487). Originally posted by [QDarkRex](https://github.com/QDarkRex) on 2026-10-04T03:43:30Z. --- `agc_driver_pixel_helper_lanes` fails on every run on an AMD GPU on `main` (33a2f90). The wave64 passes succeed; the wave32 pass fails: AGC graphics: pixel helper lanes wave32: the wave whose first lane is pixel 584 has 26 covered pixels, but EXEC holds 24 lanes It is deterministic (6 of 6 runs, same wave). CI skips this test because lavapipe's subgroup is narrower than 32, and NVIDIA's subgroup is 32, so a wave32 shader there fills a subgroup exactly. **Host:** Windows 11, Ryzen 7 5700X, Radeon RX 9060 XT (RDNA4), AMD driver 26.9.2 (LLPC), Vulkan 1.4.355, MinGW-w64 GCC 15.2.0. The device reports `subgroupSize = 64` (min 32, max 64; `subgroupSizeControl` and `requiredSubgroupSizeStages` include fragment). **The failing wave**, dumped with a local print in `Check()` (rank = `v_mbcnt` in EXEC, exec = `s_bcnt1` of EXEC, all 26 pixels read pixel 584 through `v_readfirstlane`): | Pixels | Ranks | exec | |---|---|---| | 24 pixels from two triangles (x 8–13 / y 3–7 and x 48–51 / y 24–25) | 0 … 23 | 24 | | pixel 4660 (52, 24) | 24 | 24 | | pixel 5040 (48, 26) | 24 | 24 | Two lanes have rank 24 in a 24-lane EXEC. That fits the upper half of a 64-lane subgroup seeing the lower half's EXEC: its covered lanes get the lower half's first lane and count, and a rank of all 24 lower bits. **Likely cause (from reading the code, not yet confirmed by a fix):** for `WaveSize() == 32`, `EmitBallotLaneActiveBool` (`SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp`) reads only component 0 of the ballot, and the lane is the subgroup invocation ID. Nothing splits a 64-lane subgroup into two 32-lane waves, and no `requiredSubgroupSize` is requested. The opposite case, wave64 on a 32-lane subgroup, is handled with `laneHalf`. Pipeline creation also has a pairing case for wave64 on a 32-lane subgroup, but nothing for wave32 on a 64-lane one. Possible directions, none tried: request a 32-lane subgroup for wave32 stages through `VK_EXT_subgroup_size_control` where the device allows it, or split the subgroup into two waves as `laneHalf` does for the opposite case. If this holds, it is not limited to the test: any wave32 pixel shader in a title that uses EXEC counts, `v_mbcnt` or `v_readfirstlane` would see mixed lanes on AMD GPUs that run 64-wide subgroups. I can run builds or diagnostics on this card. @oneandonlydean, since the test comes from 7ed138d. Investigated with AI assistance (Claude Code).
oneandonlydean commented 2026-10-06 05:25:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T05:25:18Z.


Thanks for the analysis, and sorry for not replying here sooner about the test from 7ed138d.

#587 (merged in ff964224) implements the second direction you listed. For a wave32 shader on a 64-wide host subgroup it keeps guest lane IDs in 0..31, takes the ballot word of the invocation's own 32-lane half, and maps shuffle targets back to physical lanes. That covers readlane, readfirstlane, DPP, DS permute, the lane-active check and the append/consume broadcast. Its wave32_wide_subgroup test checks 32-, 64- and 128-wide subgroups on the CPU, but nobody has run it on a 64-wide AMD subgroup yet. NVIDIA and lavapipe only exercise the lower half.

Could you run this on the RX 9060 XT with main at 109a3281 or later, and post the output with the driver version?

ctest --test-dir build -R "pixel_helper_lanes|wave32" --output-on-failure

If agc_driver_pixel_helper_lanes passes, I think this can be closed. If it still fails, the same per-wave dump as in your report would show which path is left.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6009968031 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/487#issuecomment-6009968031). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-06T05:25:18Z. --- Thanks for the analysis, and sorry for not replying here sooner about the test from 7ed138d. #587 (merged in `ff964224`) implements the second direction you listed. For a wave32 shader on a 64-wide host subgroup it keeps guest lane IDs in 0..31, takes the ballot word of the invocation's own 32-lane half, and maps shuffle targets back to physical lanes. That covers readlane, readfirstlane, DPP, DS permute, the lane-active check and the append/consume broadcast. Its `wave32_wide_subgroup` test checks 32-, 64- and 128-wide subgroups on the CPU, but nobody has run it on a 64-wide AMD subgroup yet. NVIDIA and lavapipe only exercise the lower half. Could you run this on the RX 9060 XT with `main` at `109a3281` or later, and post the output with the driver version? ``` ctest --test-dir build -R "pixel_helper_lanes|wave32" --output-on-failure ``` If `agc_driver_pixel_helper_lanes` passes, I think this can be closed. If it still fails, the same per-wave dump as in your report would show which path is left.
YossiYad commented 2026-10-06 12:17:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-06T12:17:47Z.


Ran the requested selection on a 64-wide AMD subgroup, on Linux with RADV:

ctest --test-dir build -R "pixel_helper_lanes|wave32" --output-on-failure
1/3 Test #144: agc_driver_pixel_helper_lanes ....   Passed    0.04 sec
2/3 Test #197: agc_driver_wave32_subgroup .......   Passed    0.02 sec
3/3 Test #208: wave32_wide_subgroup .............   Passed    0.00 sec

The device line of agc_driver_pixel_helper_lanes:

Selected GPU name=AMD Radeon RX 7700 XT (RADV NAVI32) vendor=0x1002 device=0x747e subgroup=64
Compute wave32 programs run on subgroups of 32
  • main at 5895ea72, Release, GCC 13.3 (Ubuntu 24.04 container), -DBUILD_TESTING=ON
  • AMD Radeon RX 7700 XT (RDNA 3, device 0x747e), Mesa 25.2.8 RADV, Vulkan 1.4.318, kernel 7.2.8 (Fedora 44 host)
  • The full suite also passes on this device, 359 of 359 with two unrelated skips, and on the same host's integrated RDNA 2 GPU (Raphael, device 0x13c0, subgroup 64) with the same result.

So the wave32-on-64-wide path from #587 holds on RADV. This does not cover the AMD Windows driver (LLPC) from the report. For what it is worth, #825, #826 and #827 do not reproduce on RADV either: agc_driver_vopc_compare_table, agc_driver_lds_atomics64 and agc_driver_image_sample_derivatives pass here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6016052571 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/487#issuecomment-6016052571). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-06T12:17:47Z. --- Ran the requested selection on a 64-wide AMD subgroup, on Linux with RADV: ``` ctest --test-dir build -R "pixel_helper_lanes|wave32" --output-on-failure 1/3 Test #144: agc_driver_pixel_helper_lanes .... Passed 0.04 sec 2/3 Test #197: agc_driver_wave32_subgroup ....... Passed 0.02 sec 3/3 Test #208: wave32_wide_subgroup ............. Passed 0.00 sec ``` The device line of `agc_driver_pixel_helper_lanes`: ``` Selected GPU name=AMD Radeon RX 7700 XT (RADV NAVI32) vendor=0x1002 device=0x747e subgroup=64 Compute wave32 programs run on subgroups of 32 ``` - `main` at 5895ea72, Release, GCC 13.3 (Ubuntu 24.04 container), `-DBUILD_TESTING=ON` - AMD Radeon RX 7700 XT (RDNA 3, device 0x747e), Mesa 25.2.8 RADV, Vulkan 1.4.318, kernel 7.2.8 (Fedora 44 host) - The full suite also passes on this device, 359 of 359 with two unrelated skips, and on the same host's integrated RDNA 2 GPU (Raphael, device 0x13c0, subgroup 64) with the same result. So the wave32-on-64-wide path from #587 holds on RADV. This does not cover the AMD Windows driver (LLPC) from the report. For what it is worth, #825, #826 and #827 do not reproduce on RADV either: `agc_driver_vopc_compare_table`, `agc_driver_lds_atomics64` and `agc_driver_image_sample_derivatives` pass here.
EdouardSence commented 2026-10-07 17:53:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-07T17:53:21Z.


Same selection on RDNA4 with RADV, main cea1ef1 (includes #587):

ctest --test-dir build -R "pixel_helper_lanes|wave32" -V
Selected GPU name=AMD Radeon RX 9070 XT (RADV GFX1201) vendor=0x1002 device=0x7550 subgroup=64
1/3 Test #169: agc_driver_pixel_helper_lanes ....   Passed
2/3 Test #223: agc_driver_wave32_subgroup .......   Passed
3/3 Test #234: wave32_wide_subgroup .............   Passed

Linux (CachyOS, kernel 7.2.9), Mesa 26.2.4, GCC 16.2.1. The full suite passes as well (399/399). In a verbose run of the GPU tests (-R "agc_driver|wave32|shader"), 157 selected this device and none reported a skip.

AI-assisted: yes (Claude Code ran the tests and wrote this; the run is on my machine).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6043650244 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/487#issuecomment-6043650244). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-07T17:53:21Z. --- Same selection on RDNA4 with RADV, `main` cea1ef1 (includes #587): ``` ctest --test-dir build -R "pixel_helper_lanes|wave32" -V Selected GPU name=AMD Radeon RX 9070 XT (RADV GFX1201) vendor=0x1002 device=0x7550 subgroup=64 1/3 Test #169: agc_driver_pixel_helper_lanes .... Passed 2/3 Test #223: agc_driver_wave32_subgroup ....... Passed 3/3 Test #234: wave32_wide_subgroup ............. Passed ``` Linux (CachyOS, kernel 7.2.9), Mesa 26.2.4, GCC 16.2.1. The full suite passes as well (399/399). In a verbose run of the GPU tests (`-R "agc_driver|wave32|shader"`), 157 selected this device and none reported a skip. AI-assisted: yes (Claude Code ran the tests and wrote this; the run is on my machine).
arreina commented 2026-10-07 18:15:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by arreina on 2026-10-07T18:15:37Z.


Same selection on a 64-wide GCN 4 subgroup (Polaris) with RADV, main at 61260bda (includes #587):

1/3 Test #144: agc_driver_pixel_helper_lanes ....   Passed    0.10 sec
2/3 Test #197: agc_driver_wave32_subgroup .......   Passed    0.04 sec
3/3 Test #208: wave32_wide_subgroup .............   Passed    0.01 sec
Selected GPU name=AMD Radeon RX 580 Series (RADV POLARIS10) vendor=0x1002 device=0x67df subgroup=64

Linux Mint 22.3, kernel 7.0.0, Mesa 25.2.8, Vulkan 1.4.318, GCC 13.3. The full suite passes: 359 of 359.

What the runs above don't show: on this card agc_driver_pixel_helper_lanes failed on builds of main without #587 (cd61f15e, 2026-10-05) and passes now. I did not bisect, so I can't attribute the change to #587 alone.

AI-assisted: yes (Claude Code ran the tests and wrote this; the run is on my machine).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6044025447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/487#issuecomment-6044025447). Originally posted by [arreina](https://github.com/arreina) on 2026-10-07T18:15:37Z. --- Same selection on a 64-wide GCN 4 subgroup (Polaris) with RADV, `main` at `61260bda` (includes #587): ``` 1/3 Test #144: agc_driver_pixel_helper_lanes .... Passed 0.10 sec 2/3 Test #197: agc_driver_wave32_subgroup ....... Passed 0.04 sec 3/3 Test #208: wave32_wide_subgroup ............. Passed 0.01 sec Selected GPU name=AMD Radeon RX 580 Series (RADV POLARIS10) vendor=0x1002 device=0x67df subgroup=64 ``` Linux Mint 22.3, kernel 7.0.0, Mesa 25.2.8, Vulkan 1.4.318, GCC 13.3. The full suite passes: 359 of 359. What the runs above don't show: on this card `agc_driver_pixel_helper_lanes` failed on builds of `main` without #587 (`cd61f15e`, 2026-10-05) and passes now. I did not bisect, so I can't attribute the change to #587 alone. AI-assisted: yes (Claude Code ran the tests and wrote this; the run is on my machine).
oneandonlydean commented 2026-10-08 08:26:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T08:26:08Z.


Fixed by #587 (ff9642245). The test now passes on 64-wide subgroups on RDNA 3 (RX 7700 XT), RDNA 4 (RX 9070 XT) and Polaris (RX 580). If it still fails on your RX 9060 XT on current main, please comment with the output and it can be reopened.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055867779 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/487#issuecomment-6055867779). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T08:26:08Z. --- Fixed by #587 (`ff9642245`). The test now passes on 64-wide subgroups on RDNA 3 (RX 7700 XT), RDNA 4 (RX 9070 XT) and Polaris (RX 580). If it still fails on your RX 9060 XT on current main, please comment with the output and it can be reopened.
Sign in to join this conversation.
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
boykopovar/AnyPS5#487
No description provided.