shader: lower gfx1013 float image stores and mip loads #1604

Merged
Jess-Doit merged 5 commits from upstream-pr/1611 into main 2026-11-24 16:18:39 +00:00
Jess-Doit commented 2026-11-24 15:02:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T15:02:04Z.


Refs #1545

Change

Require DMASK 0xf for the gfx1013 2D RGBA32 FLOAT image_store at u0.
Four consecutive VGPRs supply R, G, B and A. A sparse store is refused
before emission. image_load_mip still accepts sparse masks on a separate
float4 SRV at t0 and uses the last address VGPR in Load(int3(x, y, mip)).

The source-built shader loads red and blue from mip 1 into v14 and v15.
It stores those two words and distinct constants from v16 and v17 into 16
unique destination texels. The CPU reference checks all 1,344 DWORDs, including
1,280 sentinels in the surrounding texels and untouched mips. The source and
destination textures are separate. The caller supplies distinct destinations
per invocation. Translation controls reject a sparse store, D16, non-2D forms,
image atomics, overlapping or swapped descriptors, and missing waits.
The sparse-store control was accepted and zero-filled by 3ca76c4f and is
refused by the revised lowerer.

Verification

Tested aa87ce9a451f98cb602752709ed811b7035a60b3 on parent 3ca76c4f735dc175fcaa3203a4916f4b7ad3239f.
Windows 10 22H2 build 19045.6456, Windows SDK 10.0.26100.0 DXC targeting cs_6_0.

Adapter Driver Baseline Swapped sparse-load channels Forced mip zero
GTX 1060 6 GB 32.0.15.6094 1,344/1,344 32 mismatches 32 mismatches
In-box WARP 10.0.19041.5794 1,344/1,344 32 mismatches 32 mismatches

Both controls first differed at mip 0, word 0. The swapped sparse load read
3f100004 and forced mip zero read 3f000000, each against 3f100000.
The D3D12 debug layer was enabled and reported zero warnings and errors in
the new dispatches. Debug passed 25 tests, covering all 24 compute image tests
and the docs link check. Release passed both new adapter tests. Both runs had
zero failures and zero skips.

. .\tools\dev.ps1
$env:VULKAN_SDK = 'C:\VulkanSDK\1.4.363.0'
$env:XBOX2WINDOWS_ADAPTER = '1060'
$env:X2W_D3D12_DEBUG = '1'
$venvPython = (Resolve-Path 'out/pe-env/Scripts/python.exe').Path
foreach ($preset in 'dev', 'release') {
    cmake --preset $preset "-DINTAKE_PYTHON:FILEPATH=$venvPython"
    cmake --build --preset $preset --target offscreen_check -j 2
}
ctest --preset dev --no-tests=error -j 1 -R '^(compute_store_aot_.*(image|texture|mimg).*|docs_links)$' -V
ctest --preset release --no-tests=error -j 1 -R '^compute_store_aot_gfx1013_image_store_(warp|hardware)$' -V

An independent rerun of aa87ce9a in Debug on the same host passed 24/24:
ctest --preset dev --no-tests=error -R '^compute_store_aot_.*(image|texture|mimg)'.

#1608 has merged. The merge with main keeps both lower() keywords (image_srv_descriptor and rsrc2).
After that merge, Debug passed 28/28 on the same host: all compute image, texture and MIMG tests,
compute_store_aot_{warp,hardware} and compute_entry_layout_{warp,hardware}.

Local LLVM 23.1.6 reproduced the recorded bytes and disassembled them back to
the fixture instructions. The Ubuntu job runs the LLVM 15 word, disassembly
and container CLI checks:

python3 -B tests/compute_mimg_float_store_check.py --binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1

AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584767098 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1611). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T15:02:04Z. --- Refs #1545 ### Change Require DMASK `0xf` for the gfx1013 2D RGBA32 FLOAT `image_store` at `u0`. Four consecutive VGPRs supply R, G, B and A. A sparse store is refused before emission. `image_load_mip` still accepts sparse masks on a separate float4 SRV at `t0` and uses the last address VGPR in `Load(int3(x, y, mip))`. The source-built shader loads red and blue from mip 1 into v14 and v15. It stores those two words and distinct constants from v16 and v17 into 16 unique destination texels. The CPU reference checks all 1,344 DWORDs, including 1,280 sentinels in the surrounding texels and untouched mips. The source and destination textures are separate. The caller supplies distinct destinations per invocation. Translation controls reject a sparse store, D16, non-2D forms, image atomics, overlapping or swapped descriptors, and missing waits. The sparse-store control was accepted and zero-filled by `3ca76c4f` and is refused by the revised lowerer. ### Verification Tested `aa87ce9a451f98cb602752709ed811b7035a60b3` on parent `3ca76c4f735dc175fcaa3203a4916f4b7ad3239f`. Windows 10 22H2 build 19045.6456, Windows SDK 10.0.26100.0 DXC targeting `cs_6_0`. | Adapter | Driver | Baseline | Swapped sparse-load channels | Forced mip zero | |---|---|---|---|---| | GTX 1060 6 GB | 32.0.15.6094 | 1,344/1,344 | 32 mismatches | 32 mismatches | | In-box WARP | 10.0.19041.5794 | 1,344/1,344 | 32 mismatches | 32 mismatches | Both controls first differed at mip 0, word 0. The swapped sparse load read `3f100004` and forced mip zero read `3f000000`, each against `3f100000`. The D3D12 debug layer was enabled and reported zero warnings and errors in the new dispatches. Debug passed 25 tests, covering all 24 compute image tests and the docs link check. Release passed both new adapter tests. Both runs had zero failures and zero skips. ```powershell . .\tools\dev.ps1 $env:VULKAN_SDK = 'C:\VulkanSDK\1.4.363.0' $env:XBOX2WINDOWS_ADAPTER = '1060' $env:X2W_D3D12_DEBUG = '1' $venvPython = (Resolve-Path 'out/pe-env/Scripts/python.exe').Path foreach ($preset in 'dev', 'release') { cmake --preset $preset "-DINTAKE_PYTHON:FILEPATH=$venvPython" cmake --build --preset $preset --target offscreen_check -j 2 } ctest --preset dev --no-tests=error -j 1 -R '^(compute_store_aot_.*(image|texture|mimg).*|docs_links)$' -V ctest --preset release --no-tests=error -j 1 -R '^compute_store_aot_gfx1013_image_store_(warp|hardware)$' -V ``` An independent rerun of `aa87ce9a` in Debug on the same host passed 24/24: `ctest --preset dev --no-tests=error -R '^compute_store_aot_.*(image|texture|mimg)'`. #1608 has merged. The merge with `main` keeps both `lower()` keywords (`image_srv_descriptor` and `rsrc2`). After that merge, Debug passed 28/28 on the same host: all compute image, texture and MIMG tests, `compute_store_aot_{warp,hardware}` and `compute_entry_layout_{warp,hardware}`. Local LLVM 23.1.6 reproduced the recorded bytes and disassembled them back to the fixture instructions. The Ubuntu job runs the LLVM 15 word, disassembly and container CLI checks: ```sh python3 -B tests/compute_mimg_float_store_check.py --binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1 ``` AI-assisted (Codex).
R0Y00 commented 2026-11-24 16:03:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T15:12:44Z.

Review: CHANGES_REQUESTED


This version emits a full float4 store and zero-fills channels omitted by a sparse DMASK. That changes destination components without evidence that the source operation does so. Please start with a full store mask and a sparse-store refusal, as agreed in #1545. Sparse SRV loads can remain if the selected source components and explicit mip are verified separately. Keep the wrong-mip control and verify surrounding destinations and untouched mips.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6041911707 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1611#pullrequestreview-6041911707). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T15:12:44Z. **Review:** CHANGES_REQUESTED --- This version emits a full float4 store and zero-fills channels omitted by a sparse DMASK. That changes destination components without evidence that the source operation does so. Please start with a full store mask and a sparse-store refusal, as agreed in #1545. Sparse SRV loads can remain if the selected source components and explicit mip are verified separately. Keep the wrong-mip control and verify surrounding destinations and untouched mips.
tedin7 commented 2026-11-24 16:03:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:46:48Z.

Review: COMMENTED


Technical review (Linux only; no Windows, WARP or GPU run). The draw test compute_store_aot_gfx1013_image_store_{warp,hardware} and its 1,344-word readback comparison are therefore not reproduced here.

Checked out the PR head (aa87ce9a, which restricts stores to DMASK 0xf) in a clean tree.

What I ran:

  • tests/compute_mimg_float_store_check.py (translation controls): passes.
  • The same with --binary llvm-mc-19 llvm-objcopy-19 --llvm <libLLVM 19>: the recorded gfx1013 machine words match llvm-mc, the LLVM 19 disassembly translates to the same HLSL as the hand-written program, and the container CLI output equals the library output. (The workflow pins LLVM 15; this is an additional LLVM 19 check, not a replacement.)
  • docs_links_check, bidi_controls_check and git diff --check: clean. The new README anchor resolves.
  • Reading of the lowering: with rgba32_float_image the UAV is RWTexture2D<float4>, the SRV is Texture2D<float4>, the store is asfloat(uint4(...)) of the four data VGPRs and the load is asuint(imageData.Load(int3(x,y,mip))), so values pass through as raw words; a store using the SRV descriptor or a load using the UAV descriptor fails the ("image"|"image_srv", index) descriptor check. The 1,344 = 3 mips and 1,280 sentinel arithmetic in the docs matches the fixture (16 texels x 4 words rewritten).
  • On the earlier change request about sparse stores: in this head a store with DMASK other than 0xf is refused with "requires full DMASK 0xf" and the sparse-store control exists, so the zero-fill behaviour is gone from the lowering. Sparse image_load_mip (DMASK 0x5) remains and is checked through channel order (R,B into consecutive VGPRs) and the forced-mip-zero control.

