test: verify overlapping private LDS byte and halfword writes #866

Manually merged
github merged 2 commits from gh-pr/866/head into gh-pr/866/base 2026-11-26 22:24:42 +00:00
Owner

@⁠MrSkelee on GitHub · 2026-11-23 14:52 UTC · original
MrSkelee:feature/shader-ds-read-write → main · +45 −1 · 1 files · 2 commits · merged 2026-11-23 15:26 UTC

Lowers 5 sub-dword Local Data Share (LDS) read and write instructions in tools/compute_store_aot.py (cs_6_0) for thread-private LDS memory:

  • ds_read_i16: 16-bit signed load with sign-extension (offsets 0, 2)
  • ds_read_u8: 8-bit unsigned load with zero-extension (offsets 0..3)
  • ds_read_i8: 8-bit signed load with sign-extension (offsets 0..3)
  • ds_write_b16: 16-bit partial write with halfword masking (offsets 0, 2)
  • ds_write_b8: 8-bit partial write with byte masking (offsets 0..3)

Highlights

  • Operand & Addressing Validation:
    • Requires thread-private allocation (--lds-bytes >= 128), a verified local_x << 2 base address, and immediate s_waitcnt lgkmcnt(0) after every DS operation.
    • Enforces valid byte and halfword alignments/offsets: ds_read_i16/ds_write_b16 reject odd offsets; ds_read_u8/ds_read_i8/ds_write_b8 reject offsets > 3.
    • Rejects partial sub-dword writes without an earlier defining full-word store (ds_write_b32).
  • Offscreen Readback (WARP & Hardware):
    • Added dedicated lds_signed and lds_subwrite fixtures to tests/compute_store_check.py alongside private.
    • Compares 320 UAV words across dispatches of 1 and 3 groups against Python CPU reference bit-loops.
    • Includes negative mutation tests for sign extension, byte masking, and offset mutations that assert immediate mismatch detection.
  • Coverage: Credits 5 instructions on gfx1013 and gfx1030 under DS.

Verification

python -B tests/compute_store_check.py draw-lds-private "C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/dxc.exe" "C:/Users/andre/Desktop/Xbox2Windows/out/build/dev/offscreen_check.exe" warp
python -B tests/rdna2_tools_check.py

Local results: 3/3 LDS draw fixtures passed (0 mismatches across 320 words for 1 and 3 groups), all 3 negative mutations detected, 75/75 unit tests passed.

**@⁠MrSkelee** on GitHub · 2026-11-23 14:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/866) `MrSkelee:feature/shader-ds-read-write` → `main` · +45 −1 · 1 files · 2 commits · merged 2026-11-23 15:26 UTC Lowers 5 sub-dword Local Data Share (LDS) read and write instructions in `tools/compute_store_aot.py` (`cs_6_0`) for thread-private LDS memory: - `ds_read_i16`: 16-bit signed load with sign-extension (offsets 0, 2) - `ds_read_u8`: 8-bit unsigned load with zero-extension (offsets 0..3) - `ds_read_i8`: 8-bit signed load with sign-extension (offsets 0..3) - `ds_write_b16`: 16-bit partial write with halfword masking (offsets 0, 2) - `ds_write_b8`: 8-bit partial write with byte masking (offsets 0..3) ### Highlights - **Operand & Addressing Validation**: - Requires thread-private allocation (`--lds-bytes >= 128`), a verified `local_x << 2` base address, and immediate `s_waitcnt lgkmcnt(0)` after every DS operation. - Enforces valid byte and halfword alignments/offsets: `ds_read_i16`/`ds_write_b16` reject odd offsets; `ds_read_u8`/`ds_read_i8`/`ds_write_b8` reject offsets > 3. - Rejects partial sub-dword writes without an earlier defining full-word store (`ds_write_b32`). - **Offscreen Readback (WARP & Hardware)**: - Added dedicated `lds_signed` and `lds_subwrite` fixtures to `tests/compute_store_check.py` alongside `private`. - Compares 320 UAV words across dispatches of 1 and 3 groups against Python CPU reference bit-loops. - Includes negative mutation tests for sign extension, byte masking, and offset mutations that assert immediate mismatch detection. - **Coverage**: Credits 5 instructions on `gfx1013` and `gfx1030` under `DS`. ### Verification ```powershell python -B tests/compute_store_check.py draw-lds-private "C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/dxc.exe" "C:/Users/andre/Desktop/Xbox2Windows/out/build/dev/offscreen_check.exe" warp python -B tests/rdna2_tools_check.py ``` Local results: 3/3 LDS draw fixtures passed (0 mismatches across 320 words for 1 and 3 groups), all 3 negative mutations detected, 75/75 unit tests passed.
Lower sub-dword LDS read and write instructions (ds_read_i16, ds_read_u8, ds_read_i8, ds_write_b16, ds_write_b8) to thread-private local storage accesses in tools/compute_store_aot.py (cs_6_0).

- Operand & offset validation: ds_read_i16 at offset 0/2 with sign extension, ds_read_u8/ds_read_i8 at offsets 0..3 with zero/sign extension, ds_write_b16 at offset 0/2 with halfword masking, and ds_write_b8 at offsets 0..3 with byte masking.

- Offscreen readback: Added signed read and sub-word write fixtures to tests/compute_store_check.py verifying 320 UAV words for 1 and 3 groups, with negative mutation assertions.

- Documentation: Updated docs/experiments.md with sub-dword LDS profile details.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:24:40 +00:00
github manually merged commit e8f31c2071 into gh-pr/866/base 2026-11-26 22:24:42 +00:00
Author
Owner

@⁠stan495 on GitHub · 2026-11-23 14:58 UTC · original

Thanks for working on this! #865 has landed on main and covers the same private LDS byte and halfword operations in the compute translator, including partial writes, signed and unsigned reads, and tests for every supported offset. If there’s a case in #866 that #865 missed, it would be worth keeping as a focused follow-up. Otherwise, I think we can close this as covered by #865.

**@⁠stan495** on GitHub · 2026-11-23 14:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/866#issuecomment-7104827176) Thanks for working on this! #865 has landed on `main` and covers the same private LDS byte and halfword operations in the compute translator, including partial writes, signed and unsigned reads, and tests for every supported offset. If there’s a case in #866 that #865 missed, it would be worth keeping as a focused follow-up. Otherwise, I think we can close this as covered by #865.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 15:01 UTC · original

#865 landed the five instruction forms and the disjoint-write controls. I kept your read-before-write fixture and based it on that implementation. It now reads the same byte before the halfword write, after that write, and after an overlapping byte write as part of the full word. That checks that the earlier reads survive both overwrites and that the final write preserves the other bytes.

WARP and RTX 4060 Laptop matched the full 320-word readback for one and three groups. Dropping the halfword write mismatched the intermediate read at word 1. Dropping the byte write mismatched the final word at word 2. LLVM 15 also passed. The updated branch is test-only and is waiting for a fresh CI run.

**@⁠R0Y00** on GitHub · 2026-11-23 15:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/866#issuecomment-7104901839) #865 landed the five instruction forms and the disjoint-write controls. I kept your read-before-write fixture and based it on that implementation. It now reads the same byte before the halfword write, after that write, and after an overlapping byte write as part of the full word. That checks that the earlier reads survive both overwrites and that the final write preserves the other bytes. WARP and RTX 4060 Laptop matched the full 320-word readback for one and three groups. Dropping the halfword write mismatched the intermediate read at word 1. Dropping the byte write mismatched the final word at word 2. LLVM 15 also passed. The updated branch is test-only and is waiting for a fresh CI run.
Author
Owner

@⁠MrSkelee on GitHub · 2026-11-23 15:02 UTC · original

Awesome, thank you @⁠R0Y00! Glad the overlapping write fixture and readback checks are useful as a dedicated regression test.

**@⁠MrSkelee** on GitHub · 2026-11-23 15:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/866#issuecomment-7104923138) Awesome, thank you @⁠R0Y00! Glad the overlapping write fixture and readback checks are useful as a dedicated regression test.
This discussion has been locked. Commenting is limited to contributors.
No description provided.