Skip to content

runtime: bind typed buffer views on the in-process compute route - #3460

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
Not-Saii:runtime/native-typed-buffers
Nov 30, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
Not-Saii:runtime/native-typed-buffers

Conversation

@Not-Saii

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

Copy link
Copy Markdown
Contributor

Refs #3224

What

Since #3449 the launchers set X2W_NATIVE_SHADERS_ONLY=1, so load_compute_translation never reads <key>.txt, and the srv/uav <i> typed bindings from #3386 and #3397 did not run in a default run (pointed out in review). The in-process route, translate_compute_natively, refused both kinds with view kind 1/8 is not bound for a natively translated program.

This change makes translate_compute_natively accept typed_buffer_srv and typed_buffer_uav when required_bytes is 4, 8, 12 or 16. That is the test compile_dxil applies before it writes a typed line, now one helper (x2w::typed_dword_view_bytes) shared by the writer, the manifest parser and this route. A typed store goes to the UAV list, and the slot's typed_bytes is set as the manifest parser sets it. From there the existing dispatch path does the binding: UINT views, tokens, and every named refusal.

No shader or root-signature change: both routes compile the same translate_compute(request, 0, true) module (Buffer<uint4>, RWBuffer<uint[n]>), and the root signature has no per-kind ranges. A typed view selected from the resource heap is still refused, because its root parameter is above 15.

Test

tests/startup_compute_typed_buffer_{srv,uav}_check.py take a new native argument. It sets X2W_NATIVE_SHADERS and X2W_NATIVE_SHADERS_ONLY=1, skips publication, and runs the same cases and refusal controls. On top of that it requires translated natively (and no not translated natively) on every translated Dispatch.

ctest --preset dev --no-tests=error -R '^startup_compute_typed_buffer_(srv|uav)_(native_)?(warp|hardware)$' -V

Results at 087b17c, Debug, Windows build 26300, NVIDIA GeForce RTX 4090 driver 32.0.16.1088, debug layer enabled:

  • _native_hardware, inputs: passed (26.6 s). 1 to 4 components read 50 elements and then zeros, plus the 4-component token, with 8/11/11/12 refusal controls.
  • _native_hardware, outputs: passed (21.5 s). 1, 2 and 4 components plus the tokens; the 3-component store is refused (no R32G32B32 typed UAV), with 7/8/8/9 refusal controls.
  • Manifest-route _hardware checks, both _controls tests and startup_compute_dispatch_native_hardware: passed (no regression).
  • All four _warp tests: capability skip (77). WARP runs 4-lane waves.

After the review fixes (8f2e448, Debug rebuild): the same 11 tests give 7 passed and 4 WARP skips (77), and native_compute_manifest_reasons / _requests passed.

Negative control: I reverted d3d12_compute_dispatch.inl to 4932e06. Both native hardware checks then fail at word 0 with the sentinel c5c5c5c5, and the log shows not translated natively: view kind 1 is not bound for a natively translated program (kind 8 for outputs), then Dispatch(3, 2, 2) refused: no translation.

This covers source-built fixtures only. It does not show that any title program dispatches correctly.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Not-Saii and others added 3 commits November 29, 2026 16:30
translate_compute_natively accepted neither typed_buffer_srv nor
typed_buffer_uav, so since X2W_NATIVE_SHADERS_ONLY=1 became the launcher
default the typed bindings from the manifest route never ran. Set
typed_bytes on the slot for widths of 4 to 16 bytes, as the manifest
parser does, and route typed stores to the UAV list. The typed SRV and
UAV checks gain a native route.

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>

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

Read at 5682601 against main 5de0b11 (3 commits, 6 files). Diff reading only, nothing built or run.

What it fixes. With X2W_NATIVE_SHADERS_ONLY=1, load_compute_translation returns before it reads <key>.txt (d3d12_compute_dispatch.inl:280-283), so only translate_compute_natively can bind a compute program, and its binding loop threw view kind 1/8 is not bound for typed_buffer_srv / typed_buffer_uav. The change accepts both kinds there, so the default path now binds them. The manifest route is not touched.

