diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 19a3122b4..652e14e46 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -2540,6 +2540,12 @@ or does not check is rebuilt from the generations' names, with young counted ful -51726, -51757, -51772, -51839 and -51840. No tool translates every pipeline state of the recorded streams under the identity domains without a GPU, so the count is of these streams to these frames. +- A 64-bit texture atomic (`atomic_min` or `atomic_max` on a `ulong` texture), which Metal's + feature set tables give the Apple8 family and later ("GPU devices in the Apple8 family support + 64-bit atomic minimum and maximum using ulong, on both buffers and textures, only on macOS"), + is lowered to a 64-bit image atomic, which needs `shaderImageInt64Atomics`. Device creation + enables no 64-bit image atomic, so a state over a function that calls one is + `Error::Translation` of `Unsupported{ImageAtomics}`, needing that feature, on every device. - Every `VkPipeline` is made through the device's `VkPipelineCache` (The cache directory, above), which is empty on a host's first run. Cold, the driver's time for a recorded session's render pipelines made through it, against the same pipelines made past any cache (states-only plays): diff --git a/crates/metal2vulkan-validation/src/executor_contract.rs b/crates/metal2vulkan-validation/src/executor_contract.rs index 3d707e47a..400c66393 100644 --- a/crates/metal2vulkan-validation/src/executor_contract.rs +++ b/crates/metal2vulkan-validation/src/executor_contract.rs @@ -155,7 +155,8 @@ fn encoder_operation_is_executable(operation: crate::air::calls::CommandEncoderO } /// The requirements a module's `air.*` calls state by their names alone: an implicit imageblock -/// texture whose format no literal names, and an indirect command no executor encodes. +/// texture whose format no literal names, an indirect command no executor encodes, and a 64-bit +/// texture atomic, which the runtime refuses ([`calls_ulong_texture_atomic`]). pub fn unsupported_air_requirements( calls: &BTreeMap, ) -> BTreeSet { @@ -172,9 +173,26 @@ pub fn unsupported_air_requirements( }) { requirements.insert(ToolingRequirement::IndirectCommandBuffer); } + if calls_ulong_texture_atomic(calls) { + requirements.insert(ToolingRequirement::UlongTextureAtomic); + } requirements } +/// Whether the module calls an atomic on a Metal `ulong` texture (`atomic_min` or `atomic_max`, +/// the only ones Apple's compiler takes of one): a [`ulong_texture_calls`] call whose operation is +/// an atomic, which the translator lowers to a 64-bit image atomic +/// ([`ToolingRequirement::UlongTextureAtomic`]). +pub fn calls_ulong_texture_atomic(calls: &BTreeMap) -> bool { + use metal2vulkan_air::intrinsics::{AirIntrinsic, TexOp}; + ulong_texture_calls(calls).any(|name| { + matches!( + AirIntrinsic::parse(name), + Some(AirIntrinsic::Texture(texture)) if matches!(texture.op, TexOp::Atomic(_)) + ) + }) +} + /// The module's `air.*` texture operations on a Metal `ulong` texture: those the product's /// intrinsic table decodes with a 64-bit unsigned texel (`air::intrinsics::Texture::ulong`). A /// `ulong` texture that is only queried spells no texel, so no call names it. Descriptive: every @@ -2112,8 +2130,9 @@ mod tests { } /// Each texture operation on a `ulong` texel, in every shape the public fixtures spell, is a - /// `ulong` texture call, and no executor's gap. The same operations on a 32-bit texel are no - /// `ulong` texture call. + /// `ulong` texture call; a read or a write is no executor's gap, and an atomic is the runtime's + /// ([`ToolingRequirement::UlongTextureAtomic`]). The same operations on a 32-bit texel are no + /// `ulong` texture call and no gap. #[test] fn ulong_texture_operations_are_named_by_their_texel() { let fixtures = [ @@ -2136,12 +2155,18 @@ mod tests { .count() ); operations += ulong.len(); - assert!(unsupported_air_requirements(&calls).is_empty()); + let atomic = ulong.iter().any(|name| name.contains("atomic_")); + assert_eq!(calls_ulong_texture_atomic(&calls), atomic); + assert_eq!( + unsupported_air_requirements(&calls), + BTreeSet::from_iter(atomic.then_some(ToolingRequirement::UlongTextureAtomic)) + ); let narrow = calls .keys() .map(|name| (name.replace(".u.v4i64", ".u.v4i32"), 1)) .collect::>(); assert!(!calls_ulong_texture(&narrow)); + assert!(unsupported_air_requirements(&narrow).is_empty()); } // The distinct operations the two modules spell: reads, writes, and atomic minima and // maxima of the six shapes, the 2D ones at 32- and 16-bit coordinates. diff --git a/crates/metal2vulkan-validation/src/requirement.rs b/crates/metal2vulkan-validation/src/requirement.rs index 7597479e7..808861c4d 100644 --- a/crates/metal2vulkan-validation/src/requirement.rs +++ b/crates/metal2vulkan-validation/src/requirement.rs @@ -199,6 +199,17 @@ pub enum ToolingRequirement { /// source's structure, so no census row carries it. The Metal oracle draws it, so a case of it /// stays Metal-qualified ([`Self::qualifies_on_metal`]). IndexBufferPastEnd, + /// A 64-bit texture atomic its module calls (`executor_contract::unsupported_air_requirements`): + /// an `atomic_min` or `atomic_max` on a Metal `ulong` texture, an Apple8-family feature (Metal's + /// feature set tables: "GPU devices in the Apple8 family support 64-bit atomic minimum and + /// maximum using ulong, on both buffers and textures, only on macOS"). The translator lowers it + /// to a 64-bit image atomic, which needs `shaderImageInt64Atomics`, and the runtime enables no + /// 64-bit image atomic on any device (its floor's features), so it refuses the pipeline on + /// every device as `Unsupported{ImageAtomics}` needing that feature + /// (`device_capability_missing`), a known gap its README states, which is its guard: the limit + /// is the runtime's ([`Limit::Runtime`]) and the engine's candidate does not run the case. The + /// Metal oracle runs it, so a case of it stays Metal-qualified ([`Self::qualifies_on_metal`]). + UlongTextureAtomic, } /// Every executor (the requirement leaves no case to author, or none to observe). @@ -206,7 +217,7 @@ const AUTHORING: &[Executor] = &Executor::ALL; const ENGINE: &[Executor] = &[Executor::EngineCandidate]; impl ToolingRequirement { - pub const ALL: [Self; 28] = [ + pub const ALL: [Self; 29] = [ Self::FunctionConstantLiteral, Self::VertexAttributeLiteral, Self::TessellationAttributeLiteral, @@ -235,6 +246,7 @@ impl ToolingRequirement { Self::SeqCstFence, Self::RenderFunctionTable, Self::IndexBufferPastEnd, + Self::UlongTextureAtomic, ]; pub const fn as_str(self) -> &'static str { @@ -269,6 +281,7 @@ impl ToolingRequirement { Self::SeqCstFence => "seq_cst_fence", Self::RenderFunctionTable => "render_function_table", Self::IndexBufferPastEnd => "index_buffer_past_end", + Self::UlongTextureAtomic => "ulong_texture_atomic", } } @@ -290,9 +303,10 @@ impl ToolingRequirement { /// template it does not draw or replay ([`ToolingRequirement::MeshRenderPipeline`], /// [`ToolingRequirement::ReplayedTemplateResources`]), and a texture buffer an argument /// buffer or a texture-handle array holds ([`ToolingRequirement::TextureBufferMember`]), - /// and a sequentially consistent fence, a render function's function table and an indexed - /// draw past its index buffer, which the runtime refuses ([`ToolingRequirement::SeqCstFence`], - /// [`ToolingRequirement::RenderFunctionTable`], [`ToolingRequirement::IndexBufferPastEnd`]). + /// and a sequentially consistent fence, a render function's function table, an indexed draw + /// past its index buffer and a 64-bit texture atomic, which the runtime refuses + /// ([`ToolingRequirement::SeqCstFence`], [`ToolingRequirement::RenderFunctionTable`], + /// [`ToolingRequirement::IndexBufferPastEnd`], [`ToolingRequirement::UlongTextureAtomic`]). /// /// The requirements that stopped only the old engine's candidate were retired with it. pub const fn stops(self) -> &'static [Executor] { @@ -324,7 +338,8 @@ impl ToolingRequirement { | Self::ReplayedTemplateResources | Self::SeqCstFence | Self::RenderFunctionTable - | Self::IndexBufferPastEnd => ENGINE, + | Self::IndexBufferPastEnd + | Self::UlongTextureAtomic => ENGINE, } } @@ -334,7 +349,8 @@ impl ToolingRequirement { /// refuses it, typed. Only [`ToolingRequirement::MeshRenderPipeline`], /// [`ToolingRequirement::TextureBufferMember`], [`ToolingRequirement::DepthOutsideUnitRange`], /// [`ToolingRequirement::SeqCstFence`], [`ToolingRequirement::RenderFunctionTable`] and - /// [`ToolingRequirement::IndexBufferPastEnd`]: their cases are qualified on Metal. + /// [`ToolingRequirement::IndexBufferPastEnd`] and [`ToolingRequirement::UlongTextureAtomic`]: + /// their cases are qualified on Metal. pub const fn qualifies_on_metal(self) -> bool { matches!( self, @@ -344,6 +360,7 @@ impl ToolingRequirement { | Self::SeqCstFence | Self::RenderFunctionTable | Self::IndexBufferPastEnd + | Self::UlongTextureAtomic ) } @@ -351,8 +368,8 @@ impl ToolingRequirement { /// [`ToolingRequirement::KernelMinLodClamp`], which Apple's compiler cannot build a pipeline /// for, and [`ToolingRequirement::SeqCstFence`], [`ToolingRequirement::TextureBufferMember`], /// [`ToolingRequirement::DepthOutsideUnitRange`], [`ToolingRequirement::MeshRenderPipeline`], - /// [`ToolingRequirement::RenderFunctionTable`] and [`ToolingRequirement::IndexBufferPastEnd`], - /// which the runtime refuses. + /// [`ToolingRequirement::RenderFunctionTable`], [`ToolingRequirement::IndexBufferPastEnd`] and + /// [`ToolingRequirement::UlongTextureAtomic`], which the runtime refuses. pub const fn limit(self) -> Limit { match self { Self::KernelMinLodClamp => Limit::Metal, @@ -361,7 +378,8 @@ impl ToolingRequirement { | Self::DepthOutsideUnitRange | Self::MeshRenderPipeline | Self::RenderFunctionTable - | Self::IndexBufferPastEnd => Limit::Runtime, + | Self::IndexBufferPastEnd + | Self::UlongTextureAtomic => Limit::Runtime, _ => Limit::Tooling, } } @@ -515,7 +533,8 @@ mod tests { ToolingRequirement::MeshRenderPipeline, ToolingRequirement::SeqCstFence, ToolingRequirement::RenderFunctionTable, - ToolingRequirement::IndexBufferPastEnd + ToolingRequirement::IndexBufferPastEnd, + ToolingRequirement::UlongTextureAtomic ] ); } @@ -574,6 +593,19 @@ mod tests { assert_eq!("index_buffer_past_end".parse(), Ok(requirement)); } + /// A 64-bit texture atomic: the Metal oracle runs it, so its cases stay Metal-qualified; the + /// runtime enables no 64-bit image atomic, so the engine's candidate runs none, the runtime's + /// limit, which closes its rows. The retired `ulong_texture` name stays retired. + #[test] + fn a_ulong_texture_atomic_stops_only_the_candidate() { + let requirement = ToolingRequirement::UlongTextureAtomic; + assert_eq!(requirement.stops(), [Executor::EngineCandidate]); + assert_eq!(requirement.limit(), Limit::Runtime, "{requirement}"); + assert!(!requirement.blocks_closure(), "{requirement}"); + assert!(requirement.qualifies_on_metal(), "{requirement}"); + assert_eq!("ulong_texture_atomic".parse(), Ok(requirement)); + } + /// Every requirement stops some executor, and an executor's name is as stable as a /// requirement's. A requirement that stops the Metal oracle stops every executor: when Metal /// cannot run a case, no candidate has an observation to be compared with. Only a tooling gap @@ -623,7 +655,8 @@ mod tests { ToolingRequirement::MeshRenderPipeline, ToolingRequirement::SeqCstFence, ToolingRequirement::RenderFunctionTable, - ToolingRequirement::IndexBufferPastEnd + ToolingRequirement::IndexBufferPastEnd, + ToolingRequirement::UlongTextureAtomic ] ); for executor in Executor::ALL {