Skip to content

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

Done

Description

@JB2WIN

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.

Activity

  1. JB2WIN commented on Nov 27, 2026

    @JB2WIN
    ContributorAuthor

    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.

  2. JB2WIN commented on Nov 28, 2026

    @JB2WIN
    ContributorAuthor

    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.

  3. added a commit that references this issue on Nov 28, 2026
  4. JB2WIN commented on Nov 28, 2026

    @JB2WIN
    ContributorAuthor

    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.

  5. JB2WIN commented on Nov 29, 2026

    @JB2WIN
    ContributorAuthor

    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.

  6. added a commit that references this issue on Nov 29, 2026
  7. added
    priority: P0
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: P0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions