Skip to content

startup: pixel image_store sparse DMASK via read-modify-write - #2661

Open
SimSalabimse wants to merge 2 commits into
R0Y00:mainfrom
SimSalabimse:cursor/image-store-sparse-dmask-e885
Open

SimSalabimse wants to merge 2 commits into
R0Y00:mainfrom
SimSalabimse:cursor/image-store-sparse-dmask-e885

Conversation

@SimSalabimse

@SimSalabimse SimSalabimse commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Change

Refs #2618 (batch M200-01, work code I).

Pixel image_store refused every partial DMASK because a typed UAV write covers all four channels. M200-01 I / the #2618 starter asks for a sparse-mask store with distinct channel init and per-channel readback.

  • Pixel stage: non-empty DMASK → float4 read-modify-write; selected channels filled in VDATA order.
  • Compute and D16 still require dmask:0xf.
  • Empty / out-of-range masks refused; wrong VGPR count refused.
  • Fixture adds dmask:0x5 (x,z): UAV clear -1 → texel (1, -1, 2, -1); control that writes all four channels must mismatch.

AI-assisted.

Verification

Commit under test: this PR head.

python3 -B tests/startup_pixel_image_store_check.py
python3 -B tests/startup_compute_image_store_check.py

Both passed on Linux. This agent could not run DXC / WARP / hardware draws.

Windows verification:

ctest --preset dev --no-tests=error -R '^startup_pixel_image_store' -V

Expect: controls pass; _warp includes the sparse dmask:0x5 case; hardware may pass or skip 77.

Evidence and follow-up

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.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 12f890f (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 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cursor
cursor Bot force-pushed the cursor/image-store-sparse-dmask-e885 branch 2 times, most recently from 1fb9ce8 to c06d763 Compare November 26, 2026 02:09
Typed UAV stores write all four channels, so a partial DMASK needs an RMW.
Accept non-empty pixel-stage masks and overwrite selected channels in VDATA
order (M200-01 I). Compute and D16 still require dmask 0xf. Fixture: dmask
0x5 leaves y/w at the UAV clear; full-write control must mismatch.

Refs R0Y00#2618

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/image-store-sparse-dmask-e885 branch from c06d763 to d837f75 Compare November 26, 2026 02:15
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms).
The negative control still expected only one non-IndexError survivor.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants