From e649629fde90898457d570e121fddb952a793e77 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 13:02:01 -0800 Subject: [PATCH] Translator: the identity domains lower object and mesh functions; IdentityCause::ObjectOrMeshStage deleted What: identity_refusal no longer refuses a function for being an object or mesh function, and it takes an object function's PushField::ReplayRegionAddress, the address of the region record its folded grid's draw pieces read (bind::mesh_arguments); that field stays refused for every other stage. IdentityCause::ObjectOrMeshStage, which nothing produces now, is deleted. Why: the mesh build. Every profile refused object and mesh functions under the identity domains, the one form, so no mesh render pipeline compiled anywhere. Public item removed (api_signatures.tsv): metal2vulkan::error::IdentityCause::ObjectOrMeshStage. Consumer search: reims-vgpu development 35cea45c0e plus its 210 steelbrain refs younger than a day: 0 hits for ObjectOrMeshStage. SEMANTICS_VERSION 2366 (a placeholder; the number is set at landing): object and mesh functions compile where they were refused. Tests: the parent's red test passes; the validation companion's mesh pipelines compile where they were refused; the linked reflection test's mesh pipeline compiles with its unwritten fragment input dropped, as the tessellated one does. docs/API.md's cause list no longer names the deleted cause; runtime-sources.sha256 is re-pinned. Verified: see the job named below. --- .../src/companion/tests.rs | 21 +++++++------------ crates/metal2vulkan/src/cache/mod.rs | 2 +- crates/metal2vulkan/src/error/mod.rs | 3 --- crates/metal2vulkan/src/lower/select.rs | 14 ++++++------- .../src/reflection/linked_tests.rs | 19 ++++++++++------- crates/metal2vulkan/tests/api_signatures.tsv | 1 - docs/API.md | 2 +- 7 files changed, 28 insertions(+), 34 deletions(-) diff --git a/crates/metal2vulkan-validation/src/companion/tests.rs b/crates/metal2vulkan-validation/src/companion/tests.rs index deaa052c0..601a75913 100644 --- a/crates/metal2vulkan-validation/src/companion/tests.rs +++ b/crates/metal2vulkan-validation/src/companion/tests.rs @@ -990,7 +990,7 @@ fn generated_companions_link_with_their_cases_in_the_engine() { descriptor.color_attachments[0] = Some(metal2vulkan::pipeline::ColorAttachmentDescriptor::new( metal2vulkan::metal::PixelFormat::RGBA32Uint, )); - refused_mesh(device.compile_mesh_pipeline(&descriptor, &metal2vulkan::Budget::standard())); + compiled_mesh(device.compile_mesh_pipeline(&descriptor, &metal2vulkan::Budget::standard())); // The payload object under the mesh function that reads its payload, and that mesh // function's fragment partner. @@ -1014,21 +1014,14 @@ fn generated_companions_link_with_their_cases_in_the_engine() { metal2vulkan::metal::PixelFormat::RGBA32Uint, )); } - refused_mesh(device.compile_mesh_pipeline(&descriptor, &metal2vulkan::Budget::standard())); + compiled_mesh(device.compile_mesh_pipeline(&descriptor, &metal2vulkan::Budget::standard())); } -/// The one form's refusal of a mesh pipeline: its object and mesh stages are a stage other than a -/// kernel, vertex or fragment function (`IdentityCause::ObjectOrMeshStage`). -fn refused_mesh(r: Result) { - use metal2vulkan::error::{Cause, Error, IdentityCause}; - match r { - Err(Error::Unsupported(u)) => assert_eq!( - u.cause, - Some(Cause::Identity(IdentityCause::ObjectOrMeshStage)), - "{u}" - ), - Err(e) => panic!("the mesh pipeline: {e}"), - Ok(_) => panic!("the mesh pipeline compiled"), +/// A mesh pipeline of the companion's stages compiles under the identity domains: its object, +/// mesh and fragment stages link. +fn compiled_mesh(r: Result) { + if let Err(e) = r { + panic!("the mesh pipeline: {e}"); } } diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 1ffcf2b6e..54f5082e0 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -60,7 +60,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 = 2378; +pub const SEMANTICS_VERSION: u32 = 2379; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another diff --git a/crates/metal2vulkan/src/error/mod.rs b/crates/metal2vulkan/src/error/mod.rs index cb25553cc..4b9be3238 100644 --- a/crates/metal2vulkan/src/error/mod.rs +++ b/crates/metal2vulkan/src/error/mod.rs @@ -1075,9 +1075,6 @@ pub enum IdentityCause { /// decoded, a texture read through another numeric type than its own, or a handle that reads /// its table entry beyond its element. HeapResource, - /// A function of a stage other than a kernel, vertex or fragment function: an object or mesh - /// function. - ObjectOrMeshStage, /// A sample through a sampler the identity sampling does not take: a sampler argument whose /// minimum level the function specializes. SamplerState, diff --git a/crates/metal2vulkan/src/lower/select.rs b/crates/metal2vulkan/src/lower/select.rs index b1579f672..bd9e7e207 100644 --- a/crates/metal2vulkan/src/lower/select.rs +++ b/crates/metal2vulkan/src/lower/select.rs @@ -1811,16 +1811,16 @@ fn identity_pushes(field: PushField, loc: PushLoc, views: bool) -> bool { /// program reaches it, which [`identity_admits`]'s refusal names (diagnostics only); `None` where /// it holds none. fn identity_refusal(plan: &Plan) -> Option<(IdentityCause, String)> { - if !matches!(plan.stage, Stage::Kernel | Stage::Vertex | Stage::Fragment) { - return Some(( - IdentityCause::ObjectOrMeshStage, - "a function of a stage other than a kernel, vertex or fragment function".to_owned(), - )); - } // A kernel on a device that binds its buffer arguments reaches each storage view at its // pushed bind offset (`AccessPlan::robust_views`). let views = plan.families.access.robust_views; - let field = (plan.push.fields.iter()).find(|f| !identity_pushes(f.field, f.loc, views)); + let field = (plan.push.fields.iter()).find(|f| { + // An object function's grid is folded: its region is the record its draw's pieces read + // (`lower::mesh`'s object grid, `bind::mesh_arguments`). + let object_region = + matches!(f.field, PushField::ReplayRegionAddress) && plan.stage == Stage::Object; + !object_region && !identity_pushes(f.field, f.loc, views) + }); if let Some(f) = field { return Some(( IdentityCause::EncoderValue, diff --git a/crates/metal2vulkan/src/reflection/linked_tests.rs b/crates/metal2vulkan/src/reflection/linked_tests.rs index 7124ebd22..708dfafad 100644 --- a/crates/metal2vulkan/src/reflection/linked_tests.rs +++ b/crates/metal2vulkan/src/reflection/linked_tests.rs @@ -718,8 +718,8 @@ fn a_dropped_unwritten_fragment_input_is_absent_from_the_compiled_fragment() { /// A post-tessellation vertex function's and a mesh function's unwritten fragment input are /// answered as a vertex function's. Metal refuses with color 0 attached and makes without (on an M4 /// under macOS 27.0.1). Kept, the descriptors name the input and the link -/// refuses the pair; dropped, the tessellated compile reads it as zero (no input variable) and -/// links. A mesh pipeline's compile is the identity domains' typed refusal of its mesh function. +/// refuses the pair; dropped, the tessellated compile and the mesh compile each read it as zero +/// (no input variable) and link. #[test] fn tessellated_and_mesh_pipelines_answer_an_unwritten_fragment_input_as_a_vertex_function_s() { use crate::device::{Device, DeviceDescription}; @@ -777,11 +777,16 @@ fn tessellated_and_mesh_pipelines_answer_an_unwritten_fragment_input_as_a_vertex (false, other) => panic!("tessellated: {other:?}"), } if !attached { - match device.compile_mesh_pipeline(&meshed, &budget) { - Err(crate::error::Error::Unsupported(u)) => { - assert_eq!(u.feature, crate::error::Feature::IdentityDomains, "mesh"); - } - other => panic!("mesh: {:?}", other.map(|p| p.stages.len())), + let compiled = device + .compile_mesh_pipeline(&meshed, &budget) + .map(|p| p.stages.last().map(|s| s.spirv.clone())); + match compiled { + Ok(Some(spirv)) => assert_eq!( + input_locations(&spirv), + Vec::::new(), + "mesh: the absent input has a variable" + ), + other => panic!("mesh: {:?}", other.map(|s| s.map(|w| w.len()))), } } } diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index f5b6ac671..8882454ea 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -9726,7 +9726,6 @@ variant metal2vulkan::error::IdentityCause::ConstantBlob ConstantBlob variant metal2vulkan::error::IdentityCause::Descriptor Descriptor variant metal2vulkan::error::IdentityCause::EncoderValue EncoderValue variant metal2vulkan::error::IdentityCause::HeapResource HeapResource -variant metal2vulkan::error::IdentityCause::ObjectOrMeshStage ObjectOrMeshStage variant metal2vulkan::error::IdentityCause::SamplerState SamplerState variant metal2vulkan::error::IdentityCause::StorageTextureFormat StorageTextureFormat variant metal2vulkan::error::IdentityCause::TextureState TextureState diff --git a/docs/API.md b/docs/API.md index 86f5c2adc..773278287 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1544,7 +1544,7 @@ match floor.compile_function(&min_lod, &LoweringInputs::new(), &Budget::standard | Variant | Means | Retry | |---|---|---| -| `Unsupported` | The device cannot run this exactly. `feature` names the Metal feature, `needs` what would change it, and `cause`, where the feature covers more than one cause, the structure the translator met (`Cause::Access` names an access's: `AccessCause::PointerStore`, `AccessCause::UnderAligned`, ...; `Cause::Tessellation` a tessellation input's: `TessellationCause::UncountedPatch`, `TessellationCause::SimdGroup`, ...; `Cause::Imageblocks` an imageblock's: `ImageblockCause::TwoImageblocks`, `ImageblockCause::DataOperands`, ...; `Cause::Identity` the form the identity domains do not lower: `IdentityCause::ObjectOrMeshStage`, `IdentityCause::StorageTextureFormat`, ...); its `Display` prints the cause after the feature | No | +| `Unsupported` | The device cannot run this exactly. `feature` names the Metal feature, `needs` what would change it, and `cause`, where the feature covers more than one cause, the structure the translator met (`Cause::Access` names an access's: `AccessCause::PointerStore`, `AccessCause::UnderAligned`, ...; `Cause::Tessellation` a tessellation input's: `TessellationCause::UncountedPatch`, `TessellationCause::SimdGroup`, ...; `Cause::Imageblocks` an imageblock's: `ImageblockCause::TwoImageblocks`, `ImageblockCause::DataOperands`, ...; `Cause::Identity` the form the identity domains do not lower: `IdentityCause::StorageTextureFormat`, `IdentityCause::SamplerState`, ...); its `Display` prints the cause after the feature | No | | `NeedsInput` | The compile needs a pipeline input you did not supply | After supplying it | | `InvalidInput` | The AIR or container is malformed | No | | `InvalidDescriptor` | The descriptor is invalid as Metal would refuse it, or names a missing entry | No |