compute: LDS reads, writes and atomics plus s_barrier (groupshared lowering) #1534

Open
opened 2026-11-24 13:47:57 +00:00 by denn0x · 4 comments
denn0x commented 2026-11-24 13:47:57 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-24T13:47:57Z.


Problem

The compute translators have no LDS. Measured on the 349 gfx1013 compute programs (device slot 67 pipelines) that the executable created in one run past start-up, and on the 627 dispatches of one busy frame after loading. 38 programs (44 of the busy frame's dispatches) stop at a ds_*
instruction; across all programs the forms are ds_read_b64 (811 sites), ds_write_b128 (550), ds_read2_b32
(416), ds_read_b32, ds_write_b32, ds_write2_b32, ds_write2st64_b32, ds_read2st64_b32, ds_write_b64,
ds_min_u32, ds_max_u32, ds_add_u32, ds_add_rtn_u32, ds_or_b32, ds_wrxchg_rtn_b32, and s_barrier
(140 sites).

Proposal

  • groupshared uint lds[N] with N from COMPUTE_PGM_RSRC2.LDS_SIZE (bits 23:15, 512-byte units on gfx10); refuse
    above the 32 KiB D3D12 limit.
  • ds_write*_bNN addr, data offset:k stores dwords at (addr + k) >> 2; ds_write2* uses offset0/offset1
    scaled by the element size, and by 64 elements for the st64 forms. Reads mirror this.
  • ds_{add,min,max,or,and}_u32 map to Interlocked* on lds[]; the _rtn forms return the old value.
  • s_barrier maps to GroupMemoryBarrierWithGroupSync(). fxc refuses a barrier under per-lane control flow
    (X3663) even where the machine program is wave-uniform; compiling those with dxc (cs_6_0) works.
  • Stores under a non-entry exec mask need the lane guard.

A local experiment lowers these as above; with it, LDS stops no longer appear in the census.

Alternatives

Refuse every program with LDS (current behaviour).

Verification

A source-built gfx1013 fixture (LLVM 15 llvm-mc, as the existing compute_store_check.py and pixel_aot_check.py
fixtures) that uses the instructions, translated and dispatched on WARP, with the UAV read back and compared with
expected words. Include a negative control (an operand form or modifier the lowering refuses).

Checklist

  • I checked for an existing issue or pull request for this change.
  • I did not include game files, dumps, distribution links or credentials.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583243203 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1541). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-24T13:47:57Z. --- ### Problem The compute translators have no LDS. Measured on the 349 gfx1013 compute programs (device slot 67 pipelines) that the executable created in one run past start-up, and on the 627 dispatches of one busy frame after loading. 38 programs (44 of the busy frame's dispatches) stop at a `ds_*` instruction; across all programs the forms are `ds_read_b64` (811 sites), `ds_write_b128` (550), `ds_read2_b32` (416), `ds_read_b32`, `ds_write_b32`, `ds_write2_b32`, `ds_write2st64_b32`, `ds_read2st64_b32`, `ds_write_b64`, `ds_min_u32`, `ds_max_u32`, `ds_add_u32`, `ds_add_rtn_u32`, `ds_or_b32`, `ds_wrxchg_rtn_b32`, and `s_barrier` (140 sites). ### Proposal - `groupshared uint lds[N]` with N from `COMPUTE_PGM_RSRC2.LDS_SIZE` (bits 23:15, 512-byte units on gfx10); refuse above the 32 KiB D3D12 limit. - `ds_write*_bNN addr, data offset:k` stores dwords at `(addr + k) >> 2`; `ds_write2*` uses `offset0`/`offset1` scaled by the element size, and by 64 elements for the `st64` forms. Reads mirror this. - `ds_{add,min,max,or,and}_u32` map to `Interlocked*` on `lds[]`; the `_rtn` forms return the old value. - `s_barrier` maps to `GroupMemoryBarrierWithGroupSync()`. fxc refuses a barrier under per-lane control flow (X3663) even where the machine program is wave-uniform; compiling those with dxc (cs_6_0) works. - Stores under a non-entry exec mask need the lane guard. A local experiment lowers these as above; with it, LDS stops no longer appear in the census. ### Alternatives Refuse every program with LDS (current behaviour). ### Verification A source-built gfx1013 fixture (LLVM 15 `llvm-mc`, as the existing `compute_store_check.py` and `pixel_aot_check.py` fixtures) that uses the instructions, translated and dispatched on WARP, with the UAV read back and compared with expected words. Include a negative control (an operand form or modifier the lowering refuses). ### Checklist - [x] I checked for an existing issue or pull request for this change. - [x] I did not include game files, dumps, distribution links or credentials. AI-assisted (Claude Code).
