From e69068885bfa4034d44f29b1c0e03ee160fa2b8e Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 23 Oct 2026 00:54:12 +0300 Subject: [PATCH] Write a kernel's draw of a primitive type past Metal's five as points, as Metal's encoding does The steps this packet landed as, in order: - Give the private-writes fixture its golden printout and inventory rows - Draw an indirect render command's private primitive types as the encoder's draws of them - Count an injected page fault or hang toward a queue's revocation, as the error it stands for - Drop a unit's ungated dispatches at its unbalanced first record, as Metal does Content: the tree of `development` at 8e08f4d248, unchanged. --- .../src/canon/command_writes.rs | 7 +- .../src/canon/tests/command_buffers.rs | 7 +- crates/metal2vulkan-runtime/README.md | 6 +- .../src/command_buffer/mod.rs | 12 + .../src/command_buffer/revocation.rs | 29 ++- crates/metal2vulkan-runtime/src/encoder.rs | 58 +++++ crates/metal2vulkan-runtime/src/error.rs | 14 +- .../src/indirect_command_buffer.rs | 128 ++++++++--- .../metal2vulkan-runtime/src/predication.rs | 85 ++++--- crates/metal2vulkan-runtime/src/render.rs | 4 +- .../src/render/executions.rs | 63 ++++-- .../metal2vulkan-runtime/src/render_values.rs | 7 +- crates/metal2vulkan-runtime/src/shadow.rs | 8 + .../src/tests/command_buffer.rs | 26 +++ .../fixtures/public/engine/TOOLCHAIN | 1 + .../engine/icb_render_typed_encode.air.ll | 85 +++++++ .../public/engine/icb_render_typed_encode.ll | 84 +++++++ .../engine/icb_render_typed_encode.metal | 28 +++ .../src/metal/platform/predication_tests.rs | 5 +- .../runtime_lane/indirect_command_buffers.rs | 4 +- .../src/runtime_lane/predication.rs | 96 ++------ .../src/runtime_lane/predication_streams.tsv | 31 ++- .../src/runtime_lane/render_executions.rs | 208 +++++++++++++++++- .../src/runtime_lane/render_gpu_executions.rs | 42 ++++ .../metal2vulkan/src/lower/access/encode.rs | 36 ++- .../air_input/icb_render_typed_encode.txt | 112 ++++++++++ .../tests/air_input/rt6_private_writes.txt | 140 ++++++++++++ .../public_fixture_expectations_engine.tsv | 6 + docs/API.md | 13 +- docs/FAST-PATHS.md | 7 + docs/REFUSALS.md | 70 +++--- docs/RUNTIME-PORTING.md | 12 +- scripts/refusal-surface/reach.tsv | 1 - 33 files changed, 1180 insertions(+), 255 deletions(-) create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.air.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.metal create mode 100644 crates/metal2vulkan/tests/air_input/icb_render_typed_encode.txt create mode 100644 crates/metal2vulkan/tests/air_input/rt6_private_writes.txt diff --git a/crates/metal2vulkan-air/src/canon/command_writes.rs b/crates/metal2vulkan-air/src/canon/command_writes.rs index 8d0bb4d1a..eaf3409c6 100644 --- a/crates/metal2vulkan-air/src/canon/command_writes.rs +++ b/crates/metal2vulkan-air/src/canon/command_writes.rs @@ -13,7 +13,9 @@ use crate::ir::{Call, Callee, Const, FuncId, InstKind, Module, ModuleParts, Valu /// /// A draw's primitive type (`draw_primitives` and `draw_indexed_primitives`) counts as the value /// its operand holds where that is a constant of Metal's five (`MTLPrimitiveType`'s raw values, -/// bit `n` for value `n`), and as all five where it is anything else. A call the walk cannot see +/// bit `n` for value `n`), as a point draw where it is a constant past them (Metal's encoding +/// writes one so: the translator's `lower::access::encode`), and as all five where it is anything +/// else. A call the walk cannot see /// into (an indirect call, an intrinsic outside the closed set, a call to a declaration other /// than the entry's control-point functions) may write anything: [`CommandWrites::ANY`]. /// Records the function does not write are not its own fact: a command buffer's other writers @@ -134,7 +136,8 @@ impl CommandWrites { C::DrawPrimitives | C::DrawIndexedPrimitives { .. } => { match call.args.get(2).and_then(|&v| literal(parts, v)) { Some(raw) if raw < 5 => 1 << raw, - _ => CommandWrites::ALL_PRIMITIVE_TYPES, + Some(_) => 1, + None => CommandWrites::ALL_PRIMITIVE_TYPES, } } _ => 0, diff --git a/crates/metal2vulkan-air/src/canon/tests/command_buffers.rs b/crates/metal2vulkan-air/src/canon/tests/command_buffers.rs index 1d5ffeab0..675e934bf 100644 --- a/crates/metal2vulkan-air/src/canon/tests/command_buffers.rs +++ b/crates/metal2vulkan-air/src/canon/tests/command_buffers.rs @@ -255,14 +255,17 @@ fn draw_of(f: &mut FunctionBuilder<'_>, cmd: Value, primitive_type: Value) { } /// An entry that draws a constant primitive type writes that type's bit alone; one whose type -/// is loaded writes every type's; a value past Metal's five is no type, so every type's too. +/// is loaded writes every type's; a value past Metal's five (a private type's, or none) writes a +/// point draw, as Metal's encoding does. #[test] fn a_draw_writes_its_constant_primitive_type() { for (raw, types) in [ (0u64, 0b1), (3, 0b1000), (4, 0b1_0000), - (5, CommandWrites::ALL_PRIMITIVE_TYPES), + (5, 0b1), + (9, 0b1), + (255, 0b1), ] { let e = specialized(|f| { let i32t = f.module().int(32); diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 35eac025b..1c1d378fb 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -234,7 +234,8 @@ Calls Metal does not have, for a consumer that emulates a Metal device: - `RenderCommandEncoder::set_color_resolve_target`, `set_depth_resolve_target` and `set_stencil_resolve_target` change where a pass resolves until it ends (the last target set wins), as Metal's private calls do. -- The four draw calls take a `DrawPrimitiveType`, which every `PrimitiveType` converts into, and +- The four draw calls, and an indirect render command's two, take a `DrawPrimitiveType`, which + every `PrimitiveType` converts into, and whose `LineLoop`, `TriangleFan`, `Quads` and `QuadStrip` are the values 5 to 8 Metal's draws take besides its header's (`DrawPrimitiveType::from_raw`): each draws as the list plain Metal draws, in Metal's vertex order, direct, indexed and indirect, and quads and a quad strip count one @@ -244,7 +245,8 @@ Calls Metal does not have, for a consumer that emulates a Metal device: (`GpuRecoveryVictim`), by the draw's form, running nothing from its encoder on (docs/API.md, "Accepted differences", for the timing and the race over the encoders after a fault); a queue's second hang or page fault revokes it, as Metal's does: its later command buffers fail - at their commit (`AccessRevoked`). + at their commit (`AccessRevoked`). A kernel's draw of a value past the header's draws points, + as Metal's does. - `TextureDescriptor::address_mode_map` presents a texture as sampling by other address modes than its sampler's. - Resource ID reservations, placements and counts (`Device::reserve_resource_ids`, diff --git a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs index 4eedd48c0..f6cad056b 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs @@ -1394,6 +1394,18 @@ impl State { self.failed_at_commit = Some(failure.encoders); } + /// A command-predication record dropped what the ended encoders from `first` on recorded, + /// its unit's earlier encoders (`predication.rs`): each of their parts runs nothing, as a + /// failed encoder's ([`fail_part`](Self::fail_part)). + pub(super) fn leave_out_ended(&mut self, first: usize) { + let State { + recorded, retained, .. + } = self; + for part in recorded.iter_mut().filter(|part| part.encoder >= first) { + State::fail_part(part, retained); + } + } + /// A failed encoder's recorded `part` runs nothing: its segments (with their recordings), /// sparse updates and writes into ASTC carriers go to `retained`, released with what the /// command buffer retained without this lock, its `VkCommandBuffer`s are left unsubmitted, diff --git a/crates/metal2vulkan-runtime/src/command_buffer/revocation.rs b/crates/metal2vulkan-runtime/src/command_buffer/revocation.rs index 2f1b7ac5f..0d697c9bf 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/revocation.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/revocation.rs @@ -28,8 +28,12 @@ //! making that Metal's GPU causes: [`CommandBufferError::PageFault`] as the runtime fails an //! encoder Metal's GPU faults (a draw of primitive type 9 over indices, a render encoder's //! execution of an indirect command buffer under a state it cannot inherit), and -//! [`CommandBufferError::GpuHang`]. A failure the driver relays is the driver's own queue's, -//! which Metal counts itself under MoltenVK. From the completion of the second one, before its +//! [`CommandBufferError::GpuHang`]; and one a program commits as failed in their place +//! (`CommandBuffer::commit_failed`, [`CommandBufferError::Injected`] of Metal's code of either, +//! 3 or 2), which stands for what Metal's GPU caused. Of the other codes it counts none: a +//! victim's (1) does not count on Metal, and the rest are not caused GPU errors or not measured. +//! A failure the driver relays is the driver's own queue's, which Metal counts itself under +//! MoltenVK. From the completion of the second one, before its //! status reads final, the queue is revoked: a command buffer committed on it then fails with //! [`CommandBufferError::AccessRevoked`] as its commit's work, from its first encoder, its event //! signals dropped (`commit_now`). One committed before runs as committed, whatever its event @@ -50,12 +54,9 @@ pub(crate) struct QueueErrors { impl QueueErrors { /// A command buffer of the queue completes with `error` (`None` for none), before its status - /// reads final: counted where the GPU caused it. + /// reads final: counted where the GPU caused it ([`caused`]). pub(super) fn completed(&self, error: Option) { - if matches!( - error, - Some(CommandBufferError::PageFault | CommandBufferError::GpuHang) - ) { + if error.is_some_and(caused) { self.caused.fetch_add(1, Ordering::SeqCst); } } @@ -66,3 +67,17 @@ impl QueueErrors { self.caused.load(Ordering::SeqCst) >= REVOKING } } + +/// Whether a command buffer that completed with `error` counts against its queue (the module +/// docs): a page fault or a hang, the runtime's or one a program injected in its place by its +/// Metal code. +pub(crate) fn caused(error: CommandBufferError) -> bool { + let of = |caused: CommandBufferError| caused.metal_code(); + match error { + CommandBufferError::PageFault | CommandBufferError::GpuHang => true, + CommandBufferError::Injected(code) => { + code == of(CommandBufferError::PageFault) || code == of(CommandBufferError::GpuHang) + } + _ => false, + } +} diff --git a/crates/metal2vulkan-runtime/src/encoder.rs b/crates/metal2vulkan-runtime/src/encoder.rs index 48e1a25a3..b9cb0463b 100644 --- a/crates/metal2vulkan-runtime/src/encoder.rs +++ b/crates/metal2vulkan-runtime/src/encoder.rs @@ -237,6 +237,9 @@ pub(super) struct EncoderCore { ended: Vec, /// The segments it left for commit, `executions_at` counting its own executions. segments: Vec, + /// Its first parts, which a command-predication record left out of the command buffer's + /// work ([`leave_out_recorded`](Self::leave_out_recorded)): each ends running nothing. + left_out: usize, /// The order of the encoder's commands, and its summary. uses: EncoderUses, /// The uses of the command [`note_reaching`](Self::note_reaching) notes, with those of the @@ -446,6 +449,7 @@ impl EncoderCore { pass: None, ended: Vec::new(), segments: Vec::new(), + left_out: 0, uses: EncoderUses::new(ordered), retained: Retained::default(), executions: Vec::new(), @@ -528,6 +532,7 @@ impl EncoderCore { pass: None, ended: Vec::new(), segments: Vec::new(), + left_out: 0, uses: EncoderUses::new(ordered), retained: Retained::default(), executions: Vec::new(), @@ -1713,6 +1718,40 @@ impl EncoderCore { self.defer(work) } + /// Leave what the encoder recorded so far out of the command buffer's work, as a + /// command-predication record that drops it does (`predication.rs`): its `VkCommandBuffer`s so + /// far, ended, are never submitted; the work it left apart is never recorded, and is held as + /// what its commands use is; the textures it shadows are forgotten unread, so nothing is + /// copied back and a later command copies in again; and its later commands go on in a new + /// `VkCommandBuffer`, in a part of their own, which needs no barrier after the commands left + /// out. Its parts so far end as a failed encoder's do, with their fences' waits alone + /// ([`end_with_replay`](Self::end_with_replay)). Refused where no new one can be made, or the + /// current one does not end, which abandons the command buffer. + pub(super) fn leave_out_recorded(&mut self) -> Result<(), Error> { + self.release_pass()?; + self.flush_gathers(); + let next = self.continuation()?; + if self.raw != vk::CommandBuffer::null() { + // SAFETY: as in `barrier`. + if let Err(error) = unsafe { self.open.command_buffer.end_raw(self.raw) } { + self.open.command_buffer.state().abandoned = true; + return Err(vulkan(error)); + } + } + self.raw = next.0; + self.recorded = false; + self.ended.clear(); + // A segment the GPU may write what it reads for started a part of its own. + self.left_out += 1 + self.segments.iter().filter(|segment| segment.host).count(); + for segment in self.segments.drain(..) { + self.retained + .boxed(Box::new((segment.work, segment.inputs))); + } + self.uses.split(); + self.shadows.forget(); + Ok(()) + } + /// Begin `raw`, a `VkCommandBuffer` the command buffer's pool just handed out, with `flags`. fn begin( &self, @@ -1886,6 +1925,7 @@ impl EncoderCore { raw, mut ended, segments, + left_out, uses, retained, executions, @@ -1949,6 +1989,24 @@ impl EncoderCore { .replay_log_kept(bytes); } let mut summaries = uses.finish_parts().into_iter(); + // The parts a command-predication record left out run nothing, each with its fences' + // waits alone (`leave_out_recorded`), in the batch the encoder's first part joins. + for _ in 0..left_out { + let summary = summaries + .next() + .ok_or_else(|| internal("an encoder's part without its summary"))?; + state.end_encoder( + &open.command_buffer, + Recorded { + encoder, + raws: Vec::new(), + segments: Vec::new(), + summary: summary.fences_only(), + sparse: Vec::new(), + twin_writes: Vec::new(), + }, + ); + } let parts = into_parts(ended, segments, base); // The writes into ASTC carriers go with the last part (a blit encoder's only one). let count = parts.len(); diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index 8a7cc75a4..b05107160 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -1511,13 +1511,6 @@ pub enum RuntimeGap { /// The attachment's pixel format. pixel_format: PixelFormat, }, - /// An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the - /// other ends, or `encode_start_else`, with no block open; `encode_start_if` on a nil buffer - /// with none) that is its unit's first record, after dispatches of the unit (of this encoder, - /// or of an earlier one of its unit). Metal answers NO and drops those dispatches, which have - /// run nothing; the runtime recorded them ungated, before any record, so it cannot drop them. - /// Every other unbalanced record runs as Metal's does. - PredicationDropsUngatedWork, /// A blit copy between a buffer and a multisampled texture (`copyFromBuffer:...toTexture:` /// into, or `copyFromTexture:...toBuffer:` out of, a texture of more than one sample). /// Vulkan copies no multisampled image to or from a buffer (its `vkCmdCopyBufferToImage` and @@ -1649,7 +1642,9 @@ pub enum CommandBufferError { /// `commit`'s would be. Refused, /// The program committed the command buffer as failed, with this `MTLCommandBufferError` - /// code ([`CommandBuffer::commit_failed`](crate::CommandBuffer::commit_failed)). + /// code ([`CommandBuffer::commit_failed`](crate::CommandBuffer::commit_failed)). Of Metal's + /// codes of a page fault (3) and a hang (2), it counts against its queue as the error it + /// stands for does ([`AccessRevoked`](Self::AccessRevoked)); of any other code, not. Injected(u64), /// The command buffer encoded a render pass without attachments whose /// `renderTargetWidth` or `renderTargetHeight` is past 16384, which Metal's encoder takes: @@ -1718,7 +1713,8 @@ pub enum CommandBufferError { /// count against its queue. GpuRecoveryVictim, /// Metal ignored the command buffer, committed on a queue whose second command buffer with a - /// GPU error it caused ([`PageFault`](Self::PageFault), [`GpuHang`](Self::GpuHang); not a + /// GPU error it caused ([`PageFault`](Self::PageFault), [`GpuHang`](Self::GpuHang), or + /// [`Injected`](Self::Injected) of Metal's code of either; not a /// [`GpuRecoveryVictim`](Self::GpuRecoveryVictim)) had completed: /// `MTLCommandBufferErrorAccessRevoked` (4, "Ignored (for causing prior/excessive GPU errors) /// (00000004:kIOGPUCommandBufferCallbackErrorSubmissionsIgnored)" on the M3 Max, macOS diff --git a/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs b/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs index 520fc4715..55b56f8f3 100644 --- a/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs +++ b/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs @@ -78,6 +78,7 @@ use super::pipeline::{ }; use super::released_programs::{KeptProgram, KeptPrograms}; use super::render::{index_size, DrawProblem}; +use super::render_values::DrawPrimitiveType; use super::resource_ids::{records_placement, HolderThen, IdPlacement, ResourceId, StateKind}; use super::unique_identifier::{degrade_identifier, state_value_degradation, UniqueIdentifier}; use super::values::{Origin, Region, Size}; @@ -596,6 +597,7 @@ impl Device { unforeseen: Mutex::new(Vec::new()), cpu_writes: AtomicU64::new(0), barriers: AtomicBool::new(false), + nines: AtomicBool::new(false), overflow, tail: Mutex::default(), gpu_writes: Arc::default(), @@ -960,6 +962,9 @@ struct IcbShared { /// The CPU set a render command's barrier: an execution's render pass instance may split at /// it (`render/executions.rs`), for good. barriers: AtomicBool, + /// The CPU drew primitive type 9 in a render command: an execution looks for it among the + /// commands it runs ([`nine_among`](IndirectCommandBuffer::nine_among)), for good. + nines: AtomicBool, /// The buffer slots past the record's, where the descriptor counts more, and a compute /// buffer's threadgroup lengths 31 to 37 ([`Overflow`]). overflow: Option, @@ -2401,6 +2406,35 @@ impl IndirectCommandBuffer { self.0.barriers.load(Ordering::Acquire) } + /// How the first draw of primitive type 9 among commands `range` (inside the size), as their + /// records stand, fails the command buffer that executes them, as Metal's GPU fails it there + /// (`DrawPrimitiveType::Nine`; measured through indirect command buffers too): `None` where + /// none draws one that fails it, and at once where the CPU never drew one. A kernel writes no + /// such draw (it writes points). + pub(super) fn nine_among(&self, range: Range) -> Result, Error> { + if !self.0.nines.load(Ordering::Acquire) { + return Ok(None); + } + let nine = DrawPrimitiveType::Nine.raw() as u32; + for index in range { + match self.record(index)?.action { + Action::DrawPrimitives { + primitive_type, + vertex_count, + instance_count, + .. + } if primitive_type == nine && vertex_count >= 3 && instance_count > 0 => { + return Ok(Some(NineDraw::Hangs)); + } + Action::DrawIndexedPrimitives { primitive_type, .. } if primitive_type == nine => { + return Ok(Some(NineDraw::Faults)); + } + _ => {} + } + } + Ok(None) + } + /// Whether a render command's record may hold a barrier: the CPU set one /// ([`held_a_barrier`](Self::held_a_barrier)), or the GPU may have written the records (a /// kernel's `set_barrier`, or a blit copy of a command that holds one). @@ -3046,7 +3080,7 @@ fn dispatch_of(action: &Action) -> Option { } /// A record's draw, of `action`: none for an action that draws nothing, and for a draw of a -/// primitive type or an index type Metal has no value for (a kernel's write), which runs nothing. +/// primitive type or an index type Metal has no value for, which runs nothing. fn draw_of(action: &Action) -> Option { let size = |[width, height, depth]: [u32; 3]| Size::new(width.into(), height.into(), depth.into()); @@ -3057,7 +3091,7 @@ fn draw_of(action: &Action) -> Option { vertex_count, instance_count, base_instance, - } => PrimitiveType::try_from(primitive_type) + } => DrawPrimitiveType::from_raw(primitive_type.into()) .ok() .map(|primitive_type| IndirectDraw::Primitives { primitive_type, @@ -3074,7 +3108,7 @@ fn draw_of(action: &Action) -> Option { instance_count, base_vertex, base_instance, - } => PrimitiveType::try_from(primitive_type) + } => DrawPrimitiveType::from_raw(primitive_type.into()) .ok() .zip(IndexType::try_from(index_type).ok()) .map( @@ -3939,9 +3973,13 @@ impl IndirectRenderCommand { /// `drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:`: the command draws /// `vertex_count` vertices of `primitive_type` from `vertex_start`, `instance_count` times /// from `base_instance`, each value's low 32 bits, which the record holds (Metal takes larger - /// values; what it keeps of them is not measured: its getter answers an object). A draw of no - /// vertices or no instances runs nothing, as plain Metal runs it where its validation stops - /// the call ("instanceCount(0) must be non-zero"). The records of every render buffer but one + /// values; what it keeps of them is not measured: its getter answers an object). A type is a + /// public one or one of Metal's private ones ([`DrawPrimitiveType`]), which an execution draws + /// as an encoder's draw of it draws, type 9 failing the command buffer so where an execution + /// of a range given at its call finds it there (the M3 Max, macOS 27.0.1: types 5 to 9 drew + /// and failed as the encoder's draws of them, direct and indexed). A draw of no vertices or + /// no instances runs nothing, as plain Metal runs it where its validation stops the call + /// ("instanceCount(0) must be non-zero"). The records of every render buffer but one /// of mesh draws alone hold it: on a buffer whose command types lack `DRAW` it runs as on its /// own, as plain Metal runs it, where Metal's validation stops the call ("drawPrimitives is not /// enabled on this indirect command buffer"). Refused (`Invalid`): a buffer of mesh draws alone @@ -3949,7 +3987,7 @@ impl IndirectRenderCommand { /// of either mesh kind and of both, the encoder's pipeline inherited). pub fn draw_primitives( &self, - primitive_type: PrimitiveType, + primitive_type: impl Into, vertex_start: u64, vertex_count: u64, instance_count: u64, @@ -3959,39 +3997,44 @@ impl IndirectRenderCommand { if self.of_compute() { return Ok(()); } + let primitive_type = primitive_type.into(); let action = Action::DrawPrimitives { - primitive_type: primitive_type.as_raw(), + primitive_type: primitive_type.raw() as u32, vertex_start: vertex_start as u32, vertex_count: vertex_count as u32, instance_count: instance_count as u32, base_instance: base_instance as u32, }; self.check_draw(CALL, IndirectCommandType::DRAW, &action)?; - self.edit(CALL, RecordField::Action(action), None) + self.edit(CALL, RecordField::Action(action), None)?; + self.drew(primitive_type); + Ok(()) } /// `drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount: /// baseVertex:baseInstance:`: the command draws `index_count` indices of `index_type` from /// `index_buffer_offset` of `index_buffer`, `instance_count` times from `base_instance`, each - /// index plus `base_vertex`. The record holds the buffer as one address (its `gpu_address` - /// plus the offset's low 32 bits, as Metal keeps it; its validation checks the whole offset, as - /// the refusal below does), which an execution resolves against the encoder's resident - /// resources (`render/executions.rs`), and each value's low 32 bits, `base_vertex` as a signed - /// one: Metal keeps a base vertex's so (a count past 32 bits always runs past the buffer, which - /// is refused). It runs as on its own on a buffer of patch draws, whose records hold it, as - /// plain Metal runs it, where Metal's validation stops a buffer whose command types lack - /// `DRAW_INDEXED`. A draw of no indices or no instances runs nothing, and the indices are read - /// from the offset rounded down to a multiple of the index size, as plain Metal runs them where - /// its validation stops the call (`idx_count_zero`, `idx_instances_zero`; 32-bit indices at - /// offset 2 and 16-bit ones at 1 drew those at 0). Refused (`Invalid`): a buffer of draws of - /// primitives alone, whose records cannot hold it (`CommandType`; plain Metal's GPU faults), or - /// of mesh draws alone (`CommandType`; Metal's process ends), and, as Metal's - /// validation stops it, indices past the buffer's length from that offset (`IndexBufferRange`, - /// of the whole count; plain Metal draws from whatever memory follows), and an index buffer of - /// another device. + /// index plus `base_vertex`, of a public primitive type or a private one, as + /// [`draw_primitives`](Self::draw_primitives) says (type 9 faults the command buffer, of any + /// index or instance count, as the encoder's draw does). The record holds the buffer as one + /// address (its `gpu_address` plus the offset's low 32 bits, as Metal keeps it; its validation + /// checks the whole offset, as the refusal below does), which an execution resolves against + /// the encoder's resident resources (`render/executions.rs`), and each value's low 32 bits, + /// `base_vertex` as a signed one: Metal keeps a base vertex's so (a count past 32 bits always + /// runs past the buffer, which is refused). It runs as on its own on a buffer of patch draws, + /// whose records hold it, as plain Metal runs it, where Metal's validation stops a buffer + /// whose command types lack `DRAW_INDEXED`. A draw of no indices or no instances runs nothing + /// (but type 9's), and the indices are read from the offset rounded down to a multiple of the + /// index size, as plain Metal runs them where its validation stops the call + /// (`idx_count_zero`, `idx_instances_zero`; 32-bit indices at offset 2 and 16-bit ones at 1 + /// drew those at 0). Refused (`Invalid`): a buffer of draws of primitives alone, whose records + /// cannot hold it (`CommandType`; plain Metal's GPU faults), or of mesh draws alone + /// (`CommandType`; Metal's process ends), and, as Metal's validation stops it, indices past + /// the buffer's length from that offset (`IndexBufferRange`, of the whole count; plain Metal + /// draws from whatever memory follows), and an index buffer of another device. pub fn draw_indexed_primitives( &self, - primitive_type: PrimitiveType, + primitive_type: impl Into, index_count: u64, index_type: IndexType, index_buffer: &Buffer, @@ -4001,8 +4044,9 @@ impl IndirectRenderCommand { base_instance: u64, ) -> Result<(), Error> { const CALL: &str = "draw_indexed_primitives"; + let primitive_type = primitive_type.into(); let action = Action::DrawIndexedPrimitives { - primitive_type: primitive_type.as_raw(), + primitive_type: primitive_type.raw() as u32, index_count: index_count as u32, index_type: index_type.as_raw(), index_buffer: index_buffer.gpu_address().0 + u64::from(index_buffer_offset as u32), @@ -4030,7 +4074,17 @@ impl IndirectRenderCommand { }), )); } - self.edit(CALL, RecordField::Action(action), None) + self.edit(CALL, RecordField::Action(action), None)?; + self.drew(primitive_type); + Ok(()) + } + + /// The command now draws `primitive_type`: a draw of type 9 marks its buffer for the + /// executions that look for one ([`IndirectCommandBuffer::nine_among`]). + fn drew(&self, primitive_type: DrawPrimitiveType) { + if primitive_type == DrawPrimitiveType::Nine { + self.icb.0.nines.store(true, Ordering::Release); + } } /// `drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount: @@ -4627,14 +4681,24 @@ impl EncodedRenderCommand { } } +/// How a draw of primitive type 9 among an execution's commands fails its command buffer +/// ([`IndirectCommandBuffer::nine_among`]). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum NineDraw { + /// A direct draw of 3 vertices or more: Metal's GPU hangs at it. + Hangs, + /// An indexed draw: Metal's GPU faults at it. + Faults, +} + /// A render command's draw. #[non_exhaustive] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum IndirectDraw { /// `drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:`. Primitives { - /// `primitiveType`. - primitive_type: PrimitiveType, + /// `primitiveType`: a public type or one of Metal's private ones. + primitive_type: DrawPrimitiveType, /// `vertexStart`. vertex_start: u64, /// `vertexCount`. @@ -4647,8 +4711,8 @@ pub enum IndirectDraw { /// `drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount: /// baseVertex:baseInstance:`: the index buffer as the address of its first index. IndexedPrimitives { - /// `primitiveType`. - primitive_type: PrimitiveType, + /// `primitiveType`: a public type or one of Metal's private ones. + primitive_type: DrawPrimitiveType, /// `indexCount`. index_count: u64, /// `indexType`. diff --git a/crates/metal2vulkan-runtime/src/predication.rs b/crates/metal2vulkan-runtime/src/predication.rs index 40bb31eb1..8f860fd37 100644 --- a/crates/metal2vulkan-runtime/src/predication.rs +++ b/crates/metal2vulkan-runtime/src/predication.rs @@ -93,9 +93,14 @@ //! - **A dropped range** rewrites its anchor's step as `PredicationOp::Drop` and every step since //! as `PredicationOp::Hold` (or, anchored at the unit's start, records a `Drop` step at the //! record), so its gated dispatches run nothing; the next record first records a -//! `PredicationOp::Resume`. A range anchored at the unit's start whose work the runtime ran -//! ungated (the unit's dispatches before its first record) cannot be dropped: refused -//! ([`RuntimeGap::PredicationDropsUngatedWork`]). +//! `PredicationOp::Resume`. The unit's dispatches before its first record run ungated, so a +//! program that never records pays nothing for predication; where that first record is +//! unbalanced and such dispatches came before it, what the unit's encoders recorded before the +//! record is left out of the command buffer's work instead: its earlier encoders' parts and +//! what the open encoder recorded so far (its `VkCommandBuffer`s and the work it left apart) +//! are never submitted, as a failed encoder's are, their fences' waits kept, and the open +//! encoder forgets the textures it shadows unread and goes on, from the record's `Drop` step, +//! in a part of its own (`EncoderCore::leave_out_recorded`). //! - **A block open where its unit ends**: each compute encoder that ends with a live block open //! records a `PredicationOp::UnitEnd` step, which writes whether the counter skips into the //! unit's check word; where the unit ended so, a set word fails the command buffer at its @@ -134,7 +139,7 @@ use super::compute::{ComputeCommandEncoder, EncoderState}; use super::deferred::Deferred; use super::degradation::Degradation; use super::encoder::EncoderCore; -use super::error::{internal, Error, RuntimeGap}; +use super::error::{internal, Error}; use super::indirect_command_buffer::IndirectCommandBuffer; use super::owned_kernel::{OwnedBinds, OwnedKernel, OwnedModule, OwnedSet}; use super::residency::Residency; @@ -178,6 +183,10 @@ pub(super) struct Predication { /// The steps and gated dispatches recorded so far: what a loop's copies lay down is counted /// from it ([`copies_of`]). laid: u64, + /// An unbalanced record just dropped what its unit's encoders recorded before it, from the + /// encoder at this place among the command buffer's ended encoders on, which the open encoder + /// leaves out of the command buffer's work ([`take_left_out`](Self::take_left_out)). + left_out: Option, } /// The laying of a unit's outermost loop: its pieces in encoding order (`command_buffer/rerun.rs`), @@ -413,6 +422,8 @@ struct IndirectRun { /// One unit of predication. struct Unit { + /// The place among the command buffer's ended encoders its first compute encoder takes. + first: usize, /// The place among the command buffer's ended encoders its last compute encoder takes. place: usize, /// The event waits and signals encoded before it. @@ -506,6 +517,7 @@ struct Run { impl Unit { fn new(place: usize, events: (usize, usize), dispatch_type: DispatchType) -> Unit { Unit { + first: place, place, events, dispatch_type, @@ -723,9 +735,9 @@ impl Predication { } /// An unbalanced record (the module docs): its range drops from the anchor on; the step to - /// record, where the range starts at the unit's start. Refused, changing nothing: a range from - /// the unit's start over dispatches the runtime ran ungated - /// ([`RuntimeGap::PredicationDropsUngatedWork`]). + /// record, where the range starts at the unit's start. Where the unit's dispatches before the + /// record ran ungated, what its encoders recorded so far is left out + /// ([`take_left_out`](Self::take_left_out)). fn unbalanced( &mut self, uploads: &mut Uploads, @@ -743,18 +755,25 @@ impl Predication { range.dropping = true; return Ok(None); } - if range.work { - return Err(Error::NotImplemented( - RuntimeGap::PredicationDropsUngatedWork, - )); - } let record = self.step(uploads, device, (None, None), |counter| { PredicationStep::new(counter, PredicationOp::Drop) })?; - self.unit()?.range.dropping = true; + let unit = self.unit()?; + unit.range.dropping = true; + let left_out = unit.range.work.then_some(unit.first); + self.left_out = left_out.or(self.left_out); Ok(Some(record)) } + /// Where the last record dropped what its unit's encoders recorded before it, dispatches the + /// runtime ran ungated among it (the module docs): the place of the unit's first encoder + /// among the command buffer's ended encoders. The open encoder leaves out of the command + /// buffer's work every part of those encoders and what it recorded itself so far, before the + /// record's step. + pub(super) fn take_left_out(&mut self) -> Option { + self.left_out.take() + } + /// A Start with no block open, before its own step: where a range is dropping, the `Resume` /// step to record first, and whether the block it opens is killed from its start (the range /// held no work Metal emitted). @@ -1412,7 +1431,9 @@ impl ComputeCommandEncoder { } /// Run `record` on the command buffer's predication with its arena, under its lock, the - /// encoder's dispatches since its last record noted first. + /// encoder's dispatches since its last record noted first. Where it dropped what the unit's + /// encoders recorded before it, dispatches that ran ungated among it, that is left out of the + /// command buffer's work (`Predication::take_left_out`), before what it returns is recorded. fn predication( &mut self, record: impl FnOnce(&mut Predication, &mut Uploads, &Device) -> Result, @@ -1424,13 +1445,24 @@ impl ComputeCommandEncoder { self.captures().worked = false; let core = self.core(); let device = core.device().clone(); - let mut state = core.command_buffer().state(); - let state = &mut *state; - state.predicated = true; - if let Some(unit) = &mut state.predication.unit { - unit.note_work(worked); + let (recorded, left_out) = { + let mut state = core.command_buffer().state(); + let state = &mut *state; + state.predicated = true; + if let Some(unit) = &mut state.predication.unit { + unit.note_work(worked); + } + let recorded = record(&mut state.predication, &mut state.uploads, &device)?; + let left_out = state.predication.take_left_out(); + if let Some(first) = left_out { + state.leave_out_ended(first); + } + (recorded, left_out.is_some()) + }; + if left_out { + self.core().leave_out_recorded()?; } - record(&mut state.predication, &mut state.uploads, &device) + Ok(recorded) } /// The encoder dispatched, or executed an indirect command buffer's commands: work Metal @@ -1726,9 +1758,7 @@ impl ComputeCommandEncoder { /// Metal reads memory unrelated to the buffer, which the runtime reads as zero, announced /// (`Degradation::PredicationWordPastBuffer`). /// - /// Refused, recording nothing: a buffer of another device (`Invalid`); a nil buffer with no - /// block open whose range holds the unit's dispatches from before its first record - /// (`NotImplemented(PredicationDropsUngatedWork)`). + /// Refused, recording nothing: a buffer of another device (`Invalid`). pub fn encode_start_if( &mut self, buffer: Option<&Buffer>, @@ -1778,9 +1808,6 @@ impl ComputeCommandEncoder { /// `encodeEndIf`, run where its condition failed (the module docs). A second Else in one If, or /// an Else on a loop, kills the outermost open block, as Metal's does; with no block open it is /// an unbalanced record, as Metal's is. - /// - /// Refused, recording nothing: no block open where its range holds the unit's dispatches from - /// before its first record (`NotImplemented(PredicationDropsUngatedWork)`). pub fn encode_start_else(&mut self) -> Result<(), Error> { let result = self.encode_start_else_uncounted(); self.counted(result) @@ -1802,8 +1829,6 @@ impl ComputeCommandEncoder { /// outermost open block and answers `NO`; inside a block a misused record killed, `NO` but /// for the End that closes that block; with no block open it is an unbalanced record, /// answering `NO` (the module docs). - /// - /// Refused, recording nothing: as [`encode_start_else`](Self::encode_start_else) refuses. pub fn encode_end_if(&mut self) -> Result { let result = self.encode_end_if_uncounted(); self.counted(result) @@ -1875,7 +1900,7 @@ impl ComputeCommandEncoder { /// `encodeStartDoWhile` (SPI): the commands encoded after it, up to its `encodeEndDoWhile`, /// run, and again while that End's condition holds after each run, as - /// [`encode_start_while`](Self::encode_start_while)'s run, laid down and refused as there. + /// [`encode_start_while`](Self::encode_start_while)'s run, laid down as there. pub fn encode_start_do_while(&mut self) -> Result<(), Error> { let result = self.encode_start_do_while_uncounted(); self.counted(result) @@ -1890,8 +1915,6 @@ impl ComputeCommandEncoder { /// `encodeEndWhile` (SPI): closes the open While loop, answering Metal's `YES`; on another /// block it kills the outermost open block and answers `NO`; with no block open it is an /// unbalanced record, answering `NO` (the module docs). - /// - /// Refused, recording nothing: as [`encode_start_else`](Self::encode_start_else) refuses. pub fn encode_end_while(&mut self) -> Result { let result = self.encode_end_while_uncounted(); self.counted(result) diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs index 747f9e94c..96f4e9300 100644 --- a/crates/metal2vulkan-runtime/src/render.rs +++ b/crates/metal2vulkan-runtime/src/render.rs @@ -6937,8 +6937,8 @@ impl RenderLowering { /// A draw of primitive type 9 (`DrawPrimitiveType::Nine`), by `call`, `empty` where it has /// no vertices, indices or instances: it records nothing, and fails the command buffer as - /// `failure` says, as Metal's GPU does: a hang fails it from the encoder on and holds it - /// (`command_buffer/hang.rs`), a fault fails the encoder alone. Checked as a draw of a public + /// `failure` says, as Metal's GPU does: a hang or a fault fails it from the encoder on and + /// holds it (`command_buffer/hang.rs`). Checked as a draw of a public /// type is (a pipeline state set, a draw kind it takes); under a tessellation pipeline it /// draws nothing, as a public type's draw does there. fn draw_nine( diff --git a/crates/metal2vulkan-runtime/src/render/executions.rs b/crates/metal2vulkan-runtime/src/render/executions.rs index 89d8d0925..858fa747c 100644 --- a/crates/metal2vulkan-runtime/src/render/executions.rs +++ b/crates/metal2vulkan-runtime/src/render/executions.rs @@ -223,9 +223,19 @@ //! host step records the pass from the copy once the work before it completed. A draw of the same //! pass that writes the range before the execution is read by Metal's; the copy would not see it, //! so a range a draw of the encoder before the call may write is refused. +//! - **Metal's private primitive types** (`DrawPrimitiveType`, which the CPU's draws take; a +//! kernel writes points for them, as Metal's encoding does). A command's draw of types 5 to 8 +//! draws as the encoder's draw of the type does, the list its program writes. One of type 9 +//! among a range given at the call, as the records stand then, fails the command buffer there +//! as the encoder's draw does, the encoder running nothing (`IndirectCommandBuffer::nine_among`; +//! the M3 Max, macOS 27.0.1: a direct one of 3 vertices or more hung, an indexed one of any +//! count faulted, as the encoder's); one the step meets, written after the call or among a +//! range read from a buffer, runs nothing (`RECORD`), where Metal's GPU fails the command buffer +//! (`docs/FAST-PATHS.md`, known gaps). //! - **Faults** (`bind::ReplayFaults`, the execution report's). A header holding a producer's //! sticky encoding fault runs no command (`ENCODING`); a record that does not decode, sets what -//! the descriptor does not allow, names a primitive or index type Metal has no value for, sets +//! the descriptor does not allow, names a primitive or index type Metal has no value for (or +//! type 9, above), sets //! a barrier, which Metal enables only for mesh draws, has no index or factor buffer (which //! ends Metal's process), a buffer offset Metal's validation stops and plain Metal's answer to //! is not measured (an odd factor buffer offset or factor instance stride; one 2 past a @@ -244,10 +254,10 @@ //! from a buffer that a draw of the encoder before the call may write, are //! `NotImplemented(IndirectRenderCommands)`. What a command's draw refuses (a pipeline of //! other formats than the pass's, among others) is refused so: it either refuses the commit, -//! or fails -//! the command buffer where the step records it, `CommandBufferError::Refused` with the same -//! refusal typed (`CommandBuffer::refusal`). The call checks no record: Metal lets a program -//! write the records until it commits. A command's vertex buffer set without an +//! or fails the command buffer where the step records it, `CommandBufferError::Refused` with +//! the same refusal typed (`CommandBuffer::refusal`). The call checks no record but for type 9 +//! (above): Metal lets a program write the records until it commits. A command's vertex buffer +//! set without an //! attribute stride, where its pipeline state's layout of `MTLBufferLayoutStrideDynamic` reads //! the stride, is refused so too (`Invalid`, `IndirectCommandBufferProblem::UnstridedBuffer`): //! Metal reads it at stride 2^32 - 1 with no bounds check, so past vertex 0 its answer is @@ -285,7 +295,7 @@ use crate::executed_commands::{ExecutedCommand, RecordsRead}; use crate::fragment_imageblock::PassImageblock; use crate::indirect_command_buffer::{ IndirectCommandBuffer, IndirectCommandBufferProblem, IndirectCommandCheck, - IndirectCommandCheckNeeds, Reader, + IndirectCommandCheckNeeds, NineDraw, Reader, }; use crate::indirect_dispatch; use crate::indirect_execute::{self, ExecutionRange}; @@ -297,6 +307,7 @@ use crate::rate_mapped_pass::RateMappedPass; use crate::render_pass::{ColorTarget, PassLayout, Target}; use crate::render_state::EncoderState; use crate::render_target::{self, Feedback, PassShape, Position, RenderPassObject}; +use crate::render_values::DrawPrimitiveType; use crate::residency::{every_render_stage, Residency}; use crate::resource::ResourceKey; use crate::sample_planes::{PlanesCommands, PlanesStep}; @@ -397,6 +408,15 @@ impl RenderLowering { Inherited::Commands => None, Inherited::Encoder(state) => Some(state), }; + // A draw of primitive type 9 among the commands as their records stand fails the command + // buffer as Metal's GPU fails it there, the encoder running nothing. + if let Some(nine) = icb.nine_among(range.clone())? { + match nine { + NineDraw::Hangs => self.core.hang(), + NineDraw::Faults => self.core.fault(CommandBufferError::PageFault), + } + return Ok(()); + } self.degrade_repeated_start(icb, &range); self.defer_execution(icb, ExecutionRange::Fixed(range), pipeline, check) } @@ -1371,7 +1391,8 @@ enum Asked { /// A command's draw, its buffers as `B`: the addresses the record holds, or the resident buffers /// and offsets they resolve to. enum Draw { - Primitives(PrimitiveType, DrawCall), + /// A draw without indices of a type other than 9 (`Assembly::of`). + Primitives(Assembly, DrawCall), /// A mesh draw's grid, and its object and mesh threadgroups' threads. Mesh(MeshGrid, [u32; 3], [u32; 3]), Indexed(IndexedDraw, B), @@ -1426,7 +1447,11 @@ impl Asked { instance_count, base_instance, } => { - let Ok(primitive_type) = PrimitiveType::try_from(primitive_type) else { + // Type 9 the call did not find (`RenderLowering::execute_range`) runs nothing. + let Some(assembly) = DrawPrimitiveType::from_raw(primitive_type.into()) + .ok() + .and_then(Assembly::of) + else { return Asked::Fault; }; if vertex_count == 0 || instance_count == 0 { @@ -1438,7 +1463,7 @@ impl Asked { instance_count, base_instance, }; - Asked::Draw(Draw::Primitives(primitive_type, draw)) + Asked::Draw(Draw::Primitives(assembly, draw)) } Action::DrawIndexedPrimitives { primitive_type, @@ -1449,12 +1474,16 @@ impl Asked { base_vertex, base_instance, } => { + // Type 9 the call did not find (`RenderLowering::execute_range`) runs nothing. let (Ok(primitive_type), Ok(index_type)) = ( - PrimitiveType::try_from(primitive_type), + DrawPrimitiveType::from_raw(primitive_type.into()), IndexType::try_from(index_type), ) else { return Asked::Fault; }; + if primitive_type == DrawPrimitiveType::Nine { + return Asked::Fault; + } // Metal ends the process for no index buffer. if index_buffer == 0 { return Asked::Fault; @@ -1463,7 +1492,7 @@ impl Asked { return Asked::Nothing; } let draw = IndexedDraw { - primitive_type: primitive_type.into(), + primitive_type, index_count, index_type, instance_count, @@ -1632,7 +1661,7 @@ impl Draw { resolve(address, 1).map(|(b, offset)| (b, offset - offset % multiple)) }; let resolved = match self { - Draw::Primitives(primitive_type, draw) => Ok(Draw::Primitives(primitive_type, draw)), + Draw::Primitives(assembly, draw) => Ok(Draw::Primitives(assembly, draw)), Draw::Mesh(grid, object, mesh) => Ok(Draw::Mesh(grid, object, mesh)), Draw::Indexed(draw, address) => rounded(address, index_size(draw.index_type)) .map(|index| Draw::Indexed(draw, index)), @@ -2100,13 +2129,9 @@ impl RenderExecution { } } match draw { - Draw::Primitives(primitive_type, draw) => encoder.draw( - CALL, - Assembly::Primitives(primitive_type), - draw, - DrawBuffers::default(), - false, - )?, + Draw::Primitives(assembly, draw) => { + encoder.draw(CALL, assembly, draw, DrawBuffers::default(), false)? + } Draw::Indexed(draw, (buffer, offset)) => { encoder.draw_indexed(CALL, draw, &buffer, offset)?; } diff --git a/crates/metal2vulkan-runtime/src/render_values.rs b/crates/metal2vulkan-runtime/src/render_values.rs index 812367438..d66afcbf9 100644 --- a/crates/metal2vulkan-runtime/src/render_values.rs +++ b/crates/metal2vulkan-runtime/src/render_values.rs @@ -322,7 +322,12 @@ impl ScissorRect { /// vertex mode 0 and its last under the last-vertex mode, and `[[vertex_id]]`, /// `[[base_vertex]]`, `[[instance_id]]` and `[[base_instance]]` are those of the public draw /// of the same arguments. Value 9 ([`DrawPrimitiveType::Nine`]) draws nothing and fails its -/// command buffer as Metal's GPU does; the values past it are undefined. +/// command buffer as Metal's GPU does; the values past it are undefined. The CPU's draws of an +/// indirect render command take each value too, and an execution draws or fails it as the +/// encoder's draw does ([`IndirectRenderCommand::draw_primitives`]); a kernel's draw of a value +/// past the header's draws points, as Metal's encoding writes it so (the M3 Max, macOS 27.0.1). +/// +/// [`IndirectRenderCommand::draw_primitives`]: crate::IndirectRenderCommand::draw_primitives #[non_exhaustive] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum DrawPrimitiveType { diff --git a/crates/metal2vulkan-runtime/src/shadow.rs b/crates/metal2vulkan-runtime/src/shadow.rs index d6807c4af..a3c68f90b 100644 --- a/crates/metal2vulkan-runtime/src/shadow.rs +++ b/crates/metal2vulkan-runtime/src/shadow.rs @@ -2381,6 +2381,14 @@ impl ShadowSync { copies } + /// Forget every texture, recording no copy: what the encoder recorded so far is left out of + /// its command buffer's work (`EncoderCore::leave_out_recorded`), so no image holds what a + /// copy in there moved, and nothing written through one there ran. A later command copies in + /// again. + pub(super) fn forget(&mut self) { + self.entries.clear(); + } + /// The copies back at the end of the encoder: every texture written through since its last /// (merged where kept). pub(super) fn finish(&mut self) -> Vec> { diff --git a/crates/metal2vulkan-runtime/src/tests/command_buffer.rs b/crates/metal2vulkan-runtime/src/tests/command_buffer.rs index b4ad893c2..c4f4500cd 100644 --- a/crates/metal2vulkan-runtime/src/tests/command_buffer.rs +++ b/crates/metal2vulkan-runtime/src/tests/command_buffer.rs @@ -344,3 +344,29 @@ fn metal_submissions_follow_the_consumer_s_measurements() { assert_eq!(kinds, [Render, Blit]); assert!(metal_submissions([]).is_empty()); } + +/// A command buffer counts toward its queue's revocation where it completed with a GPU error it +/// caused: a page fault or a hang, the runtime's or one a program injected in their place by +/// Metal's code (3 or 2); not a victim of the GPU's recovery, injected (1) or not, another code, +/// nor a failure the driver relays. +#[test] +fn caused_errors_count_toward_revocation_by_their_metal_code() { + use crate::command_buffer::revocation::caused; + use CommandBufferError as E; + let counted = [E::PageFault, E::GpuHang, E::Injected(3), E::Injected(2)]; + let uncounted = [ + E::GpuRecoveryVictim, + E::Injected(1), + E::Injected(4), + E::Injected(8), + E::Injected(11), + E::Execution(3), + E::AccessRevoked, + ]; + for error in counted { + assert!(caused(error), "{error:?}"); + } + for error in uncounted { + assert!(!caused(error), "{error:?}"); + } +} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN index 0036dfd2e..c96b614df 100644 --- a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN +++ b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN @@ -143,6 +143,7 @@ fixture icb_render_replay_encode_draw_only: metal: Apple metal version 32023.921 fixture icb_render_replay_encode: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture icb_render_replay_template: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture icb_render_stride_template: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) +fixture icb_render_typed_encode: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture icb_replay_encode_buffers_two: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture icb_replay_encode_dispatch: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture icb_replay_grid_template: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.air.ll new file mode 100644 index 000000000..a85e9e197 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.air.ll @@ -0,0 +1,85 @@ +; Generated by scripts/regen-air-fixtures from icb_render_typed_encode.metal (typed pointers; xcrun metal-as reassembles it). Do not edit. +; ModuleID = '-' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.Encoder = type { %"struct.metal::command_buffer" } +%"struct.metal::command_buffer" = type { %struct._command_buffer_t addrspace(1)* } +%struct._command_buffer_t = type opaque + +; Function Attrs: mustprogress nounwind willreturn +define void @icb_render_typed_encode(%struct.Encoder addrspace(1)* nocapture noundef readonly align 8 dereferenceable(8) "air-buffer-no-alias" %0, i32 addrspace(2)* nocapture noundef readnone "air-buffer-no-alias" %1, i32 addrspace(1)* noundef "air-buffer-no-alias" %2, i32 noundef %3) local_unnamed_addr #0 { + %5 = getelementptr inbounds %struct.Encoder, %struct.Encoder addrspace(1)* %0, i64 0, i32 0, i32 0 + %6 = load %struct._command_buffer_t addrspace(1)*, %struct._command_buffer_t addrspace(1)* addrspace(1)* %5, align 8, !tbaa.struct !24, !alias.scope !29, !noalias !32 + %7 = load i32, i32 addrspace(1)* %2, align 4, !tbaa !34, !alias.scope !32, !noalias !29 + %8 = icmp eq i32 %3, 0 + br i1 %8, label %9, label %10 + +9: ; preds = %4 + tail call void @air.draw_primitives_render_command(%struct._command_buffer_t addrspace(1)* nocapture %6, i32 0, i32 %7, i32 0, i32 6, i32 1, i32 0) #2 + br label %13 + +10: ; preds = %4 + %11 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 4 + %12 = bitcast i32 addrspace(1)* %11 to i16 addrspace(1)* + tail call void @air.draw_indexed_primitives_render_command.p1i16(%struct._command_buffer_t addrspace(1)* nocapture %6, i32 %3, i32 %7, i32 6, i16 addrspace(1)* %12, i32 1, i32 0, i32 0) #2 + br label %13 + +13: ; preds = %10, %9 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.draw_primitives_render_command(%struct._command_buffer_t addrspace(1)* nocapture, i32, i32, i32, i32, i32, i32) local_unnamed_addr #1 + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.draw_indexed_primitives_render_command.p1i16(%struct._command_buffer_t addrspace(1)* nocapture, i32, i32, i32, i16 addrspace(1)*, i32, i32, i32) local_unnamed_addr #1 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nounwind willreturn } +attributes #2 = { nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9} +!air.compile_options = !{!18, !19, !20} +!llvm.ident = !{!21} +!air.version = !{!22} +!air.language_version = !{!23} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{void (%struct.Encoder addrspace(1)*, i32 addrspace(2)*, i32 addrspace(1)*, i32)* @icb_render_typed_encode, !10, !11} +!10 = !{} +!11 = !{!12, !15, !16, !17} +!12 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !13, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"Encoder", !"air.arg_name", !"encoder"} +!13 = !{i32 0, i32 8, i32 0, !"command_buffer", !"commands", !"air.indirect_argument", !14} +!14 = !{i32 0, !"air.command_buffer", !"air.location_index", i32 0, i32 1, !"air.arg_type_name", !"command_buffer", !"air.arg_name", !"commands"} +!15 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"params", !"air.arg_unused"} +!16 = !{i32 2, !"air.buffer", !"air.location_index", i32 2, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"typed"} +!17 = !{i32 3, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!18 = !{!"air.compile.denorms_disable"} +!19 = !{!"air.compile.fast_math_enable"} +!20 = !{!"air.compile.framebuffer_fetch_enable"} +!21 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"} +!22 = !{i32 2, i32 8, i32 0} +!23 = !{!"Metal", i32 4, i32 0, i32 0} +!24 = !{i64 0, i64 8, !25} +!25 = !{!26, !26, i64 0} +!26 = !{!"__metal_command_buffer_t", !27, i64 0} +!27 = !{!"omnipotent char", !28, i64 0} +!28 = !{!"Simple C++ TBAA"} +!29 = !{!30} +!30 = distinct !{!30, !31, !"air-alias-scope-arg(0)"} +!31 = distinct !{!31, !"air-alias-scopes(icb_render_typed_encode)"} +!32 = !{!33} +!33 = distinct !{!33, !31, !"air-alias-scope-arg(2)"} +!34 = !{!35, !35, i64 0} +!35 = !{!"int", !27, i64 0} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.ll b/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.ll new file mode 100644 index 000000000..82f8c4310 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.ll @@ -0,0 +1,84 @@ +; Generated by scripts/regen-air-fixtures from icb_render_typed_encode.metal (llvm-dis of icb_render_typed_encode.air). Do not edit. +; ModuleID = '' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.Encoder = type { %"struct.metal::command_buffer" } +%"struct.metal::command_buffer" = type { ptr addrspace(1) } + +; Function Attrs: mustprogress nounwind willreturn +define void @icb_render_typed_encode(ptr addrspace(1) noundef readonly align 8 captures(none) dereferenceable(8) "air-buffer-no-alias" %0, ptr addrspace(2) noundef readnone captures(none) "air-buffer-no-alias" %1, ptr addrspace(1) noundef "air-buffer-no-alias" %2, i32 noundef %3) local_unnamed_addr #0 { + %5 = getelementptr inbounds %struct.Encoder, ptr addrspace(1) %0, i64 0, i32 0, i32 0 + %6 = load ptr addrspace(1), ptr addrspace(1) %5, align 8, !tbaa.struct !24, !alias.scope !29, !noalias !32 + %7 = load i32, ptr addrspace(1) %2, align 4, !tbaa !34, !alias.scope !32, !noalias !29 + %8 = icmp eq i32 %3, 0 + br i1 %8, label %9, label %10 + +9: ; preds = %4 + tail call void @air.draw_primitives_render_command(ptr addrspace(1) captures(none) %6, i32 0, i32 %7, i32 0, i32 6, i32 1, i32 0) #2 + br label %13 + +10: ; preds = %4 + %11 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 4 + %12 = bitcast ptr addrspace(1) %11 to ptr addrspace(1) + tail call void @air.draw_indexed_primitives_render_command.p1i16(ptr addrspace(1) captures(none) %6, i32 %3, i32 %7, i32 6, ptr addrspace(1) %12, i32 1, i32 0, i32 0) #2 + br label %13 + +13: ; preds = %10, %9 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.draw_primitives_render_command(ptr addrspace(1) captures(none), i32, i32, i32, i32, i32, i32) local_unnamed_addr #1 + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.draw_indexed_primitives_render_command.p1i16(ptr addrspace(1) captures(none), i32, i32, i32, ptr addrspace(1), i32, i32, i32) local_unnamed_addr #1 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nounwind willreturn } +attributes #2 = { nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9} +!air.compile_options = !{!18, !19, !20} +!llvm.ident = !{!21} +!air.version = !{!22} +!air.language_version = !{!23} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{ptr @icb_render_typed_encode, !10, !11} +!10 = !{} +!11 = !{!12, !15, !16, !17} +!12 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !13, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"Encoder", !"air.arg_name", !"encoder"} +!13 = !{i32 0, i32 8, i32 0, !"command_buffer", !"commands", !"air.indirect_argument", !14} +!14 = !{i32 0, !"air.command_buffer", !"air.location_index", i32 0, i32 1, !"air.arg_type_name", !"command_buffer", !"air.arg_name", !"commands"} +!15 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"params", !"air.arg_unused"} +!16 = !{i32 2, !"air.buffer", !"air.location_index", i32 2, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"typed"} +!17 = !{i32 3, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!18 = !{!"air.compile.denorms_disable"} +!19 = !{!"air.compile.fast_math_enable"} +!20 = !{!"air.compile.framebuffer_fetch_enable"} +!21 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"} +!22 = !{i32 2, i32 8, i32 0} +!23 = !{!"Metal", i32 4, i32 0, i32 0} +!24 = !{i64 0, i64 8, !25} +!25 = !{!26, !26, i64 0} +!26 = !{!"__metal_command_buffer_t", !27, i64 0} +!27 = !{!"omnipotent char", !28, i64 0} +!28 = !{!"Simple C++ TBAA"} +!29 = !{!30} +!30 = distinct !{!30, !31, !"air-alias-scope-arg(0)"} +!31 = distinct !{!31, !"air-alias-scopes(icb_render_typed_encode)"} +!32 = !{!33} +!33 = distinct !{!33, !31, !"air-alias-scope-arg(2)"} +!34 = !{!35, !35, i64 0} +!35 = !{!"int", !27, i64 0} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.metal b/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.metal new file mode 100644 index 000000000..56a98761a --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/icb_render_typed_encode.metal @@ -0,0 +1,28 @@ +// Owned fixture: a kernel whose only effect is the draws it encodes, of the primitive type the +// first word of `typed` holds, whatever it is: Metal's private values and those past them too. +// Thread 0 encodes command 0's draw of 6 vertices from 0; thread 1 command 1's draw of the six +// 16-bit indices from byte 16 of `typed`, once. The pipeline is the executing encoder's, which the +// commands inherit, and the vertex buffers the host's. `params` is bound here unread, so a case +// owns the buffers the host binds to the commands. Only executing the commands observes them. +// Loop-free. +#include +using namespace metal; + +struct Encoder { + command_buffer commands; +}; + +kernel void icb_render_typed_encode( + device const Encoder &encoder [[buffer(0)]], + constant uint *params [[buffer(1)]], + device const uint *typed [[buffer(2)]], + uint tid [[thread_position_in_grid]]) +{ + render_command command(encoder.commands, tid); + primitive_type type = primitive_type(typed[0]); + if (tid == 0) { + command.draw_primitives(type, 0, 6, 1, 0); + } else { + command.draw_indexed_primitives(type, 6, (device const ushort *)(typed + 4), 1, 0, 0); + } +} diff --git a/crates/metal2vulkan-validation/src/metal/platform/predication_tests.rs b/crates/metal2vulkan-validation/src/metal/platform/predication_tests.rs index 3acc873ab..6974f3b4b 100644 --- a/crates/metal2vulkan-validation/src/metal/platform/predication_tests.rs +++ b/crates/metal2vulkan-validation/src/metal/platform/predication_tests.rs @@ -386,8 +386,9 @@ fn metal_compares_as_recorded() { /// Whiles and DoWhiles of 0 to 64, a While in a concurrent encoder, three nested loops, each /// pass's bindings, an If in a DoWhile; loops spanning a unit's encoders (serial, concurrent, /// three, around an If, inside a spanning If, with an encoder's own bindings) and a serial -/// encoder's While its concurrent encoder ends, which kills it; six nested loops; and loops of 65 -/// to 100000 passes, past the copies the runtime lays down, which Metal runs on. +/// encoder's While its concurrent encoder ends, which kills it; six nested loops; loops of 65 +/// to 100000 passes, past the copies the runtime lays down, which Metal runs on; and loops after +/// an unbalanced End that drops its unit's dispatches before it. #[test] fn metal_runs_loops_as_the_lane_expects() { let probe = Probe::new(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs b/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs index f00ef63a3..fc8c3bd86 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/indirect_command_buffers.rs @@ -1871,7 +1871,7 @@ fn render_commands_read_back_what_was_set() { assert_eq!( read.draw, Some(IndirectDraw::Primitives { - primitive_type: PrimitiveType::TriangleStrip, + primitive_type: PrimitiveType::TriangleStrip.into(), vertex_start: 5, vertex_count: 3, instance_count: 2, @@ -2164,7 +2164,7 @@ fn indexed_and_patch_draws_read_back_what_was_set() { assert_eq!( render_command(&made, 0).draw, Some(IndirectDraw::IndexedPrimitives { - primitive_type: PrimitiveType::LineStrip, + primitive_type: PrimitiveType::LineStrip.into(), index_count: 6, index_type: IndexType::UInt16, index_buffer: at(&indices, 8), diff --git a/crates/metal2vulkan-validation/src/runtime_lane/predication.rs b/crates/metal2vulkan-validation/src/runtime_lane/predication.rs index e23a8032b..103a146ce 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/predication.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/predication.rs @@ -6,8 +6,9 @@ //! //! - streams of records and marks ([`run`]'s notation, the table `predication_streams.tsv`): //! blocks nested, with Elses, spanning a unit's encoders, killed by misused records, and -//! unbalanced records dropping their ranges, with fences, setters and indirect dispatches among -//! them, run the marks Metal ran and answer what Metal answered; +//! unbalanced records dropping their ranges (the unit's dispatches before its first record +//! included, in its encoder and the unit's earlier ones), with fences, setters and indirect +//! dispatches among them, run the marks Metal ran and answer what Metal answered; //! - the condition compares as Metal's codes say, reads the word at the offset rounded down to a //! multiple of 4, and reads what a dispatch of the encoder wrote just before, with no barrier, //! in a serial and a concurrent encoder; @@ -24,9 +25,7 @@ //! as Metal's GPU recovery does, and is harmless where they run; //! - a word past its buffer reads as Metal reads it: zero within the 256 bytes Metal rounds a lone //! buffer up to, the heap's bytes past a buffer placed in a heap, and zero, announced, where -//! Metal reads memory unrelated to the buffer; -//! - what the runtime refuses: an unbalanced record that is its unit's first after dispatches of -//! the unit. +//! Metal reads memory unrelated to the buffer. use super::{ buffer_with, read_buffer, validated_device, validated_device_with, Messages, ScratchCache, WAIT, @@ -45,7 +44,7 @@ use metal2vulkan_runtime::{ ComputeCommandEncoder, ComputePipelineState, Degradation, Device, Error, EventRef, HeapDescriptor, HeapType, IndirectCommandBuffer, IndirectCommandBufferDescriptor, Invalid, LoadAction, MetalLevel, Origin, PipelineOptions, Problem, RenderPassDescriptor, - ResourceOptions, RuntimeGap, Size, StoreAction, TextureDescriptor, + ResourceOptions, Size, StoreAction, TextureDescriptor, }; /// The kernels: `prd_mark` adds 1 to word `t[0]` of `log`; `prd_put` writes `v[0]` into word 0 @@ -496,7 +495,7 @@ pub(crate) fn loop_cases() -> Vec { "1", )); } - let fixed: [FixedLoopCase; 25] = [ + let fixed: [FixedLoopCase; 28] = [ // Past the copies laid down, the laying run again: 128 passes, a DoWhile of 65, and inner // loops of 17 and 40 passes in a While of 2, with marks after. ("w128 T0 V T1", &[(0, 128), (1, 1)], "1"), @@ -536,6 +535,11 @@ pub(crate) fn loop_cases() -> Vec { ), ("% w3 T0 % T5 V T6", &[(0, 3), (5, 3), (6, 1)], "1"), ("w3 T0 % T5 V T6", &[(0, 1)], "0"), + // An unbalanced End drops the unit's dispatches before it, in its encoder and the unit's + // earlier one, and a loop after it runs, past its copies too. + ("T1 E D T2 z3@2 T4", &[(2, 3), (4, 1)], "01"), + ("T1 E D T2 z100@2 T4", &[(2, 100), (4, 1)], "01"), + ("T1 | T3 E w70 T0 V T4", &[(0, 70), (4, 1)], "01"), ( "D T0 | I1 T5 | E T7 z3 T6", &[(0, 3), (5, 3), (7, 3), (6, 1)], @@ -973,68 +977,6 @@ fn noted(messages: &Messages) -> usize { .count() } -/// What the runtime refuses, recording nothing, where it cannot give Metal's answer: an -/// unbalanced record that is its unit's first after dispatches of the unit, in its encoder or an earlier one of the unit (Metal drops those, which -/// ran ungated); the work around them runs. After a blit the next encoder starts a unit, whose -/// unbalanced record drops nothing earlier, and an unbalanced record after a block drops what -/// it gated, both as Metal's do. -#[test] -fn what_the_runtime_refuses() { - on_device(|device| { - let marks = Marks::new(device); - let queue = device.new_command_queue().unwrap(); - let ungated = Err(Error::NotImplemented( - RuntimeGap::PredicationDropsUngatedWork, - )); - let command_buffer = queue.command_buffer().unwrap(); - let mut encoder = command_buffer.compute_command_encoder().unwrap(); - marks.mark(&mut encoder, 1); - assert_eq!(encoder.encode_end_if().map(drop), ungated); - assert_eq!(encoder.encode_start_else(), ungated); - assert_eq!(encoder.encode_end_while().map(drop), ungated); - assert_eq!( - encoder.encode_end_do_while(None, 0, EQUAL, 0).map(drop), - ungated - ); - assert_eq!(encoder.encode_start_if(None, 0, EQUAL, 0), ungated); - assert_eq!(encoder.encode_start_while(None, 0, EQUAL, 0), ungated); - let word = &marks.word; - assert_eq!( - encoder - .encode_end_do_while(Some(word), 0, EQUAL, 0) - .map(drop), - ungated - ); - // The last word of the buffer, at an offset Metal rounds down to it. - encoder.encode_start_if(Some(word), 15, EQUAL, 0).unwrap(); - marks.mark(&mut encoder, 2); - assert_eq!(encoder.encode_end_if(), Ok(true)); - marks.mark(&mut encoder, 3); - encoder.end_encoding().unwrap(); - let blit = || { - let mut blit = command_buffer.blit_command_encoder().unwrap(); - blit.fill_buffer(word, 8..12, 1).unwrap(); - blit.end_encoding().unwrap(); - }; - // The unit's dispatches in an earlier encoder: refused there too. - blit(); - let mut encoder = command_buffer.compute_command_encoder().unwrap(); - marks.mark(&mut encoder, 6); - encoder.end_encoding().unwrap(); - let mut encoder = command_buffer.compute_command_encoder().unwrap(); - assert_eq!(encoder.encode_end_if().map(drop), ungated); - encoder.end_encoding().unwrap(); - // A blit ends the unit: the next one's unbalanced record drops its own work only. - blit(); - let mut encoder = command_buffer.compute_command_encoder().unwrap(); - assert_eq!(encoder.encode_end_if(), Ok(false)); - marks.mark(&mut encoder, 5); - encoder.end_encoding().unwrap(); - complete(&command_buffer); - assert_eq!(marks.ran(), [1, 2, 3, 6]); - }); -} - /// A block open where its unit ends, as Metal answers it on an M3 Max under macOS 27.0.1: where /// the unit's commands skip there (a failed If, a failed While, a held If's Else, a failing If /// inside a held one) Metal's GPU recovery fails the command buffer, `Internal`, code 1, with @@ -1458,12 +1400,11 @@ fn loops_run_as_metal_ran() { /// The loops Metal ran ([`loop_cases`]) run its passes, answer what its Ends answered and /// complete, those that run past the copies the runtime lays down among them (their laying run -/// again, counted), but one whose unbalanced End would drop the unit's ungated dispatches, refused -/// (`RuntimeGap::PredicationDropsUngatedWork`). +/// again, counted). #[test] fn loop_streams_run_as_metal_ran() { // Past the copies laid down: 2 x 2 x ... six deep, its laying cut at 64, 16, 16 and 1 copies. - const PAST_COPIES: [&str; 11] = [ + const PAST_COPIES: [&str; 13] = [ "w128 T0 V T1", "D T0 z65 T1", "w2 T0 Q1 w17@1 T1 T2 V V T3", @@ -1475,22 +1416,15 @@ fn loop_streams_run_as_metal_ran() { "D T0 z100000 T2", "w2@1 T1 Q2 w17@2 T2 T50 V V", "w3@1 T1 Q2 w100@2 T2 T50 V V", + "T1 E D T2 z100@2 T4", + "T1 | T3 E w70 T0 V T4", ]; - // Its unbalanced End drops the dispatches the unit ran before its first record. - const DROPS_UNGATED: &str = "w3 T0 % T5 V T6"; on_device(|device| { let streams = Streams::new(device); let mut wrong = Vec::new(); let mut ran_again = device.work_counts().predicated_loop_runs_again; for (script, want, answers) in loop_cases() { let got = run_counted(&streams, &script); - if script == DROPS_UNGATED { - let ungated = Error::NotImplemented(RuntimeGap::PredicationDropsUngatedWork); - if got.refused != Some(ungated) { - wrong.push(format!("{script}: refused {:?}", got.refused)); - } - continue; - } if let Some(error) = got.refused { wrong.push(format!("{script}: refused {error:?}")); continue; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/predication_streams.tsv b/crates/metal2vulkan-validation/src/runtime_lane/predication_streams.tsv index ba12dce33..4a8a4db92 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/predication_streams.tsv +++ b/crates/metal2vulkan-validation/src/runtime_lane/predication_streams.tsv @@ -5,10 +5,10 @@ # probe's name, the stream (the notation of `runtime_lane::predication::run`), the tags that ran # (each once, ascending, comma-separated), and what the Ends answered (1 YES, 0 NO, in order). # Hand-written streams first, then three seeded random sets (`g`, `h`: unbalanced records among -# valid blocks; `k`: misused records, fence updates and indirect dispatches too). Only streams the -# runtime takes are here: none whose unit's first record is unbalanced after a dispatch of the -# unit (`RuntimeGap::PredicationDropsUngatedWork`), and none that ends a unit with a block open -# whose commands skip (a GPU recovery on Metal, `CommandBufferError::PredicationOpenAtUnitEnd`). +# valid blocks; `k`: misused records, fence updates and indirect dispatches too). Only streams whose +# command buffer completes are here: none that ends a unit with a block open whose commands skip (a +# GPU recovery on Metal, `CommandBufferError::PredicationOpenAtUnitEnd`). The `x` rows' unit's first +# record is unbalanced after dispatches of the unit, which Metal drops. else0t T9 I1 T1 E T8 1,8,9 1 else0f T9 I0 T1 E T8 8,9 1 else2t T9 I1 T1 L T2 L T3 E T8 8,9 1 @@ -131,6 +131,29 @@ o_while_held T5 B W1 T1 B T3 1,3,5 o_do T5 B D T1 B T3 1,3,5 o_dead T5 B I1 V T1 B T3 3,5 0 c_unb % T1 I1 T2 E T3 E T4 I1 T5 E T6 B T99 1,5,6,99 101 +x_end T1 E 0 +x_end_after T1 E T2 B T99 99 0 +x_resume T1 E I1 T2 E T3 2,3 01 +x_resume_f T1 E I0 T2 E T3 3 01 +x_else T1 L I1 T2 E T3 2,3 1 +x_nil_if T1 In I1 T2 E 2 1 +x_nil_while T1 Wn I1 T2 E 2 1 +x_zn T1 Zn I1 T2 E 2 01 +x_z0 T1 Z0 I1 T2 E 2 01 +x_span T1 | T2 | E I1 T3 E T4 3,4 01 +x_span_c % T1 % T2 E I1 T3 E 3 01 +x_blit T9 B T1 | T2 E I1 T3 E 3,9 01 +x_other_unit T1 % E T2 1 0 +x_indirect G1 H2 T3 E I1 T4 E T5 4,5 01 +x_host_span T1 H2 | H3 T4 E I1 H5 E 5 01 +x_fence Fu | Fw T1 E I1 T2 E 2 01 +x_use U T1 E I1 T2 E 2 01 +x_widen T1 E T2 V T3 I1 T4 E T5 4,5 001 +x_redrop T1 E I1 T2 E T3 V T4 I1 T5 E 5 0101 +x_type_end I1 T0 % T1 E T2 0 0 +x_fence_end I1 T0 Fu | T1 E T2 0 0 +x_fence_end_c % I1 T0 Fu % T1 E T2 0 0 +x_all T1 E L V Zn In Wn Z0 I1 T2 E T3 B T6 | E B E T5 2,3 0000100 g1 Wn V T1 Zn Wn T2 T3 B T99 99 00 g2 T1 | I1 | T2 | L T3 T4 E T5 T6 B T99 1,2,5,6,99 1 g3 Zn Z0 T1 I0 L | | W0 T2 V T3 E T4 B T99 3,4,99 0011 diff --git a/crates/metal2vulkan-validation/src/runtime_lane/render_executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/render_executions.rs index 89e0f92cb..353b9a82c 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/render_executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/render_executions.rs @@ -58,10 +58,11 @@ use metal2vulkan::metal::{ use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RuntimeFact}; use metal2vulkan_runtime::{ Attachment, Buffer, CommandBuffer, CommandBufferError, CommandBufferStatus, Degradation, - Device, DrawProblem, Error, EventRef, ExecutedPipeline, Execution, Heap, HeapDescriptor, - HeapType, IndirectCommandBuffer, IndirectCommandBufferDescriptor, IndirectCommandBufferProblem, - IndirectRenderCommand, Invalid, PipelineOptions, Problem, Region, RenderCommandEncoder, - RenderPassDescriptor, RenderPipelineState, ResourceOptions, RuntimeGap, Size, + Device, DrawPrimitiveType, DrawProblem, Error, EventRef, ExecutedPipeline, Execution, Heap, + HeapDescriptor, HeapType, IndirectCommandBuffer, IndirectCommandBufferDescriptor, + IndirectCommandBufferProblem, IndirectRenderCommand, Invalid, PipelineOptions, Problem, Region, + RenderCommandEncoder, RenderPassDescriptor, RenderPipelineState, ResourceOptions, RuntimeGap, + Size, }; use metal2vulkan_runtime::{LoadAction, StoreAction, TextureDescriptor}; @@ -509,6 +510,205 @@ fn an_execution_under_a_state_without_support_faults_its_encoder() { }); } +/// Metal's private primitive types 5 to 8, and how many of six vertices (`0..6`, or the indices +/// [`PERMUTED`]) each type's list reaches: every one of a line loop, a fan and a quad strip, the +/// first four of quads. +const PRIVATE: [(DrawPrimitiveType, usize); 4] = [ + (DrawPrimitiveType::LineLoop, 6), + (DrawPrimitiveType::TriangleFan, 6), + (DrawPrimitiveType::Quads, 4), + (DrawPrimitiveType::QuadStrip, 6), +]; + +/// Six 16-bit indices: a permutation of `0..6`. +const PERMUTED: [u16; 6] = [5, 3, 0, 1, 4, 2]; + +/// A shared buffer of [`PERMUTED`]. +fn permuted(device: &Device) -> Buffer { + let halves: Vec = PERMUTED.iter().flat_map(|h| h.to_le_bytes()).collect(); + buffer_with(device, &halves).unwrap() +} + +/// Draw commands of both kinds, of two vertex buffers and one fragment buffer, nothing inherited. +fn both_draws() -> IndirectCommandBufferDescriptor { + let mut both = descriptor(); + both.command_types = IndirectCommandType::DRAW.union(IndirectCommandType::DRAW_INDEXED); + both +} + +/// Commands of Metal's private primitive types 5 to 8 draw as the encoder's draws of them do, the +/// vertices of the list each type's program writes, direct and indexed (Metal's: on the M3 Max, +/// macOS 27.0.1, each drew the same texels through an indirect command buffer as the encoder's +/// draw). Windows 0 and 1 are the commands', 2 and 3 the encoder's own draws after them. +#[test] +fn commands_of_private_types_draw_as_the_encoder_s_draws() { + on_device(|device, _| { + let indices = permuted(device); + for (primitive_type, reached) in PRIVATE { + let setup = Setup::new(device); + let icb = icb(device, &both_draws(), 2); + setup + .command(&icb, 0, 0) + .draw_primitives(primitive_type, 0, 6, 1, 0) + .unwrap(); + setup + .command(&icb, 1, 1) + .draw_indexed_primitives(primitive_type, 6, IndexType::UInt16, &indices, 0, 1, 0, 0) + .unwrap(); + let queue = device.new_command_queue().unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + let mut encoder = command_buffer.render_command_encoder(&pass()).unwrap(); + setup.resident(&mut encoder); + encoder + .use_resource( + indices.as_resource(), + ResourceUsage::READ, + RenderStages::VERTEX, + ) + .unwrap(); + encoder.set_render_pipeline_state(&setup.state).unwrap(); + encoder.execute_commands_in_buffer(&icb, 0..2).unwrap(); + setup.bind(&mut encoder, 2); + encoder.draw_primitives(primitive_type, 0, 6, 1, 0).unwrap(); + setup.bind(&mut encoder, 3); + encoder + .draw_indexed_primitives(primitive_type, 6, IndexType::UInt16, &indices, 0, 1, 0, 0) + .unwrap(); + encoder.end_encoding().unwrap(); + complete(&command_buffer); + let direct: Vec = (0..reached).collect(); + let indexed: Vec = PERMUTED[..reached] + .iter() + .map(|&i| usize::from(i)) + .collect(); + let drawn = expected_vertices(&[ + (0, &direct, 0..1), + (1, &indexed, 0..1), + (2, &direct, 0..1), + (3, &indexed, 0..1), + ]); + assert_eq!( + setup.output(), + drawn, + "{primitive_type:?} on {}", + device.name() + ); + } + }); +} + +/// A command of primitive type 9 among a range given at the call fails its command buffer as the +/// encoder's draw of it does (Metal's: on the M3 Max, macOS 27.0.1, through an indirect command +/// buffer as directly): a direct one of 3 vertices hangs it (`GpuHang`), an indexed one of any +/// count faults it (`PageFault`), its encoder and every one after it running nothing, the command +/// before it included, and the encoder before running; a direct one of 2 vertices draws nothing, +/// and the rest runs. Window 3 is the encoder's before, 0 the command before the draw, 1 the +/// draw's, 2 the encoder's after; each on a queue of its own (a queue's second fault revokes it). +#[test] +fn a_command_of_type_nine_fails_its_command_buffer_as_the_encoder_s_draw_does() { + on_device(|device, _| { + let indices = permuted(device); + let nine = DrawPrimitiveType::Nine; + let cases = [ + ( + "a direct draw of 3", + None, + Some(CommandBufferError::GpuHang), + ), + ( + "an indexed draw of 3", + Some(3), + Some(CommandBufferError::PageFault), + ), + ( + "an indexed draw of none", + Some(0), + Some(CommandBufferError::PageFault), + ), + ("a direct draw of 2", None, None), + ]; + for (label, indexed, error) in cases { + let setup = Setup::new(device); + let icb = icb(device, &both_draws(), 2); + setup + .command(&icb, 0, 0) + .draw_primitives(PrimitiveType::Point, 0, 4, 1, 0) + .unwrap(); + let command = setup.command(&icb, 1, 1); + match (indexed, error) { + (Some(count), _) => command.draw_indexed_primitives( + nine, + count, + IndexType::UInt16, + &indices, + 0, + 1, + 0, + 0, + ), + (None, Some(_)) => command.draw_primitives(nine, 0, 3, 1, 0), + (None, None) => command.draw_primitives(nine, 0, 2, 1, 0), + } + .unwrap(); + let queue = device.new_command_queue().unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + let points = |window: usize, execute: bool| { + let mut encoder = command_buffer.render_command_encoder(&pass()).unwrap(); + setup.resident(&mut encoder); + encoder + .use_resource( + indices.as_resource(), + ResourceUsage::READ, + RenderStages::VERTEX, + ) + .unwrap(); + encoder.set_render_pipeline_state(&setup.state).unwrap(); + if execute { + encoder.execute_commands_in_buffer(&icb, 0..2).unwrap(); + } + setup.bind(&mut encoder, window); + encoder + .draw_primitives(PrimitiveType::Point, 0, 2, 1, 0) + .unwrap(); + encoder.end_encoding().unwrap(); + }; + points(3, false); + points(2, true); + points(2, false); + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + let label = format!("{label} on {}", device.name()); + assert_eq!(command_buffer.error(), error, "{label}"); + let window = |window, count| Drawn { + window, + start: 0, + count, + instances: 1, + base: 0, + }; + let drawn = match error { + Some(_) => { + assert_eq!( + command_buffer.status(), + CommandBufferStatus::Error, + "{label}" + ); + expected(&[window(3, 2)]) + } + None => { + assert_eq!( + command_buffer.status(), + CommandBufferStatus::Completed, + "{label}" + ); + expected(&[window(3, 2), window(0, 4), window(2, 2)]) + } + }; + assert_eq!(setup.output(), drawn, "{label}"); + } + }); +} + /// A command's buffer address in no resource the command buffer's encoders made resident, and /// in no buffer of its own (a buffer placed in a heap no encoder of the command buffer used, which /// Metal's M4 did not reach either), misses: the slot reads zero and drops writes, so `out` keeps diff --git a/crates/metal2vulkan-validation/src/runtime_lane/render_gpu_executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/render_gpu_executions.rs index 8a669fa92..22a033623 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/render_gpu_executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/render_gpu_executions.rs @@ -226,6 +226,48 @@ fn for_triangles(device: &Device, setup: &Setup) -> IndirectCommandBuffer { icb } +/// A kernel's draw of a primitive type past Metal's five draws points, as Metal's encoding +/// writes it (the M3 Max, macOS 27.0.1: a kernel's draws of values 5 to 12 and past drew what +/// value 0 draws, direct and indexed): the owned `icb_render_typed_encode`'s draws of quads (7), +/// of type 9 and of 300 each draw all six vertices, direct (window 0) and over six indices that +/// permute them (window 1), where quads would draw four and type 9 fail the command buffer. +#[test] +fn a_kernel_s_draw_of_a_type_past_metal_s_five_draws_points() { + on_device(|device, _| { + let writer = indirect_host_steps::state(device, "icb_render_typed_encode", false); + let mut descriptor = inheriting(1); + descriptor.command_types = + IndirectCommandType::DRAW.union(IndirectCommandType::DRAW_INDEXED); + for value in [7u32, 9, 300] { + let setup = Setup::new(device); + let icb = icb(device, &descriptor, 2); + for index in 0..2 { + buffers(&setup, &icb, index, index as usize); + } + let indices: [u16; 6] = [5, 3, 0, 1, 4, 2]; + let mut typed: Vec = [value, 0, 0, 0] + .iter() + .flat_map(|w| w.to_le_bytes()) + .collect(); + typed.extend(indices.iter().flat_map(|h| h.to_le_bytes())); + let typed = buffer_with(device, &typed).unwrap(); + let writing = Writing { + setup: &setup, + writer: &writer, + out: &typed, + }; + let command_buffer = encode(device, &writing, (&icb, 2), (&[(0, 2)], &Call::Plain)); + complete(&command_buffer); + assert_eq!( + setup.output(), + expected(&[drawn(0, 0, 6), drawn(1, 0, 6)]), + "{value} on {}", + device.name() + ); + } + }); +} + /// The reason the host-step notice delivered so far gives (the rule that kept the pass from the /// GPU alone), the notices put back for [`assert_made_once`]; empty where none was delivered. fn host_step_reason(messages: &Messages) -> String { diff --git a/crates/metal2vulkan/src/lower/access/encode.rs b/crates/metal2vulkan/src/lower/access/encode.rs index 7704a20b4..2e7d963fb 100644 --- a/crates/metal2vulkan/src/lower/access/encode.rs +++ b/crates/metal2vulkan/src/lower/access/encode.rs @@ -127,8 +127,8 @@ pub enum Fields { Barrier { enabled: bool }, /// A threadgroup length at `binding` (`i32` each). ThreadgroupLength { length: ValueId, binding: ValueId }, - /// The primitive type, vertex start, vertex count, instance count, and base instance - /// (`i32` each), and the action. + /// The primitive type (written as Metal's encoding writes it: [`encoded_primitive_type`]), + /// vertex start, vertex count, instance count, and base instance (`i32` each), and the action. Draw { arguments: [ValueId; 5] }, /// The stage-in region's origin and size (`<3 x i32>` each). StageInRegion { origin: ValueId, size: ValueId }, @@ -136,9 +136,9 @@ pub enum Fields { ImageblockSize { size: ValueId }, /// The whole record, restored to its default. Reset, - /// An indexed draw's primitive type, index count, instance count, base vertex and base - /// instance (`i32` each), its `MTLIndexType` (0 for 16-bit indices, 1 for 32-bit ones), the - /// index buffer's guest address, and the action. + /// An indexed draw's primitive type (as [`Fields::Draw`]'s), index count, instance count, + /// base vertex and base instance (`i32` each), its `MTLIndexType` (0 for 16-bit indices, 1 + /// for 32-bit ones), the index buffer's guest address, and the action. IndexedDraw { arguments: [ValueId; 5], index_type: u32, @@ -673,6 +673,22 @@ fn k32(fb: &mut FunctionBuilder<'_>, v: u32) -> BResult { crate::memory::leaf::k32(fb, v) } +/// A draw's primitive type `operand` (a `u32`) as Metal's encoding writes it into the record: a +/// value past Metal's five (`MTLPrimitiveType`, 0 to 4) as 0, which draws points, as Metal's GPU +/// draws a kernel's draw of one (measured on the M3 Max, macOS 27.0.1: 5 to 12, 15, 16, 31, 63, +/// 255 to 257 and 65535, both draws). Its private types 5 to 9 are the CPU's alone. +fn encoded_primitive_type( + cx: &mut EmitCx<'_>, + fb: &mut FunctionBuilder<'_>, + operand: ValueId, +) -> BResult { + let x = cx.operand(fb, operand)?; + let five = k32(fb, 5)?; + let known = fb.binary(BinOp::ULessThan, x, five)?; + let point = k32(fb, 0)?; + fb.select(known, x, point) +} + /// The guest address the records of the command buffer whose word (its resource ID, a `u64`) is /// `word` start at: `indirect_commands::records_address`, the ID shifted up /// `RECORDS_ADDRESS_SHIFT` bits past `RECORDS_ADDRESS_BASE`. No records start at the null ID's. @@ -868,7 +884,10 @@ fn emit_command<'c>(cx: &mut EmitCx<'c>, fb: &mut FunctionBuilder<'_>, c: &Comma } Fields::Draw { arguments } => { for (i, a) in arguments.iter().enumerate() { - let x = cx.operand(fb, *a)?; + let x = match i { + 0 => encoded_primitive_type(cx, fb, *a)?, + _ => cx.operand(fb, *a)?, + }; let to = fixed(fb, layout::ARGUMENTS + 4 * i as u64)?; writes.push((to, x, WORD)); } @@ -1006,7 +1025,10 @@ fn emit_command<'c>(cx: &mut EmitCx<'c>, fb: &mut FunctionBuilder<'_>, c: &Comma (7, *base_instance), ]; for (word, operand) in operands { - let x = cx.operand(fb, operand)?; + let x = match word { + 0 => encoded_primitive_type(cx, fb, operand)?, + _ => cx.operand(fb, operand)?, + }; let to = fixed(fb, layout::ARGUMENTS + 4 * word)?; writes.push((to, x, WORD)); } diff --git a/crates/metal2vulkan/tests/air_input/icb_render_typed_encode.txt b/crates/metal2vulkan/tests/air_input/icb_render_typed_encode.txt new file mode 100644 index 000000000..f6a0a6118 --- /dev/null +++ b/crates/metal2vulkan/tests/air_input/icb_render_typed_encode.txt @@ -0,0 +1,112 @@ +target triple = "air64_v28-apple-macosx26.0.0" +source_filename = "-" +; datalayout DataLayout { endian: Little, pointers: {0: PointerSpec { size_bits: 64, abi_bits: 64, pref_bits: 64, index_bits: 64 }}, ints: {1: AlignSpec { abi_bits: 8, pref_bits: 8 }, 8: AlignSpec { abi_bits: 8, pref_bits: 8 }, 16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }}, floats: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }}, vectors: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 24: AlignSpec { abi_bits: 32, pref_bits: 32 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 48: AlignSpec { abi_bits: 64, pref_bits: 64 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 96: AlignSpec { abi_bits: 128, pref_bits: 128 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }, 192: AlignSpec { abi_bits: 256, pref_bits: 256 }, 256: AlignSpec { abi_bits: 256, pref_bits: 256 }, 512: AlignSpec { abi_bits: 512, pref_bits: 512 }, 1024: AlignSpec { abi_bits: 1024, pref_bits: 1024 }}, aggregate: AlignSpec { abi_bits: 0, pref_bits: 64 }, native_ints: [8, 16, 32], stack_align_bits: None, alloca_space: 0, program_space: 0, globals_space: 0, mangling: None, fn_ptr_align: None, non_integral: [] } +%t5 = type void (ptr addrspace(1), ptr addrspace(2), ptr addrspace(1), i32) +%t6 = type void (ptr addrspace(1), i32, i32, i32, i32, i32, i32) +%t7 = type void (ptr addrspace(1), i32, i32, i32, ptr addrspace(1), i32, i32, i32) +%t9 = type [2 x i32] +%t11 = type { ptr addrspace(1) } ; "struct.metal::command_buffer" +%t12 = type { %t11 } ; "struct.Encoder" +c6 = %t9 [27, 0] + +define %t5 @f0 "icb_render_typed_encode" "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins"="" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" %a0( align 8 dereferenceable(8) Ref nocapture "air-buffer-no-alias"="" ) %a1( NoModRef nocapture "air-buffer-no-alias"="" ) %a2( "air-buffer-no-alias"="" ) { +bb0: + %i0 = getelementptr inbounds %t12, %a0, i64 0, i32 0, i32 0 + %i1 = load ptr addrspace(1), %i0, align 8 + %i2 = load i32, %a2, align 4 + %i3 = icmp eq %a3, i32 0 + br %i3, bb1, bb2 +bb1: + tail call void @f1 [air IndirectCommand(DrawPrimitives)](%i1, i32 0, %i2, i32 0, i32 6, i32 1, i32 0) arg0( nocapture ) + br bb3 +bb2: + %i7 = getelementptr inbounds i32, %a2, i64 4 + %i8 = bitcast %i7 to ptr addrspace(1) + tail call void @f2 [air IndirectCommand(DrawIndexedPrimitives { space: Device, wide: false })](%i1, %a3, %i2, i32 6, %i8, i32 1, i32 0, i32 0) arg0( nocapture ) + br bb3 +bb3: + ret void +} + +declare %t6 @f1 "air.draw_primitives_render_command" %a0( nocapture ) + +declare %t7 @f2 "air.draw_indexed_primitives_render_command.p1i16" %a0( nocapture ) +!md0 = !"SDK Version" +!md1 = !"wchar_size" +!md2 = !"frame-pointer" +!md3 = !"air.max_device_buffers" +!md4 = !"air.max_constant_buffers" +!md5 = !"air.max_threadgroup_buffers" +!md6 = !"air.max_textures" +!md7 = !"air.max_read_write_textures" +!md8 = !"air.max_samplers" +!md9 = !"air.indirect_buffer" +!md10 = !"air.buffer_size" +!md11 = !"air.location_index" +!md12 = !"air.read" +!md13 = !"air.address_space" +!md14 = !"air.struct_type_info" +!md15 = !"command_buffer" +!md16 = !"commands" +!md17 = !"air.indirect_argument" +!md18 = !"air.command_buffer" +!md19 = !"air.arg_type_name" +!md20 = !"air.arg_name" +!md21 = !"air.arg_type_size" +!md22 = !"air.arg_type_align_size" +!md23 = !"Encoder" +!md24 = !"encoder" +!md25 = !"air.buffer" +!md26 = !"uint" +!md27 = !"params" +!md28 = !"air.arg_unused" +!md29 = !"typed" +!md30 = !"air.thread_position_in_grid" +!md31 = !"tid" +!md32 = !"air.compile.denorms_disable" +!md33 = !"air.compile.fast_math_enable" +!md34 = !"air.compile.framebuffer_fetch_enable" +!md35 = !"Apple metal version 32023.921 (metalfe-32023.921.6)" +!md36 = !"Metal" +!md37 = i32 2 +!md38 = %t9 c6 +!md39 = i32 1 +!md40 = i32 4 +!md41 = i32 7 +!md42 = i32 31 +!md43 = i32 128 +!md44 = i32 8 +!md45 = i32 16 +!md46 = ptr addrspace(0) @f0 +!md47 = i32 0 +!md48 = i32 3 +!md49 = !{!md37, !md0, !md38} +!md50 = !{!md39, !md1, !md40} +!md51 = !{!md41, !md2, !md37} +!md52 = !{!md41, !md3, !md42} +!md53 = !{!md41, !md4, !md42} +!md54 = !{!md41, !md5, !md42} +!md55 = !{!md41, !md6, !md43} +!md56 = !{!md41, !md7, !md44} +!md57 = !{!md41, !md8, !md45} +!md58 = !{} +!md59 = !{!md47, !md18, !md11, !md47, !md39, !md19, !md15, !md20, !md16} +!md60 = !{!md47, !md44, !md47, !md15, !md16, !md17, !md59} +!md61 = !{!md47, !md9, !md10, !md44, !md11, !md47, !md39, !md12, !md13, !md39, !md14, !md60, !md21, !md44, !md22, !md44, !md19, !md23, !md20, !md24} +!md62 = !{!md39, !md25, !md11, !md39, !md39, !md12, !md13, !md37, !md21, !md40, !md22, !md40, !md19, !md26, !md20, !md27, !md28} +!md63 = !{!md37, !md25, !md11, !md37, !md39, !md12, !md13, !md39, !md21, !md40, !md22, !md40, !md19, !md26, !md20, !md29} +!md64 = !{!md48, !md30, !md19, !md26, !md20, !md31} +!md65 = !{!md61, !md62, !md63, !md64} +!md66 = !{!md46, !md58, !md65} +!md67 = !{!md32} +!md68 = !{!md33} +!md69 = !{!md34} +!md70 = !{!md35} +!md71 = !{!md37, !md44, !md47} +!md72 = !{!md36, !md40, !md47, !md47} +!"llvm.module.flags" = !{!md49, !md50, !md51, !md52, !md53, !md54, !md55, !md56, !md57} +!"air.kernel" = !{!md66} +!"air.compile_options" = !{!md67, !md68, !md69} +!"llvm.ident" = !{!md70} +!"air.version" = !{!md71} +!"air.language_version" = !{!md72} diff --git a/crates/metal2vulkan/tests/air_input/rt6_private_writes.txt b/crates/metal2vulkan/tests/air_input/rt6_private_writes.txt new file mode 100644 index 000000000..0455e5f06 --- /dev/null +++ b/crates/metal2vulkan/tests/air_input/rt6_private_writes.txt @@ -0,0 +1,140 @@ +target triple = "air64_v28-apple-macosx26.0.0" +source_filename = "-" +; datalayout DataLayout { endian: Little, pointers: {0: PointerSpec { size_bits: 64, abi_bits: 64, pref_bits: 64, index_bits: 64 }}, ints: {1: AlignSpec { abi_bits: 8, pref_bits: 8 }, 8: AlignSpec { abi_bits: 8, pref_bits: 8 }, 16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }}, floats: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }}, vectors: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 24: AlignSpec { abi_bits: 32, pref_bits: 32 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 48: AlignSpec { abi_bits: 64, pref_bits: 64 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 96: AlignSpec { abi_bits: 128, pref_bits: 128 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }, 192: AlignSpec { abi_bits: 256, pref_bits: 256 }, 256: AlignSpec { abi_bits: 256, pref_bits: 256 }, 512: AlignSpec { abi_bits: 512, pref_bits: 512 }, 1024: AlignSpec { abi_bits: 1024, pref_bits: 1024 }}, aggregate: AlignSpec { abi_bits: 0, pref_bits: 64 }, native_ints: [8, 16, 32], stack_align_bits: None, alloca_space: 0, program_space: 0, globals_space: 0, mangling: None, fn_ptr_align: None, non_integral: [] } +%t3 = type <{ <4 x float> }> +%t6 = type %t3 (i32, i32, i32, ptr addrspace(1), ptr addrspace(1)) +%t7 = type float (i32) +%t8 = type <4 x float> () +%t9 = type i32 (i32, i32) +%t11 = type i32 (ptr addrspace(1), i32, i32, i32, i1) +%t13 = type [2 x i32] +%t15 = type { i32 } ; "struct.metal::_atomic" +c8 = %t13 [27, 0] +c27 = <4 x float> [poison, poison, 0x0, 0x3F800000] +c29 = <4 x float> [0x3F800000, 0x3F800000, 0x3F800000, 0x3F800000] + +define %t6 @f0 "pw_vertex" "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins"="" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" %a3( nocapture "air-buffer-no-alias"="" ) %a4( Mod nocapture "air-buffer-no-alias"="" ) { +bb0: + %i0 = sub i32 %a0, %a1 + %i1 = and i32 %i0, i32 63 + %i2 = tail call i32 @f3 [air Math(Math { f: IMin(Unsigned), precision: Precise, ty: NumTy { elem: I32, lanes: 1 } })](%a2, i32 1) + %i3 = shl i32 %i2, i32 6 + %i4 = or i32 %i3, %i1 + %i5 = zext %i4 to i64 + %i6 = getelementptr inbounds %t15, %a3, %i5, i32 0 + %i7 = tail call i32 @f4 [air Atomic(Atomic { space: Global, op: Add, sign: Some(Unsigned), ty: NumTy { elem: I32, lanes: 1 }, order: Relaxed, failure: None, scope: Device, volatile: true, fetch: true, flags: None })](%i6, i32 1, i32 0, i32 2, i1 1) arg0( nocapture ) + %i8 = insertelement <2 x i32> undef, %a0, i64 0 + %i9 = insertelement %i8, %a1, i64 1 + %i10 = getelementptr inbounds <2 x i32>, %a4, %i5 + store %i9, %i10, align 8 + %i12 = and i32 %a0, i32 1 + %i13 = tail call reassoc nnan ninf nsz arcp contract afn float @f1 [air Convert(Convert { dst: NumTy { elem: F32, lanes: 1 }, dst_kind: Float, src: NumTy { elem: I32, lanes: 1 }, src_kind: Unsigned, src_fp8: None })](%i12) + %i14 = fadd reassoc nnan ninf nsz arcp contract afn float %i13, float 0xBF000000 + %i15 = lshr i32 %a0, i32 1 + %i16 = and i32 %i15, i32 1 + %i17 = tail call reassoc nnan ninf nsz arcp contract afn float @f1 [air Convert(Convert { dst: NumTy { elem: F32, lanes: 1 }, dst_kind: Float, src: NumTy { elem: I32, lanes: 1 }, src_kind: Unsigned, src_fp8: None })](%i16) + %i18 = fadd reassoc nnan ninf nsz arcp contract afn float %i17, float 0xBF000000 + %i19 = insertelement <4 x float> c27, %i14, i64 0 + %i20 = insertelement %i19, %i18, i64 1 + %i21 = insertvalue %t3 undef %i20, 0 + ret %i21 +} + +declare %t7 @f1 "air.convert.f.f32.u.i32" memory(NoModRef, NoModRef, NoModRef) + +define %t8 @f2 "pw_fragment" memory(NoModRef, NoModRef, NoModRef) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins"="" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" { +bb0: + ret <4 x float> c29 +} + +declare %t9 @f3 "air.min.u.i32" memory(NoModRef, NoModRef, NoModRef) + +declare %t11 @f4 "air.atomic.global.add.u.i32" %a0( nocapture ) +!md0 = !"SDK Version" +!md1 = !"wchar_size" +!md2 = !"frame-pointer" +!md3 = !"air.max_device_buffers" +!md4 = !"air.max_constant_buffers" +!md5 = !"air.max_threadgroup_buffers" +!md6 = !"air.max_textures" +!md7 = !"air.max_read_write_textures" +!md8 = !"air.max_samplers" +!md9 = !"air.position" +!md10 = !"air.arg_type_name" +!md11 = !"float4" +!md12 = !"air.arg_name" +!md13 = !"position" +!md14 = !"air.vertex_id" +!md15 = !"uint" +!md16 = !"vid" +!md17 = !"air.base_vertex" +!md18 = !"base_vertex" +!md19 = !"air.instance_id" +!md20 = !"iid" +!md21 = !"air.buffer" +!md22 = !"air.location_index" +!md23 = !"air.read_write" +!md24 = !"air.address_space" +!md25 = !"air.struct_type_info" +!md26 = !"__s" +!md27 = !"air.arg_type_size" +!md28 = !"air.arg_type_align_size" +!md29 = !"metal::_atomic" +!md30 = !"counts" +!md31 = !"uint2" +!md32 = !"seen" +!md33 = !"air.render_target" +!md34 = !"air.compile.denorms_disable" +!md35 = !"air.compile.fast_math_enable" +!md36 = !"air.compile.framebuffer_fetch_enable" +!md37 = !"Apple metal version 32023.921 (metalfe-32023.921.6)" +!md38 = !"Metal" +!md39 = i32 2 +!md40 = %t13 c8 +!md41 = i32 1 +!md42 = i32 4 +!md43 = i32 7 +!md44 = i32 31 +!md45 = i32 128 +!md46 = i32 8 +!md47 = i32 16 +!md48 = ptr addrspace(0) @f0 +!md49 = i32 0 +!md50 = i32 3 +!md51 = ptr addrspace(0) @f2 +!md52 = !{!md39, !md0, !md40} +!md53 = !{!md41, !md1, !md42} +!md54 = !{!md43, !md2, !md39} +!md55 = !{!md43, !md3, !md44} +!md56 = !{!md43, !md4, !md44} +!md57 = !{!md43, !md5, !md44} +!md58 = !{!md43, !md6, !md45} +!md59 = !{!md43, !md7, !md46} +!md60 = !{!md43, !md8, !md47} +!md61 = !{!md9, !md10, !md11, !md12, !md13} +!md62 = !{!md61} +!md63 = !{!md49, !md14, !md10, !md15, !md12, !md16} +!md64 = !{!md41, !md17, !md10, !md15, !md12, !md18} +!md65 = !{!md39, !md19, !md10, !md15, !md12, !md20} +!md66 = !{!md49, !md42, !md49, !md15, !md26} +!md67 = !{!md50, !md21, !md22, !md49, !md41, !md23, !md24, !md41, !md25, !md66, !md27, !md42, !md28, !md42, !md10, !md29, !md12, !md30} +!md68 = !{!md42, !md21, !md22, !md41, !md41, !md23, !md24, !md41, !md27, !md46, !md28, !md46, !md10, !md31, !md12, !md32} +!md69 = !{!md63, !md64, !md65, !md67, !md68} +!md70 = !{!md48, !md62, !md69} +!md71 = !{!md33, !md49, !md49, !md10, !md11} +!md72 = !{!md71} +!md73 = !{} +!md74 = !{!md51, !md72, !md73} +!md75 = !{!md34} +!md76 = !{!md35} +!md77 = !{!md36} +!md78 = !{!md37} +!md79 = !{!md39, !md46, !md49} +!md80 = !{!md38, !md42, !md49, !md49} +!"llvm.module.flags" = !{!md52, !md53, !md54, !md55, !md56, !md57, !md58, !md59, !md60} +!"air.vertex" = !{!md70} +!"air.fragment" = !{!md74} +!"air.compile_options" = !{!md75, !md76, !md77} +!"llvm.ident" = !{!md78} +!"air.version" = !{!md79} +!"air.language_version" = !{!md80} diff --git a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv index a1ce6bbb4..6dd50a3f2 100644 --- a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv +++ b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv @@ -1261,6 +1261,8 @@ engine/icb_render_replay_template.air.ll icb_render_replay_template ok ok ok ok engine/icb_render_replay_template.ll icb_render_replay_template ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} engine/icb_render_stride_template.air.ll icb_render_stride_template ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} engine/icb_render_stride_template.ll icb_render_stride_template ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} +engine/icb_render_typed_encode.air.ll icb_render_typed_encode ok ok ok ok ok ok ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} +engine/icb_render_typed_encode.ll icb_render_typed_encode ok ok ok ok ok ok ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} engine/icb_replay_encode.air.ll icb_replay_encode ok ok ok ok ok ok ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} engine/icb_replay_encode.ll icb_replay_encode ok ok ok ok ok ok ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} engine/icb_replay_encode_buffers.air.ll icb_replay_encode_buffers ok ok ok ok ok ok ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} ok ok ok ok ok Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(ShaderInt64)]]} Unsupported{GpuEncodedIndirectCommands; AnyOf[[Feature(BufferDeviceAddress), Feature(ShaderInt64)]]} @@ -1829,6 +1831,10 @@ engine/rt6_private_types.ll pt_full ok ok ok ok ok ok ok ok ok ok ok Unsupported engine/rt6_private_types.ll pt_weights ok ok ok ok ok ok ok ok ok ok ok Unsupported{Barycentrics; AnyOf[[Feature(FragmentShaderBarycentric)], [Feature(GeometryShader)]]} ok ok ok ok ok Unsupported{Barycentrics; AnyOf[[Feature(FragmentShaderBarycentric)], [Feature(GeometryShader)]]} Unsupported{Barycentrics; AnyOf[[Feature(FragmentShaderBarycentric)], [Feature(GeometryShader)]]} Unsupported{Barycentrics; AnyOf[[Feature(FragmentShaderBarycentric)], [Feature(GeometryShader)]]} engine/rt6_private_types.ll pt_primitive ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/rt6_private_types.ll pt_plain ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/rt6_private_writes.air.ll pw_vertex ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} +engine/rt6_private_writes.air.ll pw_fragment ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/rt6_private_writes.ll pw_vertex ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} ok Unsupported{StageStoresAndAtomics; AnyOf[[Feature(VertexPipelineStoresAndAtomics)]]} +engine/rt6_private_writes.ll pw_fragment ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/rt6_provoking.air.ll pv_vertex ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/rt6_provoking.air.ll pv_vertex_smooth ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/rt6_provoking.air.ll pv_flat ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok diff --git a/docs/API.md b/docs/API.md index 662a01eb1..965927d26 100644 --- a/docs/API.md +++ b/docs/API.md @@ -3011,9 +3011,9 @@ each item named states the rule in full. run, after another round trip to the host where its first recording waited for the work before it. A condition word past its buffer reads as Metal reads it (the heap's bytes, or zero), and as zero where Metal reads memory unrelated to - the buffer (`predication-word-past-buffer`). Refused where Metal runs on (`RuntimeGap`): an - unbalanced record that is its unit's first after dispatches of the unit - (`PredicationDropsUngatedWork`). + the buffer (`predication-word-past-buffer`). An unbalanced record that is its unit's first + drops the unit's dispatches before it as Metal's does: what the unit's encoders recorded before + it is never submitted. - **A GPU-written indirect command naming a placed ID runs that ID's live holder**, the state made last; once it is released, nothing. - **An indirect render command keeps a draw's values to 32 bits**, as Metal's records keep most of @@ -3097,8 +3097,11 @@ each item named states the rule in full. running nothing and firing none of its event signals, for good (two seconds on too), while one committed before it runs; the device's other queues, new ones too, run on. The runtime counts the faults and hangs it makes Metal's answer for (primitive type 9, an execution of indirect - commands under a state it cannot inherit), not the ones the driver relays, and decides at the - commit: a command buffer committed before the revocation runs whatever its event waits. + commands under a state it cannot inherit) and those a program commits as failed in their place + (`commit_failed` with Metal's code 3 or 2, `CommandBufferError::Injected`), not the ones the + driver relays, and decides at the commit: a command buffer committed before the revocation runs + whatever its event waits, a predicated loop's runs again included (on the M3 Max a loop + committed before the revocation ran all its passes after it, with no error). **Heaps and memory** diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 4ba796421..a3dbf659b 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -296,6 +296,13 @@ driver's. Each is open work. takes the index rewrite pass's three dispatches between barriers per draw before its render pass: there 78 us per draw against 1.7. That form is not batched. +- **An indirect render command's draw of primitive type 9 that its execution's call cannot see**: + one the CPU wrote after the call, or among a range the execution reads from a buffer. It runs + nothing, counted as a record fault in the execution report (`RECORD`), where Metal's GPU hangs + or faults the command buffer at it. One among a range given at the call, as the records stand + then, fails the command buffer as the encoder's draw does (`render/executions.rs`); failing it + from inside the host step that meets the record, its earlier encoders run, is not built. + - **A no-copy buffer imported by its pointer follows a remap of its pages** on a driver whose pointer imports follow their address (`DriverFact::PointerImportsFollowTheirAddress`: ANV on i915, RADV, lavapipe): pages mapped over the buffer's addresses after it was made (`mmap` with diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 062623b3f..7a71000fc 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -14,14 +14,14 @@ Columns: - `none`: no public API path: malformed or non-Metal input, Apple-private calls, or a cap no valid program of ordinary size meets; - `?`: not assessed yet. -Generated at `dd8b2eac3`. +Generated at `13d45141f`. ## Totals | Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed | |---|---|---|---|---|---|---|---| | Translator and front-end refusals | 126 | 126 | 6 | 33 | 70 | 17 | 0 | -| Runtime gaps | 67 | 67 | 1 | 8 | 43 | 15 | 0 | +| Runtime gaps | 66 | 66 | 1 | 8 | 43 | 14 | 0 | | Apple-only calls | 5 | 5 | 0 | 0 | 0 | 5 | 0 | | Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 | | Translation caps | 14 | 14 | 0 | 0 | 7 | 7 | 0 | @@ -131,11 +131,11 @@ Generated at `dd8b2eac3`. | `SparseTexture` | A sparse texture (`MTLTexture.isSparse`) bound at `slot`, where a function observes the residency of its accesses (`sparse_color::resident()`) and... | - | via a helper: 2: `crates/metal2vulkan/src/bind/plan/slots.rs:583`, `crates/metal2vulkan/src/bind/plan/slots.rs:607` | `rare`: sparse residency reads | | `TextureSize` | A texture whose extent, array layers, or level count is past what the device takes for its format, type, and usage (`Capability::Limit` names the... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/image_plan.rs:1196` | `app`: a texture past a device's image limits | | `TextureSampleCount` | A texture sample count the device does not take for its format, type, and usage | devices short of a Vulkan property the site names; devices without VkFeature::MultisampleArrayImage; every device (no Vulkan mechanism) | 3: `crates/metal2vulkan-runtime/src/image_plan.rs:1244`, `crates/metal2vulkan-runtime/src/image_plan.rs:598` (+1) | `app`: a sample count a device lacks for the texture | -| `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture.rs:5150` (+5) | `app`: a texture view Vulkan cannot make exactly | -| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:998` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured | +| `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture.rs:5136` (+5) | `app`: a texture view Vulkan cannot make exactly | +| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:996` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured | | `MipmapGeneration` | `generateMipmapsForTexture:` where the device's filter is not shown to give Metal's answer | devices without VkFeature::ShaderInt64; devices without a format's usage; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/blit_texture.rs:1890`, `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37` (+5) | `app`: generateMipmapsForTexture: where the device's filter is not Metal's | | `HostMemory` | A buffer over the caller's host memory without a copy (`newBufferWithBytesNoCopy:`) | devices without VkExtension::ExtExternalMemoryHost; every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/host_memory.rs:430`, `crates/metal2vulkan-runtime/src/host_memory.rs:470` (+3) | `system`: newBufferWithBytesNoCopy: where the device cannot import the memory | -| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2828` | `rare`: GPU times on a queue without timestamps | +| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2840` | `rare`: GPU times on a queue without timestamps | | `CountingVisibility` | A `Counting` visibility result (`MTLVisibilityResultModeCounting`) on a device without `occlusionQueryPrecise` | devices without VkFeature::OcclusionQueryPrecise | 1: `crates/metal2vulkan-runtime/src/visibility.rs:452` | `rare`: counting occlusion queries on a device without precise queries | | `ViewFormatReinterpretation` | A texture view whose format has other components, or components of other widths, than its texture's (`RGBA8Unorm` as `R32Uint`), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/view_plan.rs:570` | `app`: a view of another component layout on a portability subset (MoltenVK) | | `SeparateMultisampledDepthStencil` | A render pass whose depth and stencil attachments are separate multisampled textures that it loads or may store, on a device without maintenance8,... | - | via a helper: 7: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:188`, `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:294` (+5) | `rare`: separate multisampled depth and stencil textures | @@ -165,7 +165,7 @@ Generated at `dd8b2eac3`. |---|---|---|---|---| | `Textures` | Textures and texture buffers | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:163`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:1563` (+7) | `rare`: texture forms the runtime has not built (texture buffers of some forms, X24Stencil8 views) | | `ResourceHeap` | The resource-ID heap, descriptor set 1 | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/binding.rs:1982` | `rare`: the resource-ID heap's remaining forms | -| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:465`, `crates/metal2vulkan-runtime/src/texture.rs:1683` (+1) | `rare`: sparse heaps | +| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:465`, `crates/metal2vulkan-runtime/src/texture.rs:1674` (+1) | `rare`: sparse heaps | | `SparseTileMaps` | What the runtime's emulation of sparse textures does not build yet | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/binding.rs:562`, `crates/metal2vulkan-runtime/src/sparse/texture.rs:30` (+1) | `rare`: sparse texture emulation's unbuilt pieces | | `HeapPastMaxBufferSize` | A heap larger than the device's `maxBufferSize`, which the device can allocate | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/heap.rs:714` | `rare`: a heap past maxBufferSize | | `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1071` | `rare`: a heap texture needing more than 256 KiB alignment | @@ -208,34 +208,33 @@ Generated at `dd8b2eac3`. | `LayeredPass` | A layered render pass (`renderTargetArrayLength` 2 or more) that needs a step of one layer | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/color_resolve.rs:890` | `rare`: layered passes needing a per-layer color resolve | | `FunctionOptions` | A function descriptor's options beyond `CompileToBinary` and `StoreFunctionInMetalPipelinesScript` (`Library::new_function_with_descriptor`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:215` | `rare`: function descriptor options beyond CompileToBinary | | `OverlappingTextureCopies` | A blit copy between overlapping regions of one texture's texels (`copyFromTexture:...` with the source's region meeting the destination's, through... (not scheduled) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs:1340` | `rare`: overlapping texture copies (Metal races) | -| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637`, `crates/metal2vulkan-runtime/src/texture/heap.rs:2739` (+3) | `none`: a runtime extension's rebind with a live texture | -| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5789` | `rare`: PVRTC regions off whole levels | -| `DecodedHeapTexture` | A heap's or a sparse heap's texture of an ASTC format on a device without that ASTC format (`astc.rs`), or a sparse heap's texture of an ETC2 or... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/texture.rs:1691`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1373` | `app`: an ASTC texture in a heap on a device without ASTC | +| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637`, `crates/metal2vulkan-runtime/src/texture/heap.rs:2726` (+3) | `none`: a runtime extension's rebind with a live texture | +| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5775` | `rare`: PVRTC regions off whole levels | +| `DecodedHeapTexture` | A heap's or a sparse heap's texture of an ASTC format on a device without that ASTC format (`astc.rs`), or a sparse heap's texture of an ETC2 or... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/texture.rs:1682`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1373` | `app`: an ASTC texture in a heap on a device without ASTC | | `VertexFetchPast4GiB` | A draw (`drawPrimitives:` and its forms, or an indirect command buffer's command) that may read a vertex attribute the pipeline fetches in its... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72` | `rare`: vertex fetch past 4 GiB of a bind offset | | `StageInFetchPast4GiB` | A dispatch (`dispatchThreads:threadsPerThreadgroup:` and its forms, or an indirect command buffer's command) whose kernel may read a... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126` | `rare`: stage-in fetch past 4 GiB of a bind offset | | `MappedTextureSampling` | A command that would sample a texture of an address-mode map (`TextureDescriptor::address_mode_map`) where the runtime cannot map it at bind... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/address_map.rs:158` | `none`: a runtime extension's texture (address_mode_map) sampled where the runtime cannot map it; no Metal API path | | `LibrarySource` | A library compiled from Metal Shading Language source | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:107` | `app`: a library compiled from Metal source (newLibraryWithSource:); the runtime takes metallibs and AIR | | `RestartedStrip` | An indexed strip after `set_primitive_restart_enabled` with an index Vulkan does not restart at, which the runtime draws as a list an index... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/restart.rs:71` | `none`: a strip after the Apple-private setPrimitiveRestartEnabled:index: whose rewrite pass cannot run as Metal draws | -| `PrivatePrimitives` | A draw of one of Metal's private primitive types (`DrawPrimitiveType` | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:7982`, `crates/metal2vulkan-runtime/src/render/restart.rs:72` | `none`: a draw of an Apple-private primitive type (OpenGL on Metal's quads and kin) whose list cannot draw as Metal draws: a list past a u32 or one storage range, indices or arguments an unordered earlier draw wrote | +| `PrivatePrimitives` | A draw of one of Metal's private primitive types (`DrawPrimitiveType` | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:7937`, `crates/metal2vulkan-runtime/src/render/restart.rs:72` | `none`: a draw of an Apple-private primitive type (OpenGL on Metal's quads and kin) whose list cannot draw as Metal draws: a list past a u32 or one storage range, indices or arguments an unordered earlier draw wrote | | `ProvokingVertex` | A draw under Apple's last provoking vertex (`setProvokingVertexMode:` 1) on a device without `VK_EXT_provoking_vertex`'s last vertex, which the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/restart.rs:73` | `none`: a draw after the Apple-private setProvokingVertexMode: 1, on a device without the last provoking vertex, whose rotated list cannot draw as Metal draws | -| `PrimitiveIdIndices` | An indexed draw (`drawIndexedPrimitives:`) of a pipeline whose fragment function reads `[[primitive_id]]` on a device whose fragment stage cannot... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render.rs:7992` | `rare`: an indexed draw of a primitive_id pipeline, on a device without geometry or tessellation shaders, whose indices the encoder wrote since its last barrier | +| `PrimitiveIdIndices` | An indexed draw (`drawIndexedPrimitives:`) of a pipeline whose fragment function reads `[[primitive_id]]` on a device whose fragment stage cannot... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render.rs:7947` | `rare`: an indexed draw of a primitive_id pipeline, on a device without geometry or tessellation shaders, whose indices the encoder wrote since its last barrier | | `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1669`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:715` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer | | `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 8: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:641`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:622` (+6) | `none`: a runtime extension's detach with a texture no stand-in presents exactly | | `TextureBufferLevels` | A texture buffer of more than one level (`TextureDescriptor::mipmap_level_count`, up to its width's full chain) from the device's, a heap's or the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:540` | `rare`: a texture buffer of more than one level (public, unusual) | | `WriteSwizzle` | A texture of `TextureDescriptor::write_swizzle_enabled` whose swizzle is not the default, with `ShaderWrite` or `RenderTarget` usage, from the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:547` | `none`: Apple-private writeSwizzleEnabled with a swizzle that writes | -| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4938` | `none`: CPU texel access while a runtime extension detached the bytes | +| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4924` | `none`: CPU texel access while a runtime extension detached the bytes | | `SurfaceDepthStencil` | A use of a texture of a depth or stencil format (`Depth16Unorm`, `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`) over a plane... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:269`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57` | `rare`: a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 | | `ExtendedRangeResolve` | The multisample resolve (`MultisampleResolve`, `StoreAndMultisampleResolve`) of a color attachment of an extended-range format (`BGRA10_XR`,... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/resolve.rs:604` | `rare`: a multisample resolve of a BGRA10_XR, BGR10_XR or sRGB twin attachment (EDR content drawn multisampled) | -| `PredicationDropsUngatedWork` | An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the other ends, or `encode_start_else`, with no block open;... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:748` | `none`: an unbalanced Apple-private command-predication record as its unit's first, after dispatches of the unit | | `MultisampledBufferCopy` | A blit copy between a buffer and a multisampled texture (`copyFromBuffer:...toTexture:` into, or `copyFromTexture:...toBuffer:` out of, a texture... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:536`, `crates/metal2vulkan-runtime/src/blit_texture.rs:693` | `rare`: a buffer<->multisampled-texture copy on a device without sample-rate shading, an integer multisample attachment at the count, or the copy format's storage; and, where maintenance8's depth/colour copies are missing or wrong, what the sample-rate draws cannot move: a 16-bit depth, or a depth or stencil texture they cannot sample or render to (emulated elsewhere; the consumer's Maps pans and screensaver make the copy) | -| `MultisampledBufferLayout` | A blit copy between a buffer and a multisampled texture (as for `MultisampledBufferCopy`) in one of two buffer layouts that plain Metal copies by... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1029` | `rare`: a buffer<->multisampled-texture copy at a bytesPerRow of 0 from an offset that is a multiple of 16, or of pixels of 32 bytes or more at a pitch below a row or off the pixel: Metal copies these by rules not yet reduced, and its API validation rejects them | +| `MultisampledBufferLayout` | A blit copy between a buffer and a multisampled texture (as for `MultisampledBufferCopy`) in one of two buffer layouts that plain Metal copies by... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1020` | `rare`: a buffer<->multisampled-texture copy at a bytesPerRow of 0 from an offset that is a multiple of 16, or of pixels of 32 bytes or more at a pitch below a row or off the pixel: Metal copies these by rules not yet reduced, and its API validation rejects them | | `ColorAttachmentGroups` | What a render pass the device draws in color groups does not build | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/color_groups.rs:106` | `app`: in a render pass of more color attachments than the device draws at once (five or more on a device of four), or one at an index past them: a pipeline state of other colors, a tile state, an execution of render commands, a draw reading another group's attachment | ## 3. Apple-only calls (`Error::AppleOnly`) | Variant | What it blocks | Where | Sites | Reach | |---|---|---|---|---| -| `ProtectedContent` | Protection options whose answer on Metal is not measured (`command_buffer/protection.rs`) | every device (Apple-private, Metal's answer not measured) | 3: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2386`, `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126` (+1) | `none`: Apple-private (no public header) | +| `ProtectedContent` | Protection options whose answer on Metal is not measured (`command_buffer/protection.rs`) | every device (Apple-private, Metal's answer not measured) | 3: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2398`, `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126` (+1) | `none`: Apple-private (no public header) | | `LineWidth` | A line width other than 1 (`setLineWidth:`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:189` | `none`: Apple-private (no public header) | | `ViewportTransformDisabled` | The viewport transform turned off (`setViewportTransformEnabled:NO`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:191` | `none`: Apple-private (no public header) | | `VertexAmplificationMode` | `setVertexAmplificationMode:value:` of a count (the value's set bits in mode 1, else the value) of 0, whose copies change from run to run on... | every device (Apple-private, Metal's answer not measured) | 2: `crates/metal2vulkan-runtime/src/apple_only.rs:195`, `crates/metal2vulkan-runtime/src/apple_only.rs:320` | `none`: Apple-private (no public header) | @@ -330,7 +329,7 @@ Each refusal's sites, with the function that builds it. - `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs:569 (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs:3658 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3702 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3740 (patch_binding)`; `crates/metal2vulkan/src/bind/instantiate.rs:659 (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs:226 (select)`; `crates/metal2vulkan/src/lower/access/mod.rs:1184 (place_slots)` - `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs:582 (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs:1133 (selector_form)` - `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs:230 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs:587 (check_scalar)` -- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:523 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:530 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:545 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:602 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:694 (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:2206 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:519 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:582 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:614 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:851 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:346 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:526 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1625 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1628 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:227 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:271 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:291 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:306 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:353 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:392 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:474 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:508 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:522 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:544 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:670 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:787 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:907 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:2292 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1031 (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1369 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1709 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1802 (attachment_format)`; `crates/metal2vulkan-runtime/src/resolve.rs:409 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/resolve.rs:616 (color)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:303 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:649 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:656 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:2056 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3602 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:498 (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:534 (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1949 (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:80 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:278 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:384 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:150 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:380 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:393 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:400 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:412 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:422 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:285 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1134 (plain_texture)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1814 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:193 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:959 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:328 (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs:259 (shadow_copy_in_module)`; `crates/metal2vulkan/src/bind/unused_bits.rs:687 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:160 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:166 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1202 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1223 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1229 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1235 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1260 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1437 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1873 (select_read)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1979 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:2006 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:2025 (select_output)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1093 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:691 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2355 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:896 (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs:83 (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2360 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3002 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3174 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3344 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3381 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3714 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1035 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1048 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1054 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:739 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:742 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:753 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:771 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:791 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:815 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:826 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:873 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:908 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:917 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1693 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1695 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1825 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2783 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2801 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2809 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2906 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1100 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:428 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:474 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:546 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:969 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:990 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:449 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:593 (alpha_in_red_blend)` +- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:523 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:530 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:545 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:602 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:694 (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:2206 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:519 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:582 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:614 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:851 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:346 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:526 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1625 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1628 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:227 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:271 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:291 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:306 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:353 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:392 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:474 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:508 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:522 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:544 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:670 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:787 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:907 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:2292 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1031 (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1369 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1709 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1802 (attachment_format)`; `crates/metal2vulkan-runtime/src/resolve.rs:409 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/resolve.rs:616 (color)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:301 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:648 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:655 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:2047 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3588 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:498 (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:534 (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1949 (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:80 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:278 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:384 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:150 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:380 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:393 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:400 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:412 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:422 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:285 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1134 (plain_texture)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1814 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:193 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:959 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:328 (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs:259 (shadow_copy_in_module)`; `crates/metal2vulkan/src/bind/unused_bits.rs:687 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:160 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:166 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1202 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1223 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1229 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1235 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1260 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1437 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1873 (select_read)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1979 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:2006 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:2025 (select_output)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1093 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:691 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2355 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:896 (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs:83 (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2360 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3002 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3174 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3344 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3381 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3714 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1035 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1048 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1054 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:739 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:742 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:753 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:771 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:791 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:815 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:826 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:873 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:908 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:917 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1693 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1695 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1825 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2783 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2801 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2809 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2906 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1100 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:428 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:474 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:546 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:969 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:990 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:449 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:593 (alpha_in_red_blend)` - `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs:352 (select_sampling)` - `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:136 (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs:229 (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs:255 (query_min_level)` - `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs:1572 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:973 (min_lod)` @@ -393,11 +392,11 @@ Each refusal's sites, with the function that builds it. - `feature::SparseTexture`: `crates/metal2vulkan/src/bind/plan/slots.rs:583 (check_sparse_textures)`; `crates/metal2vulkan/src/bind/plan/slots.rs:607 (check_sparse_textures)` - `feature::TextureSize`: `crates/metal2vulkan-runtime/src/image_plan.rs:1196 (check_image_limits)` - `feature::TextureSampleCount`: `crates/metal2vulkan-runtime/src/image_plan.rs:1244 (check_image_limits)`; `crates/metal2vulkan-runtime/src/image_plan.rs:598 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:608 (plan_held)` -- `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:5150 (view)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:1427 (make_second_twin)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:298 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:433 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:483 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:505 (check_view)` -- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:998 (may_view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1102 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2587 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3409 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3756 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:307 (select)` +- `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:5136 (view)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:1427 (make_second_twin)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:298 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:433 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:483 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:505 (check_view)` +- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:996 (may_view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1102 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2587 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3409 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3756 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:307 (select)` - `feature::MipmapGeneration`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1890 (mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37 (pick_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:262 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:270 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:275 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:304 (plan_mipmaps)`; `crates/metal2vulkan/src/bind/mipmap_filter.rs:973 (mipmap_filter_module)` - `feature::HostMemory`: `crates/metal2vulkan-runtime/src/host_memory.rs:430 (not_importable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:470 (refuse_unwritable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:689 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:694 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:712 (new)` -- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2828 (gpu_times)` +- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2840 (gpu_times)` - `feature::CountingVisibility`: `crates/metal2vulkan-runtime/src/visibility.rs:452 (check_mode)` - `feature::ViewFormatReinterpretation`: `crates/metal2vulkan-runtime/src/view_plan.rs:570 (reinterpretation_refused)` - `feature::SeparateMultisampledDepthStencil`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:188 (sampled_candidate)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:294 (by_draws)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:336 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:376 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:777 (plan)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:658 (nan_write)`; `crates/metal2vulkan-runtime/src/texture/signed_depth.rs:191 (sample_strip)` @@ -420,23 +419,23 @@ Each refusal's sites, with the function that builds it. - `feature::ProgramScopeBinding`: `crates/metal2vulkan-air/src/abi/module.rs:77 (decode)`; `crates/metal2vulkan/src/error/mod.rs:267 (from)` - `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs:443 (require_seq_cst)` - `feature::PostDepthCoverage`: `crates/metal2vulkan-runtime/src/families/features.rs:1219 (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:783 (param)` -- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:163 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1563 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1625 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1463 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:2230 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:3050 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4092 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5717 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:207 (new_surface_planes_texture)` +- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:163 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1563 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1625 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1461 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:2221 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:3036 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4078 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5703 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:207 (new_surface_planes_texture)` - `gap::ResourceHeap`: `crates/metal2vulkan-runtime/src/binding.rs:1982 (descriptor)` -- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:465 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1683 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4840 (make_aliasable)` -- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:562 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1716 (plan_sparse_texture)` +- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:465 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1674 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4826 (make_aliasable)` +- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:562 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1707 (plan_sparse_texture)` - `gap::HeapPastMaxBufferSize`: `crates/metal2vulkan-runtime/src/heap.rs:714 (heap_size)` - `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1071 (check_heap_base)` - `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1510 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1517 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2059 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2291 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:554 (memory_refusal)` - `gap::FunctionTablePastMaxBufferLength`: `crates/metal2vulkan-runtime/src/function_table.rs:622 (past_limit)` - `gap::IndirectCommandBufferPastMaxBufferLength`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522 (new_indirect_command_buffer)` -- `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1291 (execute_range)`; `crates/metal2vulkan-runtime/src/compute.rs:1376 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:4368 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:517 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1632 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:7196 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7726 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8143 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8651 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1106 (back_memoryless)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2916 (record_forms)`; `crates/metal2vulkan-runtime/src/render/executions.rs:382 (execute_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:441 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:456 (execute_indirect_range)` +- `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1291 (execute_range)`; `crates/metal2vulkan-runtime/src/compute.rs:1376 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:4368 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:517 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1632 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:7196 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7681 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8098 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8605 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1106 (back_memoryless)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2916 (record_forms)`; `crates/metal2vulkan-runtime/src/render/executions.rs:382 (execute_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:441 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:456 (execute_indirect_range)` - `gap::IndirectImageblockSize`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3363 (set_imageblock_size)` - `gap::CommandReplay`: `crates/metal2vulkan-runtime/src/binding.rs:723 (bind_into)`; `crates/metal2vulkan-runtime/src/binding.rs:726 (bind_into)` - `gap::RenderAttachments`: `crates/metal2vulkan-runtime/src/binding.rs:1794 (unexpected)` - `gap::AccelerationStructures`: `crates/metal2vulkan-runtime/src/binding.rs:1797 (unexpected)` - `gap::FeatureEnable`: `crates/metal2vulkan-runtime/src/enables.rs:1165 (of)` - `gap::ExtensionEnable`: `crates/metal2vulkan-runtime/src/enables.rs:1156 (of)` -- `gap::Render`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:404 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:460 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:684 (check_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:796 (attachment_twin)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:283 (check_sizes)`; `crates/metal2vulkan-runtime/src/kept_bytes.rs:138 (settle)`; `crates/metal2vulkan-runtime/src/linear_attachment.rs:293 (settle)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/pipeline/render.rs:1169 (imageblock_sample_length)`; `crates/metal2vulkan-runtime/src/render.rs:2223 (check_pipeline)`; `crates/metal2vulkan-runtime/src/render.rs:5940 (next_instance)`; `crates/metal2vulkan-runtime/src/render.rs:7820 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:516 (scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1313 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1676 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1730 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1791 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:2024 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:1035 (attach)`; `crates/metal2vulkan-runtime/src/resolve.rs:1103 (color_copy)`; `crates/metal2vulkan-runtime/src/resolve.rs:1150 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1167 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1232 (destination)` +- `gap::Render`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:404 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:460 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:684 (check_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:796 (attachment_twin)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:283 (check_sizes)`; `crates/metal2vulkan-runtime/src/kept_bytes.rs:138 (settle)`; `crates/metal2vulkan-runtime/src/linear_attachment.rs:293 (settle)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/pipeline/render.rs:1169 (imageblock_sample_length)`; `crates/metal2vulkan-runtime/src/render.rs:2223 (check_pipeline)`; `crates/metal2vulkan-runtime/src/render.rs:5940 (next_instance)`; `crates/metal2vulkan-runtime/src/render.rs:7775 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:516 (scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1313 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1676 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1730 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1791 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:2024 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:1035 (attach)`; `crates/metal2vulkan-runtime/src/resolve.rs:1103 (color_copy)`; `crates/metal2vulkan-runtime/src/resolve.rs:1150 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1167 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1232 (destination)` - `gap::TexelsPastBufferLength`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:261 (refusal_error)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:105 (surface_depth_twin)` - `gap::OverlappingSurfaceRows`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:263 (refusal_error)` - `gap::SamplePositionsAtBegin`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:145 (stencil_scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1861 (positioned_stand_in)`; `crates/metal2vulkan-runtime/src/sample_positions.rs:185 (grid)` @@ -445,7 +444,7 @@ Each refusal's sites, with the function that builds it. - `gap::NonFiniteDepthBias`: `crates/metal2vulkan-runtime/src/render_state.rs:1603 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:1606 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:365 (set_depth_bias)`; `crates/metal2vulkan-runtime/src/render_state.rs:463 (draw_viewports)`; `crates/metal2vulkan-runtime/src/render_state.rs:605 (compensation)` - `gap::DepthNeverWithoutAttachment`: `crates/metal2vulkan-runtime/src/depth_stencil.rs:147 (failing_draw)` - `gap::HiddenDepthStencil`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:563 (hidden)`; `crates/metal2vulkan-runtime/src/render.rs:6617 (hidden_depth_stencil)` -- `gap::IndirectDrawArguments`: `crates/metal2vulkan-runtime/src/index_bounds.rs:91 (new)`; `crates/metal2vulkan-runtime/src/render.rs:3302 (draw_indexed_primitives_indirect)`; `crates/metal2vulkan-runtime/src/render.rs:7516 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7630 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7661 (draw_resident)` +- `gap::IndirectDrawArguments`: `crates/metal2vulkan-runtime/src/index_bounds.rs:91 (new)`; `crates/metal2vulkan-runtime/src/render.rs:3302 (draw_indexed_primitives_indirect)`; `crates/metal2vulkan-runtime/src/render.rs:7516 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7585 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7616 (draw_resident)` - `gap::DepthStencilResolve`: `crates/metal2vulkan-runtime/src/depth_stencil_resolve.rs:441 (draws_run)`; `crates/metal2vulkan-runtime/src/resolve.rs:1388 (plan)`; `crates/metal2vulkan-runtime/src/resolve.rs:787 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:885 (steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:905 (steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:946 (split_steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:958 (split_steps)` - `gap::TileAtSampleCount`: `crates/metal2vulkan-runtime/src/render_pass.rs:1611 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:937` - `gap::ImageblockMasters`: `crates/metal2vulkan-runtime/src/render.rs:7350 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:929 (dispatch_tiles_resident)` @@ -465,29 +464,28 @@ Each refusal's sites, with the function that builds it. - `gap::LayeredPass`: `crates/metal2vulkan-runtime/src/color_resolve.rs:890 (plan)` - `gap::FunctionOptions`: `crates/metal2vulkan-runtime/src/library.rs:215 (new_function_with_descriptor)` - `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1340 (texture_copies_of_bytes)` -- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2739 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2754 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2765 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2808 (dma_buf_heap_images_again)` -- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5789 (host_copy)` -- `gap::DecodedHeapTexture`: `crates/metal2vulkan-runtime/src/texture.rs:1691 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1373 (heap_plan)` +- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2726 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2741 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2752 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2795 (dma_buf_heap_images_again)` +- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5775 (host_copy)` +- `gap::DecodedHeapTexture`: `crates/metal2vulkan-runtime/src/texture.rs:1682 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1373 (heap_plan)` - `gap::VertexFetchPast4GiB`: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72 (check_vertex_reach)` - `gap::StageInFetchPast4GiB`: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126 (check_stage_in_reach)` - `gap::MappedTextureSampling`: `crates/metal2vulkan-runtime/src/address_map.rs:158 (resolve)` - `gap::LibrarySource`: `crates/metal2vulkan-runtime/src/library.rs:107 (new_library_with_source)` - `gap::RestartedStrip`: `crates/metal2vulkan-runtime/src/render/restart.rs:71 (gap)` -- `gap::PrivatePrimitives`: `crates/metal2vulkan-runtime/src/render.rs:7982 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/restart.rs:72 (gap)` +- `gap::PrivatePrimitives`: `crates/metal2vulkan-runtime/src/render.rs:7937 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/restart.rs:72 (gap)` - `gap::ProvokingVertex`: `crates/metal2vulkan-runtime/src/render/restart.rs:73 (gap)` -- `gap::PrimitiveIdIndices`: `crates/metal2vulkan-runtime/src/render.rs:7992 (draw_resident)` -- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1669 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:715 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:185 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:201 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:643 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:5108 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:100 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:322 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:238 (new_usage_shadow)` -- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:641 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:622 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:172 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2948 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:298 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:304 (stand_ins)` +- `gap::PrimitiveIdIndices`: `crates/metal2vulkan-runtime/src/render.rs:7947 (draw_resident)` +- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1669 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:715 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:185 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:201 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:642 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:5094 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:100 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:322 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:238 (new_usage_shadow)` +- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:641 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:622 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:172 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2935 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:298 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:304 (stand_ins)` - `gap::TextureBufferLevels`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:540 (check_made)` - `gap::WriteSwizzle`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:547 (check_made)` -- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4938 (refuse_detached_texels)` +- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4924 (refuse_detached_texels)` - `gap::SurfaceDepthStencil`: `crates/metal2vulkan-runtime/src/blit_texture.rs:269 (unit)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57 (surface_depth_twin)` - `gap::ExtendedRangeResolve`: `crates/metal2vulkan-runtime/src/resolve.rs:604 (color)` -- `gap::PredicationDropsUngatedWork`: `crates/metal2vulkan-runtime/src/predication.rs:748 (unbalanced)` - `gap::MultisampledBufferCopy`: `crates/metal2vulkan-runtime/src/blit_texture.rs:536 (copy_from_buffer_to_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:693 (copy_from_texture_to_buffer)` -- `gap::MultisampledBufferLayout`: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1029 (plan)` +- `gap::MultisampledBufferLayout`: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1020 (plan)` - `gap::ColorAttachmentGroups`: `crates/metal2vulkan-runtime/src/render/color_groups.rs:106 (gap)` -- `apple::ProtectedContent`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2386 (commit_now)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126 (refuse_protected_state_encoder)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:52 (set)` +- `apple::ProtectedContent`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2398 (commit_now)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126 (refuse_protected_state_encoder)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:52 (set)` - `apple::LineWidth`: `crates/metal2vulkan-runtime/src/apple_only.rs:189 (check)` - `apple::ViewportTransformDisabled`: `crates/metal2vulkan-runtime/src/apple_only.rs:191 (check)` - `apple::VertexAmplificationMode`: `crates/metal2vulkan-runtime/src/apple_only.rs:195 (check)`; `crates/metal2vulkan-runtime/src/apple_only.rs:320 (set_vertex_amplification_mode)` diff --git a/docs/RUNTIME-PORTING.md b/docs/RUNTIME-PORTING.md index b534bd2ac..3395885d9 100644 --- a/docs/RUNTIME-PORTING.md +++ b/docs/RUNTIME-PORTING.md @@ -162,9 +162,9 @@ narrow refusal that the call's rustdoc describes. | `DispatchThreads` | `dispatchThreads:threadsPerThreadgroup:` | `ComputeCommandEncoder::dispatch_threads` | | `DispatchThreadsIndirect` | `dispatchThreadsWithIndirectBuffer:indirectBufferOffset:` (SPI) | `ComputeCommandEncoder::dispatch_threads_indirect` (a host step reads the arguments); refused at `MacOS26_7` as `dispatch_threadgroups_indirect` is | | `EncodeStartDoWhile` | `encodeStartDoWhile` (SPI) | `ComputeCommandEncoder::encode_start_do_while`, as Metal runs it, its body in its unit's later encoders included, nested to any depth, laid down as 64 copies of the loop's commands (16 inside another loop, fewer past 16384 steps and gated dispatches, at least one), submitted again from where the loop stopped until it ends; a loop without bound runs until the process ends, as Metal's does | -| `EncodeStartElse` | `encodeStartElse` (SPI) | `ComputeCommandEncoder::encode_start_else`, as Metal runs it; with no block open an unbalanced record, dropping its range of the unit's work as Metal's does; refused where that range holds dispatches from before the unit's first record (`NotImplemented(PredicationDropsUngatedWork)`) *(partial)* | -| `EncodeStartIf` | `encodeStartIf:offset:comparison:referenceValue:` (SPI) | `ComputeCommandEncoder::encode_start_if`, as Metal runs it, on a counter the runtime's step kernel moves; a live block open where its unit ends fails the command buffer where its commands skip there, as Metal's GPU recovery does (`PredicationOpenAtUnitEnd`); a word past its buffer reads as Metal reads it (the heap's bytes, or zero; zero announced where Metal reads unrelated memory); refused: a nil buffer with no block open where `encode_start_else` refuses *(partial)* | -| `EncodeStartWhile` | `encodeStartWhile:offset:comparison:referenceValue:` (SPI) | `ComputeCommandEncoder::encode_start_while`, as Metal runs it, laid down as `encode_start_do_while`'s loops are; refused as `encode_start_if` refuses *(partial)* | +| `EncodeStartElse` | `encodeStartElse` (SPI) | `ComputeCommandEncoder::encode_start_else`, as Metal runs it; with no block open an unbalanced record, dropping its range of the unit's work as Metal's does, the unit's dispatches before its first record included | +| `EncodeStartIf` | `encodeStartIf:offset:comparison:referenceValue:` (SPI) | `ComputeCommandEncoder::encode_start_if`, as Metal runs it, on a counter the runtime's step kernel moves; a live block open where its unit ends fails the command buffer where its commands skip there, as Metal's GPU recovery does (`PredicationOpenAtUnitEnd`); a word past its buffer reads as Metal reads it (the heap's bytes, or zero; zero announced where Metal reads unrelated memory) *(partial)* | +| `EncodeStartWhile` | `encodeStartWhile:offset:comparison:referenceValue:` (SPI) | `ComputeCommandEncoder::encode_start_while`, as Metal runs it, laid down as `encode_start_do_while`'s loops are; its word read as `encode_start_if` reads it *(partial)* | | `EndEncoding` | `endEncoding` | `ComputeCommandEncoder::end_encoding` | | `ExecuteCommandsIndirect` | `executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:` | `ComputeCommandEncoder::execute_commands_in_buffer_indirect`; `_checked` adds an `IndirectCommandCheck` its host step calls on each command first, and the `IndirectCommandCheckNeeds` it looks for | | `ExecuteCommandsInBuffer` | `executeCommandsInBuffer:withRange:` | `ComputeCommandEncoder::execute_commands_in_buffer`; `_checked` adds an `IndirectCommandCheck` that `commit` (for the CPU's records) or a host step calls on each command first, and the `IndirectCommandCheckNeeds` it looks for, which may rule it out (then it runs on the GPU alone where it can) | @@ -194,9 +194,9 @@ narrow refusal that the call's rustdoc describes. | Item | Metal | Runtime | |---|---|---| | `encode` | | one `ComputeCommandEncoder` method per `ComputeCmd` (above) | -| `encode_end_do_while` | `encodeEndDoWhile:offset:comparison:referenceValue:` (SPI) | `ComputeCommandEncoder::encode_end_do_while`, answering Metal's `BOOL`; with no block open answering `NO` and dropping its range as Metal's does; refused as `encode_start_if` refuses *(partial)* | -| `encode_end_if` | `encodeEndIf` (SPI) | `ComputeCommandEncoder::encode_end_if`, answering Metal's `BOOL`; with no block open answering `NO` and dropping its range as Metal's does; refused as `encode_start_else` refuses *(partial)* | -| `encode_end_while` | `encodeEndWhile` (SPI) | `ComputeCommandEncoder::encode_end_while`, answering Metal's `BOOL`; with no block open answering `NO` and dropping its range as Metal's does; refused as `encode_start_else` refuses *(partial)* | +| `encode_end_do_while` | `encodeEndDoWhile:offset:comparison:referenceValue:` (SPI) | `ComputeCommandEncoder::encode_end_do_while`, answering Metal's `BOOL`; with no block open answering `NO` and dropping its range as Metal's does; its word read as `encode_start_if` reads it *(partial)* | +| `encode_end_if` | `encodeEndIf` (SPI) | `ComputeCommandEncoder::encode_end_if`, answering Metal's `BOOL`; with no block open answering `NO` and dropping its range as Metal's does | +| `encode_end_while` | `encodeEndWhile` (SPI) | `ComputeCommandEncoder::encode_end_while`, answering Metal's `BOOL`; with no block open answering `NO` and dropping its range as Metal's does | ### `TextureDescriptor`: `MTLTextureDescriptor` diff --git a/scripts/refusal-surface/reach.tsv b/scripts/refusal-surface/reach.tsv index 3cdd0ae95..e67592d89 100644 --- a/scripts/refusal-surface/reach.tsv +++ b/scripts/refusal-surface/reach.tsv @@ -229,7 +229,6 @@ feature TileReach app the tiles a pass's draws reach, binned on a device without feature CommandPredication none Apple-private command predication on a device without buffer device addresses feature ProgramScopeBinding app MSL 3.2 program-scope buffer bindings (macOS 15 and later) feature SeqCstFence rare a seq_cst fence in a vertex or fragment stage without its stores and atomics -gap PredicationDropsUngatedWork none an unbalanced Apple-private command-predication record as its unit's first, after dispatches of the unit gap MultisampledBufferCopy rare a buffer<->multisampled-texture copy on a device without sample-rate shading, an integer multisample attachment at the count, or the copy format's storage; and, where maintenance8's depth/colour copies are missing or wrong, what the sample-rate draws cannot move: a 16-bit depth, or a depth or stencil texture they cannot sample or render to (emulated elsewhere; the consumer's Maps pans and screensaver make the copy) gap MultisampledBufferLayout rare a buffer<->multisampled-texture copy at a bytesPerRow of 0 from an offset that is a multiple of 16, or of pixels of 32 bytes or more at a pitch below a row or off the pixel: Metal copies these by rules not yet reduced, and its API validation rejects them gap ColorAttachmentGroups app in a render pass of more color attachments than the device draws at once (five or more on a device of four), or one at an index past them: a pipeline state of other colors, a tile state, an execution of render commands, a draw reading another group's attachment