Translator: under the identity domains, constexpr samplers a lane chooses among are a switch over them

An argument buffer's texture sampled through a sampler the run picks among two or more
constexpr samplers with consecutive handles took select_heap_array's form: one sampling
through a set-0 array of the candidates' immutable samplers. The identity domains have no
set-0 array; their constexpr sampler is the set-1 sampler array's element at its pushed index
(PushField::ConstexprSampler). So every device that indexes a sampler array non-uniformly
refused the function as Unsupported{IdentityDomains} "an array of samplers", and the runtime
translates every state under the identity domains.

select_heap_array is an optimisation of the switch over the candidates. Under the identity
domains it now declines, and the switch stays: one arm per candidate, each a heap sampling
through that candidate's pushed index, a form the identity domains already lower (the
profiles without non-uniform sampler indexing took it before). identity_refusal's "an array of
samplers" arm can no longer be reached and is deleted, along with the runtime README's
known-gap line for it.

SEMANTICS_VERSION 2243 -> 2244: the output changes for these functions, from a refusal to a
module.

Test: engine_identity's
an_argument_buffer_texture_through_chosen_constexpr_samplers_is_a_switch_over_them (it was
..._is_refused_naming_it) compiles the chosen-sampler kernel under the identity domains on
every profile, passes L3 and pushes one ConstexprSampler per candidate.
This commit is contained in:
Anees Iqbal committed 2026-11-20 22:23:33 -08:00
1 parent afd9686408
commit 5cd5de678f
6 files changed
+37 -54

No files matched your search

