A heap texture's chosen constexpr samplers are one sampler array, not a switch

A heap texture sampled through one of several constexpr samplers that a
sampler handle names at run time (a table of constexpr samplers read at a
computed index) was a switch-at-use with one arm per candidate: each arm
its own heap sampling and raw-texel emulation. On large kernels that
multiplies the sampling code by the candidate count.

Where every candidate is a constexpr sampler, their handles are
consecutive, each candidate's sampling is the same but for its sampler
and the state its raw emulation follows, the use is not tangled, and the
device indexes a sampler array non-uniformly
(shaderSampledImageArrayNonUniformIndexing, which heap textures already
need), the sampling is now one sampling through a set-0 array of the
candidates' samplers (ResourceKind::SamplerArray,
BindingSource::SamplerArray): element handle - first, NonUniform, its
immutable samplers each made as the heap sampler of that candidate alone
would be (DescriptorBinding::immutable_samplers, listed per stage in
StageInterface::sampler_arrays). A handle outside the array reads zero,
as the switch's null arm. The raw emulation reads the element's sampler
word from a constant table at the same index (heap_raw::State::Table),
through the runtime-word path. Elsewhere the switch stays.

The runtime bakes one sampler per element into the set layout, pushes
each element's own sampler where set 0 is pushed, and keys the set-0
shape on them.

Tests: the array form on every profile with the sampled heap (one
sampled image, L3), the switch kept for non-consecutive handles, each
element equal to the immutable sampler of the candidate sampled alone and
never written by the plan, and a device test (lavapipe under
m2v_cpu_icd) that each lane reads what its sampler alone reads and what
the address modes define.

Docs: API.md section 5, the sampler module doc, api_signatures,
api_surface, REFUSALS regenerated.
This commit is contained in:
Anees Iqbal committed 2026-11-12 14:55:47 -08:00
1 parent 2f4a0a3a95
commit da3cea7633
30 files changed
+1061 -46

No files matched your search

+11
View File
@@ -1243,6 +1243,17 @@ for dependency in &pipeline.dependencies {
(`DescriptorCount`), and a stage that would bind it only to test its argument samplers for a
cubic filter binds nothing, so the plan refuses a cubic sampler listed beside it
(`SamplerBicubicFilter`).
- A heap texture sampled through one of several constexpr samplers, the one a sampler handle names
at run time (a table of constexpr samplers read at a computed index), samples once through a
set-0 array of those samplers (`ResourceKind::SamplerArray`, `BindingSource::SamplerArray`),
at the element the handle names. The binding's `immutable_samplers` holds each element's sampler,
`count` of them, each made as a heap texture sampled through that sampler alone bakes it; it takes
no descriptor write, and a pushed set 0 pushes them. `StageInterface::sampler_arrays` lists each
array's constexpr samplers by its slot. The module takes this form where the candidates' handles
are consecutive, each candidate's sampling is the same but for its sampler, and the device indexes
a sampler array by a value that may differ between invocations
(`shaderSampledImageArrayNonUniformIndexing`, which heap textures already need); otherwise it
switches over the candidates, one sampling per candidate.
- Each binding's `variables` is the most variables one stage's entry point uses at it (those its
`OpEntryPoint` lists): a function that reaches a buffer through several types uses a variable of
each type at the buffer's binding. A set-0 uniform or storage buffer binding may be created as its dynamic type