Fix guest wave32 GDS counter returns in compute shaders #56

Closed
philip-roy-jones wants to merge 0 commits from upstream-pr/56 into main
philip-roy-jones commented 2026-11-21 21:39:19 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by philip-roy-jones on 2026-11-21T21:39:19Z.


Library / area: tombox-xshader compute shaders

Exports changed (exports.txt rows): None

Source of the behaviour: AMD RDNA 2 ISA, section 12.13, DS_CONSUME and DS_APPEND and D3D12 wave size requirements.

On WARP, upstream ds_append and ds_consume each return eight distinct old values within a fully active 32-lane guest wave. The final counter total is correct. The existing test skips the per-wave return assertion on WARP. Upstream already includes the M0 addressing change from #21.

Straight-line compute shaders now form a guest EXEC mask in group memory. The first active lane updates the counter once and broadcasts its old value. Counters inside control flow or alongside the 32 KiB LDS mirror require a native wave32. The WARP regression covers full, partial and empty masks, wraparound, consecutive updates and the reserved GDS boundary.

  • cargo test --locked -p tombox-xshader --no-fail-fast on Windows/WARP passed 134 tests on 0fc7295 and 135 on 1c4638e. Both runs had zero failures and the same 12 ignored tests.

  • cargo test --locked -p tombox-xshader --test exec exec_mem::gds:: passed all three upstream cases and all four on this branch. Both opcodes now return one old value per active guest wave on WARP.

  • cargo test --locked --release -p tombox-xshader --test exec exec_mem::gds:: passed all four branch tests. DXC compiled the native path. Execution of that path still needs compatible hardware.

  • Guest wave64 remains unsupported. A separate Shader Model 5.1 FXC smoke check failed on the shared uint64_t preamble on both revisions.

  • cargo test -p tombox-xshader passes

  • No game or console files and no binaries included

  • No fake success; anything not possible is left missing with a note

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6534719482 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/56). Originally posted by [philip-roy-jones](https://github.com/philip-roy-jones) on 2026-11-21T21:39:19Z. --- **Library / area:** `tombox-xshader` compute shaders **Exports changed (exports.txt rows):** None **Source of the behaviour:** [AMD RDNA 2 ISA, section 12.13, DS_CONSUME and DS_APPEND](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content#page=204) and [D3D12 wave size requirements](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_WaveSize.html). On WARP, upstream `ds_append` and `ds_consume` each return eight distinct old values within a fully active 32-lane guest wave. The final counter total is correct. The existing test skips the per-wave return assertion on WARP. Upstream already includes the M0 addressing change from [#21](https://github.com/omonkeyz/xbox-emulator/pull/21#issuecomment-7069201721). Straight-line compute shaders now form a guest EXEC mask in group memory. The first active lane updates the counter once and broadcasts its old value. Counters inside control flow or alongside the 32 KiB LDS mirror require a native wave32. The WARP regression covers full, partial and empty masks, wraparound, consecutive updates and the reserved GDS boundary. - `cargo test --locked -p tombox-xshader --no-fail-fast` on Windows/WARP passed 134 tests on `0fc7295` and 135 on `1c4638e`. Both runs had zero failures and the same 12 ignored tests. - `cargo test --locked -p tombox-xshader --test exec exec_mem::gds::` passed all three upstream cases and all four on this branch. Both opcodes now return one old value per active guest wave on WARP. - `cargo test --locked --release -p tombox-xshader --test exec exec_mem::gds::` passed all four branch tests. DXC compiled the native path. Execution of that path still needs compatible hardware. - Guest wave64 remains unsupported. A separate Shader Model 5.1 FXC smoke check failed on the shared `uint64_t` preamble on both revisions. - [x] `cargo test -p tombox-xshader` passes - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
QuentinDanblon commented 2026-11-21 21:44:43 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-21T21:44:43Z.


FYI, related work: fix/wave32-lane-halves (PR coming) maps a wave32 guest lane L to host lane (WaveGetLaneIndex() & ~31) | (L & 31) for v_readlane/v_writelane, the DPP row mask and the STATUS EXECZ/VCCZ bits, for hosts that run 64-lane waves. It doesn't touch GDS. Your guest-EXEC-in-group-memory approach for ds_append/consume shouldn't conflict, but we both edit hlsl.rs, so whoever lands second rebases.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7069689478 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/56#issuecomment-7069689478). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-21T21:44:43Z. --- FYI, related work: `fix/wave32-lane-halves` (PR coming) maps a wave32 guest lane L to host lane `(WaveGetLaneIndex() & ~31) | (L & 31)` for v_readlane/v_writelane, the DPP row mask and the STATUS EXECZ/VCCZ bits, for hosts that run 64-lane waves. It doesn't touch GDS. Your guest-EXEC-in-group-memory approach for ds_append/consume shouldn't conflict, but we both edit `hlsl.rs`, so whoever lands second rebases.

Pull request closed

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
omonkeyz/xbox-emulator!56
No description provided.