shader: lower ds_write_*_d16_hi and ds_read_{u8,i8}_d16* in native compute #3786

Manually merged
github merged 3 commits from github-bot/gh-3784 into gh-pr/3784/base 2026-12-03 15:09:00 +00:00 AGit
Owner

@⁠R0D4X on GitHub · 2026-12-01 21:52 UTC · original
R0D4X:shader/native-lds-d16-subdword → main · +68 −23 · 5 files · 3 commits · merged 2026-12-03 15:03 UTC

Refs #3226, #2935

Summary

Completes the GFX10 D16 sub-DWORD LDS family alongside ds_read_u16_d16 / ds_read_u16_d16_hi (0xa6, 0xa7) in gfx1013_compute_ir and the direct C++ compute frontend:

  • 0xa0 (ds_write_b8_d16_hi): writes (v[data0] >> 16) & 0xff to LDS byte address.
  • 0xa1 (ds_write_b16_d16_hi): writes (v[data0] >> 16) & 0xffff to even LDS halfword address (skipping odd effective addresses, matching ds_write_b16).
  • 0xa2 (ds_read_u8_d16) / 0xa3 (ds_read_u8_d16_hi): zero-extends 1 LDS byte to 16 bits into the low/high half of v[dst], preserving the untouched 16-bit half.
  • 0xa4 (ds_read_i8_d16) / 0xa5 (ds_read_i8_d16_hi): sign-extends 1 LDS byte to 16 bits into the low/high half of v[dst], preserving the untouched 16-bit half.

Changes

  • src/gfx1013_compute_ir.h and src/gfx1013_compute_ir.cpp:
    • Add bool store_d16_hi to LocalDataAccess and decode 0xa0..0xa5 in decode_local_data.
    • Shift v[data0] right by 16 bits in lower_lds when store_d16_hi is set; mask signed field to 16 bits and clear the full 16-bit destination half (~(0xffffu << bit)) when read_d16 is set.
  • src/gfx1013_direct_compute.inl:
    • Mirror both behaviors in the direct DXIL LDS lowering (leaving 0xa6 / 0xa7 DXIL bit-for-bit unchanged).
  • tests/native_lds_subword_read_check.py:
    • Verify exact DXIL shape for 0xa2..0xa5 alongside 0xa6, 0xa7, 0x39..0x3c; update the unsupported-opcode refusal control from 0xa2 (162) to 0xa8 (168).
    • Add hardware execution cases for 0xa2, 0xa3, 0xa4, 0xa5 (including sign-extension of 0xb3 -> 0xffb3 with preserved high/low halves), 0xa0 (ds_write_b8_d16_hi), 0xa1 (ds_write_b16_d16_hi), and the odd-offset skip control for 0xa1.

Verification

  • Commit: f4882407 (based on main 158ef794)
  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK / DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), Microsoft Basic Render Driver (10.0.26100.9818), D3D12 debug layer enabled (debug_errors=0 debug_warnings=0).

Commands and results

ctest --preset dev --no-tests=error -R '^(native_lds_subword_read|gfx1013_compute_ir)' -V
ctest --preset release --no-tests=error -R '^(native_lds_subword_read|gfx1013_compute_ir_all)' -V
  • dev (Debug): 92/92 Passed (89/89 gfx1013_compute_ir_* unit + mutation tests PASS; native_lds_subword_read_controls PASS; native_lds_subword_read_hardware PASS in 3.92 s on RTX 5080, all 10 cases × 336 texture words matched; native_lds_subword_read_warp Skipped (77) — shader wave32 fixture requires SM 6.6, WaveOps, and a 32-lane wave).
  • release (/O2): gfx1013_compute_ir_all (83/83) Passed, native_lds_subword_read_controls Passed, native_lds_subword_read_hardware Passed (3.72 s on RTX 5080), native_lds_subword_read_warp Skipped (77).

Fail-first / mutation control

Disabling if (op.store_d16_hi) in src/gfx1013_direct_compute.inl and rebuilding compile_dxil fails native_lds_subword_read_hardware (exit 8) on the 0xa0 case (expected=654300a2 actual=654300c0).

Pure-Python checks

.\out\pe-env\Scripts\python.exe -B tests\docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py
  • Both PASS.