Vladimir-Human commented 2026-11-25 14:05:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Vladimir-Human on 2026-11-25T13:05:17Z.


Claiming a narrow follow-up to #2327: bounded 64-bit group-shared LDS exchanges (\ds_write_b64\ and \ds_read_b64\ across \s_barrier\ in 1D compute groups) in \ ools/startup/gfx2hlsl.py, leaving \ds_read2_b32\ (#2274) and dynamic-EXEC forms untouched. PR incoming with WARP and desktop GPU readback checks plus negative controls.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163272612 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1541#issuecomment-7163272612). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-25T13:05:17Z. --- Claiming a narrow follow-up to #2327: bounded 64-bit group-shared LDS exchanges (\ds_write_b64\ and \ds_read_b64\ across \s_barrier\ in 1D compute groups) in \ ools/startup/gfx2hlsl.py\, leaving \ds_read2_b32\ (#2274) and dynamic-EXEC forms untouched. PR incoming with WARP and desktop GPU readback checks plus negative controls. AI-assisted.
Vladimir-Human commented 2026-11-25 15:02:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Vladimir-Human on 2026-11-25T14:40:52Z.


Claiming bounded 128-bit group-shared LDS exchanges (ds_write_b128 and ds_read_b128 across s_barrier in 1D compute groups) in tools/startup/gfx2hlsl.py, extending the 64-bit LDS exchange path with mixed-width uint-array interoperability, bounds/alignment refusals, Python unit tests, and WARP + desktop GPU readback checks.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7165649402 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1541#issuecomment-7165649402). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-25T14:40:52Z. --- Claiming bounded 128-bit group-shared LDS exchanges (`ds_write_b128` and `ds_read_b128` across `s_barrier` in 1D compute groups) in `tools/startup/gfx2hlsl.py`, extending the 64-bit LDS exchange path with mixed-width uint-array interoperability, bounds/alignment refusals, Python unit tests, and WARP + desktop GPU readback checks. AI-assisted.
RavenCurseBurg commented 2026-11-26 03:03:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T02:41:10Z.


I will take a test-only fix for the startup LDS readback fixtures on a secondary adapter. Their successful-path checks currently treat the hardware enumeration notice as a test error, and the mutation summary can print the notice instead of the differing word. I will reproduce on Intel UHD 770 with RTX 4060 and WARP controls, keep genuine stderr, skips and debug-layer checks, and verify the mutation diagnostics.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181027470 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1541#issuecomment-7181027470). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T02:41:10Z. --- I will take a test-only fix for the startup LDS readback fixtures on a secondary adapter. Their successful-path checks currently treat the hardware enumeration notice as a test error, and the mutation summary can print the notice instead of the differing word. I will reproduce on Intel UHD 770 with RTX 4060 and WARP controls, keep genuine stderr, skips and debug-layer checks, and verify the mutation diagnostics.
RonLogic commented 2026-11-26 05:02:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T04:37:02Z.


Independent post-merge check for the standalone compute_store_aot slice in #1566. Ran python -B tests/pyc_main.py compute_store_check draw-lds-shared <dxc> <offscreen_check> <backend> at 343dc04f with SDK DXC 1.9.2602.17 and a matching MSVC Release runner on Windows 26300.10075. In-box WARP 10.0.26100.10068 and physical RTX 4070 32.0.16.2124 both passed without skips. The D3D12 debug layer reported zero errors and warnings. The three mutations were caught at words 0, 1 and 11 on each backend. This adds a result on in-box WARP and a second physical adapter for that one-guest-wave fixture.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182750239 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1541#issuecomment-7182750239). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-26T04:37:02Z. --- Independent post-merge check for the standalone `compute_store_aot` slice in #1566. Ran `python -B tests/pyc_main.py compute_store_check draw-lds-shared <dxc> <offscreen_check> <backend>` at `343dc04f` with SDK DXC `1.9.2602.17` and a matching MSVC Release runner on Windows `26300.10075`. In-box WARP `10.0.26100.10068` and physical RTX 4070 `32.0.16.2124` both passed without skips. The D3D12 debug layer reported zero errors and warnings. The three mutations were caught at words 0, 1 and 11 on each backend. This adds a result on in-box WARP and a second physical adapter for that one-guest-wave fixture.
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
R0Y00/Xbox2Windows#1534
No description provided.