RUNTIME 2488: A spliced shadow's staged heads and tails go back as row copies too, one dispatch each where faster
A spliced copy back out of a staging buffer copied its rows' edges into the arena region (each row's head before its first line boundary and its tail after its last, which the host step then copies into the pages) as one vkCmdCopyBuffer region per edge: 2N regions per copy back. On ANV, which splices every such copy back, and on the RTX 5080 Laptop (DriverFact::RowCopiesDispatchFaster), the driver records each region as an operation of its own. That is the cost row_copies.rs removes. shadow_splice::staged now puts a cut's heads (in `edges`) and its tails (in `tails`) in separate lists. Each takes the region in the same order as before (a row's head, then its tail), so the region's layout, the pieces and the host step are unchanged. For rows of one shape the heads are equal-sized and equally spaced in both buffers, and so are the tails. SplicePlan::place makes each list a RowCopies from the staging buffer into the region (the arena's chunks carry storage usage), beside the whole lines' RowCopies into the truth. record_spliced records all three; the encoder takes their stages and uses (ShadowCopy::spliced_stages and spliced_uses: a texture buffer's shadow is read by every dispatched copy) and retains every set. Tests: - tests::shadow_splice::a_staged_cut_of_equal_rows_is_three_copies_of_rows_of_one_shape_each checks that the cut of the validation test's shape, at three phases, gives whole lines, heads and tails of one dispatchable shape each. - The staged cut's byte test also reads the tails. - runtime_lane::row_copies::a_spliced_shadow_s_lines_heads_and_tails_go_back_as_one_dispatch_each (renamed from ..._whole_lines_go_back_as_one_dispatch) asserts 3 row copies of 96 regions, 3 dispatched where the fact holds. Before this change it was 1 copy of 32. - The unforced test expects 3 copies where its copy back was spliced, else 1. The three row copies live in Splice.rows (clippy's large_enum_variant refused a 600-byte variant of SpliceCopies::Staged; nothing boxed). RUNTIME_VERSION 2488 (2487 is the early pin branch's). Verified: msi m3-max-38042 at 777d9a3412, lavapipe, --cfg m2v_cpu_icd: clippy -p runtime -p validation --all-targets --all-features -D warnings 0; validation 43/43 (a_spliced_shadow_s_lines_heads_and_tails_ go_back_as_one_dispatch_each: spliced 1, row copies 3, regions 96, 3 dispatched where the fact holds; the same scenario measured 1 copy at 869519d69f, m3-max-38028); runtime shadow, splice and row-copy tests 118/118 (a_staged_cut_of_equal_rows_is_three_copies_of_rows_of_one_shape_each: each copy meets RowsDispatch::new's conditions, so ANV and the 5080 dispatch them: expected, not run). Plain and --cfg m2v_gpu clippy and rustdoc in m3-max-38043.
This commit is contained in:
1 parent
e3959de823
commit
ac7dffa3fd
8 files changed
+209
-111
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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`).
|
||||
|
||||
@@ -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<Use<ResourceKey>> {
|
||||
/// 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<Use<ResourceKey>> {
|
||||
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
|
||||
|
||||
@@ -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<R> {
|
||||
pub(crate) whole: Vec<R>,
|
||||
pub(crate) edges: Vec<R>,
|
||||
pub(crate) tails: Vec<R>,
|
||||
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<vk::BufferImageCopy> {
|
||||
|
||||
/// `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<vk::BufferCopy> {
|
||||
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<RowCopies>; 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<vk::BufferImageCopy>,
|
||||
},
|
||||
/// 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<RowCopies>,
|
||||
edges: Vec<vk::BufferCopy>,
|
||||
},
|
||||
/// 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<OwnedSets> {
|
||||
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<vk::BufferImageCopy>),
|
||||
@@ -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<vk::BufferCopy>| {
|
||||
(!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 },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<vk::BufferCopy> = (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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
Vendored
+1
-1
@@ -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
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
Reference in new issue
Block a user