Scope note

This verifies source-built gfx1013 LDS subword compute fixtures through compile_dxil and offscreen_check on the RTX 5080 and WARP; it does not establish full-title startup or frame rate.

AI-assisted.

**@⁠R0D4X** on GitHub · 2026-12-01 21:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784) `R0D4X:shader/native-lds-d16-subdword` → `main` · +68 −23 · 5 files · 3 commits · merged 2026-12-03 15:03 UTC Refs #3226, #2935 ## Summary Completes the GFX10 D16 sub-DWORD LDS family alongside `ds_read_u16_d16` / `ds_read_u16_d16_hi` (`0xa6`, `0xa7`) in `gfx1013_compute_ir` and the direct C++ compute frontend: - `0xa0` (`ds_write_b8_d16_hi`): writes `(v[data0] >> 16) & 0xff` to LDS byte address. - `0xa1` (`ds_write_b16_d16_hi`): writes `(v[data0] >> 16) & 0xffff` to even LDS halfword address (skipping odd effective addresses, matching `ds_write_b16`). - `0xa2` (`ds_read_u8_d16`) / `0xa3` (`ds_read_u8_d16_hi`): zero-extends 1 LDS byte to 16 bits into the low/high half of `v[dst]`, preserving the untouched 16-bit half. - `0xa4` (`ds_read_i8_d16`) / `0xa5` (`ds_read_i8_d16_hi`): sign-extends 1 LDS byte to 16 bits into the low/high half of `v[dst]`, preserving the untouched 16-bit half. ### Changes - `src/gfx1013_compute_ir.h` and `src/gfx1013_compute_ir.cpp`: - Add `bool store_d16_hi` to `LocalDataAccess` and decode `0xa0..0xa5` in `decode_local_data`. - Shift `v[data0]` right by 16 bits in `lower_lds` when `store_d16_hi` is set; mask signed `field` to 16 bits and clear the full 16-bit destination half (`~(0xffffu << bit)`) when `read_d16` is set. - `src/gfx1013_direct_compute.inl`: - Mirror both behaviors in the direct DXIL LDS lowering (leaving `0xa6` / `0xa7` DXIL bit-for-bit unchanged). - `tests/native_lds_subword_read_check.py`: - Verify exact DXIL shape for `0xa2..0xa5` alongside `0xa6`, `0xa7`, `0x39..0x3c`; update the unsupported-opcode refusal control from `0xa2` (`162`) to `0xa8` (`168`). - Add hardware execution cases for `0xa2`, `0xa3`, `0xa4`, `0xa5` (including sign-extension of `0xb3` -> `0xffb3` with preserved high/low halves), `0xa0` (`ds_write_b8_d16_hi`), `0xa1` (`ds_write_b16_d16_hi`), and the odd-offset skip control for `0xa1`. ## Verification - **Commit:** `f4882407` (based on `main` `158ef794`) - **Environment:** Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230`, Windows SDK / DXC `10.0.26100.0`, NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2140`), Microsoft Basic Render Driver (`10.0.26100.9818`), D3D12 debug layer enabled (`debug_errors=0 debug_warnings=0`). ### Commands and results ```powershell ctest --preset dev --no-tests=error -R '^(native_lds_subword_read|gfx1013_compute_ir)' -V ctest --preset release --no-tests=error -R '^(native_lds_subword_read|gfx1013_compute_ir_all)' -V ``` - `dev` (Debug): **92/92 Passed** (`89/89 gfx1013_compute_ir_*` unit + mutation tests PASS; `native_lds_subword_read_controls` PASS; `native_lds_subword_read_hardware` PASS in 3.92 s on RTX 5080, all 10 cases × 336 texture words matched; `native_lds_subword_read_warp` **Skipped (77)** — `shader wave32 fixture requires SM 6.6, WaveOps, and a 32-lane wave`). - `release` (`/O2`): `gfx1013_compute_ir_all` (83/83) **Passed**, `native_lds_subword_read_controls` **Passed**, `native_lds_subword_read_hardware` **Passed** (3.72 s on RTX 5080), `native_lds_subword_read_warp` **Skipped (77)**. ### Fail-first / mutation control Disabling `if (op.store_d16_hi)` in `src/gfx1013_direct_compute.inl` and rebuilding `compile_dxil` fails `native_lds_subword_read_hardware` (exit 8) on the `0xa0` case (`expected=654300a2 actual=654300c0`). ### Pure-Python checks ```powershell .\out\pe-env\Scripts\python.exe -B tests\docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py ``` - Both **PASS**. ## Scope note This verifies source-built gfx1013 LDS subword compute fixtures through `compile_dxil` and `offscreen_check` on the RTX 5080 and WARP; it does not establish full-title startup or frame rate. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 21:55:43 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 01:55 UTC · original

