diff --git a/crates/metal2vulkan-runtime/src/encoder.rs b/crates/metal2vulkan-runtime/src/encoder.rs index 22299e01e..c346aab53 100644 --- a/crates/metal2vulkan-runtime/src/encoder.rs +++ b/crates/metal2vulkan-runtime/src/encoder.rs @@ -3216,23 +3216,21 @@ impl EncoderCore { } }; let splice = plan.place(region, &device); - // Its whole lines out of a staging buffer are a copy of rows, whose dispatch's uses and - // stages these are where it dispatches; the host step's write of the edges is a copy's. - let (stages, uses) = ( - copy.stages_with(splice.rows()), - copy.spliced_uses(splice.rows()), - ); + // Out of a staging buffer its rows' whole lines, heads and tails are copies of rows, + // whose dispatches' uses and stages these are where they dispatch; the host step's write + // of the edges is a copy's. + let (stages, uses) = (copy.spliced_stages(&splice), copy.spliced_uses(&splice)); let recorded = std::cell::Cell::new(false); let record = |device: &Vk, raw: vk::CommandBuffer| { // SAFETY: the encoder's command buffer is recording outside a render pass; its // commands retain the shadowed texture (its image and staging buffer), its arena - // (the region) and the copy of rows' set until it completes, and every image rests + // (the region) and the copies of rows' sets until it completes, and every image rests // in the `GENERAL` layout. recorded.set(unsafe { copy.record_spliced(device, raw, &splice) }); }; self.shadow_command(run, (stages, &uses, true), record); - let Splice { copies, drain, .. } = splice; - if let Some(sets) = copies.retained() { + let Splice { rows, drain, .. } = splice; + for sets in rows.into_iter().flatten().filter_map(RowCopies::retained) { self.retain(sets); } if !recorded.get() { diff --git a/crates/metal2vulkan-runtime/src/row_copies.rs b/crates/metal2vulkan-runtime/src/row_copies.rs index 698e00a06..7cd5dda7f 100644 --- a/crates/metal2vulkan-runtime/src/row_copies.rs +++ b/crates/metal2vulkan-runtime/src/row_copies.rs @@ -4,8 +4,9 @@ //! here: a blit between a buffer and a texture over a buffer, or between two textures over buffers //! (`blit_texture.rs`, `RowsCopy`, through a scratch buffer too where its rows share bytes); a //! buffer-texture copy's rows through its staging buffer; and a shadow's copy back out of its -//! staging buffer (`shadow.rs`, `ShadowCopy::staged_back`), or the whole lines of one spliced -//! (`shadow_splice.rs`, `SplicePlan::place`): a texture over a buffer's bytes, a +//! staging buffer (`shadow.rs`, `ShadowCopy::staged_back`), or one spliced (`shadow_splice.rs`, +//! `SplicePlan::place`: its rows' whole lines into the buffer, and their heads and their tails +//! into the region its host step copies them from): a texture over a buffer's bytes, a //! texture buffer, a rotated texture (`rotated.rs`), a heap's two-plane or tiled texture //! (`texture/heap_two_planes.rs`, `texture/heap_tiled.rs`), as an encoder records it or as a //! render pass's steps record it between its instances (`render/pass_steps.rs`). diff --git a/crates/metal2vulkan-runtime/src/shadow.rs b/crates/metal2vulkan-runtime/src/shadow.rs index b3c098289..95cf8b162 100644 --- a/crates/metal2vulkan-runtime/src/shadow.rs +++ b/crates/metal2vulkan-runtime/src/shadow.rs @@ -2187,7 +2187,7 @@ impl ShadowCopy { true } ( - SpliceCopies::Staged { whole, edges }, + SpliceCopies::Staged, ShadowTarget::Image { staging: Some(staging), .. @@ -2205,14 +2205,12 @@ impl ShadowCopy { ); Barrier::everything().record(device, command_buffer); } - // Its rows' whole lines, as one dispatch where the device runs it faster; - // after the barrier above where the image's copy wrote the staging buffer. - if let Some(rows) = whole { + // Its rows' whole lines, heads and tails, each one dispatch where the device + // runs it faster; after the barrier above where the image's copy wrote the + // staging buffer. + for rows in splice.rows().into_iter().flatten() { rows.record(device, command_buffer); } - if !edges.is_empty() { - device.cmd_copy_buffer(command_buffer, staging.raw(), splice.region, edges); - } true } _ => false, @@ -2378,29 +2376,40 @@ impl ShadowCopy { uses } - /// The copy's uses where it is spliced (`shadow_splice.rs`) and its whole lines go back by - /// `rows` (`shadow_splice::Splice::rows`): where they dispatch, the write of the buffer's - /// bytes is the dispatch's, and the read of a texture buffer's staging buffer, its shadow, is - /// the dispatch's and its edges' copy's. - pub(super) fn spliced_uses(&self, rows: Option<&RowCopies>) -> Vec> { + /// The copy's uses where it is spliced as `splice` cuts it (`shadow_splice.rs`): where its + /// rows' whole lines go back as a dispatch (`Splice::rows`), the write of the buffer's bytes + /// is that dispatch's; and the read of a texture buffer's staging buffer, its shadow, is each + /// dispatch's of its copies of rows as well as a copy's. + pub(super) fn spliced_uses(&self, splice: &Splice) -> Vec> { let mut uses = self.uses(); - let (Some(rows), ShadowSource::Bytes { target, .. }) = (rows, &self.copies.source) else { + let ShadowSource::Bytes { target, .. } = &self.copies.source else { return uses; }; - if !rows.dispatched() { - return uses; - } + let [whole, heads, tails] = splice.rows().map(|rows| rows.filter(|r| r.dispatched())); let shadow_read = matches!(target, ShadowTarget::Buffer(_)); for used in &mut uses { if !used.write.is_empty() { - used.write = rows.write(); + if let Some(whole) = whole { + used.write = whole.write(); + } } else if shadow_read && !used.read.is_empty() { - used.read = used.read.union(rows.read()); + for rows in [whole, heads, tails].into_iter().flatten() { + used.read = used.read.union(rows.read()); + } } } uses } + /// The copy's stages where it is spliced as `splice` cuts it: with the compute stage where a + /// copy of rows of it dispatches (`Splice::rows`). + pub(super) fn spliced_stages(&self, splice: &Splice) -> vk::PipelineStageFlags2 { + let dispatched = splice.rows().into_iter().flatten(); + dispatched + .filter(|rows| rows.dispatched()) + .fold(self.stages(), |stages, rows| stages | rows.stages()) + } + /// The stages the copy runs in: a rotated texture's copies dispatch the rotation kernel, a /// heap's two-plane texture's the two-plane kernel, a tiled heap texture's the tiled texel /// kernel (its keep too), a keep that dispatches the copy back's kernel diff --git a/crates/metal2vulkan-runtime/src/shadow_splice.rs b/crates/metal2vulkan-runtime/src/shadow_splice.rs index 84a800fb9..e6e7a311c 100644 --- a/crates/metal2vulkan-runtime/src/shadow_splice.rs +++ b/crates/metal2vulkan-runtime/src/shadow_splice.rs @@ -25,14 +25,15 @@ //! is cut at the first and last line boundaries it holds: the columns between them, whose lines //! hold that row's texels alone, are copied by the GPU straight into the buffer, one region for //! every row of a slice where its rows are a multiple of a line apart (each row's boundaries then -//! fall at the same columns), else one a row (out of a staging buffer, a copy of rows, -//! `row_copies.rs`: one dispatch where the device runs it faster, as an unspliced copy's rows -//! are); the columns before the first boundary and after the last are copied by the GPU into a -//! region of the command buffer's arena (`upload.rs`), its own lines whole ([`region`]), and from -//! there by the CPU into the pages, by a host step of a batch of its own once that copy completed -//! ([`ShadowSplices::drain`], `Deferred::ShadowSplice`): a store of the CPU changes the bytes it -//! stores alone, so its own writes beside them stay. A -//! row whose texels hold no whole line goes to the CPU whole. A texel the boundary cuts goes to +//! fall at the same columns), else one a row; the columns before the first boundary and after the +//! last are copied by the GPU into a region of the command buffer's arena (`upload.rs`), its own +//! lines whole ([`region`]), and from there by the CPU into the pages, by a host step of a batch of +//! its own once that copy completed ([`ShadowSplices::drain`], `Deferred::ShadowSplice`): a store +//! of the CPU changes the bytes it stores alone, so its own writes beside them stay. Out of a +//! staging buffer, the rows' whole lines, their heads (before the first boundary) and their tails +//! (after the last) are three copies of rows (`row_copies.rs`), each one dispatch where the device +//! runs it faster, as an unspliced copy's rows are. A row whose texels hold no whole line goes to +//! the CPU whole, as a head. A texel the boundary cuts goes to //! the CPU with its row's edge. The encoder notes the CPU's writes of the truth's bytes after the //! step, so the commands after it order after them; and the work after it goes in a later batch, //! which the step precedes. @@ -75,7 +76,6 @@ use super::buffer::Buffer; use super::encoder::RecordedSegment; use super::error::{internal, Error}; use super::in_place::{Access, InPlaceChecks, PagesClass, RowEnds, Verdict}; -use super::owned_kernel::OwnedSets; use super::row_copies::RowCopies; use super::shadow_merge::ShadowMerge; use super::upload::{Upload, Uploads}; @@ -257,11 +257,16 @@ pub(crate) unsafe fn store_differing(host: *mut u8, kept: &[u8], changed: &[u8]) /// A copy back cut for its splice: the GPU's copies `R` of whole lines into the buffer /// (`whole`) and of the rest into the region (`edges`, their offsets from its start), and the -/// CPU's pieces: each one's host address, length and byte of the region. +/// CPU's pieces: each one's host address, length and byte of the region. A staged cut's +/// ([`staged`]) `edges` are its rows' heads (the bytes before a row's first line boundary, or the +/// whole row where it holds no whole line) and `tails` their tails (those past its last), apart, +/// so that each is a copy of rows (`row_copies.rs`); an image's cut ([`image`]) has no `tails`, +/// each band's head and tail being a region each. #[derive(Debug, Default)] pub(crate) struct Cut { pub(crate) whole: Vec, pub(crate) edges: Vec, + pub(crate) tails: Vec, pub(crate) pieces: Vec<(u64, u64, u64)>, /// The bytes of the region the edges take. pub(crate) length: u64, @@ -410,30 +415,38 @@ impl Cut { /// `back`, the copies of a staging buffer's rows into a `VkBuffer` whose byte `v` lies at the /// host address `v + base` (wrapping), cut for lines of `line` bytes: each copy's bytes between -/// its first and last line boundaries go straight in, and the rest through the region. +/// its first and last line boundaries go straight in, and the rest through the region, its head +/// and its tail apart ([`Cut`]), each taking the region's bytes in the copies' order. pub(crate) fn staged(back: &[vk::BufferCopy], base: u64, line: u64) -> Cut { let mut cut = Cut::default(); for copy in back.iter().filter(|copy| copy.size > 0) { let phase = copy.dst_offset.wrapping_add(base) % line; let (first, last) = boundaries(phase, copy.size, line); - let edges = match last > first { + let (head, tail) = match last > first { true => { cut.whole.push(vk::BufferCopy { src_offset: copy.src_offset + first, dst_offset: copy.dst_offset + first, size: last - first, }); - [(0, first), (last, copy.size)] + ((0, first), (last, copy.size)) } - false => [(0, 0), (0, copy.size)], + false => ((0, copy.size), (0, 0)), }; - for (a, b) in edges.into_iter().filter(|(a, b)| b > a) { + for ((a, b), tail) in [(head, false), (tail, true)] { + if b <= a { + continue; + } let into = cut.take(b - a); - cut.edges.push(vk::BufferCopy { + let edge = vk::BufferCopy { src_offset: copy.src_offset + a, dst_offset: into, size: b - a, - }); + }; + match tail { + true => cut.tails.push(edge), + false => cut.edges.push(edge), + } let from = copy.dst_offset + a; cut.pieces.push((from.wrapping_add(base), b - a, into)); } @@ -473,6 +486,8 @@ pub(super) fn region( /// A copy back's splice, cut and its region taken: what the copy records. pub(super) struct Splice { pub(super) copies: SpliceCopies, + /// A staged one's copies of rows ([`rows`](Self::rows)); none for an image's. + pub(super) rows: [Option; 3], /// The truth's `VkBuffer`, as the copy is recorded. pub(super) truth: vk::Buffer, /// The region's `VkBuffer`. @@ -482,13 +497,11 @@ pub(super) struct Splice { } impl Splice { - /// The copy of rows of its whole lines out of the staging buffer, where it goes through one - /// and any row holds a whole line. - pub(super) fn rows(&self) -> Option<&RowCopies> { - match &self.copies { - SpliceCopies::Staged { whole, .. } => whole.as_ref(), - SpliceCopies::Image { .. } => None, - } + /// Its copies of rows out of the staging buffer, where it goes through one: of its rows' + /// whole lines into the truth, then of their heads and of their tails into the region, each + /// where a row has one. + pub(super) fn rows(&self) -> [Option<&RowCopies>; 3] { + self.rows.each_ref().map(Option::as_ref) } } @@ -500,11 +513,9 @@ pub(super) enum SpliceCopies { edges: Vec, }, /// From the staging buffer: a texture buffer's, or a 2D texture's after its image's copy - /// into it; its whole lines a copy of rows (`row_copies.rs`), where any. - Staged { - whole: Option, - edges: Vec, - }, + /// into it; its rows' whole lines, their heads and their tails each a copy of rows + /// (`row_copies.rs`), where any ([`Splice::rows`]). + Staged, } /// A copy back cut for its splice, its region not yet taken: the truth's `VkBuffer` and the cut. @@ -513,19 +524,6 @@ pub(super) struct SplicePlan { pub(super) cut: PlannedCut, } -impl SpliceCopies { - /// What the command buffer holds until it completes: the set of its copy of rows, where that - /// dispatches with one (`RowCopies::retained`). - pub(super) fn retained(self) -> Option { - match self { - SpliceCopies::Staged { - whole: Some(rows), .. - } => rows.retained(), - SpliceCopies::Staged { whole: None, .. } | SpliceCopies::Image { .. } => None, - } - } -} - /// A [`SplicePlan`]'s cut, of either form: a staged one with its staging buffer's `VkBuffer`. pub(super) enum PlannedCut { Image(Cut), @@ -544,11 +542,12 @@ impl SplicePlan { } } - /// The splice, its edges in `region`; a staged one's whole lines made on `device` as a copy - /// of rows from its staging buffer into the truth (`row_copies.rs`), which counts it. + /// The splice, its edges in `region`; a staged one's copies made on `device` as copies of + /// rows from its staging buffer (`row_copies.rs`), which counts each: its rows' whole lines + /// into the truth, their heads into the region and their tails there. pub(super) fn place(self, region: Upload, device: &Device) -> Splice { - let into = region.offset(); - let (copies, pieces) = match self.cut { + let (into, raw) = (region.offset(), region.raw()); + let (copies, rows, pieces) = match self.cut { PlannedCut::Image(mut cut) => { for edge in &mut cut.edges { edge.buffer_offset += into; @@ -557,25 +556,28 @@ impl SplicePlan { whole: cut.whole, edges: cut.edges, }; - (copies, cut.pieces) + (copies, [None, None, None], cut.pieces) } PlannedCut::Staged { mut cut, staging } => { - for edge in &mut cut.edges { + for edge in cut.edges.iter_mut().chain(&mut cut.tails) { edge.dst_offset += into; } - let whole = (!cut.whole.is_empty()) - .then(|| RowCopies::new(device, staging, self.truth, cut.whole)); - let copies = SpliceCopies::Staged { - whole, - edges: cut.edges, + let rows = |dst, regions: Vec| { + (!regions.is_empty()).then(|| RowCopies::new(device, staging, dst, regions)) }; - (copies, cut.pieces) + let rows = [ + rows(self.truth, cut.whole), + rows(raw, cut.edges), + rows(raw, cut.tails), + ]; + (SpliceCopies::Staged, rows, cut.pieces) } }; Splice { copies, + rows, truth: self.truth, - region: region.raw(), + region: raw, drain: SpliceDrain { region, pieces }, } } diff --git a/crates/metal2vulkan-runtime/src/tests/shadow_splice.rs b/crates/metal2vulkan-runtime/src/tests/shadow_splice.rs index a672ac240..a5d942ffe 100644 --- a/crates/metal2vulkan-runtime/src/tests/shadow_splice.rs +++ b/crates/metal2vulkan-runtime/src/tests/shadow_splice.rs @@ -211,7 +211,7 @@ fn a_staged_cut_writes_each_byte_once_and_no_shared_line_from_the_gpu() { } } let mut arena = vec![None; cut.length as usize]; - for copy in &cut.edges { + for copy in cut.edges.iter().chain(&cut.tails) { for i in 0..copy.size { arena[(copy.dst_offset + i) as usize] = Some(source(copy.src_offset + i)); } @@ -233,6 +233,89 @@ fn a_staged_cut_writes_each_byte_once_and_no_shared_line_from_the_gpu() { } } +/// The size of each of `copies` and how far apart in their source and destination they lie, each +/// the same for every copy and a whole number of 4-byte words, their first offsets too, and the +/// destination's rows apart by one's size at least: the shape a copy of rows dispatches +/// (`row_copies.rs`). +fn one_shape(copies: &[vk::BufferCopy]) -> (u64, u64, u64) { + let [first, second, ..] = copies else { + panic!("fewer than two copies"); + }; + let shape = ( + first.size, + second.src_offset - first.src_offset, + second.dst_offset - first.dst_offset, + ); + for (i, copy) in copies.iter().enumerate() { + let i = i as u64; + assert_eq!(copy.size, shape.0, "copy {i}'s size"); + assert_eq!( + copy.src_offset, + first.src_offset + i * shape.1, + "copy {i}'s source" + ); + assert_eq!( + copy.dst_offset, + first.dst_offset + i * shape.2, + "copy {i}'s destination" + ); + } + let words = [ + shape.0, + shape.1, + shape.2, + first.src_offset, + first.dst_offset, + ]; + assert!(words.iter().all(|v| v % 4 == 0), "{shape:?}: not words"); + assert!(shape.2 >= shape.0, "{shape:?}: destination rows overlap"); + shape +} + +/// A staged copy back of 32 rows of 128 bytes, tight in the staging buffer and 256 bytes apart +/// in the buffer from a byte `phase` past a line (a texture of 16-byte texels over a no-copy +/// buffer `phase` bytes into its page, `runtime_lane::row_copies` in the validation crate): its +/// rows' whole lines, heads and tails are each of one shape, so each is one copy of rows, one +/// dispatch where the device runs it faster; the heads and tails lie in the region in the rows' +/// order, a head then its row's tail, as the host step's pieces read them. +#[test] +fn a_staged_cut_of_equal_rows_is_three_copies_of_rows_of_one_shape_each() { + for phase in [4u64, 20, 36] { + let back: Vec = (0..32) + .map(|y| vk::BufferCopy { + src_offset: y * 128, + dst_offset: phase + y * 256, + size: 128, + }) + .collect(); + let cut = staged(&back, 0x10_0000, LINE); + let head = LINE - phase; + let tail = 128 - LINE - head; + let apart = head.next_multiple_of(16) + tail.next_multiple_of(16); + assert_eq!( + one_shape(&cut.whole), + (LINE, 128, 256), + "phase {phase}: whole lines" + ); + assert_eq!( + one_shape(&cut.edges), + (head, 128, apart), + "phase {phase}: heads" + ); + assert_eq!( + one_shape(&cut.tails), + (tail, 128, apart), + "phase {phase}: tails" + ); + assert_eq!( + (cut.edges[0].dst_offset, cut.tails[0].dst_offset), + (0, head.next_multiple_of(16)), + "phase {phase}: a row's head, then its tail" + ); + assert_eq!(cut.pieces.len(), 64, "phase {phase}: pieces"); + } +} + /// The bytes of `cut`'s rows (a rectangle of `texture`'s) in lines of [`LINE`] bytes (from a /// multiple of it at host address `v + base`) that hold a byte of no row of `texture`'s, found byte /// by byte, each with its byte of the rectangle's rows laid back to back. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs b/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs index 4241e451a..6339a092b 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs @@ -12,9 +12,10 @@ //! which form each copy took. `a_shadow_s_staged_rows_go_back_as_one_dispatch` clears a texture //! of 16-byte texels over a no-copy buffer 4 bytes past a page, whose shadow goes back through a //! staging buffer, 32 rows as one dispatch where the device runs it faster, and checks every byte -//! of its pages; `a_spliced_shadow_s_whole_lines_go_back_as_one_dispatch` does so on a device -//! whose check of such pages fails, where the copy back is spliced (the runtime's -//! `shadow_splice.rs`) and the rows' whole lines are that copy. +//! of its pages; `a_spliced_shadow_s_lines_heads_and_tails_go_back_as_one_dispatch_each` does so +//! on a device whose check of such pages fails, where the copy back is spliced (the runtime's +//! `shadow_splice.rs`) and the rows' whole lines, their heads and their tails are three such +//! copies. //! //! `row_copies_cost` (ignored; run it with `--ignored --nocapture`) prints `ROW-COPIES` lines: a //! frame of one blit of `rows` rows of 1920 `BGRA8Unorm` texels from a tight buffer into a texture @@ -474,15 +475,17 @@ fn long_copies_of_any_size_copy_metals_bytes() { /// (`DriverFact::RowCopiesDispatchFaster`), else as the copy's regions. The rows hold the clear, /// and every byte between them and around the buffer keeps its own. Where the device's check of /// such pages has not answered as the copy back is recorded (as on a device made with no record of -/// its verdicts), the copy back is spliced, and its rows' whole lines are that copy. +/// its verdicts), the copy back is spliced, and its rows' whole lines, their heads and their tails +/// are three such copies. #[test] fn a_shadow_s_staged_rows_go_back_as_one_dispatch() { on_device(|device| { - let (dispatched, copies, _) = cleared_over_pages(device); + let (dispatched, copies, _, spliced) = cleared_over_pages(device); + let want = 1 + 2 * spliced; assert_eq!( (dispatched, copies), - (dispatches(device), 1), - "the copy back's rows, dispatched where faster" + (want * dispatches(device), want), + "the copy back's rows ({spliced} spliced), dispatched where faster" ); }); } @@ -490,27 +493,28 @@ fn a_shadow_s_staged_rows_go_back_as_one_dispatch() { /// [`a_shadow_s_staged_rows_go_back_as_one_dispatch`] on a device whose check of such pages fails /// (`DeviceOptions::fail_in_place_check`): its copy back is spliced (the runtime's /// `shadow_splice.rs`), the rows' 128 bytes, 4 past a line of the device's memory, holding bytes -/// beside them in their first and last lines (every venue's line is 16 to 64 bytes), and the -/// whole lines of the 32 rows go back out of the staging buffer as one dispatch where the device -/// runs it faster, else as the copy's regions. +/// beside them in their first and last lines (every venue's line is 16 to 64 bytes): out of the +/// staging buffer, the 32 rows' whole lines go back into the buffer, and their heads and their +/// tails into the region its host step copies them from, each 32 rows as one dispatch where the +/// device runs it faster, else as the copy's regions. #[test] -fn a_spliced_shadow_s_whole_lines_go_back_as_one_dispatch() { +fn a_spliced_shadow_s_lines_heads_and_tails_go_back_as_one_dispatch_each() { let fail = |options: &mut DeviceOptions| options.fail_in_place_check = true; on_device_with(fail, |device| { - let (dispatched, copies, spliced) = cleared_over_pages(device); + let (dispatched, copies, regions, spliced) = cleared_over_pages(device); assert_eq!(spliced, 1, "the copy back, spliced"); assert_eq!( - (dispatched, copies), - (dispatches(device), 1), - "the spliced copy back's whole lines, dispatched where faster" + (dispatched, copies, regions), + (3 * dispatches(device), 3, 3 * 32), + "the spliced copy back's whole lines, heads and tails, dispatched where faster" ); }); } /// Clear the texture of [`a_shadow_s_staged_rows_go_back_as_one_dispatch`] on `device` and check -/// every byte of its pages: the dispatched row copies, the row copies and the copies back spliced -/// since. -fn cleared_over_pages(device: &Device) -> (u64, u64, u64) { +/// every byte of its pages: the dispatched row copies, the row copies, their regions and the +/// copies back spliced since. +fn cleared_over_pages(device: &Device) -> (u64, u64, u64, u64) { let (at, [w, h], bpr) = (4usize, [8u64, 32], 256usize); let len = h as usize * bpr; let pages = Mapping::anonymous(2 * GUEST_PAGE); @@ -553,9 +557,10 @@ fn cleared_over_pages(device: &Device) -> (u64, u64, u64) { } assert_eq!(pages.read(0..2 * GUEST_PAGE), want, "the pages"); let (dispatched, copies) = copies_since(device, &counts); - let spliced = - device.work_counts().shadow_copies_back_spliced - counts.shadow_copies_back_spliced; - (dispatched, copies, spliced) + let now = device.work_counts(); + let regions = now.row_copy_regions - counts.row_copy_regions; + let spliced = now.shadow_copies_back_spliced - counts.shadow_copies_back_spliced; + (dispatched, copies, regions, spliced) } /// The untimed and the timed frames of each row count. diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 3d7e144c1..50b2ec270 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 = 525; /// 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 = 2486; +pub const RUNTIME_VERSION: u32 = 2488; /// 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/HOWTO.md b/docs/HOWTO.md index 069d5dc5c..533429787 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -590,10 +590,10 @@ A blit that names a texture over a buffer runs on the buffers' bytes, a region p rows lie apart, and a buffer-texture copy in a layout Vulkan cannot state moves its rows through a staging buffer, as does a shadow's copy back where its texels start off their alignment (and a rotated texture's, and a heap's two-plane or tiled texture's), whether an encoder records it or a -render pass between two of its instances, and the rows' whole lines where such a copy back into -host pages is spliced (`shadow_splice.rs`). A driver may record each region as an operation of its -own: on ANV the 1080 rows of a 1920-texel `BGRA8Unorm` texture took 3.1-3.3 ms of CPU and 5.3-7.8 ms -of GPU on the Iris Xe of RPL-P. Where the device is measured to run it faster +render pass between two of its instances; where such a copy back into host pages is spliced +(`shadow_splice.rs`), its rows' whole lines, their heads and their tails are three such copies. A +driver may record each region as an operation of its own: on ANV the 1080 rows of a 1920-texel +`BGRA8Unorm` texture took 3.1-3.3 ms of CPU and 5.3-7.8 ms of GPU on the Iris Xe of RPL-P. Where the device is measured to run it faster (`DriverFact::RowCopiesDispatchFaster`: ANV, there 0.3-0.4 ms and 1.1 ms, and NVIDIA's on the RTX 5080 Laptop GPU, where 1080 rows took 2.0 ms of GPU as regions and 0.4 ms as one dispatch), a copy of 2 rows or more, each the same whole number of 4-byte words and the same distance after the one