startup: pixel image_store sparse DMASK as component stores #2653

Merged
SimSalabimse merged 5 commits from upstream-pr/2661 into main 2026-11-27 05:02:20 +00:00
SimSalabimse commented 2026-11-26 01:06:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T01:06:32Z.


Change

Refs #2618.

A pixel-stage 2D image_store with a partial DMASK now writes only the selected components (w0[uint2(x, y)].xz = float2(...)). It does not read the texel. A float4 read-modify-write is not used: that form stores every channel, so two invocations that hit one texel with disjoint masks can put stale values back, and the load needs a typed UAV format.

Compute stores, D16 stores and array stores still require dmask:0xf. The full-mask store is unchanged.

A source-built fixture draws two pixels in one pass. Both address texel (1, 2). One stores x (dmask:0x1, 1.0) and the other stores z (dmask:0x4, 2.0). From a -1 clear the texel must read back (1, -1, 2, -1). Writing the second value into y instead of z must mismatch.

A manifest line may end in typedload when the binding must support a typed UAV load. The translator does not emit that word for a component store. A binding that asks for the load is refused before the draw when the format has no typed UAV load, and no view is written.

Verification

Commit under test: dd6fdaa1, on top of a merge of upstream main 6ee878d8 (the previous head was 3162ce77).

Linux, Python 3.12, LLVM 15.0.7:

./out/pe-env/bin/python -B tests/startup_pixel_image_store_check.py
./out/pe-env/bin/python -B tests/startup_pixel_image_store_check.py binary llvm-mc-15
./out/pe-env/bin/python -B tests/startup_compute_image_store_check.py
./out/pe-env/bin/python -B tests/startup_compute_image_store_d16_check.py

All four passed. The same interpreter then ran the python-linux list (211 checks) and the LLVM 15 pixel-binary list (137 checks). Both runs printed all N checks passed. No DXC, WARP or hardware draw was run here.

Windows 11 25H2 (26200), MSVC 19.42, dev preset, on the test PC:

ctest --preset dev --no-tests=error -R '^startup_pixel_image_store_(controls|warp|hardware)$' -V -j 1

At dd6fdaa1 on an RTX 4070 Ti (driver 32.0.16.2135), startup_pixel_image_store_controls, startup_pixel_image_store_warp and startup_pixel_image_store_hardware passed in both of two runs (3/3, ctest exit 0, no skips). The draw modes cover the sparse dmask:0x5 store, the two-pixel same-texel store, the y-for-z mutation, and --startup-image-store-reject-load.

Evidence and follow-up

The fixtures are hand-assembled gfx1013 words, checked against llvm-mc -arch=amdgcn -mcpu=gfx1013. No game files or captured programs.

The component store does not need exclusive texel ownership or a typed UAV load, because it never reads the texel and never writes an unselected channel. DXC must keep the HLSL swizzle as a masked store; if a driver expands it to a full-vector write, the same-texel readback is the failure.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Cursor)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5502034915 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2661). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T01:06:32Z. --- ## Change Refs #2618. A pixel-stage 2D `image_store` with a partial DMASK now writes only the selected components (`w0[uint2(x, y)].xz = float2(...)`). It does not read the texel. A float4 read-modify-write is not used: that form stores every channel, so two invocations that hit one texel with disjoint masks can put stale values back, and the load needs a typed UAV format. Compute stores, D16 stores and array stores still require `dmask:0xf`. The full-mask store is unchanged. A source-built fixture draws two pixels in one pass. Both address texel (1, 2). One stores x (`dmask:0x1`, 1.0) and the other stores z (`dmask:0x4`, 2.0). From a -1 clear the texel must read back (1, -1, 2, -1). Writing the second value into y instead of z must mismatch. A manifest line may end in `typedload` when the binding must support a typed UAV load. The translator does not emit that word for a component store. A binding that asks for the load is refused before the draw when the format has no typed UAV load, and no view is written. ## Verification Commit under test: `dd6fdaa1`, on top of a merge of upstream main `6ee878d8` (the previous head was `3162ce77`). Linux, Python 3.12, LLVM 15.0.7: ```bash ./out/pe-env/bin/python -B tests/startup_pixel_image_store_check.py ./out/pe-env/bin/python -B tests/startup_pixel_image_store_check.py binary llvm-mc-15 ./out/pe-env/bin/python -B tests/startup_compute_image_store_check.py ./out/pe-env/bin/python -B tests/startup_compute_image_store_d16_check.py ``` All four passed. The same interpreter then ran the `python-linux` list (211 checks) and the LLVM 15 `pixel-binary` list (137 checks). Both runs printed `all N checks passed`. No DXC, WARP or hardware draw was run here. Windows 11 25H2 (26200), MSVC 19.42, dev preset, on the test PC: ```powershell ctest --preset dev --no-tests=error -R '^startup_pixel_image_store_(controls|warp|hardware)$' -V -j 1 ``` At `dd6fdaa1` on an RTX 4070 Ti (driver 32.0.16.2135), `startup_pixel_image_store_controls`, `startup_pixel_image_store_warp` and `startup_pixel_image_store_hardware` passed in both of two runs (3/3, ctest exit 0, no skips). The draw modes cover the sparse `dmask:0x5` store, the two-pixel same-texel store, the y-for-z mutation, and `--startup-image-store-reject-load`. ## Evidence and follow-up The fixtures are hand-assembled gfx1013 words, checked against `llvm-mc -arch=amdgcn -mcpu=gfx1013`. No game files or captured programs. The component store does not need exclusive texel ownership or a typed UAV load, because it never reads the texel and never writes an unselected channel. DXC must keep the HLSL swizzle as a masked store; if a driver expands it to a full-vector write, the same-texel readback is the failure. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Cursor)
tedin7 commented 2026-11-26 01:11:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:11:45Z.

