From a7166b2dedf1ebb29d09875991f65c595660a563 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 4 Dec 2026 13:56:22 -0800 Subject: [PATCH] Translator: the open_cl_lines variant goes; the runtime never asks for it LoweringInputs::open_cl_lines, VariantKey::open_cl_lines and metal2vulkan-air's SpecRequest::open_cl_lines named the 1D images of a kernel of OpenCL mode that a 1D texture is bound for, which then kept their 1D type and operations. metal2vulkan-runtime never asks for that variant: it refuses a 1D texture bound for such a kernel (Gap::OpenClLineTexture, the encoder's check of interface.open_cl_mode), since no reading of one is documented Metal, and nothing else in the tree sets the field. Consumer search: reims-vgpu cc1f47b30b (its development, read only): git grep -n open_cl_lines -> 0 hits (its only OpenCL hits are its own open_cl_mode fields and the RGFX_COMPUTE_PIPELINE_OPENCL_MODE flag). Its generated link-order.txt names VariantKey::lowering_inputs' closures, not the field. Deleted: - metal2vulkan-air: SpecRequest::open_cl_lines; canon::opencl::entry's lines argument (every 1D image of the kernel now takes its 2D texture's type); canon::opencl_1d's kept parameters (site, of_params, kept_params), so expand rewrites every 1D operation it lists; the doc lines that named the variant. Entry::open_cl_1d_images stays: its doc drops the variant. - metal2vulkan: LoweringInputs::open_cl_lines, VariantKey::open_cl_lines (is_empty and lowering_inputs), the function key's "open-cl-lines" part (appended only when set, so every surviving key hashes the same bytes), and compile.rs's plumbing: InputsFrom::open_cl_lines, StageEntry::open_cl_lines, the lines half of the stage entries' (mode, lines) match, given_inputs' clearing and the request's lines. - Tests: the variant's half of the AIR test (renamed opencl_1d_images_take_their_2d_textures_types, which keeps its OpenCL-mode type names and open_cl_1d_images assertions), the api round-trip values, and the field in every SpecRequest and LoweringInputs literal (air canon tests, memory plan tests, air_canon, validation's check.rs). - docs/API.md's OpenCL image paragraph named the variant; it now says each Mac's reading of a 1D texture there, which the kernel does not take. Public surface: python3 scripts/api-signatures/signatures.py --bless removes exactly the three field records (metal2vulkan-air::SpecRequest.open_cl_lines, metal2vulkan::cache::VariantKey.open_cl_lines, metal2vulkan::pipeline::LoweringInputs.open_cl_lines), a breaking change of the two published crates. refusal_surface.py reads no such field: --check passes unchanged, docs/REFUSALS.md does not move. Output: none moves for any input the runtime makes. A kernel compiled with an empty set, the only one anything sent, specializes and keys as before; SEMANTICS_VERSION stays (as at a7dd2e846e for the binder's inputs). The per-parameter meter ticks of kept_params go with it. Search at 9db78abe7d: git grep -n open_cl_lines -- crates docs: 37 hits across compile.rs, cache/mod.rs, lower_inputs.rs, key.rs, the AIR canon and the tests; 0 after. --- .../src/canon/devirt_tests.rs | 1 - .../src/canon/dynamic_tests.rs | 3 +- .../metal2vulkan-air/src/canon/link_tests.rs | 3 +- crates/metal2vulkan-air/src/canon/mod.rs | 13 +--- crates/metal2vulkan-air/src/canon/opencl.rs | 16 ++--- .../metal2vulkan-air/src/canon/opencl_1d.rs | 51 +++----------- crates/metal2vulkan-air/src/canon/tests.rs | 4 +- .../src/canon/tests/opencl.rs | 68 +++---------------- crates/metal2vulkan-validation/src/check.rs | 1 - crates/metal2vulkan/src/cache/mod.rs | 14 ---- crates/metal2vulkan/src/memory/plan/tests.rs | 3 - crates/metal2vulkan/src/pipeline/api_tests.rs | 2 - crates/metal2vulkan/src/pipeline/compile.rs | 59 ++++------------ .../metal2vulkan/src/pipeline/compile/key.rs | 6 -- .../src/pipeline/compile/tests.rs | 1 - .../metal2vulkan/src/pipeline/lower_inputs.rs | 7 -- crates/metal2vulkan/src/tests/air_canon.rs | 2 - crates/metal2vulkan/tests/api_signatures.tsv | 3 - docs/API.md | 9 +-- 19 files changed, 46 insertions(+), 220 deletions(-) diff --git a/crates/metal2vulkan-air/src/canon/devirt_tests.rs b/crates/metal2vulkan-air/src/canon/devirt_tests.rs index 6ef713747..6fd6f0e6c 100644 --- a/crates/metal2vulkan-air/src/canon/devirt_tests.rs +++ b/crates/metal2vulkan-air/src/canon/devirt_tests.rs @@ -131,7 +131,6 @@ fn request() -> SpecRequest { SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: BTreeSet::new(), entry: "k".into(), constants: BTreeMap::new(), } diff --git a/crates/metal2vulkan-air/src/canon/dynamic_tests.rs b/crates/metal2vulkan-air/src/canon/dynamic_tests.rs index fb9dc0418..a6be70c59 100644 --- a/crates/metal2vulkan-air/src/canon/dynamic_tests.rs +++ b/crates/metal2vulkan-air/src/canon/dynamic_tests.rs @@ -4,7 +4,7 @@ //! the search order, a library's own calls binding to its own definitions, a variable shared by //! every reference, the refusals of what is missing or not loaded. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; use super::*; use crate::abi::{ @@ -314,7 +314,6 @@ fn request() -> SpecRequest { SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: BTreeSet::new(), entry: "k".into(), constants: BTreeMap::new(), } diff --git a/crates/metal2vulkan-air/src/canon/link_tests.rs b/crates/metal2vulkan-air/src/canon/link_tests.rs index b191409b5..de5959a4e 100644 --- a/crates/metal2vulkan-air/src/canon/link_tests.rs +++ b/crates/metal2vulkan-air/src/canon/link_tests.rs @@ -1,7 +1,7 @@ //! Linking tests over IR built with the typed test builder: a kernel calls visible functions //! through reference stubs, and linked modules define them. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; use super::*; use crate::abi::{ @@ -255,7 +255,6 @@ fn request() -> SpecRequest { SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: BTreeSet::new(), entry: "k".into(), constants: BTreeMap::new(), } diff --git a/crates/metal2vulkan-air/src/canon/mod.rs b/crates/metal2vulkan-air/src/canon/mod.rs index 2feae7931..fc9fcd3db 100644 --- a/crates/metal2vulkan-air/src/canon/mod.rs +++ b/crates/metal2vulkan-air/src/canon/mod.rs @@ -207,12 +207,6 @@ pub struct SpecRequest { /// sits 3 past its index, and OpenCL C's work-item functions read the dispatch's values /// ([`opencl`]). Any other entry than a kernel specializes as without it. pub open_cl_mode: bool, - /// With [`open_cl_mode`](Self::open_cl_mode), the texture indices of the kernel's 1D images - /// (`texture1d` and `texture1d_array` arguments) that a 1D texture is bound for, where Apple's - /// OpenCL binds a 2D texture of height 1: each keeps its 1D type and its 1D operations, which - /// read the 1D texture. Every other 1D image of the kernel is read as the 2D texture - /// ([`Entry::open_cl_1d_images`]). - pub open_cl_lines: BTreeSet, } /// The constexpr samplers of one linked function that a pipeline state numbers @@ -306,8 +300,7 @@ pub struct Entry { pub unmeasured_speculation: bool, /// In a kernel of OpenCL mode ([`SpecRequest::open_cl_mode`]), the texture indices of its 1D /// images (`texture1d` and `texture1d_array` arguments): each is read as the 2D texture of - /// height 1 Apple's OpenCL binds for it, or as a 1D texture where - /// [`SpecRequest::open_cl_lines`] names it. Empty elsewhere. + /// height 1 Apple's OpenCL binds for it. Empty elsewhere. pub open_cl_1d_images: BTreeSet, } @@ -634,7 +627,7 @@ pub fn specialize_dynamic( // OpenCL mode: a 1D image's operations are the 2D texture's that Apple's OpenCL binds for it, // but those of an image a 1D texture is bound for. let body = if req.open_cl_mode && matches!(ep.stage, Stage::Kernel { .. }) { - opencl_1d::expand(body, &mut parts, (ep, &req.open_cl_lines), m)? + opencl_1d::expand(body, &mut parts, ep, m)? } else { body }; @@ -821,7 +814,7 @@ pub fn specialize_dynamic( // OpenCL mode's indices and hidden buffers. let mut open_cl_1d_images = BTreeSet::new(); if let Some(first) = hidden { - (ep, open_cl_1d_images) = opencl::entry(ep, first, &req.open_cl_lines)?; + (ep, open_cl_1d_images) = opencl::entry(ep, first)?; } // The buffer parameters the program-scope bindings' reads became, each at a slot no other // parameter binds. diff --git a/crates/metal2vulkan-air/src/canon/opencl.rs b/crates/metal2vulkan-air/src/canon/opencl.rs index a8e55de21..22874fe91 100644 --- a/crates/metal2vulkan-air/src/canon/opencl.rs +++ b/crates/metal2vulkan-air/src/canon/opencl.rs @@ -672,14 +672,10 @@ pub(super) fn barriers(mut body: Body, parts: &ModuleParts, m: &mut Meter) -> Re /// `first` to `first + 2`: each argument bound at a buffer index 3 past its own (an argument /// buffer, a function table and an acceleration structure as a buffer), threadgroup memory, /// textures and samplers at theirs, a 1D image's texture of the 2D type Metal's OpenCL binds for -/// it (`texture1d` as `texture2d`, `texture1d_array` as `texture2d_array`) but at a texture index -/// of `lines`, a 1D texture's, which keeps its type, and the buffers' bindings after the entry's -/// own. With it, the texture indices of the entry's 1D images (`Entry::open_cl_1d_images`). -pub fn entry( - mut ep: EntryPoint, - first: u32, - lines: &BTreeSet, -) -> Result<(EntryPoint, BTreeSet), Error> { +/// it (`texture1d` as `texture2d`, `texture1d_array` as `texture2d_array`), and the buffers' +/// bindings after the entry's own. With it, the texture indices of the entry's 1D images +/// (`Entry::open_cl_1d_images`). +pub fn entry(mut ep: EntryPoint, first: u32) -> Result<(EntryPoint, BTreeSet), Error> { let mut images = BTreeSet::new(); for p in &mut ep.params { if let ParamRole::Texture(t) = &p.role { @@ -692,9 +688,7 @@ pub fn entry( if let Some(index) = index { images.insert(index); } - if !index.is_some_and(|index| lines.contains(&index)) { - p.ty.name = Some(DiagName::new(bound)); - } + p.ty.name = Some(DiagName::new(bound)); } continue; } diff --git a/crates/metal2vulkan-air/src/canon/opencl_1d.rs b/crates/metal2vulkan-air/src/canon/opencl_1d.rs index ad97e1bb5..7f7448356 100644 --- a/crates/metal2vulkan-air/src/canon/opencl_1d.rs +++ b/crates/metal2vulkan-air/src/canon/opencl_1d.rs @@ -18,15 +18,12 @@ //! array, its coordinate `(x, 0)`, a sampled coordinate `(x, 0.5)` (the row's centre in //! normalized and unnormalized coordinates alike), its offset `(o, 0)` or, where the 1D form has //! none, `(0, 0)`. Lowering then declares the slot, and the binder binds it, as the 2D texture -//! Metal's OpenCL binds. An image a 1D texture is bound for (`SpecRequest::open_cl_lines`, the -//! binder's variant) keeps its 1D operations, which read the 1D texture: the 5300M's answer. -//! Not rewritten: `get_num_mip_levels`, whose 1D answer (0) a 2D texture's is +//! Metal's OpenCL binds; a 1D texture bound there, which Apple's OpenCL never binds, is the +//! consumer's to refuse. Not rewritten: `get_num_mip_levels`, whose 1D answer (0) a 2D texture's is //! not, and the image format queries, which read a hidden buffer whatever the shape //! (`canon::opencl`); neither is OpenCL C's. -use std::collections::BTreeSet; - -use crate::abi::{AbiInt, EntryPoint, ParamRole}; +use crate::abi::EntryPoint; use crate::budget::Meter; use crate::error::Error; use crate::intrinsics::{AirIntrinsic, ImageDim, ImageShape, Query, TexOp, TexRole, Texture}; @@ -60,9 +57,8 @@ fn widened(t: Texture) -> Option { } } -/// The 1D texture operation `kind` calls that [`expand`] rewrites, with its declaration and call: -/// not one of a texture parameter of `kept`, a 1D texture's. -fn site<'a>(kind: &'a InstKind, kept: &[u32]) -> Option<(Texture, FuncId, &'a Call)> { +/// The 1D texture operation `kind` calls that [`expand`] rewrites, with its declaration and call. +fn site(kind: &InstKind) -> Option<(Texture, FuncId, &Call)> { let InstKind::Call(call) = kind else { return None; }; @@ -70,36 +66,11 @@ fn site<'a>(kind: &'a InstKind, kept: &[u32]) -> Option<(Texture, FuncId, &'a Ca Callee::Air { decl, op: AirIntrinsic::Texture(t), - } if widened(t).is_some() && !of_params(t, call, kept) => Some((t, decl, call)), + } if widened(t).is_some() => Some((t, decl, call)), _ => None, } } -/// Whether operation `t`'s `call` names a texture that is one of the entry's parameters `kept`. -fn of_params(t: Texture, call: &Call, kept: &[u32]) -> bool { - let texture = t.layout().index(TexRole::Texture); - match texture.and_then(|i| call.args.get(i)) { - Some(Value::Arg(a)) => u32::try_from(a.index()).is_ok_and(|p| kept.contains(&p)), - _ => false, - } -} - -/// The parameters of `ep` that bind a texture at an index of `lines`: the 1D images a 1D texture -/// is bound for, whose operations stay 1D. -fn kept_params(ep: &EntryPoint, lines: &BTreeSet, m: &mut Meter) -> Result, Error> { - let mut kept = Vec::new(); - for p in &ep.params { - m.tick(1)?; - if let ParamRole::Texture(t) = &p.role { - if matches!(t.location.index, AbiInt::Const(index) if lines.contains(&index)) { - m.reserve(&mut kept, 1)?; - kept.push(p.param); - } - } - } - Ok(kept) -} - /// Whether `parts` declares a 1D texture operation [`expand`] rewrites. Every site calls one, so /// a module that declares none has none, and [`expand`] need not read its instructions. fn declares_sites(parts: &ModuleParts, m: &mut Meter) -> Result { @@ -121,25 +92,23 @@ fn declares_sites(parts: &ModuleParts, m: &mut Meter) -> Result { } /// Make each 1D texture operation of the entry `ep`'s inlined `body` that the module doc lists a -/// call of a function built for it, and inline the result: each but those of an image at a -/// texture index of `lines`, which a 1D texture is bound for. +/// call of a function built for it, and inline the result. pub(super) fn expand( body: Body, parts: &mut ModuleParts, - (ep, lines): (&EntryPoint, &BTreeSet), + ep: &EntryPoint, m: &mut Meter, ) -> Result { if !declares_sites(parts, m)? { return Ok(body); } let func = ep.func; - let kept = kept_params(ep, lines, m)?; // One function per operation and declaration, and each call's. let mut made: Vec<((Texture, FuncId), FuncId)> = Vec::new(); let mut calls: Vec<(InstId, FuncId)> = Vec::new(); for (id, inst) in body.insts.iter() { m.tick(1)?; - let Some((t, decl, call)) = site(&inst.kind, &kept) else { + let Some((t, decl, call)) = site(&inst.kind) else { continue; }; let f = match made.iter().find(|(k, _)| *k == (t, decl)) { @@ -156,8 +125,6 @@ pub(super) fn expand( } m.release(made.capacity() * std::mem::size_of::<((Texture, FuncId), FuncId)>()); drop(made); - m.release(kept.capacity() * std::mem::size_of::()); - drop(kept); if calls.is_empty() { m.release(calls.capacity() * std::mem::size_of::<(InstId, FuncId)>()); return Ok(body); diff --git a/crates/metal2vulkan-air/src/canon/tests.rs b/crates/metal2vulkan-air/src/canon/tests.rs index f4b153fa5..6a980803c 100644 --- a/crates/metal2vulkan-air/src/canon/tests.rs +++ b/crates/metal2vulkan-air/src/canon/tests.rs @@ -1,6 +1,6 @@ //! Canonicalization tests over IR built with the typed test builder. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; use super::*; use crate::abi::{ @@ -184,7 +184,6 @@ fn request(constants: &[(u32, ConstValue)]) -> SpecRequest { SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: BTreeSet::new(), entry: "k".into(), constants: constants.iter().cloned().collect::>(), } @@ -2864,7 +2863,6 @@ fn a_static_initializer_branch_on_an_unsupplied_constant_takes_its_false_way() { let r = SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: BTreeSet::new(), entry: "k".into(), constants: [(3, boolean(1))].into_iter().collect(), }; diff --git a/crates/metal2vulkan-air/src/canon/tests/opencl.rs b/crates/metal2vulkan-air/src/canon/tests/opencl.rs index d6be7064d..887efb28a 100644 --- a/crates/metal2vulkan-air/src/canon/tests/opencl.rs +++ b/crates/metal2vulkan-air/src/canon/tests/opencl.rs @@ -4,6 +4,8 @@ //! the same kernel specializes as Metal AIR, its OpenCL-only reads left for lowering to refuse. //! The modules are LLVM text written here, assembled with `llvm-as`; a run without it skips. +use std::collections::BTreeSet; + use super::*; use crate::abi::Builtin; use crate::intrinsics::WorkItem; @@ -332,12 +334,6 @@ attributes #3 = { nounwind willreturn }\n\ /// [`IMAGES`] specialized, in OpenCL mode where `open_cl_mode`; `None` without `llvm-as`. fn images(test: &str, open_cl_mode: bool) -> Option { - images_bound(test, open_cl_mode, BTreeSet::new()) -} - -/// [`IMAGES`] specialized, in OpenCL mode where `open_cl_mode`, a 1D texture bound for each 1D -/// image at a texture index of `lines`; `None` without `llvm-as`. -fn images_bound(test: &str, open_cl_mode: bool, lines: BTreeSet) -> Option { let bitcode = match metal2vulkan_devtools::llvm_assemble_text(&format!("{HEAD}{IMAGES}")) { Ok(b) => b, Err(e) => { @@ -349,7 +345,6 @@ fn images_bound(test: &str, open_cl_mode: bool, lines: BTreeSet) -> Option< let req = SpecRequest { entry: "img".into(), open_cl_mode, - open_cl_lines: lines, ..SpecRequest::default() }; Some(specialize(d.module, &d.abi, &req, &mut meter()).expect("specialized")) @@ -513,52 +508,15 @@ fn opencl_1d_images_are_read_written_and_queried_as_2d_textures() { ); } -/// A 1D image a 1D texture is bound for (`SpecRequest::open_cl_lines`), which Apple's OpenCL never -/// binds, keeps its type and its 1D operations, which read that texture; every other 1D image is -/// the 2D texture's still. The entry names its 1D images in OpenCL mode alone, whatever is bound. +/// In OpenCL mode each 1D image takes the type of the 2D texture Apple's OpenCL binds for it +/// (`texture1d` as `texture2d`, `texture1d_array` as `texture2d_array`), and the entry names its +/// 1D images (`Entry::open_cl_1d_images`); without the mode it names none. #[test] -fn opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations() { - use crate::intrinsics::{ImageDim, Query}; - let test = "opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations"; - let (Some(plain), Some(cl), Some(lines)) = ( - images(test, false), - images(test, true), - images_bound(test, true, BTreeSet::from([1, 2])), - ) else { +fn opencl_1d_images_take_their_2d_textures_types() { + let test = "opencl_1d_images_take_their_2d_textures_types"; + let (Some(plain), Some(cl)) = (images(test, false), images(test, true)) else { return; }; - let ops = |e: &Entry| { - let mut v: Vec<_> = texture_ops(e) - .into_iter() - .filter(|(op, ..)| { - !matches!( - op, - TexOp::Query(Query::ChannelOrder | Query::ChannelDataType) - ) - }) - .collect(); - v.sort(); - v - }; - let width = TexOp::Query(Query::Width); - let layers = TexOp::Query(Query::ArraySize); - let sample = |e: &Entry| { - texture_ops(e) - .into_iter() - .find(|(op, ..)| matches!(op, TexOp::Sample { .. })) - .expect("a sample") - .0 - }; - // `b` (texture 1) and `c` (texture 2) stay 1D; `d` (texture 3) writes its 2D texture. - let mut want = vec![ - (layers, ImageDim::D1, true), - (TexOp::Read, ImageDim::D1, false), - (sample(&lines), ImageDim::D1, true), - (width, ImageDim::D1, false), - (TexOp::Write, ImageDim::D2, false), - ]; - want.sort(); - assert_eq!(ops(&lines), want, "{}", print(&lines.module)); let names = |e: &Entry| -> Vec<(u32, String)> { e.ep.params .iter() @@ -571,15 +529,6 @@ fn opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations() { }) .collect() }; - assert_eq!( - names(&lines), - [ - (0, "texture2d".to_owned()), - (1, "texture1d".to_owned()), - (2, "texture1d_array".to_owned()), - (3, "texture2d".to_owned()), - ] - ); assert_eq!( names(&cl), [ @@ -590,7 +539,6 @@ fn opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations() { ] ); assert_eq!(cl.open_cl_1d_images, BTreeSet::from([1, 2, 3])); - assert_eq!(lines.open_cl_1d_images, BTreeSet::from([1, 2, 3])); assert!(plain.open_cl_1d_images.is_empty()); } diff --git a/crates/metal2vulkan-validation/src/check.rs b/crates/metal2vulkan-validation/src/check.rs index 08e1b8a7b..bc339f9cb 100644 --- a/crates/metal2vulkan-validation/src/check.rs +++ b/crates/metal2vulkan-validation/src/check.rs @@ -573,7 +573,6 @@ fn omitted_constants_error( let request = metal2vulkan_air::canon::SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: Default::default(), entry: entry.to_string(), constants, }; diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 81f551bfe..9d0ab6a5f 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -278,13 +278,6 @@ pub struct VariantKey { /// a list's base vertex cannot carry (`RuntimeFact::PrivateList`). #[cfg_attr(feature = "serde", serde(default))] pub private_list: bool, - /// The texture slots of a kernel of OpenCL mode, each a 1D image it reads as the 2D texture of - /// height 1 Apple's OpenCL binds, that the shape binds a 1D or 1D array texture at - /// (`LoweringInputs::open_cl_lines`): the variant's kernel declares each as that 1D texture and - /// reads it. `metal2vulkan-runtime` asks for none: it refuses such a binding - /// (`Gap::OpenClLineTexture`). - #[cfg_attr(feature = "serde", serde(default))] - pub open_cl_lines: BTreeSet, /// The render pipeline draws a rasterization-rate-mapped pass's regions several at a time, /// each one draw of a multi-draw whose index selects its viewport and scissor: its vertex /// function stores `ViewportIndex` as `DrawIndex` @@ -328,7 +321,6 @@ impl VariantKey { && self.primitive_id_indices.is_none() && !self.quad_primitive_ids && !self.private_list - && self.open_cl_lines.is_empty() && !self.region_viewports && !self.depth_range_fold } @@ -384,12 +376,6 @@ impl VariantKey { self.region_viewports && stage == crate::pipeline::sym::Stage::Vertex; out.depth_range_fold = self.depth_range_fold && stage == crate::pipeline::sym::Stage::Vertex; - out.open_cl_lines = self - .open_cl_lines - .iter() - .filter(|s| s.stage == stage) - .copied() - .collect(); out.extended_range = self .extended_range .iter() diff --git a/crates/metal2vulkan/src/memory/plan/tests.rs b/crates/metal2vulkan/src/memory/plan/tests.rs index 8208379c0..b2d68db8e 100644 --- a/crates/metal2vulkan/src/memory/plan/tests.rs +++ b/crates/metal2vulkan/src/memory/plan/tests.rs @@ -740,7 +740,6 @@ fn pooled_cells(stem: &str) -> Option { let req = crate::air::SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: Default::default(), entry: stem.to_owned(), constants: Default::default(), }; @@ -1612,7 +1611,6 @@ fn every_public_fixture_analyzes_without_an_internal_error() { let req = crate::air::SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: Default::default(), entry: name.clone(), constants: Default::default(), }; @@ -1659,7 +1657,6 @@ fn hand_checked_fixtures() { let req = crate::air::SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: Default::default(), entry: stem.to_owned(), constants: Default::default(), }; diff --git a/crates/metal2vulkan/src/pipeline/api_tests.rs b/crates/metal2vulkan/src/pipeline/api_tests.rs index 640dc4a51..4f81866d2 100644 --- a/crates/metal2vulkan/src/pipeline/api_tests.rs +++ b/crates/metal2vulkan/src/pipeline/api_tests.rs @@ -119,7 +119,6 @@ mod serde_round_trips { primitive_id_indices: Some(metal::IndexType::UInt16), quad_primitive_ids: true, private_list: true, - open_cl_lines: BTreeSet::from([slot(Stage::Kernel, SlotClass::Texture, 1)]), region_viewports: true, depth_range_fold: true, }); @@ -272,7 +271,6 @@ mod serde_round_trips { threadgroup_size_matches_tile_size: true, rotated_blends: BTreeSet::from([4, 6]), texture_write_rounding: metal::TextureWriteRoundingMode::NearestEven, - open_cl_lines: BTreeSet::from([slot(Stage::Kernel, SlotClass::Texture, 2)]), uniform_varyings: BTreeSet::from([VaryingKey::user(b"user(tint)")]), instanced_attributes: BTreeSet::from([1]), object_payload: Some(64), diff --git a/crates/metal2vulkan/src/pipeline/compile.rs b/crates/metal2vulkan/src/pipeline/compile.rs index aa1ad5ffb..a3c72784a 100644 --- a/crates/metal2vulkan/src/pipeline/compile.rs +++ b/crates/metal2vulkan/src/pipeline/compile.rs @@ -60,7 +60,7 @@ use crate::pipeline::descriptor::{ }; use crate::pipeline::facts::RuntimeFact; use crate::pipeline::interface::{SlotInterface, StageInterface}; -use crate::pipeline::sym::{SlotClass, SlotRef, Stage, VaryingKey}; +use crate::pipeline::sym::{SlotClass, VaryingKey}; use crate::reflection; use crate::spirv::ir::TypedModule; @@ -231,19 +231,6 @@ impl<'a> InputsFrom<'a> { InputsFrom::Vertex(..) | InputsFrom::Fragment(..) => false, } } - - /// The kernel's texture slots of OpenCL mode's 1D images bound to a 1D texture - /// (`LoweringInputs::open_cl_lines`): the given inputs'; a render pipeline's stage has none. - fn open_cl_lines(&self) -> &'a BTreeSet { - static NONE: BTreeSet = BTreeSet::new(); - match self { - InputsFrom::Given(i) => { - let given: &'a LowerInputs = i; - &given.open_cl_lines - } - InputsFrom::Vertex(..) | InputsFrom::Fragment(..) => &NONE, - } - } } /// Where `inputs` are a render pipeline's fragment stage's, each `[[color(n)]]` input the @@ -589,7 +576,7 @@ pub fn stage_inputs( m: &mut Meter, ) -> Result { guarded(|| { - let open_cl = (inputs.open_cl_mode(), inputs.open_cl_lines()); + let open_cl = inputs.open_cl_mode(); let specialized = entries.specialized(fd, inputs.call_stack_depth(), open_cl, m)?; color_inputs_attached(&specialized.spec, inputs)?; let spec = &specialized.spec; @@ -1005,8 +992,6 @@ struct StageEntry { depth: u32, /// Specialized as the kernel of a compute pipeline of OpenCL mode. open_cl_mode: bool, - /// With it, the slots of its 1D images bound to a 1D texture (`LoweringInputs::open_cl_lines`). - open_cl_lines: BTreeSet, /// What specializing it charged, which every ask that finds it is charged; the byte bound /// counts the bytes it holds. spent: Spent, @@ -1149,9 +1134,8 @@ impl StageEntries { } /// The entry of stage `fd`, its calls nesting `depth` deep through visible functions (0 is - /// taken as 1, Metal's default), as the kernel of a pipeline of OpenCL mode where `open_cl` - /// says so, its 1D images bound to a 1D texture at the slots it names, specialized as a - /// compile specializes it before lowering + /// taken as 1, Metal's default), as the kernel of a pipeline of OpenCL mode where + /// `open_cl_mode` says so, specialized as a compile specializes it before lowering /// (its constants bound, its linked functions resolved, its calls inlined, SCCP run), with /// what a compile takes beside it (The AIR hash, the entry name, what its code read before, so /// a compile of the stage reads it too, [`specialize_one`]): the one made before, charged to @@ -1161,15 +1145,14 @@ impl StageEntries { &self, fd: &FunctionDescriptor, depth: u32, - (open_cl_mode, open_cl_lines): (bool, &BTreeSet), + open_cl_mode: bool, m: &mut Meter, ) -> Result, Error> { let depth = depth.max(1); // The library's table states it without decoding (`Function::info`). let air_hash = fd.function.info().air_hash; let lock = || self.kept.lock().unwrap_or_else(|e| e.into_inner()); - let open_cl = (open_cl_mode, open_cl_lines); - let found = lock().take(&air_hash, fd, depth, open_cl); + let found = lock().take(&air_hash, fd, depth, open_cl_mode); if let Some((specialized, spent)) = found { m.spend(spent)?; return Ok(specialized); @@ -1177,7 +1160,6 @@ impl StageEntries { let mut inputs = LowerInputs::new(); inputs.max_call_stack_depth = call_stack_input(depth); inputs.open_cl_mode = open_cl_mode; - inputs.open_cl_lines = open_cl_lines.clone(); let (specialized, spent) = m.measured(|m| { with_request_shared( &fd.function, @@ -1192,7 +1174,7 @@ impl StageEntries { let mut kept = lock(); // Another caller may have specialized the same stage meanwhile: its entry is this one, so // the two share one. - if let Some((theirs, _)) = kept.take(&air_hash, fd, depth, open_cl) { + if let Some((theirs, _)) = kept.take(&air_hash, fd, depth, open_cl_mode) { return Ok(theirs); } kept.made += 1; @@ -1202,7 +1184,6 @@ impl StageEntries { function: fd.clone(), depth, open_cl_mode, - open_cl_lines: inputs.open_cl_lines, spent, specialized: Arc::clone(&specialized), ordered: None, @@ -1221,7 +1202,7 @@ impl StageEntries { &self, fd: &FunctionDescriptor, depth: u32, - open_cl: (bool, &BTreeSet), + open_cl: bool, m: &mut Meter, ) -> Result, Error> { let depth = depth.max(1); @@ -1268,7 +1249,7 @@ impl Kept { air_hash: &Hash256, fd: &FunctionDescriptor, depth: u32, - open_cl: (bool, &BTreeSet), + open_cl: bool, ) -> Option<(Arc, Spent)> { let entry = self.used(air_hash, fd, depth, open_cl)?; let found = (Arc::clone(&entry.specialized), entry.spent); @@ -1284,12 +1265,11 @@ impl Kept { air_hash: &Hash256, fd: &FunctionDescriptor, depth: u32, - (open_cl_mode, open_cl_lines): (bool, &BTreeSet), + open_cl_mode: bool, ) -> Option<&mut StageEntry> { let at = self.entries.iter().position(|e| { e.depth == depth && e.open_cl_mode == open_cl_mode - && e.open_cl_lines == *open_cl_lines && e.air_hash == *air_hash && e.function == *fd })?; @@ -1306,7 +1286,7 @@ impl Kept { air_hash: &Hash256, fd: &FunctionDescriptor, depth: u32, - open_cl: (bool, &BTreeSet), + open_cl: bool, ) -> Option<(Arc, Spent, Spent)> { let entry = self.used(air_hash, fd, depth, open_cl)?; let order = entry.ordered.as_ref()?; @@ -1324,7 +1304,7 @@ impl Kept { air_hash: &Hash256, fd: &FunctionDescriptor, depth: u32, - open_cl: (bool, &BTreeSet), + open_cl: bool, (spent, ordered): (Spent, Arc), ) { let Some(entry) = self.used(air_hash, fd, depth, open_cl) else { @@ -2169,7 +2149,6 @@ pub(crate) fn spec_request( constants: constant_values(&decoded.abi, consts)?, call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: BTreeSet::new(), }) } @@ -2271,7 +2250,7 @@ pub(crate) fn kernel_inputs_read( return Ok(inputs.clone()); }; let depth = inputs.max_call_stack_depth.unwrap_or(1); - let open_cl = (inputs.open_cl_mode, &inputs.open_cl_lines); + let open_cl = inputs.open_cl_mode; let specialized = entries.specialized(fd, depth, open_cl, m)?; let read = stage_in_attributes(&specialized.spec); let mut out = inputs.clone(); @@ -2509,9 +2488,6 @@ fn given_inputs(spec: &air::Entry, i: &LowerInputs) -> LowerInputs { let mut out = i.clone(); out.folded_groups = i.folded_groups || matches!(spec.ep.stage, AbiStage::Object { .. }); out.open_cl_mode = i.open_cl_mode && matches!(spec.ep.stage, AbiStage::Kernel { .. }); - if !out.open_cl_mode { - out.open_cl_lines = BTreeSet::new(); - } out.object_payload = i.object_payload.filter(|&bytes| { matches!( spec.ep.stage, @@ -2658,7 +2634,7 @@ fn specialize_unweighed(r: &Request<'_>, m: &mut Meter) -> Result, m: &mut Meter) -> Result, m: &mut Meter) -> Result /// read one ordered entry. fn ordered_entry(r: &Request<'_>, m: &mut Meter) -> Result { if let Shared::Entry(entries, fd) = r.shared { - let open_cl = (r.inputs.open_cl_mode(), r.inputs.open_cl_lines()); + let open_cl = r.inputs.open_cl_mode(); let depth = r.inputs.call_stack_depth(); let kept = entries.ordered(fd, depth, open_cl, m)?; return Ok(Specialized::clone(&kept)); diff --git a/crates/metal2vulkan/src/pipeline/compile/key.rs b/crates/metal2vulkan/src/pipeline/compile/key.rs index 84477676c..99548663c 100644 --- a/crates/metal2vulkan/src/pipeline/compile/key.rs +++ b/crates/metal2vulkan/src/pipeline/compile/key.rs @@ -403,12 +403,6 @@ pub fn function_key( if inputs.texture_write_rounding != crate::metal::TextureWriteRoundingMode::TowardZero { h.bytes(b"texture-write-rounding-nearest-even"); } - // Appended only when set, as `signed_color_attachments`: a kernel whose 1D images are bound as Apple's - // OpenCL binds them keeps its key. - if !inputs.open_cl_lines.is_empty() { - h.bytes(b"open-cl-lines") - .bytes(format!("{:?}", inputs.open_cl_lines).as_bytes()); - } // Appended only when set, in its derived `Debug` form (an ordered set of byte keys): a // fragment function whose vertex function writes no varying it interpolates the same at // every vertex keeps its key. diff --git a/crates/metal2vulkan/src/pipeline/compile/tests.rs b/crates/metal2vulkan/src/pipeline/compile/tests.rs index 879d13597..03d6583a9 100644 --- a/crates/metal2vulkan/src/pipeline/compile/tests.rs +++ b/crates/metal2vulkan/src/pipeline/compile/tests.rs @@ -678,7 +678,6 @@ fn the_inputs_encoding_is_the_earlier_derived_debug() { .replace(", threadgroup_size_matches_tile_size: false", "") .replace(", rotated_blends: {}", "") .replace(", texture_write_rounding: TowardZero", "") - .replace(", open_cl_lines: {}", "") .replace(", uniform_varyings: {}", "") .replace(", instanced_attributes: {}", "") .replace(", object_payload: None", "") diff --git a/crates/metal2vulkan/src/pipeline/lower_inputs.rs b/crates/metal2vulkan/src/pipeline/lower_inputs.rs index 0a449a04a..b5756793c 100644 --- a/crates/metal2vulkan/src/pipeline/lower_inputs.rs +++ b/crates/metal2vulkan/src/pipeline/lower_inputs.rs @@ -641,13 +641,6 @@ pub struct LoweringInputs { /// that writes no such texel, compiles as without it. #[cfg_attr(feature = "serde", serde(default))] pub texture_write_rounding: metal::TextureWriteRoundingMode, - /// With [`open_cl_mode`](Self::open_cl_mode), the kernel's texture slots of a 1D image bound to - /// a 1D or 1D array texture (`VariantKey::open_cl_lines`), where Apple's OpenCL binds a 2D - /// texture of height 1: the kernel declares each as that 1D texture and reads it, as a Radeon - /// Pro 5300M (macOS 26.7.1) answers (`air::SpecRequest::open_cl_lines`). Every other 1D image - /// is read as the 2D texture. Empty for any other function. - #[cfg_attr(feature = "serde", serde(default))] - pub open_cl_lines: BTreeSet, /// The `float` and `half` varyings the fragment function reads interpolated (`center`, /// `centroid` or `sample`, with or without perspective) whose keys its render pipeline's /// vertex function writes the same value at every vertex of a primitive diff --git a/crates/metal2vulkan/src/tests/air_canon.rs b/crates/metal2vulkan/src/tests/air_canon.rs index 134bb68c2..9475b6726 100644 --- a/crates/metal2vulkan/src/tests/air_canon.rs +++ b/crates/metal2vulkan/src/tests/air_canon.rs @@ -310,7 +310,6 @@ fn a_static_initializer_fixture_specializes_with_its_constant() { let r = SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: Default::default(), entry: "fcfold".into(), constants: [( 0, @@ -360,7 +359,6 @@ fn a_vector_function_constant_bakes_through_the_static_initializer() { let r = SpecRequest { call_stack_depth: 1, open_cl_mode: false, - open_cl_lines: Default::default(), entry: entry.into(), constants: [( 0, diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 0563fe88d..ec649ea72 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -845,7 +845,6 @@ field metal2vulkan-air::Lockstep.unordered pub unordered: bool field metal2vulkan-air::SpecRequest.call_stack_depth pub call_stack_depth: u32 field metal2vulkan-air::SpecRequest.constants pub constants: BTreeMap field metal2vulkan-air::SpecRequest.entry pub entry: String -field metal2vulkan-air::SpecRequest.open_cl_lines pub open_cl_lines: BTreeSet field metal2vulkan-air::SpecRequest.open_cl_mode pub open_cl_mode: bool field metal2vulkan-air::abi::AirAbi.air_version pub air_version: Option field metal2vulkan-air::abi::AirAbi.compile pub compile: CompileOptions @@ -2092,7 +2091,6 @@ field metal2vulkan::cache::VariantKey.folded_groups pub folded_groups: bool field metal2vulkan::cache::VariantKey.kept_imageblock_bytes pub kept_imageblock_bytes: Option field metal2vulkan::cache::VariantKey.line_band pub line_band: Option field metal2vulkan::cache::VariantKey.merged_draws pub merged_draws: bool -field metal2vulkan::cache::VariantKey.open_cl_lines pub open_cl_lines: BTreeSet field metal2vulkan::cache::VariantKey.partial_threadgroups pub partial_threadgroups: bool field metal2vulkan::cache::VariantKey.primitive_id_indices pub primitive_id_indices: Option field metal2vulkan::cache::VariantKey.private_list pub private_list: bool @@ -2599,7 +2597,6 @@ field metal2vulkan::pipeline::LoweringInputs.max_call_stack_depth pub max_call_s field metal2vulkan::pipeline::LoweringInputs.merged_draws pub merged_draws: bool field metal2vulkan::pipeline::LoweringInputs.multisampled pub multisampled: bool field metal2vulkan::pipeline::LoweringInputs.object_payload pub object_payload: Option -field metal2vulkan::pipeline::LoweringInputs.open_cl_lines pub open_cl_lines: BTreeSet field metal2vulkan::pipeline::LoweringInputs.open_cl_mode pub open_cl_mode: bool field metal2vulkan::pipeline::LoweringInputs.partial_threadgroups pub partial_threadgroups: bool field metal2vulkan::pipeline::LoweringInputs.primitive_id_indices pub primitive_id_indices: Option diff --git a/docs/API.md b/docs/API.md index 49437fa5c..7b1234b9a 100644 --- a/docs/API.md +++ b/docs/API.md @@ -878,12 +878,9 @@ through buffer arguments it reads at any index. image, `get_image_width` and `get_image_array_size` is the 2D texture's at row 0 (a sampled coordinate at the row's centre), as both Macs answer. A real 1D texture bound for an `image1d_t`, or a 1D array texture for an `image1d_array_t`, which Apple's OpenCL never binds, - takes the kernel's variant that declares that slot as the 1D texture - (`VariantKey::open_cl_lines`): each read, sample and size - query answers the 1D texture's values, of the layer an array access names, as a Radeon Pro - 5300M (macOS 26.7.1) answers (an Intel UHD Graphics 630 reads layer 0 of the array, an M3 Max - texel 0 at every coordinate). Under the identity domains no variant is made: the kernel reads - each 1D image as the 2D texture, and a consumer refuses a 1D + is read differently by each Mac (a Radeon Pro 5300M, macOS 26.7.1, answers the 1D texture's + values, an Intel UHD Graphics 630 layer 0 of the array, an M3 Max texel 0 at every + coordinate): the kernel reads each 1D image as the 2D texture, and a consumer refuses a 1D texture bound for it (the runtime's `Gap::OpenClLineTexture`), since no reading of one is documented Metal. Apple's OpenCL binds an image of most channel orders as a swizzled view (on an M3 Max, macOS 27.0.1, with `CL_UNORM_INT8`: `CL_R`,