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

Merged
Not-Saii merged 4 commits from upstream-pr/3460 into main 2026-11-30 08:46:33 +00:00
Not-Saii commented 2026-11-29 14:40:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T14:40:04Z.


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 087b17ca, 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 (8f2e448f, 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 4932e061. 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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5551770214 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3460). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-29T14:40:04Z. --- 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. ```powershell ctest --preset dev --no-tests=error -R '^startup_compute_typed_buffer_(srv|uav)_(native_)?(warp|hardware)$' -V ``` Results at 087b17ca, 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 (8f2e448f, 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 4932e061. 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](https://claude.com/claude-code)
Leyukaka commented 2026-11-29 15:03:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T15:03:26Z.

Review: APPROVED


Read at 56826014 against main 5de0b114 (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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6103432063 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3460#pullrequestreview-6103432063). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T15:03:26Z. **Review:** APPROVED --- Read at 56826014 against main 5de0b114 (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.
Not-Saii commented 2026-11-29 15:17:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T15:17:53Z.


Thanks. All four are fixed in 8f2e448f:

  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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7257977456 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3460#issuecomment-7257977456). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-29T15:17:53Z. --- Thanks. All four are fixed in 8f2e448f: 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 commented 2026-11-29 15:36:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T15:36:28Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6103557235 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3460#pullrequestreview-6103557235). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T15:36:28Z. **Review:** APPROVED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3460
No description provided.