native: read sampler descriptors from the directly indexed sampler heap #3076

Closed
opened 2026-11-27 14:20:52 +00:00 by JB2WIN · 4 comments
JB2WIN commented 2026-11-27 14:20:52 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-27T14:20:52Z.


Progress update · 1 December 2026

#3140 merged the fixed-index C++ lowering, #3540 enabled the published native runtime pair, and #3626 preserved the sampler-heap span when installing it. On the a0e126c2 main 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. #3154 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 with s_load_dwordx8) at a 16-byte aligned immediate offset, then sample with image_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"), and sampler_index accepts constant sampler words only ("nonconstant sampler").

On a local start-up capture (counts only, compile_dxil at 36d2cbeb): 1,830 of 2,689 compute requests sample or gather, and 993 load at least one sampler from memory. On main this 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.

  1. Translator (this issue's first PR, target main): mark the sampler-heap entry SGPR; accept s_load_dwordx4/x8 through it at a 16-byte aligned immediate offset; read the sampler as SamplerDescriptorHeap[offset / 16] (createHandleFromHeap with the sampler-heap flag, module flag 0x80000000, root flag SAMPLER_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.
  2. Runtime (follow-up): bind a mirrored sampler heap with index parity for natively translated compute, as the draw path already does for heap-indexed roots.

Test. Source-built .c67 requests (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 one dwordx8 load; the sampler's LOD clamp applies to image_sample_l. Compile refusals for the unsupported shapes. _warp skips (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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6648264542 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3076). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-27T14:20:52Z. --- ## Progress update · 1 December 2026 #3140 merged the fixed-index C++ lowering, #3540 enabled the published native runtime pair, and #3626 preserved the sampler-heap span when installing it. On the `a0e126c2` main 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. #3154 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 with `s_load_dwordx8`) at a 16-byte aligned immediate offset, then sample with `image_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"), and `sampler_index` accepts constant sampler words only ("nonconstant sampler"). On a local start-up capture (counts only, `compile_dxil` at `36d2cbeb`): 1,830 of 2,689 compute requests sample or gather, and 993 load at least one sampler from memory. On `main` this 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.** 1. Translator (this issue's first PR, target `main`): mark the sampler-heap entry SGPR; accept `s_load_dwordx4/x8` through it at a 16-byte aligned immediate offset; read the sampler as `SamplerDescriptorHeap[offset / 16]` (`createHandleFromHeap` with the sampler-heap flag, module flag `0x80000000`, root flag `SAMPLER_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. 2. Runtime (follow-up): bind a mirrored sampler heap with index parity for natively translated compute, as the draw path already does for heap-indexed roots. **Test.** Source-built `.c67` requests (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 one `dwordx8` load; the sampler's LOD clamp applies to `image_sample_l`. Compile refusals for the unsupported shapes. `_warp` skips (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 commented 2026-11-27 17:49:05 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-27T17:49:05Z.


Stage 1 (translator) is in #3140: fixed-index samplers from the directly indexed sampler heap become SamplerDescriptorHeap[index] for image_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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7224818173 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3076#issuecomment-7224818173). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-27T17:49:05Z. --- Stage 1 (translator) is in #3140: fixed-index samplers from the directly indexed sampler heap become `SamplerDescriptorHeap[index]` for `image_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 commented 2026-11-28 00:59:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-28T00:59:32Z.


Taking stage 2 (runtime sampler-heap binding for natively translated compute), on main. I will build on #3154 where the two touch translate_compute_natively and keep the change separate from #3199.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7231339017 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3076#issuecomment-7231339017). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-28T00:59:32Z. --- Taking stage 2 (runtime sampler-heap binding for natively translated compute), on `main`. I will build on #3154 where the two touch `translate_compute_natively` and keep the change separate from #3199. AI-assisted.
JB2WIN commented 2026-11-28 03:57:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-28T03:57:40Z.


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 (main 86beae95) 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 a heap_sampler binding, and none of the 2,201 refusals is sampler related. Not-Saii's 84 in #3224 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7233550061 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3076#issuecomment-7233550061). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-28T03:57:40Z. --- 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` (`main` `86beae95`) 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 a `heap_sampler` binding, and none of the 2,201 refusals is sampler related. Not-Saii's 84 in #3224 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 commented 2026-11-29 22:52:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T22:52:14Z.


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 #3524 and the comparison CLAMP_BORDER change that follows it), gather through the sampler heap is not translated becomes 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. Today compile_dxil --requests writes no manifest for a sampler-heap program at all. On main this 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_INDEXED on 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 touch dynamic_sampler or the snapshot code that #3199 edits. Test: a hardware dispatch through the stand-in with a title sampler heap, entry 67 against decoys.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7264013723 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3076#issuecomment-7264013723). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-29T22:52:14Z. --- 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 #3524 and the comparison CLAMP_BORDER change that follows it), `gather through the sampler heap is not translated` becomes 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. Today `compile_dxil --requests` writes no manifest for a sampler-heap program at all. On `main` this 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_INDEXED` on 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 touch `dynamic_sampler` or the snapshot code that #3199 edits. Test: a hardware dispatch through the stand-in with a title sampler heap, entry 67 against decoys. AI-assisted.
Sign in to join this conversation.
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#3076
No description provided.