diff --git a/crates/metal2vulkan-conformance/known-gaps-rt.tsv b/crates/metal2vulkan-conformance/known-gaps-rt.tsv index 3f1e59384..ad40cd91d 100644 --- a/crates/metal2vulkan-conformance/known-gaps-rt.tsv +++ b/crates/metal2vulkan-conformance/known-gaps-rt.tsv @@ -202,10 +202,10 @@ astc-8x6-srgb RX 550 refused case/zero-blocks/texture Err(Error::Unsupported("no astc-8x8-ldr RX 550 refused case/zero-blocks/texture Err(Error::Unsupported("no texture of ASTC8x8LDR is made on this device for the usage")) The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatASTC_8x8_LDR with the usage the case asks, so rt makes no such texture (Gap::TextureFormat, or the creator's NotMade). astc-8x8-srgb Iris(R) Xe divergent case/seeded-blocks/texels 256 elements differ (F32), the largest difference 0.0018463432788848877 The device's own answer (rule 1): ANV's decode of the case's sRGB blocks, read through the device's decode (notes `compressed-texel-decode` and `srgb-texel-decode`). The catalogue states compressed-texel-decode's bound for the linear forms; the sRGB forms' bound is unmeasured. Open: that bound. astc-8x8-srgb RX 550 refused case/zero-blocks/texture Err(Error::Unsupported("no texture of ASTC8x8SRGB is made on this device for the usage")) The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatASTC_8x8_sRGB with the usage the case asks, so rt makes no such texture (Gap::TextureFormat, or the creator's NotMade). -attribute-stride-buffer * refused case/pipeline Err(Error::Unsupported("a kernel's stage input of a form not built yet: DynamicStride")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDescriptor nil). rt refuses the state at its creation (Gap::StageIn, StageInKind::DynamicStride: a layout of MTLBufferLayoutStrideDynamic the kernel reads, whose stride the compute encoder's attributeStride setters would bind, which it does not have); rt README, Known gaps of compute. -attribute-stride-buffer-offset * refused case/pipeline Err(Error::Unsupported("a kernel's stage input of a form not built yet: DynamicStride")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDescriptor nil). rt refuses the state at its creation (Gap::StageIn, StageInKind::DynamicStride: a layout of MTLBufferLayoutStrideDynamic the kernel reads, whose stride the compute encoder's attributeStride setters would bind, which it does not have); rt README, Known gaps of compute. -attribute-stride-inline-bytes * refused case/pipeline Err(Error::Unsupported("a kernel's stage input of a form not built yet: DynamicStride")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDescriptor nil). rt refuses the state at its creation (Gap::StageIn, StageInKind::DynamicStride: a layout of MTLBufferLayoutStrideDynamic the kernel reads, whose stride the compute encoder's attributeStride setters would bind, which it does not have); rt README, Known gaps of compute. -attribute-stride-plural-buffers * refused case/pipeline Err(Error::Unsupported("a kernel's stage input of a form not built yet: DynamicStride")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDescriptor nil). rt refuses the state at its creation (Gap::StageIn, StageInKind::DynamicStride: a layout of MTLBufferLayoutStrideDynamic the kernel reads, whose stride the compute encoder's attributeStride setters would bind, which it does not have); rt README, Known gaps of compute. +attribute-stride-buffer * refused case/outcome/dispatch_type Err(TheConsumers("an encoder's dispatchType is the argument it was made with: metal2vulkan-runtime keeps no getter and leaves it to its consumer")) refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. +attribute-stride-buffer-offset * refused case/outcome/dispatch_type Err(TheConsumers("an encoder's dispatchType is the argument it was made with: metal2vulkan-runtime keeps no getter and leaves it to its consumer")) refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. +attribute-stride-inline-bytes * refused case/outcome/dispatch_type Err(TheConsumers("an encoder's dispatchType is the argument it was made with: metal2vulkan-runtime keeps no getter and leaves it to its consumer")) refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. +attribute-stride-plural-buffers * refused case/outcome/dispatch_type Err(TheConsumers("an encoder's dispatchType is the argument it was made with: metal2vulkan-runtime keeps no getter and leaves it to its consumer")) refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. attribute-stride-vertex-buffer * refused case/pipeline Err(Error::Unsupported("a render pipeline state with DynamicState is not built")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). rt builds no render pipeline state with DynamicState (Gap::RenderPipeline; rt README, Known gaps of render pipeline states). attribute-stride-vertex-bytes * refused case/pipeline Err(Error::Unsupported("a render pipeline state with DynamicState is not built")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). rt builds no render pipeline state with DynamicState (Gap::RenderPipeline; rt README, Known gaps of render pipeline states). border-swizzles-rgba8unorm RX 550 divergent case/01rg/black/words 2 elements differ (U32), the largest difference 1065353216 The device's own answer (rule 1), a known gap of the runtime (its README, Known gaps of textures): a runtime sampler of an opaque-black border, clamp to border on `s` and `t`, sampled past the texture's edge; the sample of a RGBA8Unorm texture under the `01rg` swizzle, whose view's component mapping is not the identity, on a device that does not report `borderColorSwizzleFromImage` (the RX 550's driver, RADV on Polaris 12, lists no `VK_EXT_border_color_swizzle`): Vulkan leaves that border texel undefined, and the driver's differs from Metal's, which reads the border colour in the format's channels and then the swizzle. A sampler in the arrays meets every view, so no create info names the view's mapping. The first differing element is at [image 0, row 1, 10] (U32, byte 120): Metal 0 (0x0), ours 1065353216 (0x3f800000). Note `swizzled-opaque-black-border`. diff --git a/crates/metal2vulkan-conformance/src/rt_side/compute.rs b/crates/metal2vulkan-conformance/src/rt_side/compute.rs index 7eedbf372..8ed941dff 100644 --- a/crates/metal2vulkan-conformance/src/rt_side/compute.rs +++ b/crates/metal2vulkan-conformance/src/rt_side/compute.rs @@ -176,15 +176,52 @@ impl RtSide<'_> { ComputeStep::DispatchThreads { grid, threads } => { (encoder.dispatch_threads(*grid, *threads)).map_err(of_rt) } - // The attribute-stride setters, the stage-in region and heaps: the runtime has no - // counterpart yet. - ComputeStep::BufferWithStride { .. } - | ComputeStep::BuffersWithStrides { .. } - | ComputeStep::BufferOffsetWithStride { .. } - | ComputeStep::BytesWithStride { .. } - | ComputeStep::StageInRegion { .. } - | ComputeStep::UseHeap { .. } - | ComputeStep::UseHeaps { .. } => Err(Failure::unavailable(step.call())), + ComputeStep::BufferWithStride { + buffer, + offset, + stride, + index, + } => (encoder.set_buffer_with_attribute_stride( + Some(self.held(*buffer)?), + *offset, + *stride, + *index, + )) + .map_err(of_rt), + ComputeStep::BuffersWithStrides { buffers, first } => { + for (at, (buffer, offset, stride)) in (*first..).zip(buffers) { + (encoder.set_buffer_with_attribute_stride( + Some(self.held(*buffer)?), + *offset, + *stride, + at, + )) + .map_err(of_rt)?; + } + Ok(()) + } + ComputeStep::BufferOffsetWithStride { + offset, + stride, + index, + } => (encoder.set_buffer_offset_with_attribute_stride(*offset, *stride, *index)) + .map_err(of_rt), + ComputeStep::BytesWithStride { + bytes, + stride, + index, + } => (encoder.set_bytes_with_attribute_stride(bytes, *stride, *index)).map_err(of_rt), + ComputeStep::StageInRegion { origin, size } => { + encoder.set_stage_in_region(rt::Region { + origin: *origin, + size: *size, + }); + Ok(()) + } + // Heaps: the runtime has no counterpart yet. + ComputeStep::UseHeap { .. } | ComputeStep::UseHeaps { .. } => { + Err(Failure::unavailable(step.call())) + } } } diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 262ede962..e0da5a458 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -3376,6 +3376,14 @@ while the driver's exit handler waited on a lock, with every runtime thread alre the index its index buffer holds at that clamped quotient, as an Apple M3 Max read it at step rates 1, 2 and 3. Each fetch keeps its reach check: an element past the first 2^32 bytes from its bind offset reads zero. + A layout of `MTLBufferLayoutStrideDynamic` fetches at the stride its buffer was bound with: + `set_buffer_with_attribute_stride` (`setBuffer:offset:attributeStride:atIndex:`; the range + call is a loop of it), `set_buffer_offset_with_attribute_stride` and + `set_bytes_with_attribute_stride` keep the stride's low 32 bits with the binding, pushed at + each later dispatch, so `MTLAttributeStrideStatic` reads the element at the bind offset and + zeros past it, as an Apple M3 Max read it (`attribute-stride-*`). A plain bind of the slot + (`set_buffer`, `set_buffer_offset`, `set_bytes`) binds a stride of 0 and clears an earlier + one: Metal documents no answer for it, and an Apple M3 Max on macOS 27.0.1 read 0. - A kernel whose private memory passes the translator's 16 KiB floor (its arrays a thread indexes at run time: Metal holds such a kernel's thread memory itself) keeps it in the runtime's device memory, the private arena (`RuntimeFact::PrivateArena`): one slot of the kernel's bytes, @@ -4727,13 +4735,9 @@ cache is answered compile-required on both. - A state whose kernel the consumer compiled (`StageSource::Compiled`) holds no linked functions and answers no handle (`function_handle` is `None` for every function), so its tables hold only null entries. -- Two forms of a kernel's `[[stage_in]]` are refused, each as `Gap::StageIn` naming its - `StageInKind`: `set_stage_in_region_with_indirect_buffer` - (`setStageInRegionWithIndirectBuffer:indirectBufferOffset:`, a region the GPU reads), - `IndirectRegion`; and an attribute the kernel reads through a thread-position layout of - `MTLBufferLayoutStrideDynamic`, whose stride the `setBuffer:offset:attributeStride:atIndex:` - family would bind (the compute encoder has none of it), `DynamicStride`, at the state's - creation. +- A stage-in region the GPU reads, `set_stage_in_region_with_indirect_buffer` + (`setStageInRegionWithIndirectBuffer:indirectBufferOffset:`), is refused as `Gap::StageIn` of + `StageInKind::IndirectRegion`. A kernel that encodes plain or indexed triangle draws or plain or indexed patch draws into an indirect command buffer is built (Indirect command buffers, below); one that encodes anything else the translator refuses diff --git a/crates/metal2vulkan-runtime/src/encoder.rs b/crates/metal2vulkan-runtime/src/encoder.rs index a2e401857..7a512be6e 100644 --- a/crates/metal2vulkan-runtime/src/encoder.rs +++ b/crates/metal2vulkan-runtime/src/encoder.rs @@ -99,7 +99,9 @@ pub enum Resource<'a> { IndirectCommandBuffer(&'a IndirectCommandBuffer), } -/// What a buffer slot holds. +/// What a buffer slot holds. A binding carries the stride its call bound it with, the low 32 bits +/// of the `attributeStride` (0 for a plain bind), which a `[[stage_in]]` layout of +/// `MTLBufferLayoutStrideDynamic` at the slot fetches at ([`FieldValue::StageInStride`]). #[derive(Clone, Default)] enum Slot { #[default] @@ -107,9 +109,26 @@ enum Slot { Buffer { buffer: Lent, offset: u64, + stride: u32, }, - /// Where a `set_bytes` copy lies in the parameter ring, and its length. - Bytes(Placed, u32), + /// Where a `set_bytes` copy lies in the parameter ring, its length, and its stride. + Bytes(Placed, u32, u32), +} + +impl Slot { + /// The stride the slot's binding carries, 0 where nothing is bound. + fn stride(&self) -> u32 { + match self { + Slot::Buffer { stride, .. } | Slot::Bytes(_, _, stride) => *stride, + Slot::Empty => 0, + } + } +} + +/// The stride a slot keeps of an `attributeStride` argument: its low 32 bits, as Metal's fetch +/// reads it, so `MTLAttributeStrideStatic` (`u64::MAX`) is `2^32 - 1`. +fn attribute_stride(stride: u64) -> u32 { + stride as u32 } /// [`Refusal::TextureUsageAtSlot`] where a texture of `usage` (its usage as Metal answers it) is @@ -561,6 +580,8 @@ impl ComputeCommandEncoder { /// `setBuffer:offset:atIndex:` (`setBuffers:offsets:withRange:` is a loop of it). `None` /// unbinds the slot. The command buffer keeps the buffer, and so its block, until it retires. + /// The slot's stride is 0, as + /// [`set_buffer_with_attribute_stride`](Self::set_buffer_with_attribute_stride) says. /// /// Err: [`Refusal::BufferIndex`] for an index of 31 or more; [`Refusal::OtherDevice`] for /// another device's buffer. @@ -569,16 +590,58 @@ impl ComputeCommandEncoder { buffer: Option<&Buffer>, offset: u64, index: u32, + ) -> Result<(), Error> { + self.bind_buffer(buffer, offset, 0, index) + } + + /// `setBuffer:offset:attributeStride:atIndex:` (`setBuffers:offsets:attributeStrides:withRange:` + /// is a loop of it): `buffer` bound as [`set_buffer`](Self::set_buffer) binds it, with + /// `stride`, at which a kernel's `[[stage_in]]` layout of `MTLBufferLayoutStrideDynamic` whose + /// buffer index is `index` fetches its elements, pushed at each later dispatch. The slot keeps + /// the stride's low 32 bits, as Metal's fetch reads it: a stride past 32 bits reads as its + /// remainder modulo 2^32, and `MTLAttributeStrideStatic` (`u64::MAX`) as 2^32 - 1, which reads + /// the element at the bind offset and zeros past it. A layout of a fixed stride reads its own, + /// whatever the bind's, as Metal's does. + /// + /// Metal documents no answer for a plain bind of a slot a dynamic layout reads + /// (`setBuffer:offset:atIndex:`, `setBufferOffset:atIndex:` or `setBytes:length:atIndex:`). + /// The runtime reads a stride of 0 there, as an M3 Max on macOS 27.0.1 did: every element is + /// the one at the bind offset, and a plain bind clears the stride an earlier bind of the slot + /// set. + /// + /// Err: as [`set_buffer`](Self::set_buffer). + pub fn set_buffer_with_attribute_stride( + &mut self, + buffer: Option<&Buffer>, + offset: u64, + stride: u64, + index: u32, + ) -> Result<(), Error> { + self.bind_buffer(buffer, offset, attribute_stride(stride), index) + } + + /// Binds `buffer` at `offset` with `stride` at slot `index` + /// ([`set_buffer_with_attribute_stride`](Self::set_buffer_with_attribute_stride)). + fn bind_buffer( + &mut self, + buffer: Option<&Buffer>, + offset: u64, + stride: u32, + index: u32, ) -> Result<(), Error> { let slot = self.slot(index)?; let bound = match buffer { Some(buffer) => { + // The same buffer at the same offset changes no dispatch's facts, whatever its + // stride. if let Slot::Buffer { buffer: held, offset: at, - } = &self.slots[slot] + stride: kept, + } = &mut self.slots[slot] { if held.address() == buffer.address() && *at == offset { + *kept = stride; return Ok(()); } } @@ -591,6 +654,7 @@ impl ComputeCommandEncoder { // buffer commits. buffer: unsafe { building.lend_buffer(buffer) }, offset, + stride, } } None => Slot::Empty, @@ -763,15 +827,42 @@ impl ComputeCommandEncoder { })) } - /// `setBufferOffset:atIndex:`. + /// `setBufferOffset:atIndex:`. The slot's stride is 0, as + /// [`set_buffer_with_attribute_stride`](Self::set_buffer_with_attribute_stride) says. /// /// Err: [`Refusal::BufferIndex`] for an index of 31 or more; [`Refusal::NoBufferAtIndex`] /// where no buffer is bound there. pub fn set_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> { + self.offset_buffer(offset, 0, index) + } + + /// `setBufferOffset:attributeStride:atIndex:`: the buffer bound at `index` moved to `offset`, + /// as [`set_buffer_offset`](Self::set_buffer_offset) moves it, with `stride` in place of the + /// slot's, kept as + /// [`set_buffer_with_attribute_stride`](Self::set_buffer_with_attribute_stride) keeps it. + /// + /// Err: as [`set_buffer_offset`](Self::set_buffer_offset). + pub fn set_buffer_offset_with_attribute_stride( + &mut self, + offset: u64, + stride: u64, + index: u32, + ) -> Result<(), Error> { + self.offset_buffer(offset, attribute_stride(stride), index) + } + + /// Moves the buffer bound at slot `index` to `offset`, with `stride` + /// ([`set_buffer_offset_with_attribute_stride`](Self::set_buffer_offset_with_attribute_stride)). + fn offset_buffer(&mut self, offset: u64, stride: u32, index: u32) -> Result<(), Error> { let slot = self.slot(index)?; match &mut self.slots[slot] { - Slot::Buffer { offset: bound, .. } => { + Slot::Buffer { + offset: bound, + stride: kept, + .. + } => { *bound = offset; + *kept = stride; self.changed(); Ok(()) } @@ -780,13 +871,34 @@ impl ComputeCommandEncoder { } /// `setBytes:length:atIndex:`: the bytes are copied into the parameter ring now, as Metal - /// copies them, and the slot's address is the copy's. + /// copies them, and the slot's address is the copy's. The slot's stride is 0, as + /// [`set_buffer_with_attribute_stride`](Self::set_buffer_with_attribute_stride) says. /// /// Err: [`Refusal::BufferIndex`] for an index of 31 or more; [`Limit::BytesLength`] past one /// ring chunk (64 KiB; Metal documents the call for data under 4 KB); /// [`Limit::MemoryAllocations`] where the ring's next block would take the device past its /// allocation count; [`Error::Vulkan`] where the ring cannot grow. pub fn set_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> { + self.bind_bytes(bytes, 0, index) + } + + /// `setBytes:length:attributeStride:atIndex:`: the bytes copied and bound as + /// [`set_bytes`](Self::set_bytes) copies and binds them, with `stride`, kept as + /// [`set_buffer_with_attribute_stride`](Self::set_buffer_with_attribute_stride) keeps it. + /// + /// Err: as [`set_bytes`](Self::set_bytes). + pub fn set_bytes_with_attribute_stride( + &mut self, + bytes: &[u8], + stride: u64, + index: u32, + ) -> Result<(), Error> { + self.bind_bytes(bytes, attribute_stride(stride), index) + } + + /// Copies `bytes` and binds the copy with `stride` at slot `index` + /// ([`set_bytes_with_attribute_stride`](Self::set_bytes_with_attribute_stride)). + fn bind_bytes(&mut self, bytes: &[u8], stride: u32, index: u32) -> Result<(), Error> { let slot = self.slot(index)?; if bytes.len() as u64 > CHUNK { return Err(Error::Limit(Limit::BytesLength { @@ -803,7 +915,7 @@ impl ComputeCommandEncoder { self.changed(); } // At most one chunk, 64 KiB. - self.slots[slot] = Slot::Bytes(placed, bytes.len() as u32); + self.slots[slot] = Slot::Bytes(placed, bytes.len() as u32, stride); Ok(()) } @@ -1834,7 +1946,7 @@ fn check_alignments( _ => continue, }; match slots.get(slot as usize) { - Some(Slot::Buffer { buffer, offset }) => { + Some(Slot::Buffer { buffer, offset, .. }) => { let at = buffer.gpu_address().wrapping_add(*offset); if words && mask > 3 && at & mask != 0 && at & 3 == 0 { bound |= 1 << slot; @@ -1904,10 +2016,10 @@ impl Parameters { match field.value { FieldValue::BufferAddress { slot, .. } => { let address = match slots.get(slot as usize) { - Some(Slot::Buffer { buffer, offset }) => { + Some(Slot::Buffer { buffer, offset, .. }) => { buffer.gpu_address().wrapping_add(*offset) } - Some(Slot::Bytes(placed, _)) => placed.address, + Some(Slot::Bytes(placed, ..)) => placed.address, Some(Slot::Empty) | None => nil, }; let word = address_word(address); @@ -1919,8 +2031,10 @@ impl Parameters { } FieldValue::BufferBounds(slot) => { let bounds = match slots.get(slot as usize) { - Some(Slot::Buffer { buffer, offset }) => bounds(buffer.length(), *offset), - Some(Slot::Bytes(_, length)) => bounds(u64::from(*length), 0), + Some(Slot::Buffer { buffer, offset, .. }) => { + bounds(buffer.length(), *offset) + } + Some(Slot::Bytes(_, length, _)) => bounds(u64::from(*length), 0), Some(Slot::Empty) | None => [0; 8], }; bytes[at..at + 8].copy_from_slice(&bounds); @@ -1985,6 +2099,10 @@ impl Parameters { bytes[at..at + 32].copy_from_slice(stage_in); } } + FieldValue::StageInStride(slot) => { + let stride = slots.get(slot as usize).map_or(0, Slot::stride); + bytes[at..at + 4].copy_from_slice(&stride.to_le_bytes()); + } // A compute content has none of these (`pipeline::interface`). FieldValue::Word(_) | FieldValue::TessellationFactors @@ -2056,7 +2174,7 @@ struct Parameters { /// - nothing bound, or a buffer or a copy of no bytes: a null descriptor, with 0. fn view(slots: &[Slot], slot: u32, align: u64) -> (Descriptor, u32) { match slots.get(slot as usize) { - Some(Slot::Buffer { buffer, offset }) if buffer.length() > 0 => { + Some(Slot::Buffer { buffer, offset, .. }) if buffer.length() > 0 => { let (reached, at) = buffer.device_range(); let start = at & !(align - 1); let ahead = at - start; @@ -2064,7 +2182,7 @@ fn view(slots: &[Slot], slot: u32, align: u64) -> (Descriptor, u32) { let word = u32::try_from(ahead + offset).unwrap_or(u32::MAX); ((reached, start, ahead + buffer.length()), word) } - Some(Slot::Bytes(placed, length)) if *length > 0 => { + Some(Slot::Bytes(placed, length, _)) if *length > 0 => { debug_assert!(placed.address % align == 0); ((placed.buffer, placed.offset, u64::from(*length)), 0) } diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index 3275d8a21..9ea7312b9 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -1337,12 +1337,10 @@ pub enum Gap { kind: KernelInputKind, }, /// A form of a kernel's `[[stage_in]]` that is not built, `kind` naming which: a stage-in - /// region the GPU reads, or a layout of `MTLBufferLayoutStrideDynamic` a read attribute steps - /// through. Metal's counterpart is `setStageInRegionWithIndirectBuffer:indirectBufferOffset:` - /// and the `setBuffer:offset:attributeStride:atIndex:` family. + /// region the GPU reads. Metal's counterpart is + /// `setStageInRegionWithIndirectBuffer:indirectBufferOffset:`. /// - /// Basis: ours (no replay stream makes a compute state with a stage-input descriptor or sets a - /// stage-in region indirectly). + /// Basis: ours (no replay stream sets a stage-in region indirectly). StageIn { /// The form, named where the runtime found it. kind: StageInKind, @@ -2060,11 +2058,6 @@ pub enum StageInKind { /// ([`ComputeCommandEncoder::set_stage_in_region_with_indirect_buffer`](crate::ComputeCommandEncoder::set_stage_in_region_with_indirect_buffer)). /// Metal's counterpart is `setStageInRegionWithIndirectBuffer:indirectBufferOffset:`. IndirectRegion, - /// An attribute the kernel reads through a layout of `MTLBufferLayoutStrideDynamic` that - /// steps by thread position, whose stride the encoder would bind with the buffer. Metal's - /// counterpart is the `setBuffer:offset:attributeStride:atIndex:` family, which the compute - /// encoder does not have. - DynamicStride, } /// Which sample positions a render pass refuses ([`Refusal::SamplePositions`]). diff --git a/crates/metal2vulkan-runtime/src/pipeline.rs b/crates/metal2vulkan-runtime/src/pipeline.rs index 323631459..b3d54abf0 100644 --- a/crates/metal2vulkan-runtime/src/pipeline.rs +++ b/crates/metal2vulkan-runtime/src/pipeline.rs @@ -65,7 +65,7 @@ use crate::encoder::{ decide, imageblock_checked, size_checked, threadgroup_memory, Dispatch, Lengths, Module, Sizes, BUFFER_SLOTS, TEXTURE_SLOTS, }; -use crate::error::{Error, Gap, IndirectCommandsKind, KernelInputKind, Refusal, StageInKind}; +use crate::error::{Error, Gap, IndirectCommandsKind, KernelInputKind, Refusal}; use crate::hazard::Access; use crate::kernel_map::KernelKey; use crate::reaper::{Free, Job}; @@ -1029,6 +1029,12 @@ pub(crate) enum FieldValue { /// The compute encoder's stage-in region (`setStageInRegion:`), 32 bytes read as two /// `uvec4`: its origin and its size, each with a zero `w`. StageInRegion, + /// A `u32`: the stride the buffer at the slot was bound with + /// (`setBuffer:offset:attributeStride:atIndex:` and its forms, the low 32 bits), 0 for a + /// plain bind and where nothing is bound, which a `[[stage_in]]` layout of + /// `MTLBufferLayoutStrideDynamic` there fetches at (the translator's + /// `PushField::StageInStride`). + StageInStride(u32), /// A `u32` the content fixes: a post-tessellation vertex function's pulled layout's stride, /// the descriptor's. Word(u32), @@ -1165,9 +1171,7 @@ impl crate::Device { /// 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`]); - /// [`Refusal::SamplerIds`] where + /// compute encoder does not supply yet; [`Refusal::SamplerIds`] where /// `sampler_ids` answers another count; [`Refusal::IndicesNotGranted`] for a constexpr /// sampler's index; [`Limit::DeviceSamplers`](crate::Limit::DeviceSamplers); /// [`Error::StageUnfilled`], whose request the consumer's helper fills before it makes the @@ -1272,9 +1276,6 @@ impl Compiled { translator.kernel_inputs_read(function, &inputs, &budget, entries) }) .map_err(Error::translation)?; - if let Some(kind) = unbuilt_stage_in(&plain) { - return Err(Error::Unsupported(Gap::StageIn { kind })); - } let source = (function, plain.clone()); let inputs = plain.kernel_variant(KernelVariant::PartialThreadgroups); let lower = @@ -1749,29 +1750,6 @@ fn past_stage_bound(error: &Error) -> bool { ) } -/// The form of a kernel's `[[stage_in]]` the runtime does not build ([`Gap::StageIn`]) that -/// `inputs` fetch by, the first in attribute order: `inputs` are the kernel's narrowed to the -/// attributes it reads (`kernel_inputs_read`), so an attribute it never reads refuses nothing. A -/// thread-position layout, plain or indexed, of `MTLBufferLayoutStrideDynamic` is -/// [`StageInKind::DynamicStride`]. What Metal's pipeline creation stops (a missing layout, a -/// vertex step, a step rate of 0) is the translator's to refuse, and a constant step reads no -/// stride. -fn unbuilt_stage_in(inputs: &LoweringInputs) -> Option { - use metal2vulkan::metal::StepFunction as S; - let input = inputs.stage_input.as_ref()?; - input.attributes.values().find_map(|attribute| { - let layout = input.layouts.get(&attribute.buffer_index)?; - let by_position = matches!( - layout.step_function, - S::ThreadPositionInGridX - | S::ThreadPositionInGridY - | S::ThreadPositionInGridXIndexed - | S::ThreadPositionInGridYIndexed - ); - (by_position && layout.stride.is_none()).then_some(StageInKind::DynamicStride) - }) -} - /// The runtime's view of the translator's kernel, or what the kernel reads that the compute /// encoder does not supply ([`Gap::KernelInput`] of that kind), the first this finds, on a device /// whose push window is `window` bytes (`DeviceProfile::push_window`). @@ -1864,8 +1842,9 @@ pub(crate) fn interface( // buffer access 2 for its storage buffers (`kernel_robustness`), and each binding of // set 0 is its slot's buffer (`crate::bound`). RuntimeFact::RobustStorageBuffers => {} - // The stage-in region, which the encoder pushes (`FieldValue::StageInRegion`). - RuntimeFact::StageInRegion => {} + // The stage-in region, and the stride a dynamic layout's buffer was bound with, which + // the encoder pushes (`FieldValue::StageInRegion`, `FieldValue::StageInStride`). + RuntimeFact::StageInRegion | RuntimeFact::StageInStride { .. } => {} // What the translator checks against the descriptor when it compiles, and nothing on // the device reads; OpenCL mode decides which textures a dispatch takes. RuntimeFact::CallStackDepth { .. } => {} @@ -2008,6 +1987,7 @@ pub(crate) fn interface( } (PushField::DispatchRegion, _) => FieldValue::DispatchRegion, (PushField::StageInRegion, _) => FieldValue::StageInRegion, + (PushField::StageInStride(index), _) => FieldValue::StageInStride(index), ( PushField::SlotBounds(SlotRef { stage: Stage::Kernel, diff --git a/crates/metal2vulkan-runtime/src/render_encoder.rs b/crates/metal2vulkan-runtime/src/render_encoder.rs index 1af580d98..edfa8ec47 100644 --- a/crates/metal2vulkan-runtime/src/render_encoder.rs +++ b/crates/metal2vulkan-runtime/src/render_encoder.rs @@ -4555,6 +4555,7 @@ fn fill_push( // at its address. FieldValue::DispatchRegion | FieldValue::StageInRegion + | FieldValue::StageInStride(_) | FieldValue::PrivateArena | FieldValue::BindOffset { .. } => {} } diff --git a/crates/metal2vulkan-runtime/src/tests/translate.rs b/crates/metal2vulkan-runtime/src/tests/translate.rs index 5f8f20434..315704c7b 100644 --- a/crates/metal2vulkan-runtime/src/tests/translate.rs +++ b/crates/metal2vulkan-runtime/src/tests/translate.rs @@ -32,10 +32,10 @@ mod on_device { use crate::tests::{devices_of_the_cfgs_kind, keeps_a_blob, keeps_creations}; use crate::StageInKind; use crate::{ - host_time, Block, Buffer, ComputePipelineDescriptor, ComputePipelineState, Device, - DeviceOptions, DispatchType, Error, FunctionDescriptor, Gap, Gauges, Instance, Library, - Limit, MemoryClass, PartialThreadgroupsSite, PrecisionNote, Refusal, Region, StageSource, - MAX_BUFFER_LENGTH, + host_time, Block, Buffer, ComputeCommandEncoder, ComputePipelineDescriptor, + ComputePipelineState, Device, DeviceOptions, DispatchType, Error, FunctionDescriptor, Gap, + Gauges, Instance, Library, Limit, MemoryClass, PartialThreadgroupsSite, PrecisionNote, + Refusal, Region, StageSource, MAX_BUFFER_LENGTH, }; use metal2vulkan::device::{DeviceDescription, VkFeature}; use metal2vulkan::metal::{AttributeFormat, IndexType, StepFunction}; @@ -4603,6 +4603,162 @@ define void @nil_read_kernel(ptr addrspace(1) %in, ptr addrspace(1) %out, i32 %t }); } + /// `engine/kernel_stage_in`'s `stage_in_fetch` under [`stage_in_fetch`]'s descriptor of a + /// layout of `MTLBufferLayoutStrideDynamic` stepping by thread position at rate 1, under a + /// stage-in region at origin 0 and 8 elements long, its buffer at index 1 bound by each setter + /// in turn: each thread `x` of a grid of 8 reports the bits of the 40-byte element at + /// `offset + x * stride`, at the offset and the stride the slot's last bind gave. A stride + /// bind's stride is its low 32 bits, so `2^32 + 40` reads at 40, and `MTLAttributeStrideStatic` + /// (`u64::MAX`, 2^32 - 1) reads thread 0's element and zeros past it, as an M3 Max read the + /// conformance suite's `attribute-stride-*` cases. A plain bind binds a stride of 0 and clears + /// the one an earlier bind of the slot set: after a bind at stride 40, `set_buffer` of the + /// buffer and offset the slot holds, `set_buffer_offset` and `set_bytes` each have every + /// thread read the element at the bind offset. Metal documents no answer for a plain bind of + /// such a slot; this holds the runtime's own. Before the compute encoder pushed a bound stride, + /// the state was `Gap::StageIn` of `DynamicStride`. + #[test] + fn every_device_fetches_a_dynamic_stride_layout_at_the_stride_each_bind_gives() { + let Some(plain) = descriptor_of("kernel_stage_in", "stage_in_fetch") else { + return; + }; + const THREADS: u32 = 8; + const ELEMENTS: u32 = 16; + const OFFSET: u64 = 16; + let descriptor = stage_in_fetch(&plain, None, StepFunction::ThreadPositionInGridX, 1); + // The element each thread reads: `x` at 40, `2x` at 80, the bind offset's at 0, and the + // first then nothing at `MTLAttributeStrideStatic`. + let packed: fn(u32) -> Option = Some; + let spread: fn(u32) -> Option = |x| Some(2 * x); + let first: fn(u32) -> Option = |_| Some(0); + let second: fn(u32) -> Option = |_| Some(1); + let alone: fn(u32) -> Option = |x| (x == 0).then_some(0); + each_device("compute_stage_in_dynamic_stride", |name, _, device| { + let mut buffers = Buffers::new(&device, 8192); + let source = buffers.buffer(OFFSET + 40 * u64::from(ELEMENTS)); + let bytes: Vec = (0..ELEMENTS) + .flat_map(stage_in_element) + .flat_map(u32::to_le_bytes) + .collect(); + write(&source, OFFSET, &bytes); + let state = state(name, &device, &descriptor); + // What a row is called, its binds of index 1, and the element each thread reads. + type Row<'a> = ( + &'a str, + &'a dyn Fn(&mut ComputeCommandEncoder) -> Result<(), Error>, + fn(u32) -> Option, + ); + let rows: [Row<'_>; 10] = [ + ( + "set_buffer_with_attribute_stride at 40", + &|e| e.set_buffer_with_attribute_stride(Some(&source), OFFSET, 40, 1), + packed, + ), + ( + "the same buffer and offset at 80", + &|e| e.set_buffer_with_attribute_stride(Some(&source), OFFSET, 80, 1), + spread, + ), + ( + "at 2^32 + 40", + &|e| { + e.set_buffer_with_attribute_stride(Some(&source), OFFSET, (1 << 32) + 40, 1) + }, + packed, + ), + ( + "at MTLAttributeStrideStatic", + &|e| e.set_buffer_with_attribute_stride(Some(&source), OFFSET, u64::MAX, 1), + alone, + ), + ( + "at 40, then set_buffer of the same buffer and offset", + &|e| { + e.set_buffer_with_attribute_stride(Some(&source), OFFSET, 40, 1)?; + e.set_buffer(Some(&source), OFFSET, 1) + }, + first, + ), + ( + "at 40, then set_buffer_offset one element on", + &|e| { + e.set_buffer_with_attribute_stride(Some(&source), OFFSET, 40, 1)?; + e.set_buffer_offset(OFFSET + 40, 1) + }, + second, + ), + ( + "set_buffer_offset_with_attribute_stride back, at 80", + &|e| e.set_buffer_offset_with_attribute_stride(OFFSET, 80, 1), + spread, + ), + ( + "set_bytes_with_attribute_stride at 40", + &|e| e.set_bytes_with_attribute_stride(&bytes, 40, 1), + packed, + ), + ( + "set_bytes_with_attribute_stride at 40, then set_bytes", + &|e| { + e.set_bytes_with_attribute_stride(&bytes, 40, 1)?; + e.set_bytes(&bytes, 1) + }, + first, + ), + ( + "set_buffer_with_attribute_stride at 40, then set_bytes", + &|e| { + e.set_buffer_with_attribute_stride(Some(&source), OFFSET, 40, 1)?; + e.set_bytes(&bytes, 1) + }, + first, + ), + ]; + // Three `uint4`s a thread, and a spare thread's past the grid. + let outs: Vec = (0..rows.len()) + .map(|_| buffers.buffer(48 * u64::from(THREADS + 1))) + .collect(); + let queue = device.new_command_queue(4).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("a state"); + encoder.set_stage_in_region(Region { + origin: [0; 3], + size: [THREADS, 1, 1], + }); + for ((what, bind, _), out) in rows.iter().zip(&outs) { + encoder.set_buffer(Some(out), 0, 0).expect("a buffer"); + bind(&mut encoder).unwrap_or_else(|error| panic!("{name}: {what}: {error}")); + encoder + .dispatch_threads([THREADS, 1, 1], [4, 1, 1]) + .unwrap_or_else(|error| panic!("{name}: {what}: {error}")); + } + encoder.end_encoding(); + command_buffer.commit().expect("a commit"); + finished(name, &command_buffer); + assert_eq!(command_buffer.error(), None, "{name}"); + for ((what, _, element), out) in rows.iter().zip(&outs) { + // Per thread: the `float4`'s bits, the `uint4`, then the `int`'s bits, each + // `half`'s and the thread's index; zeros for an element past the reach. + let mut expected: Vec = (0..THREADS) + .flat_map(|x| { + let w = element(x).map_or([0; 10], stage_in_element); + let [front @ .., i, h] = w; + front.into_iter().chain([i, h & 0xffff, h >> 16, x]) + }) + .collect(); + expected.extend([0; 12]); + assert_eq!( + words(out, 0, 12 * (THREADS as usize + 1)), + expected, + "{name}: {what}: the attributes each thread fetched" + ); + } + println!("{name}: each thread fetched at the stride the slot's last bind gave"); + }); + } + /// The form of a kernel's `[[stage_in]]` the runtime does not build is refused as /// `Gap::StageIn` of its own kind: `setStageInRegionWithIndirectBuffer:indirectBufferOffset:` /// (`IndirectRegion`) at its call. A thread-position layout of `MTLBufferLayoutStrideDynamic`, diff --git a/crates/metal2vulkan-validation/src/requirement.rs b/crates/metal2vulkan-validation/src/requirement.rs index cfb312c29..2b227c2d9 100644 --- a/crates/metal2vulkan-validation/src/requirement.rs +++ b/crates/metal2vulkan-validation/src/requirement.rs @@ -208,10 +208,10 @@ pub enum ToolingRequirement { KernelAccelerationStructure, /// A compute kernel's `[[stage_in]]` input of a layout of `MTLBufferLayoutStrideDynamic` /// (`executor_contract::case_requirements`), whose data the case binds with the stride form. - /// The runtime refuses such a layout (`metal2vulkan_runtime::Gap::StageIn` of - /// `StageInKind::DynamicStride`): its compute encoder has no - /// `setBuffer:offset:attributeStride:atIndex:`, which is its guard. A kernel's stage inputs of - /// a fixed stride and its dispatch's stage-in region run through the runtime. + /// The runtime builds such a layout (`ComputeCommandEncoder::set_buffer_with_attribute_stride`), + /// and the engine's candidate does not yet bind a slot with the stride form, which is its guard. + /// A kernel's stage inputs of a fixed stride and its dispatch's stage-in region run through the + /// runtime. DynamicStageInStride, /// A rasterization-rate map (`executor_contract::case_requirements`): a render pass's, or one /// whose parameter data a buffer or an argument buffer's buffer holds. The runtime makes no @@ -453,7 +453,8 @@ impl ToolingRequirement { /// [`ToolingRequirement::IndirectDrawTypes`], [`ToolingRequirement::IndirectCommandInheritance`], /// [`ToolingRequirement::HostEncodedIndirectCommands`] and /// [`ToolingRequirement::ArgumentBufferPipelineState`], which the runtime refuses or does not - /// build. + /// build, or, for [`ToolingRequirement::DynamicStageInStride`], which the engine's candidate + /// does not bind yet. pub const fn limit(self) -> Limit { match self { Self::KernelMinLodClamp => Limit::Metal, diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index cf7ee346e..75861c449 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 = 2369; +pub const SEMANTICS_VERSION: u32 = 2370; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another @@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 609; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 2569; +pub const RUNTIME_VERSION: u32 = 2570; /// Writes a digest as lowercase hex. pub(crate) fn write_hex(f: &mut fmt::Formatter<'_>, name: &str, hash: &Hash256) -> fmt::Result { diff --git a/crates/metal2vulkan/src/lower/select.rs b/crates/metal2vulkan/src/lower/select.rs index 026ac3534..1ec93669d 100644 --- a/crates/metal2vulkan/src/lower/select.rs +++ b/crates/metal2vulkan/src/lower/select.rs @@ -1717,7 +1717,9 @@ fn identity_unsourced(f: &RuntimeFact) -> bool { /// pushed: the dispatch's region, a storage texture's integer channel widths, its level count /// and the first element of its levels' run in set 1's storage array (`PushField::TextureLevels`, /// `PushField::TextureLevelBase`), the compute -/// encoder's stage-in region (`PushField::StageInRegion`), the stride of a vertex layout whose +/// encoder's stage-in region (`PushField::StageInRegion`) and the stride a kernel's stage-in layout +/// of `MTLBufferLayoutStrideDynamic` reads its buffer's bind at (`PushField::StageInStride`), the +/// stride of a vertex layout whose /// attributes the function pulls (`PushField::VertexBufferStride`): a post-tessellation function's /// control points and patches, and a plain vertex function's layouts that the de-indexed and /// private list forms and a pipeline made for indirect command buffers pull; the render encoder's alpha test @@ -1773,6 +1775,7 @@ fn identity_refusal(plan: &Plan) -> Option<(IdentityCause, String)> { | PushField::BicubicTexels(_) | PushField::ConstexprSampler(_) | PushField::StageInRegion + | PushField::StageInStride(_) | PushField::VertexBufferStride(_) | PushField::AlphaTestReference | PushField::FetchedColor { .. } diff --git a/crates/metal2vulkan/src/tests/engine_kernel_stage_in.rs b/crates/metal2vulkan/src/tests/engine_kernel_stage_in.rs index 5bf1eed08..d154d5e3f 100644 --- a/crates/metal2vulkan/src/tests/engine_kernel_stage_in.rs +++ b/crates/metal2vulkan/src/tests/engine_kernel_stage_in.rs @@ -522,11 +522,13 @@ fn a_kernel_the_stage_in_region_reaches_is_no_replay_variant() { /// A layout of a fixed stride fetches at it whatever stride the encoder binds its buffer with, so /// a kernel whose layouts all have one records no `RuntimeFact::StageInStride`. A layout of -/// `MTLBufferLayoutStrideDynamic` would read the stride its buffer is bound with, an encoder value -/// the identity domains do not take: the pipeline is their typed refusal naming the first layout -/// read (the runtime refuses a dynamic stride when it makes the state). +/// `MTLBufferLayoutStrideDynamic` that steps by thread position reads the stride its buffer is +/// bound with, which the encoder pushes: the kernel records `RuntimeFact::StageInStride` of each +/// such layout it reads, 1 and 2, and none of its constant step's, 3, which reads no stride. Before +/// the identity domains took that encoder value, the pipeline was their typed refusal naming +/// `StageInStride(1)`. #[test] -fn a_fixed_layout_records_no_stride_and_a_dynamic_one_is_refused() { +fn a_fixed_layout_records_no_stride_and_a_dynamic_one_records_its_own() { let Some(bc) = fixture() else { return }; let mut d = fetch_descriptor( (StepFunction::ThreadPositionInGridX, 1), @@ -534,28 +536,24 @@ fn a_fixed_layout_records_no_stride_and_a_dynamic_one_is_refused() { IndexType::UInt16, ); let dev = device("moltenvk-m3"); - let pipe = pipeline(&dev, &bc, "stage_in_fetch", Some(&d)).expect("pipeline"); - assert!( - !pipe - .dependencies - .iter() - .any(|f| matches!(f.fact, RuntimeFact::StageInStride { .. })), - "fixed strides" - ); + let strides = |pipe: &ComputePipeline| { + let mut layouts: Vec = (pipe.dependencies.iter()) + .filter_map(|f| match f.fact { + RuntimeFact::StageInStride { layout } => Some(layout), + _ => None, + }) + .collect(); + layouts.sort_unstable(); + layouts.dedup(); + layouts + }; + let pipe = pipeline(&dev, &bc, "stage_in_fetch", Some(&d)).expect("fixed strides"); + assert!(strides(&pipe).is_empty(), "fixed strides"); for layout in [1, 2, 3] { d.layouts.get_mut(&layout).expect("layout").stride = None; } - match pipeline(&dev, &bc, "stage_in_fetch", Some(&d)) { - Err(Error::Unsupported(u)) => { - assert_eq!(u.feature, Feature::IdentityDomains, "dynamic strides"); - assert_eq!( - u.symbol.map(|s| s.to_string()).as_deref(), - Some("an encoder value the function reads as StageInStride(1)"), - "dynamic strides" - ); - } - other => panic!("dynamic strides: {other:?}"), - } + let pipe = pipeline(&dev, &bc, "stage_in_fetch", Some(&d)).expect("dynamic strides"); + assert_eq!(strides(&pipe), [1, 2], "dynamic strides"); } /// A step by thread position at any rate or through the index buffer reads the stage-in region, diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index a78cf3402..017460b6d 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -6021,7 +6021,10 @@ method metal2vulkan-runtime::ComputeCommandEncoder::end_encoding pub fn end_enco method metal2vulkan-runtime::ComputeCommandEncoder::memory_barrier pub fn memory_barrier(&mut self) method metal2vulkan-runtime::ComputeCommandEncoder::set_buffer pub fn set_buffer(&mut self, buffer: Option<&Buffer>, offset: u64, index: u32) -> Result<(), Error> method metal2vulkan-runtime::ComputeCommandEncoder::set_buffer_offset pub fn set_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> +method metal2vulkan-runtime::ComputeCommandEncoder::set_buffer_offset_with_attribute_stride pub fn set_buffer_offset_with_attribute_stride(&mut self, offset: u64, stride: u64, index: u32) -> Result<(), Error> +method metal2vulkan-runtime::ComputeCommandEncoder::set_buffer_with_attribute_stride pub fn set_buffer_with_attribute_stride(&mut self, buffer: Option<&Buffer>, offset: u64, stride: u64, index: u32) -> Result<(), Error> method metal2vulkan-runtime::ComputeCommandEncoder::set_bytes pub fn set_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> +method metal2vulkan-runtime::ComputeCommandEncoder::set_bytes_with_attribute_stride pub fn set_bytes_with_attribute_stride(&mut self, bytes: &[u8], stride: u64, index: u32) -> Result<(), Error> method metal2vulkan-runtime::ComputeCommandEncoder::set_compute_pipeline_state pub fn set_compute_pipeline_state(&mut self, state: &ComputePipelineState) -> Result<(), Error> method metal2vulkan-runtime::ComputeCommandEncoder::set_imageblock_size pub fn set_imageblock_size(&mut self, width: u32, height: u32) -> Result<(), Error> method metal2vulkan-runtime::ComputeCommandEncoder::set_sampler_state pub fn set_sampler_state(&mut self, sampler: Option<&SamplerState>, index: u32) -> Result<(), Error> @@ -8828,7 +8831,6 @@ variant metal2vulkan-runtime::StageGap::Breach Breach(crate::StageBreach) variant metal2vulkan-runtime::StageGap::NoCacheDirectory NoCacheDirectory variant metal2vulkan-runtime::StageGap::NoPipelineCache NoPipelineCache variant metal2vulkan-runtime::StageGap::RenderStage RenderStage -variant metal2vulkan-runtime::StageInKind::DynamicStride DynamicStride variant metal2vulkan-runtime::StageInKind::IndirectRegion IndirectRegion variant metal2vulkan-runtime::StageSource::Compiled Compiled(CompiledFunction) variant metal2vulkan-runtime::StageSource::Function Function(FunctionDescriptor) diff --git a/docs/CONFORMANCE-COVERAGE.md b/docs/CONFORMANCE-COVERAGE.md index d0f66290f..46110e2c3 100644 --- a/docs/CONFORMANCE-COVERAGE.md +++ b/docs/CONFORMANCE-COVERAGE.md @@ -31,13 +31,13 @@ Its limits, measured rather than asserted: | | | |---|---| -| implemented Metal items | 645 | +| implemented Metal items | 649 | | of those, unreachable: `objc2-metal` binds no name for them | 2 | -| so reachable by some case | 643 | -| of the reachable, exercised by the suite's Metal leg | 562 | +| so reachable by some case | 647 | +| of the reachable, exercised by the suite's Metal leg | 566 | | of the reachable, not exercised | 81 | | share of the reachable exercised | 87% | -| of those exercised, no case reaching it loosens anything | 341 | +| of those exercised, no case reaching it loosens anything | 345 | | of those exercised, a case reaching it loosens some site | 221 | | case modules | 197 | | committed recordings | 1355 | @@ -367,7 +367,7 @@ Every container with an implemented item, by how much of it the suite reaches. * | `MTLRenderCommandEncoder` | 66 | 0 | 59 | 7 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | | `MTLDevice` | 29 | 1 | 22 | 6 | `alpha_coverage_pairs`, `argument_encoder_crossings`, `argument_encoders`, `astc_textures`… | | the header's free functions | 5 | 0 | 0 | 5 | | -| `MTLComputeCommandEncoder` | 29 | 0 | 26 | 3 | `argument_encoders`, `astc_textures`, `attribute_formats`, `attribute_strides`… | +| `MTLComputeCommandEncoder` | 33 | 0 | 30 | 3 | `argument_encoders`, `astc_textures`, `attribute_formats`, `attribute_strides`… | | `MTLFunctionConstantValues` | 5 | 0 | 2 | 3 | `function_constants_half3`, `function_facts`, `library_facts` | | `MTLLibrary` | 10 | 0 | 7 | 3 | `alpha_coverage_pairs`, `argument_encoder_crossings`, `argument_encoders`, `astc_textures`… | | `MTLRasterizationRateSampleArray` | 3 | 0 | 0 | 3 | | @@ -459,7 +459,7 @@ A container is one Objective-C type; the SDK header it sits in is the family of | `MTLRenderCommandEncoder.h` | 66 | 59 | 7 | | `MTLLibrary.h` | 40 | 35 | 5 | | `MTLRenderPipeline.h` | 102 | 97 | 5 | -| `MTLComputeCommandEncoder.h` | 29 | 26 | 3 | +| `MTLComputeCommandEncoder.h` | 33 | 30 | 3 | | `MTLFunctionConstantValues.h` | 5 | 2 | 3 | | `MTLStageInputOutputDescriptor.h` | 21 | 18 | 3 | | `MTLVertexDescriptor.h` | 19 | 16 | 3 | @@ -542,7 +542,7 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | `argument_encoders` | 5 | 5 | every field | 57 | | `astc_textures` | 42 | 42 | 1 tolerance(s): `Degradation` | 39 | | `attribute_formats` | 2 | 2 | every field | 48 | -| `attribute_strides` | 4 | 4 | every field | 46 | +| `attribute_strides` | 4 | 4 | every field | 50 | | `bicubic_texel_classes` | 1 | 1 | every field | 31 | | `binary_archives` | 6 | 6 | every field | 27 | | `blend_interactions` | 4 | 4 | every field | 121 | @@ -568,7 +568,7 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | `compressed_small_levels` | 2 | 2 | every field | 38 | | `compressed_views` | 14 | 14 | every field | 37 | | `compute_encoder_commands` | 8 | 8 | every field | 62 | -| `compute_heap_residency` | 1 | 1 | every field | 44 | +| `compute_heap_residency` | 1 | 1 | every field | 48 | | `compute_pipeline_descriptors` | 3 | 3 | 1 tolerance(s): `AcceptedDifference` | 22 | | `compute_render_chains` | 3 | 3 | every field | 145 | | `compute_threadgroups` | 2 | 1 | every field | 27 | @@ -953,6 +953,10 @@ One row per implemented item of the SDK, in the coverage map's order. *exercised | `setBuffer:offset:atIndex:` | yes | `argument_encoders`, `astc_textures`, `attribute_formats`, `attribute_strides`, `bicubic_texel_classes`, `blit_indirect_commands`, `block_writes_only`, `border_swizzles`, `buffer_bind_off_alignment`, `buffer_depth_samples`, `buffer_tails`, `chroma_pairs`, `compressed_decode`, `compute_encoder_commands`, `compute_heap_residency`, `compute_render_chains`, `compute_threadgroups`, `denormal_word_fetches`, `depth_colour_reads`, `depth_texel_reads`, `etc_textures`, `extended_range_blends`, `extended_range_planes`, `extended_range_targets`, `extended_range_two_planes`, `extended_swizzles`, `frame_chains`, `function_constants_half3`, `half_read_nans`, `half_storage_writes`, `half_texel_nans`, `half_write_nans`, `host_page_writes`, `imageblock_sizes`, `indirect_command_depth`, `indirect_commands`, `indirect_ranges`, `level_sizes`, `math_routines`, `nan_integer_conversions`, `nearest_positions`, `norm_storage_writes`, `pass_bytes`, `pixel_downscales`, `pixel_samplers`, `read_through`, `read_write_tiers`, `resolve_then_load`, `rgb10a2_srgb`, `sampler_bind_clamps`, `sampler_crossings`, `sampler_filtering`, `shared_exponent_storage`, `signed_remainders`, `simdgroup_lockstep`, `sparse_status`, `srgb_storage_writes`, `stage_in_regions`, `stage_in_unread`, `swizzled_storage`, `texel_swizzles`, `texture_buffer_tails`, `texture_view_casts`, `threadgroup_start`, `two_plane_samples`, `vector_word_phases`, `visible_tables`, `ycbcr_gathers`, `ycbcr_minify`, `ycbcr_textures` | 411 | | `setBufferOffset:atIndex:` | yes | `compute_encoder_commands`, `compute_heap_residency` | 9 | | `setBuffers:offsets:withRange:` | yes | `compute_encoder_commands`, `compute_heap_residency` | 9 | +| `setBuffer:offset:attributeStride:atIndex:` | yes | `attribute_strides`, `compute_heap_residency` | 5 | +| `setBuffers:offsets:attributeStrides:withRange:` | yes | `attribute_strides`, `compute_heap_residency` | 5 | +| `setBufferOffset:attributeStride:atIndex:` | yes | `attribute_strides`, `compute_heap_residency` | 5 | +| `setBytes:length:attributeStride:atIndex:` | yes | `attribute_strides`, `compute_heap_residency` | 5 | | `setVisibleFunctionTable:atBufferIndex:` | yes | `visible_tables` | 18 | | `setVisibleFunctionTables:withBufferRange:` | no | — | — | | `setTexture:atIndex:` | yes | `argument_encoders`, `astc_textures`, `attribute_formats`, `bicubic_texel_classes`, `blit_indirect_commands`, `block_writes_only`, `border_swizzles`, `buffer_depth_samples`, `buffer_tails`, `chroma_pairs`, `compressed_decode`, `compute_encoder_commands`, `compute_heap_residency`, `compute_render_chains`, `compute_threadgroups`, `denormal_word_fetches`, `depth_colour_reads`, `depth_texel_reads`, `etc_textures`, `extended_range_blends`, `extended_range_planes`, `extended_range_targets`, `extended_range_two_planes`, `extended_swizzles`, `frame_chains`, `function_constants_half3`, `half_read_nans`, `half_storage_writes`, `half_texel_nans`, `half_write_nans`, `host_page_writes`, `imageblock_slice_past_grid`, `indirect_command_depth`, `indirect_commands`, `level_sizes`, `math_routines`, `nan_integer_conversions`, `nearest_positions`, `norm_storage_writes`, `pass_bytes`, `pixel_downscales`, `pixel_samplers`, `read_through`, `read_write_tiers`, `resolve_then_load`, `rgb10a2_srgb`, `sampler_bind_clamps`, `sampler_crossings`, `sampler_filtering`, `shared_exponent_storage`, `signed_remainders`, `simdgroup_lockstep`, `sparse_status`, `srgb_storage_writes`, `stage_in_regions`, `stage_in_unread`, `swizzled_storage`, `texel_swizzles`, `texture_buffer_tails`, `texture_view_casts`, `two_plane_samples`, `ycbcr_gathers`, `ycbcr_minify`, `ycbcr_textures` | 376 | @@ -1856,10 +1860,6 @@ An item the suite's Metal leg calls whose coverage-map status is not implemented | `MTLCommandQueue` `label` | out of scope | the consumer's (metal2vulkan-runtime's README, What the consumer implements) | `command_buffer_facts` | | `MTLComputeCommandEncoder` `dispatchType` | out of scope | the consumer's (metal2vulkan-runtime's README, What the consumer implements) | `attribute_strides`, `buffer_bind_off_alignment`, `compute_encoder_commands`, `compute_heap_residency`, `imageblock_sizes`, `imageblock_slice_past_grid`, `sampler_bind_clamps`, `threadgroup_start`, `vector_word_phases` | | `MTLComputeCommandEncoder` `executeCommandsInBuffer:withRange:` | missing | indirect command buffers past GPU-encoded plain or indexed triangle or patch draws with an inherited pipeline state (`Gap::IndirectCommandBuffers`) | `blit_indirect_commands`, `indirect_command_depth`, `indirect_commands` | -| `MTLComputeCommandEncoder` `setBuffer:offset:attributeStride:atIndex:` | missing | a bind with a per-bind stride, which stage-in and vertex fetch read | `attribute_strides`, `compute_heap_residency` | -| `MTLComputeCommandEncoder` `setBufferOffset:attributeStride:atIndex:` | missing | a bind with a per-bind stride, which stage-in and vertex fetch read | `attribute_strides`, `compute_heap_residency` | -| `MTLComputeCommandEncoder` `setBuffers:offsets:attributeStrides:withRange:` | missing | a bind with a per-bind stride, which stage-in and vertex fetch read | `attribute_strides`, `compute_heap_residency` | -| `MTLComputeCommandEncoder` `setBytes:length:attributeStride:atIndex:` | missing | a bind with a per-bind stride, which stage-in and vertex fetch read | `attribute_strides`, `compute_heap_residency` | | `MTLComputePipelineDescriptor` `binaryArchives` | out of scope | the consumer's (metal2vulkan-runtime's README, What the consumer implements) | `binary_archives`, `compute_pipeline_descriptors` | | `MTLComputePipelineDescriptor` `label` | out of scope | the consumer's (metal2vulkan-runtime's README, What the consumer implements) | `compute_pipeline_descriptors`, `pipeline_facts`, `pipeline_handlers` | | `MTLComputePipelineState` `device` | missing | a query or call metal2vulkan-runtime does not answer | `pipeline_facts`, `pipeline_handlers` | @@ -2301,10 +2301,10 @@ A case whose difference from Metal is recorded rather than compared away. The le | `astc-8x8-ldr` | The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatASTC_8x8_LDR with the usage the case asks, so rt makes no such te… | | `astc-8x8-srgb` | The device's own answer (rule 1): ANV's decode of the case's sRGB blocks, read through the device's decode (notes `compressed-texel-decode` and `srgb-texel-deco… | | `astc-8x8-srgb` | The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatASTC_8x8_sRGB with the usage the case asks, so rt makes no such t… | -| `attribute-stride-buffer` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDe… | -| `attribute-stride-buffer-offset` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDe… | -| `attribute-stride-inline-bytes` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDe… | -| `attribute-stride-plural-buffers` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every compute pipeline descriptor's stageInputDe… | +| `attribute-stride-buffer` | refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. | +| `attribute-stride-buffer-offset` | refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. | +| `attribute-stride-inline-bytes` | refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. | +| `attribute-stride-plural-buffers` | refused: the consumer's own (dispatchType). rt takes the dispatch type as the encoder's argument and keeps no getter. | | `attribute-stride-vertex-buffer` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… | | `attribute-stride-vertex-bytes` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… | | `border-swizzles-rgba8unorm` | The device's own answer (rule 1), a known gap of the runtime (its README, Known gaps of textures): a runtime sampler of an opaque-black border, clamp to border … | diff --git a/docs/METAL-COVERAGE.md b/docs/METAL-COVERAGE.md index c4ca89aed..2ac8fb01e 100644 --- a/docs/METAL-COVERAGE.md +++ b/docs/METAL-COVERAGE.md @@ -10,12 +10,12 @@ Every public item of the macOS 27.2 SDK (Xcode 27.2, 27B52)'s Metal headers, by | Status | Items | Of which deprecated | |---|---|---| -| implemented | 646 | 29 | -| missing | 1065 | 34 | +| implemented | 650 | 29 | +| missing | 1061 | 34 | | out of scope | 424 | 5 | | all | 2135 | 68 | -Implemented by the runtime: 289; by the translator's values: 357. Missing by size: S 178, M 198, L 313, XL 376. +Implemented by the runtime: 293; by the translator's values: 357. Missing by size: S 178, M 194, L 313, XL 376. ## Missing, in build order @@ -33,7 +33,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | a buffer made with bytes | S | 1 | `MTLDevice.newBufferWithBytes:length:options:` | | pipeline creation forms (from a function, with a completion handler) | S | 6 | `MTLDevice.newRenderPipelineStateWithDescriptor:options:completionHandler:`, `MTLDevice.newComputePipelineStateWithFunction:error:`, `MTLDevice.newComputePipelineStateWithFunction:options:reflection:error:`, ... | | render pass descriptor fields | S/M/L | 5 | `MTLRenderPassAttachmentDescriptor.storeActionOptions`, `MTLRenderPassDescriptor.imageblockSampleLength`, `MTLRenderPassDescriptor.threadgroupMemoryLength`, ... | -| encoder calls (stride setters, indirect draws, store action options, a render encoder's heap uses) | S/M/L | 21 | `MTLBlitCommandEncoder.synchronizeTexture:slice:level:`, `MTLBlitCommandEncoder.copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:`, `MTLBlitCommandEncoder.copyFromTexture:toTexture:`, ... | +| encoder calls (stride setters, indirect draws, store action options, a render encoder's heap uses) | S/M/L | 17 | `MTLBlitCommandEncoder.synchronizeTexture:slice:level:`, `MTLBlitCommandEncoder.copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:`, `MTLBlitCommandEncoder.copyFromTexture:toTexture:`, ... | | `textureBarrier` and queue-stage barriers | S/M | 2 | `MTLCommandEncoder.barrierAfterQueueStages:beforeStages:`, `MTLRenderCommandEncoder.textureBarrier` | | a pipeline state's reflection after creation | S | 2 | `MTLComputePipelineState.reflection`, `MTLRenderPipelineState.reflection` | | function handles by name, and a handle's type and ID | S | 6 | `MTLComputePipelineState.functionHandleWithName:`, `MTLFunctionHandle.functionType`, `MTLFunctionHandle.name`, ... | @@ -1227,10 +1227,10 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | `MTLComputeCommandEncoder.setBuffer:offset:atIndex:` | method | implemented | `ComputeCommandEncoder::set_buffer` (runtime) | | `MTLComputeCommandEncoder.setBufferOffset:atIndex:` | method | implemented | `ComputeCommandEncoder::set_buffer_offset` (runtime) | | `MTLComputeCommandEncoder.setBuffers:offsets:withRange:` | method | implemented | `ComputeCommandEncoder::set_buffer` (runtime): a loop of it | -| `MTLComputeCommandEncoder.setBuffer:offset:attributeStride:atIndex:` | method | missing | M: a bind with a per-bind stride, which stage-in and vertex fetch read | -| `MTLComputeCommandEncoder.setBuffers:offsets:attributeStrides:withRange:` | method | missing | M: a bind with a per-bind stride, which stage-in and vertex fetch read | -| `MTLComputeCommandEncoder.setBufferOffset:attributeStride:atIndex:` | method | missing | M: a bind with a per-bind stride, which stage-in and vertex fetch read | -| `MTLComputeCommandEncoder.setBytes:length:attributeStride:atIndex:` | method | missing | M: a bind with a per-bind stride, which stage-in and vertex fetch read | +| `MTLComputeCommandEncoder.setBuffer:offset:attributeStride:atIndex:` | method | implemented | `ComputeCommandEncoder::set_buffer_with_attribute_stride` (runtime): the stride's low 32 bits | +| `MTLComputeCommandEncoder.setBuffers:offsets:attributeStrides:withRange:` | method | implemented | `ComputeCommandEncoder::set_buffer_with_attribute_stride` (runtime): a loop of it | +| `MTLComputeCommandEncoder.setBufferOffset:attributeStride:atIndex:` | method | implemented | `ComputeCommandEncoder::set_buffer_offset_with_attribute_stride` (runtime): the stride's low 32 bits | +| `MTLComputeCommandEncoder.setBytes:length:attributeStride:atIndex:` | method | implemented | `ComputeCommandEncoder::set_bytes_with_attribute_stride` (runtime): the stride's low 32 bits | | `MTLComputeCommandEncoder.setVisibleFunctionTable:atBufferIndex:` | method | implemented | `ComputeCommandEncoder::set_visible_function_table` (runtime) | | `MTLComputeCommandEncoder.setVisibleFunctionTables:withBufferRange:` | method | implemented | `ComputeCommandEncoder::set_visible_function_table` (runtime): a loop of it | | `MTLComputeCommandEncoder.setIntersectionFunctionTable:atBufferIndex:` | method | out of scope | ray tracing | diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 442240cf5..3d6412374 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -251,7 +251,7 @@ Columns: | `SamplerArgumentIndex` | A sampler argument index past Metal's 16 entries (`setSamplerState`) | every device (a public call's own check of its arguments) | `metal-documented`: the sampler argument table has 16 entries per stage | 2: `crates/metal2vulkan-runtime/src/encoder.rs (bind_sampler)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (set_sampler_state)` | `-` | | `FunctionTableIndex` | A visible-function table's entry at or past its size (`VisibleFunctionTable::set_function`, `set_functions`), which writes nothing | every device (a public call's own check of its arguments) | `ours`: the runtime writes no byte past a table's words | 1: `crates/metal2vulkan-runtime/src/function_table.rs (set_functions)` | `-` | | `SamplerIds` | A consumer's answer to `Device::new_compute_pipeline_state`'s numbered samplers with another count of indices | every device (a public call's own check of its arguments) | `ours`: each numbered sampler takes one index | 1: `crates/metal2vulkan-runtime/src/pipeline.rs (number_samplers)` | `-` | -| `NoBufferAtIndex` | `setBufferOffset` at an index where no buffer is bound, or a draw whose vertex descriptor reads a vertex buffer index where none is bound | every device (a public call's own check of its arguments) | `ours`: there is no buffer whose offset to change, and none whose vertices the draw reads; Metal's validation stops such a draw | 3: `crates/metal2vulkan-runtime/src/encoder.rs (set_buffer_offset)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (find)` (+1) | `-` | +| `NoBufferAtIndex` | `setBufferOffset` at an index where no buffer is bound, or a draw whose vertex descriptor reads a vertex buffer index where none is bound | every device (a public call's own check of its arguments) | `ours`: there is no buffer whose offset to change, and none whose vertices the draw reads; Metal's validation stops such a draw | 3: `crates/metal2vulkan-runtime/src/encoder.rs (offset_buffer)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (find)` (+1) | `-` | | `ThreadgroupSize` | A threadgroup of no threads, or of more than Metal's `maxTotalThreadsPerThreadgroup` for the kernel (a required size's threads, where the... | every device (a public call's own check of its arguments) | `metal-documented`: a threadgroup's threads total at most the state's `maxTotalThreadsPerThreadgroup` | 2: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`, `crates/metal2vulkan-runtime/src/encoder.rs (size_checked)` | `-` | | `ImageblockSize` | An imageblock size (`ComputeCommandEncoder::set_imageblock_size`) whose width or height is not a power of two, 0 included, or whose cells are more... | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `imageblock_size_rules.m` in the conformance crate: Metal's validation layer stops each at the call, `width(24) must be a power of 2.`, `height(12) must be a power of 2.`, `width(0) must be a power of 2.` and `width(64)*height(32) must be less than or equal to 1024`; it takes 16 by 16, 1024 by 1, 1 by 1024, 16 by 16 for a state of 64 threads, and a size set before the pipeline state | 1: `crates/metal2vulkan-runtime/src/encoder.rs (imageblock_checked)` | `-` | | `IndirectOffset` | An indirect dispatch's or draw's argument offset that is not a multiple of 4, which Metal's `indirectBufferOffset` must be... | every device (a public call's own check of its arguments) | `metal-documented`: MTLComputeCommandEncoder.h for `dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:`, and MTLRenderCommandEncoder.h for the indirect `drawPrimitives` and `drawIndexedPrimitives`: "indirectBufferOffset must be a multiple of 4"; Apple's page for the indirect `drawPatches` sends its offset to the feature set tables, whose minimum constant buffer offset alignment is 4 bytes | 2: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch_threadgroups_with_indirect_buffer)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (indirect)` | `-` | @@ -324,7 +324,7 @@ Columns: | `BlockIds` | A block after every block number has been used (`Device::take_block`) | every device (a public call's own check of its arguments) | `ours`: block numbers are 32 bits | 2: `crates/metal2vulkan-runtime/src/memory.rs (allocation_number)`, `crates/metal2vulkan-runtime/src/memory.rs (number)` | `-` | | `ThreadgroupMemory` | A dispatch whose threadgroup memory, the kernel's own and the lengths set (each rounded up to 16 bytes), is past the device's... | at the device's limit | `device`: the device's `maxComputeSharedMemorySize` | 1: `crates/metal2vulkan-runtime/src/encoder.rs (threadgroup_memory)` | `-` | | `ThreadgroupThreads` | A dispatch whose threadgroup is within Metal's `maxTotalThreadsPerThreadgroup` for the kernel and past the state's on this device | at the device's limit | `device`: the device's compute work-group and shared-memory limits | 1: `crates/metal2vulkan-runtime/src/encoder.rs (size_checked)` | `-` | -| `BytesLength` | `setBytes` data longer than one parameter ring chunk | every device (a public call's own check of its arguments) | `ours`: a ring chunk is 64 KiB | 2: `crates/metal2vulkan-runtime/src/encoder.rs (set_bytes)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (set_bytes)` | `-` | +| `BytesLength` | `setBytes` data longer than one parameter ring chunk | every device (a public call's own check of its arguments) | `ours`: a ring chunk is 64 KiB | 2: `crates/metal2vulkan-runtime/src/encoder.rs (bind_bytes)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (set_bytes)` | `-` | | `IndexRange` | A grant of no indices, or one past its class's range (`Device::grant_indices`, [`IndexClass::range`]) | every device (a public call's own check of its arguments) | `ours`: the descriptor arrays are 65,536 sampled and 65,536 storage textures, one index of both a texture's, and 4,000 samplers of each use, and index 0 is nil | 1: `crates/metal2vulkan-runtime/src/arrays.rs (grant)` | `-` | | `TextureSize` | A texture whose extent or array layers are past what the device makes of its format, type, usage and sample count | at the device's limit | `device`: the image format query's `maxExtent` and `maxArrayLayers`, an import's with its handle type, and `maxTexelBufferElements` | 2: `crates/metal2vulkan-runtime/src/texture.rs (size_within)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_width)` | `-` | | `DeviceSamplers` | A sampler state whose device samplers would take the device past its `maxSamplerAllocationCount`, less the sampler arrays' two defaults... | at the device's limit | `device`: the device's `maxSamplerAllocationCount` | 1: `crates/metal2vulkan-runtime/src/sampler.rs (take)` | `-` | @@ -348,7 +348,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 | 2: `crates/metal2vulkan-runtime/src/encoder.rs (set_stage_in_region_with_indirect_buffer)`, `crates/metal2vulkan-runtime/src/pipeline.rs (of)` | `-` | +| `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 sets a stage-in region indirectly | 1: `crates/metal2vulkan-runtime/src/encoder.rs (set_stage_in_region_with_indirect_buffer)` | `-` | | `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)` | `-` | @@ -538,7 +538,7 @@ Each refusal's sites, with the function that builds it. - `rt:Refusal::Committed`: `crates/metal2vulkan-runtime/src/command.rs (open)` - `rt:Refusal::InScheduledHandler`: `crates/metal2vulkan-runtime/src/command.rs (not_in_scheduled_handler)` - `rt:Refusal::WaitOnOwnThread`: `crates/metal2vulkan-runtime/src/command.rs (wait_until_completed)`; `crates/metal2vulkan-runtime/src/command.rs (wait_until_scheduled)`; `crates/metal2vulkan-runtime/src/event.rs (wait_until_signaled_value)`; `crates/metal2vulkan-runtime/src/queue.rs (command_buffer)` -- `rt:Refusal::OtherDevice`: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-runtime/src/blit.rs (copy_from_buffer_to_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (copy_from_texture)`; `crates/metal2vulkan-runtime/src/blit.rs (fill_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)`; `crates/metal2vulkan-runtime/src/blit.rs (optimize_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (reset_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (synchronize_resource)`; `crates/metal2vulkan-runtime/src/command.rs (check)`; `crates/metal2vulkan-runtime/src/command.rs (present_drawable)`; `crates/metal2vulkan-runtime/src/device.rs (release_block)`; `crates/metal2vulkan-runtime/src/encoder.rs (bind_sampler)`; `crates/metal2vulkan-runtime/src/encoder.rs (dispatch_threadgroups_with_indirect_buffer)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_buffer)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_texture)`; `crates/metal2vulkan-runtime/src/encoder.rs (use_resource, 3 sites)`; `crates/metal2vulkan-runtime/src/fence.rs (check)`; `crates/metal2vulkan-runtime/src/pass.rs (check, 2 sites)`; `crates/metal2vulkan-runtime/src/pass.rs (resolve)`; `crates/metal2vulkan-runtime/src/render_encoder.rs`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer_with_range)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (indirect)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_depth_stencil_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_render_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_sampler_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_tessellation_factor_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_texture)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (use_resource, 3 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (new_managed_texture)` +- `rt:Refusal::OtherDevice`: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-runtime/src/blit.rs (copy_from_buffer_to_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (copy_from_texture)`; `crates/metal2vulkan-runtime/src/blit.rs (fill_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)`; `crates/metal2vulkan-runtime/src/blit.rs (optimize_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (reset_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/blit.rs (synchronize_resource)`; `crates/metal2vulkan-runtime/src/command.rs (check)`; `crates/metal2vulkan-runtime/src/command.rs (present_drawable)`; `crates/metal2vulkan-runtime/src/device.rs (release_block)`; `crates/metal2vulkan-runtime/src/encoder.rs (bind_buffer)`; `crates/metal2vulkan-runtime/src/encoder.rs (bind_sampler)`; `crates/metal2vulkan-runtime/src/encoder.rs (dispatch_threadgroups_with_indirect_buffer)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/encoder.rs (set_texture)`; `crates/metal2vulkan-runtime/src/encoder.rs (use_resource, 3 sites)`; `crates/metal2vulkan-runtime/src/fence.rs (check)`; `crates/metal2vulkan-runtime/src/pass.rs (check, 2 sites)`; `crates/metal2vulkan-runtime/src/pass.rs (resolve)`; `crates/metal2vulkan-runtime/src/render_encoder.rs`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execute_commands_in_buffer_with_range)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (indirect)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_depth_stencil_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_render_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_sampler_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_tessellation_factor_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_texture)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (use_resource, 3 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (new_managed_texture)` - `rt:Refusal::NoCommandBuffers`: `crates/metal2vulkan-runtime/src/queue.rs (new_command_queue)` - `rt:Refusal::EncoderOpen`: `crates/metal2vulkan-runtime/src/command.rs (open)` - `rt:Refusal::NoPipeline`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw, 2 sites)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_reaches)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)` @@ -553,7 +553,7 @@ Each refusal's sites, with the function that builds it. - `rt:Refusal::SamplerArgumentIndex`: `crates/metal2vulkan-runtime/src/encoder.rs (bind_sampler)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_sampler_state)` - `rt:Refusal::FunctionTableIndex`: `crates/metal2vulkan-runtime/src/function_table.rs (set_functions)` - `rt:Refusal::SamplerIds`: `crates/metal2vulkan-runtime/src/pipeline.rs (number_samplers)` -- `rt:Refusal::NoBufferAtIndex`: `crates/metal2vulkan-runtime/src/encoder.rs (set_buffer_offset)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (find)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_buffer_offset)` +- `rt:Refusal::NoBufferAtIndex`: `crates/metal2vulkan-runtime/src/encoder.rs (offset_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (find)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_buffer_offset)` - `rt:Refusal::ThreadgroupSize`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`; `crates/metal2vulkan-runtime/src/encoder.rs (size_checked)` - `rt:Refusal::ImageblockSize`: `crates/metal2vulkan-runtime/src/encoder.rs (imageblock_checked)` - `rt:Refusal::IndirectOffset`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch_threadgroups_with_indirect_buffer)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (indirect)` @@ -621,7 +621,7 @@ Each refusal's sites, with the function that builds it. - `rt:Limit::BlockIds`: `crates/metal2vulkan-runtime/src/memory.rs (allocation_number)`; `crates/metal2vulkan-runtime/src/memory.rs (number)` - `rt:Limit::ThreadgroupMemory`: `crates/metal2vulkan-runtime/src/encoder.rs (threadgroup_memory)` - `rt:Limit::ThreadgroupThreads`: `crates/metal2vulkan-runtime/src/encoder.rs (size_checked)` -- `rt:Limit::BytesLength`: `crates/metal2vulkan-runtime/src/encoder.rs (set_bytes)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_bytes)` +- `rt:Limit::BytesLength`: `crates/metal2vulkan-runtime/src/encoder.rs (bind_bytes)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_bytes)` - `rt:Limit::IndexRange`: `crates/metal2vulkan-runtime/src/arrays.rs (grant)` - `rt:Limit::TextureSize`: `crates/metal2vulkan-runtime/src/texture.rs (size_within)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_width)` - `rt:Limit::DeviceSamplers`: `crates/metal2vulkan-runtime/src/sampler.rs (take)` @@ -640,7 +640,7 @@ Each refusal's sites, with the function that builds it. - `rt:Limit::TextureSamples`: `crates/metal2vulkan-runtime/src/texture.rs (planned)` - `rt:Gap::IndirectCommandBuffers`: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/indirect.rs (shape)`; `crates/metal2vulkan-runtime/src/pipeline.rs (compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)` - `rt:Gap::KernelInput`: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)` -- `rt:Gap::StageIn`: `crates/metal2vulkan-runtime/src/encoder.rs (set_stage_in_region_with_indirect_buffer)`; `crates/metal2vulkan-runtime/src/pipeline.rs (of)` +- `rt:Gap::StageIn`: `crates/metal2vulkan-runtime/src/encoder.rs (set_stage_in_region_with_indirect_buffer)` - `rt:Gap::ImageblockLength`: `crates/metal2vulkan-runtime/src/pipeline.rs (imageblock_memory_length_for_dimensions)`; `crates/metal2vulkan-runtime/src/render.rs (imageblock_sample_length)` - `rt:Gap::PartialSimdgroups`: `crates/metal2vulkan-runtime/src/encoder.rs (decide)` - `rt:Gap::PartialThreadgroups`: `crates/metal2vulkan-runtime/src/encoder.rs (decide)` diff --git a/scripts/metal-coverage/coverage.tsv b/scripts/metal-coverage/coverage.tsv index a02c12622..b0959b1ae 100644 --- a/scripts/metal-coverage/coverage.tsv +++ b/scripts/metal-coverage/coverage.tsv @@ -916,10 +916,10 @@ MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBytes:length:atInd MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBuffer:offset:atIndex: I runtime ComputeCommandEncoder::set_buffer MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBufferOffset:atIndex: I runtime ComputeCommandEncoder::set_buffer_offset MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBuffers:offsets:withRange: I runtime ComputeCommandEncoder::set_buffer a loop of it -MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBuffer:offset:attributeStride:atIndex: M a bind with a per-bind stride, which stage-in and vertex fetch read M encoder-calls -MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBuffers:offsets:attributeStrides:withRange: M a bind with a per-bind stride, which stage-in and vertex fetch read M encoder-calls -MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBufferOffset:attributeStride:atIndex: M a bind with a per-bind stride, which stage-in and vertex fetch read M encoder-calls -MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBytes:length:attributeStride:atIndex: M a bind with a per-bind stride, which stage-in and vertex fetch read M encoder-calls +MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBuffer:offset:attributeStride:atIndex: I runtime ComputeCommandEncoder::set_buffer_with_attribute_stride the stride's low 32 bits +MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBuffers:offsets:attributeStrides:withRange: I runtime ComputeCommandEncoder::set_buffer_with_attribute_stride a loop of it +MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBufferOffset:attributeStride:atIndex: I runtime ComputeCommandEncoder::set_buffer_offset_with_attribute_stride the stride's low 32 bits +MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setBytes:length:attributeStride:atIndex: I runtime ComputeCommandEncoder::set_bytes_with_attribute_stride the stride's low 32 bits MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setVisibleFunctionTable:atBufferIndex: I runtime ComputeCommandEncoder::set_visible_function_table MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setVisibleFunctionTables:withBufferRange: I runtime ComputeCommandEncoder::set_visible_function_table a loop of it MTLComputeCommandEncoder.h MTLComputeCommandEncoder method setIntersectionFunctionTable:atBufferIndex: O ray tracing