Skip to content

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

Backlog

Description

@JB2WIN

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.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions