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

Merged
Leyukaka merged 1 commit from upstream-pr/3330 into main 2026-11-29 08:35:39 +00:00
Leyukaka commented 2026-11-28 10:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T10:04:04Z.


Part of #3224. 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5539014702 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3330). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T10:04:04Z. --- Part of #3224. 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 commented 2026-11-28 16:19:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T16:19:48Z.


Measurement on a 600 s run of main f5a6f6ba with thread holding off (--suspend-others 0, see #3331). 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
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7242157703 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3330#issuecomment-7242157703). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T16:19:48Z. --- Measurement on a 600 s run of `main` `f5a6f6ba` with thread holding off (`--suspend-others 0`, see #3331). 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 commented 2026-11-29 05:03:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T05:03:41Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7251024883 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3330#issuecomment-7251024883). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T05:03:41Z. --- 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.
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
R0Y00/Xbox2Windows!3330
No description provided.