Skip to content

runtime: bind published typed buffer outputs with 32-bit components - #3397

Open
Not-Saii wants to merge 8 commits into
R0Y00:mainfrom
Not-Saii:runtime/typed-buffer-uav
Open

Not-Saii wants to merge 8 commits into
R0Y00:mainfrom
Not-Saii:runtime/typed-buffer-uav

Conversation

@Not-Saii

@Not-Saii Not-Saii commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Refs #3224

Stacked on #3386 (typed buffer inputs). It uses #3386's typed_bytes slot field and its gfx10 FORMAT helper, and turns #3386's descriptor checks into one function shared by inputs and outputs. Until #3386 merges, this diff also shows #3386's commits. This PR's own commits are 4598d597, 3d93cffa (docs) and 31417719 (review cases); 3b5679f7 merges #3386's review commit. I'll rebase once #3386 lands.

Behavior

In @Leyukaka's measurement of #3386, 32 programs (2,001,657 dispatches) move from SRV kind typed_buffer_srv to UAV kind typed_buffer_uav, which makes it the largest remaining "compiles, but no runtime manifest" reason. These programs store with buffer_store_format_x to _xyzw (MUBUF, element index only), which the direct compiler writes as an RWBuffer<uint4>.

  • Manifest (src/direct_compute_cache.cpp): writes uav <register> typed table <parameter> <byte> bytes <n>, where n is 4 bytes per stored component. The compiler already refuses mixed store widths on one slot.
  • Stand-in (src/startup_stubs/d3d12_compute_dispatch.inl): binds a UINT typed UAV of the title's 32-bit components whose channel count equals the stored components. It reuses existing paths instead of adding a parallel one:
  • Each refusal has its own reason, listed in docs/experiments/compute-typed-buffer-inputs.md. 8- and 16-bit formats, UNORM, SNORM and 16-bit FLOAT stay refused, because a UINT view does not convert.
  • tests/native_compute_manifest_reasons.cpp: the UAV kind typed_buffer_uav case now uses a 20-byte width that the line cannot carry. It used to rely on a zero width.

Not in this PR: whether the 32 programs dispatch translated. A published manifest can still stop at a runtime input check, such as the placed-buffer check of #2860 / #2862. The re-measure follows on #3224.

Tests

tests/startup_compute_typed_buffer_uav_check.py (tests/cmake/startup_compute_typed_buffer_uav.cmake) uses the published route: compile_dxil --requests → <key>.txt → slot 14 Dispatch on the stand-in.

  • _controls (no GPU): source-built stores of 1 to 4 components publish uav 0 typed table 1 32 bytes 4n.
  • _warp / _hardware: each of the 384 lanes stores words computed from its element index through a 32-bit FLOAT descriptor of 50 elements, so only those elements change.
    • The 1-component case also stores through the consumer's slot 19 R32_UINT token (312 elements from element 4), and a structured token must be refused.
    • Each width also stores through its UINT and SINT FORMATs, and through a descriptor 8 bytes into the output (dispatch-records32-output-offset). 1 and 2 components store shifted by that much; 3 and 4 components are refused as not element-aligned.
    • Refusal controls, each with the output untouched: an 8_8_8_8_UNORM FORMAT, a wrong stride, word 1 bit 30, OOB_SELECT 3, a legacy FORMAT, a FORMAT of another width, and swapped X/Y DST_SEL.
    • Before publication the dispatch reports no translation.

Verification

Windows 11 build 26300, MSVC x64 Debug, Windows SDK 10.0.26100 DXC, D3D12 debug layer enabled. Branch head 3d93cffa = #3386 (4a2720e0, on main d418f70e) + 4598d597 + 3d93cffa.

cmake --build --preset dev --target compile_dxil d3d12_xs_shim startup_stream_consumer offscreen_check native_compute_manifest_reasons
ctest --preset dev --no-tests=error -V -R "^(startup_compute_typed_buffer_uav_(controls|warp|hardware)|startup_compute_typed_buffer_srv_(controls|hardware)|native_compute_manifest_reasons)$"

AI-assisted.

🤖 Generated with Claude Code

Not-Saii and others added 5 commits November 28, 2026 19:51
format_compute_runtime_manifest writes `srv <i> typed table <param>
<byte> bytes <n>` for a typed_buffer_srv (buffer_load_format_*, read as
Buffer<uint4>), n being the widest load. The stand-in resolves the
title's hardware descriptor or slot 18 typed buffer view token as a
buffer range and binds a UINT view of its 32-bit components; every
other shape is refused with a named reason.

Refs R0Y00#3224

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
format_compute_runtime_manifest writes `uav <i> typed table <param>
<byte> bytes <n>` for a typed_buffer_uav (buffer_store_format_*, an
RWBuffer<uint4>). The stand-in binds it as a UINT typed UAV: a hardware
descriptor through the output path of the R0Y00#3302 D16 stores, with the
FORMAT checks of the R0Y00#3386 typed inputs (now shared) and an exact
component width; a slot 19 token through native_buffer_store_view, the
native route's typed-store contract. Typed UAV store support is checked
by one helper for both half and 32-bit typed outputs.

