Files
metal2vulkan/docs
Anees Iqbal da3cea7633 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.
2026-11-12 14:55:47 -08:00
..