The reviewed head passed Windows and Linux CI, but GitHub reports a merge conflict against current main. Please rebase and retain the LocalDataAccess default initializers from #3796 when adding store_d16_hi. Please rerun the subword LDS controls on the new head.

**@⁠R0Y00** on GitHub · 2026-12-02 01:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784#issuecomment-7332269007) The reviewed head passed Windows and Linux CI, but GitHub reports a merge conflict against current main. Please rebase and retain the `LocalDataAccess` default initializers from #3796 when adding `store_d16_hi`. Please rerun the subword LDS controls on the new head.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 01:08 UTC · original · reviewed

Independently tested c49f0cde with MSVC Debug, Windows 11 build 26300. ctest --preset dev --no-tests=error -j 1 -V -R "^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$": 5 passed, 2 capability skips, 0 failures. RTX 4060 Laptop (616.56) matched 4,704 texture words across the read and store fixture cases. WARP reported skip 77 for both wave32 draws, with the debug layer enabled. Git still reports a single conflict in gfx1013_compute_ir.h; please retain the existing default initializers and rerun this selection after resolving it.

**@⁠R0Y00** on GitHub · 2026-12-03 01:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784#pullrequestreview-6161933403) · **reviewed** Independently tested c49f0cde with MSVC Debug, Windows 11 build 26300. ctest --preset dev --no-tests=error -j 1 -V -R "^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$": 5 passed, 2 capability skips, 0 failures. RTX 4060 Laptop (616.56) matched 4,704 texture words across the read and store fixture cases. WARP reported skip 77 for both wave32 draws, with the debug layer enabled. Git still reports a single conflict in gfx1013_compute_ir.h; please retain the existing default initializers and rerun this selection after resolving it.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 07:15 UTC · original

I tested c49f0cde against main 29bb2aed, keeping the initialized LocalDataAccess fields and adding bool store_d16_hi = false. MSVC Debug built both targets. The RTX 4060 Laptop read and store fixtures passed, and both WARP fixtures reported capability skip 77. The two compiler controls failed for the same reason: 0xa8 is rejected by the instruction decoder (unknown gfx1013 opcode 168) before reaching the LDS lowering assertion. I verified a replacement control on the trial tree: use recognized 0x22 and expect unsupported local DS opcode 34, passing data0=1 in the read fixture and retaining the store fixture’s existing data operand. Both compiler controls then passed. Please keep that negative-control coverage when rebasing.

**@⁠R0Y00** on GitHub · 2026-12-03 07:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784#issuecomment-7370783895) I tested `c49f0cde` against `main` `29bb2aed`, keeping the initialized `LocalDataAccess` fields and adding `bool store_d16_hi = false`. MSVC Debug built both targets. The RTX 4060 Laptop read and store fixtures passed, and both WARP fixtures reported capability skip 77. The two compiler controls failed for the same reason: `0xa8` is rejected by the instruction decoder (`unknown gfx1013 opcode 168`) before reaching the LDS lowering assertion. I verified a replacement control on the trial tree: use recognized `0x22` and expect `unsupported local DS opcode 34`, passing `data0=1` in the read fixture and retaining the store fixture’s existing data operand. Both compiler controls then passed. Please keep that negative-control coverage when rebasing.
github-bot force-pushed github-bot/gh-3784 from c49f0cdebd to 1e0604e5a6 2026-12-03 14:08:19 +00:00 Compare
Author
Owner

@⁠R0D4X on GitHub · 2026-12-03 14:07 UTC · original

