Runtime: a compute kernel that reaches an explicit imageblock gets its state; its dispatch is refused

A compute pipeline state whose kernel reaches an explicit imageblock was refused at its make as
Gap::KernelInput of KernelInputKind::RuntimeFact naming ImageblockSize, which every arm64 macOS
guest boot meets once. The state is now made, and what stays refused is the dispatch, where Metal
reads the extent setImageblockWidth:height: set, which the compute encoder does not have:

- interface() takes RuntimeFact::ImageblockSize, keeping its cell bytes as Interface::imageblock,
  and leaves SpecKey::ImageblockWidth and ImageblockHeight at the module's default (0 by 0)
  instead of refusing them as a specialization it does not set.
- encoder::decide, which the dispatch, prepare_dispatch, dispatch_variant and the main pipeline's
  key all go through, refuses a kernel with an imageblock first, as Gap::KernelInput of
  RuntimeFact naming the fact (RuntimeFact::name). So no VkPipeline of such a kernel is made:
  finish_pipeline has no main key, and a pre-pass gets no key. A dispatch of such a kernel that
  writes no memory records nothing and is not refused, as for any kernel without effects.
- imageblock_memory_length_for_dimensions keeps its typed answer, Gap::ImageblockLength, for a
  kernel that declares an imageblock: the one recording of Metal's answer for such a kernel
  (conformance pipeline-facts-compute-imageblock, M3 Max, 256 bytes at 8 by 4 by 3) settles no rule.

The translator is untouched. Gap and KernelInputKind keep their variants; the docs of
Gap::KernelInput, KernelInputKind::RuntimeFact and Specialization, Gap::ImageblockLength (and its
basis line), the dispatch and the state's make say where the refusal now is. docs/REFUSALS.md,
docs/METAL-COVERAGE.md (setImageblockWidth:height:'s note) and docs/CONFORMANCE-COVERAGE.md are
regenerated. The runtime README's state facts and its known gap are re-worded, with the counts and
jobs kept. The conformance ledger's pipeline-facts-compute-imageblock row moves from case/state to
the facts' label and device (the consumer's own, as for every state) and imageblock_memory_length
(Gap::ImageblockLength). Validation's KernelImageblock requirement doc and its acceptance test's doc
name the dispatch's refusal and the renamed device test.

Test: tests::kernel_input::an_explicit_imageblock_kernel_is_made_and_its_dispatch_refused_as_its_named_runtime_fact
(replacing an_explicit_imageblock_kernel_is_refused_as_its_named_runtime_fact) makes a4_imageblock_extent's
state, reads its imageblock length as Gap::ImageblockLength, gets no dispatch_variant key, and has
one 4 by 2 threadgroup's dispatch refused as Gap::KernelInput of RuntimeFact { fact: "ImageblockSize" }.
This commit is contained in:
Anees Iqbal committed 2026-11-22 20:15:34 -08:00
1 parent b2fb0993d7
commit da020e5d7b
13 files changed
+145 -76

No files matched your search

