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.

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