-5
View File
@@ -2517,11 +2517,6 @@ or does not check is rebuilt from the generations' names, with young counted ful
domains, which every state is translated under: a state over a function that holds one is
`Error::Translation` of `Unsupported{IdentityDomains}`, not implemented, whose symbol names the
first form it holds. By form:
- an array of samplers (constexpr samplers a lane chooses among beside an argument buffer's
texture, on a device that indexes a sampler array by a value that may differ between
invocations): the translator test
`an_argument_buffer_textures_sample_in_a_form_not_lowered_is_refused_naming_it` asserts the
text;
- a bicubic sample at pixel coordinates ("a bicubic filter at pixel coordinates") and one of a
1D texture ("a bicubic filter of a 1D texture"): the translator test
`a_bicubic_kernel_reads_each_slots_format_treatment_from_its_pushed_field` asserts each text;
+1 -1
View File
@@ -61,7 +61,7 @@ mod tests;
/// unchanged version, and its bless records the version. Independent of the crate's version and of
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
/// history.
pub const SEMANTICS_VERSION: u32 = 2243;
pub const SEMANTICS_VERSION: u32 = 2244;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
+9 -7
View File
@@ -19,13 +19,15 @@
//! sampler, is one sampling through a set-0 array of their samplers (`ResourceKind::SamplerArray`,
//! one immutable sampler per candidate, its element `NonUniform` and at the handle's distance from
//! the first candidate's; a handle outside it reads zero), where the device indexes a sampler array
//! by a value that may differ between invocations (`shaderSampledImageArrayNonUniformIndexing`).
//! Any other sampler of several static candidates beside a heap image is a switch-at-use over
//! them, one arm per candidate, each the heap element through that candidate's heap sampler.
//! Under the identity domains a heap image has no heap sampler binding: its runtime or constexpr
//! sampler is the element of the set-1 sampler array of its use that a texture slot's sampling
//! reads there ([`IdentitySampling`]), at the index the sampler slot's pushed resource ID holds or
//! at the constexpr sampler's pushed index (`PushField::ConstexprSampler`).
//! by a value that may differ between invocations (`shaderSampledImageArrayNonUniformIndexing`),
//! outside the identity domains. Any other sampler of several static candidates beside a heap
//! image is a switch-at-use over them, one arm per candidate, each the heap element through that
//! candidate's heap sampler. Under the identity domains a heap image has no heap sampler binding:
//! its runtime or constexpr sampler is the element of the set-1 sampler array of its use that a
//! texture slot's sampling reads there ([`IdentitySampling`]), at the index the sampler slot's
//! pushed resource ID holds or at the constexpr sampler's pushed index
//! (`PushField::ConstexprSampler`), and a sampler of several constexpr candidates is the switch
//! over them.
//!
//! **Argument buffers' samplers** (the sampler half). A heap image sampled through a sampler loaded
//! from an argument buffer reads `OpSampledImage` of its heap element and of the heap sampler's
@@ -556,7 +556,9 @@ fn select_heap_switch(
/// value that may differ between invocations (`shaderSampledImageArrayNonUniformIndexing`, which
/// the heap's own image array already needs); the use is not tangled; and each candidate's
/// sampling is the same but for its sampler and the state its raw emulation follows. `None`
/// otherwise, and the switch over the candidates stays.
/// otherwise, and under the identity domains, whose constexpr sampler is the set-1 sampler array's
/// element at its pushed index (`PushField::ConstexprSampler`) and no set-0 array holds: the
/// switch over the candidates stays, each arm through its own.
fn select_heap_array(
cx: &mut SelectCx<'_>,
call: Call<'_>,
@@ -566,7 +568,10 @@ fn select_heap_array(
m: &mut Meter,
) -> Result<Option<TextureStrategy>, Error> {
use super::heap_raw::State;
if cands.len() < 2 || !cx.profile.fields().descriptors.non_uniform_sampled_image {
if cands.len() < 2
|| !cx.profile.fields().descriptors.non_uniform_sampled_image
|| crate::lower::access::identity(cx.profile)
{
return Ok(None);
}
if !cands
+4 -7
View File
@@ -2035,9 +2035,10 @@ fn identity_refusal(plan: &Plan) -> Option<String> {
// an argument buffer's texture through an argument buffer's sampler (its resource ID the
// handle, `access::handle::emit_identity_sampler`), a runtime sampler's word read from its
// resource ID, and a 2D texture slot's bicubic sample at normalized coordinates, the bound
// format's treatment read from its push field (`PushField::BicubicTexels`): no array of
// samplers, bicubic sample at pixel coordinates, bicubic sample of a 1D texture (`Routine::Line`), or
// specialization of a slot's state. A two-plane texture's sample read in place
// format's treatment read from its push field (`PushField::BicubicTexels`): no bicubic sample
// at pixel coordinates, bicubic sample of a 1D texture (`Routine::Line`), or specialization of
// a slot's state. Constexpr samplers a lane chooses among are a switch over them, never an
// array of their samplers (`sampler::select::select_heap_array`). A two-plane texture's sample read in place
// (`Routine::Quad`) never reaches here: its slot's `PushField::YCbCrInPlace` is refused first,
// as an encoder value the identity domains do not source.
use crate::lower::sampler::bicubic::routines::Routine;
@@ -2048,10 +2049,6 @@ fn identity_refusal(plan: &Plan) -> Option<String> {
|| !sampled.decls.is_empty(),
"a texture argument sampled through a sampler the identity sampling does not take",
),
(
!sampled.arrays.is_empty() || !sampled.heap_arrays.is_empty(),
"an array of samplers",
),
(sampled.bicubic_pixel, BICUBIC_PIXEL_FORM),
(
sampled.bicubic_routines.contains(&Routine::Line),
@@ -1020,14 +1020,13 @@ fn an_argument_buffer_textures_sample_takes_its_sampler_from_the_identity_arrays
}
/// Under the identity domains constexpr samplers a lane chooses among beside an argument buffer's
/// texture (`engine_handles::chosen_sampler_kernel`) are refused as `Unsupported{IdentityDomains}`,
/// not implemented, naming the array of samplers they are on a profile that indexes a sampler
/// array by a value that may differ between invocations, where the default domains compile them;
/// elsewhere they are a switch over the candidates, each arm sampling as through that sampler
/// alone, which compiles and passes L3.
/// texture (`engine_handles::chosen_sampler_kernel`) are a switch over the candidates on every
/// profile, each arm sampling as through that sampler alone at its pushed index
/// (`PushField::ConstexprSampler`, one for each candidate), never an array of their samplers: each
/// compiles and passes L3, and the default domains compile them as before.
#[test]
fn an_argument_buffer_textures_sample_in_a_form_not_lowered_is_refused_naming_it() {
use super::engine_handles::chosen_sampler_kernel;
fn an_argument_buffer_texture_through_chosen_constexpr_samplers_is_a_switch_over_them() {
use super::engine_handles::{chosen_sampler_kernel, CHOSEN_SAMPLERS};
let chosen = format!(
"target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32\"\n\
target triple = \"air64_v28-apple-macosx26.0.0\"\n\n{}",
@@ -1039,31 +1038,16 @@ target triple = \"air64_v28-apple-macosx26.0.0\"\n\n{}",
for stem in PROFILES {
let default = profile(stem, DevicePolicy::default()).unwrap_or_else(|e| panic!("{e}"));
let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{e}"));
let array = p.fields().descriptors.non_uniform_sampled_image;
let form = array.then_some("an array of samplers");
{
let what = format!("{stem}: chosen");
compile(&chosen, "chosen", &default)
.unwrap_or_else(|e| panic!("{what}: default domains: {e}"));
match (compile(&chosen, "chosen", &p), form) {
(Err(Error::Unsupported(u)), Some(form)) => {
assert_eq!(
(u.feature, u.needs),
(Feature::IdentityDomains, Needs::NotImplemented),
"{what}"
);
assert_eq!(
u.symbol.map(|f| f.to_string()).as_deref(),
Some(form),
"{what}"
);
}
(Ok(a), None) => {
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
}
(other, _) => panic!("{what}: {other:?}"),
}
}
let what = format!("{stem}: chosen");
compile(&chosen, "chosen", &default)
.unwrap_or_else(|e| panic!("{what}: default domains: {e}"));
let (a, plan, _) =
compile_kept(&chosen, "chosen", &p).unwrap_or_else(|e| panic!("{what}: {e}"));
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
let pushed = (plan.push.fields.iter())
.filter(|f| matches!(f.field, PushField::ConstexprSampler(_)))
.count();
assert_eq!(pushed, CHOSEN_SAMPLERS.len(), "{what}");
}
}