@@ -3351,6 +3351,8 @@ library-facts-one-function * refused case/facts/device Err(Unavailable({call: "d
# tile getters, fields the runtime's side refuses on every venue.
pipeline-facts-compute-plain * refused case/facts/device Err(Unavailable({call: "device"})) refused: the consumer's own (device). rt keeps no device on a pipeline state, so the state facts' device relation is a refused field and the state's other getters compare.
pipeline-facts-compute-plain * refused case/facts/label Err(Unavailable({call: "label"})) refused: the consumer's own (label). rt keeps no label on a pipeline state, so the state facts' label field is refused and the state's other getters compare.
pipeline-facts-compute-imageblock * refused case/facts/device Err(Unavailable({call: "device"})) refused: the consumer's own (device). rt keeps no device on a pipeline state, so the state facts' device relation is a refused field and the state's other getters compare.
pipeline-facts-compute-imageblock * refused case/facts/label Err(Unavailable({call: "label"})) refused: the consumer's own (label). rt keeps no label on a pipeline state, so the state facts' label field is refused and the state's other getters compare.
pipeline-facts-render-plain * refused case/facts/device Err(Unavailable({call: "device"})) refused: the consumer's own (device). rt keeps no device on a pipeline state, so the state facts' device relation is a refused field and the state's other getters compare.
pipeline-facts-render-plain * refused case/facts/label Err(Unavailable({call: "label"})) refused: the consumer's own (label). rt keeps no label on a pipeline state, so the state facts' label field is refused and the state's other getters compare.
pipeline-facts-render-plain * refused case/facts/max_total_threads_per_threadgroup Err(Unavailable({call: "maxTotalThreadsPerThreadgroup"})) refused: no stream uses it yet (libs census 11-19, m3-max-51379..51431: 0 tile pipelines). A tile getter of a drawing state: rt makes no tile render state, so it has no tile getters (its README, the render state's getters; tile functions are not built), and the field is refused while the state's other getters compare.
@@ -5997,7 +5999,7 @@ pass-start-barrier-over-buffer-read Iris(R) Xe refused case/pieces/1-renderComma
pass-start-barrier-over-buffer-sample llvmpipe refused case/pieces/1-renderCommandEncoder Err(Error::Unsupported("a draw with AttachmentRead is not built")) rt's own gap, not the device's: the pass reads, at its own pixels, its target, a texture over a buffer, and where the device's linear image lies at the buffer's pitch that texture is a linear image on the buffer's memory (rule 3's form), which rt gives no attachment read, neither the feedback usage nor a shadow (texture.rs: only an image a texture's own plan makes takes them), so the draw is Gap::Draw (AttachmentRead). Expected from the code and the venues' pattern, not shown by a counter: the 32-texel targets (128-byte rows) refuse on lavapipe and the Iris Xe and are read on the Radeon 780M, the 896-texel one (3,584-byte rows) refuses on all three, and the RTX 3090 reads both (53452, 53559).
pass-start-barrier-over-buffer-sample Iris(R) Xe refused case/pieces/1-renderCommandEncoder Err(Error::Unsupported("a draw with AttachmentRead is not built")) rt's own gap, not the device's: the pass reads, at its own pixels, its target, a texture over a buffer, and where the device's linear image lies at the buffer's pitch that texture is a linear image on the buffer's memory (rule 3's form), which rt gives no attachment read, neither the feedback usage nor a shadow (texture.rs: only an image a texture's own plan makes takes them), so the draw is Gap::Draw (AttachmentRead). Expected from the code and the venues' pattern, not shown by a counter: the 32-texel targets (128-byte rows) refuse on lavapipe and the Iris Xe and are read on the Radeon 780M, the 896-texel one (3,584-byte rows) refuses on all three, and the RTX 3090 reads both (53452, 53559).
pipeline-facts-compute-described * refused case/state Err(Error::Unsupported("indirect command buffers of ComputeCommands are not built")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every pipeline descriptor's supportIndirectCommandBuffers NO). Gap::IndirectCommandBuffers, IndirectCommandsKind::ComputeCommands: a compute pipeline state for indirect command buffers is refused on every device; compute commands are not built (the runtime README, Known gaps of indirect command buffers).
pipeline-facts-compute-imageblock * refused case/state Err(Error::Unsupported("the kernel reads an input the compute encoder does not supply yet: RuntimeFact { fact: \"ImageblockSize\" }")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no imageblock). rt refuses it (the kernel reads an input the compute encoder does not supply yet), and no replay stream asks it.
pipeline-facts-compute-imageblock * refused case/facts/imageblock_memory_length Err(Error::Unsupported("the state's imageblock length is not measured against Metal's")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no imageblock). Gap::ImageblockLength: rt makes the state of a kernel that reaches an explicit imageblock (its dispatch is Gap::KernelInput naming ImageblockSize), and Metal's rule for such a state's imageblockMemoryLengthForDimensions: is not measured: this recording answers one extent of one kernel, which settles no rule.
pipeline-functions-cleared * refused case/facts Err(Unavailable({call: "render_pipeline_functions_descriptor_facts"})) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no render pipeline functions descriptor and no binary function linking). The rt side of the suite answers `render_pipeline_functions_descriptor_facts` Unavailable: rt has no counterpart of the call, and no replay stream makes it.
pipeline-functions-emptied * refused case/facts Err(Unavailable({call: "render_pipeline_functions_descriptor_facts"})) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no render pipeline functions descriptor and no binary function linking). The rt side of the suite answers `render_pipeline_functions_descriptor_facts` Unavailable: rt has no counterpart of the call, and no replay stream makes it.
pipeline-functions-every-stage * refused case/facts Err(Unavailable({call: "render_pipeline_functions_descriptor_facts"})) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no render pipeline functions descriptor and no binary function linking). The rt side of the suite answers `render_pipeline_functions_descriptor_facts` Unavailable: rt has no counterpart of the call, and no replay stream makes it.
Can't render this file because it is too large.
+13 -10
View File
@@ -2855,10 +2855,10 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
(`thread_execution_width`), 32 on every device: a kernel that observes its SIMD group runs it 32
wide, and one that does not cannot tell its width. `imageblockMemoryLengthForDimensions:`
(`imageblock_memory_length_for_dimensions`) answers 0 for a kernel that declares no imageblock, as
Metal does. A kernel that reaches an imageblock has no state (`Gap::KernelInput` of
`KernelInputKind::RuntimeFact` naming `ImageblockSize`); one that declares an imageblock it never
reaches, or whose compile kept no reflection to tell, answers `Gap::ImageblockLength`, as no case
measures Metal's length. `requiredThreadsPerThreadgroup` (`required_threads_per_threadgroup`) is
Metal does; one that declares an imageblock, or whose compile kept no reflection to tell, answers
`Gap::ImageblockLength`: the one recording of Metal's answer for such a kernel
(`pipeline-facts-compute-imageblock`, 256 bytes at 8 by 4 by 3) settles no rule.
`requiredThreadsPerThreadgroup` (`required_threads_per_threadgroup`) is
the descriptor's size, `[0, 0, 0]` where it set none, as the M3 recordings
`pipeline-facts-compute-plain` and `pipeline-facts-compute-described` answer, and
`supportIndirectCommandBuffers` (`support_indirect_command_buffers`) is false: a descriptor that
@@ -3318,15 +3318,18 @@ cache is answered compile-required on both.
cold cache it compiles in that call, where Metal changes these with no compile: on a cold play,
`Metrics::first_use_waits` against `Metrics::made_ahead_variants` reads what the consumer's
pre-pass left to the encoding threads.
- A compute kernel with an explicit imageblock has no state (`Gap::KernelInput` of
`KernelInputKind::RuntimeFact` naming `ImageblockSize`). The Metal Shading Language specification
- A compute kernel with an explicit imageblock has a state, and its dispatch is refused
(`Gap::KernelInput` of `KernelInputKind::RuntimeFact` naming `ImageblockSize`): the extent a
dispatch runs is what `setImageblockWidth:height:` sets, and the compute encoder has no
counterpart for that call. Such a kernel that writes no memory records nothing, as any such
kernel's dispatch does. A pre-pass gets no key or pipeline of its dispatches (`dispatch_variant`,
`prepare_dispatch`), and `finish_pipeline` makes none. The Metal Shading Language specification
supports imageblocks on macOS for Apple silicon only (sections 5.6 and 6.14), so a device that
answers `supportsImageBlocks` NO gives a guest no imageblock to use. Over 34 recorded guest
streams, one of them an arm64 macOS 27 boot, two such kernels are made, no dispatch binds one, and
no stream calls `setImageblockWidth:height:`; the compute encoder has no counterpart for that
call. One recording, the M3's, makes 10 states refused as `Gap::KernelInput`, the count of its
explicit-imageblock makes; none is dispatched (jobs m3-max-58471, m3-max-58477, m3-max-58478 and
m3-max-58483, and m3-max-57983 for the count).
no stream calls `setImageblockWidth:height:`. One recording, the M3's, makes 10 states of
explicit-imageblock kernels and dispatches none (jobs m3-max-58471, m3-max-58477, m3-max-58478
and m3-max-58483, and m3-max-57983 for the count).
- An image-only kernel's first dispatch over a grid more than one deep at a tile no state of its
content has run makes that tile's `VkPipeline` on the calling thread, which waits for it
(`Metrics::first_use_waits`), through the device's pipeline cache. In each of the two recorded
+14 -4
View File
@@ -5,7 +5,7 @@ use crate::buffer::{Buffer, BufferInner, BufferObject};
use crate::command::{Building, CommandBuffer};
use crate::counters::Metric;
use crate::device::Core;
use crate::error::{Error, Gap, Limit, Refusal, StageInKind};
use crate::error::{Error, Gap, KernelInputKind, Limit, Refusal, StageInKind};
use crate::fence::Fence;
use crate::floor;
use crate::hazard::Access;
@@ -14,7 +14,7 @@ use crate::kept::{Handle, Lent, Uncounted};
use crate::memory::BlockId;
use crate::over::{self, Reached, Span};
use crate::pipeline::{
address_word, Compiled, ComputePipelineState, FieldValue, Form, Interface, Kernel, Place,
address_word, gap, Compiled, ComputePipelineState, FieldValue, Form, Interface, Kernel, Place,
Which, PUSH_STAGES, SQUARE,
};
use crate::record::Reach;
@@ -25,7 +25,8 @@ use ash::vk;
use metal2vulkan::metal::format::{integer_channels_word, BICUBIC_TEXELS_UNBOUND};
use metal2vulkan::metal::PixelFormat;
use metal2vulkan::pipeline::{
grid_tile, nonuniform_region_bytes, region_bytes, DEEP_THREADGROUP, GRID_TILE_THREADS,
grid_tile, nonuniform_region_bytes, region_bytes, RuntimeFact, DEEP_THREADGROUP,
GRID_TILE_THREADS,
};
use std::ops::BitOr;
use std::sync::Arc;
@@ -881,6 +882,9 @@ impl ComputeCommandEncoder {
/// alignment, which nothing records; [`Gap::SwizzledReadWrite`]; [`Gap::BicubicTexels`];
/// [`Limit::ThreadgroupMemory`]; [`Gap::PartialSimdgroups`] for a threadgroup that is not
/// whole SIMD groups of a kernel whose tier needs them and that has no emulated module;
/// [`Gap::KernelInput`] naming `RuntimeFact::ImageblockSize` for a kernel that reaches an
/// explicit imageblock and writes memory: its extent is what Metal's
/// `setImageblockWidth:height:` sets, which this encoder does not have;
/// [`Limit::MemoryAllocations`] where the parameter ring needs a block past the device's
/// allocation count; [`Error::Vulkan`] where the pipeline's compile, the ring or recording
/// fails.
@@ -1317,13 +1321,19 @@ pub(crate) fn size_checked(interface: &Interface, size: [u32; 3]) -> Result<(),
/// dispatch of it the variant takes. The variant is the state's module itself where its make
/// lowered no plain module beside it (`pipeline::Partial::Alone`). An indirect dispatch states no
/// grid in its region, so the variant runs it in the single-region form, every invocation live,
/// as the translator's dispatch regions say (`lower::dispatch`).
/// as the translator's dispatch regions say (`lower::dispatch`). A kernel that reaches an
/// explicit imageblock runs nothing: its extent is `setImageblockWidth:height:`'s, which the
/// encoder does not have ([`Gap::KernelInput`] naming `RuntimeFact::ImageblockSize`).
pub(crate) fn decide<'a>(
compiled: &'a Compiled,
direct: Option<Direct>,
size: [u32; 3],
(set, max): (&[(u32, u32)], u32),
) -> Result<(Choice, Module, &'a Kernel), Error> {
if let Some(cell_bytes) = compiled.whole.interface.imageblock {
let fact = RuntimeFact::ImageblockSize { cell_bytes }.name();
return Err(gap(KernelInputKind::RuntimeFact { fact }));
}
let choice = choose(&compiled.form, direct, size);
let partial_threadgroups = || {
Error::Unsupported(Gap::PartialThreadgroups {
+20 -16
View File
@@ -1076,7 +1076,10 @@ pub enum Gap {
/// `[[stage_in]]` attributes of a fixed layout stride and a pinned subgroup size are supplied.
/// Metal's counterpart is the compute pipeline state's make
/// (`newComputePipelineStateWithDescriptor:options:reflection:error:` and its siblings), which
/// makes each.
/// makes each. An explicit imageblock's extent is refused at the dispatch instead
/// (`dispatchThreadgroups:threadsPerThreadgroup:` and its siblings), the state being made:
/// Metal's dispatch runs the extent `setImageblockWidth:height:` set, which the encoder does
/// not have.
///
/// Basis: ours (the encoder supplies only those).
KernelInput {
@@ -1097,14 +1100,15 @@ pub enum Gap {
/// The form, named where the runtime found it.
kind: StageInKind,
},
/// An imageblock length Metal answers that no case measures: a compute state's
/// `imageblockMemoryLengthForDimensions:` where its kernel declares an imageblock it never
/// reaches, or its compile kept no reflection to tell whether it declares one (a kernel that
/// declares none answers 0, as Metal's does); a render state's `imageblockSampleLength` and
/// An imageblock length Metal answers by a rule no case measures: a compute state's
/// `imageblockMemoryLengthForDimensions:` where its kernel declares an imageblock (one
/// recording answers one extent of one kernel, which settles no rule), or its
/// compile kept no reflection to tell whether it declares one (a kernel that declares none
/// answers 0, as Metal's does); a render state's `imageblockSampleLength` and
/// `imageblockMemoryLengthForDimensions:` where a color format has no measured place in
/// Metal's record of a pixel's colors.
///
/// Basis: ours (the length is not measured against Metal's).
/// Basis: ours (no case measures Metal's rule for the length).
ImageblockLength,
/// A dispatch whose threadgroup is not whole SIMD groups of a kernel whose tier runs each SIMD
/// group as one subgroup of `width` threads (a pinned subgroup of 32, or the device's own
@@ -1662,10 +1666,11 @@ pub enum KernelInputKind {
/// counterpart: it states no subgroup control.
StageFlags,
/// A fact of the module the encoder does not supply: a `RuntimeFact` the runtime does not
/// name, such as an explicit imageblock's size (`RuntimeFact::ImageblockSize`), a resource's
/// presence or a sampler's coordinates, or an address alignment of a slot that is not a
/// kernel's buffer or that is not a power of two. Metal's counterpart is the dispatch's state
/// the fact stands for: `setImageblockWidth:height:`, or the bound resource's own state.
/// name, such as a resource's presence or a sampler's coordinates, or an address alignment of
/// a slot that is not a kernel's buffer or that is not a power of two, at the state's make;
/// an explicit imageblock's size (`RuntimeFact::ImageblockSize`) at a dispatch of the state.
/// Metal's counterpart is the dispatch's state the fact stands for:
/// `setImageblockWidth:height:`, or the bound resource's own state.
RuntimeFact {
/// The fact's name (`RuntimeFact::name`), such as `"ImageblockSize"`.
fact: &'static str,
@@ -1691,12 +1696,11 @@ pub enum KernelInputKind {
/// (`DeviceProfile::push_window`, its `maxPushConstantsSize` up to 256 bytes). Metal's
/// counterpart is the kernel's arguments, which Metal binds however many there are.
PushBytes,
/// A specialization constant the runtime does not set: an explicit imageblock's width or
/// height, a sampler state's fields, a constant that is not 4 bytes, the threadgroup memory
/// length of an argument the kernel does not take, or a kernel's threadgroup memory lengths
/// past the 31 indices `setThreadgroupMemoryLength:atIndex:` sets. Metal's counterpart is the
/// state the constant stands for: `setImageblockWidth:height:`, a sampler state's descriptor,
/// or `setThreadgroupMemoryLength:atIndex:`.
/// A specialization constant the runtime does not set: a sampler state's fields, a constant
/// that is not 4 bytes, the threadgroup memory length of an argument the kernel does not take,
/// or a kernel's threadgroup memory lengths past the 31 indices
/// `setThreadgroupMemoryLength:atIndex:` sets. Metal's counterpart is the state the constant
/// stands for: a sampler state's descriptor, or `setThreadgroupMemoryLength:atIndex:`.
Specialization,
/// A workgroup the module fixes in a shape the runtime does not run: a subgroup multiple
/// outside a flattened local size (a compute-derivative group), or a module that neither
+36 -21
View File
@@ -612,6 +612,11 @@ pub(crate) struct Interface {
/// (`RuntimeFact::PrivateArena`), where its private memory passes the translator's floor: a
/// dispatch of it takes the runtime's arena (`crate::arena`, [`FieldValue::PrivateArena`]).
pub(crate) private_arena: Option<u32>,
/// The bytes of each cell of the kernel's explicit imageblock (`RuntimeFact::ImageblockSize`),
/// where it reaches one. Its extent is what `setImageblockWidth:height:` sets, which the
/// encoder does not have: the state is made, and its dispatches are refused
/// (`encoder::decide`).
pub(crate) imageblock: Option<u32>,
/// The kernel's specialization constants: each one's id and what sets it.
pub(crate) constants: Vec<(u32, Constant)>,
/// The index of each threadgroup memory argument the kernel takes, in the order of
@@ -883,10 +888,12 @@ impl crate::Device {
/// Err: [`Error::Translation`], the translator's typed refusal or a descriptor Metal refuses,
/// naming the kernel; [`Gap::IndirectCommandBuffers`] of
/// [`IndirectCommandsKind::ComputeCommands`] for a descriptor that sets
/// `supportIndirectCommandBuffers`; [`Gap::KernelInput`] for a kernel that
/// reads what the compute encoder does not supply yet; [`Gap::StageIn`] for a `[[stage_in]]`
/// attribute the kernel reads through a layout of a dynamic stride
/// ([`StageInKind::DynamicStride`]) or of an indexed step at a step rate past 1
/// `supportIndirectCommandBuffers`; [`Gap::KernelInput`] for a kernel that reads what the
/// compute encoder does not supply yet, but for an explicit imageblock's extent: a kernel that
/// reaches one is made, and its dispatches are refused
/// ([`ComputeCommandEncoder::dispatch_threadgroups`](crate::ComputeCommandEncoder::dispatch_threadgroups));
/// [`Gap::StageIn`] for a `[[stage_in]]` attribute the kernel reads through a layout of a
/// dynamic stride ([`StageInKind::DynamicStride`]) or of an indexed step at a step rate past 1
/// ([`StageInKind::IndexedStepRate`]); [`Refusal::SamplerIds`] where
/// `sampler_ids` answers another count; [`Refusal::IndicesNotGranted`] for a constexpr
/// sampler's index; [`Limit::DeviceSamplers`](crate::Limit::DeviceSamplers);
@@ -1149,7 +1156,8 @@ impl Compiled {
/// partial-threadgroups variant's, which runs whole grids, ragged and indirect ones alike, or
/// the whole module's where the content has no such variant or the variant's threadgroup
/// memory, a predicated walk's vote word with it, is past the device's (`encoder::decide`);
/// none where the module takes a threadgroup memory length from the encoder.
/// none where the module takes a threadgroup memory length from the encoder, or where
/// `encoder::decide` refuses the dispatch (a kernel's explicit imageblock).
fn main_key(&self, descriptor: &ComputePipelineDescriptor) -> Option<DispatchVariant> {
let (module, size) = match &self.form {
Form::Tiled => (Module::Tiles, [GRID_TILE_THREADS, 1, 1]),
@@ -1480,6 +1488,7 @@ pub(crate) fn interface(
let mut aligned = Vec::new();
let mut vote = 0;
let mut private_arena = None;
let mut imageblock = None;
let mut own = OwnMemory::Static(pipeline.metal_info.static_threadgroup_memory_length);
for dependency in &pipeline.dependencies {
match dependency.fact {
@@ -1499,6 +1508,8 @@ pub(crate) fn interface(
// Each invocation's slot of the private arena, which the encoder places
// (`FieldValue::PrivateArena`).
RuntimeFact::PrivateArena { slot_bytes } => private_arena = Some(slot_bytes),
// The explicit imageblock's extent, which no dispatch supplies.
RuntimeFact::ImageblockSize { cell_bytes } => imageblock = Some(cell_bytes),
// The emulated tier's arena and scratch, in place of Metal's static part.
RuntimeFact::SimdgroupEmulation {
bytes_per_simdgroup,
@@ -1701,6 +1712,9 @@ pub(crate) fn interface(
// (true) for every dispatch: one pipeline, whose fetch reads an element past the first
// 2^32 bytes from its bind offset as zero.
SpecKey::StageInReach => continue,
// The explicit imageblock's extent, kept at the module's default (0 by 0): no
// dispatch runs a module that reaches an imageblock (`encoder::decide`).
SpecKey::ImageblockWidth | SpecKey::ImageblockHeight => continue,
_ => return Err(KernelInputKind::Specialization),
};
constants.push((constant.id, set));
@@ -1747,6 +1761,7 @@ pub(crate) fn interface(
stage_in_region: (fields.iter())
.any(|field| matches!(field.value, FieldValue::StageInRegion)),
private_arena,
imageblock,
fields,
constants,
threadgroups,
@@ -1760,7 +1775,7 @@ pub(crate) fn interface(
}
/// The refusal of a kernel that reads what the compute encoder does not supply, of `kind`.
fn gap(kind: KernelInputKind) -> Error {
pub(crate) fn gap(kind: KernelInputKind) -> Error {
Error::Unsupported(Gap::KernelInput { kind })
}
@@ -1890,11 +1905,11 @@ impl ComputePipelineState {
/// of the dispatch's module, workgroup size, threadgroup memory lengths and grid tiles. It
/// returns at once where that is made, or another thread is making it: a dispatch that needs
/// it then waits for that thread alone. It makes nothing where the dispatch would refuse its
/// threadgroup size, its variant or its threadgroup memory, or records nothing (a grid with no
/// threads, a kernel that writes no memory), and it reports no other error than a kernel's past
/// the stage bound: every other is the dispatch's own. What the dispatch checks of the
/// encoder's bindings is not checked here. A make that failed is made again by the next call
/// or dispatch that needs it.
/// threadgroup size, its variant, its threadgroup memory or its kernel's explicit imageblock,
/// or records nothing (a grid with no threads, a kernel that writes no memory), and it reports
/// no other error than a kernel's past the stage bound: every other is the dispatch's own.
/// What the dispatch checks of the encoder's bindings is not checked here. A make that failed
/// is made again by the next call or dispatch that needs it.
///
/// Counted as [`Metrics::made_ahead_variants`](crate::Metrics::made_ahead_variants).
///
@@ -1940,10 +1955,10 @@ impl ComputePipelineState {
/// reads false until its [`finish_pipeline`](Self::finish_pipeline), a `prepare_dispatch`
/// call or a dispatch has made it. The key does not move.
///
/// None where the dispatch would refuse its threadgroup size, its variant or its threadgroup
/// memory, or records nothing (a grid with no threads, a kernel that writes no memory): where
/// `prepare_dispatch` makes nothing whatever was made before. It makes nothing and allocates
/// nothing where it answers a key.
/// None where the dispatch would refuse its threadgroup size, its variant, its threadgroup
/// memory or its kernel's explicit imageblock, or records nothing (a grid with no threads, a
/// kernel that writes no memory): where `prepare_dispatch` makes nothing whatever was made
/// before. It makes nothing and allocates nothing where it answers a key.
pub fn dispatch_variant(
&self,
dispatch: Dispatch,
@@ -1983,11 +1998,11 @@ impl ComputePipelineState {
}
/// `imageblockMemoryLengthForDimensions:`: 0 for a kernel that declares no imageblock, as
/// Metal answers, whatever the dimensions. A kernel that reaches an imageblock has no state
/// here ([`Gap::KernelInput`]).
/// Metal answers, whatever the dimensions.
///
/// Err: [`Gap::ImageblockLength`] for a kernel that declares an imageblock it never reaches,
/// or whose compile kept no reflection to tell: its length is not measured against Metal's.
/// Err: [`Gap::ImageblockLength`] for a kernel that declares an imageblock, or whose compile
/// kept no reflection to tell: Metal's rule for its length is not measured (the conformance
/// recording `pipeline-facts-compute-imageblock` answers one extent of one kernel).
pub fn imageblock_memory_length_for_dimensions(
&self,
_dimensions: [u32; 3],
@@ -2212,8 +2227,8 @@ impl Compiled {
/// What a dispatch of `dispatch` at threadgroup size `size`, with the encoder's threadgroup
/// memory lengths `set`, runs, decided as the dispatch decides it: its kernel, its module, its
/// workgroup size and its kernel's threadgroup memory lengths. None where the dispatch refuses
/// its threadgroup size, its variant or its threadgroup memory, or records nothing (a grid
/// with no threads, a kernel that writes no memory).
/// its threadgroup size, its variant, its threadgroup memory or its kernel's explicit
/// imageblock, or records nothing (a grid with no threads, a kernel that writes no memory).
fn dispatched(
&self,
dispatch: Dispatch,
@@ -54,6 +54,7 @@ pub(crate) mod on_device {
fields,
stage_in_region: false,
private_arena: None,
imageblock: None,
constants: vec![
(0, Constant::Size(0)),
(1, Constant::Size(1)),
@@ -1,5 +1,6 @@
//! A kernel that reads what the compute encoder does not supply is refused at its state's make
//! as `Gap::KernelInput` of the kind the runtime found, and the refusal's text names that kind:
//! as `Gap::KernelInput` of the kind the runtime found, and the refusal's text names that kind,
//! but for an explicit imageblock's extent, whose state is made and whose dispatch is refused:
//! one test per kind an engine fixture's kernel meets on lavapipe. No engine fixture's kernel
//! meets the other kinds there.
@@ -7,7 +8,7 @@
mod on_device {
use crate::tests::command::on_device::each_device;
use crate::{ComputePipelineDescriptor, Error, FunctionDescriptor, Gap, KernelInputKind};
use crate::{NumberedSampler, StageSource};
use crate::{Dispatch, DispatchType, NumberedSampler, StageSource};
use metal2vulkan::library::Library;
use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError};
@@ -54,19 +55,48 @@ mod on_device {
/// `a4_imageblock_extent`, a kernel over an explicit imageblock: its module states the
/// imageblock's size as a runtime fact, which the encoder does not supply (it has no
/// `setImageblockWidth:height:`), and the refusal names that fact.
/// `setImageblockWidth:height:`). Its state is made, its imageblock length the typed gap; a
/// pre-pass gets no key of its dispatch, and the dispatch, one threadgroup of the kernel's 4 by
/// 2, is refused naming that fact.
#[test]
fn an_explicit_imageblock_kernel_is_refused_as_its_named_runtime_fact() {
fn an_explicit_imageblock_kernel_is_made_and_its_dispatch_refused_as_its_named_runtime_fact() {
let Some(descriptor) = descriptor_of("a4_imageblock_extent", "a4_imageblock_extent") else {
return;
};
refused_as(
"kernel_input_imageblock",
&descriptor,
KernelInputKind::RuntimeFact {
fact: "ImageblockSize",
},
);
let kind = KernelInputKind::RuntimeFact {
fact: "ImageblockSize",
};
let (groups, threads) = ([1, 1, 1], [4, 2, 1]);
each_device("kernel_input_imageblock", |name, _, device| {
let state = (device.new_compute_pipeline_state(&descriptor, sampler_ids))
.unwrap_or_else(|error| panic!("{name}: no state: {error}"));
let length = state.imageblock_memory_length_for_dimensions([8, 4, 3]);
assert!(
matches!(length, Err(Error::Unsupported(Gap::ImageblockLength))),
"{name}: the imageblock length {length:?}"
);
let dispatch = Dispatch::Threadgroups(groups);
let key = state.dispatch_variant(dispatch, threads, &[]);
assert!(key.is_none(), "{name}: a pre-pass key {key:?}");
let queue = device.new_command_queue(1).expect("a queue");
let command_buffer = queue.command_buffer().expect("a command buffer");
let mut encoder =
(command_buffer.compute_command_encoder(DispatchType::Serial)).expect("an encoder");
encoder
.set_compute_pipeline_state(&state)
.expect("the state");
match encoder.dispatch_threadgroups(groups, threads) {
Err(Error::Unsupported(Gap::KernelInput { kind: found })) => {
assert_eq!(found, kind, "{name}: the kind the dispatch found")
}
Ok(()) => panic!("{name}: a dispatch, where the encoder sets no imageblock extent"),
Err(error) => panic!("{name}: {error}, not Gap::KernelInput of {kind:?}"),
}
encoder.end_encoding();
println!(
"{name}: the imageblock kernel's state made, its dispatch refused as {kind:?}"
);
});
}
/// `visible_table_dispatch`, a kernel that takes a visible function table at buffer 1: a slot
@@ -141,8 +141,9 @@ fn a_full_subgroup_kernel_row_is_made_through_the_runtime() {
}
}
/// A kernel with an explicit imageblock is the runtime's typed refusal, as a guest's is: its
/// compute encoder does not set an imageblock's extent (`setImageblockWidth:height:`).
/// A kernel with an explicit imageblock is the runtime's typed refusal at its dispatch, as a
/// guest's is: its compute encoder does not set an imageblock's extent
/// (`setImageblockWidth:height:`).
#[cfg(target_os = "linux")]
#[test]
fn an_imageblock_kernel_row_is_the_runtimes_refusal() {
@@ -209,10 +209,11 @@ pub enum ToolingRequirement {
KernelFunctionTable,
/// A compute kernel's explicit imageblock (`executor_contract::case_requirements`), a tile
/// pass's tile size included. The runtime's compute encoder has no
/// `setImageblockWidth:height:`, and its make of a pipeline state that reaches an imageblock is
/// `metal2vulkan_runtime::Gap::KernelInput` of `KernelInputKind::RuntimeFact` naming
/// `ImageblockSize`, held on lavapipe by the runtime's device test
/// `tests::kernel_input::an_explicit_imageblock_kernel_is_refused_as_its_named_runtime_fact`;
/// `setImageblockWidth:height:`: it makes the pipeline state of a kernel that reaches an
/// imageblock, and refuses its dispatch as `metal2vulkan_runtime::Gap::KernelInput` of
/// `KernelInputKind::RuntimeFact` naming `ImageblockSize`, held on lavapipe by the runtime's
/// device test in `tests::kernel_input`
/// `an_explicit_imageblock_kernel_is_made_and_its_dispatch_refused_as_its_named_runtime_fact`;
/// it builds no tile function. Both are known gaps its README states.
KernelImageblock,
/// A fragment function's imageblock, the case's cells of it
+6 -4
View File
@@ -42,7 +42,7 @@ Its limits, measured rather than asserted:
| committed recordings | 1325 |
| distinct SDK items the Metal leg reaches, of any status | 808 |
| of those, reached only where this cannot name the family | 5 |
| ledger rows (a case whose gap is recorded) | 7988 |
| ledger rows (a case whose gap is recorded) | 7990 |
| declared crossings of the option space (pairs put to Metal at once) | 26 |
| declared crossings that are no pair of it (a boolean or numeric field, or one type in two slots) | 30 |
@@ -2053,8 +2053,8 @@ A facts call answers many getters at once, and a side answers or refuses each of
| `ComputeDescriptorFacts` | 11 | 2 | `label`: `label`, 3 (3), 3; `binary_archives`: `binary_archives`, 3 (3), 3 |
| `FunctionFacts` | 9 | 2 | `options`: `options`, 22 (22), 22; `device_is_the_cases`: `device`, 24 (24), 24 |
| `LibraryFacts` | 4 | 1 | `device_is_the_cases`: `device`, 9 (9), 9 |
| `ComputeStateFacts` | 6 | 3 | `label`: `label`, 7 (7), 7; `device_is_the_cases`: `device`, 7 (7), 7; `imageblock_memory_length`: `imageblock_memory_length`, 0 (0), 0 |
| `RenderStateFacts` | 8 | 5 | `label`: `label`, 7 (7), 7; `device_is_the_cases`: `device`, 7 (7), 7; `max_total_threads_per_threadgroup`: `max_total_threads_per_threadgroup`, 6 (6), 6; `threadgroup_size_matches_tile_size`: `threadgroup_size_matches_tile_size`, 6 (6), 6; `required_threads_per_tile_threadgroup`: `required_threads_per_tile_threadgroup`, 6 (6), 6 |
| `ComputeStateFacts` | 6 | 3 | `label`: `label`, 8 (8), 8; `device_is_the_cases`: `device`, 8 (8), 8; `imageblock_memory_length`: `imageblock_memory_length`, 0 (0), 0 |
| `RenderStateFacts` | 8 | 5 | `label`: `label`, 8 (8), 8; `device_is_the_cases`: `device`, 8 (8), 8; `max_total_threads_per_threadgroup`: `max_total_threads_per_threadgroup`, 6 (6), 6; `threadgroup_size_matches_tile_size`: `threadgroup_size_matches_tile_size`, 6 (6), 6; `required_threads_per_tile_threadgroup`: `required_threads_per_tile_threadgroup`, 6 (6), 6 |
| `RenderDescriptorFacts` | 30 | 2 | `label`: `label`, 3 (3), 3; `binary_archives`: `binary_archives`, 3 (3), 3 |
| `EventRise` | 7 | 1 | `label`: `label`, 1 (1), 1 |
@@ -5383,6 +5383,8 @@ A case whose difference from Metal is recorded rather than compared away. The le
| `library-facts-one-function` | refused: the consumer's own (device). The runtime's library and its functions are the translator's, which keep no device, so the device relation is a refused fi… |
| `pipeline-facts-compute-plain` | refused: the consumer's own (device). rt keeps no device on a pipeline state, so the state facts' device relation is a refused field and the state's other gette… |
| `pipeline-facts-compute-plain` | refused: the consumer's own (label). rt keeps no label on a pipeline state, so the state facts' label field is refused and the state's other getters compare. |
| `pipeline-facts-compute-imageblock` | refused: the consumer's own (device). rt keeps no device on a pipeline state, so the state facts' device relation is a refused field and the state's other gette… |
| `pipeline-facts-compute-imageblock` | refused: the consumer's own (label). rt keeps no label on a pipeline state, so the state facts' label field is refused and the state's other getters compare. |
| `pipeline-facts-render-plain` | refused: the consumer's own (device). rt keeps no device on a pipeline state, so the state facts' device relation is a refused field and the state's other gette… |
| `pipeline-facts-render-plain` | refused: the consumer's own (label). rt keeps no label on a pipeline state, so the state facts' label field is refused and the state's other getters compare. |
| `pipeline-facts-render-plain` | refused: no stream uses it yet (libs census 11-19, m3-max-51379..51431: 0 tile pipelines). A tile getter of a drawing state: rt makes no tile render state, so i… |
@@ -8006,7 +8008,7 @@ A case whose difference from Metal is recorded rather than compared away. The le
| `pass-start-barrier-over-buffer-sample` | rt's own gap, not the device's: the pass reads, at its own pixels, its target, a texture over a buffer, and where the device's linear image lies at the buffer's… |
| `pass-start-barrier-over-buffer-sample` | rt's own gap, not the device's: the pass reads, at its own pixels, its target, a texture over a buffer, and where the device's linear image lies at the buffer's… |
| `pipeline-facts-compute-described` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every pipeline descriptor's supportIndirectComma… |
| `pipeline-facts-compute-imageblock` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no imageblock). rt refuses it (the kernel reads … |
| `pipeline-facts-compute-imageblock` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no imageblock). Gap::ImageblockLength: rt makes … |
| `pipeline-functions-cleared` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no render pipeline functions descriptor and no b… |
| `pipeline-functions-emptied` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no render pipeline functions descriptor and no b… |
| `pipeline-functions-every-stage` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no render pipeline functions descriptor and no b… |
+1 -1
View File
@@ -1243,7 +1243,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app
| `MTLComputeCommandEncoder.setSamplerState:lodMinClamp:lodMaxClamp:atIndex:` | method | implemented | `ComputeCommandEncoder::set_sampler_state` (runtime) |
| `MTLComputeCommandEncoder.setSamplerStates:lodMinClamps:lodMaxClamps:withRange:` | method | implemented | `ComputeCommandEncoder::set_sampler_state_with_lod_clamps` (runtime): a loop of it |
| `MTLComputeCommandEncoder.setThreadgroupMemoryLength:atIndex:` | method | implemented | `ComputeCommandEncoder::set_threadgroup_memory_length` (runtime) |
| `MTLComputeCommandEncoder.setImageblockWidth:height:` | method | missing | M: explicit imageblocks; a kernel that declares one is refused (`Gap::KernelInput`) |
| `MTLComputeCommandEncoder.setImageblockWidth:height:` | method | missing | M: explicit imageblocks; a kernel that reaches one is made and its dispatch refused (`Gap::KernelInput`) |
| `MTLComputeCommandEncoder.setStageInRegion:` | method | implemented | `ComputeCommandEncoder::set_stage_in_region` (runtime) |
| `MTLComputeCommandEncoder.setStageInRegionWithIndirectBuffer:indirectBufferOffset:` | method | implemented | `ComputeCommandEncoder::set_stage_in_region_with_indirect_buffer` (runtime): always refused: a stage-in region the GPU reads is not built (`Gap::StageIn`) |
| `MTLComputeCommandEncoder.dispatchThreadgroups:threadsPerThreadgroup:` | method | implemented | `ComputeCommandEncoder::dispatch_threadgroups` (runtime) |
+1 -1
View File
@@ -338,7 +338,7 @@ Columns:
| `IndirectCommandBuffers` | An indirect command buffer, its execution, or a compute pipeline state for one, of what the runtime does not build, `kind` naming it | every device (a public call's own check of its arguments) | `ours`: the first cut of indirect command buffers builds that alone | 5: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`, `crates/metal2vulkan-runtime/src/indirect.rs (shape)` (+3) | `-` |
| `KernelInput` | A kernel that reads something the compute encoder does not supply yet, `kind` naming what | every device (a public call's own check of its arguments) | `ours`: the encoder supplies only those | 1: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)` | `-` |
| `StageIn` | A form of a kernel's `[[stage_in]]` that is not built, `kind` naming which | every device (a public call's own check of its arguments) | `ours`: no replay stream makes a compute state with a stage-input descriptor or sets a stage-in region indirectly; what Metal reads at an indexed step's rate past 1 is not measured | 2: `crates/metal2vulkan-runtime/src/encoder.rs (set_stage_in_region_with_indirect_buffer)`, `crates/metal2vulkan-runtime/src/pipeline.rs (of)` | `-` |
| `ImageblockLength` | An imageblock length Metal answers that no case measures | every device (a public call's own check of its arguments) | `ours`: the length is not measured against Metal's | 2: `crates/metal2vulkan-runtime/src/pipeline.rs (imageblock_memory_length_for_dimensions)`, `crates/metal2vulkan-runtime/src/render.rs (imageblock_sample_length)` | `-` |
| `ImageblockLength` | An imageblock length Metal answers by a rule no case measures | every device (a public call's own check of its arguments) | `ours`: no case measures Metal's rule for the length | 2: `crates/metal2vulkan-runtime/src/pipeline.rs (imageblock_memory_length_for_dimensions)`, `crates/metal2vulkan-runtime/src/render.rs (imageblock_sample_length)` | `-` |
| `PartialSimdgroups` | A dispatch whose threadgroup is not whole SIMD groups of a kernel whose tier runs each SIMD group as one subgroup of `width` threads (a pinned... | every device (a public call's own check of its arguments) | `ours`: no emulated-SIMD-group module | 1: `crates/metal2vulkan-runtime/src/encoder.rs (decide)` | `-` |
| `PartialThreadgroups` | `dispatchThreads` with a grid that is not a whole number of threadgroups on some axis, of a kernel that observes its threadgroup partition and... | every device (a public call's own check of its arguments) | `ours`: the translator's partial-threadgroups variant does not take the emulated SIMD-group tier, nor a vote word past the workgroup memory | 1: `crates/metal2vulkan-runtime/src/encoder.rs (decide)` | `-` |
| `NoStageInRegion` | A dispatch of a kernel that reads the stage-in region (`[[grid_origin]]`, `[[grid_size]]`, a `[[stage_in]]` attribute of a thread-position step)... | every device (a public call's own check of its arguments) | `ours`: no replay stream dispatches such a kernel without setting a region | 1: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)` | `-` |
+1 -1
View File
@@ -932,7 +932,7 @@ MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setSamplerStates:with
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setSamplerState:lodMinClamp:lodMaxClamp:atIndex: I runtime ComputeCommandEncoder::set_sampler_state
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setSamplerStates:lodMinClamps:lodMaxClamps:withRange: I runtime ComputeCommandEncoder::set_sampler_state_with_lod_clamps a loop of it
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setThreadgroupMemoryLength:atIndex: I runtime ComputeCommandEncoder::set_threadgroup_memory_length
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setImageblockWidth:height: M explicit imageblocks; a kernel that declares one is refused (`Gap::KernelInput`) M encoder-calls
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setImageblockWidth:height: M explicit imageblocks; a kernel that reaches one is made and its dispatch refused (`Gap::KernelInput`) M encoder-calls
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setStageInRegion: I runtime ComputeCommandEncoder::set_stage_in_region
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setStageInRegionWithIndirectBuffer:indirectBufferOffset: I runtime ComputeCommandEncoder::set_stage_in_region_with_indirect_buffer always refused: a stage-in region the GPU reads is not built (`Gap::StageIn`)
MTLComputeCommandEncoder.h MTLComputeCommandEncoder method dispatchThreadgroups:threadsPerThreadgroup: I runtime ComputeCommandEncoder::dispatch_threadgroups
1 header container kind name deprecated status crate counterpart note size group
932 MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setSamplerState:lodMinClamp:lodMaxClamp:atIndex: I runtime ComputeCommandEncoder::set_sampler_state
933 MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setSamplerStates:lodMinClamps:lodMaxClamps:withRange: I runtime ComputeCommandEncoder::set_sampler_state_with_lod_clamps a loop of it
934 MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setThreadgroupMemoryLength:atIndex: I runtime ComputeCommandEncoder::set_threadgroup_memory_length
935 MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setImageblockWidth:height: M explicit imageblocks; a kernel that declares one is refused (`Gap::KernelInput`) explicit imageblocks; a kernel that reaches one is made and its dispatch refused (`Gap::KernelInput`) M encoder-calls
936 MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setStageInRegion: I runtime ComputeCommandEncoder::set_stage_in_region
937 MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setStageInRegionWithIndirectBuffer:indirectBufferOffset: I runtime ComputeCommandEncoder::set_stage_in_region_with_indirect_buffer always refused: a stage-in region the GPU reads is not built (`Gap::StageIn`)
938 MTLComputeCommandEncoder.h MTLComputeCommandEncoder method dispatchThreadgroups:threadsPerThreadgroup: I runtime ComputeCommandEncoder::dispatch_threadgroups