Local mutation check on tools/compute_store_aot.py, against controls() (each reverted afterwards; tree clean):

  • DMASK guard removed, UAV declared as uint4, store emitted without asfloat: caught.
  • gfx1013 guard (m["kind"], mip) not in (("store", False), ("load", True)) removed: not caught. Without it, a plain image_load (no _mip) is accepted on gfx1013 (an image_store_mip is still refused by a later check). No Linux control uses a plain image_load or image_store_mip on this path; the control list uses image_sample_l, which is refused earlier for a different reason. Suggestion: add image_load and image_store_mip variants to the refusal list.
  • a16 / packed guards removed: not caught, but both are also refused later with a different message, so there is no behaviour hole; only the message would change.
  • float images allowed on gfx1030 (cpu == condition dropped), "SRV requires a typed FLOAT UAV" check removed, SRV overlap test made one-sided, SRV alignment test removed: not caught. I probed the unmutated code with SRV offsets 0x30, 0x34, 0x41 and 0x62, a UINT format and cpu="gfx1030": all are refused today, so these are behaviours worth pinning, not bugs. The suite only tries 0x40 and 0x50 (overlaps above).

Not covered by the fixture (all inputs are normal binary32 values, no sign-flipped sentinel is NaN): NaN payloads, denormals and negative zero through the typed load and store. The code is a pure word pass-through, but D3D does not promise bit-exact NaN handling for float typed UAV stores on every adapter, so it is worth either adding one such texel to the fixture or stating the limit in the docs.

No defects found in the lowering itself.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6042554218 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1611#pullrequestreview-6042554218). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T15:46:48Z. **Review:** COMMENTED --- Technical review (Linux only; no Windows, WARP or GPU run). The draw test `compute_store_aot_gfx1013_image_store_{warp,hardware}` and its 1,344-word readback comparison are therefore not reproduced here. Checked out the PR head (`aa87ce9a`, which restricts stores to DMASK 0xf) in a clean tree. What I ran: - `tests/compute_mimg_float_store_check.py` (translation controls): passes. - The same with `--binary llvm-mc-19 llvm-objcopy-19 --llvm <libLLVM 19>`: the recorded gfx1013 machine words match `llvm-mc`, the LLVM 19 disassembly translates to the same HLSL as the hand-written program, and the container CLI output equals the library output. (The workflow pins LLVM 15; this is an additional LLVM 19 check, not a replacement.) - `docs_links_check`, `bidi_controls_check` and `git diff --check`: clean. The new README anchor resolves. - Reading of the lowering: with `rgba32_float_image` the UAV is `RWTexture2D<float4>`, the SRV is `Texture2D<float4>`, the store is `asfloat(uint4(...))` of the four data VGPRs and the load is `asuint(imageData.Load(int3(x,y,mip)))`, so values pass through as raw words; a store using the SRV descriptor or a load using the UAV descriptor fails the `("image"|"image_srv", index)` descriptor check. The `1,344 = 3 mips` and `1,280 sentinel` arithmetic in the docs matches the fixture (16 texels x 4 words rewritten). - On the earlier change request about sparse stores: in this head a store with DMASK other than 0xf is refused with "requires full DMASK 0xf" and the sparse-store control exists, so the zero-fill behaviour is gone from the lowering. Sparse `image_load_mip` (DMASK 0x5) remains and is checked through channel order (R,B into consecutive VGPRs) and the forced-mip-zero control. Local mutation check on `tools/compute_store_aot.py`, against `controls()` (each reverted afterwards; tree clean): - DMASK guard removed, UAV declared as `uint4`, store emitted without `asfloat`: caught. - gfx1013 guard `(m["kind"], mip) not in (("store", False), ("load", True))` removed: **not caught**. Without it, a plain `image_load` (no `_mip`) is accepted on gfx1013 (an `image_store_mip` is still refused by a later check). No Linux control uses a plain `image_load` or `image_store_mip` on this path; the control list uses `image_sample_l`, which is refused earlier for a different reason. Suggestion: add `image_load` and `image_store_mip` variants to the refusal list. - `a16` / `packed` guards removed: not caught, but both are also refused later with a different message, so there is no behaviour hole; only the message would change. - float images allowed on gfx1030 (`cpu ==` condition dropped), "SRV requires a typed FLOAT UAV" check removed, SRV overlap test made one-sided, SRV alignment test removed: not caught. I probed the unmutated code with SRV offsets 0x30, 0x34, 0x41 and 0x62, a UINT format and `cpu="gfx1030"`: all are refused today, so these are behaviours worth pinning, not bugs. The suite only tries 0x40 and 0x50 (overlaps above). Not covered by the fixture (all inputs are normal binary32 values, no sign-flipped sentinel is NaN): NaN payloads, denormals and negative zero through the typed load and store. The code is a pure word pass-through, but D3D does not promise bit-exact NaN handling for float typed UAV stores on every adapter, so it is worth either adding one such texel to the fixture or stating the limit in the docs. No defects found in the lowering itself. AI-assisted; commands listed were executed locally.
Jess-Doit commented 2026-11-24 16:03:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T15:29:59Z.


