Skip to content

shader: translate packed D16 image stores in startup compute programs - #2300

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/startup-compute-d16-store
Nov 25, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/startup-compute-d16-store

Conversation

@RavenCurseBurg

Copy link
Copy Markdown
Contributor

Refs #2274, item A, compute image_store d16. At 25317c63 the startup compute translator refuses the source-built shader from #2106 with image_store outside a pixel stage.

The new path accepts a 2D full-RGBA-mask store with full-width XY and an intact eight-word descriptor from a fixed table location. It unpacks the low/high half-floats of VDATA and VDATA+1 into RGBA and writes under the lane's EXEC bit. The layout comes from the AMD RDNA 2 ISA, §§8.2.1 and 8.2.5.

The shared interface with item B is the version 2 compute manifest line uav N tex2d float table P O channels 4. For the fixture it names table 1, byte 64. The translator assigns a single UAV index space to raw and typed views. Tests cover both discovery orders, conflicting raw/typed stores and conflicting SRV/UAV uses of the same descriptor. The standalone test supplies an RGBA16_FLOAT UAV. Slot-67 binding and its view-format checks remain with the runtime item.

Verification

  • LLVM 15.0.7 assembled the two public gfx1013 programs (80 and 84 bytes) and each binary control. With full EXEC the two groups change 64 of the 1,344 half-words across three mips. With partial EXEC they change 32. The CPU reference includes signed zeros, positive and negative subnormals, every inactive texel and both untouched mips.
  • python -B tests/startup_compute_image_store_d16_check.py --dispatch <dxc> <offscreen_check> warp and the same command with hardware ran on Windows build 26100.9711, WARP 10.0.26100.9711 and a desktop RTX 4060 with driver 32.0.15.9579. Both positive cases matched all 1,344 halves on each adapter. The four controls removing the store, swapping R/G, swapping the packed registers and dropping EXEC protection differed in exactly 64, 32, 64 and 32 halves. The first three showed 5000, c000 and 0000 at mip 0, half 0 (expected 3c00). The fourth showed 3c08 at half 128 (expected 5080). The local debug layer was unavailable.
  • The ordinary python -B tools/startup/gfx2hlsl.py --pending <cache> path processed synthetic request keys d3cfb5c33473af1f and 1bd251f34165a64e. Both manifests and HLSL matched the direct translator. All four dispatches of the CLI-produced CSOs matched 1,344/1,344 halves.
  • The eight targeted host checks passed via tools/run_checks_parallel.py (startup D16 store, compute, gather, pixel store, compute translation, offline D16 store, docs links and bidi controls). All 51 tests/startup_gfx2hlsl*_check.py entries passed. The original offline D16 WARP draw also passed, including its two existing negative controls. git diff --check passed.

To repeat the registered checks, build offscreen_check and run ctest --preset release --no-tests=error -R '^startup_compute_image_store_d16' -V. The input shader and CPU oracle are the repository's MIT-licensed synthetic fixtures. AI-assisted with Codex.

Share the typed UAV register allocation with raw buffer stores. Verify 2D full-mask half-float stores and per-lane EXEC against the three-mip RGBA16 fixture. Refs R0Y00#2274.

@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 43822328746ab6eee06cca1349187f274018c03b.

Result: no P1, no P2.

Checked:

  • Title is neutral. PR is mergeable. CI at review time: Linux checks pass, gfx1013 fixture job passes, Windows build pending, /O2 skipped.
  • Packed D16 unpack in op_image_store matches the cited layout: RG in VDATA, BA in VDATA+1, low half first. Full dmask, exactly two VGPRs, full-width VGPR XY and an intact fixed-table 8-word descriptor are all enforced. Other compute stores are refused.
  • Moving the descriptor check into fixed_table_image is a pure refactor for gather4. Its tests still pass.
  • Raw and typed UAVs now share one index space. The manifest lines come out in index order, because dict insertion order equals index order.

