runtime: bind the title's sampler heap for published native compute #3540

Merged
JB2WIN merged 6 commits from upstream-pr/3540 into main 2026-11-30 08:58:32 +00:00
JB2WIN commented 2026-11-30 02:45:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-30T02:45:21Z.


Change

#3076 stage 2a. A native compute program that reads samplers from the directly indexed sampler heap at a fixed index (stage 1, SamplerDescriptorHeap[i]) now gets a published runtime manifest, and the stand-in's Dispatch binds the title's sampler heap for it. Until now compile_dxil --requests published no manifest for such a program.

  • Writer (format_compute_runtime_manifest): the single heap_sampler binding is taken out of the view bookkeeping before the sort, stride and contiguity loops, and written as smpidx <bytes> after the static sampler lines. Exactly one binding, with root compute_sampler_heap, register 0 and a span of whole 16-byte entries up to 16*2047. Any other shape keeps the reason sampler heap.
  • Reader (load_compute_translation): smpidx is accepted once, with whole 16-byte entries below the fallback entry 2047. Otherwise the reason is a sampler heap span that is not 16-byte entries below the fallback.
  • Root: create_translated_root gets a trailing extra_flags parameter, and a translation with smpidx adds D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED. Graphics callers are unchanged.
  • Dispatch: the heap is the draw path's snapshot (prepare_draw_sampler_heap, keeping the list's fallback setting). It is bound with the view heap before the root signature. Refusals, all before a descriptor is taken: no sampler heap is set on the list, sampler heap creation failed, the sampler heap has no readable entries, the sampler heap is smaller than the program reads.

Refs #3076, #3023. The in-process route is unchanged. dynamic_sampler, create_sampler_snapshot_heap and decode_statics are not touched (#3199).

Verification

Build on 2ff74a6a, Windows 11, NVIDIA GeForce RTX 3080.

  • New startup_compute_dispatch_sampler_heap_hardware, a stand-in dispatch through a title sampler heap in title memory with the debug layer on and no error:

    • all 32 lanes equal the CPU model of entry 67;
    • four decoys in slot 67 each change the output;
    • a view heap only gives no sampler heap is set on the list;
    • a 67-entry heap gives the sampler heap is smaller than the program reads;
    • a 68-entry heap (1088 bytes) runs;
    • a manifest span of 1104 on 68 entries is refused;
    • smpidx removed from the .txt gives pipeline creation failed, which shows the root flag matters;
    • the reader rejects smpidx 0, 20, 32768, -16 and a second smpidx.

    _warp runs the manifest and reader parts, then exits 77 (no 32-lane waves).

  • New CPU test native_compute_manifest_sampler_heap (24 checks): the exact text, smpl plus smpidx, the binding placed first, between or last among t0 and a stride SRV with the same text, and nullopt for two bindings, a wrong root, or a bad span.

  • native_sampler_heap_check.py: the "no .txt" assertion becomes the exact published manifest (SAMPLE smpidx 1088, TWO smpidx 1104, MIXED smpl 0 … then smpidx 1088). This is the intended behaviour change.

  • ctest -R "startup_compute|native_sampler|startup_sampler|direct_compute|native_compute": baseline 228 tests with 0 failures; after 231 with 0 failures. The skips are the same WARP cases plus the new one.

  • Mutations, each rebuilt and run on hardware:

    • without the root flag: the hardware test fails;
    • without writing smpidx: the hardware test, the CPU test and native_sampler_heap_hardware fail;
    • the bound entry shifted by one: every lane reads the neighbour's texel, and the dispatch is still logged as translated.

Evidence and follow-up