Updated in aa87ce9a:

  • image_store now requires DMASK 0xf. A sparse store mask is refused, and the zero-fill path is removed.
  • The fixture stores all four channels to unique texels. It checks all 1,344 words, including the 1,280 sentinels in surrounding texels and untouched mips.
  • Sparse SRV loads stay, with their own channel-swap control.
  • The forced-mip-zero control is kept.
  • The GTX 1060 and WARP match with the debug layer clean. Details are in the description.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7136130631 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1611#issuecomment-7136130631). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T15:29:59Z. --- Updated in `aa87ce9a`: - `image_store` now requires DMASK `0xf`. A sparse store mask is refused, and the zero-fill path is removed. - The fixture stores all four channels to unique texels. It checks all 1,344 words, including the 1,280 sentinels in surrounding texels and untouched mips. - Sparse SRV loads stay, with their own channel-swap control. - The forced-mip-zero control is kept. - The GTX 1060 and WARP match with the debug layer clean. Details are in the description.
Jess-Doit commented 2026-11-24 16:03:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T15:51:36Z.


Thanks @tedin7. These are in the latest commit:

  • A plain image_load and an image_store_mip are now refusal controls. Removing the (kind, mip) guard fails the controls.
  • SRV offsets 0x30, 0x34, 0x40, 0x41, 0x50 and 0x62 must be refused: misaligned, or overlapping either half of the UAV descriptor.
  • A UINT format and cpu="gfx1030" must be refused, and so must a separate SRV with a raw output, which pins the "requires a gfx1013 RGBA32 FLOAT image UAV" check.
  • NaN payloads, denormals and negative zero are stated as a limit in docs/experiments.md. Every fixture word is a normal binary32 value, and D3D12 doesn't promise bit-exact float typed UAV stores for those values.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7136733704 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1611#issuecomment-7136733704). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T15:51:36Z. --- Thanks @tedin7. These are in the latest commit: - A plain `image_load` and an `image_store_mip` are now refusal controls. Removing the `(kind, mip)` guard fails the controls. - SRV offsets `0x30`, `0x34`, `0x40`, `0x41`, `0x50` and `0x62` must be refused: misaligned, or overlapping either half of the UAV descriptor. - A UINT format and `cpu="gfx1030"` must be refused, and so must a separate SRV with a raw output, which pins the "requires a gfx1013 RGBA32 FLOAT image UAV" check. - NaN payloads, denormals and negative zero are stated as a limit in `docs/experiments.md`. Every fixture word is a normal binary32 value, and D3D12 doesn't promise bit-exact float typed UAV stores for those values.
upstream-sync closed this pull request 2026-11-24 17:01:40 +00:00
R0Y00 commented 2026-11-24 17:01:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:13:56Z.

Review: APPROVED


Full-mask float stores and separate read-only mip loads satisfy the requested scope. After reconciling the CLI with #1608, the binding/refusal controls and both hardware/WARP pairs passed in Windows Release with zero skips. The parallel Linux binary command is retained.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043016276 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1611#pullrequestreview-6043016276). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:13:56Z. **Review:** APPROVED --- Full-mask float stores and separate read-only mip loads satisfy the requested scope. After reconciling the CLI with #1608, the binding/refusal controls and both hardware/WARP pairs passed in Windows Release with zero skips. The parallel Linux binary command is retained.
R0Y00 commented 2026-11-24 17:02:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:13:35Z.


Resolved the CLI conflict with #1608 in ec7bfff0 by retaining both keyword arguments. The full-mask image-store and mip read-only binding controls passed, as did all four RTX and WARP image tests in Release and the entry-layout translation controls.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137319769 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1611#issuecomment-7137319769). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:13:35Z. --- Resolved the CLI conflict with #1608 in ec7bfff0 by retaining both keyword arguments. The full-mask image-store and mip read-only binding controls passed, as did all four RTX and WARP image tests in Release and the entry-layout translation controls.
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!1604
No description provided.