Skip to content

runtime: publish narrow half-float texture UAV stores - #3305

Open
RonLogic wants to merge 4 commits into
R0Y00:mainfrom
RonLogic:runtime/narrow-half-image-uav
Open

RonLogic wants to merge 4 commits into
R0Y00:mainfrom
RonLogic:runtime/narrow-half-image-uav

Conversation

@RonLogic

Copy link
Copy Markdown
Contributor

Change

Refs #3224 and #2935. Direct Compute already emits D16 image stores for one and two channels. The five source-built programs here emitted DXIL but stopped at half_scalar_uav or half2_texture_uav manifest publication on the preceding compiler.

Publish the existing one- and two-channel bindings as typed half-float texture UAVs. The slot 14 binder checks the view and resource formats with the existing native_half_store_format contract and queries typed-store support on the view format. It uses the recorded mip and slice range for 1D, 2D, 2D-array and 3D textures. This is the published texture path. #3302 covers hardware buffer descriptors, and #3049 covers the separate in-process binding work.

Verification

58f3fc4f on bbf4687b, with clean merges checked against current main and #3302. Windows 11 26300.10075, MSVC 19.52.37029, Windows SDK 10.0.26100 DXC 1.9.2602.17, Agility 1.620.2, RTX 4070 driver 32.0.16.2124, and app-local WARP 1.0.22.

cmake --build <build> --target startup_stream_consumer d3d12_xs_shim offscreen_check compile_dxil
ctest --test-dir <build> --no-tests=error -j 2 -V -R '^(startup_compute_(half_image_uav_.*|dispatch_(texture|two_mips)_(hardware|warp))|native_image_store_exact_width_hardware_.*|native_direct_container)$'
  • Debug and Release each passed 15/15, with zero skips.
  • The six source-built view cases matched 5,664 halfwords on each adapter in each configuration. The tests write mip 1, cover scalar and two-channel views, exercise a typeless backing resource, and check untouched pixels and adjacent layers. The layered cases write relative slice 1 of a view beginning at physical slice 1.
  • The same-channel R32_FLOAT and R32G32_FLOAT controls refused and preserved the complete destination. The debug layer was enabled for both GPU paths and reported no errors.
  • Documentation check passed for 147 files and 671 links.

Evidence and follow-up

The texture data and guest code are generated by the test. The tested view coordinates follow the D3D12 UAV contract. The observed compatibility result is the five source-built programs through the published runtime, including a second view representation for the scalar 2D program. I used Codex to prepare the change and ran verification locally.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for this. I reviewed head 58f3fc4f by reading it and running pure-Python checks on the merged tree (no build, no Wine, no GPU). I found nothing blocking, only one suggestion and a few nits.

  • Merge: git merge-tree --write-tree of this head into main c3204a9c is clean (rc=0). runtime: bind published D16 buffer stores to typed UAVs #3302 changed the same three files (direct_compute_cache.cpp, d3d12_compute_dispatch.inl, startup_stream_consumer.cpp), but in separate branches of the same chains. The merged runtime keeps both the bufhalf and the new half table forms.
  • Opcodes: the DXIL ops this relies on are used the same way across the repo. git grep -F over src tools finds "textureStore.f32", 67 ×1, "textureLoad.f32", 66 ×2, "legacyF16ToF32", 131 ×14 and "legacyF32ToF16", 130 ×2.
  • Docs: on the merged tree, docs_links_check.py reports Checked 148 Markdown files and 671 links. (rc=0).
  • CI passed (Windows build/test, gfx1013 fixtures, Linux Python). The Windows job runs ctest --preset pr (100% tests passed out of 73), and grep -c half_image_uav on its log gives 0. So your local 15/15 run is the only run of the new tests.