All fixtures are source-built (the stage 1 program and its CPU model, the stand-in's own heap). No game data.

Not covered by a test: the wrapper-only sampler heap path (a heap without title memory, refused as empty if no shadow heap is readable), ExecuteIndirect, a draw and a sampler-heap dispatch alternating on one list, and sampler heap creation failed. The 1.0 root with the flag is verified on the RTX 3080 only. No revision bump: manifests published before keep their meaning, and only programs that had no manifest get one.

On main this publishes no extra local capture program, because those stop earlier, at the resource heap. It is groundwork for #3023 stage 3, where gather through the sampler heap follows next.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (docs/experiments/native-sampler-heap.md)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5558042645 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3540). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-30T02:45:21Z. --- ## Change #3076 stage 2a. A native compute program that reads samplers from the directly indexed sampler heap at a fixed index (stage 1, `SamplerDescriptorHeap[i]`) now gets a published runtime manifest, and the stand-in's Dispatch binds the title's sampler heap for it. Until now `compile_dxil --requests` published no manifest for such a program. - Writer (`format_compute_runtime_manifest`): the single `heap_sampler` binding is taken out of the view bookkeeping before the sort, stride and contiguity loops, and written as `smpidx <bytes>` after the static sampler lines. Exactly one binding, with root `compute_sampler_heap`, register 0 and a span of whole 16-byte entries up to 16*2047. Any other shape keeps the reason `sampler heap`. - Reader (`load_compute_translation`): `smpidx` is accepted once, with whole 16-byte entries below the fallback entry 2047. Otherwise the reason is `a sampler heap span that is not 16-byte entries below the fallback`. - Root: `create_translated_root` gets a trailing `extra_flags` parameter, and a translation with `smpidx` adds `D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED`. Graphics callers are unchanged. - Dispatch: the heap is the draw path's snapshot (`prepare_draw_sampler_heap`, keeping the list's fallback setting). It is bound with the view heap before the root signature. Refusals, all before a descriptor is taken: `no sampler heap is set on the list`, `sampler heap creation failed`, `the sampler heap has no readable entries`, `the sampler heap is smaller than the program reads`. Refs #3076, #3023. The in-process route is unchanged. `dynamic_sampler`, `create_sampler_snapshot_heap` and `decode_statics` are not touched (#3199). ## Verification Build on `2ff74a6a`, Windows 11, NVIDIA GeForce RTX 3080. - New `startup_compute_dispatch_sampler_heap_hardware`, a stand-in dispatch through a title sampler heap in title memory with the debug layer on and no error: - all 32 lanes equal the CPU model of entry 67; - four decoys in slot 67 each change the output; - a view heap only gives `no sampler heap is set on the list`; - a 67-entry heap gives `the sampler heap is smaller than the program reads`; - a 68-entry heap (1088 bytes) runs; - a manifest span of 1104 on 68 entries is refused; - `smpidx` removed from the `.txt` gives `pipeline creation failed`, which shows the root flag matters; - the reader rejects `smpidx 0`, `20`, `32768`, `-16` and a second `smpidx`. `_warp` runs the manifest and reader parts, then exits 77 (no 32-lane waves). - New CPU test `native_compute_manifest_sampler_heap` (24 checks): the exact text, `smpl` plus `smpidx`, the binding placed first, between or last among `t0` and a stride SRV with the same text, and nullopt for two bindings, a wrong root, or a bad span. - `native_sampler_heap_check.py`: the "no `.txt`" assertion becomes the exact published manifest (SAMPLE `smpidx 1088`, TWO `smpidx 1104`, MIXED `smpl 0 …` then `smpidx 1088`). This is the intended behaviour change. - `ctest -R "startup_compute|native_sampler|startup_sampler|direct_compute|native_compute"`: baseline 228 tests with 0 failures; after 231 with 0 failures. The skips are the same WARP cases plus the new one. - Mutations, each rebuilt and run on hardware: - without the root flag: the hardware test fails; - without writing `smpidx`: the hardware test, the CPU test and `native_sampler_heap_hardware` fail; - the bound entry shifted by one: every lane reads the neighbour's texel, and the dispatch is still logged as translated. ## Evidence and follow-up All fixtures are source-built (the stage 1 program and its CPU model, the stand-in's own heap). No game data. Not covered by a test: the wrapper-only sampler heap path (a heap without title memory, refused as empty if no shadow heap is readable), `ExecuteIndirect`, a draw and a sampler-heap dispatch alternating on one list, and `sampler heap creation failed`. The 1.0 root with the flag is verified on the RTX 3080 only. No revision bump: manifests published before keep their meaning, and only programs that had no manifest get one. On `main` this publishes no extra local capture program, because those stop earlier, at the resource heap. It is groundwork for #3023 stage 3, where `gather through the sampler heap` follows next. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (`docs/experiments/native-sampler-heap.md`) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
JB2WIN commented 2026-11-30 03:22:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-30T03:22:39Z.


The Linux Python job failed in startup_triage_run_check.py, because the new dispatch refusals were missing from COMPUTE_DISPATCH_REASONS. 37a6b269 adds them. It also adds an output UAV interval exceeds the D3D12 buffer view element limit from #3471, which is on main and was missing from the list as well. I merged main first (d6262698). startup_triage_run_check.py now reports 0 failed, and ctest -R 'sampler_heap|native_compute_manifest|startup_compute_dispatch|output_uav' passes 43/43.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7267837877 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3540#issuecomment-7267837877). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-30T03:22:39Z. --- The Linux Python job failed in `startup_triage_run_check.py`, because the new dispatch refusals were missing from `COMPUTE_DISPATCH_REASONS`. 37a6b269 adds them. It also adds `an output UAV interval exceeds the D3D12 buffer view element limit` from #3471, which is on `main` and was missing from the list as well. I merged `main` first (d6262698). `startup_triage_run_check.py` now reports 0 failed, and `ctest -R 'sampler_heap|native_compute_manifest|startup_compute_dispatch|output_uav'` passes 43/43. AI-assisted.
lukaslw-lab commented 2026-11-30 07:25:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T07:25:46Z.

Review: APPROVED


Reviewed 37a6b269 by reading the diff; not built or run.

Verdict: approve. The writer and the reader agree on the one shape they accept: a single heap_sampler binding of whole 16-byte entries below entry 2047 (src/direct_compute_cache.cpp:948-959, d3d12_compute_dispatch.inl:433-437). Every other shape keeps the old reasons. The heaps are bound before SetComputeRootSignature, and every new refusal comes before a view descriptor is taken. No MUST.

  • SHOULD "sampler heap creation failed" (d3d12_compute_dispatch.inl:1309) is the only new reason missing from COMPUTE_DISPATCH_REASONS. startup_triage_run_check.py does not catch it, because its reason_start pattern only collects literals that start with a/an/the/no/…. So triage_run.py would report this refusal as other (text omitted), the case that check exists to prevent. Rewording it to "the sampler heap could not be created" and listing it fixes both.
  • SHOULD At :268 the PR returns "the device does not take a directly indexed sampler heap" for any create_translated_root failure when smpidx is set. Serialisation or root creation can also fail for other reasons (parameter count, static samplers), and this text would hide those. Checking the resource binding tier first, or keeping "root signature creation failed" for other HRESULTs, would make the reason reliable.
  • Checked: prepare_draw_sampler_heap sets sampler_snapshot on every true return, so the ->count dereference at :1310 is safe. A program without smpidx keeps the bound sampler heap. #3542 adds the same #3471 reason line, and git merge-tree of the two heads merges cleanly.

Tests: native_compute_manifest_sampler_heap proves the writer text and its refusals. startup_compute_dispatch_sampler_heap_hardware proves the dispatch, the decoys and each size refusal, and the smpidx-removed control shows the root flag matters. The _warp variant exits 77 after the reader checks. Neither test is in the pr preset filter, so CI ran only the Linux triage check; the dispatch evidence is the author's RTX 3080 run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6108262538 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3540#pullrequestreview-6108262538). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-30T07:25:46Z. **Review:** APPROVED --- Reviewed `37a6b269` by reading the diff; not built or run. **Verdict: approve.** The writer and the reader agree on the one shape they accept: a single `heap_sampler` binding of whole 16-byte entries below entry 2047 (`src/direct_compute_cache.cpp:948-959`, `d3d12_compute_dispatch.inl:433-437`). Every other shape keeps the old reasons. The heaps are bound before `SetComputeRootSignature`, and every new refusal comes before a view descriptor is taken. No MUST. - **SHOULD** `"sampler heap creation failed"` (`d3d12_compute_dispatch.inl:1309`) is the only new reason missing from `COMPUTE_DISPATCH_REASONS`. `startup_triage_run_check.py` does not catch it, because its `reason_start` pattern only collects literals that start with a/an/the/no/…. So `triage_run.py` would report this refusal as `other (text omitted)`, the case that check exists to prevent. Rewording it to "the sampler heap could not be created" and listing it fixes both. - **SHOULD** At `:268` the PR returns "the device does not take a directly indexed sampler heap" for any `create_translated_root` failure when `smpidx` is set. Serialisation or root creation can also fail for other reasons (parameter count, static samplers), and this text would hide those. Checking the resource binding tier first, or keeping "root signature creation failed" for other HRESULTs, would make the reason reliable. - Checked: `prepare_draw_sampler_heap` sets `sampler_snapshot` on every `true` return, so the `->count` dereference at `:1310` is safe. A program without `smpidx` keeps the bound sampler heap. #3542 adds the same #3471 reason line, and `git merge-tree` of the two heads merges cleanly. Tests: `native_compute_manifest_sampler_heap` proves the writer text and its refusals. `startup_compute_dispatch_sampler_heap_hardware` proves the dispatch, the decoys and each size refusal, and the `smpidx`-removed control shows the root flag matters. The `_warp` variant exits 77 after the reader checks. Neither test is in the `pr` preset filter, so CI ran only the Linux triage check; the dispatch evidence is the author's RTX 3080 run.
JB2WIN commented 2026-11-30 08:39:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-30T08:39:42Z.


Thanks, both addressed in 170d6762, 376dc826 and 8d5163ea.

  1. The refusal is now "the sampler heap could not be created" and is listed in COMPUTE_DISPATCH_REASONS. startup_triage_run_check.py now also scans compute_root_refusal in translated_sampler_bindings.h, where the two root texts live; a wrong text there fails the check.
  2. A serialization failure always keeps "root signature creation failed". "the device does not take a directly indexed sampler heap" is given only when CreateRootSignature refuses a serialized root with the flag on an adapter below shader model 6.6 or resource binding tier 3. That is an inference from the reported capabilities, and the comment and doc say so. A device-free check covers all eight combinations and fails against the earlier logic. The tier query itself is untested here: the RTX 3080 has the capability.

Targeted ctest: 16 run, 14 passed, 2 WARP skips.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7273184980 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3540#issuecomment-7273184980). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-30T08:39:42Z. --- Thanks, both addressed in 170d6762, 376dc826 and 8d5163ea. 1. The refusal is now "the sampler heap could not be created" and is listed in `COMPUTE_DISPATCH_REASONS`. `startup_triage_run_check.py` now also scans `compute_root_refusal` in `translated_sampler_bindings.h`, where the two root texts live; a wrong text there fails the check. 2. A serialization failure always keeps "root signature creation failed". "the device does not take a directly indexed sampler heap" is given only when `CreateRootSignature` refuses a serialized root with the flag on an adapter below shader model 6.6 or resource binding tier 3. That is an inference from the reported capabilities, and the comment and doc say so. A device-free check covers all eight combinations and fails against the earlier logic. The tier query itself is untested here: the RTX 3080 has the capability. Targeted ctest: 16 run, 14 passed, 2 WARP skips. AI-assisted.
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!3540
No description provided.