From 445b720f78c16fdde448fbd1ed3b29025b327adb Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Tue, 17 Nov 2026 12:46:10 -0800 Subject: [PATCH] identity: texture slots sampled through runtime sampler slots from set 1's sampler arrays Under the identity domains a kernel samples a texture slot through a runtime sampler slot. The texture is its class's set-1 element at the index of its pushed gpuResourceID, as a read's is. The sampler is the element of a set-1 sampler array at the index of the sampler slot's pushed gpuResourceID (SlotGuestBase of the sampler slot), joined to the texture by OpSampledImage. The array is picked by the use: binding 2 for a plain sample, 3 for a depth comparison, 4 for a texture of an integer format; 4,000 SAMPLER descriptors each, PARTIALLY_BOUND | UPDATE_AFTER_BIND | UPDATE_UNUSED_WHILE_PENDING, every stage, the same set 1 for every pipeline. The sampler's word (pixel coordinates, a nearest pixel sampler) is read from the ID's high word, so no specialization constant and no SamplerReduction, SamplerCoordinates, CubicSampler or ConstantLanes fact remains; every precision note is static. An integer write to a storage slot without a format saturates to the channel widths the consumer pushes (PushField::TextureIntegerChannels, a u32), with no fact. Still refused as Unsupported{IdentityDomains}: constexpr samplers (next change: a pushed index), an argument buffer's sampler, arrays of samplers, bicubic and anisotropy emulation, a slot's minimum level. 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-42189), with no "changed under an unchanged key" and no "profile changed:" line. For the runtime's side (the planner's three facts): a. The runtime must dedupe device samplers by create info across the three arrays' uses. Exhausting maxSamplerAllocationCount (4,000 on the 2080, 3090 and UHD 630; 32,768 on lavapipe; 65,536 on the others) must be a typed refusal, with a fill-past-capacity test. b. The update-after-bind limits for 65,536 sampled images, 4,096 storage images and 12,000 samplers hold on all nine profiles (the smallest is lavapipe's 1,015,808); the floor must check them by query. c. The count of cubic sampler descriptors is asked of the replay lane; if any exist it goes back to the planner before step 5 closes. SEMANTICS_VERSION 2161: identity-domain modules of sampling kernels and integer writes change. Verified: - m3-max-42094 (msi), this change on cd5a76a757: clippy -p metal2vulkan --all-targets --all-features and rustdoc -D warnings green; nextest all() of metal2vulkan and metal2vulkan-rt, 3,719 of 3,723 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-42096 (msi): clippy --cfg m2v_gpu and --cfg m2v_cpu_icd green. - m3-max-42189 (msi), this tip 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: sample_down links and passes L3 on every profile and on moltenvk-m3 without robustImageAccess2, with set 1 bindings 0, 1 and 2 used, no spec constant but LocalSize, and no sampler fact; an integer write of (300, 70000, 5, 2^31) stores (255, 255, 5, 255) under the RGBA8Uint word and the raw lanes under word 0, on the CPU interpreter. --- .../src/lower/sampler/anisotropic.rs | 7 + crates/metal2vulkan/src/lower/sampler/emit.rs | 73 +++++- crates/metal2vulkan/src/lower/sampler/mod.rs | 74 +++++- .../metal2vulkan/src/lower/sampler/select.rs | 12 +- crates/metal2vulkan/src/lower/select.rs | 38 ++- crates/metal2vulkan/src/lower/texture/mod.rs | 6 + crates/metal2vulkan/src/lower/texture/slot.rs | 6 +- crates/metal2vulkan/src/pipeline/link.rs | 44 +++- .../metal2vulkan/src/tests/engine_identity.rs | 217 +++++++++++++++--- docs/API.md | 19 +- docs/REFUSALS.md | 4 +- docs/RESOURCE-ID.md | 21 +- scripts/refusal-surface/reach.tsv | 2 +- 13 files changed, 460 insertions(+), 63 deletions(-) diff --git a/crates/metal2vulkan/src/lower/sampler/anisotropic.rs b/crates/metal2vulkan/src/lower/sampler/anisotropic.rs index 71d9ecedd..c1a78eff1 100644 --- a/crates/metal2vulkan/src/lower/sampler/anisotropic.rs +++ b/crates/metal2vulkan/src/lower/sampler/anisotropic.rs @@ -368,6 +368,13 @@ pub(super) fn select( // anisotropy. Elsewhere it is the plain sample, with no emulation in the module: // Metal's sample wherever the word states no anisotropy, the only words a function // compiled without the slot is bound with there. + // Under the identity domains no binder chooses the variant. + if reached && crate::lower::access::identity(cx.profile) { + return Err(crate::error::Unsupported::not_implemented( + crate::error::Feature::IdentityDomains, + ) + .into()); + } if reached { let slot = super::select::sampler_slot(cx.stage, n); cx.facts diff --git a/crates/metal2vulkan/src/lower/sampler/emit.rs b/crates/metal2vulkan/src/lower/sampler/emit.rs index 89290378c..b42b3a974 100644 --- a/crates/metal2vulkan/src/lower/sampler/emit.rs +++ b/crates/metal2vulkan/src/lower/sampler/emit.rs @@ -661,6 +661,10 @@ pub(super) fn sampled_image( source: Source, ) -> BResult<(SValue, CombinedImage, Option)> { match source { + Source::Combined(key) if cx.plan.families.access.identity => { + let (si, image) = identity_sampled_image(cx, fb, key)?; + Ok((si, image, None)) + } Source::Combined(key) => { let Some(&(binding, image)) = cx.decl.families.sampler.combined.get(&key) else { return Err(cx.fail(format!("combined binding {key:?} is not declared"))); @@ -1291,13 +1295,18 @@ pub(super) fn pixel_coordinates( } /// The word of the runtime sampler `pixel` names: a slot's `SamplerState` specialization (masked by -/// the fields the function reads), or an argument buffer's sampler table entry's. +/// the fields the function reads), or under the identity domains its pushed resource ID's high +/// word, whole; or an argument buffer's sampler table entry's. pub(crate) fn sampler_word( cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, pixel: Pixel, ) -> BResult { match pixel { + Pixel::Spec(n) if cx.plan.families.access.identity => { + let id = sampler_id(cx, fb, n)?; + fb.composite_extract(id, &[1]) + } Pixel::Spec(n) => match cx.decl.families.sampler.words.get(&n).copied() { Some(w) => Ok(w), None => Err(cx.fail(format!("sampler slot {n} has no state word"))), @@ -1307,6 +1316,61 @@ pub(crate) fn sampler_word( } } +/// Under the identity domains, runtime sampler slot `n`'s resource ID (`uvec2`, the index in the +/// low word and the word in the high one), from its push field. +fn sampler_id(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, n: u32) -> BResult { + let slot = super::select::sampler_slot(cx.plan.stage, n); + cx.push_field(fb, crate::pipeline::sym::PushField::SlotGuestBase(slot)) +} + +/// Under the identity domains, the sampled image of combined binding `key` +/// ([`super::IdentitySampling`]): the texture slot's element of its class's set-1 array and the +/// sampler slot's element of the set-1 sampler array of the use, each at the index its pushed +/// resource ID holds, uniform over the call, joined by `OpSampledImage`. +fn identity_sampled_image( + cx: &mut EmitCx<'_>, + fb: &mut FunctionBuilder<'_>, + key: super::BindingKey, +) -> BResult<(SValue, CombinedImage)> { + let Some(i) = cx.plan.families.sampler.identity.get(&key).copied() else { + return Err(cx.fail(format!("combined binding {key:?} has no identity sampling"))); + }; + let crate::pipeline::sym::SamplerRef::Slot(n) = key.sampler else { + return Err(cx.fail("an identity sampling of a constexpr sampler")); + }; + let slot = cx + .plan + .families + .texture + .slots + .get(&key.texture) + .map(|s| s.slot); + let images = cx.decl.families.texture.heap.get(&i.class).copied(); + let samplers = cx.decl.families.sampler.identity.get(&i.use_).copied(); + let (Some(slot), Some(images), Some(samplers)) = (slot, images, samplers) else { + return Err(cx.fail(format!("combined binding {key:?} is not declared"))); + }; + let id = cx.push_field(fb, crate::pipeline::sym::PushField::SlotGuestBase(slot))?; + let element = fb.composite_extract(id, &[0])?; + let base = fb.module().global_value(images)?; + let p = fb.access_chain(base, &[element])?; + let img = fb.load(p, MemAccess::default())?; + let id = sampler_id(cx, fb, n)?; + let element = fb.composite_extract(id, &[0])?; + let base = fb.module().global_value(samplers)?; + let p = fb.access_chain(base, &[element])?; + let sampler = fb.load(p, MemAccess::default())?; + let si = fb.sampled_image(img, sampler)?; + Ok(( + si, + CombinedImage { + plane: super::plane_of(i.image.dim), + arrayed: i.image.arrayed, + texel: i.image.texel, + }, + )) +} + /// Field `field` of the sampler table entry an argument buffer's sampler handle `handle` names: the /// handle is the entry's index, the null entry's 0 for a missed or null id. fn heap_sampler_field( @@ -1399,6 +1463,13 @@ pub(super) fn centre( let Pixel::Spec(n) = s.pixel else { return Err(cx.fail("a specialized texel centre without a runtime sampler slot")); }; + // Under the identity domains the slot's word says whether it is a nearest pixel + // sampler, as an argument buffer's sampler's does. + if cx.plan.families.access.identity { + let mask = SamplerWord::nearest_pixel(image.texel != TexelClass::Float); + let word = sampler_word(cx, fb, s.pixel)?; + return Ok(Centre::TexelWhere(word_states(fb, word, mask)?)); + } match cx.decl.families.sampler.nearest.get(&n).copied() { Some(c) => Centre::TexelWhere(c), None => return Err(cx.fail(format!("sampler slot {n} has no nearest constant"))), diff --git a/crates/metal2vulkan/src/lower/sampler/mod.rs b/crates/metal2vulkan/src/lower/sampler/mod.rs index d36dee09d..4bad7c906 100644 --- a/crates/metal2vulkan/src/lower/sampler/mod.rs +++ b/crates/metal2vulkan/src/lower/sampler/mod.rs @@ -1264,6 +1264,25 @@ pub struct SamplerPlan { /// The sampling routines the samples call, each shape once (`routine::note`): the census counts /// each one's words once. pub routines: Vec, + /// Under the identity domains, each combined binding's image and sampler, set by [`finish`] + /// in place of its declaration ([`IdentitySampling`]). + pub identity: BTreeMap, +} + +/// Under the identity domains, a texture slot sampled through a runtime sampler slot: the slot's +/// texture is the element of its class's set-1 array at the index its resource ID holds, as a +/// read's is (`texture::identity_class`), and the sampler the element of the set-1 sampler array +/// of its use at the index the sampler's resource ID holds (`docs/RESOURCE-ID.md`), each taken +/// from its slot's push field: the use is plain, compare or integer, by the instruction and the +/// texture's numeric type. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct IdentitySampling { + /// The texture's image, sampled. + pub image: ImageDecl, + /// The set-1 class of [`IdentitySampling::image`]. + pub class: crate::pipeline::sym::ImageHandleClass, + /// The sampler array's use. + pub use_: SamplerUse, } /// The image facts emission reads for a combined binding. @@ -1325,6 +1344,8 @@ pub struct Declared { pub bicubic_line: Option, /// The in-place two-plane YCbCr linear samples' routines, when the module has one. pub linear_quad: Option, + /// Under the identity domains, the set-1 sampler array of each use ([`IdentitySampling`]). + pub identity: BTreeMap, } /// Complete the sampler family's plan: declare each combined binding (its image from the @@ -1335,6 +1356,7 @@ pub struct Declared { pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> { let mut counts = DescriptorCounts::default(); let mut decls = BTreeMap::new(); + let mut identity = BTreeMap::new(); for key in &cx.families.sampler.combined { let s = cx .families @@ -1377,6 +1399,22 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> { rows: false, parts: None, }; + if crate::lower::access::identity(cx.profile) { + let refused = || Unsupported::not_implemented(Feature::IdentityDomains); + if !matches!(key.sampler, SamplerRef::Slot(_)) || key.unnormalized { + return Err(refused().into()); + } + let class = crate::lower::texture::identity_class(&image).ok_or_else(refused)?; + identity.insert( + *key, + IdentitySampling { + image, + class, + use_: SamplerUse::new(key.compare, texel != TexelClass::Float), + }, + ); + continue; + } let symbol = ResourceSlot { stage: cx.stage, kind: ResourceKind::CombinedTextureSampler(sampler), @@ -1502,7 +1540,15 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> { .ok_or_else(|| invariant("a bicubic sample of an unplanned texture slot"))?; cx.facts.insert(RuntimeFact::BicubicTexels { slot: s.slot }); } + // Under the identity domains a runtime sampler slot's resource ID is pushed, and the shader + // reads the sampler's word from it (`emit::sampler_word`): the consumer makes the device's + // sampler of the descriptor, its reduction included. for r in cx.families.sampler.slots.values() { + if crate::lower::access::identity(cx.profile) { + cx.push + .insert(crate::pipeline::sym::PushField::SlotGuestBase(r.slot)); + continue; + } cx.facts .insert(RuntimeFact::SamplerReduction { slot: r.slot }); if r.coordinates { @@ -1511,6 +1557,7 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> { } } cx.families.sampler.decls = decls; + cx.families.sampler.identity = identity; cx.families.sampler.separate = separate; cx.families.sampler.heap_decls = heap_decls; cx.families.sampler.heap_sampler_decls = heap_sampler_decls; @@ -1704,9 +1751,32 @@ pub fn declare( }; d.heap_arrays.insert(*key, g); } + // Under the identity domains one set-1 sampler array per use, and a slot's word is its pushed + // resource ID's (`emit::sampler_word`). + for use_ in plan.families.sampler.identity.values().map(|i| i.use_) { + if d.identity.contains_key(&use_) { + continue; + } + let sampler = mb.ty(SType::Sampler)?; + let array = mb.ty(SType::RuntimeArray { + elem: sampler, + stride: None, + })?; + let g = mb.resource( + ResourceSlot { + stage: plan.stage, + kind: ResourceKind::Heap(HandleClass::sampler(use_)), + index: 0, + }, + StorageClass::UniformConstant, + array, + )?; + d.identity.insert(use_, g); + } + let identity = plan.families.access.identity; for (n, r) in &plan.families.sampler.slots { let fields = r.fields(); - if fields != 0 { + if fields != 0 && !identity { let u = mb.ty(SType::Int { width: 32, signed: false, @@ -1734,7 +1804,7 @@ pub fn declare( let c = mb.spec(SpecKey::SamplerAnisotropy(r.slot), u, ConstBits(0))?; d.degrees.insert(*n, mb.const_value(c)?); } - if r.nearest { + if r.nearest && !identity { let b = mb.ty(SType::Bool)?; let c = mb.spec(SpecKey::NearestPixelSampler(r.slot), b, ConstBits(0))?; d.nearest.insert(*n, mb.const_value(c)?); diff --git a/crates/metal2vulkan/src/lower/sampler/select.rs b/crates/metal2vulkan/src/lower/sampler/select.rs index ea95c998f..cbc86cdef 100644 --- a/crates/metal2vulkan/src/lower/sampler/select.rs +++ b/crates/metal2vulkan/src/lower/sampler/select.rs @@ -2451,8 +2451,13 @@ fn select_one( // texture's image holds Metal's unmapped value and its tile map answers exactly the texels // Metal counts. let texel_op = !matches!(op, SampleOp::Lod { .. } | SampleOp::QueryLevel { .. }); + // Under the identity domains no texture is sparse (the consumer refuses a sparse texture), and + // the view's own components read the lanes its format lacks. + let identity = crate::lower::access::identity(cx.profile); let unmapped = match image { - ImageRef::Slot(index) if sparse_images && texel_op && !fetches && !shape.depth => { + ImageRef::Slot(index) + if sparse_images && !identity && texel_op && !fetches && !shape.depth => + { let named_texels = matches!(op, SampleOp::PixelFetch { .. }); if let Some(s) = cx.families.texture.slots.get_mut(&index) { s.constant_lanes = true; @@ -3010,6 +3015,11 @@ fn cubic_slot( cx: &mut SelectCx<'_>, n: u32, ) -> Result, Error> { + // Under the identity domains no binder chooses a variant: the consumer makes no device sampler + // of a cubic descriptor (`docs/RESOURCE-ID.md`). + if crate::lower::access::identity(cx.profile) { + return Ok(None); + } let slot = sampler_slot(cx.stage, n); cx.facts .insert(crate::pipeline::facts::RuntimeFact::CubicSampler { slot }); diff --git a/crates/metal2vulkan/src/lower/select.rs b/crates/metal2vulkan/src/lower/select.rs index 19aa6ea49..3a9beb183 100644 --- a/crates/metal2vulkan/src/lower/select.rs +++ b/crates/metal2vulkan/src/lower/select.rs @@ -1911,8 +1911,8 @@ fn identity_unsourced(f: &RuntimeFact) -> bool { } /// Under the identity domains, the plans lowered so far: a kernel that reaches memory only -/// through its buffer slots' device addresses and its textures' resource IDs, with no -/// descriptor, no sampler, and no state of a bound texture but its resource ID's +/// through its buffer slots' device addresses and its textures' and runtime samplers' resource +/// IDs, with no descriptor and no state of a bound texture or sampler but its resource ID's /// (`SlotPlan::identity_lowered`, [`identity_unsourced`]). Its fields past the push window are a /// parameter block, whose address the window holds. fn identity_admits(plan: &Plan) -> Result<(), Error> { @@ -1920,7 +1920,9 @@ fn identity_admits(plan: &Plan) -> Result<(), Error> { (PushField::ArgumentTableAddress, loc) => matches!(loc, PushLoc::Push { .. }), (field, _) => matches!( field, - PushField::SlotGuestBase(_) | PushField::DispatchRegion + PushField::SlotGuestBase(_) + | PushField::DispatchRegion + | PushField::TextureIntegerChannels(_) ), }); let addressed = plan @@ -1954,19 +1956,28 @@ fn identity_admits(plan: &Plan) -> Result<(), Error> { && t.heap_raw.is_empty() && !t.heap_half && t.slots.values().all(|s| s.identity_lowered()); - // No sampler use: a read's decode through Metal's own texture unit (`metal_sampler`) is only - // a requirement. + // Samples only of a texture slot through a runtime sampler slot (`sampler::IdentitySampling`), + // every one's word read from the sampler's resource ID: no constexpr sampler, argument + // buffer's sampler, bicubic filter or specialization of a slot's state. let sampled = &plan.families.sampler; - let unsampled = *sampled - == sampler::SamplerPlan { - metal_sampler: sampled.metal_sampler, - ..Default::default() - }; + let sampling = sampled + .combined + .iter() + .all(|k| sampled.identity.contains_key(k)) + && sampled.decls.is_empty() + && sampled.heap.is_empty() + && sampled.heap_samplers.is_empty() + && sampled.arrays.is_empty() + && sampled.heap_arrays.is_empty() + && sampled.bicubic.is_empty() + && sampled.bicubic_routines.is_empty() + && !sampled.cubic_reach + && sampled.slots.values().all(|r| !r.min_level && !r.emulated); if plan.stage == Stage::Kernel && fields && addressed && textures - && unsampled + && sampling && !plan.facts.iter().any(identity_unsourced) && plan.descriptors == DescriptorCounts::default() { @@ -2070,7 +2081,12 @@ pub(crate) fn any_of(tests: impl IntoIterator) -> Vec Option { + // Under the identity domains no constant or binder decides a note: each is static. + if families.access.identity { + return None; + } let key = match t.on { NoteOn::Unmeasured(index) => { let s = families.texture.slots.get(&index)?; diff --git a/crates/metal2vulkan/src/lower/texture/mod.rs b/crates/metal2vulkan/src/lower/texture/mod.rs index 832ff0a5f..0438afed5 100644 --- a/crates/metal2vulkan/src/lower/texture/mod.rs +++ b/crates/metal2vulkan/src/lower/texture/mod.rs @@ -1260,6 +1260,12 @@ pub fn declare( } d.images.insert(*index, (g, decl.declare(mb)?)); } + // And each sampled slot's class (`sampler::IdentitySampling`), which no read declares. + for i in plan.families.sampler.identity.values() { + if let std::collections::btree_map::Entry::Vacant(e) = d.heap.entry(i.class) { + e.insert(heap_array(mb, plan.stage, i.class, i.image)?); + } + } } let slots = (plan.families.texture.slots.iter()).filter(|_| !plan.families.access.identity); for (index, s) in slots { diff --git a/crates/metal2vulkan/src/lower/texture/slot.rs b/crates/metal2vulkan/src/lower/texture/slot.rs index 97fc97ad9..e82e75962 100644 --- a/crates/metal2vulkan/src/lower/texture/slot.rs +++ b/crates/metal2vulkan/src/lower/texture/slot.rs @@ -1280,8 +1280,12 @@ fn declare_slot( if !crate::lower::access::identity(cx.profile) { facts.push(RuntimeFact::StorageTextureFormat { slot: s.slot }); } + // Under the identity domains the push word is the contract: the consumer writes the bound + // texture's channel widths there, as for any slot's push field. if s.uses.int_channels { - facts.push(RuntimeFact::StorageTextureIntegerChannels { slot: s.slot }); + if !crate::lower::access::identity(cx.profile) { + facts.push(RuntimeFact::StorageTextureIntegerChannels { slot: s.slot }); + } push.push(PushField::TextureIntegerChannels(s.slot)); } storage_format(cx, s, texel)? diff --git a/crates/metal2vulkan/src/pipeline/link.rs b/crates/metal2vulkan/src/pipeline/link.rs index c976690e0..8bf7c1531 100644 --- a/crates/metal2vulkan/src/pipeline/link.rs +++ b/crates/metal2vulkan/src/pipeline/link.rs @@ -1249,21 +1249,48 @@ const IDENTITY_SAMPLED_IMAGES: u32 = 65_536; /// storage-capable texture. const IDENTITY_STORAGE_IMAGES: u32 = 4_096; +/// Each sampler array of the identity domains' set 1: bindings 2, 3 and 4, one element per index a +/// sampler's resource ID may hold (`docs/RESOURCE-ID.md`). +const IDENTITY_SAMPLERS: u32 = 4_000; + /// Set 1 under the identity domains: the same layout for every pipeline, so the consumer binds one /// set for every command. Binding 0 is the sampled-image array and binding 1 the storage-image /// array, each element the texture whose resource ID holds its index; every heap class the /// pipeline's stages declare is a variable of its descriptor type's binding, as the variables of -/// one set and binding may be (Vulkan's "DescriptorSet and Binding Assignment"). Every stage sees -/// both arrays, partially bound, updated after binding and while unused elements are pending: the -/// floor's features. +/// one set and binding may be (Vulkan's "DescriptorSet and Binding Assignment"). Bindings 2, 3 and +/// 4 are the sampler arrays of the three uses, each element the device's sampler of that use made +/// of the sampler whose resource ID holds its index: plain (2), with depth comparison (3), and for +/// an integer texture (4), every filter nearest. Every stage sees every array, partially bound, +/// updated after binding and while unused elements are pending: the floor's features. fn identity_set( heap: &BTreeMap, table: &mut LinkTable, ) -> Result { - for h in heap.values() { - let binding = match h.ty { - vk::DescriptorType::SAMPLED_IMAGE => 0, - vk::DescriptorType::STORAGE_IMAGE => 1, + for (class, h) in heap { + let binding = match (h.ty, class) { + (vk::DescriptorType::SAMPLED_IMAGE, _) => 0, + (vk::DescriptorType::STORAGE_IMAGE, _) => 1, + ( + vk::DescriptorType::SAMPLER, + HandleClass::Sampler { + compare: false, + integer: false, + }, + ) => 2, + ( + vk::DescriptorType::SAMPLER, + HandleClass::Sampler { + compare: true, + integer: false, + }, + ) => 3, + ( + vk::DescriptorType::SAMPLER, + HandleClass::Sampler { + compare: false, + integer: true, + }, + ) => 4, _ => return Err(Unsupported::not_implemented(Feature::IdentityDomains).into()), }; for slot in &h.slots { @@ -1297,6 +1324,9 @@ fn identity_set( vk::DescriptorType::STORAGE_IMAGE, IDENTITY_STORAGE_IMAGES, ), + array(2, vk::DescriptorType::SAMPLER, IDENTITY_SAMPLERS), + array(3, vk::DescriptorType::SAMPLER, IDENTITY_SAMPLERS), + array(4, vk::DescriptorType::SAMPLER, IDENTITY_SAMPLERS), ], flags: vk::DescriptorSetLayoutCreateFlags::UPDATE_AFTER_BIND_POOL, }) diff --git a/crates/metal2vulkan/src/tests/engine_identity.rs b/crates/metal2vulkan/src/tests/engine_identity.rs index f19d0b71a..8fec37252 100644 --- a/crates/metal2vulkan/src/tests/engine_identity.rs +++ b/crates/metal2vulkan/src/tests/engine_identity.rs @@ -30,7 +30,15 @@ //! only reads and a `constant` one) are loaded through `NonWritable` device-address places; a //! written slot, and a `device` slot the AIR does not declare unaliased, are not. It passes L3 //! and computes its answer on the CPU interpreter. -//! - A kernel that samples a texture (`engine/a2_dynamic_texel_offset`) is still refused as +//! - A kernel sampling a texture slot through a runtime sampler slot (the harness's +//! `sample_down`) takes the texture and the sampler from set 1's arrays at the indices their +//! pushed resource IDs hold, the sampler from the plain array, with no descriptor, no +//! specialization constant and no fact of the bound sampler; it passes L3. +//! - A kernel writing integer texels to a storage slot without a format (`ic`, generated) +//! saturates each lane to the channel widths the consumer pushes +//! (`PushField::TextureIntegerChannels`), with no fact, on the CPU interpreter. +//! - A kernel that samples through a constexpr sampler (`engine/a2_dynamic_texel_offset`) is still +//! refused as //! `Unsupported{IdentityDomains}`, not implemented, where the default domains compile it. //! - A kernel's emulated-simdgroup variant (`engine/gsm2_simd_products`'s `simd_float_products`) //! opens every barrier of its exchanges under a branch on `1 < N`, which the default domains do @@ -248,7 +256,184 @@ fn a_buffer_kernel_reads_each_slot_at_its_pushed_device_address() { } } -/// A kernel that samples a texture is not lowered under the identity domains yet. +/// The harness's sampling kernels (`fixtures/public/harness/workloads.ll`, our own), assembled. +fn workloads() -> Option> { + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../metal2vulkan-validation/fixtures/public/harness/workloads.ll"); + assembled("workloads", llvm_assemble(&path)) +} + +/// A kernel sampling a texture slot through a runtime sampler slot (`sample_down`: a 2D `float` +/// sample, a size query and a write) takes the sampled texture from set 1's sampled-image array +/// and the sampler from its plain sampler array, each at the index its pushed resource ID holds, +/// with no descriptor, no specialization constant and no fact of the bound sampler: the word the +/// sample reads is the resource ID's. It passes L3 on each profile. +#[test] +fn a_runtime_sampler_is_the_set_1_element_its_resource_id_names() { + let Some(bc) = workloads() else { + return; + }; + let mut profiles: Vec<(String, DeviceProfile)> = PROFILES + .iter() + .map(|stem| { + let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{e}")); + (stem.to_string(), p) + }) + .collect(); + profiles.push(( + "moltenvk-m3 without robustImageAccess2".to_string(), + identity_without("moltenvk-m3", &[VkFeature::RobustImageAccess2]), + )); + for (stem, p) in &profiles { + let (a, plan, _) = + compile_kept(&bc, "sample_down", p).unwrap_or_else(|e| panic!("{stem}: {e}")); + link_and_validate(&a, p).unwrap_or_else(|e| panic!("{stem}: L3: {e}")); + assert!( + (a.interface.spec.iter()).all(|c| matches!(c.key, SpecKey::LocalSize(_))), + "{stem}: {:?}", + a.interface.spec + ); + assert!( + !plan.facts.iter().any(|f| matches!( + f, + RuntimeFact::SamplerCoordinates { .. } + | RuntimeFact::SamplerReduction { .. } + | RuntimeFact::CubicSampler { .. } + )), + "{stem}: {:?}", + plan.facts + ); + let mut slots: Vec<_> = (plan.push.fields.iter()) + .filter_map(|f| match f.field { + PushField::SlotGuestBase(s) => Some((s.class, s.index)), + _ => None, + }) + .collect(); + slots.sort(); + assert_eq!( + slots, + [ + (SlotClass::Texture, 0), + (SlotClass::Texture, 1), + (SlotClass::Sampler, 0) + ], + "{stem}" + ); + let linked = link(&[&a], &LinkInputs::standalone(), p).unwrap_or_else(|e| panic!("{e}")); + let sets: Vec<_> = (linked.layout.sets.iter()) + .map(|s| { + let b: Vec<_> = (s.bindings.iter()) + .map(|b| (b.binding, b.ty, b.count)) + .collect(); + (s.set, b) + }) + .collect(); + assert_eq!(sets, [(0, vec![]), (1, identity_arrays())], "{stem}"); + let mut used: Vec = (linked.table.bindings.values()) + .filter(|(set, _)| *set == 1) + .map(|(_, binding)| *binding) + .collect(); + used.sort(); + // The sampled source, the written destination, and the plain sampler. + assert_eq!(used, [0, 1, 2], "{stem}"); + } +} + +/// A kernel writing `uint4(300, 70000, 5, 2^31)` to its `texture2d` slot 0 at its +/// position, over a `2 × 1` grid. +fn channels_kernel() -> String { + "define void @ic(ptr addrspace(1) %t, <2 x i32> noundef %tid) {\n\ +entry:\n\ + tail call void @air.write_texture_2d.u.v4i32(ptr addrspace(1) %t, <2 x i32> %tid, <4 x i32> , i32 0, i32 2)\n\ + ret void\n\ +}\n\n\ +declare void @air.write_texture_2d.u.v4i32(ptr addrspace(1), <2 x i32>, <4 x i32>, i32, i32)\n\n\ +!air.kernel = !{!0}\n!air.version = !{!4}\n!air.language_version = !{!5}\n\ +!0 = !{ptr @ic, !1, !2}\n!1 = !{}\n!2 = !{!6, !3}\n\ +!6 = !{i32 0, !\"air.texture\", !\"air.location_index\", i32 0, i32 1, !\"air.write\", !\"air.arg_type_name\", !\"texture2d\", !\"air.arg_name\", !\"t\"}\n\ +!3 = !{i32 1, !\"air.thread_position_in_grid\", !\"air.arg_type_name\", !\"uint2\", !\"air.arg_name\", !\"tid\"}\n\ +!4 = !{i32 2, i32 8, i32 0}\n!5 = !{!\"Metal\", i32 4, i32 0, i32 0}\n" + .to_string() +} + +/// An integer write to a storage slot without a format saturates each lane to the bound format's +/// channel width, which the consumer pushes (`PushField::TextureIntegerChannels`, the push word +/// of the contract, with no fact): into `RGBA8Uint` the kernel's 300, 70000 and 2^31 store 255 +/// and its 5 stays, and a word of 0 (32-bit channels) stores every lane as written. +#[test] +fn an_integer_write_saturates_to_the_pushed_channel_widths() { + let Some(bc) = assemble_text("ic", &channels_kernel()) else { + return; + }; + const L: [u32; 3] = [2, 1, 1]; + for stem in PROFILES { + let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{e}")); + let (a, plan, module) = + compile_kept(&bc, "ic", &p).unwrap_or_else(|e| panic!("{stem}: {e}")); + link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{stem}: L3: {e}")); + assert!( + !(plan.facts.iter()) + .any(|f| matches!(f, RuntimeFact::StorageTextureIntegerChannels { .. })), + "{stem}" + ); + let linked = link(&[&a], &LinkInputs::standalone(), &p).unwrap_or_else(|e| panic!("{e}")); + let (storage, _) = (linked.table.bindings.iter()) + .find(|(_, b)| **b == (1, 1)) + .unwrap_or_else(|| panic!("{stem}: no storage class")); + let rgba8 = crate::metal::format::integer_channels_word(PixelFormat::RGBA8Uint); + for (word, want) in [ + (rgba8, [255, 255, 5, 255]), + (0, [300, 70_000, 5, 0x8000_0000]), + ] { + let mut push = vec![0u8; plan.push.push_range.map_or(0, |(_, end)| end as usize)]; + for field in &plan.push.fields { + let PushLoc::Push { offset } = field.loc else { + panic!("{stem}: {field:?} spilled"); + }; + let o = offset as usize; + match field.field { + PushField::SlotGuestBase(_) => { + push[o..o + 8].copy_from_slice(&resource_id(2, 0).to_le_bytes()) + } + PushField::TextureIntegerChannels(_) => { + push[o..o + 4].copy_from_slice(&word.to_le_bytes()) + } + PushField::DispatchRegion => { + let region = region_bytes([0; 3], L, L).expect("packs"); + push[o..o + 32].copy_from_slice(®ion); + } + other => panic!("{stem}: unexpected push field {other:?}"), + } + } + let mut images: Vec = (0..2) + .map(|e| texture(*storage, e, [1, 1], |_, _| [0; 4], None)) + .collect(); + images.push(texture(*storage, 2, [2, 1], |_, _| [0; 4], None)); + let res = Resources { + buffers: Vec::new(), + push, + spec: local_size3(L), + }; + let (_, images) = run_with_images(&module, &Config::default(), res, images) + .unwrap_or_else(|e| panic!("{stem}: {e}")); + assert_eq!(images[2].texels, [want, want], "{stem}: word {word:#x}"); + } + } +} + +/// Set 1's fixed arrays under the identity domains: binding, descriptor type and count. +fn identity_arrays() -> Vec<(u32, vk::DescriptorType, u32)> { + vec![ + (0, vk::DescriptorType::SAMPLED_IMAGE, 65_536), + (1, vk::DescriptorType::STORAGE_IMAGE, 4_096), + (2, vk::DescriptorType::SAMPLER, 4_000), + (3, vk::DescriptorType::SAMPLER, 4_000), + (4, vk::DescriptorType::SAMPLER, 4_000), + ] +} + +/// A kernel that samples a texture through a constexpr sampler is not lowered under the identity +/// domains yet. #[test] fn a_sampling_kernel_is_refused_under_the_identity_domains() { let Some(bc) = assemble("a2_dynamic_texel_offset") else { @@ -544,30 +729,10 @@ fn textures_at_their_resource_ids(ab: bool) { (s.set, b) }) .collect(); - assert_eq!( - sets, - [ - (0, vec![]), - ( - 1, - vec![ - ( - 0, - vk::DescriptorType::SAMPLED_IMAGE, - 65_536, - BindingSource::IdentityArray - ), - ( - 1, - vk::DescriptorType::STORAGE_IMAGE, - 4_096, - BindingSource::IdentityArray - ), - ] - ) - ], - "{stem}" - ); + let arrays: Vec<_> = (identity_arrays().into_iter()) + .map(|(binding, ty, count)| (binding, ty, count, BindingSource::IdentityArray)) + .collect(); + assert_eq!(sets, [(0, vec![]), (1, arrays)], "{stem}"); let class = |binding: u32| { let mut s = (linked.table.bindings.iter()).filter(|(_, b)| **b == (1, binding)); let (slot, _) = s diff --git a/docs/API.md b/docs/API.md index 1b6b46a6b..9bcb6a291 100644 --- a/docs/API.md +++ b/docs/API.md @@ -127,12 +127,19 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`: slot and a member of one class index one array. No binder chooses a variant there: a texture reads through the plain form whatever texture its ID names, its `float` or `half` reads take the device's sRGB decode with `PrecisionNote::SrgbTexelDecode`, and no texture is sparse - (the consumer refuses a sparse texture). 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. Any other function is refused as `Unsupported{IdentityDomains}`: one that - samples, 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 beyond its ID. + (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 + 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 + 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 default; changes emitted code). On an integrated GPU or a CPU device a function that only samples, gathers or sizes a `YCBCR8_420_2P` or `YCBCR10_420_2P` texture reads its planes' codes diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 2c9c043a3..1f48504ad 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -143,7 +143,7 @@ Columns: | `RasterizationRateMap` | | devices without VkFeature::MultiViewport; devices without VkFeature::ShaderDrawParameters; devices without VkFeature::ShaderOutputViewportIndex; devices without VkLimit::MaxGeometryTotalOutputComponents; devices without a capability the site computes; devices without a capability the site computes (`vec![Capability::Feature(lacks)]`); every device (not implemented) | `ours` | 10: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_copy, 3 sites)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)` (+3) | `rare`: rasterization rate maps | | `GpuEncodedIndirectCommands` | | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 20: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`, `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)` (+13) | `rare`: indirect command buffers encoded by a kernel | | `VulkanVersion` | The device's Vulkan version is below the 1.2 floor | devices without ApiVersion::V1_2 | `device` | 2: `crates/metal2vulkan/src/ash_interop/query.rs (query)`, `crates/metal2vulkan/src/device/derive.rs (derived)` | `none`: a device below Vulkan 1.2 | -| `IdentityDomains` | The identity pointer and handle domains (`PointerDomain::Identity`, `HandleDomain::Identity`) | devices without a capability the site computes (`all`); every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`, `crates/metal2vulkan/src/lower/select.rs (identity_admits)` (+2) | `none`: the identity domains, which the new runtime alone takes and which lower only kernels over buffer slots and unsampled textures, in slots or argument buffers, so far | +| `IdentityDomains` | The identity pointer and handle domains (`PointerDomain::Identity`, `HandleDomain::Identity`) | devices without a capability the site computes (`all`); every device (not implemented) | `ours` | 6: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`, `crates/metal2vulkan/src/lower/sampler/anisotropic.rs (select)` (+4) | `none`: the identity domains, which the new runtime alone takes and which lower only kernels over buffer slots, textures in slots or argument buffers, and runtime samplers, so far | | `Constant` | A constants-block record LLVM defines that the typed model has no form for (a block address, a `select` and the other constant expressions of... | - | `-` | via a helper: 3: `crates/metal2vulkan-air/src/bitcode/constants.rs (record, 2 sites)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM constant forms AIR does not emit | | `Attribute` | An LLVM attribute kind that changes the calling ABI and that AIR does not use (`inalloca`, `preallocated`, `byref`, `nest`, the `swift*` kinds) | - | `-` | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/attrs.rs (known)`, `crates/metal2vulkan/src/error/mod.rs (from)` | `none`: LLVM ABI attributes AIR does not use | | `BitcodeRecord` | A bitcode record LLVM defines in `block` that the typed model does not cover and that has no more specific variant (legacy spellings predating... | - | `-` | via a helper: 8: `crates/metal2vulkan-air/src/bitcode/attrs.rs (decode_lists)`, `crates/metal2vulkan-air/src/bitcode/function.rs (symtab)` (+5) | `none`: bitcode records AIR does not emit | @@ -727,7 +727,7 @@ Each refusal's sites, with the function that builds it. - `feature::RasterizationRateMap`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_copy, 3 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (region_viewport, 2 sites)`; `crates/metal2vulkan/src/pipeline/link.rs (region_box)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (check_limits)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs (fan_plan, 3 sites)` - `feature::GpuEncodedIndirectCommands`: `crates/metal2vulkan/src/bind/replay.rs (preprocess)`; `crates/metal2vulkan/src/bind/replay.rs (replay_preprocess_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_module)`; `crates/metal2vulkan/src/bind/replay/draws.rs (draw_replay_preprocess)`; `crates/metal2vulkan/src/bind/replay/flat.rs (flat_dispatch_module)`; `crates/metal2vulkan/src/bind/replay/merged.rs (draw_merge_module)`; `crates/metal2vulkan/src/lower/access/encode.rs (needs, 2 sites)`; `crates/metal2vulkan/src/lower/access/encode.rs (select_command)`; `crates/metal2vulkan/src/lower/access/mod.rs (plan_replay, 3 sites)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_partial_groups)`; `crates/metal2vulkan/src/lower/select.rs (finish, 2 sites)`; `crates/metal2vulkan/src/lower/simd/divergent.rs (barriers)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (merged)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`; `crates/metal2vulkan/src/pipeline/compile.rs (analyze_one, 2 sites)` - `feature::VulkanVersion`: `crates/metal2vulkan/src/ash_interop/query.rs (query)`; `crates/metal2vulkan/src/device/derive.rs (derived)` -- `feature::IdentityDomains`: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`; `crates/metal2vulkan/src/lower/select.rs (identity_admits)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format)`; `crates/metal2vulkan/src/pipeline/link.rs (identity_set)` +- `feature::IdentityDomains`: `crates/metal2vulkan/src/device/derive.rs (identity_domains)`; `crates/metal2vulkan/src/lower/sampler/anisotropic.rs (select)`; `crates/metal2vulkan/src/lower/sampler/mod.rs (finish)`; `crates/metal2vulkan/src/lower/select.rs (identity_admits)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format)`; `crates/metal2vulkan/src/pipeline/link.rs (identity_set)` - `feature::Constant`: `crates/metal2vulkan-air/src/bitcode/constants.rs (record, 2 sites)`; `crates/metal2vulkan/src/error/mod.rs (from)` - `feature::Attribute`: `crates/metal2vulkan-air/src/bitcode/attrs.rs (known)`; `crates/metal2vulkan/src/error/mod.rs (from)` - `feature::BitcodeRecord`: `crates/metal2vulkan-air/src/bitcode/attrs.rs (decode_lists)`; `crates/metal2vulkan-air/src/bitcode/function.rs (symtab)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs (decode, 2 sites)`; `crates/metal2vulkan-air/src/bitcode/module.rs (check_bodies)`; `crates/metal2vulkan-air/src/bitcode/module.rs (read)`; `crates/metal2vulkan-air/src/bitcode/module.rs (symtab)`; `crates/metal2vulkan/src/error/mod.rs (from)` diff --git a/docs/RESOURCE-ID.md b/docs/RESOURCE-ID.md index 63eb1a672..0365d42a6 100644 --- a/docs/RESOURCE-ID.md +++ b/docs/RESOURCE-ID.md @@ -29,10 +29,11 @@ it is a typed refusal under these domains. ## The arrays Under the identity domains set 1 has one layout for every pipeline: binding 0 is the sampled-image -array of 65,536 elements and binding 1 the storage-image array of 4,096, each partially bound, -updated after binding and while unused elements are pending, and seen by every stage. Element `i` -of each is the texture whose ID holds index `i`, so the consumer writes an element once, as it -makes the texture, for every pipeline. Element 0 is a null descriptor (`nullDescriptor`): a nil +array of 65,536 elements, binding 1 the storage-image array of 4,096, and bindings 2, 3 and 4 the +sampler arrays of 4,000 elements each, every one partially bound, updated after binding and while +unused elements are pending, and seen by every stage. Element `i` of each image array is the +texture whose ID holds index `i`, so the consumer writes an element once, as it makes the texture, +for every pipeline. Element 0 is a null descriptor (`nullDescriptor`): a nil texture sizes 0, reads and samples zero, and drops a store, as Metal answers for a nil texture, with no code in the shader. Each texture class a shader declares (its shape, numeric type and depth comparison, sampled, or storage without a format) is a variable of its descriptor type's binding. @@ -41,7 +42,17 @@ A shader takes a texture slot's ID from the slot's push field (`PushField::SlotG argument buffer's texture's ID from the member's 8 bytes, with no table between. It indexes the arrays with the low word, answers `is_null_texture` by whether the index is 0, and, where it checks a `read` itself (a device without `robustImageAccess2`), takes an out-of-bounds -alpha of 1 from bit 12 of the word. Samplers are not lowered under these domains yet. +alpha of 1 from bit 12 of the word. + +Element `i` of each sampler array is a device sampler made of the sampler whose ID holds index `i`, +one per use, which the shader picks by the instruction and the texture's numeric type: binding 2 +for a plain sample, 3 for a depth comparison, and 4 for a texture of an integer format, every +filter nearest. The consumer makes each from the descriptor (its reduction mode and anisotropy +included); it makes none of a descriptor whose min or mag filter is cubic. A shader takes a +runtime sampler slot's ID from the slot's push field, samples through the element its low word +indexes, and reads the word's fields where a sample depends on them (pixel coordinates, a nearest +pixel sampler). A constexpr sampler and an argument buffer's sampler are not lowered under these +domains yet. ## The texture word diff --git a/scripts/refusal-surface/reach.tsv b/scripts/refusal-surface/reach.tsv index 603387792..eaf6db93b 100644 --- a/scripts/refusal-surface/reach.tsv +++ b/scripts/refusal-surface/reach.tsv @@ -82,7 +82,7 @@ feature Tensors rare shader tensors feature RasterizationRateMap rare rasterization rate maps feature GpuEncodedIndirectCommands rare indirect command buffers encoded by a kernel feature VulkanVersion none a device below Vulkan 1.2 -feature IdentityDomains none the identity domains, which the new runtime alone takes and which lower only kernels over buffer slots and unsampled textures, in slots or argument buffers, so far +feature IdentityDomains none the identity domains, which the new runtime alone takes and which lower only kernels over buffer slots, textures in slots or argument buffers, and runtime samplers, so far feature Constant none LLVM constant forms AIR does not emit feature Attribute none LLVM ABI attributes AIR does not use feature BitcodeRecord none bitcode records AIR does not emit