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

Merged
RavenCurseBurg merged 2 commits from upstream-pr/2224 into main 2026-11-25 06:18:49 +00:00
RavenCurseBurg commented 2026-11-25 06:07:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T06:07:46Z.


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. #2205 and #2217 have since landed on main.

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6598369516 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2224). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T06:07:46Z. --- 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](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45559194295) 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](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45551525537). - 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](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45552909687) 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. #2205 and #2217 have since landed on main. AI-assisted with Codex (GPT-6.2 Astra xhigh).
upstream-sync closed this pull request 2026-11-25 07:01:05 +00:00
tedin7 commented 2026-11-25 07:01:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:12:56Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052689906 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2224#pullrequestreview-6052689906). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:12:56Z. **Review:** COMMENTED --- 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.
RavenCurseBurg commented 2026-11-25 07:01:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T06:14:41Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154590968 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2224#issuecomment-7154590968). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T06:14:41Z. --- 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.
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!2216
No description provided.