shader: lower 8 scratch load and store instructions in pixel_aot (FLAT) #777

Merged
MrSkelee merged 2 commits from upstream-pr/783 into main 2026-11-23 14:35:22 +00:00
MrSkelee commented 2026-11-23 03:01:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MrSkelee on 2026-11-23T03:01:50Z.


Lowers 8 FLAT scratch memory load and store instructions in tools/pixel_aot.py:

  • scratch_load_dword, scratch_load_dwordx2, scratch_load_dwordx3, scratch_load_dwordx4
  • scratch_store_dword, scratch_store_dwordx2, scratch_store_dwordx3, scratch_store_dwordx4

Highlights

  • Translates to thread-private local storage in HLSL (uint scratch[256] = (uint[256])0;).
  • Validation & Controls: Enforces 12-bit signed dword-aligned immediate offsets (-2048..2047), saddr SGPR bases, and vaddr VGPR offsets. Rejects out-of-range registers (> v255, > s105), unaligned offsets, simultaneous active vaddr and saddr, span count mismatches, unsupported modifiers (lds, clamp), and non-entry masks.
  • Offscreen Readback (WARP & Hardware): Added check_flat_scratch_draws testing bit-exact integer exports across 2 multi-dword groups over 5 constant sets, with 5 negative mutations verifying mismatch detection.
  • Binary Roundtrip: Added both groups to check_binary() for LLVM 15 parity.
  • Coverage: Credits 8/130 forms on gfx1013 and 8/133 forms on gfx1030 under FLAT.

Verification

ctest --preset dev -R "pixel_aot_flat_scratch_warp" -V

Local results: 1/1 test passed (0.83s).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6551360942 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/783). Originally posted by [MrSkelee](https://github.com/MrSkelee) on 2026-11-23T03:01:50Z. --- Lowers 8 FLAT scratch memory load and store instructions in tools/pixel_aot.py: - `scratch_load_dword`, `scratch_load_dwordx2`, `scratch_load_dwordx3`, `scratch_load_dwordx4` - `scratch_store_dword`, `scratch_store_dwordx2`, `scratch_store_dwordx3`, `scratch_store_dwordx4` ### Highlights - Translates to thread-private local storage in HLSL (`uint scratch[256] = (uint[256])0;`). - Validation & Controls: Enforces 12-bit signed dword-aligned immediate offsets (-2048..2047), saddr SGPR bases, and vaddr VGPR offsets. Rejects out-of-range registers (> v255, > s105), unaligned offsets, simultaneous active vaddr and saddr, span count mismatches, unsupported modifiers (`lds`, `clamp`), and non-entry masks. - Offscreen Readback (WARP & Hardware): Added `check_flat_scratch_draws` testing bit-exact integer exports across 2 multi-dword groups over 5 constant sets, with 5 negative mutations verifying mismatch detection. - Binary Roundtrip: Added both groups to `check_binary()` for LLVM 15 parity. - Coverage: Credits 8/130 forms on gfx1013 and 8/133 forms on gfx1030 under FLAT. ### Verification ```powershell ctest --preset dev -R "pixel_aot_flat_scratch_warp" -V ``` Local results: 1/1 test passed (0.83s).
upstream-sync closed this pull request 2026-11-24 06:44:46 +00:00
R0Y00 commented 2026-11-24 06:48:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T03:48:13Z.


The fixture covers the in-range, previously written case. The lowerer also accepts dynamic bases without proving their effective alignment or that the entire access fits the 1 KiB frame. It rounds the address down and reads from a zero-initialized array even when no store defined those words. Please scope the first version to effective addresses whose full access is provably aligned and in bounds, and reject reads without an earlier defining store. Add rejection controls for a dynamic, unproven access and a load before any store. Please also show how the load wait is preserved, or reject a consumer before the matching wait.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7091038305 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/783#issuecomment-7091038305). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T03:48:13Z. --- The fixture covers the in-range, previously written case. The lowerer also accepts dynamic bases without proving their effective alignment or that the entire access fits the 1 KiB frame. It rounds the address down and reads from a zero-initialized array even when no store defined those words. Please scope the first version to effective addresses whose full access is provably aligned and in bounds, and reject reads without an earlier defining store. Add rejection controls for a dynamic, unproven access and a load before any store. Please also show how the load wait is preserved, or reject a consumer before the matching wait.
R0Y00 commented 2026-11-24 06:49:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T14:19:50Z.


Your latest revision establishes the scratch frame bounds and rejects reads of unwritten words. I fixed one remaining wait case: after an earlier image sample, a partial VM wait could release a new scratch result too soon because it had sequence number zero. Both partial-wait spellings now keep that result pending; a full wait releases it. The scratch integer readback still passes on WARP and RTX 4060 Laptop, and LLVM 15 and the docs check passed. GitHub CI is rerunning.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7103834318 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/783#issuecomment-7103834318). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T14:19:50Z. --- Your latest revision establishes the scratch frame bounds and rejects reads of unwritten words. I fixed one remaining wait case: after an earlier image sample, a partial VM wait could release a new scratch result too soon because it had sequence number zero. Both partial-wait spellings now keep that result pending; a full wait releases it. The scratch integer readback still passes on WARP and RTX 4060 Laptop, and LLVM 15 and the docs check passed. GitHub CI is rerunning.
MrSkelee commented 2026-11-24 06:49:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MrSkelee on 2026-11-23T14:26:52Z.


Thanks for catching the partial VM wait sequence number edge case and verifying on hardware Pulled the update locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7104011573 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/783#issuecomment-7104011573). Originally posted by [MrSkelee](https://github.com/MrSkelee) on 2026-11-23T14:26:52Z. --- Thanks for catching the partial VM wait sequence number edge case and verifying on hardware Pulled the update locally.
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!777
No description provided.