Skip to content

compute: lower buffer_store_format_d16_x to FLOAT1 heap views - #2340

Merged
tedin7 merged 1 commit into
R0Y00:mainfrom
Vladimir-Human:shader/compute-d16-x-heap-store
Nov 25, 2026
Merged

tedin7 merged 1 commit into
R0Y00:mainfrom
Vladimir-Human:shader/compute-d16-x-heap-store

Conversation

@Vladimir-Human

Copy link
Copy Markdown
Contributor

Refs #2022

Summary

Extend --heap-store-view in tools/compute_store_aot.py to lower gfx1013 buffer_store_format_d16_x (one data VGPR, idxen, 4-byte aligned offset, indexed by dispatch thread ID tid.<axis>) into live identity BUF_FMT_32_FLOAT (0x01016fac, format 22) side-table heap views (store_heap_word_d16), extending item B's heap-store path (#2230). (The separate #2274 item A gfx2hlsl.py compute-stage buffer_store_format_d16_x path is untouched.)

  • Skips the non-heap raw UAV outputData.Load(...) read-modify-write under heap_store_view (elif partial and not descriptor_store and heap_store_view is None:).
  • heap_store_view_hlsl(..., single_d16=True) emits store_heap_word_d16(slot, index, offset, value) while leaving store_heap_words4 untouched: checks slot < view_count, HEAP_VIEW_LIVE == 1u, view.w == 0x01016facu (descriptor_format_word(22)), (view.y & 0xc000ffffu) == 0u, 4-byte aligned view.x and stride, stride >= offset + 4u, index < view.z, view.x <= bytes, offset + 4u <= bytes - view.x, index <= (bytes - view.x - offset - 4u) / stride, widens the low 16 bits via asuint(f16tof32(value & 0xffffu)), and writes one 4-byte binary32 word via outputData.Store(...). (Per AMD RDNA 2 ISA DS/MUBUF format conversion and HLSL f16tof32.)
  • Keeps buffer_store_format_d16_xy, d16_xyz, x, xy, xyz, offen, multi-VGPR v[10:11], unaligned offsets, unready slot constants, and wrong thread-ID indexing refused.
  • Expanded compute_heap_store_check.py (including D16_X_PROGRAM in llvm-mc-15 binary verification, 12 FLOAT1 layout/bounds/format cases + 4 binary16 payload patterns with 0x4200-poisoned high halves + UINT1/FLOAT4 mismatch rejections + 11 GPU shader mutations) and documented the coverage in docs/experiments.md.

Verification (481ff717, Windows 11 Build 26300, DXC cs_6_0, D3D12 debug_layer=enabled)

Commands:

  • . .\tools\dev.ps1; cmake --preset release; cmake --build --preset release --target offscreen_check
  • python -B tests/compute_heap_store_check.py (controls pass)
  • ctest --preset release --no-tests=error -j 1 -R "^compute_(heap_store_controls|heap_view_controls|load_format_controls|store_aot_heap_view_(load|store)_(warp|hardware)|store_aot_descriptor_store_format_(warp|hardware)|store_aot_mubuf_store_format(|_xyz)_(warp|hardware))$" -V (13/13 passed, 0 failed, 0 skipped):
    • WARP (Microsoft Basic Render Driver, vendor=1414 device=008c, driver 10.0.26100.9818, debug_layer=enabled): UINT4 (12 cases + 8 mutations), D16-to-FLOAT4 (12 cases + 11 mutations), D16_X-to-FLOAT1 (16 cases + 11 mutations) passed; direct D16_X dispatch groups=1 compared_words=320 mismatches=0 debug_errors=0 debug_warnings=0.
    • RTX 4070 SUPER (NVIDIA GeForce RTX 4070 SUPER, vendor=10de device=2783, driver 32.0.16.2114, debug_layer=enabled): UINT4 (12 cases + 8 mutations), D16-to-FLOAT4 (12 cases + 11 mutations), D16_X-to-FLOAT1 (16 cases + 11 mutations) passed; direct D16_X dispatch groups=1 compared_words=320 mismatches=0 debug_errors=0 debug_warnings=0.
  • ctest --preset release --no-tests=error -R "^compute_" -E "_(warp|hardware)$" (7/7 passed, 0 failed, 0 skipped)
  • compute_heap_view_check.py, compute_load_format_check.py, docs_links_check.py, bidi_controls_check.py, startup_tools_lint_check.py, form_coverage_check.py, shader_census_check.py: all passed.

Not Tested Locally

  • llvm-mc-15 binary verification (tests/compute_heap_store_check.py wired in .github/workflows/windows.yml:46) was not run locally on Windows.
  • Real title compute shaders, d16_xy, d16_xyz, and non-FLOAT1 packed targets.

AI-assisted implementation and verification.

@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 481ff71 (tools/compute_store_aot.py, tests/compute_heap_store_check.py, docs/experiments.md).

Findings: 0 P1, 0 P2.

  • buffer_store_format_d16_x under --heap-store-view takes the low 16 bits (& 0xffffu) through f16tof32 and writes one binary32 word. The format word is 22 (BUF_FMT_32_FLOAT), the check order matches the existing FLOAT4 path, and the extent math uses a 4-byte width. Sibling d16_xy / d16_xyz stay refused.
  • The partial-store read-modify-write is skipped for heap views, so no raw UAV Load is emitted for d16_x.
  • No other open or recently merged PR covers d16_x heap-view stores.

Commands run locally on the exact head:

  • python3 tests/compute_heap_store_check.py -> heap-store controls passed
  • python3 tests/docs_links_check.py -> Checked 18 Markdown files and 451 links
  • python3 tests/bidi_controls_check.py -> no bidirectional controls
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: format word 22 -> 20 in the d16_x HLSL: controls FAIL (killed).
  • Mutation 2: drop "d16_x" from the allowed channel list: controls FAIL (killed).
  • Mutation 3: low half -> value >> 16u: not caught by the Linux controls; it is only covered by the WARP draw readback (CI job below).
  • CI at this head: Build and test on Windows = pass, Run platform-independent Python checks on Linux = pass, Assemble and translate gfx1013 fixtures = pass.

Comment-only review; no approval.

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit 9e3e7d3 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.

2 participants