native: read sampler descriptors from the directly indexed sampler heap #3076
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#3076
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@JB2WIN on GitHub · 2026-11-27 14:20 UTC · original
Progress update · 1 December 2026
#3142 merged the fixed-index C++ lowering, #3542 enabled the published native runtime pair, and #3628 preserved the sampler-heap span when installing it. On the
a0e126c2main tree, the manifest test and RTX 4060 Laptop dispatch readback passed. The WARP dispatch case reported a capability skip. The remaining scope is directly indexed sampler heaps on the in-process C++ route. #3156 covers constant static samplers on that route.Part of #2935 (item "Samplers": only constant sampler words are accepted, and there is no sampler-heap path). Related: #1143 (the Python translator's default-sampler shortcut for register-offset sampler-heap loads).
Problem. In slot 67 compute requests whose root sets both heap-indexing flags (0xc00), the entry SGPR after the resource heap holds the sampler heap base. Programs copy it into an even SGPR pair with a zero high word and load a sampler with
s_load_dwordx4(or two withs_load_dwordx8) at a 16-byte aligned immediate offset, then sample withimage_sample_lz/image_sample_l. The native translator marks only the resource heap SGPR (src/gfx1013_compute_native.cpp,translate_program), so such a load is refused ("direct descriptor address outside bound table"), andsampler_indexaccepts constant sampler words only ("nonconstant sampler").On a local start-up capture (counts only,
compile_dxilat36d2cbeb): 1,830 of 2,689 compute requests sample or gather, and 993 load at least one sampler from memory. Onmainthis is never the first refusal yet. With the GPU-selected heap chain of #3023 applied locally (#3034, #3042, #3063, contract forced by an uncommitted switch), 130 requests stop first at such a sampler-heap load.Plan.
main): mark the sampler-heap entry SGPR; accepts_load_dwordx4/x8through it at a 16-byte aligned immediate offset; read the sampler asSamplerDescriptorHeap[offset / 16](createHandleFromHeapwith the sampler-heap flag, module flag0x80000000, root flagSAMPLER_HEAP_DIRECTLY_INDEXED) for explicit-LOD, non-comparison samples. Everything else through the sampler heap (SGPR offsets, scalar buffer loads, comparison, gather, bias, gradients, implicit LOD) is refused with a named reason. No manifest is published for such a program, and the in-process route keeps refusing it, so nothing reaches a run yet.Test. Source-built
.c67requests (DXC root signature with both heap flags) dispatched on hardware with a shader-visible sampler heap: the result changes with the address mode stored in heap entry 67 and not with neighbouring entries; two samplers from onedwordx8load; the sampler's LOD clamp applies toimage_sample_l. Compile refusals for the unsupported shapes._warpskips (wave32), like the other native execution tests.I'm taking it; a PR follows. Environment: Windows 11 build 26200, NVIDIA GeForce RTX 3080.
AI-assisted.
@JB2WIN on GitHub · 2026-11-27 17:49 UTC · original
Stage 1 (translator) is in #3142: fixed-index samplers from the directly indexed sampler heap become
SamplerDescriptorHeap[index]forimage_sample_l/image_sample_lz; everything else through the sampler heap is refused with a named reason. No manifest is published for such a program and the in-process route refuses it, so nothing reaches a run yet.Stage 2 (runtime) has to bind a sampler heap for natively translated compute with index parity (entry n = title byte offset 16·n),
dynamic_sampler()decoding, and entry 2047 as the fallback (the translator never reads 2047).AI-assisted.
@JB2WIN on GitHub · 2026-11-28 00:59 UTC · original
Taking stage 2 (runtime sampler-heap binding for natively translated compute), on
main. I will build on #3156 where the two touchtranslate_compute_nativelyand keep the change separate from #3201.AI-assisted.
@JB2WIN on GitHub · 2026-11-28 03:57 UTC · original
Impact check for stage 2a (runtime binding of the sampler heap on the published route), before building it.
I ran
compile_dxil --jobs 8 gfx1013-direct-cs@0 --requests(main86beae95) on a copy of my 2,689 slot 67 compute requests: 488 compile, 206 publish a manifest, and 282 compile without one. None of the 282 has aheap_samplerbinding, and none of the 2,201 refusals is sampler related. Not-Saii's 84 in #3226 show none either.So stage 2a would unblock 0 programs here. I'm pausing it. The design stays in my notes, and I'll pick it up if a capture shows programs that read the sampler heap on this route.
AI-assisted.
@JB2WIN on GitHub · 2026-11-29 22:52 UTC · original
Resuming stage 2a (binding the title's sampler heap for published native compute) as groundwork for #3023 stage 3.
Why now: in my local #3023 prototype (heap texture loads stubbed in, plus #3526 and the comparison CLAMP_BORDER change that follows it),
gather through the sampler heap is not translatedbecomes the most frequent first refusal, at 305 of 2,689 compute requests. Translating such a program does not help until the runtime can bind the sampler heap on the published route. Todaycompile_dxil --requestswrites no manifest for a sampler-heap program at all. Onmainthis still moves 0 requests (they stop earlier, at the resource heap). I'll say so in the PR.Scope is as in the plan above: the published-manifest route only. A
smpidx <bytes>manifest line,SAMPLER_HEAP_DIRECTLY_INDEXEDon the translated root, and the title's sampler heap bound at Dispatch through the draw path's snapshot (prepare_draw_sampler_heap), each with a named refusal. I won't touchdynamic_sampleror the snapshot code that #3201 edits. Test: a hardware dispatch through the stand-in with a title sampler heap, entry 67 against decoys.AI-assisted.