Commands run locally, with results:

  • python3 -B tests/startup_compute_image_store_d16_check.py: passed.
  • python3 -B tests/startup_gfx2hlsl_compute_check.py: passed.
  • python3 -B tests/compute_mimg_float_store_d16_check.py: passed.
  • python3 tests/docs_links_check.py: passed, 438 links.
  • python3 tests/bidi_controls_check.py: passed.
  • git diff --check origin/main...HEAD: clean.
  • Mutation 1: swapped the low and high half unpack. The test failed on the expected HLSL line.
  • Mutation 2: removed the if (exec & 1) guard (this edit hit 3 emit sites). The test failed on the EXEC guard assertion.
  • Both mutations reverted with git checkout -- ..

Nits:

  • The mutation kills above come from string assertions in the Linux run. The WARP readback (--dispatch ... warp) is where the half order and EXEC are checked numerically. I did not re-run it, because the PR body lists its own Windows verification and the Windows CI job was still pending. Please make sure that job is green before Ready.
  • fixed_table_image rejects a descriptor whose words were modified. A short comment saying that the manifest binds the original table view would help the next reader. The old comment was dropped in the refactor.

AI-assisted; commands listed were executed locally.

@RavenCurseBurg

Copy link
Copy Markdown
Contributor Author

The final-head Windows 2025 run passed all four CTests at c091eed7: startup D16 host controls, startup D16 WARP, the offline D16 WARP fixture and the typed UAV-load WARP fixture. The startup dispatch executed both positive cases and all four negative controls. Each compared 1,344 halves with the predicted mismatch count and reported debug_errors=0 debug_warnings=0 with the debug layer enabled. All three standard upstream jobs also passed at this head.

The first debug-layer run matched all 1,344 halves but reported warning 989 from the texture fixture's legacy format capability query. The follow-up uses the repository's SDK-version-aware check_feature helper for the format and additional typed-load queries. It also explains why an alias modification invalidates the original table view even if the eight SGPR symbols still look intact.

@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.

Re-review of head c091eed70d1906b968be2b2ec37c6417561fb734 (previously reviewed at 43822328).

Result: no P1, no P2.

What changed since the last review:

  • tests/compute_check.cpp:547,551: the two texture-store capability queries (D3D12_FEATURE_FORMAT_SUPPORT, D3D12_FEATURE_D3D12_OPTIONS) now go through the shared check_feature() helper (declared in tests/desktop_gpu.h, defined in tests/desktop_gpu.cpp:18, already included). Same queries, now made against the selected Agility SDK device. No logic change.
  • tools/startup/gfx2hlsl.py fixed_table_image: the docstring is reworded, and a comment now explains that a write through a second load of the descriptor can leave the SGPR symbols intact. This addresses my earlier nit about the dropped comment. Comment and docstring only.

Checked:

  • CI on this head: Linux checks pass, gfx1013 fixture job passes, Windows build and test passes (2m30s). The /O2 job is skipped and the coverage chart job is skipping. This closes my earlier note about the pending Windows job.
  • PR is mergeable. Title is neutral.

Commands run locally, with results:

  • python3 -B tests/startup_compute_image_store_d16_check.py: passed.
  • python3 -B tests/startup_gfx2hlsl_compute_check.py: passed.
  • python3 -B tests/compute_mimg_float_store_d16_check.py: passed.
  • python3 tests/docs_links_check.py: passed, 438 links.
  • python3 tests/bidi_controls_check.py: passed.
  • git diff --check origin/main...HEAD: clean.
  • Mutation: changed the descriptor alignment check first[3] % 8 to % 4 in fixed_table_image. The D16 check failed with an AssertionError on the expected refusal text. Reverted with git checkout -- ..

Nits: none new. The WARP readback is covered by the Windows CI job, which is green. I did not re-run Win2025, since the new commit does not touch the translated HLSL.

AI-assisted; commands listed were executed locally.

@R0Y00
R0Y00 merged commit d9bed39 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