Rebased onto upstream/main (e7277aa4) at 1e0604e5:

  • Resolved src/gfx1013_compute_ir.h retaining all LocalDataAccess default initializers and adding bool store_d16_hi = false;.
  • Updated the negative controls in tests/native_lds_subword_read_check.py (0x22, {'data0': 1}) and tests/native_lds_subword_store_check.py (0x22, {}) to expect unsupported local DS opcode 34.

Verification (1e0604e5)

  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230 (Debug), Windows SDK / DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), Microsoft Basic Render Driver (10.0.26100.9818), D3D12 debug layer enabled.
  • ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$': 5 passed, 2 skipped (77), 0 failed (gfx1013_compute_ir_all, native_lds_subword_read_controls, native_lds_subword_read_hardware, native_lds_subword_store_controls, native_lds_subword_store_hardware passed; native_lds_subword_read_warp and native_lds_subword_store_warp skipped 77 on WARP for lacking 32-lane waves).
**@⁠R0D4X** on GitHub · 2026-12-03 14:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784#issuecomment-7380917868) Rebased onto `upstream/main` (`e7277aa4`) at `1e0604e5`: - Resolved `src/gfx1013_compute_ir.h` retaining all `LocalDataAccess` default initializers and adding `bool store_d16_hi = false;`. - Updated the negative controls in `tests/native_lds_subword_read_check.py` (`0x22`, `{'data0': 1}`) and `tests/native_lds_subword_store_check.py` (`0x22`, `{}`) to expect `unsupported local DS opcode 34`. ### Verification (`1e0604e5`) - **Environment:** Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230` (Debug), Windows SDK / DXC `10.0.26100.0`, NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2140`), Microsoft Basic Render Driver (`10.0.26100.9818`), D3D12 debug layer enabled. - `ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$'`: **5 passed, 2 skipped (77), 0 failed** (`gfx1013_compute_ir_all`, `native_lds_subword_read_controls`, `native_lds_subword_read_hardware`, `native_lds_subword_store_controls`, `native_lds_subword_store_hardware` passed; `native_lds_subword_read_warp` and `native_lds_subword_store_warp` skipped 77 on WARP for lacking 32-lane waves).
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 14:24 UTC · original · requested changes

Independent MSVC Debug run on 1e0604e5, Windows 11 build 26300: ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$' yielded 5 passes and 2 wave32 capability skips on inbox WARP 10.0.26100.9818. RTX 4060 Laptop 32.0.16.1656 passed. The revised 0x22 diagnostics are now covered.

The committed store fixture still only runs 0x1e and 0x1f. I temporarily disabled the high-half right shift in the direct lowering and the committed hardware test still passed. Please add coverage for 0xa0 and 0xa1 using different low/high halves, including an odd-address refusal/no-write case for 0xa1. In a local extension of the existing oracle I added 0xa0 at offset 4 and 0xa1 at offsets 4 and 5 and compared the source shifted right by 16. The unmodified compiler matched all 336 words in each new case on RTX. This pins the new behavior with the existing source-built fixture.

**@⁠R0Y00** on GitHub · 2026-12-03 14:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784#pullrequestreview-6171670110) · **requested changes** Independent MSVC Debug run on 1e0604e5, Windows 11 build 26300: `ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$'` yielded 5 passes and 2 wave32 capability skips on inbox WARP 10.0.26100.9818. RTX 4060 Laptop 32.0.16.1656 passed. The revised 0x22 diagnostics are now covered. The committed store fixture still only runs 0x1e and 0x1f. I temporarily disabled the high-half right shift in the direct lowering and the committed hardware test still passed. Please add coverage for 0xa0 and 0xa1 using different low/high halves, including an odd-address refusal/no-write case for 0xa1. In a local extension of the existing oracle I added 0xa0 at offset 4 and 0xa1 at offsets 4 and 5 and compared the source shifted right by 16. The unmodified compiler matched all 336 words in each new case on RTX. This pins the new behavior with the existing source-built fixture.
Author
Owner

@⁠R0D4X on GitHub · 2026-12-03 14:39 UTC · original