Suggestion:

  1. In direct_compute_cache.cpp, the half branch's guard b.array_count == 1 && (b.image_dimension < 3 || b.image_dimension == 5) is the only thing that stops a 1D-array D16 store from being published as tex2da, because the name ternary falls through to "tex2da". The direct compiler does emit dim-4 stores: dx_kind[]{1, 2, 4, 5, 6, 7, 3, 8} maps dim 4 to Texture1DArray, and only dimensions queries refuse dim == 4. No test pins the guard. CASES covers dims 0, 1, 2 and 5, and native_compute_manifest_reasons.cpp has no half kind (git grep -c half_ exits 1). A dim-4 (and perhaps dim-3) row in controls() that expects the view_shape("UAV", …) refusal would pin it.

Nits:
2. The header comment of d3d12_compute_dispatch.inl lists the float table and bufhalf forms but not the new half table … channels <1|2> form.
3. Only two normal values, 1.0 and −2.0 (0x3c00, 0xc000), are pinned. No f16 denormal or NaN value checks the f16→f32→f16 path (legacyF16ToF32 then a typed R16 store) against the console's raw-bits D16 write.
4. The PR body has no mutation table. One would show which new checks turn red when each guard is removed.

Once you've considered the suggestion, it looks ready from our side.

This comment was AI-assisted.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for the work here. This branch no longer merges with current main (c6f23813): git merge-tree --write-tree origin/main 58f3fc4f exits 1 with a conflict in src/startup_stubs/d3d12_compute_dispatch.inl.

Could you merge or rebase current main into the branch, resolve that conflict, and re-run the tests this PR adds, so reviewers can look at the refreshed head?

This comment was AI-assisted.

Copy link
Copy Markdown
Contributor Author

Thanks for flagging the 1D-array case. I refreshed the branch onto 052abe6f and ran the new controls on 905db2e44fb8c1d52d2889706eb22fc341b84084. Git's merge-tree check against that main revision was clean.

  • On clean main, all five distinct source-built programs produced validated DXIL and no usable manifest. The new head publishes all five manifests. All five DXIL artifacts and manifests had identical hashes on cold and warm compiles.
  • The publisher now maps the four supported dimensions explicitly. A source-built D16 1D-array store still validates as DXIL, then returns UAV kind half2_texture_uav 1d-array without a manifest. Deliberately mapping that dimension to tex2da makes the new control fail.
  • Through the slot 67/14 published route, six views matched 6,688 halfwords per adapter and configuration after fenced readback, including 1,024 untouched halfwords from mip 0. The wrong R32 and R32G32 views left their sentinels intact. Shifting the 3D UAV's first W slice from 1 to 0 changed exactly 16 halfwords on both adapters. The first difference was component 256, expected 0x5100, read 0x3c00.
  • Debug and Release each passed the three exact-head tests on RTX 4070 and app-local WARP. The broader selection passed 20/20 per configuration from the same source changes before the commit was recorded. The stock Windows PR smoke ran with the pinned SPIR-V tools and finished with 70 passes and three XMem capability skips. Those skips exercise a placeholder fallback the OS does not take.
  • I also probed special half values through the published path. Both adapters preserved positive and negative minimum subnormals, negative zero, infinity and the tested quiet NaN. The signaling NaN 0x7c55 was stored as quiet 0x7e55 on both. Guest hardware parity for signaling NaN remains unverified.

Windows 26300.10075, MSVC 19.52.37029, DXC 1.9.2602.17, Agility 1.620.2. RTX 4070 10de:2786, driver 32.0.16.2124, wave32. WARP 1.0.22 1414:008c, forced wave32 verified. The debug layer was enabled on both and reported no errors in the fixture. Inbox WARP separately reported four lanes and skipped the wave32 probe.

# Run once for each of the dev and release presets with Agility and WARP configured.
cmake --build --preset <preset> --target compile_dxil d3d12_xs_shim startup_stream_consumer offscreen_check native_compute_manifest_reasons
ctest --preset <preset> --no-tests=error -j 1 -V -R '^(startup_compute_(half_image_uav_.*|half_buffer_uav_.*|dispatch_(texture|two_mips)_(hardware|warp))|native_image_store_exact_width_hardware_.*|native_direct_container|native_compute_manifest_reasons(_requests)?)$'

