runtime: bind the title's sampler heap for published native compute #3540
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3540"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 nowcompile_dxil --requestspublished no manifest for such a program.format_compute_runtime_manifest): the singleheap_samplerbinding is taken out of the view bookkeeping before the sort, stride and contiguity loops, and written assmpidx <bytes>after the static sampler lines. Exactly one binding, with rootcompute_sampler_heap, register 0 and a span of whole 16-byte entries up to 16*2047. Any other shape keeps the reasonsampler heap.load_compute_translation):smpidxis accepted once, with whole 16-byte entries below the fallback entry 2047. Otherwise the reason isa sampler heap span that is not 16-byte entries below the fallback.create_translated_rootgets a trailingextra_flagsparameter, and a translation withsmpidxaddsD3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED. Graphics callers are unchanged.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_heapanddecode_staticsare 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:no sampler heap is set on the list;the sampler heap is smaller than the program reads;smpidxremoved from the.txtgivespipeline creation failed, which shows the root flag matters;smpidx 0,20,32768,-16and a secondsmpidx._warpruns 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,smplplussmpidx, the binding placed first, between or last amongt0and 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 (SAMPLEsmpidx 1088, TWOsmpidx 1104, MIXEDsmpl 0 …thensmpidx 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:
smpidx: the hardware test, the CPU test andnative_sampler_heap_hardwarefail;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, andsampler 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
mainthis publishes no extra local capture program, because those stop earlier, at the resource heap. It is groundwork for #3023 stage 3, wheregather through the sampler heapfollows next.Checklist
docs/experiments/native-sampler-heap.md)AI-assisted.
🤖 Generated with Claude Code
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 fromCOMPUTE_DISPATCH_REASONS.37a6b269adds them. It also addsan output UAV interval exceeds the D3D12 buffer view element limitfrom #3471, which is onmainand was missing from the list as well. I mergedmainfirst (d6262698).startup_triage_run_check.pynow reports 0 failed, andctest -R 'sampler_heap|native_compute_manifest|startup_compute_dispatch|output_uav'passes 43/43.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T07:25:46Z.
Review: APPROVED
Reviewed
37a6b269by reading the diff; not built or run.Verdict: approve. The writer and the reader agree on the one shape they accept: a single
heap_samplerbinding 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 beforeSetComputeRootSignature, and every new refusal comes before a view descriptor is taken. No MUST."sampler heap creation failed"(d3d12_compute_dispatch.inl:1309) is the only new reason missing fromCOMPUTE_DISPATCH_REASONS.startup_triage_run_check.pydoes not catch it, because itsreason_startpattern only collects literals that start with a/an/the/no/…. Sotriage_run.pywould report this refusal asother (text omitted), the case that check exists to prevent. Rewording it to "the sampler heap could not be created" and listing it fixes both.:268the PR returns "the device does not take a directly indexed sampler heap" for anycreate_translated_rootfailure whensmpidxis 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.prepare_draw_sampler_heapsetssampler_snapshoton everytruereturn, so the->countdereference at:1310is safe. A program withoutsmpidxkeeps the bound sampler heap. #3542 adds the same #3471 reason line, andgit merge-treeof the two heads merges cleanly.Tests:
native_compute_manifest_sampler_heapproves the writer text and its refusals.startup_compute_dispatch_sampler_heap_hardwareproves the dispatch, the decoys and each size refusal, and thesmpidx-removed control shows the root flag matters. The_warpvariant exits 77 after the reader checks. Neither test is in theprpreset filter, so CI ran only the Linux triage check; the dispatch evidence is the author's RTX 3080 run.Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-30T08:39:42Z.
Thanks, both addressed in
170d6762,376dc826and8d5163ea.COMPUTE_DISPATCH_REASONS.startup_triage_run_check.pynow also scanscompute_root_refusalintranslated_sampler_bindings.h, where the two root texts live; a wrong text there fails the check.CreateRootSignaturerefuses 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.