Checked.

  • The native route sets the same Slot::typed_bytes (:566) that the manifest parser sets (:366, :392). Everything after that is the existing shared code: the indirect refusal (:839), the typed input view (:1022-1025) and the typed store contract (:1087-1088, :1160-1188).
  • The accepted widths are the ones compile_dxil writes a typed line for (direct_compute_cache.cpp:969-970, :1001-1002). array_count != 1 is refused at :554, as the writer requires.
  • A typed_buffer_uav of another width goes to the UAV list (:539-540), then fails supported and throws the same view kind 8 message as before.
  • The new native runs fail if the route is not taken: translated() requires translated natively and no not translated natively. A view kind refusal is not in CAPABILITY_REFUSALS, so it cannot turn into a skip (77).

NITs, none blocking.

  1. The width test required_bytes && <= 16 && % 4 == 0 now exists in 5 places: direct_compute_cache.cpp:969-970 and :1001-1002, d3d12_compute_dispatch.inl:364, :390 and :537-538. A shared helper, like x2w::native_half_buffer_format for bufhalf, would keep them from drifting.
  2. tests/startup_compute_typed_buffer_srv_check.py:132 and tests/startup_compute_typed_buffer_uav_check.py:150: the new assert has 13 spaces before result.stderr[-3000:] on a 151-column line. It looks like a lost line break. Valid Python.
  3. assert keys and not published (srv_check.py:179, uav_check.py:210): the not published half cannot fail. The native branch never calls publish, and the runtime only reads <key>.txt and <key>.cs.cso (d3d12_compute_dispatch.inl:286, :450); nothing in it writes those or <key>.fail. The check that does guard the route is the translated natively assert.
  4. The PR body still says it is stacked on #3397 and #3386 and that the diff includes their commits. Both are merged, and the diff against main is the 3 commits only.

Review of R0Y00#3460: one helper, x2w::typed_dword_view_bytes, replaces the
five copies of the 4-to-16-byte test in compile_dxil's writer, the
manifest parser and the in-process route. The native checks lose a
cache assertion that could not fail (nothing on that route writes
<key>.txt, .cs.cso or .fail); the translated-natively assertion is
what guards the route. Also rewraps that assertion.

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

Copy link
Copy Markdown
Contributor Author

Thanks. All four are fixed in 8f2e448:

  1. One helper, x2w::typed_dword_view_bytes in src/gfx1013_compute_native.h, now replaces the five copies of the 4-to-16-byte test: the two compile_dxil writer branches, the two manifest parser lines and the in-process route.
  2. I rewrapped the assertion. The \ continuation had been lost inside a heredoc.
  3. Dropped the cache assertion. You're right that nothing on that route writes <key>.txt, .cs.cso or .fail. The docs no longer describe it.
  4. The PR body no longer says it is stacked.

Rebuilt (Debug) on the RTX 4090, driver 32.0.16.1088, Windows build 26300. startup_compute_typed_buffer_(srv|uav)_(native_)?(hardware|controls) and startup_compute_dispatch_native_hardware passed. The four _warp tests are capability skips (77). native_compute_manifest_reasons and _requests passed, which covers the writer refusals the helper now decides.

AI-assisted (Claude Code).

@Leyukaka Leyukaka 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-read at 8f2e448f (delta 56826014..8f2e448f, one commit). Diff reading only, nothing built or run.

The four points from my review of 56826014 are addressed:

  1. Width test: one helper, x2w::typed_dword_view_bytes (src/gfx1013_compute_native.h:76), used at direct_compute_cache.cpp:970, :1002 and d3d12_compute_dispatch.inl:364, :390, :538. No other copy of the predicate is left in src.
  2. Assert line break: native_ok is computed on its own line (srv_check.py:132-133, uav_check.py:150-151), same logic.
  3. not published: the if native: cache block is removed from both checks, and docs/experiments/compute-typed-buffer-inputs.md:146 no longer claims it. The translated natively assert still guards the route.
  4. PR body: no longer says it is stacked on #3397 and #3386.

No new issue found in the delta.

@R0Y00
R0Y00 merged commit 7badf72 into R0Y00:main Nov 30, 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