From 7af3c4228a6cc0af3ff26caa0b885551bf97d862 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 14 Nov 2026 01:59:11 -0800 Subject: [PATCH] RUNTIME 2272: a failure inside a group of folded compute encoders fails only the encoders it names RUNTIME 2268 failed a whole group of compute encoders recorded into one VkCommandBuffer when a failure (commit_failed's From(n) or Set, a fault, a recording failure) named only some of them. Metal runs every encoder the failure leaves, so a From(n) inside a group dropped the work of the encoders before n: a consumer's protection probe (a compute encoder, then one made under protection options it fails From) read the first encoder's words as never written. Now every compute encoder logs its calls (replay.rs), a closed group keeps its members' logs until the commit, and the commit splits a group its failure fails in part (State::split_failure): the members that run are encoded again from their logs, each into VkCommandBuffers of its own, in the commit's call before the scheduler sees the batches (the rebind's encode-again path, held by the same mark); the shared VkCommandBuffer is never submitted and the failed members run nothing. Groups no failure splits give their logs back at the commit. The split also works in a command buffer that used command predication where its encoders are alone. The one remaining difference (docs/API.md section 10, FAST-PATHS known gaps): a group whose predication unit later laid a loop (encode_start_while / encode_start_do_while) or left a record unbalanced still fails whole. pending_rebind's test reaches its no-log case through an If opened by the encoder before (Unlogged::Predicated), since compute encoders now always log; Unlogged::NoCalls's doc and notice text name what logs nothing now. Cost (dchain, 5080 node CPU, dispatch_chain --host 20 --runs 9 --only encoders --dispatches 2300, no host-page buffer, ABAB, ns a dispatch): thread_cpu 3393/3396 -> 3539/3809; commit 113-126 -> 221-223 (logs held until commit; a follow-up gives them back under one lock and keeps them as spares); bind 49-50 -> 96-97 (the log itself, stays). RUNTIME_VERSION 2272: folded groups split at a partial failure. Verified (dchain): lavapipe full runtime suite at c118ca6fb6 (m3-max-28648) 2581 passed, 1 failed (host_ram_copy_device private-bit, the same at 09068993d6, owned by roip); pending_rebind negative control (guard removed) fails on VUID-VkDescriptorBufferInfo-buffer-parameter; RTX 5080 208/208 (encoder_fold, rebind, reencode, command_buffer, dispatch, predication, replay, fence, indirect, compute, failed); negative control at dd286c7304 (m3-max-28590): the four failure tests fail, the consumer-shaped one included. Squashed from steelbrain/dchain2 89480ccfd3..c118ca6fb6. --- .../src/command_buffer/fold.rs | 122 +++++++++++--- .../src/command_buffer/mod.rs | 76 +++++++-- .../src/command_buffer/rebound_use.rs | 10 +- .../src/command_buffer/reencode.rs | 44 ++++- crates/metal2vulkan-runtime/src/compute.rs | 18 +- .../metal2vulkan-runtime/src/encoder_fold.rs | 44 +++-- crates/metal2vulkan-runtime/src/replay.rs | 7 +- .../src/tests/encoder_fold.rs | 154 ++++++++++++++++-- .../src/tests/pending_rebind.rs | 29 ++-- .../src/tests/tile_rebind_making_wait.rs | 5 +- .../metal2vulkan-runtime/src/work_counts.rs | 4 +- crates/metal2vulkan/src/cache/mod.rs | 2 +- docs/API.md | 30 ++-- docs/FAST-PATHS.md | 10 ++ 14 files changed, 433 insertions(+), 122 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/command_buffer/fold.rs b/crates/metal2vulkan-runtime/src/command_buffer/fold.rs index d92393d72..aaccc4e24 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/fold.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/fold.rs @@ -1,6 +1,6 @@ //! A command buffer's groups of compute encoders recorded into one `VkCommandBuffer` //! (`encoder_fold.rs`): the group its tail holds, which compute encoder joins it, its logs, and -//! the failures that fail a whole group. +//! the failures that split a group. use super::{FailedEncoders, Failure, State}; use crate::encoder_fold::{Fold, FoldEnd, FoldOrder, Joining, Stashed}; @@ -9,7 +9,6 @@ use crate::resource::ResourceKey; use crate::tracker::Summary; use crate::work_counts::Counters; use std::collections::BTreeSet; -use std::ops::Range; impl State { /// The group the compute encoder opening now joins, asking `joining`, where its command @@ -96,10 +95,12 @@ impl State { /// Close the group the command buffer's tail holds, where it holds one: no encoder joins it /// any more. Where it holds more than one encoder, each notes the group's encoders, which a - /// failure and a rebind take together (`widen_failure`, `reencode.rs`), and the logs its + /// failure and a rebind take together (`split_failure`, `reencode.rs`), and the logs its /// members did not keep are kept where one member kept its own and the command buffer used no - /// command predication, so the group can be encoded again; else they come back, for the - /// caller to give back to the device's spares without this lock (`replay.rs`). + /// command predication, so a rebind can encode the group again; else they are held until the + /// commit, whose failure may split the group ([`split_failure`](Self::split_failure)). A lone + /// encoder's comes back, for the caller to give back to the device's spares without this lock + /// (`replay.rs`). pub(crate) fn close_fold(&mut self, counts: &Counters) -> Vec { let Some(fold) = self.fold.take() else { return Vec::new(); @@ -115,7 +116,8 @@ impl State { } let logged = (self.ended[members.clone()].iter()).any(|record| record.replay.is_some()); if !logged || self.predicated { - return stashed.into_iter().map(|stashed| stashed.log).collect(); + self.held_logs.extend(stashed); + return Vec::new(); } let mut unkept = Vec::new(); for Stashed { @@ -133,27 +135,95 @@ impl State { unkept } - /// `failure`, its failed encoders widened to every encoder of each group one of them lies in - /// (`encoder_fold.rs`'s **Failed**): a group's encoders record into one `VkCommandBuffer`, which - /// runs all of them or none. Unchanged where it fails no group in part. - pub(super) fn widen_failure(&self, mut failure: Failure) -> Failure { - let group = |encoder: usize| -> Option> { - self.ended - .get(encoder) - .and_then(|record| record.group.clone()) + /// At the commit, `failure` as the groups of compute encoders recorded into one + /// `VkCommandBuffer` take it (`encoder_fold.rs`'s **Failed**): a group it fails in part is + /// split, each encoder of it that runs to be encoded again from its log, kept now, into + /// `VkCommandBuffer`s of its own before the first submission (`reencode.rs`), and the group's + /// shared one never submitted; where one of them cannot be encoded again (its unit of command + /// predication laid a loop or left work out, `Predication::alone`), the failure fails that + /// whole group instead. With + /// `failure`, the encoders that run of each group split, the units to encode again. The logs + /// held for the commit that no split takes come back, for the caller to give back to the + /// device's spares without this lock. + pub(super) fn split_failure( + &mut self, + failure: Option, + ) -> (Option, Vec>, Vec) { + let mut units = Vec::new(); + let Some(mut failure) = failure else { + let held = self.held_logs.drain(..).map(|held| held.log).collect(); + return (None, units, held); }; - failure.encoders = match failure.encoders { - FailedEncoders::From(first) => match group(first) { - Some(group) => FailedEncoders::From(group.start), - None => FailedEncoders::From(first), - }, - FailedEncoders::Set(set) => { - let widened: BTreeSet = (set.iter()) - .flat_map(|&encoder| group(encoder).unwrap_or(encoder..encoder + 1)) - .collect(); - FailedEncoders::Set(widened) + let groups: BTreeSet<(usize, usize)> = (self.ended.iter()) + .filter_map(|record| record.group.as_ref()) + .map(|group| (group.start, group.end)) + .collect(); + let mut whole = BTreeSet::new(); + for (start, end) in groups { + let fails = |encoder: &usize| failure.encoders.fails(*encoder); + let running: Vec = (start..end).filter(|encoder| !fails(encoder)).collect(); + if running.is_empty() || running.len() == end - start { + continue; } - }; - failure + let logged = running.iter().all(|&encoder| { + (!self.predicated || self.predication.alone(encoder)) + && (self.ended[encoder].replay.is_some() + || self.held_logs.iter().any(|held| held.encoder == encoder)) + }); + if !logged { + whole.extend(start..end); + continue; + } + for &encoder in &running { + let Some(at) = (self.held_logs.iter()).position(|held| held.encoder == encoder) + else { + continue; + }; + let Stashed { + log, executions, .. + } = self.held_logs.swap_remove(at); + if let Some(log) = self.keep_replay(encoder, Some(log), executions.clone()) { + self.held_logs.push(Stashed { + encoder, + log, + executions, + }); + } + } + // Encoded again apart, its encoders share no `VkCommandBuffer` any more. + for record in &mut self.ended[start..end] { + record.group = None; + } + units.push(running); + } + if !whole.is_empty() { + failure.encoders = failure.encoders.with(&whole, self.ended.len()); + } + let held = self.held_logs.drain(..).map(|held| held.log).collect(); + (Some(failure), units, held) + } + + /// `encoders`, a group's encoders the commit split that run (`split_failure`), whose + /// encoding again failed: they run nothing after all, as the failure's encoders do, the + /// shared `VkCommandBuffer` among them never submitted (`encoder_fold.rs`'s **Failed**). + pub(super) fn fail_unsplit(&mut self, encoders: &[usize]) { + let failed: BTreeSet = encoders.iter().copied().collect(); + let State { + recorded, + retained, + ended, + .. + } = self; + for part in recorded + .iter_mut() + .filter(|part| failed.contains(&part.encoder)) + { + State::fail_part(part, ended, retained); + } + let ended = self.ended.len(); + self.failed_at_commit = Some(match self.failed_at_commit.take() { + Some(before) => before.with(&failed, ended), + None => FailedEncoders::Set(failed), + }); } } diff --git a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs index 3651c3984..27437706f 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs @@ -584,6 +584,32 @@ pub enum FailedEncoders { } impl FailedEncoders { + /// These encoders and `more` besides, of `ended` ended encoders: a first failed encoder that + /// `more` reaches up to from below moves back to the first of them, and stays a suffix where + /// `more` holds no encoder before that; else a set (`encoder_fold.rs`'s **Failed**). + pub(super) fn with(self, more: &BTreeSet, ended: usize) -> FailedEncoders { + match self { + FailedEncoders::From(first) => { + let mut start = first; + while start > 0 && more.contains(&(start - 1)) { + start -= 1; + } + match more.iter().all(|&encoder| encoder >= start) { + true => FailedEncoders::From(start), + false => FailedEncoders::Set( + (first..ended.max(first)) + .chain(more.iter().copied()) + .collect(), + ), + } + } + FailedEncoders::Set(mut set) => { + set.extend(more); + FailedEncoders::Set(set) + } + } + } + /// Whether encoder `encoder` runs nothing. pub(super) fn fails(&self, encoder: usize) -> bool { match self { @@ -804,6 +830,12 @@ pub(super) struct State { /// compute encoder may join, recording on into it (`encoder_fold.rs`); held by that encoder /// while it is open. pub(super) fold: Option>, + /// The logs of the closed groups' encoders kept for nothing else, held until the commit, + /// whose failure may split a group (`fold.rs`'s `split_failure`). + pub(super) held_logs: Vec, + /// The encoders that run of each group the commit's failure split, which its call encodes + /// again before the first submission (`reencode.rs`). + pub(super) split_units: Vec>, /// The batches whose end went into their last `VkCommandBuffer` (`submit.rs`): each batch's /// index, that command buffer, and whether it wrote the command buffer's end timestamp. folds: Vec, @@ -2506,6 +2538,8 @@ impl CommandBuffer { recorded: Revised::new(Vec::new(), &footprints.revision), tail: None, fold: None, + held_logs: Vec::new(), + split_units: Vec::new(), folds: Vec::new(), prefix: None, batches: Revised::new(Batches::default(), &footprints.revision), @@ -3596,9 +3630,11 @@ impl CommandBuffer { /// each one's kind, its place among the event waits and signals, and what it uses. A command /// buffer Metal fails from a render pass on ([`commit`](Self::commit)) fails from there too, /// whatever `failure` names, and signals no event after the pass; it completes with - /// `failure.code`. Differs: compute encoders recorded into one `VkCommandBuffer` - /// (`WorkCounts::encoders_folded`) fail together, so a first failed encoder or a set member - /// inside such a group fails the whole group (docs/API.md, section 10). + /// `failure.code`. Compute encoders recorded into one `VkCommandBuffer` + /// (`WorkCounts::encoders_folded`) that `failure` fails in part are recorded again apart at + /// the commit, so exactly the encoders it names run nothing. Differs: where such a group's + /// unit of command predication laid a loop or left work out, a failure inside the group fails + /// the whole group (docs/API.md, section 10). /// /// Refused, changing nothing, as [`commit`](Self::commit) is; and for a set naming an /// encoder past the ended ones (`Invalid`, `Problem::IndexOutOfRange`, its `limit` the @@ -3812,12 +3848,13 @@ impl CommandBuffer { for log in unkept { device.shared().scheduler.spare_logs().give(log); } - let (segments, places, failure, reached, hangs): ( + let (segments, places, failure, reached, hangs, (split, held)): ( Vec<(Deferred, bool)>, Vec, _, _, _, + _, ) = { let mut state = self.state(); let refusal = match run { @@ -3932,9 +3969,10 @@ impl CommandBuffer { true => Some(Failure::revoked()), false => failure, }; - // A group of compute encoders in one `VkCommandBuffer` runs whole or not at all - // (`encoder_fold.rs`). - let failure = failure.map(|failure| state.widen_failure(failure)); + // A group of compute encoders in one `VkCommandBuffer` the failure fails in part is + // split: its encoders that run are encoded again apart before the first submission + // (`encoder_fold.rs`'s **Failed**). + let (failure, split, held) = state.split_failure(failure); // The encoders that run: all but those `failure` fails. let runs = |encoder: usize| Failure::runs(failure.as_ref(), encoder); state.committing = true; @@ -3978,8 +4016,11 @@ impl CommandBuffer { .dirty .committed(&mut lock(&self.0.dirty), &held, waits, unnoted); } - (segments, places, failure, reached, hangs) + (segments, places, failure, reached, hangs, (split, held)) }; + for log in held { + device.shared().scheduler.spare_logs().give(log); + } // What the commands of its encoders that run use is resident from its commit on, as // Metal's is: a no-copy buffer or a heap among it is reached unnamed from here, by its // own commands too, the work recorded below included (`live_buffers.rs`). Listed without @@ -4098,7 +4139,7 @@ impl CommandBuffer { } copies_again = CopiesAgain::new(unreached, (used, written)); } - let (waits, away, reaches, unreplayable, reset) = { + let (waits, away, reaches, unreplayable, (reset, splits)) = { let mut state = self.state(); state.committing = false; state.copies_again = copies_again; @@ -4183,6 +4224,13 @@ impl CommandBuffer { if reset.0 { self.0.mark_reencode(); } + // So are the encoders that run of a group its failure split, encoded again in this + // call, before the scheduler sees the command buffer's batches. + let splits = !split.is_empty(); + if splits { + state.split_units = split; + self.0.mark_reencode(); + } if let Some(slot) = lock(&self.0.slot).as_mut() { slot.committed(); } @@ -4256,7 +4304,13 @@ impl CommandBuffer { .find(|image| image.rests_out_of_general()); // Its commands may reach every texture through its resource ID where one bound a // heap set. - (waits, away, state.heaps.bound(), unreplayable, reset) + ( + waits, + away, + state.heaps.bound(), + unreplayable, + (reset, splits), + ) }; // Each making the batches wait for wakes the scheduler as it finishes, with no lock // held (`render/pending.rs`), registered before the scheduler first looks at the batches: @@ -4305,7 +4359,7 @@ impl CommandBuffer { // as a reset's are; its first submission waits for them (marked above). Those it cannot // encode again are announced. let (again, unencoded) = reset; - if again { + if again || splits { self.0.reencode(); } for unlogged in unencoded { diff --git a/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs b/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs index 2bad9b103..d27d717e5 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/rebound_use.rs @@ -9,8 +9,9 @@ use std::fmt; /// Why an ended encoder kept no log a rebind encodes it again from (`replay.rs`). #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(crate) enum Unlogged { - /// It logged no calls: the device had no buffer over host pages as it opened, or it is of a - /// kind that logs none (a resource state encoder's). + /// It logged no calls: a blit or render encoder that opened while the device had no buffer + /// over host pages, a compute encoder that recorded a loop of command predication + /// (`predication.rs`), or one of a kind that logs none (a resource state encoder's). NoCalls, /// It left work for later that an encoding again does not record at once: a host step's (a /// GPU-written indirect dispatch's, a scatter into a guest RAM staged through the CPU's, @@ -66,8 +67,9 @@ impl fmt::Display for Unlogged { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match self { Unlogged::NoCalls => { - "it logged no calls (no buffer over host pages as it opened, or a kind that \ - logs none)" + "it logged no calls (a blit or render encoder opened with no buffer over host \ + pages, a compute encoder that recorded a predicated loop, or a kind that logs \ + none)" } Unlogged::Segments => "it left work for later an encoding again does not record", Unlogged::Fails => "its command buffer fails it as it commits", diff --git a/crates/metal2vulkan-runtime/src/command_buffer/reencode.rs b/crates/metal2vulkan-runtime/src/command_buffer/reencode.rs index fe020977b..8560f8e95 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/reencode.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/reencode.rs @@ -62,6 +62,12 @@ //! (`encoder_fold.rs`) are encoded again together: a rebind that moves one encodes each again, //! into `VkCommandBuffer`s of its own, and puts them in their places together, or puts none //! where one of them kept no log, is refused or does not fit its place. +//! - **Split at the commit.** A commit whose failure fails some of a group's encoders and not the +//! others (`encoder_fold.rs`'s **Failed**) marks the command buffer as a rebind does, and its +//! own call encodes the group's encoders that run again, each into `VkCommandBuffer`s of its +//! own, before the scheduler sees its batches; where one cannot be encoded again or does not +//! fit its place, those encoders run nothing after all (`State::fail_unsplit`), as the whole +//! group would have. //! - **What cannot be encoded again stays as before.** An encoder whose log is gone (a compute //! encoder of a command buffer that used command predication whose unit laid a step before it //! opened, or one of its own that the unit's later encoders read, or a loop, or left work out; @@ -124,7 +130,9 @@ impl CommandBufferShared { // So are those whose pass took a rasterization-rate map since reset; one that kept no // log draws by the map as it took it, announced (`rate_mapped_pass.rs`). let mut unencoded = Vec::new(); - let units: Vec)>> = { + // Each unit with whether the commit's failure split it from its group: its encoders run + // nothing where they cannot all be encoded again (`encoder_fold.rs`'s **Failed**). + let units: Vec<(bool, Vec<(usize, Arc)>)> = { let mut state = lock(&self.state); match state.finished() { true => Vec::new(), @@ -132,9 +140,24 @@ impl CommandBufferShared { let open: BTreeSet = (state.recorded[state.unjudged_parts()..].iter()) .map(|part| part.encoder) .collect(); + let split: Vec> = state.split_units.drain(..).collect(); + let splitting: BTreeSet = split.iter().flatten().copied().collect(); + let mut units = Vec::new(); + for unit in split { + let logs: Option)>> = (unit.iter()) + .map(|&at| { + let log = state.ended.get(at)?.replay.as_ref()?; + Some((at, Arc::clone(log))) + }) + .collect(); + match logs { + Some(logs) => units.push((true, logs)), + None => state.fail_unsplit(&unit), + } + } let submitting = device.shared().rebinds.submitting(); let moved: Vec<(usize, Arc)> = (state.ended.iter().enumerate()) - .filter(|(at, _)| open.contains(at)) + .filter(|(at, _)| open.contains(at) && !splitting.contains(at)) .filter_map(|(at, record)| { let reset = record.taken.rate_map_reset(); let Some(replay) = record.replay.as_ref() else { @@ -147,7 +170,9 @@ impl CommandBufferShared { moved.then(|| (at, Arc::clone(replay))) }) .collect(); - state.encoded_together(moved, &device.shared().counts) + let together = state.encoded_together(moved, &device.shared().counts); + units.extend(together.into_iter().map(|unit| (false, unit))); + units } } }; @@ -160,7 +185,8 @@ impl CommandBufferShared { // Each unit's encoders are encoded again before any takes its place: a group of compute // encoders recorded into one `VkCommandBuffer` takes its places whole or not at all // (`encoder_fold.rs`). - for unit in units { + for (split, unit) in units { + let members: Vec = unit.iter().map(|(at, _)| *at).collect(); let mut again = Vec::new(); for (at, replay) in &unit { match self.encode_again(&handle, *at, replay) { @@ -169,7 +195,9 @@ impl CommandBufferShared { } } if again.len() < unit.len() { - if unit.len() > 1 { + if split { + lock(&self.state).fail_unsplit(&members); + } else if unit.len() > 1 { let mut state = lock(&self.state); for (at, _) in &unit { let record = &mut state.ended[*at]; @@ -215,6 +243,9 @@ impl CommandBufferShared { Err(unspliced) => { counts.reencode_refused(); state.ended[done.at].refused = Some(UNFIT.to_owned()); + if split { + state.fail_unsplit(&[done.at]); + } drop(unspliced); } } @@ -227,6 +258,9 @@ impl CommandBufferShared { Vec::new() } false => { + if split { + state.fail_unsplit(&members); + } for done in &again { counts.reencode_refused(); let refusal = match unit.len() { diff --git a/crates/metal2vulkan-runtime/src/compute.rs b/crates/metal2vulkan-runtime/src/compute.rs index c0f1002b2..3023134de 100644 --- a/crates/metal2vulkan-runtime/src/compute.rs +++ b/crates/metal2vulkan-runtime/src/compute.rs @@ -189,8 +189,7 @@ pub struct ComputeCommandEncoder { residency: Residency, /// The bodies of the predicated loops it opened and has not closed (`predication.rs`). captures: Captures, - /// Its calls so far, where the device had a buffer over host pages as it opened - /// (`replay.rs`): `None` where it logs nothing, or no longer. + /// Its calls so far (`replay.rs`): `None` where it logs no longer. log: Option>, /// Its dispatches encoded so far: the next one's order among them, which one whose /// pipelines are being made keeps for its failure (`FailedPipeline::draw`). @@ -270,14 +269,11 @@ impl CommandBuffer { let _for = self.notices_for(); // Metal's process ends here under some protection options (`command_buffer/protection.rs`). self.refuse_protected_encoder(call)?; - // It logs its calls where the device has a buffer over host pages (`replay.rs`), and joins - // the group of compute encoders before it, recording into their `VkCommandBuffer`, where - // it may (`encoder_fold.rs`). - let logs = self.device().shared().rebinds.any(); - let joining = Joining { - dispatch_type, - logs, - }; + // It joins the group of compute encoders before it, recording into their + // `VkCommandBuffer`, where it may (`encoder_fold.rs`); and it logs its calls (`replay.rs`), + // which encode it again at a rebind of a buffer over host pages it named, or at a commit + // whose failure fails some of its group's encoders and not it. + let joining = Joining { dispatch_type }; let serial = dispatch_type == DispatchType::Serial; let core = EncoderCore::open(self, call, EncoderKind::Compute, (serial, Some(joining)))?; // It joins its command buffer's unit of command predication, carrying on the loops open @@ -301,7 +297,7 @@ impl CommandBuffer { indirect_stage_in: None, residency: self.inherited_residency(false), captures: Captures::carried(carried), - log: logs.then(|| self.device().shared().scheduler.spare_logs().compute()), + log: Some(self.device().shared().scheduler.spare_logs().compute()), dispatches: 0, // The bind state the device's last ended compute encoder left (`compute/live.rs`). live: self.device().shared().live_dispatches.take(), diff --git a/crates/metal2vulkan-runtime/src/encoder_fold.rs b/crates/metal2vulkan-runtime/src/encoder_fold.rs index 9233819f2..e25eff693 100644 --- a/crates/metal2vulkan-runtime/src/encoder_fold.rs +++ b/crates/metal2vulkan-runtime/src/encoder_fold.rs @@ -14,11 +14,11 @@ //! whose recording is one part, with no work left for later (no segment), no fence update and //! nothing that fails or faults its command buffer, in the same batch (no event or semaphore //! wait or signal, host step or resource state encoder since: `Batches`), where the command -//! buffer used no command predication, the encoder trail is off, its protection options are 0, -//! and both encoders log their calls or neither does (`replay.rs`). So a group lies inside one -//! batch and one unit of command predication (`predication.rs`), and a fence orders nothing -//! inside it: what a later encoder waits for is updated after the group's last. Counted: -//! `WorkCounts::encoders_folded`. +//! buffer used no command predication, the encoder trail is off and its protection options are +//! 0. So a group lies inside one batch and one unit of command predication (`predication.rs`), +//! and a fence orders nothing inside it: what a later encoder waits for is updated after the +//! group's last. Every compute encoder logs its calls (`replay.rs`), so each of a group's +//! encoders can be encoded again apart. Counted: `WorkCounts::encoders_folded`. //! - **The barrier between them** is recorded as the encoder records, by the rule the tracker //! applies between two encoders of one batch: from each earlier write of a tracked resource's //! overlapping range to a later read or write, its accesses made visible, and from each earlier @@ -38,15 +38,24 @@ //! goes on in its own, which its part holds, planned as any part is. //! - **Encoded again** (`command_buffer/reencode.rs`). A rebind that moves a buffer one encoder of //! a group named encodes every encoder of the group again, each into `VkCommandBuffer`s of its -//! own, or none: the shared one is never submitted. So each group member's log is held until the -//! group closes and kept for every member where one member keeps its own. A group with a member -//! that cannot be encoded again is not encoded again, and its moved members are refused. -//! - **Failed.** A failure of the command buffer that fails one encoder of a group fails every -//! encoder of it (`State::widen_failure`): a recording failure at a folded encoder's end, and -//! `CommandBuffer::commit_failed` with a set or a first failed encoder that falls inside a -//! group. A first failed encoder at a group's boundary (an encoder made under protection -//! options, which never folds, or one that is not a compute encoder) fails what it failed -//! before (docs/API.md, "A command buffer committed as failed"). +//! own, or none: the shared one is never submitted. A group with a member that cannot be encoded +//! again is not encoded again, and its moved members are refused. +//! - **Failed.** A failure of the command buffer that fails some of a group's encoders and not +//! the others (`CommandBuffer::commit_failed`'s first failed encoder or set inside a group, a +//! recording failure or a fault at a folded encoder) splits the group at the commit +//! (`State::split_failure`): the encoders that run are encoded again from their logs, each into +//! `VkCommandBuffer`s of its own, before the first submission, the shared one never submitted, +//! and the failed ones run nothing: exactly the encoders the failure names run nothing, as on +//! Metal. Where the encoders that run cannot all be encoded again (their unit of command +//! predication laid a loop or left work out, so a command of theirs encoded again would run +//! outside its block: `Predication::alone`; or a call answers otherwise when encoded again), +//! the failure fails the whole group (docs/API.md, "A command buffer committed as failed"). +//! - **Logs.** A group's members' logs are held from the group's close until the commit, which +//! keeps them for every member where one member keeps its own for a rebind, keeps those of a +//! group its failure splits, and gives the rest back to the device's spares. A log holds one +//! `ComputeCall` per call (at most 64 bytes, `tests::encoder_fold`) besides the bytes and handles +//! its slices take in its arenas: a one-dispatch encoder's five calls (state, three buffers, the +//! dispatch) hold about 320 bytes, so 2,300 such encoders hold about 0.7 MiB until the commit. use crate::key_hash::KeyMap; use crate::replay::Replay; @@ -239,7 +248,7 @@ pub(crate) fn joined(own: Option, fold: Option) -> Option, diff --git a/crates/metal2vulkan-runtime/src/replay.rs b/crates/metal2vulkan-runtime/src/replay.rs index 9fb227c76..4cf0b4a9e 100644 --- a/crates/metal2vulkan-runtime/src/replay.rs +++ b/crates/metal2vulkan-runtime/src/replay.rs @@ -15,9 +15,10 @@ //! ([`CallLog::refuse`]: the encoder's `logged`, a render encoder's call made at once): encoded //! again, it is refused again and the calls after it run, as they ran after its refusal. A call //! that answers otherwise than at its first encoding leaves the encoder as it was encoded first -//! ([`Replay::run`] fails, and the encoder is not encoded again). The log starts at the -//! encoder's open where the device has a buffer over host pages (`Rebinds::any`); else nothing -//! is logged. It costs one push per call; a slice of buffers, offsets, textures or bytes goes +//! ([`Replay::run`] fails, and the encoder is not encoded again). A blit or render encoder's +//! log starts at its open where the device has a buffer over host pages (`Rebinds::any`), else +//! it logs nothing; a compute encoder always logs, as a commit whose failure splits the group of +//! compute encoders it recorded with encodes it again (`encoder_fold.rs`). It costs one push per call; a slice of buffers, offsets, textures or bytes goes //! into one of the log's arenas, so the common calls allocate nothing of their own. //! - **What is kept.** The command buffer keeps an ended encoder's log only where a command of //! it named a buffer over host pages and the encoder can be encoded again: it left no segment diff --git a/crates/metal2vulkan-runtime/src/tests/encoder_fold.rs b/crates/metal2vulkan-runtime/src/tests/encoder_fold.rs index 9d8121e5e..ee7ac9daf 100644 --- a/crates/metal2vulkan-runtime/src/tests/encoder_fold.rs +++ b/crates/metal2vulkan-runtime/src/tests/encoder_fold.rs @@ -1,7 +1,7 @@ //! Consecutive compute encoders of one command buffer recorded into one `VkCommandBuffer` //! (`encoder_fold.rs`): which encoders join a group and what ends one, the barrier the tracker's -//! rule records between two encoders of a group, a failure that fails a group whole, and a rebind -//! that encodes a group again whole. +//! rule records between two encoders of a group, a failure that splits a group at the commit, and +//! a rebind that encodes a group again whole. //! //! [`dependent_encoders_of_a_group_read_what_the_encoders_before_them_wrote`] is the barrier's //! check: each small encoder reads the tail of the large write the encoder before it made, which @@ -331,8 +331,9 @@ fn a_fence_update_ends_a_group() { } /// Three encoders of one group, a blit encoder's fill, and a compute encoder after it, committed -/// as failed with `encoders`: which of the five ran, read from what each wrote. -fn failed_with(encoders: FailedEncoders) -> [bool; 5] { +/// as failed with `encoders`: which of the five ran, read from what each wrote, and how many +/// encoders the commit encoded again (`WorkCounts::encoders_reencoded`). +fn failed_with(encoders: FailedEncoders) -> ([bool; 5], u64) { let scratch = Scratch::new("fold-failed"); let kernel = Kernel::new(&scratch); let device = &kernel.device; @@ -368,31 +369,154 @@ fn failed_with(encoders: FailedEncoders) -> [bool; 5] { command_buffer.error(), Some(CommandBufferError::Injected(2)) ); + let after = device.work_counts(); + for (at, output) in outputs.iter().enumerate() { + let words = words_of(output); + let ran = words.iter().any(|&word| word != 0); + let whole = match at { + 3 => words + .iter() + .all(|&word| word == u32::from_le_bytes([FILL; 4])), + _ => read(output) == expected(SMALL, |i| 2 * i), + }; + assert!(!ran || whole, "encoder {at} ran in part: {words:?}"); + } let ran = |at: usize| words_of(&outputs[at]).iter().any(|&word| word != 0); - [ran(0), ran(1), ran(2), ran(3), ran(4)] + let reencoded = after.encoders_reencoded - before.encoders_reencoded; + ([ran(0), ran(1), ran(2), ran(3), ran(4)], reencoded) } -/// A failed set that names one encoder of a group fails the group whole; the encoders after it -/// run. +/// A failed set that names one encoder of a group fails that encoder alone, as on Metal: the +/// group's other two are encoded again apart at the commit, and the encoders after it run. #[test] -fn a_failed_encoder_inside_a_group_fails_the_group() { +fn a_failed_encoder_inside_a_group_fails_alone() { let set = FailedEncoders::Set(BTreeSet::from([1])); - assert_eq!(failed_with(set), [false, false, false, true, true]); + assert_eq!(failed_with(set), ([true, false, true, true, true], 2)); } -/// A first failed encoder inside a group fails from the group's first encoder on. +/// A first failed encoder inside a group fails from there on, as on Metal: the group's first +/// encoder is encoded again apart at the commit, and runs. #[test] -fn a_first_failed_encoder_inside_a_group_fails_from_the_group_s_first() { +fn a_first_failed_encoder_inside_a_group_runs_the_group_s_encoders_before_it() { let from = FailedEncoders::From(1); - assert_eq!(failed_with(from), [false; 5]); + assert_eq!(failed_with(from), ([true, false, false, false, false], 1)); } -/// A first failed encoder at a group's boundary (an encoder that is not a compute encoder) fails -/// what it failed before: the group before it runs. +/// A first failed encoder at a group's boundary (an encoder that is not a compute encoder) splits +/// no group: the group before it runs as recorded. #[test] fn a_first_failed_encoder_at_a_group_s_boundary_fails_from_there() { let from = FailedEncoders::From(3); - assert_eq!(failed_with(from), [true, true, true, false, false]); + assert_eq!(failed_with(from), ([true, true, true, false, false], 0)); +} + +/// The shape of a consumer's protection probe: a compute encoder, then a second one, folded into +/// the first's group, the command buffer committed as failed from the second (code 16, no +/// signals), on a device with no buffer over host pages: the first encoder's words land and the +/// second's do not, as on Metal. +#[test] +fn a_failure_from_a_folded_encoder_runs_the_encoder_before_it() { + let scratch = Scratch::new("fold-failed-second"); + let kernel = Kernel::new(&scratch); + let device = &kernel.device; + let queue = device.new_command_queue().unwrap(); + let input = floats(device, SMALL, |i| i as f32); + let outputs = [ + floats(device, SMALL, |_| 0.0), + floats(device, SMALL, |_| 0.0), + ]; + let warm = floats(device, SMALL, |_| 0.0); + let serial = DispatchType::Serial; + let command_buffer = queue.command_buffer().unwrap(); + kernel.dispatch(&command_buffer, serial, (&input, 0), (&warm, SMALL)); + kernel.run(&command_buffer); + + let before = device.work_counts(); + let command_buffer = queue.command_buffer().unwrap(); + for output in &outputs { + kernel.dispatch(&command_buffer, serial, (&input, 0), (output, SMALL)); + } + let folded = device.work_counts().encoders_folded - before.encoders_folded; + assert_eq!(folded, 1, "the second encoder joined the first's group"); + let failure = CommitFailure { + code: 16, + encoders: FailedEncoders::From(1), + signals: false, + }; + command_buffer.commit_failed(failure).unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + let after = device.work_counts(); + assert_eq!( + (command_buffer.status(), command_buffer.error()), + ( + CommandBufferStatus::Error, + Some(CommandBufferError::Injected(16)) + ) + ); + assert_eq!( + read(&outputs[0]), + expected(SMALL, |i| 2 * i), + "the first encoder ran" + ); + assert_eq!( + words_of(&outputs[1]), + vec![0; SMALL as usize], + "the failed encoder ran nothing" + ); + assert_eq!(after.encoders_reencoded - before.encoders_reencoded, 1); +} + +/// A chain of six dependent encoders in one group, each reading what the one before wrote, +/// committed as failed from the fifth: the four before it run, encoded again apart at the commit, +/// each after the one before; the last two run nothing. +#[test] +fn a_split_chain_runs_its_first_encoders_in_order() { + let scratch = Scratch::new("fold-failed-chain"); + let kernel = Kernel::new(&scratch); + let device = &kernel.device; + let queue = device.new_command_queue().unwrap(); + let large = [ + floats(device, LARGE, |_| 0.0), + floats(device, LARGE, |_| 0.0), + ]; + let warm = [ + floats(device, LARGE, |_| 0.0), + floats(device, LARGE, |_| 0.0), + ]; + let serial = DispatchType::Serial; + let command_buffer = queue.command_buffer().unwrap(); + kernel.dispatch(&command_buffer, serial, (&warm[0], 0), (&warm[1], LARGE)); + kernel.run(&command_buffer); + + let before = device.work_counts(); + let command_buffer = queue.command_buffer().unwrap(); + for k in 0..6 { + let (from, to) = (&large[k % 2], &large[(k + 1) % 2]); + kernel.dispatch(&command_buffer, serial, (from, 0), (to, LARGE)); + } + let folded = device.work_counts().encoders_folded - before.encoders_folded; + assert_eq!(folded, 5); + let failure = CommitFailure { + code: 2, + encoders: FailedEncoders::From(4), + signals: true, + }; + command_buffer.commit_failed(failure).unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + let after = device.work_counts(); + assert_eq!(command_buffer.status(), CommandBufferStatus::Error); + // Step `k` writes `(k + 1) * i` into `large[(k + 1) % 2]`: steps 0 to 3 ran. + assert_eq!(read(&large[0]), expected(LARGE, |i| 4 * i), "step 3's"); + assert_eq!(read(&large[1]), expected(LARGE, |i| 3 * i), "step 2's"); + assert_eq!(after.encoders_reencoded - before.encoders_reencoded, 4); +} + +/// A compute encoder's log holds one `ComputeCall` per call, at most 64 bytes: the bound +/// `encoder_fold.rs`'s **Logs** gives what a command buffer's groups hold until the commit by. +#[test] +fn a_logged_compute_call_is_at_most_64_bytes() { + let size = std::mem::size_of::(); + assert!(size <= 64, "{size} bytes"); } /// A group of two encoders, the second writing a buffer over host pages, committed behind an diff --git a/crates/metal2vulkan-runtime/src/tests/pending_rebind.rs b/crates/metal2vulkan-runtime/src/tests/pending_rebind.rs index eef17ee75..55a54f313 100644 --- a/crates/metal2vulkan-runtime/src/tests/pending_rebind.rs +++ b/crates/metal2vulkan-runtime/src/tests/pending_rebind.rs @@ -7,9 +7,10 @@ //! the buffer lay in as the dispatch was encoded. A rebind meanwhile frees that `VkBuffer`, since //! a command buffer committed and not yet submitted holds the pages its commands took only weakly //! (`first_submission.rs`), and the submission that holds the dispatch then runs nothing: -//! `CommandBufferError::EncodedUseRebound`, the encoder having kept no log a rebind encodes it -//! again from (`Unlogged::NoCalls`: the encoder opened while the device had no buffer over host -//! pages). So the host step records none of its commands. +//! `CommandBufferError::EncodedUseRebound`, the encoder being one no rebind encodes again +//! (`Unlogged::Predicated`: a block of command predication the encoder before it opened spans it, +//! so its commands run from gates that encoder's recording writes, `Predication::alone`). So the +//! host step records none of its commands. //! //! Recording them named a freed `VkBuffer` in a bound descriptor, which the validation layer //! reports (`VUID-vkCmdDispatch-None-08114`) and a driver that reads a descriptor as it encodes @@ -77,11 +78,11 @@ pub(super) fn options() -> DeviceOptions { } } -/// A dispatch of a kernel writing into a no-copy buffer, its `VkPipeline` held from being made, -/// and the buffer rebound after the commit: the command buffer fails `EncodedUseRebound`, writing -/// nothing into either range of pages, and the host step that records the dispatch once its -/// making is done records nothing of it -- the validation layer reports no descriptor naming the -/// `VkBuffer` the rebind freed. +/// A dispatch of a kernel writing into a no-copy buffer, inside an If the encoder before its own +/// opened, its `VkPipeline` held from being made, and the buffer rebound after the commit: the +/// command buffer fails `EncodedUseRebound`, writing nothing into either range of pages, and the +/// host step that records the dispatch once its making is done records nothing of it -- the +/// validation layer reports no descriptor naming the `VkBuffer` the rebind freed. #[test] fn a_pending_dispatch_records_nothing_where_a_rebind_freed_what_its_descriptors_name() { // Declared before the device, so dropped after it. @@ -102,8 +103,15 @@ fn a_pending_dispatch_records_nothing_where_a_rebind_freed_what_its_descriptors_ // only once this hold is gone. let hold = held::hold(); let command_buffer = queue.command_buffer().unwrap(); - // Opened while the device has no buffer over host pages, so the encoder logs no call and no - // rebind encodes it again (`Unlogged::NoCalls`). + // An If that holds (the word is 0) opened by the encoder before the dispatch's and closed by + // the dispatch's: no rebind encodes the dispatch's encoder again (`Unlogged::Predicated`). + let word = device + .new_buffer_with_bytes(&0u32.to_le_bytes(), ResourceOptions::shared()) + .unwrap(); + let mut opening = command_buffer.compute_command_encoder().unwrap(); + // Comparison 0: `word == reference`. + opening.encode_start_if(Some(&word), 0, 0, 0).unwrap(); + opening.end_encoding().unwrap(); let mut encoder = command_buffer.compute_command_encoder().unwrap(); let runs = Arc::new(AtomicUsize::new(0)); let Some(output) = over_host(&device, &hosts[0], &runs) else { @@ -121,6 +129,7 @@ fn a_pending_dispatch_records_nothing_where_a_rebind_freed_what_its_descriptors_ device.work_counts().dispatch_pipelines_pooled > pooled, "the dispatch handed a making to the pool, so a host step records it" ); + assert!(encoder.encode_end_if().unwrap(), "the If ends"); encoder.end_encoding().unwrap(); command_buffer.commit().unwrap(); // The buffer lies elsewhere from here, and the pages it lay in go: nothing submitted holds diff --git a/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs b/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs index c82507f3c..02a1d4981 100644 --- a/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs +++ b/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs @@ -499,9 +499,8 @@ fn a_rebind_does_not_wait_for_a_tile_making_another_encoder_began() { /// write into pages the program handed back, with no fault and nothing said. That is the class of /// bug this guard exists for, so it is watched by the layer and not by a page's contents alone. /// -/// The encoding again is made impossible as `pending_rebind.rs` makes it: the render encoder is -/// opened while the device has no buffer over host pages, so it logs no call (`Unlogged::NoCalls`) -/// and no rebind can replay it. The device's pool is held, so only a host step records the pass, +/// The encoding again is made impossible: the render encoder is opened while the device has no +/// buffer over host pages, so it logs no call (`Unlogged::NoCalls`) and no rebind can replay it. The device's pool is held, so only a host step records the pass, /// and only once the hold is gone -- after the rebind, in every run. /// /// Without `DeferredPass::record_forms`' `encoder_rebound` guard the host step records the pass and diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index 374f8c9e1..de866c5e5 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -6929,8 +6929,8 @@ pub struct WorkCounts { pub encoders_barriered_at_open: u64, /// Compute encoders that began no `VkCommandBuffer` of their own: each recorded into the one /// of the compute encoders before it in its command buffer, where nothing between them needs a - /// boundary (the same batch, dispatch type and logging, no work left for later, no fence - /// update, nothing failing), after the barrier the tracker plans between two encoders of a + /// boundary (the same batch and dispatch type, no work left for later, no fence update, + /// nothing failing), after the barrier the tracker plans between two encoders of a /// batch, and its batch's submission submits no command buffer for it, of barriers or of its /// own. Of `encoder_command_buffers_begun`'s encoders, those it does not count. pub encoders_folded: u64, diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 120c434c0..68d4b638c 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 522; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 2271; +pub const RUNTIME_VERSION: u32 = 2272; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles diff --git a/docs/API.md b/docs/API.md index 796d752b0..4725497d6 100644 --- a/docs/API.md +++ b/docs/API.md @@ -5359,19 +5359,23 @@ each item named states the rule in full. **A command buffer committed as failed** (`CommandBuffer::commit_failed`) -- **A failure inside a group of compute encoders recorded into one `VkCommandBuffer` fails the - whole group.** The runtime records a compute encoder into the `VkCommandBuffer` of the compute - encoder before it where nothing needs a boundary between them: the same dispatch type, the same - batch (no event wait or signal between them), no fence update or work left for later in the - earlier one, no command predication, the encoder trail off (`DeviceOptions::encoder_trail`) and - protection options 0 (`WorkCounts::encoders_folded` counts each). That `VkCommandBuffer` runs - whole or not at all. So a `FailedEncoders::From(n)` whose `n` lies inside such a group, and a - `FailedEncoders::Set` that names an encoder of one, run none of that group, where Metal runs the - group's encoders before `n` and those the set leaves out. A failure from an encoder on that the - runtime makes itself (a fault, a recording failure) is widened alike. A `From(n)` at a group's - boundary fails what it failed before: an `n` that names an encoder that is not a compute - encoder, one made under protection options, or the first compute encoder after another kind of - encoder, a change of dispatch type, an event wait or signal, or a fence update. +- **A failure inside a group of compute encoders whose unit of command predication laid a loop + or left work out fails the whole group.** The runtime records a compute encoder into the + `VkCommandBuffer` of the compute encoder before it where nothing needs a boundary between them: + the same dispatch type, the same batch (no event wait or signal between them), no fence update + or work left for later in the earlier one, no command predication yet, the encoder trail off + (`DeviceOptions::encoder_trail`) and protection options 0 (`WorkCounts::encoders_folded` counts + each). A failure that fails some of such a group's encoders and not the others (a + `FailedEncoders::From(n)` whose `n` lies inside it, a `FailedEncoders::Set` that names some of + them, a fault or a recording failure at one) splits it at the commit: the encoders that run are + recorded again from their logs, each into `VkCommandBuffer`s of its own, so exactly the + encoders the failure names run nothing, as on Metal. Where the group lies in a unit of command + predication that a later encoder of the command buffer made lay a loop + (`ComputeCommandEncoder::encode_start_while`, `encode_start_do_while`) or leave work out (an + unbalanced record), its encoders cannot be recorded again outside their blocks, and such a + failure fails the whole group instead, where Metal runs the group's encoders before `n` and + those the set leaves out. So does a group one of whose calls answers otherwise when recorded + again. **GPU hangs and faults** (a draw of private primitive type 9, `DrawPrimitiveType::Nine`) diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 3b1200eb0..ddfe3c4b5 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -1166,6 +1166,16 @@ driver's. Each is open work. compute encoder its unit of command predication reaches past, which is one whose unit laid a step before it opened or one of its own that the unit's later encoders read, and one whose unit laid a loop or left work out; work on the GPU alone) fail `EncodedUseRebound` (announced). +- **A failure inside a group of compute encoders recorded together, whose unit of command + predication laid a loop or left work out, fails the whole group** (`encoder_fold.rs`, + `command_buffer/fold.rs`'s `State::split_failure`). A `CommandBuffer::commit_failed` whose + `FailedEncoders::From(n)` lies inside such a group, or whose `FailedEncoders::Set` names some of + its encoders, splits the group at the commit and records its running encoders again from their + logs. Where a later compute encoder of the group's unit of predication (the run of compute + encoders of one dispatch type it lies in, `predication.rs`) called `encode_start_while` or + `encode_start_do_while`, or left a record unbalanced, the group's encoders cannot be recorded + again outside the unit's blocks, so the group runs nothing, where Metal runs its encoders the + failure does not name. - **A copied rebind under a texture in place, where the device's check did not pass fresh pages and its own linear image lies at another pitch, is refused** (`NotImplemented(RebindTextures)`). A rebind whose pages the gate refuses, or whose bytes moved in their page, copies them, and the