Added 0xa0 (ds_write_b8_d16_hi) and 0xa1 (ds_write_b16_d16_hi) coverage to tests/native_lds_subword_store_check.py in fb75dc98:

  • Added (0xa0, 4, 255, True), (0xa1, 4, 65535, True), and (0xa1, 5, 65535, True) (odd-address no-write control) to CASES using DATA = 0x91a2b3c0 (distinct low/high halves).
  • Verified the lshr i32 ..., 16 shift in check_shape() (controls) and compared against ((DATA | lane) >> 16) in hardware().
  • Verified fail-first mutation: disabling if (op.store_d16_hi) right-shift in src/gfx1013_direct_compute.inl fails both native_lds_subword_store_controls and native_lds_subword_store_hardware.

Verification (fb75dc98)

  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230 (Debug), Windows SDK / DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), Microsoft Basic Render Driver (10.0.26100.9818), D3D12 debug layer enabled.
  • ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$': 5 passed, 2 skipped (77), 0 failed (RTX 5080 matched all 336 texture words on 0x1e, 0x1f offsets 4/5, 0xa0 offset 4, 0xa1 offsets 4/5, and contended 0x1e; WARP skipped 77 for lacking 32-lane waves).
**@⁠R0D4X** on GitHub · 2026-12-03 14:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784#issuecomment-7381820626) Added `0xa0` (`ds_write_b8_d16_hi`) and `0xa1` (`ds_write_b16_d16_hi`) coverage to `tests/native_lds_subword_store_check.py` in `fb75dc98`: - Added `(0xa0, 4, 255, True)`, `(0xa1, 4, 65535, True)`, and `(0xa1, 5, 65535, True)` (odd-address no-write control) to `CASES` using `DATA = 0x91a2b3c0` (distinct low/high halves). - Verified the `lshr i32 ..., 16` shift in `check_shape()` (`controls`) and compared against `((DATA | lane) >> 16)` in `hardware()`. - Verified fail-first mutation: disabling `if (op.store_d16_hi)` right-shift in `src/gfx1013_direct_compute.inl` fails both `native_lds_subword_store_controls` and `native_lds_subword_store_hardware`. ### Verification (`fb75dc98`) - **Environment:** Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230` (Debug), Windows SDK / DXC `10.0.26100.0`, NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2140`), Microsoft Basic Render Driver (`10.0.26100.9818`), D3D12 debug layer enabled. - `ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$'`: **5 passed, 2 skipped (77), 0 failed** (RTX 5080 matched all 336 texture words on `0x1e`, `0x1f` offsets 4/5, `0xa0` offset 4, `0xa1` offsets 4/5, and contended `0x1e`; WARP skipped 77 for lacking 32-lane waves).
github-bot changed target branch from main to gh-pr/3784/base 2026-12-03 15:08:52 +00:00
github manually merged commit fb75dc98aa into gh-pr/3784/base 2026-12-03 15:09:00 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 15:03 UTC · original · approved these changes

Re-reviewed fb75dc98. The C++ register defaults are retained and the store fixture now includes 0xa0/0xa1, deliberately different high and low halves, and the odd halfword offset. Windows 11 build 26300, MSVC Debug: ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$' reported 5 passes and 2 four-lane WARP capability skips (10.0.26100.9818). RTX 4060 Laptop 32.0.16.1656 matched 336 texture words in each of the three new cases. Temporarily disabling the high-half shift now fails the lshr 16 IR assertion. Restoring the compiler passes again. This resolves my coverage request.

**@⁠R0Y00** on GitHub · 2026-12-03 15:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3784#pullrequestreview-6172398792) · **approved these changes** Re-reviewed fb75dc98. The C++ register defaults are retained and the store fixture now includes 0xa0/0xa1, deliberately different high and low halves, and the odd halfword offset. Windows 11 build 26300, MSVC Debug: `ctest --preset dev --no-tests=error -j 1 -V -R '^(native_lds_subword_(read|store)_(controls|warp|hardware)|gfx1013_compute_ir_all)$'` reported 5 passes and 2 four-lane WARP capability skips (10.0.26100.9818). RTX 4060 Laptop 32.0.16.1656 matched 336 texture words in each of the three new cases. Temporarily disabling the high-half shift now fails the lshr 16 IR assertion. Restoring the compiler passes again. This resolves my coverage request.
This discussion has been locked. Commenting is limited to contributors.
No description provided.