compute: lower sub-dword LDS stores and loads #3332

Manually merged
github merged 1 commit from github-bot/gh-3330 into main 2026-11-29 08:39:24 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-28 10:04 UTC · original
Leyukaka:compute-lds-write-b8-b16 → main · +479 −5 · 7 files · 1 commits · merged 2026-11-29 08:35 UTC

Part of #3226. Target branch main.

Lowers the sub-dword LDS stores and loads in the direct compute path (src/gfx1013_compute_ir.cpp, src/gfx1013_direct_compute.inl; the HLSL lower_lds gets the same forms).

  • ds_write_b8 (0x1e) and ds_write_b16 (0x1f) insert the low byte or halfword into the containing dword with a cmpxchg loop. Lanes that write different bytes of one word keep each other's bytes. Lanes that write the same byte leave one lane's value, never a mix.
  • ds_read_i8, ds_read_u8, ds_read_i16 and ds_read_u16 (0x39-0x3c) load the field with sign or zero extension.
  • ds_read_u16_d16 (0xa6) and ds_read_u16_d16_hi (0xa7) write the field into the low or high half of the destination and keep the other half.
  • An odd halfword address is skipped (no store, destination unchanged). Its guest behaviour is not established.

Tests (Windows 11, RTX 5080, SDK 10.0.26100 DXC, Release, main 3f780716 plus this commit):

  • native_lds_subword_store_controls checks the cmpxchg loop shape, including a check that fails if it is replaced by an and/or pair. native_lds_subword_read_controls checks the extraction and kept-half shape of the six load forms (seven cases, one at an odd address), and four refusals.
  • On main the store control is refused with unsupported local DS opcode 30 and the read control with unsupported local DS opcode 166.
  • native_lds_subword_store_hardware passes: b8 and b16 stores, an odd b16 offset, and two lanes storing to the same byte. native_lds_subword_read_hardware passes: a b16 store read back with d16 and d16_hi into a register whose other half holds a known value, and an odd address. The _warp variants report a capability skip (77).
  • ctest -R "native_|startup_compute|compile_dxil|salu": 531 of 532. native_scalar_lds_hardware fails as on main.
  • 882 captured compute requests, compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests: 250 to 251. The added program weighs 4,280 dispatches in that run. None is lost, and the existing output is byte-identical.

Not covered: 0xa0-0xa5 (ds_write_b8/b16_d16_hi, 8-bit d16 loads) stay refused; the HLSL lower_lds forms have no test; no source mutations were run.

**@⁠Leyukaka** on GitHub · 2026-11-28 10:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3330) `Leyukaka:compute-lds-write-b8-b16` → `main` · +479 −5 · 7 files · 1 commits · merged 2026-11-29 08:35 UTC Part of #3226. Target branch `main`. Lowers the sub-dword LDS stores and loads in the direct compute path (`src/gfx1013_compute_ir.cpp`, `src/gfx1013_direct_compute.inl`; the HLSL `lower_lds` gets the same forms). - `ds_write_b8` (0x1e) and `ds_write_b16` (0x1f) insert the low byte or halfword into the containing dword with a `cmpxchg` loop. Lanes that write different bytes of one word keep each other's bytes. Lanes that write the same byte leave one lane's value, never a mix. - `ds_read_i8`, `ds_read_u8`, `ds_read_i16` and `ds_read_u16` (0x39-0x3c) load the field with sign or zero extension. - `ds_read_u16_d16` (0xa6) and `ds_read_u16_d16_hi` (0xa7) write the field into the low or high half of the destination and keep the other half. - An odd halfword address is skipped (no store, destination unchanged). Its guest behaviour is not established. Tests (Windows 11, RTX 5080, SDK 10.0.26100 DXC, Release, `main` `3f780716` plus this commit): - `native_lds_subword_store_controls` checks the `cmpxchg` loop shape, including a check that fails if it is replaced by an `and`/`or` pair. `native_lds_subword_read_controls` checks the extraction and kept-half shape of the six load forms (seven cases, one at an odd address), and four refusals. - On `main` the store control is refused with `unsupported local DS opcode 30` and the read control with `unsupported local DS opcode 166`. - `native_lds_subword_store_hardware` passes: b8 and b16 stores, an odd b16 offset, and two lanes storing to the same byte. `native_lds_subword_read_hardware` passes: a b16 store read back with `d16` and `d16_hi` into a register whose other half holds a known value, and an odd address. The `_warp` variants report a capability skip (77). - `ctest -R "native_|startup_compute|compile_dxil|salu"`: 531 of 532. `native_scalar_lds_hardware` fails as on `main`. - 882 captured compute requests, `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`: 250 to 251. The added program weighs 4,280 dispatches in that run. None is lost, and the existing output is byte-identical. Not covered: 0xa0-0xa5 (`ds_write_b8/b16_d16_hi`, 8-bit `d16` loads) stay refused; the HLSL `lower_lds` forms have no test; no source mutations were run.
ds_write_b8 and ds_write_b16 insert the low byte or halfword into the
containing LDS dword with a compare-exchange loop, so lanes writing the
same word in one instruction leave a value from one serial order.
ds_read_u8/i8/u16/i16 load the field with zero or sign extension, and
ds_read_u16_d16 and ds_read_u16_d16_hi write it into the low or high half
of the destination and keep the other half. An odd halfword address is
skipped; its guest behaviour is not established.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 10:10:14 +00:00
github-bot force-pushed github-bot/gh-3330 from 0729658df7 to f7a1d16878 2026-11-28 14:56:36 +00:00 Compare
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-28 16:19 UTC · original

Measurement on a 600 s run of main f5a6f6ba with thread holding off (--suspend-others 0, see #3333). Of the 887 compute shaders with no translation in that run, compile_dxil gfx1013-direct-cs@0 --requests on f5a6f6ba and on this branch (f7a1d168):

Shaders Dispatches in the run
Compile with this branch, refused on main 3 367,765
of which publish a runtime manifest 1 2,266
of which compile but publish no runtime manifest (SRV kind typed_buffer_srv) 2 365,499
Compiled on main, refused here 0 0
**@⁠Leyukaka** on GitHub · 2026-11-28 16:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3330#issuecomment-7242157703) Measurement on a 600 s run of `main` `f5a6f6ba` with thread holding off (`--suspend-others 0`, see #3333). Of the 887 compute shaders with no translation in that run, `compile_dxil gfx1013-direct-cs@0 --requests` on `f5a6f6ba` and on this branch (`f7a1d168`): | | Shaders | Dispatches in the run | |---|---|---| | Compile with this branch, refused on `main` | 3 | 367,765 | | of which publish a runtime manifest | 1 | 2,266 | | of which compile but publish no runtime manifest (`SRV kind typed_buffer_srv`) | 2 | 365,499 | | Compiled on `main`, refused here | 0 | 0 |
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 05:03 UTC · original

Open for review at f7a1d168 (CI green, no conflict with main 212d4b5f). A reviewer can check native_lds_subword_store_controls and native_lds_subword_read_controls for the DXIL shape, and native_lds_subword_store_hardware and native_lds_subword_read_hardware on a hardware adapter.

**@⁠Leyukaka** on GitHub · 2026-11-29 05:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3330#issuecomment-7251024883) Open for review at `f7a1d168` (CI green, no conflict with `main` `212d4b5f`). A reviewer can check `native_lds_subword_store_controls` and `native_lds_subword_read_controls` for the DXIL shape, and `native_lds_subword_store_hardware` and `native_lds_subword_read_hardware` on a hardware adapter.
github manually merged commit 24cb374d46 into main 2026-11-29 08:39:24 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.