Review: COMMENTED


Review of head 12f890ff (after update with main).

Checked:

  • op_image_store in tools/startup/gfx2hlsl.py: a pixel-stage partial DMASK (1..0xe) becomes a float4 read-modify-write of the typed UAV, channels filled in VDATA order. The scratch t is declared in every pixel entry and is assigned before each use, so no clash with other t users. Compute, D16, empty and out-of-range masks stay refused; the VGPR count follows the popcount. The no-exec-known path wraps the whole RMW in one if (exec & 1) { ... }.
  • Fixture tests/startup_pixel_image_store_check.py: new dmask:0x5 program with a UAV clear of -1 and a control that writes all four channels (must mismatch), plus the CTest _warp draw readback is wired in CMakeLists.txt.
  • No other open or merged PR covers the sparse-DMASK slice (#2155 and #2399 are the full-mask pixel and compute stores).
  • Note: a typed UAV read needs the format to support typed loads; that is a runtime binding matter outside this lowering and is already stated in the docstring.

Commands run (Linux):

  • python3 -B tests/startup_pixel_image_store_check.py: ok
  • python3 -B tests/startup_compute_image_store_check.py: ok
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: ok
  • Mutation 1 (channel order xyzw -> xzyw): the pixel check fails (exit 1).
  • Mutation 2 (RMW starts from t = 0 instead of reading the texel): the pixel check fails (exit 1).

No concerns found in the code. Windows WARP readback result comes next as a separate receipt.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067216473 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2661#pullrequestreview-6067216473). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T01:11:45Z. **Review:** COMMENTED --- Review of head 12f890ff (after update with main). Checked: - `op_image_store` in `tools/startup/gfx2hlsl.py`: a pixel-stage partial DMASK (1..0xe) becomes a float4 read-modify-write of the typed UAV, channels filled in VDATA order. The scratch `t` is declared in every pixel entry and is assigned before each use, so no clash with other `t` users. Compute, D16, empty and out-of-range masks stay refused; the VGPR count follows the popcount. The no-exec-known path wraps the whole RMW in one `if (exec & 1) { ... }`. - Fixture `tests/startup_pixel_image_store_check.py`: new `dmask:0x5` program with a UAV clear of -1 and a control that writes all four channels (must mismatch), plus the CTest `_warp` draw readback is wired in CMakeLists.txt. - No other open or merged PR covers the sparse-DMASK slice (#2155 and #2399 are the full-mask pixel and compute stores). - Note: a typed UAV read needs the format to support typed loads; that is a runtime binding matter outside this lowering and is already stated in the docstring. Commands run (Linux): - `python3 -B tests/startup_pixel_image_store_check.py`: ok - `python3 -B tests/startup_compute_image_store_check.py`: ok - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: ok - Mutation 1 (channel order xyzw -> xzyw): the pixel check fails (exit 1). - Mutation 2 (RMW starts from `t = 0` instead of reading the texel): the pixel check fails (exit 1). No concerns found in the code. Windows WARP readback result comes next as a separate receipt. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-26 01:16:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:16:08Z.

Review: CHANGES_REQUESTED


The positive fixture shows channel ordering and preservation when only one invocation touches a texel. The proposed float4 read-modify-write also accepts arbitrary pixel coordinates. Two invocations can legally target the same texel with disjoint guest masks. If both read before either stores, the second full-vector store can put stale values back into the other invocation's channels. A format that supported the previous typed store can also lack the typed load needed by this lowering.

Please keep the general sparse form refused until the runtime can verify a supported typed-load format and exclusive ownership of each addressed texel for the duration of the read-modify-write, or use a lowering that writes just the selected components. For a bounded path, include one fixture that writes distinct channels of the same texel and checks that both updates survive, or explicitly rejects the aliasing shape. Also verify that a binding without the required typed-load support is rejected before drawing. The existing full-mask route can remain as it is.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067251674 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2661#pullrequestreview-6067251674). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T01:16:08Z. **Review:** CHANGES_REQUESTED --- The positive fixture shows channel ordering and preservation when only one invocation touches a texel. The proposed `float4` read-modify-write also accepts arbitrary pixel coordinates. Two invocations can legally target the same texel with disjoint guest masks. If both read before either stores, the second full-vector store can put stale values back into the other invocation's channels. A format that supported the previous typed store can also lack the typed load needed by this lowering. Please keep the general sparse form refused until the runtime can verify a supported typed-load format and exclusive ownership of each addressed texel for the duration of the read-modify-write, or use a lowering that writes just the selected components. For a bounded path, include one fixture that writes distinct channels of the same texel and checks that both updates survive, or explicitly rejects the aliasing shape. Also verify that a binding without the required typed-load support is rejected before drawing. The existing full-mask route can remain as it is.
upstream-sync changed title from [PR #2661] startup: pixel image_store sparse DMASK via read-modify-write to [PR #2661] startup: pixel image_store sparse DMASK as component stores 2026-11-26 13:03:00 +00:00
SimSalabimse commented 2026-11-26 13:03:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T12:49:57Z.


Addressed the review in 3162ce77 (after merging current main in 46454165). The partial pixel store now writes only the selected components. It does not read the texel, so two invocations that share a texel with disjoint masks cannot put stale channels back, and that path needs neither a typed UAV load nor exclusive texel ownership. Compute, D16 and array stores still require dmask:0xf. The full-mask store is unchanged.

One draw runs two pixels against texel (1, 2): dmask:0x1 writes 1.0 and dmask:0x4 writes 2.0. From a -1 clear the texel must read back (1, -1, 2, -1), and moving the second store from z to y must mismatch. A manifest line ending in typedload is refused before the view is created and before the draw when the format has no typed UAV load; the component store does not emit that request.

Verification (Windows 11 25H2 26200, MSVC 19.42, dev preset):
ctest --preset dev --no-tests=error -j 1 -R '^startup_pixel_image_store' returned 3/3 passed (controls, warp, hardware), exit 0. On Linux, the python-linux list returned 209/209 and the LLVM 15 pixel-binary list 135/135.

The PR description is updated to match.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7192519049 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2661#issuecomment-7192519049). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T12:49:57Z. --- Addressed the review in `3162ce77` (after merging current `main` in `46454165`). The partial pixel store now writes only the selected components. It does not read the texel, so two invocations that share a texel with disjoint masks cannot put stale channels back, and that path needs neither a typed UAV load nor exclusive texel ownership. Compute, D16 and array stores still require `dmask:0xf`. The full-mask store is unchanged. One draw runs two pixels against texel `(1, 2)`: `dmask:0x1` writes 1.0 and `dmask:0x4` writes 2.0. From a `-1` clear the texel must read back `(1, -1, 2, -1)`, and moving the second store from z to y must mismatch. A manifest line ending in `typedload` is refused before the view is created and before the draw when the format has no typed UAV load; the component store does not emit that request. Verification (Windows 11 25H2 26200, MSVC 19.42, dev preset): `ctest --preset dev --no-tests=error -j 1 -R '^startup_pixel_image_store'` returned 3/3 passed (controls, warp, hardware), exit 0. On Linux, the `python-linux` list returned 209/209 and the LLVM 15 `pixel-binary` list 135/135. The PR description is updated to match. AI-Assisted
SimSalabimse commented 2026-11-26 22:50:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T22:50:19Z.


Upstream main is now merged into this branch (head dd6fdaa1). The conflicts with the upstream 2D-array image_store work are resolved, and both behaviours are kept: partial pixel 2D masks stay component stores, and the pixel-stage 2D-array image_store and its UAV binding stay as on main. On the Windows test PC, startup_pixel_image_store_controls, _warp and _hardware passed in both runs (3/3, ctest exit 0, no skips).

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7205028099 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2661#issuecomment-7205028099). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T22:50:19Z. --- Upstream main is now merged into this branch (head `dd6fdaa1`). The conflicts with the upstream 2D-array image_store work are resolved, and both behaviours are kept: partial pixel 2D masks stay component stores, and the pixel-stage 2D-array image_store and its UAV binding stay as on main. On the Windows test PC, `startup_pixel_image_store_controls`, `_warp` and `_hardware` passed in both runs (3/3, ctest exit 0, no skips). AI-Assisted
R0Y00 commented 2026-11-27 05:00:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T05:00:31Z.

Review: APPROVED


Reviewed dd6fdaa1b2de22792c642a5f907bb3235cd92d89. The updated lowering directly stores only the selected components, avoiding the read-modify-write race and the typed load requirement. The Release main integration build passed startup_pixel_image_store_(controls|warp|hardware), including disjoint stores to the same texel, the channel-swap negative control and the typed-load refusal. Independent Windows 11 26200.9974 testing used WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 where applicable. Required Windows CI passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083686439 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2661#pullrequestreview-6083686439). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T05:00:31Z. **Review:** APPROVED --- Reviewed `dd6fdaa1b2de22792c642a5f907bb3235cd92d89`. The updated lowering directly stores only the selected components, avoiding the read-modify-write race and the typed load requirement. The Release main integration build passed `startup_pixel_image_store_(controls|warp|hardware)`, including disjoint stores to the same texel, the channel-swap negative control and the typed-load refusal. Independent Windows 11 26200.9974 testing used WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 where applicable. Required Windows CI passed.
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!2653
No description provided.