diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index ad7680dd1..e75f0743c 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -1977,8 +1977,8 @@ pub enum PartialThreadgroupsSite { max: u32, }, /// The translator refused the variant for another of the kernel's structures: SIMD groups it - /// emulates, a stage-in region, compute derivatives, an imageblock slice write every - /// invocation shares, or another refusal of the variant's lowering or compile. + /// emulates, compute derivatives, an imageblock slice write every invocation shares, or + /// another refusal of the variant's lowering or compile. Translator, /// The threadgroup is not whole SIMD groups of the variant, whose tier runs only whole ones. SimdGroups { diff --git a/crates/metal2vulkan/src/lower/mesh/mod.rs b/crates/metal2vulkan/src/lower/mesh/mod.rs index 1a7ed05e3..10c72f147 100644 --- a/crates/metal2vulkan/src/lower/mesh/mod.rs +++ b/crates/metal2vulkan/src/lower/mesh/mod.rs @@ -427,17 +427,18 @@ pub fn check_payload(cx: &SelectCx<'_>, size: u64) -> Result<(), Error> { /// past them return before the body where the body holds no workgroup barrier; where it holds /// one, the body is walked predicated from its threadgroup's threads /// (`simd::divergent::barriers`, `Predication::partial_groups`), so they walk to each barrier -/// without running anything else of it. A tile function, a kernel that reads a stage-input region, -/// one with compute derivatives (whose quads a returned lane would leave partial) and one with a -/// cooperative imageblock slice write (`texture::cooperative`, whose cells every invocation of the -/// workgroup shares) are refused the kernel's input, `Unsupported{PartialThreadgroups, NotImplemented}`. Called before -/// the push fields are placed. +/// without running anything else of it. A kernel's `[[stage_in]]` attributes are fetched at entry +/// after the returns, and a walked invocation's fetch reads a grid thread's element +/// (`lower::stage_io::stage_in`). A tile function, one with compute derivatives (whose quads a +/// returned lane would leave partial) and one with a cooperative imageblock slice write +/// (`texture::cooperative`, whose cells every invocation of the workgroup shares) are refused the +/// kernel's input, `Unsupported{PartialThreadgroups, NotImplemented}`. Called before the push +/// fields are placed. pub fn plan_partial_groups(cx: &mut SelectCx<'_>) -> Result<(), Error> { match cx.stage { Stage::Object => {} Stage::Kernel if cx.inputs.partial_threadgroups => { if crate::lower::access::tile::is_tile(cx) - || cx.inputs.stage_input.is_some() || cx.families.barrier.compute_derivatives || !cx.families.texture.cooperative.is_empty() { diff --git a/crates/metal2vulkan/src/lower/stage_io/stage_in.rs b/crates/metal2vulkan/src/lower/stage_io/stage_in.rs index 2bf299a78..5b4f74fe0 100644 --- a/crates/metal2vulkan/src/lower/stage_io/stage_in.rs +++ b/crates/metal2vulkan/src/lower/stage_io/stage_in.rs @@ -22,6 +22,13 @@ //! 0th thread), and so is a vertex or tessellation step in a compute layout //! (`StageInFetch::of`): Metal's compute pipeline creation stops at an assertion for one. //! +//! **A partial threadgroup** (`LoweringInputs::partial_threadgroups`, `lower::dispatch`'s partial +//! threadgroups) adds nothing to the fetch. An invocation past its threadgroup's threads returns in +//! `dispatch::emit_entry`, which runs before the fetch, or, where the body is walked predicated for +//! its barriers, fetches and runs none of the body: its position in the threadgroup is `lin` +//! unflattened over the threads left, so along x and y, the axes a step reads, it is a thread's of +//! the grid, and its element is one Metal's thread there fetches too. +//! //! **The stride** of a layout is its descriptor's, compiled in, whatever stride the encoder binds //! the buffer with: Metal reads a bound stride only for a layout of //! `MTLBufferLayoutStrideDynamic` (an M4 read a fixed 16 under a bound 8). diff --git a/crates/metal2vulkan/src/pipeline/lower_inputs.rs b/crates/metal2vulkan/src/pipeline/lower_inputs.rs index 6db83eab6..68f85edcf 100644 --- a/crates/metal2vulkan/src/pipeline/lower_inputs.rs +++ b/crates/metal2vulkan/src/pipeline/lower_inputs.rs @@ -393,8 +393,8 @@ pub struct LoweringInputs { /// its simdgroup operations run on the live lanes, Metal's partial simdgroup. Every lane read /// ballots its live lanes (`simd::partly_live`). It declares `MultiRegion` and reads the /// region whatever builtins it reads, and states `RuntimeFact::PartialThreadgroups`. A tile - /// function, a stage-input region, compute derivatives, an imageblock slice write every - /// invocation shares, emulated simdgroups (the input + /// function, compute derivatives, an imageblock slice write every invocation shares, emulated + /// simdgroups (the input /// `emulated_simdgroups` or a kernel whose lockstep order needs them), `flat_grid`, /// `folded_groups` and `replay_bindings` are `Unsupported{PartialThreadgroups, /// NotImplemented}`, and a body whose uniform barriers' vote word its workgroup memory cannot diff --git a/docs/API.md b/docs/API.md index 8aa58b44f..6a81e052a 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1254,8 +1254,8 @@ push constants, and each distinct specialization is one `VkPipeline`. A kernel's partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) runs a grid that is not whole threadgroups as the threadgroups its threads fill at the dispatch's threadgroup size, the last along an axis Metal's partial threadgroup, so every remainder takes the same `VkPipeline`; a -kernel the variant cannot run exactly (a tile function, a stage-input region, compute -derivatives, emulated simdgroups) is refused it, `Unsupported{PartialThreadgroups, +kernel the variant cannot run exactly (a tile function, compute derivatives, emulated +simdgroups) is refused it, `Unsupported{PartialThreadgroups, NotImplemented}`. On the identity domains the variant of a kernel that does not observe its threadgroup partition (`KernelFacts::partition_oblivious`) runs its grid in tiles instead (`RuntimeFact::GridTiles`): a direct dispatch's threads run in `pipeline::grid_tile`'s tiles, one