Refs R0Y00#3224

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Not-Saii and others added 3 commits November 28, 2026 22:12
…bits

Review of R0Y00#3386: four mutations of the typed input view still passed.
The hardware check now also reads each width through its UINT and SINT
FORMATs and through a descriptor based one element into the buffer
(new consumer mode dispatch-records32-input-at-<bytes>), and refuses a
base 4 bytes in (2 or more components) and a stride field with bit 30.

Refs R0Y00#3224

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… bits

The gaps the R0Y00#3386 review found in the typed input check exist for the
typed outputs too. Each stored width now also writes through its UINT
and SINT FORMATs and through a descriptor 8 bytes into the output
buffer (shifted for 1 and 2 components, refused as not element-aligned
for 3 and 4), and a stride field with word 1 bit 30 is refused.

Refs R0Y00#3224

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — thorough, well-documented.

Adds typed buffer inputs (buffer_load_format_) and outputs (buffer_store_format_) on the published compute route. Helper functions validate gfx10 unified buffer FORMAT, stride, DST_SEL, bounds mode, and typed UAV store support. Manifest emits srv/uav typed table <param> <byte> bytes <n> lines. Dispatch stub resolves table entries, binds UINT views of 32-bit components, and refuses invalid descriptors with precise reasons. Test fixtures cover 1–4 components, UINT/SINT FORMATs, view tokens, and multiple refusal controls per width.

Ready to land.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean, well-tested.

Adds srv/uav typed manifest lines for 32-bit component typed buffer inputs and outputs. typed_dword_format_channels maps gfx10 unified FORMAT codes to channel counts; typed_dword_descriptor validates FORMAT, stride, DST_SEL, and bounds mode; typed_dword_input_view resolves table descriptors and view tokens to UINT views; typed_buffer_store_supported checks UAV_TYPED_STORE capability. Each invalid shape is refused with a named reason. Test fixtures cover 1-4 component inputs and outputs with negative controls.

Ready to land.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — publishes typed buffer inputs and outputs on the compute manifest route.

Adds srv typed and uav typed manifest lines for buffer_load_format_* and buffer_store_format_* bindings. The runtime reader resolves them as UINT views of 32-bit components with FORMAT/stride/DST_SEL/bounds validation. typed_dword_descriptor checks hardware descriptors; typed_dword_input_view handles view tokens and null buffers. typed_buffer_store_supported checks UAV store capability.

Refusal reasons cover FORMAT width, stride, DST_SEL, swizzle, channel count, element alignment, and token compatibility. Indirect dispatch requires fixed-table raw buffers for typed views.

Tests cover 1-4 component widths, UINT/SINT/FLOAT FORMATs, view tokens, and multiple invalid descriptor controls. Manifest reasons test updated to reject 20-byte typed stores.

Documentation is thorough with clear validation rules and measured results.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — publishes typed buffer inputs and outputs on the compute manifest route.

Adds srv typed and uav typed manifest lines for buffer_load_format_* and buffer_store_format_* bindings. The runtime reader resolves them as UINT views of 32-bit components with FORMAT/stride/DST_SEL/bounds validation. typed_dword_descriptor checks hardware descriptors; typed_dword_input_view handles view tokens and null buffers. typed_buffer_store_supported checks UAV store capability.

Refusal reasons cover FORMAT width, stride, DST_SEL, swizzle, channel count, element alignment, and token compatibility. Indirect dispatch requires fixed-table raw buffers for typed views.

Tests cover 1-4 component widths, UINT/SINT/FLOAT FORMATs, view tokens, and multiple invalid descriptor controls. Manifest reasons test updated to reject 20-byte typed stores.

Documentation is thorough with clear validation rules and measured results.

@Leyukaka

Copy link
Copy Markdown
Collaborator

Reviewed 31417719 by its diff (it carries #3386 up to da4fe59c). The binding logic reads correctly: 32-bit UINT/SINT/FLOAT only, FORMAT width equal to the stored components, stride 4 × channels, FirstElement from an element-aligned offset, write-back through the existing placed-alias UAV path, indirect dispatch refused. Test gaps, each a one-line change that the current cases would not catch (by reading):

  1. Token binding: tokens are only tested with one component, so slot.typed_bytes → 4 would accept a 2-4 component store through an R32 view. A token case with two or four components would catch it.
  2. Word 3: no case sets ADD_TID or INDEX_STRIDE, so the mask 0xfff80000u → 0xff000000u passes.
  3. Word 1: bit 31 is never set, so (words[1] >> 30) → ((words[1] >> 30) & 1) passes.
  4. Indirect: there is no indirect typed case, so dropping || slot.typed_bytes from the indirect refusal passes.

Gaps 2-4 are in lines that arrive with #3386 and now sit in the shared typed_dword_descriptor, so they cover the input path too.

Minor: the docs say six refusal controls per width; the script now runs 7, 7, 8 and 8.

This changes runtime binding, so a start-up run before and after is the useful check; in the 900 s census on #3224, UAV kind typed_buffer_uav was the next refusal for 32 of the 112 typed-buffer-input programs (2,001,657 dispatches; measured on #3386).

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