Skip to content

runtime: bind published typed buffer inputs with 32-bit components - #3386

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

Not-Saii wants to merge 3 commits into
R0Y00:mainfrom
Not-Saii:runtime/typed-buffer-srv

Conversation

@Not-Saii

Copy link
Copy Markdown
Contributor

Refs #3224

Behavior

In the #3224 census, SRV kind typed_buffer_srv is the largest gap between compiling a compute program and publishing its manifest. These are programs that read with buffer_load_format_x to _xyzw (MUBUF, element index only), which the direct compiler reads as a Buffer<uint4>.

  • Manifest (src/direct_compute_cache.cpp): format_compute_runtime_manifest writes srv <register> typed table <parameter> <byte> bytes <n>. n is 4 bytes per component of the widest load on that binding; required_bytes is already the maximum over the binding's loads.
  • Stand-in (src/startup_stubs/d3d12_compute_dispatch.inl): the dispatch path resolves the table entry with the existing indirect_table_buffer range rules and binds a UINT buffer view (R32_UINT to R32G32B32A32_UINT) over it. A UINT view returns the same bits as the guest format unit only for 32-bit UINT, SINT and FLOAT components, so only those are bound:
    • Hardware descriptor: FORMAT 20-22, 62-64, 72-74 or 75-77, stride equal to the element size, identity DST_SEL over the components read, unified FORMAT, structured bounds (OOB_SELECT 0), and no swizzle, index stride or ADD_TID.
    • Slot 18 typed buffer view token: reuses JB2WIN's typed_dword_channels / typed_dword_uint_format from the heap contract (native: read one-channel typed loads through a GPU-selected heap descriptor #3042).
    • All four words zero: a null buffer that reads zeros, as raw inputs already do.
  • Every other shape is refused before a dispatch is recorded, with one reason per check (listed in docs/experiments/compute-typed-buffer-inputs.md). A typed input on an indirect Dispatch is refused, and the in-process X2W_NATIVE_SHADERS route is unchanged.

Not in this PR:

Tests

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

  • _controls (no GPU): source-built programs for 1 to 4 components publish srv 0 typed table 1 0 bytes 4n.
  • _warp / _hardware: for each width, a 32-bit FLOAT descriptor of 50 elements.
    • The 384 lanes store what they read, so the words past element 49 must be zero.
    • The 4-component case also reads through a slot 18 R32G32B32A32_FLOAT view token (new consumer mode dispatch-srv-token-typed).
    • Refusal controls, each with the output untouched: an 8_8_8_8_UNORM FORMAT, a wrong stride, OOB_SELECT 3, a legacy (RESOURCE_LEVEL 0) FORMAT, swapped X/Y DST_SEL, fewer channels than read, and an R8G8B8A8_UNORM token.
    • Before publication the dispatch reports no translation.

Verification

Commits 89fd41b0, 9a414d17 and 4a2720e0 on main d418f70e. Windows 11 build 26300, MSVC x64 Debug, Windows SDK 10.0.26100 DXC, D3D12 debug layer enabled.

.\tools\dev.ps1
cmake --preset dev
cmake --build --preset dev --target compile_dxil d3d12_xs_shim startup_stream_consumer offscreen_check
ctest --preset dev --no-tests=error -V -R "^startup_compute_typed_buffer_srv_(controls|warp|hardware)$"
  • _controls: passed.
  • _hardware, NVIDIA GeForce RTX 4090, driver 32.0.16.1088: passed. 1, 2, 3 and 4 components read 50 elements and then zeros, the token reads the same elements, and 4, 6, 6 and 7 refusal controls passed. No debug layer errors.
  • _warp, Microsoft Basic Render Driver 10.0.26100.9818: capability skip (77). WARP reports 4-lane waves and the direct module needs 32.
  • Negative control: with the stand-in's parse of the typed line disabled, the manifest is published but not bound, and _hardware fails at word 0 (expected 8b02a7f1, read c5c5c5c5). With the change restored, it passes.

Regressions on the same build, run with -R "^startup_compute_(dispatch|dispatch_input|dispatch_texture|dispatch_native|half_buffer_uav|root_srv_dispatch)_(warp|hardware)$":

  • Passed: startup_compute_dispatch, _dispatch_input, _dispatch_texture and _root_srv_dispatch on WARP and hardware, and _dispatch_native_hardware.
  • Capability skips on WARP: _dispatch_native_warp and _half_buffer_uav_warp.
  • startup_compute_half_buffer_uav_hardware fails, and not because of this change. Its 1-channel D16 store now compiles to packed_d16_x_uav (since 94d2803f), which format_compute_runtime_manifest does not write (no_manifest ... UAV kind unknown). That kind is SimSalabimse's claim on direct compute: untranslated compute shaders of a start-up run ranked by dispatches, with first refusals on main #3224, and this PR changes only the SRV branch. I read this from the code; I did not run that test at main without this change.
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py      # Checked 156 Markdown files and 678 links.
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py   # no bidirectional controls

AI-assisted.

🤖 Generated with Claude Code

Not-Saii and others added 3 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>
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.

1 participant