An independent run of the 1D-array refusal and shifted-W control on the refreshed head would be useful. I used Codex to prepare the change and ran the reported checks locally.

@Leyukaka

Copy link
Copy Markdown
Collaborator

This branch conflicts with main 1990fead in tests/startup_stream_consumer.cpp only (one region: the mode flags at the top of texture_slot67). The other files merge cleanly.

Resolution: keep this branch's side (half*, shifted_w, volume, line, first_mip, width, height), add main's const bool sampled = mode == "texture-volume-native-sampled"; with its comment, and start the volume condition with sampled ||.

No review is recorded on this PR yet, and the new tests need a re-run on the merged head.

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

Reviewed 905db2e4 at the head itself, not integrated: it conflicts with main f4e2e5c6, so I am requesting changes for that alone. Everything else below passed here and is non-blocking.

Blocking: conflict with main. git merge-tree --write-tree origin/main 905db2e4 exits 1 with one conflict, in tests/startup_stream_consumer.cpp, at the mode flags at the top of texture_slot67. main added texture-volume-native-sampled there (af6045df, merged with #3154); this branch added the texture-exact-half-* flags in the same lines. The other six files merge cleanly. Please merge main and re-run the new tests; both sides' flags need to stay (sampled || at the start of volume, plus this branch's half*, shifted_w, width and height).

What I traced. The publisher branch in format_compute_runtime_manifest takes half_scalar_uav and half2_texture_uav before the float branches, maps ISA dimensions 0, 1, 2 and 5 explicitly and refuses the rest through view_shape. The binder parses the half table line into narrow_half_texture, checks the view and resource formats with native_half_store_format(...).accepts, queries typed-store support on the typed format and binds the view with that format. For the existing float path store_format is still resource.Format, so that path is unchanged. The two merge commits on the branch are the author's.

Tests at 905db2e4 (targets compile_dxil d3d12_xs_shim startup_stream_consumer offscreen_check native_compute_manifest_reasons, dev and release):

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(startup_compute_(half_image_uav_(controls|warp)|half_buffer_uav_(controls|warp)|dispatch_(texture|two_mips)_warp)|native_direct_container|native_compute_manifest_reasons(_requests)?)$'
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(startup_compute_(half_image_uav|half_buffer_uav|dispatch_texture|dispatch_two_mips)_hardware|native_image_store_exact_width_hardware_.*)$'
  • Non-hardware: 7 passed and 2 skipped in each configuration. The two skips are startup_compute_half_image_uav_warp and startup_compute_half_buffer_uav_warp: the inbox WARP here reports a 4-lane wave, so the wave32 probe returns 77. I did not run the new fixture on WARP.
  • Hardware: 11/11 in each configuration, no skips, debug layer enabled with no error message. startup_compute_half_image_uav_hardware matched 32 + 1,280 + 512 + 256 + 3,072 + 1,536 = 6,688 halfwords across the six views, the same total you reported. The shifted-W control printed 16 differences, first component 256 expected 5100, read 3c00. The 1D-array control printed 1D-array D16 store compiled and was refused at manifest publication.
  • git diff --check against the merge base 052abe6f is clean.

Mutants (dev build, startup_compute_half_image_uav_controls and _hardware):

Killed (12):

  • publisher branch disabled (negative control): both tests fail, no manifest;
  • dimension 4 mapped to tex2da instead of refused: _controls fails on the refusal reason;
  • channels 1 and 2 swapped in the manifest line; dimension 0 as tex2d; dimension 2 as tex2d: both tests fail on the expected line;
  • binder format check removed: the R32 control's consumer exits non-zero;
  • store_format = half.typed removed; kind chosen by swapped channel count; narrow_half_texture not set by the parser; typed-store query on resource.Format: all fail on a halfword mismatch;
  • accepts without the typeless resource; scalar typeless set to R16G16_TYPELESS: the typeless case fails.

Survive (3), none blocking:

  • accepts with the view-format comparison removed (resource == typed || resource == typeless only). The R32 controls change the view and the resource together, so nothing separates the two halves of the check. With this mutant a non-float 16-bit view of an R16_TYPELESS resource would be rebound as R16_FLOAT. An R16_UNORM (or R16_UINT) view of the typeless texture that expects the D16 refusal and untouched sentinels would pin it.
  • b.array_count == 1 relaxed to >= 1 in the publisher: no case has a descriptor array of a half kind.
  • parser accepting channels 3 on a half table line: the publisher never writes it, and no test feeds the runtime a hand-written line.

Equivalent in practice (1): accepts with the resource-format comparison removed. A created R16_FLOAT view implies an R16 family resource, and an uncreated view is refused earlier.

Not run: a mutant that disables the typed-store support check. My pattern for it matched twice, and on this adapter the format supports typed stores, so it could not have been killed here.

Title run: the run of this head gave no verdict (job 32 ended in error without a run result), so this review does not include one.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; NVIDIA GeForce RTX 5090 driver 32.0.16.1088, debug layer enabled; inbox WARP 10.0.26100.9818 (4 lanes, wave32 cases skipped).
CI: Build and test on Windows passed on 905db2e4; as noted earlier in the thread, that job does not run the half_image_uav tests.

This reply was AI-assisted.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for the 1D-array control and the special-value probes. I re-checked 905db2e4 against current main (c04e0dd6). Our two earlier points are answered:

  1. Dimension guard. tests/startup_compute_half_image_uav_check.py now expects unsupported startup runtime manifest bindings: UAV kind half2_texture_uav 1d-array for a source-built D16 1D-array store. pigalot's mutant that maps dimension 4 to tex2da fails on that reason.
  2. Header comment. The header of d3d12_compute_dispatch.inl now lists uav <i> <dimension> <float|half> table <param> <byte> channels <n>, next to the bufhalf form.

The only thing left is the conflict in tests/startup_stream_consumer.cpp that pigalot and Leyukaka described. It is still the only conflict on c04e0dd6 (git merge-tree --write-tree c04e0dd6 905db2e4 exits 1, one file). This publisher runs on the native compute path, which #3449 made the launcher default. So once main is merged in, the new tests need a re-run on the merged head. After that, nothing from us blocks it.

Environment: Linux only: git objects and git merge-tree. I did no build, WARP or GPU run.

This comment was AI-assisted.

@Leyukaka

Copy link
Copy Markdown
Collaborator

Update to our 11-29 12:06 comment, which named only the mode flags: on main ff9dcef0, git merge-tree --write-tree origin/main 905db2e4 now reports conflicts in two files.

  • tests/startup_stream_consumer.cpp: the mode flags at the top of texture_slot67 (main now also has zero_w and native_inputs next to sampled), and the Texture3D view line, where main's if (zero_w) view.Texture3D.WSize = 0; and this branch's shifted_w ? 0u : 1u are both needed.
  • src/startup_stubs/d3d12_compute_dispatch.inl: the header comment and the slot struct, where both atomic (from compute: indexed atomic UAV dispatch (takeover of #3417) #3454) and narrow_half_texture should be kept.

We will review again after the rebase.

@Leyukaka

Leyukaka commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Taking this over since there has been no activity for 48 h; will hand back if you resume. Your commits stay as they are and keep your authorship; I will rebase onto current main, address the open review points and report the test results here.

@Leyukaka

Leyukaka commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Continued in #3766 (rebased onto main, review points addressed, local test results in the description). Your commits are kept with your authorship; if you resume, say so there and I will hand it back.

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