identity: constexpr samplers by a pushed index into set 1's sampler arrays

Under the identity domains a texture slot sampled through a constexpr sampler takes the sampler
from the set-1 sampler array of its use (binding 2 plain, 3 compare, 4 integer texture) at an
index the consumer pushes: PushField::ConstexprSampler(CombinedSampler), one u32. The consumer
makes the device sampler that the new public CombinedSampler::constexpr_sampler(profile)
describes, places it at an index of that array, and pushes the index. The index is a push word,
not a specialization constant: an index allocated at run time would key the driver's and the
pipeline cache's entries. Link's immutable sampler for the default domains now goes through the
same method, with the same result.

Under the identity domains every device sampler is normalized: a constexpr pixel sampler's
coordinate is scaled in the shader, as a runtime sampler's is, never handed to the device's
unnormalized sampler. A linear sample or gather through it records
PrecisionNote::PixelSamplerScaling, which is static. No address-mode-map variant applies there
(no binder picks a variant), so the sampler keeps its own modes and the slot records no
ConstexprSampled fact.

Still refused as Unsupported{IdentityDomains}: an argument buffer's sampler, arrays of samplers,
bicubic and anisotropy emulation. The refusal test now uses engine/a2_bicubic_weights.

Translation output changes only under the identity domains (Device::from_queries). Device::new
output is unchanged: golden_hashes_match_the_table passes at this tip (job m3-max-42192), with no
"changed under an unchanged key" and no "profile changed:" line.

Public surface: PushField::ConstexprSampler and CombinedSampler::constexpr_sampler are added
(api_signatures blessed); nothing is removed or changed.

SEMANTICS_VERSION 2162: identity-domain modules of constexpr-sampling kernels change.
ARTIFACT_FORMAT_VERSION 531: PushField gains a variant.

Verified:
- m3-max-42097 (msi), this change on cd5a76a757: clippy -p metal2vulkan --all-targets
  --all-features and rustdoc -D warnings green; nextest all() of metal2vulkan, 3,689 of 3,693
  passed. The four failures were development's own (the new pad_simd_shape and
  vector_word_phases fixtures had no table rows), re-blessed at 74669c0552.
- m3-max-42098 (msi): clippy --cfg m2v_gpu and --cfg m2v_cpu_icd green.
- m3-max-42192 (msi), this tip on the samplers landing on 58891b9ce5: golden_hashes_match_the_table,
  public_fixtures_engine inventory and llvm_as part 8, and air_input's engine golden printouts
  pass.
- engine_identity a_constexpr_sampler_is_the_set_1_element_its_pushed_index_names: sample_up and
  the same kernel through a linear pixel sampler link and pass L3 on every profile and on
  moltenvk-m3 without robustImageAccess2. Their push fields are the two texture IDs and
  ConstexprSampler(c) of the normalized use, with no spec constant but LocalSize, no immutable
  sampler and no ConstexprSampled fact; set 1 bindings 0, 1 and 2 are used; constexpr_sampler
  gives a normalized device sampler. PixelSamplerScaling is recorded for the pixel kernel under
  identity, and under the default domains, which hand that kernel the unnormalized sampler, it is
  not.
This commit is contained in:
Anees Iqbal committed 2026-11-17 12:46:53 -08:00
1 parent 445b720f78
commit 100b92d608
14 files changed
+245 -45

No files matched your search

+11 -6
View File
@@ -130,14 +130,17 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
(the consumer refuses a sparse texture). A texture slot sampled through a runtime sampler slot
samples set 1's element of the sampler arrays at the index of the sampler's pushed
`gpuResourceID`, joined to the texture's element by `OpSampledImage`, and reads the sampler's
word from that ID. An integer write to a storage slot without a format saturates to the channel
word from that ID. One sampled through a constexpr sampler samples the element at the index the
consumer pushes for it (`PushField::ConstexprSampler`), where the consumer places the device
sampler `CombinedSampler::constexpr_sampler` describes, normalized: the shader scales a pixel
sampler's coordinate. An integer write to a storage slot without a format saturates to the channel
widths the consumer pushes (`PushField::TextureIntegerChannels`). Every precision note is
static there: no constant or binder decides one. So far they lower a kernel that reaches memory
through its buffer slots and reads, writes, sizes or tests for nil its texture slots and its
argument buffers' textures, and samples its texture slots through its runtime sampler slots.
Any other function is refused as `Unsupported{IdentityDomains}`: one that samples through a
constexpr or an argument buffer's sampler or samples an argument buffer's texture, emulates a
sampler's anisotropy or bicubic filter, uses a texture buffer, a slot's levels or swizzle, a
argument buffers' textures, and samples its texture slots through its runtime sampler slots
and its constexpr samplers. Any other function is refused as `Unsupported{IdentityDomains}`:
one that samples through an argument buffer's sampler or an array of samplers or samples an
argument buffer's texture, emulates a sampler's anisotropy or bicubic filter, uses a texture buffer, a slot's levels or swizzle, a
two-plane, extended-range or sRGB-twin form, reads an argument buffer's texture through another
numeric type or as raw texels, or uses any other state of a texture or sampler beyond its ID.
- **The model's linear sample of planes read in place** (`YCbCrInPlacePolicy::Model`, the
@@ -4604,7 +4607,9 @@ bound.
where it is not a nearest one of one isotropic level). Measured: the device's normalized
sampler's answer within one `f32` ulp of the quotient on MoltenVK and at the quotient on
lavapipe; a linear downscale by 8 within 1/255 of Metal's on MoltenVK and 2/255 on lavapipe.
Nothing is recorded where Metal's texel or footprint follows from the coordinate itself: a
Under the identity domains it is also recorded for a linear sample and a gather through any
constexpr pixel sampler, whose device sampler the consumer makes normalized. Nothing is
recorded where Metal's texel or footprint follows from the coordinate itself: elsewhere a
constexpr pixel sampler's sample or gather of a 1D or 2D texture that is no array hands the
coordinate, moved by its offset, to the device's unnormalized sampler; a nearest sample elsewhere
hands the device its texel's centre, where the device reads exactly Metal's texel; and a nearest