SEMANTICS 2125, RUNTIME 2376: Rate maps: a region-copy recording draws one row, its region its first's segments plus DrawIndex
A recording through the region-copy variant drew a box of several rows, so its vertex function found its region as `first + (DrawIndex / c)·nx + DrawIndex mod c`: it read the table's count of columns, divided by it and by the box's columns, and only then read its region's terms. Now each row of a box is its own recording (in parts of at most a multi-draw's draws), and `PushField::RegionBox` holds the row's first region's segments `[x0, y0]`: the vertex function draws the region of segments `(x0 + DrawIndex, y0)`, dividing nothing and reading no table word before its region's own, the row's `y0` the same at every vertex. A row is recorded a region at a time where a sample may lie on a pixel's left edge (`folds` answers that axis alone: a row's top and bottom edges are its scissor's). The pixels and positions are the route's as before: the same copy arithmetic of the same region, under the same viewport, its row's scissor holding the regions' pixels. A whole-table draw is 34 recordings where it was 2 (rate_map_region_copy_recordings). The docs, the FAST-PATHS fan-out row and the boxes test say rows; the docs drop the cost claim the Iris A/B disproved. Kept though neutral on the Iris: the shorter vertex function (42 instructions, 428 estimated cycles, 8 sends -> 37, 258, 7) did not move the per vertex-region cost, which lies in the fixed function after it (four user clip distances tested on every copy; 2073 of 2074 rejected there). Verified: m3-max-33295 (msi, at 72bd8baa20): clippy of the translator and runtime (all targets, all features, -D warnings) plain, m2v_cpu_icd and m2v_gpu 0; translator 47/47 and runtime fan_out 6/6 unit tests; lavapipe 24/24 rate-map device tests. m3-max-33355 (ef59a08250, docs): clippy plain and Rustdoc 0. Iris (ms01) m3-max-33332: 24/24 rate-map device tests (region_boxes direct [3 draws, 39 recordings] against indirect [3, 624], 0 texels differ; depth_equal 0 red). Negative control m3-max-33327: the base's divided region restored, the SPIR-V divisions assertion fails (4 vs 0). Iris A/B m3-max-33262 (warm, no INTEL_MEASURE): whole-table commit frame 671.1 -> 670.9 ms, Exact 505.7 -> 498.7 ms; per sub-draw 1.068 us + 0.3626 ns x V -> 0.926 us + 0.3697 ns x V.
This commit is contained in:
1 parent
b6081e2c7e
commit
da6cc554bb
19 files changed
+225
-229
No files matched your search
@@ -261,21 +261,22 @@
|
||||
//! `WorkCounts::rate_map_region_copy_draws`). The variant has no geometry stage: its vertex
|
||||
//! function puts each vertex in its region by the instructions that put a fanned-out copy's,
|
||||
//! decorated `NoContraction`, its `Position` and `ClipDistance` `Invariant`. It draws boxes of
|
||||
//! the table's regions (a run's the boxes its bounds reach, any other draw's the whole table), a
|
||||
//! recording per region or, for a direct draw on a device with the multi-draw commands, per as
|
||||
//! many regions of a box as a multi-draw takes, its rows in order
|
||||
//! (`rate_map_region_copy_recordings`), each pushing its box's first region and columns; their
|
||||
//! the table's regions (a run's the boxes its bounds reach, any other draw's the whole table)
|
||||
//! row by row, a recording per region or, for a direct draw on a device with the multi-draw
|
||||
//! commands, per as many regions of a row as a multi-draw takes
|
||||
//! (`rate_map_region_copy_recordings`), each pushing its row's first region's segments, so the
|
||||
//! vertex function's region is those segments plus its draw's index along the row; their
|
||||
//! vertices or indices times their instances times the regions each recording draws are counted
|
||||
//! for the draws into the whole table (`rate_map_whole_copy_vertex_regions`, of them the
|
||||
//! encoder's own `rate_map_own_copy_vertex_regions`) and for the runs
|
||||
//! (`rate_map_run_vertex_regions`). The
|
||||
//! recording sets one viewport, the fan-out's over the render area, which the vertex function
|
||||
//! stores 0 as `ViewportIndex` to select, and its box's scissor, so the four clip distances keep
|
||||
//! each copy to its region and the scissor rejects what lies outside the box: a border between
|
||||
//! two regions of a recording holds no sample, where the device samples at Vulkan's standard
|
||||
//! locations at up to 8 samples or the pass's own positions put none on a pixel's edge across it
|
||||
//! (else the box is recorded a column, or a row, at a time; `tests::rate_mapped_region_boxes`
|
||||
//! compares a box's recordings with one region's each, texel by texel). So a vertex in a region
|
||||
//! (`rate_map_run_vertex_regions`). The recording sets one viewport, the fan-out's over the
|
||||
//! render area, which the vertex function stores 0 as `ViewportIndex` to select, and its row's
|
||||
//! scissor, so the four clip distances keep each copy to its region and the scissor rejects what
|
||||
//! lies outside the row: a border between two regions of a recording holds no sample, where the
|
||||
//! device samples at Vulkan's standard locations at up to 8 samples or the pass's own positions
|
||||
//! put none on a pixel's left edge (else each region of the row is recorded alone;
|
||||
//! `tests::rate_mapped_region_boxes` compares a row's recordings with one region's each, texel
|
||||
//! by texel). So a vertex in a region
|
||||
//! is rasterized at one window position whichever of the pass's routes draws it, where both
|
||||
//! pipelines compute its position alike, and a later pass that tests `Equal` the depth one route
|
||||
//! stored meets it where another draws the same vertices (`tests::rate_mapped_depth_equal`:
|
||||
|
||||
@@ -989,13 +989,13 @@ struct DrawState {
|
||||
/// The draws one command records: 1 for a plain draw, and the regions of a rate-mapped pass a
|
||||
/// multi-draw records several at a time (`rate_mapped_pass.rs`, `MultiDraws`), each through
|
||||
/// the viewport and scissor at its index, at most its viewports; or, through a region-copy
|
||||
/// variant, the regions of its box (`region_box`), each through the one viewport over the
|
||||
/// render area and the box's scissor.
|
||||
/// variant, the regions of its row (`region_box`), each through the one viewport over the
|
||||
/// render area and the row's scissor.
|
||||
draws: u32,
|
||||
/// The box of a rate-mapped pass's regions it draws through its region-copy variant, which its
|
||||
/// recording pushes: its first region, in its region table's order, and its columns, its
|
||||
/// `draws` regions its rows of them in order (`render/fan_out.rs`, **Region-copy variant**);
|
||||
/// `None` for any other.
|
||||
/// The row of a rate-mapped pass's regions it draws through its region-copy variant, which its
|
||||
/// recording pushes: its first region's segments of x and y in its region table, its `draws`
|
||||
/// regions along x in order (`render/fan_out.rs`, **Region-copy variant**); `None` for any
|
||||
/// other.
|
||||
region_box: Option<[u32; 2]>,
|
||||
}
|
||||
|
||||
@@ -10163,11 +10163,11 @@ impl RenderLowering {
|
||||
// the whole draw.
|
||||
let mut draw_states = match (&self.rate_map, fans) {
|
||||
(None, _) => DrawStates::Whole([draw_state]),
|
||||
// A draw through its region-copy variant records boxes of the table's regions, each
|
||||
// recording pushing its box and drawing as many regions of it as a direct draw's
|
||||
// multi-draw takes, else one, its rows in order; it sets one viewport, over the render
|
||||
// area of the draw's depth range, and its box's scissor (`render/fan_out.rs`,
|
||||
// **Region-copy variant**).
|
||||
// A draw through its region-copy variant records boxes of the table's regions row by
|
||||
// row, each recording pushing its first region's segments and drawing as many regions
|
||||
// of the row as a direct draw's multi-draw takes, else one; it sets one viewport, over
|
||||
// the render area of the draw's depth range, and its row's scissor
|
||||
// (`render/fan_out.rs`, **Region-copy variant**).
|
||||
(Some(_), Some(_)) if region_copies => {
|
||||
let depth = (draw_state.viewports.iter().next())
|
||||
.map_or([0.0, 1.0], |v| [v.min_depth, v.max_depth]);
|
||||
@@ -10194,17 +10194,17 @@ impl RenderLowering {
|
||||
}
|
||||
(None, None) => vec![fan_out::RegionBox::whole(*grid)],
|
||||
};
|
||||
// Several columns, or rows, a recording where no sample of the pass lies on the
|
||||
// Several regions of a row a recording where no sample of the pass lies on the
|
||||
// borders between them (`fan_out::folds`).
|
||||
let (layout, standard) = (&self.layout, device.shared().standard_sample_locations);
|
||||
let folds = fan_out::folds(standard, layout.samples, &layout.sample_positions);
|
||||
let [nx, _] = *grid;
|
||||
let nx = grid[0].max(1);
|
||||
let recordings: Vec<DrawState> = (boxes.into_iter())
|
||||
.flat_map(|whole| fan_out::box_recordings(whole, nx, copy_batch, folds))
|
||||
.map(|boxed| {
|
||||
let scissor = boxed
|
||||
.flat_map(|whole| fan_out::row_recordings(whole, nx, copy_batch, folds))
|
||||
.map(|row| {
|
||||
let scissor = row
|
||||
.scissor(scissors, nx)
|
||||
.ok_or_else(|| internal("a box of regions past its region table's"))?;
|
||||
.ok_or_else(|| internal("a row of regions past its region table's"))?;
|
||||
Ok(DrawState {
|
||||
viewports: ViewportList::One(viewport),
|
||||
scissors: ViewportList::One(scissor),
|
||||
@@ -10212,8 +10212,8 @@ impl RenderLowering {
|
||||
viewports: 1,
|
||||
..draw_state.fixed
|
||||
},
|
||||
draws: boxed.columns * boxed.rows,
|
||||
region_box: Some([boxed.first, boxed.columns]),
|
||||
draws: row.columns,
|
||||
region_box: Some([row.first % nx, row.first / nx]),
|
||||
..draw_state.clone()
|
||||
})
|
||||
})
|
||||
@@ -11501,7 +11501,7 @@ impl RenderLowering {
|
||||
for a in 0..entries {
|
||||
let (push, vk_draws) = entry(a);
|
||||
for state in draw_states.of(a) {
|
||||
// A recording through the region-copy variant pushes its box of regions
|
||||
// A recording through the region-copy variant pushes its row of regions
|
||||
// (`render/fan_out.rs`, **Region-copy variant**).
|
||||
let region_push;
|
||||
let push = match (state.region_box, region_offset) {
|
||||
|
||||
@@ -40,21 +40,22 @@
|
||||
//! region-copy variant (`RegionFanOut::RegionCopies`), whose vertex function puts each vertex in
|
||||
//! its region as a fan-out stage puts a copy's. It draws boxes of the table's regions
|
||||
//! ([`RegionBox`]): a run and a boxed draw the boxes their bounds reach, any other draw the whole
|
||||
//! table. A direct draw records a box at most as many regions at a time as a multi-draw takes
|
||||
//! (`MultiDraws::copies`), its rows in order
|
||||
//! ([`box_recordings`]), each recording pushing its box's first region and columns
|
||||
//! ([`region_push`]; `DrawIndex` the region past the first, row by row), and any other draw one
|
||||
//! region a recording. Each recording sets one viewport, the target's over the render area
|
||||
//! ([`target`]), which the vertex function selects by storing 0 as `ViewportIndex`, and its box's
|
||||
//! scissor, the union of its regions' ([`table`]): the clip distances keep each copy to its
|
||||
//! region's pixels, and the scissor rejects a triangle outside the box (`bind::fan_out`, **One
|
||||
//! route per pass**). A border between two regions of a recording holds no sample where the device
|
||||
//! rasterizes at Vulkan's standard locations at up to 8 samples, and none where the pass's own
|
||||
//! positions put no sample on that axis's pixel edge ([`folds`]); a box is recorded one column at a
|
||||
//! time where a border between columns may hold one, and one row at a time where a border between
|
||||
//! rows may, so each such border is a recording's scissor's edge. Every route of the pass hands the
|
||||
//! rasterizer the same position for a vertex in a region, so a draw that tests `Equal` the depth
|
||||
//! another stored meets it whichever route each took.
|
||||
//! table. A direct draw records each row of a box in parts of at most as many regions as a
|
||||
//! multi-draw takes (`MultiDraws::copies`), the rows in order ([`row_recordings`]), each
|
||||
//! recording pushing its first region's segments of x and y ([`region_push`]; `DrawIndex` the
|
||||
//! region past the first along the row), and any other draw one region a recording. A row's
|
||||
//! region is its first's segments plus the draw's index along x, so the vertex function divides
|
||||
//! nothing and reads no table word before its region's own. Each recording sets one viewport,
|
||||
//! the target's over the render area ([`target`]), which the vertex function selects by storing
|
||||
//! 0 as `ViewportIndex`, and its row's scissor, the union of its regions' ([`table`]): the clip
|
||||
//! distances keep each copy to its region's pixels, and the scissor rejects a triangle outside
|
||||
//! the row (`bind::fan_out`, **One route per pass**). A border between two regions of a recording
|
||||
//! holds no sample where the device rasterizes at Vulkan's standard locations at up to 8 samples,
|
||||
//! and none where the pass's own positions put no sample on a pixel's left edge ([`folds`]); a
|
||||
//! row is recorded a region at a time where a border between its regions may hold one, so each
|
||||
//! such border is a recording's scissor's edge, as a row's top and bottom edges are. Every route
|
||||
//! of the pass hands the rasterizer the same position for a vertex in a region, so a draw that
|
||||
//! tests `Equal` the depth another stored meets it whichever route each took.
|
||||
|
||||
use super::executions::StepDraws;
|
||||
use crate::binding::PushWrite;
|
||||
@@ -354,49 +355,40 @@ pub(super) fn run_boxes([nx, ny]: [u32; 2], bounds: u32) -> Vec<RegionBox> {
|
||||
}
|
||||
|
||||
/// The recordings a draw through its region-copy variant draws box `whole` of a table of `nx`
|
||||
/// segments of x in (the module docs, **Region-copy variant**): boxes of at most `most` regions
|
||||
/// each, of its rows in order, each a part of its columns as wide as `most` allows and as many of
|
||||
/// its rows as then fit; one column wide where `folds[0]` is false and one row high where
|
||||
/// `folds[1]` is false ([`folds`]).
|
||||
pub(super) fn box_recordings(
|
||||
/// segments of x in (the module docs, **Region-copy variant**): each of its rows in order, in
|
||||
/// parts of at most `most` regions, or of one region where `across` is false ([`folds`]).
|
||||
pub(super) fn row_recordings(
|
||||
whole: RegionBox,
|
||||
nx: u32,
|
||||
most: u32,
|
||||
[across, down]: [bool; 2],
|
||||
across: bool,
|
||||
) -> impl Iterator<Item = RegionBox> {
|
||||
let most = most.max(1);
|
||||
let width = match across {
|
||||
true => whole.columns.min(most),
|
||||
true => whole.columns.min(most.max(1)),
|
||||
false => 1,
|
||||
};
|
||||
let height = match down {
|
||||
true => (most / width).clamp(1, whole.rows),
|
||||
false => 1,
|
||||
};
|
||||
let rows = (0..whole.rows).step_by(height as usize);
|
||||
rows.flat_map(move |r| {
|
||||
(0..whole.rows).flat_map(move |r| {
|
||||
(0..whole.columns)
|
||||
.step_by(width as usize)
|
||||
.map(move |c| RegionBox {
|
||||
first: whole.first + r * nx + c,
|
||||
columns: width.min(whole.columns - c),
|
||||
rows: height.min(whole.rows - r),
|
||||
rows: 1,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether a draw through its region-copy variant records several columns, and several rows, of
|
||||
/// a box of regions at a time in a pass of `samples` samples at `positions`, its custom positions
|
||||
/// (`sample_positions.rs`; none for the device's own), on a device that samples at Vulkan's
|
||||
/// standard locations where `standard` (`standardSampleLocations`): where no sample lies on a
|
||||
/// pixel's left edge, and none on its top edge, so that a border between two regions of a
|
||||
/// recording, which runs along pixels' edges, holds no sample (the module docs, **Region-copy
|
||||
/// variant**). The standard locations lie a sixteenth of a pixel or more inside a pixel at up to
|
||||
/// 8 samples; at 16 two of them lie on its edges.
|
||||
pub(super) fn folds(standard: bool, samples: u32, positions: &[Sixteenths]) -> [bool; 2] {
|
||||
/// Whether a draw through its region-copy variant records several regions of a row at a time in
|
||||
/// a pass of `samples` samples at `positions`, its custom positions (`sample_positions.rs`; none
|
||||
/// for the device's own), on a device that samples at Vulkan's standard locations where
|
||||
/// `standard` (`standardSampleLocations`): where no sample lies on a pixel's left edge, so that a
|
||||
/// border between two regions of a recording, which runs along pixels' left edges, holds no
|
||||
/// sample (the module docs, **Region-copy variant**). The standard locations lie a sixteenth of a
|
||||
/// pixel or more inside a pixel at up to 8 samples; at 16 two of them lie on its edges.
|
||||
pub(super) fn folds(standard: bool, samples: u32, positions: &[Sixteenths]) -> bool {
|
||||
match positions.is_empty() {
|
||||
true => [standard && samples <= 8; 2],
|
||||
false => [0, 1].map(|axis| positions.iter().all(|p| p[axis] != 0)),
|
||||
true => standard && samples <= 8,
|
||||
false => positions.iter().all(|p| p[0] != 0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,14 +627,14 @@ pub(super) fn copies_regions(device: &Device) -> bool {
|
||||
.all(|feature| features.contains(feature))
|
||||
}
|
||||
|
||||
/// The push writes of a recording of a draw through its region-copy variant of the box of
|
||||
/// regions from region `first` of `columns` columns (the module docs, **Region-copy variant**):
|
||||
/// The push writes of a recording of a draw through its region-copy variant of the row of
|
||||
/// regions from the region of segments `x0` and `y0` (the module docs, **Region-copy variant**):
|
||||
/// the draw's, `push`, with the vertex stage's two words at `offset` (`PushField::RegionBox`)
|
||||
/// holding `first` and `columns`.
|
||||
/// holding `x0` and `y0`.
|
||||
pub(super) fn region_push(
|
||||
push: &[PushWrite],
|
||||
offset: u32,
|
||||
[first, columns]: [u32; 2],
|
||||
[x0, y0]: [u32; 2],
|
||||
) -> Result<Vec<PushWrite>, Error> {
|
||||
let mut pushed = push.to_vec();
|
||||
let write = (pushed.iter_mut())
|
||||
@@ -655,8 +647,8 @@ pub(super) fn region_push(
|
||||
internal("a draw through its region-copy variant without its region's push")
|
||||
})?;
|
||||
let from = (offset - write.1) as usize;
|
||||
write.2[from..from + 4].copy_from_slice(&first.to_le_bytes());
|
||||
write.2[from + 4..from + 8].copy_from_slice(&columns.to_le_bytes());
|
||||
write.2[from..from + 4].copy_from_slice(&x0.to_le_bytes());
|
||||
write.2[from + 4..from + 8].copy_from_slice(&y0.to_le_bytes());
|
||||
Ok(pushed)
|
||||
}
|
||||
|
||||
|
||||
@@ -223,29 +223,26 @@ fn a_run_reaches_the_regions_its_blocks_bounds_hold() {
|
||||
);
|
||||
}
|
||||
|
||||
/// A box is recorded at most as many regions at a time as a command draws, its rows in order,
|
||||
/// as wide as that allows and as many rows as then fit; one column at a time where its columns'
|
||||
/// borders may hold a sample, one row where its rows' may; and one region at a time with one
|
||||
/// A box is recorded row by row, in order, each row at most as many regions at a time as a
|
||||
/// command draws; one region at a time where its columns' borders may hold a sample, and with one
|
||||
/// region a command.
|
||||
#[test]
|
||||
fn a_box_is_recorded_as_many_regions_a_time_as_a_command_draws() {
|
||||
use super::{box_recordings, RegionBox};
|
||||
fn a_box_is_recorded_row_by_row_as_many_regions_a_time_as_a_command_draws() {
|
||||
use super::{row_recordings, RegionBox};
|
||||
let boxed = |first, columns, rows| RegionBox {
|
||||
first,
|
||||
columns,
|
||||
rows,
|
||||
};
|
||||
let recorded = |whole, most, folds| box_recordings(whole, 10, most, folds).collect::<Vec<_>>();
|
||||
let recorded = |whole, most, folds| row_recordings(whole, 10, most, folds).collect::<Vec<_>>();
|
||||
let whole = boxed(12, 4, 5);
|
||||
assert_eq!(recorded(whole, 2047, [true; 2]), [whole]);
|
||||
// Two rows of four at a time, the last row alone.
|
||||
assert_eq!(
|
||||
recorded(whole, 9, [true; 2]),
|
||||
[boxed(12, 4, 2), boxed(32, 4, 2), boxed(52, 4, 1)]
|
||||
);
|
||||
// Each row whole, however many regions a command draws.
|
||||
let rows: Vec<_> = (0..5).map(|r| boxed(12 + 10 * r, 4, 1)).collect();
|
||||
assert_eq!(recorded(whole, 2047, true), rows);
|
||||
assert_eq!(recorded(whole, 9, true), rows);
|
||||
// Wider than a command: each row in parts.
|
||||
assert_eq!(
|
||||
recorded(boxed(0, 4, 2), 3, [true; 2]),
|
||||
recorded(boxed(0, 4, 2), 3, true),
|
||||
[
|
||||
boxed(0, 3, 1),
|
||||
boxed(3, 1, 1),
|
||||
@@ -253,17 +250,12 @@ fn a_box_is_recorded_as_many_regions_a_time_as_a_command_draws() {
|
||||
boxed(13, 1, 1)
|
||||
]
|
||||
);
|
||||
// One column at a time, its rows together; one row at a time, its columns together.
|
||||
let columns: Vec<_> = (12..16).map(|first| boxed(first, 1, 5)).collect();
|
||||
assert_eq!(recorded(whole, 2047, [false, true]), columns);
|
||||
let rows: Vec<_> = (0..5).map(|r| boxed(12 + 10 * r, 4, 1)).collect();
|
||||
assert_eq!(recorded(whole, 2047, [true, false]), rows);
|
||||
// One region a command, or neither axis folded: each region alone, in the table's order.
|
||||
// One region a command, or the columns not folded: each region alone, in the table's order.
|
||||
let regions: Vec<_> = (0..5)
|
||||
.flat_map(|r| (0..4).map(move |c| boxed(12 + 10 * r + c, 1, 1)))
|
||||
.collect();
|
||||
assert_eq!(recorded(whole, 1, [true; 2]), regions);
|
||||
assert_eq!(recorded(whole, 2047, [false; 2]), regions);
|
||||
assert_eq!(recorded(whole, 1, true), regions);
|
||||
assert_eq!(recorded(whole, 2047, false), regions);
|
||||
}
|
||||
|
||||
/// A box's scissor is the union of its regions', whichever way the table's order runs over the
|
||||
@@ -304,26 +296,21 @@ fn a_box_s_scissor_holds_its_regions_pixels() {
|
||||
assert_eq!(scissor(4, 2, 2), None);
|
||||
}
|
||||
|
||||
/// A box folds its columns, and its rows, together where no sample of the pass lies on a pixel's
|
||||
/// left edge, and none on its top edge: at the device's standard locations up to 8 samples, and
|
||||
/// at custom positions none of which is 0 on that axis (samples past them lie at the corner).
|
||||
/// A row folds its regions together where no sample of the pass lies on a pixel's left edge: at
|
||||
/// the device's standard locations up to 8 samples, and at custom positions none of whose x is 0
|
||||
/// (samples past them lie at the corner); a sample on a pixel's top edge lies on a row's scissor's
|
||||
/// edge, which the row's recordings share with its regions'.
|
||||
#[test]
|
||||
fn a_box_folds_where_no_sample_lies_on_its_borders() {
|
||||
fn a_row_folds_where_no_sample_lies_on_its_borders() {
|
||||
use super::folds;
|
||||
for samples in [1, 2, 4, 8] {
|
||||
assert_eq!(folds(true, samples, &[]), [true; 2], "{samples}");
|
||||
assert_eq!(folds(false, samples, &[]), [false; 2], "{samples}");
|
||||
assert!(folds(true, samples, &[]), "{samples}");
|
||||
assert!(!folds(false, samples, &[]), "{samples}");
|
||||
}
|
||||
assert_eq!(folds(true, 16, &[]), [false; 2]);
|
||||
assert_eq!(
|
||||
folds(true, 4, &[[8, 8], [4, 12], [12, 4], [2, 14]]),
|
||||
[true; 2]
|
||||
);
|
||||
assert_eq!(folds(true, 2, &[[0, 8], [8, 8]]), [false, true]);
|
||||
assert_eq!(folds(false, 2, &[[8, 0], [8, 8]]), [true, false]);
|
||||
assert!(!folds(true, 16, &[]));
|
||||
assert!(folds(true, 4, &[[8, 8], [4, 12], [12, 4], [2, 14]]));
|
||||
assert!(!folds(true, 2, &[[0, 8], [8, 8]]));
|
||||
assert!(folds(false, 2, &[[8, 0], [8, 8]]));
|
||||
// Two positions of a pass of four: the samples past them at the pixel's corner.
|
||||
assert_eq!(
|
||||
folds(true, 4, &[[8, 8], [4, 4], [0, 0], [0, 0]]),
|
||||
[false; 2]
|
||||
);
|
||||
assert!(!folds(true, 4, &[[8, 8], [4, 4], [0, 0], [0, 0]]));
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//! A rate-mapped pass's draws through their region-copy variant, box by box against region by
|
||||
//! region (`render/fan_out.rs`, **Region-copy variant**): a direct draw records a box of the
|
||||
//! table's regions as many at a time as a multi-draw takes, under the box's scissor, the borders
|
||||
//! A rate-mapped pass's draws through their region-copy variant, row by row against region by
|
||||
//! region (`render/fan_out.rs`, **Region-copy variant**): a direct draw records each row of the
|
||||
//! table's regions as many at a time as a multi-draw takes, under the row's scissor, the borders
|
||||
//! between its regions resting on each copy's clip distances alone; an indirect draw records each
|
||||
//! region alone, under that region's scissor, through the same variant and the same vertex
|
||||
//! function. Each pixel of the pass belongs to one region, so the two draw the same texels where
|
||||
@@ -322,7 +322,7 @@ fn copies(before: &WorkCounts, after: &WorkCounts) -> [u64; 2] {
|
||||
]
|
||||
}
|
||||
|
||||
/// Drawn directly, each draw records the map's regions as one box, as many at a time as a
|
||||
/// Drawn directly, each draw records the map's regions row by row, as many at a time as a
|
||||
/// multi-draw takes, and indirectly one region a recording; the frames' texels are equal bit for
|
||||
/// bit, every texel the ground covered took its `Equal` pass once, and the overlay's triangles
|
||||
/// overlap.
|
||||
@@ -393,12 +393,18 @@ fn a_box_of_regions_draws_the_texels_its_regions_draw_one_at_a_time() {
|
||||
assert_eq!(indirect[1], 3 * regions, "one recording a region");
|
||||
assert!(regions > 16, "the map's regions: {regions}");
|
||||
match multi {
|
||||
// Each draw one box of every region, in one recording.
|
||||
// Each draw a recording a row of the table: as many recordings as it has rows,
|
||||
// which split its regions into rows of several.
|
||||
Some(most) if standard && u64::from(most) >= regions => {
|
||||
assert_eq!(direct[1], 3, "a recording a box")
|
||||
let rows = direct[1] / 3;
|
||||
assert_eq!(direct[1], 3 * rows, "each draw's recordings alike");
|
||||
assert!(
|
||||
rows > 1 && regions.is_multiple_of(rows) && regions / rows > 1,
|
||||
"{rows} recordings a draw of {regions} regions"
|
||||
);
|
||||
}
|
||||
Some(_) if standard => {
|
||||
assert!(direct[1] < indirect[1], "boxes in fewer recordings")
|
||||
assert!(direct[1] < indirect[1], "rows in fewer recordings")
|
||||
}
|
||||
_ => assert_eq!(direct[1], indirect[1], "one region a recording"),
|
||||
}
|
||||
|
||||
@@ -25,31 +25,30 @@
|
||||
//! through its own viewport, is the exact one).
|
||||
//!
|
||||
//! **One route per pass.** Where a pass fans its triangles out, the draws it records region by
|
||||
//! region take their region-copy variant (`RegionFanOut::RegionCopies`), a box of the table's
|
||||
//! regions a recording: the box its recording pushes (`PushField::RegionBox`), its first region
|
||||
//! `first` in the table's order and its columns `c`, and its draw's `DrawIndex` `d` among a
|
||||
//! multi-draw's (0 for a draw that is no multi-draw's) pick the segments `(first mod nx + d mod
|
||||
//! c, first / nx + d / c)`, the box's rows in order, and the vertex function puts each vertex in
|
||||
//! that region by the emitter of the fan-out stage's copies
|
||||
//! region take their region-copy variant (`RegionFanOut::RegionCopies`), a row of the table's
|
||||
//! regions a recording: the row its recording pushes (`PushField::RegionBox`), its first region's
|
||||
//! segments `x0` and `y0`, and its draw's `DrawIndex` `d` among a multi-draw's (0 for a draw that
|
||||
//! is no multi-draw's) pick the segments `(x0 + d, y0)`, the row's regions in order, and the
|
||||
//! vertex function puts each vertex in that region by the emitter of the fan-out stage's copies
|
||||
//! (`pipeline::link::fan_out::region_copy`), storing 0 as `ViewportIndex`, the recording's one
|
||||
//! viewport. The recording sets that viewport, the target's, and its box's scissor, the union of
|
||||
//! its regions' ([`scissors`]), so a box's recording and a recording of each of its regions alone
|
||||
//! viewport. The recording sets that viewport, the target's, and its row's scissor, the union of
|
||||
//! its regions' ([`scissors`]), so a row's recording and a recording of each of its regions alone
|
||||
//! run the same pipeline and differ only in their dynamic viewport and scissor and in the integer
|
||||
//! region each draw selects (Vulkan's Invariance, Rule 4, and Rule 2: "Scissor parameters (other
|
||||
//! than enable)" have no side effects): the clip distances keep each copy to its region's pixels,
|
||||
//! as a fanned-out copy's are kept, and the scissor rejects what lies outside the box. A border between two of a box's regions holds no pixel centre and no
|
||||
//! sample at Vulkan's standard locations, which lie a sixteenth of a pixel or more inside a
|
||||
//! pixel, while each copy's clip distance there is its window coordinate less the border's times
|
||||
//! `w`, zero on the border up to rounding: each such sample is covered by the one copy of its
|
||||
//! region, as under each region's own scissor. A pass whose sample positions put a sample on a
|
||||
//! pixel's left edge (an x of 0) records a box one column at a time, and one that puts one on a
|
||||
//! pixel's top edge (a y of 0) one row at a time, so that a border such a sample lies on is a
|
||||
//! recording's scissor's edge. Every route then hands the rasterizer the same position and clip
|
||||
//! distances for a vertex in a region, through the same viewport transform: a later pass that
|
||||
//! tests `Equal` the depth one draw stored meets it where the other route drew it. The copy's
|
||||
//! arithmetic is decorated `NoContraction`, each operation correctly rounded on its own (Vulkan's
|
||||
//! *Precision and Operation of SPIR-V Instructions*), and its `Position` and `ClipDistance`
|
||||
//! outputs are `Invariant`. The routes run the copy in different pipelines and different stages
|
||||
//! as a fanned-out copy's are kept, and the scissor rejects what lies outside the row. A border
|
||||
//! between two of a row's regions holds no pixel centre and no sample at Vulkan's standard
|
||||
//! locations, which lie a sixteenth of a pixel or more inside a pixel, while each copy's clip
|
||||
//! distance there is its window coordinate less the border's times `w`, zero on the border up to
|
||||
//! rounding: each such sample is covered by the one copy of its region, as under each region's
|
||||
//! own scissor. A pass whose sample positions put a sample on a pixel's left edge (an x of 0)
|
||||
//! records each region of a row alone, so that a border such a sample lies on is a recording's
|
||||
//! scissor's edge; a row's top and bottom edges are its scissor's. Every route then hands the
|
||||
//! rasterizer the same position and clip distances for a vertex in a region, through the same
|
||||
//! viewport transform: a later pass that tests `Equal` the depth one draw stored meets it where
|
||||
//! the other route drew it. The copy's arithmetic is decorated `NoContraction`, each operation
|
||||
//! correctly rounded on its own (Vulkan's *Precision and Operation of SPIR-V Instructions*), and
|
||||
//! its `Position` and `ClipDistance` outputs are `Invariant`. The routes run the copy in different pipelines and different stages
|
||||
//! (the region-copy variant's vertex function, the fan-out variant's geometry stage), each on the
|
||||
//! position its own vertex function computes: the identity rests on those correctly rounded
|
||||
//! operations and on the guest's position computation compiling alike in both pipelines, which
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
//! the region table (`WriteSource::RateMapRegions`) and, for a probe, the flags
|
||||
//! (`WriteSource::RateMapFlags`), and a probe pushes its flag's index to the geometry stage. A
|
||||
//! region-copy variant (`RegionFanOut::RegionCopies`) draws no geometry stage: its vertex
|
||||
//! function draws its region's copy, binding the region table, and its draw pushes its box of
|
||||
//! function draws its region's copy, binding the region table, and its draw pushes its row of
|
||||
//! regions (`PushField::RegionBox`) in the vertex stage's range. Elsewhere the plan keeps the
|
||||
//! plain variant, and the consumer draws the regions one at a time. A fanned-out draw draws no
|
||||
//! regions several at a time.
|
||||
@@ -1850,7 +1850,7 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
| PushField::PatchIndexBound
|
||||
| PushField::ControlPointIndexOffset
|
||||
if stage == Stage::Vertex && emulated_tessellation.is_some() => {}
|
||||
// A region-copy variant's box of regions of a recording, which instantiation
|
||||
// A region-copy variant's row of regions of a recording, which instantiation
|
||||
// writes from the state and the consumer pushes before each recording, in the
|
||||
// window as the amplification fields are.
|
||||
PushField::RegionBox
|
||||
@@ -4759,13 +4759,14 @@ fn instantiate(
|
||||
FieldBytes::of(&word.to_le_bytes())
|
||||
}
|
||||
PushField::VertexBufferStride(layout) => pulled_stride(t, state, layout)?,
|
||||
// A region-copy variant's box of regions: the state's first region, a box of one
|
||||
// column, which the consumer pushes again before each recording of its regions.
|
||||
// A region-copy variant's row of regions: the state's first region's segment of
|
||||
// x in the table's first row, which the consumer pushes again, with its row's
|
||||
// segments, before each recording of its regions.
|
||||
PushField::RegionBox => {
|
||||
let (_, first) = state.region_fan_out.ok_or_else(|| {
|
||||
let (_, x0) = state.region_fan_out.ok_or_else(|| {
|
||||
internal("a region-copy variant's draw without its region")
|
||||
})?;
|
||||
FieldBytes::words([first, 1])
|
||||
FieldBytes::words([x0, 0])
|
||||
}
|
||||
field => slot_field(field, &bound.residuals, &t.resources, state)
|
||||
.ok_or_else(|| internal(format!("a render push field {field:?}")))?,
|
||||
|
||||
@@ -159,13 +159,13 @@ pub struct BindState {
|
||||
/// and the index of the pair of words a probe writes (`PushField::RegionProbe`,
|
||||
/// `WriteSource::RateMapFlags`; 0 for a draw); or records them region by region through that
|
||||
/// viewport, its vertex function putting each vertex in its region as the triangle stage
|
||||
/// puts a copy's ([`RegionFanOut::RegionCopies`](crate::pipeline::RegionFanOut)), and the first
|
||||
/// region, in the region table's order, of the draw's recording (`PushField::RegionBox`, a
|
||||
/// box of one column), which the consumer pushes again, with its box's columns, for each of
|
||||
/// its recordings. The
|
||||
/// consumer sets it only for a draw of triangles. The plan's variant fans out only a vertex
|
||||
/// pipeline without tessellation drawn in one pass of no views, whose stages synthesize no
|
||||
/// geometry stage of their own and draw no band (`bind::graphics`'s module docs). Its variant
|
||||
/// puts a copy's ([`RegionFanOut::RegionCopies`](crate::pipeline::RegionFanOut)), and the
|
||||
/// segment of x of its recording's first region in the region table's first row
|
||||
/// (`PushField::RegionBox`, `[x0, 0]`), which the consumer pushes again, with its row's
|
||||
/// segments, for each of its recordings. The consumer sets it only for a draw of triangles.
|
||||
/// The plan's variant fans out only a vertex pipeline without tessellation drawn in one pass
|
||||
/// of no views, whose stages synthesize no geometry stage of their own and draw no band
|
||||
/// (`bind::graphics`'s module docs). Its variant
|
||||
/// is part of the shape (`BindShape::region_fan_out`), its index only of the draw's bytes;
|
||||
/// `None` for every other draw.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
|
||||
Vendored
+2
-2
@@ -61,7 +61,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2124;
|
||||
pub const SEMANTICS_VERSION: u32 = 2125;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
@@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 523;
|
||||
/// 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 = 2375;
|
||||
pub const RUNTIME_VERSION: u32 = 2376;
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -141,8 +141,8 @@ pub const fn shape(f: PushField) -> FieldShape {
|
||||
| PushField::ControlPointIndexOffset => FieldShape::U32,
|
||||
// An emulated tessellation draw's chunk.
|
||||
PushField::TessellationChunk => FieldShape::U32,
|
||||
// The box of regions a recording of a rate-mapped pass's regions draws: its first region
|
||||
// and its columns.
|
||||
// The row of regions a recording of a rate-mapped pass's regions draws: its first region's
|
||||
// segments of x and y.
|
||||
PushField::RegionBox => FieldShape::UVec2,
|
||||
// A band's viewport half extent and half width, four `f32`s.
|
||||
PushField::LineBand => FieldShape::UVec4Array(1),
|
||||
|
||||
@@ -117,9 +117,9 @@
|
||||
//! positions in each.
|
||||
//!
|
||||
//! A vertex function compiled under `LoweringInputs::region_copies` stores its region's copy at
|
||||
//! every return ([`RegionCopy`]): region `first + (DrawIndex / c)·nx + DrawIndex mod c` of the
|
||||
//! region table, `[first, c]` its `PushField::RegionBox`, its position through the region's line
|
||||
//! and four clip distances after its own, by the emitter a fan-out stage's copies share
|
||||
//! every return ([`RegionCopy`]): the region of segments `(x0 + DrawIndex, y0)` of the region
|
||||
//! table, `[x0, y0]` its `PushField::RegionBox`, its position through the region's line and four
|
||||
//! clip distances after its own, by the emitter a fan-out stage's copies share
|
||||
//! (`pipeline::link::fan_out::region_copy`), and 0 as `ViewportIndex`, the recording's one
|
||||
//! viewport; those clip distances are `Invariant` too.
|
||||
//!
|
||||
@@ -2644,15 +2644,14 @@ fn compensate(
|
||||
}
|
||||
|
||||
/// `position`, a vertex function's `float4` position, as its region's copy (`r`,
|
||||
/// `LoweringInputs::region_copies`): region `first + (DrawIndex / c)·nx + DrawIndex mod c` of the
|
||||
/// region table, in the table's order, `[first, c]` its `PushField::RegionBox` and `nx` the
|
||||
/// table's segments of x (a draw of the box's rows of `c` regions in order), its position through
|
||||
/// the region's line and its four clip distances stored after the function's own, by the emitter
|
||||
/// a fan-out stage's copies share (`pipeline::link::fan_out::region_copy`), and 0 stored as
|
||||
/// `ViewportIndex`, the recording's one viewport (the routes' agreement is checked with these
|
||||
/// `LoweringInputs::region_copies`): the region of segments `(x0 + DrawIndex, y0)` of the region
|
||||
/// table, `[x0, y0]` its `PushField::RegionBox` (a draw of a row's regions in order), its position
|
||||
/// through the region's line and its four clip distances stored after the function's own, by the
|
||||
/// emitter a fan-out stage's copies share (`pipeline::link::fan_out::region_copy`), and 0 stored
|
||||
/// as `ViewportIndex`, the recording's one viewport (the routes' agreement is checked with these
|
||||
/// outputs, `ViewportIndex` among them: `bind::fan_out`, **One route per pass**). The clip
|
||||
/// distances alone keep the copy to its region's pixels, as a fan-out stage's copies' do: the
|
||||
/// recording's scissor is its box's.
|
||||
/// recording's scissor is its row's.
|
||||
fn store_region_copy(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
@@ -2663,11 +2662,11 @@ fn store_region_copy(
|
||||
let Some(table) = cx.decl.families.stage_io.region_table else {
|
||||
return Err(cx.fail("a region's copy without its region table"));
|
||||
};
|
||||
let boxed = cx.push_field(fb, PushField::RegionBox)?;
|
||||
let first = fb.composite_extract(boxed, &[0])?;
|
||||
let columns = fb.composite_extract(boxed, &[1])?;
|
||||
let row = cx.push_field(fb, PushField::RegionBox)?;
|
||||
let x0 = fb.composite_extract(row, &[0])?;
|
||||
let y0 = fb.composite_extract(row, &[1])?;
|
||||
let draw = fetch::load_builtin(cx, fb, r.draw_index)?;
|
||||
let segments = fan_out::box_segments(fb, table, [first, columns], draw)?;
|
||||
let segments = fan_out::row_segments(fb, [x0, y0], draw)?;
|
||||
// Viewport 0, the recording's one.
|
||||
let link = Link {
|
||||
object: r.viewport,
|
||||
|
||||
@@ -3133,9 +3133,9 @@ fn added_clip_distances(
|
||||
}
|
||||
|
||||
/// Plan the region's copy a vertex function with outputs `outputs`, returning `returned`,
|
||||
/// compiled under `LoweringInputs::region_copies`, stores at every return: region `first +
|
||||
/// (DrawIndex / c)·nx + DrawIndex mod c` of the region table (`PushField::RegionBox`'s `[first,
|
||||
/// c]`, the specification's `DrawIndex`, 0 for a draw that is no multi-draw's), its position moved
|
||||
/// compiled under `LoweringInputs::region_copies`, stores at every return: the region of segments
|
||||
/// `(x0 + DrawIndex, y0)` of the region table (`PushField::RegionBox`'s `[x0, y0]`, the
|
||||
/// specification's `DrawIndex`, 0 for a draw that is no multi-draw's), its position moved
|
||||
/// by the region's line and four clip distances past its own keeping the region's pixels
|
||||
/// ([`super::RegionCopy`], `pipeline::link::fan_out::region_copy`), and 0 as `ViewportIndex`,
|
||||
/// the recording's one viewport. A merged draw's vertex function (`merged_draws`) takes it too:
|
||||
|
||||
@@ -436,15 +436,14 @@ pub enum RegionFanOut {
|
||||
/// Draw triangles alone, through one Vulkan viewport over the whole target and a scissor over it,
|
||||
/// with the region table (`bind::fan_out::table`, `SyntheticBinding::RateMapRegions`) of that
|
||||
/// viewport over the plan's regions bound. A draw of [`RegionFanOut::RegionCopies`] records the
|
||||
/// plan's regions a box of the table's at a time, `k` of them a recording (one draw of a
|
||||
/// plan's regions a row of the table's at a time, `k` of them a recording (one draw of a
|
||||
/// `vkCmdDrawMultiEXT` or `vkCmdDrawMultiIndexedEXT` each, or a draw alone), each recording
|
||||
/// pushing the index of its box's first region and its box's columns `c` to its vertex
|
||||
/// function's `PushField::RegionBox`, at [`push_offset`](Self::push_offset) of its stage
|
||||
/// `VERTEX`: the vertex function draws region `first + (DrawIndex / c)·nx + DrawIndex mod c`,
|
||||
/// whose clip distances keep its pixels, and stores 0 as `ViewportIndex`. Such a recording sets
|
||||
/// the one viewport its pipeline
|
||||
/// takes to the one over the whole target, and the scissor of its box's pixels, the union of its
|
||||
/// regions' (`bind::fan_out::scissors`, in the table's order). A probe
|
||||
/// pushing its row's first region's segments of x and y, `x0` and `y0`, to its vertex function's
|
||||
/// `PushField::RegionBox`, at [`push_offset`](Self::push_offset) of its stage `VERTEX`: the
|
||||
/// vertex function draws the region of segments `(x0 + DrawIndex, y0)`, whose clip distances keep
|
||||
/// its pixels, and stores 0 as `ViewportIndex`. Such a recording sets the one viewport its
|
||||
/// pipeline takes to the one over the whole target, and the scissor of its row's pixels, the
|
||||
/// union of its regions' (`bind::fan_out::scissors`, in the table's order). A probe
|
||||
/// ([`RegionFanOut::Probe`]) draws nothing. Of
|
||||
/// the flags buffer's (`SyntheticBinding::RateMapFlags`) `bind::fan_out::PROBE_DRAW_WORDS`
|
||||
/// `u32`s from `PROBE_DRAW_WORDS·i`, `i` its pushed index (`PushField::RegionProbe`, at
|
||||
|
||||
@@ -557,7 +557,7 @@ pub fn link(
|
||||
});
|
||||
}
|
||||
// A region-copy variant draws no geometry stage: its vertex function draws its region's
|
||||
// copy, the box of regions of a recording pushed at its `RegionBox` field.
|
||||
// copy, the row of regions of a recording pushed at its `RegionBox` field.
|
||||
if r.region_fan_out == Some(crate::pipeline::RegionFanOut::RegionCopies) {
|
||||
gs.region_fan_out = Some(crate::pipeline::graphics::FanOutState {
|
||||
mode: crate::pipeline::RegionFanOut::RegionCopies,
|
||||
@@ -624,7 +624,7 @@ pub fn link(
|
||||
/// The graphics state of a render or mesh render pipeline whose geometry stage (its vertex or
|
||||
/// mesh stage) is `geometry`, with its fragment stage's.
|
||||
/// The byte offset of the push-constant block a region-copy variant's vertex function `vs` reads
|
||||
/// its recording's box of regions at (`PushField::RegionBox`): each recording pushes its own, so
|
||||
/// its recording's row of regions at (`PushField::RegionBox`): each recording pushes its own, so
|
||||
/// a function that holds it in its `ArgumentTable`, or reads none, is
|
||||
/// `NotImplemented(RasterizationRateMap)`.
|
||||
fn region_box(vs: &StageInterface) -> Result<u32, Error> {
|
||||
|
||||
@@ -273,27 +273,15 @@ pub(crate) fn declare_table(mb: &mut ModuleBuilder) -> BResult<GlobalId> {
|
||||
mb.resource(REGIONS_SLOT, StorageClass::StorageBuffer, block)
|
||||
}
|
||||
|
||||
/// The segments of draw `d` (a `uint`) of a box of regions of the table `table` whose first
|
||||
/// region, in the table's order, is `first` and whose columns are `c` (`uint`s, `c` at least 1;
|
||||
/// `bind::fan_out`, **One route per pass**): the box's rows of `c` regions each, in order, so
|
||||
/// `(first mod nx + d mod c, first / nx + d / c)`, `nx` the table's segments of axis x.
|
||||
pub(crate) fn box_segments(
|
||||
/// The segments of draw `d` (a `uint`) of a row of regions whose first region's segments are `x0`
|
||||
/// and `y0` (`uint`s; `bind::fan_out`, **One route per pass**): `(x0 + d, y0)`, the row's regions
|
||||
/// in order. Nothing of it reads memory or divides.
|
||||
pub(crate) fn row_segments(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
table: GlobalId,
|
||||
[first, c]: [Value; 2],
|
||||
[x0, y0]: [Value; 2],
|
||||
d: Value,
|
||||
) -> BResult<(Value, Value)> {
|
||||
let header = ku(fb, 0)?;
|
||||
let nx = word(fb, table, header)?;
|
||||
let (x0, y0) = (
|
||||
fb.binary(BinOp::UMod, first, nx)?,
|
||||
fb.binary(BinOp::UDiv, first, nx)?,
|
||||
);
|
||||
let (dx, dy) = (fb.binary(BinOp::UMod, d, c)?, fb.binary(BinOp::UDiv, d, c)?);
|
||||
Ok((
|
||||
fb.binary(BinOp::IAdd, x0, dx)?,
|
||||
fb.binary(BinOp::IAdd, y0, dy)?,
|
||||
))
|
||||
Ok((fb.binary(BinOp::IAdd, x0, d)?, y0))
|
||||
}
|
||||
|
||||
/// The terms of the copy for segments `sx` and `sy` (`uint`s) of the table `table` (its global
|
||||
|
||||
@@ -902,14 +902,14 @@ pub struct LoweringInputs {
|
||||
/// The function's render pipeline draws a rasterization-rate-mapped pass's regions through
|
||||
/// the target's viewport, each region's copy of each vertex computed in the vertex function
|
||||
/// (`VariantKey::region_fan_out`, `RegionFanOut::RegionCopies`), as a fanned-out copy's is:
|
||||
/// region `first + (DrawIndex / c)·nx + DrawIndex mod c` of the region table
|
||||
/// (`SyntheticBinding::RateMapRegions`, `bind::fan_out`), `[first, c]` its recording's
|
||||
/// `PushField::RegionBox`, `nx` the table's segments of x and `DrawIndex` its draw's among a
|
||||
/// `vkCmdDrawMultiEXT`'s (0 for any other draw). The vertex function stores the position the
|
||||
/// region's line moves (`pipeline::link::fan_out::region_copy`, the emitter the fan-out stage
|
||||
/// shares, its operations `NoContraction`), four clip distances past its own that keep the
|
||||
/// region's pixels, and 0 as `ViewportIndex`: the one viewport the runtime sets is the
|
||||
/// target's and its scissor its box's. It needs the device to store `ViewportIndex` from a
|
||||
/// the region of segments `(x0 + DrawIndex, y0)` of the region table
|
||||
/// (`SyntheticBinding::RateMapRegions`, `bind::fan_out`), `[x0, y0]` its recording's
|
||||
/// `PushField::RegionBox` and `DrawIndex` its draw's among a `vkCmdDrawMultiEXT`'s (0 for any
|
||||
/// other draw). The vertex function stores the position the region's line moves
|
||||
/// (`pipeline::link::fan_out::region_copy`, the emitter the fan-out stage shares, its
|
||||
/// operations `NoContraction`), four clip distances past its own that keep the region's
|
||||
/// pixels, and 0 as `ViewportIndex`: the one viewport the runtime sets is the target's and
|
||||
/// its scissor its row's. It needs the device to store `ViewportIndex` from a
|
||||
/// vertex function (`shaderOutputViewportIndex`), read `DrawIndex` (`shaderDrawParameters`)
|
||||
/// and write clip
|
||||
/// distances (`shaderClipDistance`), four more within `maxClipDistances` and
|
||||
|
||||
@@ -1026,12 +1026,12 @@ pub enum PushField {
|
||||
/// window holds it (at most 44 bytes before it there: `SnapshotPhase` is a fragment
|
||||
/// function's): the draw of each chunk writes it alone, between its draws.
|
||||
TessellationChunk,
|
||||
/// The box of regions a recording of a rate-mapped pass's regions draws (`uvec2`;
|
||||
/// `RegionFanOut::RegionCopies`, `LoweringInputs::region_copies`): its first region, in the
|
||||
/// region table's order, and its columns `c`, at least 1. Its vertex function draws region
|
||||
/// `first + (DrawIndex / c)·nx + DrawIndex mod c`, `nx` the table's segments of x: the box's
|
||||
/// rows of `c` regions each, in order. Placed with the amplification fields, so the vertex
|
||||
/// window holds it, as a recording writes it before its draws.
|
||||
/// The row of regions a recording of a rate-mapped pass's regions draws (`uvec2`;
|
||||
/// `RegionFanOut::RegionCopies`, `LoweringInputs::region_copies`): its first region's
|
||||
/// segments of x and y in the region table, `x0` and `y0`. Its vertex function draws the
|
||||
/// region of segments `(x0 + DrawIndex, y0)`: the row's regions in order. Placed with the
|
||||
/// amplification fields, so the vertex window holds it, as a recording writes it before its
|
||||
/// draws.
|
||||
RegionBox,
|
||||
/// Region base and grid of a multi-region dispatch.
|
||||
DispatchRegion,
|
||||
|
||||
@@ -173,19 +173,26 @@ fn a_fanned_out_draw_runs_its_variant() {
|
||||
if mode != RegionFanOut::RegionCopies {
|
||||
continue;
|
||||
}
|
||||
// Its box of regions, in the vertex stage's push range: its first region, a box of
|
||||
// one column.
|
||||
// Its row of regions, in the vertex stage's push range: its first region's segments,
|
||||
// the state's of x in the table's first row.
|
||||
let at = fan.push_offset;
|
||||
let boxed = (commands.push_constants.iter())
|
||||
let row = (commands.push_constants.iter())
|
||||
.filter(|w| w.stages.contains(vk::ShaderStageFlags::VERTEX))
|
||||
.find(|w| w.offset <= at && at + 8 <= w.offset + w.bytes.len() as u32)
|
||||
.map(|w| w.bytes[(at - w.offset) as usize..][..8].to_vec());
|
||||
let words = [5u32, 1].map(u32::to_le_bytes);
|
||||
assert_eq!(boxed, Some(words.as_flattened().to_vec()), "{stem}");
|
||||
let vertex = (p.stages.iter())
|
||||
let words = [5u32, 0].map(u32::to_le_bytes);
|
||||
assert_eq!(row, Some(words.as_flattened().to_vec()), "{stem}");
|
||||
let spirv = (p.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| decorated(&m.spirv))
|
||||
.map(|m| &m.spirv)
|
||||
.expect("a vertex module");
|
||||
// Its region is its row's first plus its draw's index: no division picks it.
|
||||
let plain_spirv = (base.stages.iter())
|
||||
.find(|m| m.stage == vk::ShaderStage::VERTEX)
|
||||
.map(|m| &m.spirv)
|
||||
.expect("a vertex module");
|
||||
assert_eq!(divisions(spirv), divisions(plain_spirv), "{stem}");
|
||||
let vertex = decorated(spirv);
|
||||
// Of each axis's coordinate and its two clip distances, five products and three sums.
|
||||
assert_eq!(vertex[0], plain[0] + 2 * 8, "{stem}");
|
||||
assert_eq!(vertex[1], plain[1] + 1, "{stem}");
|
||||
@@ -374,6 +381,23 @@ fn decorated(words: &[u32]) -> [usize; 3] {
|
||||
n
|
||||
}
|
||||
|
||||
/// The integer divisions and remainders of the module of `words`.
|
||||
fn divisions(words: &[u32]) -> usize {
|
||||
use crate::spv::Op;
|
||||
let ops = [Op::UDiv, Op::SDiv, Op::UMod, Op::SMod, Op::SRem].map(|op| op as u32);
|
||||
let mut n = 0;
|
||||
let mut i = 5;
|
||||
while let Some(&w) = words.get(i) {
|
||||
let len = (w >> 16) as usize;
|
||||
n += usize::from(ops.contains(&(w & 0xFFFF)));
|
||||
if len == 0 {
|
||||
break;
|
||||
}
|
||||
i += len;
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
/// Drawn amplified, a plan whose shape fans triangles out keeps the plain variant.
|
||||
#[test]
|
||||
fn an_amplified_draw_keeps_the_plain_variant() {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ three consumer pipelines: A2X (`a2x-s4`, `a2x-s96`), Xgc14 (`xgc14-bgra8`) and X
|
||||
| An attachment (not memoryless) that a pass loads `DontCare` and does not store, in a pass whose draws reach a tile, is cleared over the render area (`clear_reach.rs`) on a driver measured to run that clear no slower than its `DONT_CARE` load (`DriverFact::UnstoredClearNoSlower`: MoltenVK on the M3 Max, RADV on the Radeon 780M), and left `DONT_CARE` on every other driver; an aspect of separate depth and stencil textures likewise, each aspect apart, in the scratch image of the combined format the pass renders them through (`depth_stencil_scratch.rs`). Metal's draws read zero (a colour) or the pass's clear value (depth, stencil) of such an attachment wherever they read it, never its earlier texels (an M3 Max under macOS 27.0.1: an `RG16Float` second colour a framebuffer fetch reads and a `Stencil8` a stencil test reads, in passes split and whole; a separate `Depth32Float` and `Stencil8` read by a depth and a stencil test, each aspect so loaded alone or both; `runtime_lane::dont_care_unstored`); Vulkan's `DONT_CARE` load leaves the contents undefined. | `unstored_dont_care_loads = UnstoredDontCarePolicy::Driver` | `unstored_dont_care_loads = UnstoredDontCarePolicy::Cleared`: cleared on every device, by the pass's first render pass instance's load operation, or before the pass where that instance leaves the attachment out (separate depth and stencil textures: by the scratch image's load operation of the aspect); Metal's answer wherever a draw reads it | On a driver without the fact, the draws read what its `DONT_CARE` load leaves (lavapipe: the attachment's earlier texels). An image the runtime makes to stand for an attachment (the scratch image of separate depth and stencil textures, a stand-in, a backing: `Device::new_planned_texture`) starts at zero on such a driver, never as its memory lies, which may hold a released texture's texels: a clear as it is made. `DontCareUnstoredLoad` (`dont-care-unstored-load`), once per device; `runtime_lane::dont_care_unstored` (both values: Metal's answer under `Cleared` and on a driver with the fact, lavapipe's earlier texels under `Driver`; separate depth and stencil textures alike, but what lavapipe's `DONT_CARE` leaves in the scratch image is printed, not checked) | Measured, `CLEAR` against `DONT_CARE`, the GPU's span per pass, medians of 15 frames in each of two rounds, eight 3648x2038 passes a frame (a `BGRA8Unorm` colour loaded and stored, an `RG16Float` colour and a `Depth32Float_Stencil8` loaded by the form and stored `DontCare`, one draw over the whole target writing all three; a probe whose runtime still left such a load `DONT_CARE`, without the validation layer): lavapipe (Mesa 26.2.6, llvmpipe on LLVM 23.1.4) 10480 and 10744 µs against 7280 and 7259, 3.2 to 3.5 ms more, its clear a write of every texel; ANV (Mesa 26.2.6) on the Iris Xe (RPL-P) 1936 and 1936 µs against 1907 and 1151, slower in both rounds; RADV (Mesa 26.2.6) on the Radeon 780M 861 and 865 µs against 1147 and 988, faster; MoltenVK 1.4.2 on the M3 Max 218 and 218 µs against 224 and 217, apart by less than one form's two rounds; NVIDIA's 615.71.09 on the RTX 5080 Laptop GPU 74.4 and 74.6 µs against 71.2 and 71.4, 3.2 µs more. Memory: none |
|
||||
| A linear sample of a two-plane YCbCr texture whose planes a function reads in place (`YCBCR8_420_2P`, `YCBCR10_420_2P` through a uniform texel buffer over their codes, on an integrated GPU or a CPU device; `lower::sampler::in_place`), through a sampler that addresses no border on either plane axis, with no texel offset placed by a parent's size, is Vulkan's Y′CbCr model of the codes, as the device's own conversion with a linear chroma filter computes it: the four luma codes around the point and the four chroma pairs around the same point of the chroma plane (Metal's midpoint siting) blended bilinearly, then the surface's range and matrix (Metal's coefficients) in `float`, each channel clamped into `[0, 1]`: eight fetches. A runtime sampler's word decides as the function runs. A nearest sample, a border mode, a parent-placed offset and a gather are Metal's under either value. | `ycbcr_in_place_reads = YCbCrInPlacePolicy::Model` | `ycbcr_in_place_reads = YCbCrInPlacePolicy::Exact`: every tap Metal's texel (its chroma weighted 9/3/3/1 and rounded to a code, the fixed-point conversion), and the sample Metal's sum of the four taps' steps on the grid `2048`: twenty fetches and four conversions | The model reconstructs each channel at the point where Metal converts four taps and sums them: within the `float` arithmetic's rounding of the model (checked against an `f64` model on the CPU interpreter, `engine_ycbcr_in_place`), it differs from Metal's by the chroma the taps reconstruct, by Metal's roundings to a code and to `1/2048`, and where a tap's channel leaves `[0, 1]`, which Metal clamps before it sums. `HalfSampleFilter` / `FloatSampleFilter` under the bound converted 4:2:0 format, announced `ycbcr-filter-not-exact` | Radeon 780M (RADV): a 3840 x 2160 `YCBCR10_420_2P` frame sampled linearly into a 3840 x 2160 `BGRA8Unorm` target, GPU time per frame (median of 60): 6.4-6.9 ms under the exact form (`runtime_lane::video_frames`) |
|
||||
| A vertex buffer layout a draw fetches in fixed function, on a driver whose fixed-function vertex input takes an element's displacement modulo `2^32` (`RuntimeDriverDefect::VertexFetchWrapsPast4GiB`: lavapipe), where the draw's indices (`uint` indices, a per-vertex layout) or its indirect arguments (any layout but a constant one) state how far it fetches: the layout keeps the fixed-function fetch, so an element `2^32` bytes or more past the buffer's bind offset reads the bytes at its displacement's low 32 bits, where Metal reads zero past a buffer that ends before them (`render/vertex_reach.rs`). A layout whose reach the draw's own values bound (its last vertex without indices, `65535` plus its base vertex with `ushort` indices, its base instance plus its last instance over the step rate) is pulled where that reach passes `2^32`, under either value, and reads zero. Other drivers read zero (RADV on the 780M, MoltenVK 1.4.2: `runtime_lane::far_vertex_fetches`). | `vertex_reach = VertexReachPolicy::Bounded` | `vertex_reach = VertexReachPolicy::Exact`: such a layout is pulled too, wherever its stride and furthest attribute could reach past `2^32` from the largest index or argument (on lavapipe, every `uint`-indexed draw's per-vertex layout of a stride above 0, and every indirect draw's layout but a constant one), the plan's pulled-vertex-buffer variant (`WorkCounts::far_vertex_fetch_pulled_draws`) | Under `Bounded`, on lavapipe, an element of such a draw at or past `2^32` reads the wrapped bytes: the conformance case `vertex-fetch-past-4gib-small-buffer` replayed under the default policy differs in 8 elements (its two far `uint`-indexed draws at stride 4), and passes under `Exact`. `VertexFetchMayWrap` (`vertex-fetch-may-wrap`), once per device, for a draw left so; `runtime_lane::far_vertex_fetches` (both values) | Measured on lavapipe (Mesa 26.2.4, LLVM 23.1.1) on a Core Ultra 9 275HX shared with other jobs (`runtime_lane::far_vertex_fetches::far_reach_costs`): a state drawn without indices and then with `uint` indices makes one pipeline under `Bounded` and two under `Exact`, the pulled variant made at the first `uint`-indexed draw; a pass of one draw of 65,536 `uint`-indexed points, from the encoder's making to the wait's return, takes 2.3 to 2.8 times as long pulled (medians of 20 passes: 0.94 against 2.41 ms beside two builds, 3.5 to 4.8 against 9.7 to 12.0 ms at a load average of 59 on 24 threads). On every other driver neither value changes a draw |
|
||||
| A draw of triangles in a rasterization-rate-mapped pass that a host step records (an execution whose records the GPU writes or whose range a buffer holds), filled, of one amplification, without a compensation or a band, whose pipeline chooses no slice or viewport and writes no memory from its vertex function, over a map whose layers are alike and whose plan is a grid of at most 128 columns and rows, on a device that enables `geometryShader`, `shaderClipDistance` and `vertexPipelineStoresAndAtomics`, is drawn once and fanned out to the regions its triangles touch (`rate_mapped_pass.rs`, **Fan-out**): its variant's geometry stage emits a copy of each triangle for each region it touches, at most the copies the device's `maxGeometryTotalOutputComponents` allows up to 16, through one viewport over the render area, four clip distances keeping each copy to its region's pixels, where Metal shades each region through its own viewport. A probe recorded before the pass, submitted and waited for, flags a draw a triangle of which crosses `w = 0` or touches more regions than the copies, with the first and the last such triangle: a flagged list of triangles of one instance whose pipeline reads no `[[primitive_id]]` and writes no memory is drawn in parts in its place, its runs of blocks of 64 triangles that hold a flagged one region by region (the probe sets each flagged triangle's block's bit, `bind::fan_out::BLOCK_TRIANGLES`), each run only into the regions its blocks' bounds reach (the probe raises in a block's word the buckets of segments, 16 an axis, that each of its triangles' widened bounds reach, a triangle crossing `w = 0` by its part where `w` is positive: its vertices of positive `w`, unbounded on each side an edge crosses `w = 0`, a subgroup's triangles raising each word once where the device runs subgroup operations in the geometry stage, else each triangle its own; `bind::fan_out::PROBE_BOUNDS_AT`), cut to the first and the last flagged triangle, runs fewer than 170 triangles apart joined (`rate_mapped_pass::RUN_GAP`, what a region draw costs beyond its vertices) and at most four a draw, the nearest joined first, and the triangles before, between and after them fanned out (`render/fan_out.rs`, **Parts**), and another flagged draw region by region; a direct draw to fan out, or a flagged draw's part, whose region draws into the boxes its triangles reach by the probe's bounds hold no more work than its triangles' geometry stage is boxed instead, drawn through its region-copy variant into those boxes (`render/fan_out.rs`, **Boxed draws**: the boxes' regions times its vertices and 512 a region draw against 24 a triangle, `rate_mapped_pass::GEOMETRY_TRIANGLE_WORK`, below the least a fanned-out triangle's geometry cost of a boxed vertex-region on the three devices measured, on a frame of small triangles whose fragments cost little (`rate_mapped_pieces_host_step_patches`, warm, two rounds, the pass's piece): an Iris Xe's (Mesa 26.2.6) 15.4 ns a triangle against 0.49 ns and 0.48 ns, 31 and 32 times; a Radeon 780M's (Mesa 26.2.6) 21.5 ns against 0.73 ns, 29 times; an RTX 3090's (NVIDIA 620.70.06) 9.3 ns against 0.13 ns, 72 times; the lane's 61 draws boxed at 180, about 84 vertex-regions a triangle, took their pieces from 4.64 ms to 9.21 ms, 6.47 ms to 13.57 ms and 2.80 ms to 3.01 ms, about 2.5, 2.8 and 1.1 times their fan-out); and marks a draw a triangle of which it does not flag touches more than four (`bind::fan_out::FEW_COPIES`): a draw it marks none of, and a flagged draw's parts fanned out, is drawn through the variant of four copies, whose geometry stage declares the output of fewer vertices, the three variants (the probe's, four copies and the most) begun at `commit`; it stops at a command's barrier and after a draw that writes memory. On such a device that also enables `shaderOutputViewportIndex` and `shaderDrawParameters`, every other draw of the pass the variant takes (the encoder's own, the commands `commit` records, those the probe does not probe or whose step does not probe, a flagged draw's runs and a flagged draw drawn whole) is drawn region by region through its region-copy variant (`render/fan_out.rs`, **Region-copy variant**): no geometry stage, its vertex function putting each vertex in its region by the instructions that put a fanned-out copy's (`pipeline::link::fan_out::region_copy`), decorated `NoContraction`, its `Position` and `ClipDistance` `Invariant` (no rounding mode is forced), over boxes of the table's regions (a run's the boxes its bounds reach, any other draw's the whole table), a recording per region or, for a direct draw on a device with the multi-draw commands, per as many regions of a box as one `vkCmdDrawMultiEXT` takes (one below `maxMultiDrawCount`), its rows in order, each pushing its box's first region and columns (`PushField::RegionBox`), the recording setting one viewport, the fan-out's over the render area, which the vertex function stores 0 as `ViewportIndex` to select, Line truncated
|
||||
| A draw of triangles in a rasterization-rate-mapped pass that a host step records (an execution whose records the GPU writes or whose range a buffer holds), filled, of one amplification, without a compensation or a band, whose pipeline chooses no slice or viewport and writes no memory from its vertex function, over a map whose layers are alike and whose plan is a grid of at most 128 columns and rows, on a device that enables `geometryShader`, `shaderClipDistance` and `vertexPipelineStoresAndAtomics`, is drawn once and fanned out to the regions its triangles touch (`rate_mapped_pass.rs`, **Fan-out**): its variant's geometry stage emits a copy of each triangle for each region it touches, at most the copies the device's `maxGeometryTotalOutputComponents` allows up to 16, through one viewport over the render area, four clip distances keeping each copy to its region's pixels, where Metal shades each region through its own viewport. A probe recorded before the pass, submitted and waited for, flags a draw a triangle of which crosses `w = 0` or touches more regions than the copies, with the first and the last such triangle: a flagged list of triangles of one instance whose pipeline reads no `[[primitive_id]]` and writes no memory is drawn in parts in its place, its runs of blocks of 64 triangles that hold a flagged one region by region (the probe sets each flagged triangle's block's bit, `bind::fan_out::BLOCK_TRIANGLES`), each run only into the regions its blocks' bounds reach (the probe raises in a block's word the buckets of segments, 16 an axis, that each of its triangles' widened bounds reach, a triangle crossing `w = 0` by its part where `w` is positive: its vertices of positive `w`, unbounded on each side an edge crosses `w = 0`, a subgroup's triangles raising each word once where the device runs subgroup operations in the geometry stage, else each triangle its own; `bind::fan_out::PROBE_BOUNDS_AT`), cut to the first and the last flagged triangle, runs fewer than 170 triangles apart joined (`rate_mapped_pass::RUN_GAP`, what a region draw costs beyond its vertices) and at most four a draw, the nearest joined first, and the triangles before, between and after them fanned out (`render/fan_out.rs`, **Parts**), and another flagged draw region by region; a direct draw to fan out, or a flagged draw's part, whose region draws into the boxes its triangles reach by the probe's bounds hold no more work than its triangles' geometry stage is boxed instead, drawn through its region-copy variant into those boxes (`render/fan_out.rs`, **Boxed draws**: the boxes' regions times its vertices and 512 a region draw against 24 a triangle, `rate_mapped_pass::GEOMETRY_TRIANGLE_WORK`, below the least a fanned-out triangle's geometry cost of a boxed vertex-region on the three devices measured, on a frame of small triangles whose fragments cost little (`rate_mapped_pieces_host_step_patches`, warm, two rounds, the pass's piece): an Iris Xe's (Mesa 26.2.6) 15.4 ns a triangle against 0.49 ns and 0.48 ns, 31 and 32 times; a Radeon 780M's (Mesa 26.2.6) 21.5 ns against 0.73 ns, 29 times; an RTX 3090's (NVIDIA 620.70.06) 9.3 ns against 0.13 ns, 72 times; the lane's 61 draws boxed at 180, about 84 vertex-regions a triangle, took their pieces from 4.64 ms to 9.21 ms, 6.47 ms to 13.57 ms and 2.80 ms to 3.01 ms, about 2.5, 2.8 and 1.1 times their fan-out); and marks a draw a triangle of which it does not flag touches more than four (`bind::fan_out::FEW_COPIES`): a draw it marks none of, and a flagged draw's parts fanned out, is drawn through the variant of four copies, whose geometry stage declares the output of fewer vertices, the three variants (the probe's, four copies and the most) begun at `commit`; it stops at a command's barrier and after a draw that writes memory. On such a device that also enables `shaderOutputViewportIndex` and `shaderDrawParameters`, every other draw of the pass the variant takes (the encoder's own, the commands `commit` records, those the probe does not probe or whose step does not probe, a flagged draw's runs and a flagged draw drawn whole) is drawn region by region through its region-copy variant (`render/fan_out.rs`, **Region-copy variant**): no geometry stage, its vertex function putting each vertex in its region by the instructions that put a fanned-out copy's (`pipeline::link::fan_out::region_copy`), decorated `NoContraction`, its `Position` and `ClipDistance` `Invariant` (no rounding mode is forced), over boxes of the table's regions (a run's the boxes its bounds reach, any other draw's the whole table) row by row, a recording per region or, for a direct draw on a device with the multi-draw commands, per as many regions of a row as one `vkCmdDrawMultiEXT` takes (one below `maxMultiDrawCount`), each pushing its row's first region's segments (`PushField::RegionBox`), so the vertex function's region is those segments plus its `DrawIndex` along the row, read without a division or a table read before its region's Line truncated
|
||||
| A `Managed` buffer's range that `did_modify_range` names, on a device without unified memory (two copies: the runtime's own host copy, or the caller's pages through their import, `managed.rs`, `managed_copy.rs`), is copied into the GPU's copy by the GPU as the submission of the next command buffer committed that uses the buffer runs, from the host copy as it holds the range then: no copy on the CPU and no staging (pages no import of their own maps are staged by the CPU at the commit under either value, but those a guest RAM's chunk imports hold all of, which the GPU copies from those imports: `WorkCounts::managed_bytes_copied_in_from_ram`, `managed_bytes_staged_in`). Macs differ on a CPU write of the range after the commit, before the GPU runs the command buffer: an AMD Radeon Pro 5300M (two copies, macOS 26.7.1) read the bytes at the commit, an Intel UHD Graphics 630 (one copy) read the later write (steps A,B,B,A,B against A,B,B,B,B; `runtime_lane::device_copies`), so the cheaper answer is the default. | `managed_copy_in = ManagedCopyInPolicy::AtSubmission` | `managed_copy_in = ManagedCopyInPolicy::AtCommit`: the commit takes the range as the host copy holds it then, by a CPU copy into staging buffers of host-cached system memory, freed once the submission that copies them in completed (at most 256 MiB staged ahead); a write after the commit reaches no command buffer committed before it, the 5300M's answer | A CPU write after the commit, before the GPU runs the command buffer, may be read. No notice: both answers are a Mac's. `tests::managed_copy_device`'s `ranges_named_*` (the default: each round reads its own bytes or those written after its commit, never an earlier round's; `AtCommit`: its own alone) and `runtime_lane::device_copies`'s `a_did_modify_range_reaches_the_bytes_the_next_commit_finds` (step 4 reads either answer) and `exact_answers_take_a_did_modify_range_at_the_commit` (step 4 reads the bytes at the commit) | A CPU copy of each range at the commit into system memory, which the commit waits for. `tests::managed_copy_device::managed_copy_in_bench` (`MANAGED-COPY-IN`, medians of 40 commits of 32 MiB each, two rounds, over the runtime's own buffer and the caller's pages): RTX 3090 (an eGPU, NVIDIA 620.70.06) `AtSubmission` commit 0.034 to 0.045 ms and 17.3 to 17.7 ms to the completion, `AtCommit` 1.8 to 2.9 ms and 19.2 to 20.2 ms; RX 7900 XTX (RADV, Mesa 26.2.6) `AtSubmission` 0.012 to 0.036 ms and 5.1 to 5.5 ms, `AtCommit` 1.9 to 2.2 ms and 7.1 to 7.5 ms. Memory: the staged ranges until their submission completed, in buffers the device parks and takes again |
|
||||
| An indirect command buffer's records, and the slots past them, on a device that imports host pointers and whose own check found that a held pointer import costs every submission (`submit_check.rs`'s import tax: RADV, ANV on i915), lie in pooled host-visible memory, as every other buffer of the runtime's own does there (`buffer.rs`'s `Device::records_take_own_pages`), not in pages of the runtime's own imported by their pointer and held for the buffer's life. On RADV such an import is an amdgpu userptr listed in every kernel submission (RADV lists every imported memory in each), whose every page the kernel gets again in each, and the kernel's compaction or `khugepaged` migrating one of its pages waits for every fence of the import, all the process's work in flight, while every submission of the process waits behind it or fails with `EAGAIN` and is made again at once. On every other device, and before the check answers, the records lie in the runtime's own pages under either value. | `indirect_records = IndirectRecordsPolicy::Untaxed` | `indirect_records = IndirectRecordsPolicy::Carried`: the records lie in the runtime's own pages wherever the device imports host pointers, whatever a held import costs, as before | A recovery of such a device loses the records with the `VkDevice` and writes them again as a new buffer's (its header, every command reset, its slots past them zero), where Metal keeps a buffer's records across its GPU's restart: as on a device that imports no host pointer and for records in device-local memory on a discrete GPU. The recovery's notice counts such buffers (`device-recovered`: "N indirect command buffers, M of them whose records were lost"). `tests::icb_records_policy` (records in pooled memory under the default where the tax is forced to hold, in the runtime's own pages under `Carried` and where it is forced to fail, and a recovery's carry `Lost` against `Kept`) | A held pointer import for each live indirect command buffer in every submission. Measured on a Radeon 780M (RADV, Mesa 26.2.6, Linux 7.3.3), a guest desktop beside a guest game whose indirect command buffers' records were the process's only pointer imports (3 buffers, 19.6 MB): 5 windows of 65 to 140 ms in 12 s in which the submission thread's every `amdgpu_cs_ioctl` waited in `mmu_interval_read_begin` or returned `EAGAIN` (373 of the run's 382 failed calls), behind `kcompactd`, `khugepaged` and the runtime's own block allocation compacting memory, each waiting in `amdgpu_hmm_invalidate_gfx` for the import's fences. The probe of `submit_check.rs`: 10.3 us more a submission for one 16 MiB pointer import on the 780M, 45.8 on the RX 550 |
|
||||
|
||||
|
||||
Reference in new issue
Block a user