Skip to content

compute: store UINT4 through a runtime-selected buffer view - #2224

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
RavenCurseBurg:compute/heap-uav-uint4
Nov 25, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
RavenCurseBurg:compute/heap-uav-uint4

Conversation

@RavenCurseBurg

@RavenCurseBurg RavenCurseBurg commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2022, item B. This follows the 32-byte view record from #2174. A gfx1013 compute shader can now select a UINT4 view at dispatch time and write four 32-bit components with one indexed buffer_store_format_xyzw. The destination is the bound u0. The selected record in t0 determines the base, stride, element count, format and live state.

The binding supplies the writable byte extent of u0 separately from the size of t0. WARP caught a partial write at the end of the destination during development. The new check admits the last complete 16-byte texel and leaves every word untouched when only part of the texel fits. The first slice covers the identity 32_32_32_32_UINT format with a dispatch-thread index.

Review follow-up at a6f41df1

Both WARP and hardware passed the twelve cases and detected all eight wrong shaders at this head. Removing the per-index output bound is now an explicit mutation. The final-complete-texel case catches the next thread writing into the sentinel region. The device-free controls and the documentation link check also passed. The full Debug and Release workflow for this head is available here.
Verification at 2a955097 on Windows x64

  • python -B tests/compute_heap_store_check.py controls passed the accepted instruction and binding/refusal controls.
  • python -B tests/compute_heap_store_check.py draw <dxc> <offscreen_check> warp and the same command with hardware each matched all 320 output words in twelve cases. Each backend detected seven deliberately wrong shaders. The cases include a released view, a live slot beyond the table, element-count bounds, alternate base and stride, a wrong format, and the partial final texel. Used DXC 1.9.2609 and the source-built renderer.
  • LLVM 15.0.7 clang assembled the gfx1013 program, llvm-objcopy extracted its instructions, and the fixture's verify_binary compared source lowering, LLVM-C disassembly lowering and the container CLI's HLSL for equality. The Linux CI entry runs python -B tests/compute_heap_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1.
  • The integration run on the earlier parent passed the heap-store controls, heap-store WARP and adjacent heap-load WARP in Debug and Release. Three unrelated baseline tests made that overall run red. tests: find LLVM 15 on Windows PATH for the descriptor-store round trip #2205 and tests: handle hosted Windows temp paths and warning colors #2217 have since landed on main.

AI-assisted with Codex (GPT-6.2 Astra xhigh).

@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 2a955097a655bc6deb0744f20739afb548eb2762 (Linux, local worktree).

Result: no P1, no P2. Two nits.

Checked:

  • Title is neutral. The PR is MERGEABLE. CI at this head is green (Linux checks, Windows build and test, gfx1013 fixtures). Only the coverage chart and the /O2 job are skipped.
  • heap_store_view_hlsl (tools/compute_store_aot.py) follows the intended semantics. The live word at record+16 is required. Format word, channel selectors, 4-byte base and stride alignment, stride >= offset + 16, and index < count are all checked. The tail bound is computed by division, so index * stride cannot wrap. The whole 16-byte texel must fit in the declared u0 extent, otherwise nothing is written. That matches the partial-texel behavior described in the PR.
  • The lower() argument validation is strict. Mixing with heap_view, stride, output_format, image_output or format_words is refused. So are a wrong tuple length, a non-multiple-of-4 or out-of-range size, and a non-xyzw store. Slot readiness is also checked.
  • The CMake, workflow and AGENTS.md wiring are consistent with the sibling compute_heap_view_check.py entries. The docs link to the #heap-view-buffer-loads anchor.

Commands run locally:

  • python3 tests/docs_links_check.py -> Self-test passed. Checked 18 Markdown files and 413 links.
  • python3 tests/bidi_controls_check.py -> Checked 1506 files: no bidirectional controls.
  • git diff --check origin/main...HEAD -> clean (exit 0).
  • python3 -B tests/compute_heap_store_check.py controls -> heap-store controls passed.
  • Mutation: I replaced the tail-extent guard if (index > (bytes - view.x - offset - 16u) / stride) return; with if (false) return;. The Linux controls still passed. Linux controls do not run the HLSL. That guard is killed only by the WARP/hardware draw run, and the PR reports it covered by the partial-final-texel case. I did not run draw here: it needs DXC and the renderer, and no Windows run was queued from this review.

Nits:

  1. tests/compute_heap_store_check.py:49 The Linux controls string check (store_heap_uint4(params[0].x, tid.x, 4u, uint4(tid.x,) only pins the call site. The HLSL guards are exercised only by draw. This is fine given the Windows tests, but a short comment saying so would help the next maintainer.
  2. docs/experiments.md (new section) The ctest regex names compute_store_aot_heap_view_store_warp. The hardware variant is registered too. Mention it, or say that it is registered only when a hardware adapter exists.

AI-assisted; commands listed were executed locally.

Copy link
Copy Markdown
Contributor Author

I added the per-index extent mutation from your review in a6f41df1. The case where thread 0 writes the last complete UINT4 catches it: removing the guard also allows thread 1 to modify the sentinel region beyond the declared 512 bytes. The partial-texel case separately checks a first store that already straddles the limit. Both WARP and hardware passed all twelve cases and detected all eight mutations at this head. The controls now identify which checks run on-device, and the experiment guide gives a CTest selection for both backends.

@R0Y00
R0Y00 merged commit f277710 into R0Y00:main Nov 25, 2026
5 checks passed
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.

3 participants