SEMANTICS 2100 / RUNTIME 2248: a rate-mapped pass's parted run is drawn only into the regions its blocks reach
A flagged draw's runs (blocks of 64 triangles around the triangles the probe flags) were drawn region by region into every region of the map's plan. With the consumer's rate-map sample on the Iris Xe that was most of the frame: rate_map_piece_gpu_nanos 382 of 441 ms a frame at pin 74 (232 runs into 2074 regions, 83k run triangles). Now the probe ORs each 64-triangle block's bounds, widened as before, into 16 x and 16 y buckets (bind::fan_out::BOUND_BUCKETS, PROBE_BOUNDS_AT, BLOCK_SET, STRADDLE_SET, fn bucket; PROBE_SETS 6 -> 7), and a run is drawn, through the region-copy route as before, only into the regions its blocks reach, as consecutive ranges in table order. A triangle crossing w = 0 is bounded by its part where w > 0: per axis its positive-w vertices' coordinates, plus infinity on each side where an edge crosses w = 0 (the side is the sign of w_a*v_b - v_a*w_b; within 2^-16 or NaN, both sides). A run whose bounds reach every bucket draws into every region, as before. The route, its clip distances and the Equal-depth identity are unchanged. New counters: WorkCounts::rate_map_run_region_draws, rate_map_runs_every_region, rate_map_straddling_triangles. FAST-PATHS row 50 says so with its numbers. Verified (blotch, d141fe9096..b277d4df9e on69c5ab1de6): - runtime_lane::rate_mapped_pieces, wide frame (23 flagged draws, 35 runs, 8983 run triangles, 2074 regions), warm GPU: XTX fan-out 7.2 / wide 11.7 ms (9ec2b198f3: 6.1 / 20.3), runs 4.5 ms against 14.2; 780M 27.9 / 37.0 (28.9 / 43.0), runs 9.1 ms or less against 14.1. Runs drawn into 12,241 regions against 72,590; 0 runs into every region, 0 straddling triangles. - lavapipe: rate_mapped_depth_equal 0 red in all 10 route pairs; rate_mapped_fan_out 4/4 (1 straddling triangle; 6 runs into 864 regions, each spanning the target); 135 fan_out, region, rate_map and probe unit tests; the probe's structural test checks the straddle add, the bounds Or, the two infinities and the 12 edge-side compares. - Owed on development: 780M/XTX depth_equal and fan-out runs with cold creation per state, clippy in three configurations, rustdoc, the 2080 lane numbers, and the consumer's Iris sample. SEMANTICS_VERSION 2099 -> 2100, RUNTIME_VERSION 2247 -> 2248.
This commit is contained in:
1 parent
140e1811ca
commit
8c89e236d0
16 files changed
+451
-73
No files matched your search
@@ -211,7 +211,10 @@
|
||||
//! instance whose pipeline reads no `[[primitive_id]]` and writes no memory (`render/fan_out.rs`,
|
||||
//! **Parts**, `WorkCounts::rate_map_parted_draws`): its runs of blocks of 64 triangles that hold
|
||||
//! a flagged one region by region, cut to the first and the last flagged triangle, at most four
|
||||
//! (`rate_map_parted_region_triangles`, the runs `rate_map_region_runs`), the triangles before,
|
||||
//! (`rate_map_parted_region_triangles`, the runs `rate_map_region_runs`), each only into the
|
||||
//! regions its blocks' bounds reach (`rate_map_run_region_draws`, those into every region
|
||||
//! `rate_map_runs_every_region`, the flagged triangles crossing `w = 0`
|
||||
//! `rate_map_straddling_triangles`), the triangles before,
|
||||
//! between and after them fanned out; another flagged draw is drawn region by region whole; and
|
||||
//! the others are fanned out (`WorkCounts::rate_map_fanned_draws`), each in its command's place,
|
||||
//! so a pixel's fragments keep their order: a pixel lies in one region. The probe also marks a
|
||||
|
||||
@@ -1800,10 +1800,14 @@ pub(crate) struct RenderLowering {
|
||||
/// The last draw ran its fan-out variant, and whether its pipeline writes memory: what
|
||||
/// `fan_run` hears of it.
|
||||
fanned: (bool, bool),
|
||||
/// The bounds of the run of a flagged draw's blocks the next draw draws region by region
|
||||
/// (`fan_out::run_bounds`): a draw through its region-copy variant draws only the regions
|
||||
/// they reach (`fan_out::run_regions`); `None` for any other draw.
|
||||
run_bounds: Option<u32>,
|
||||
/// The region table a fan-out draw binds and its regions' scissors in its order, by the
|
||||
/// viewport and scissor it was made for, and `None` where their regions make none
|
||||
/// (`fan_out::table`).
|
||||
fan_table: Option<(FanTableKey, Option<(FanTable, Vec<vk::Rect2D>)>)>,
|
||||
fan_table: Option<(FanTableKey, Option<(FanTable, Vec<vk::Rect2D>, [u32; 2])>)>,
|
||||
/// The encoder records an execution's commands and the command it draws holds a barrier,
|
||||
/// which orders its draw after every draw before it (`render/executions.rs`).
|
||||
command_barrier: bool,
|
||||
@@ -2554,6 +2558,7 @@ impl RenderLowering {
|
||||
fan_run: None,
|
||||
fan_out: None,
|
||||
fanned: (false, false),
|
||||
run_bounds: None,
|
||||
fan_table: None,
|
||||
command_barrier: false,
|
||||
unordered: UnorderedWrites::new(),
|
||||
@@ -9994,14 +9999,30 @@ impl RenderLowering {
|
||||
let depth = (draw_state.viewports.iter().next())
|
||||
.map_or([0.0, 1.0], |v| [v.min_depth, v.max_depth]);
|
||||
let (viewport, _) = fan_out::target(render_area, depth);
|
||||
let Some((_, Some((_, scissors)))) = &self.fan_table else {
|
||||
let Some((_, Some((_, scissors, grid)))) = &self.fan_table else {
|
||||
return Err(internal(
|
||||
"a draw through its region-copy variant without its region table",
|
||||
));
|
||||
};
|
||||
let (each, per) = (copy_viewports as usize, copy_batch as usize);
|
||||
let recordings: Vec<DrawState> = ((0u32..).step_by(per))
|
||||
.zip(scissors.chunks(per))
|
||||
// A run of a flagged draw's blocks draws only the regions its bounds reach, in
|
||||
// ranges of consecutive regions (`fan_out::run_regions`); any other draw every
|
||||
// region.
|
||||
let ranges = match self.run_bounds {
|
||||
Some(bounds) => {
|
||||
let ranges = fan_out::run_regions(*grid, bounds);
|
||||
let regions = ranges.iter().map(|r| u64::from(r.end - r.start)).sum();
|
||||
let every = regions == scissors.len() as u64;
|
||||
device.shared().counts.rate_map_run_regions(regions, every);
|
||||
ranges
|
||||
}
|
||||
None => vec![0..scissors.len() as u32],
|
||||
};
|
||||
let chunks = (ranges.into_iter()).flat_map(|range| {
|
||||
let held = &scissors[range.start as usize..range.end as usize];
|
||||
((range.start..).step_by(per)).zip(held.chunks(per))
|
||||
});
|
||||
let recordings: Vec<DrawState> = chunks
|
||||
.map(|(first, chunk)| DrawState {
|
||||
viewports: std::iter::repeat_n(viewport, each).collect(),
|
||||
scissors: (chunk.iter().copied())
|
||||
@@ -11965,7 +11986,7 @@ impl RenderLowering {
|
||||
extent,
|
||||
)?;
|
||||
let table = (fan_out::table(®ions, extent))
|
||||
.map(|(bytes, scissors)| (FanTable::Bytes(bytes), scissors));
|
||||
.map(|made| (FanTable::Bytes(made.table), made.scissors, made.grid));
|
||||
let made = table.is_some();
|
||||
self.fan_table = Some((key, table));
|
||||
Ok(made)
|
||||
@@ -11974,7 +11995,7 @@ impl RenderLowering {
|
||||
/// The region table the next fan-out draw binds ([`fan_table`](Self::fan_table)), uploaded to
|
||||
/// the command buffer by the encoder's first draw that binds it.
|
||||
fn fan_table_bound(&mut self) -> Result<vk::DescriptorBufferInfo, Error> {
|
||||
let Some((_, Some((table, _)))) = &mut self.fan_table else {
|
||||
let Some((_, Some((table, _, _)))) = &mut self.fan_table else {
|
||||
return Err(internal("a fan-out draw without its region table"));
|
||||
};
|
||||
let bytes = match table {
|
||||
|
||||
@@ -2685,47 +2685,69 @@ impl RenderExecution {
|
||||
..fan
|
||||
})
|
||||
};
|
||||
// A run's bounds, of the draw's blocks' the probe found: the regions it is drawn
|
||||
// into (`fan_out::run_bounds`).
|
||||
let bounds = (fan.filter(|_| parts.is_some()))
|
||||
.and_then(|fan| encoder.fan_run.as_ref()?.bounds(fan.index));
|
||||
let part_bounds = |part: &Part| match part.fanned {
|
||||
true => None,
|
||||
false => Some(
|
||||
bounds
|
||||
.as_deref()
|
||||
.map_or(u32::MAX, |b| fan_out::run_bounds(b, part)),
|
||||
),
|
||||
};
|
||||
// Each part's triangles and whether its draw ran its fan-out variant.
|
||||
let mut drawn = Vec::new();
|
||||
match draw {
|
||||
Draw::Primitives(assembly, whole) => {
|
||||
let draws: Vec<(Option<FanOutDraw>, DrawCall, u32)> = match &parts {
|
||||
None => vec![(encoder.fan_out, whole, 0)],
|
||||
let draws: Vec<(Option<FanOutDraw>, DrawCall, u32, Option<u32>)> = match &parts
|
||||
{
|
||||
None => vec![(encoder.fan_out, whole, 0, None)],
|
||||
Some(parts) => (parts.iter())
|
||||
.map(|part| (part_fan(part), part_call(whole, *part), part.count))
|
||||
.map(|part| {
|
||||
let call = part_call(whole, *part);
|
||||
(part_fan(part), call, part.count, part_bounds(part))
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
for (at, (fan_out, draw, triangles)) in draws.into_iter().enumerate() {
|
||||
for (at, (fan_out, draw, triangles, bounds)) in draws.into_iter().enumerate() {
|
||||
if at > 0 {
|
||||
regions = note(found.piece_after(encoder));
|
||||
found.piece_before(encoder);
|
||||
}
|
||||
encoder.fan_out = fan_out;
|
||||
encoder.run_bounds = bounds;
|
||||
encoder.draw(live, CALL, assembly, draw, DrawBuffers::default(), false)?;
|
||||
encoder.run_bounds = None;
|
||||
drawn.push((triangles, encoder.fanned.0));
|
||||
}
|
||||
}
|
||||
Draw::Indexed(whole, (buffer, whole_offset)) => {
|
||||
let size = index_size(whole.index_type);
|
||||
let draws: Vec<(Option<FanOutDraw>, IndexedDraw, u64)> = match &parts {
|
||||
None => vec![(encoder.fan_out, whole, whole_offset)],
|
||||
Some(parts) => (parts.iter())
|
||||
.map(|part| {
|
||||
let draw = IndexedDraw {
|
||||
index_count: 3 * part.count,
|
||||
..whole
|
||||
};
|
||||
let offset = whole_offset + 3 * u64::from(part.first) * size;
|
||||
(part_fan(part), draw, offset)
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
for (at, (fan_out, mut draw, mut offset)) in draws.into_iter().enumerate() {
|
||||
let draws: Vec<(Option<FanOutDraw>, IndexedDraw, u64, Option<u32>)> =
|
||||
match &parts {
|
||||
None => vec![(encoder.fan_out, whole, whole_offset, None)],
|
||||
Some(parts) => (parts.iter())
|
||||
.map(|part| {
|
||||
let draw = IndexedDraw {
|
||||
index_count: 3 * part.count,
|
||||
..whole
|
||||
};
|
||||
let offset = whole_offset + 3 * u64::from(part.first) * size;
|
||||
(part_fan(part), draw, offset, part_bounds(part))
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
for (at, (fan_out, mut draw, mut offset, bounds)) in
|
||||
draws.into_iter().enumerate()
|
||||
{
|
||||
if at > 0 {
|
||||
regions = note(found.piece_after(encoder));
|
||||
found.piece_before(encoder);
|
||||
}
|
||||
encoder.fan_out = fan_out;
|
||||
encoder.run_bounds = bounds;
|
||||
let triangles = draw.index_count / 3;
|
||||
// A draw that would hold more than a piece's work, drawn as consecutive
|
||||
// ranges of its indices, each a draw a piece may begin before; the last
|
||||
@@ -2759,6 +2781,7 @@ impl RenderExecution {
|
||||
}
|
||||
}
|
||||
encoder.draw_indexed(live, CALL, draw, &buffer, offset)?;
|
||||
encoder.run_bounds = None;
|
||||
drawn.push((triangles, encoder.fanned.0));
|
||||
}
|
||||
}
|
||||
@@ -3070,6 +3093,7 @@ impl RenderExecution {
|
||||
fan_run: None,
|
||||
fan_out: None,
|
||||
fanned: (false, false),
|
||||
run_bounds: None,
|
||||
fan_table: None,
|
||||
command_barrier: false,
|
||||
unordered: UnorderedWrites::new(),
|
||||
@@ -4294,7 +4318,12 @@ impl DeferredPass {
|
||||
.collect();
|
||||
let flagged = draws.iter().filter(|draw| draw.flagged.is_some()).count();
|
||||
let triangles = draws.iter().map(|d| u64::from(d.flagged_triangles));
|
||||
(device.shared().counts).rate_map_probe(flagged as u64, triangles.sum());
|
||||
let straddling = draws.iter().map(|d| u64::from(d.straddling_triangles));
|
||||
(device.shared().counts).rate_map_probe(
|
||||
flagged as u64,
|
||||
triangles.sum(),
|
||||
straddling.sum(),
|
||||
);
|
||||
found_draws = draws.into();
|
||||
}
|
||||
probed = Some(recorded);
|
||||
|
||||
@@ -12,8 +12,12 @@
|
||||
//! joined and at most [`MOST_RUNS`] of them, the nearest joined first; and the triangles before,
|
||||
//! between and after them, fanned out. Each part is a draw of a range of the draw's vertices or
|
||||
//! indices, so each triangle keeps its vertices, its `vertex_id`s and its place among the draw's:
|
||||
//! a pixel takes the draw's fragments in the draw's order. A flagged draw of any other kind is
|
||||
//! drawn region by region whole.
|
||||
//! a pixel takes the draw's fragments in the draw's order. A run is drawn only into the regions
|
||||
//! its blocks' bounds reach ([`run_bounds`], [`run_regions`]): the probe raises a block's bounds
|
||||
//! to the buckets of segments each of its triangles reaches on each axis, widened, a straddling
|
||||
//! triangle's those of its part where `w` is positive (`bind::fan_out::PROBE_BOUNDS_AT`), so a
|
||||
//! region it skips is one no triangle of the run covers a pixel of. A flagged draw of any other
|
||||
//! kind is drawn region by region whole, into every region.
|
||||
//!
|
||||
//! **Region-copy variant.** On a device that fans the pass's triangles out and enabled what the
|
||||
//! variant takes ([`copies_regions`]), a draw of the pass that is not fanned out (the encoder's
|
||||
@@ -37,7 +41,10 @@ use crate::rate_mapped_pass::RUN_GAP;
|
||||
use crate::render_values::{ScissorRect, Viewport};
|
||||
use crate::Device;
|
||||
use ash::vk;
|
||||
use metal2vulkan::bind::fan_out::{BLOCK_TRIANGLES, PROBE_BLOCKS, PROBE_COUNT_WORDS};
|
||||
use metal2vulkan::bind::fan_out::{
|
||||
bucket, BLOCK_SET, BLOCK_TRIANGLES, BOUND_BUCKETS, PROBE_BLOCKS, PROBE_BOUNDS_AT,
|
||||
PROBE_COUNT_WORDS, STRADDLE_SET,
|
||||
};
|
||||
use metal2vulkan::bind::ReplayFaults;
|
||||
use metal2vulkan::device::{RateMapRegionPolicy, VkFeature};
|
||||
use metal2vulkan::pipeline::RegionFanOut;
|
||||
@@ -87,14 +94,18 @@ pub(super) struct Flagged {
|
||||
/// What the probe found of a draw it probed, from its words (`bind::fan_out::PROBE_DRAW_WORDS`):
|
||||
/// the copies its triangles emit (its counts summed), whether a triangle it does not flag is too
|
||||
/// wide for few copies (`bind::fan_out::FEW_COPIES`, a wide word marked), the triangles it
|
||||
/// flagged, where it flagged one, and how many it flagged (its flagged counts summed), each of
|
||||
/// each instance once.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
/// flagged, where it flagged one, how many it flagged (its flagged counts summed) and how many
|
||||
/// of those straddle `w = 0` (its straddle counts summed), each of each instance once; and,
|
||||
/// where it flagged one, its blocks' bounds (`bind::fan_out::PROBE_BOUNDS_AT`), which its runs
|
||||
/// take ([`run_bounds`]).
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(super) struct Probed {
|
||||
pub(super) copies: u32,
|
||||
pub(super) wide: bool,
|
||||
pub(super) flagged: Option<Flagged>,
|
||||
pub(super) flagged_triangles: u32,
|
||||
pub(super) straddling_triangles: u32,
|
||||
pub(super) bounds: Option<Arc<[u32]>>,
|
||||
}
|
||||
|
||||
impl Probed {
|
||||
@@ -105,18 +116,24 @@ impl Probed {
|
||||
let first = set(2).max().unwrap_or(0);
|
||||
let last = set(3).max().unwrap_or(0);
|
||||
let mut blocks = [0u32; PROBE_COUNT_WORDS as usize];
|
||||
for (bits, word) in blocks.iter_mut().zip(set(5)) {
|
||||
for (bits, word) in blocks.iter_mut().zip(set(BLOCK_SET as usize)) {
|
||||
*bits = word;
|
||||
}
|
||||
let flagged = words.first().is_some_and(|&flag| flag != 0);
|
||||
let bounds = (words.iter().skip(PROBE_BOUNDS_AT as usize))
|
||||
.take(PROBE_BLOCKS as usize)
|
||||
.copied();
|
||||
Probed {
|
||||
copies: set(0).fold(0u32, u32::saturating_add),
|
||||
wide: set(1).any(|w| w != 0),
|
||||
flagged: (words.first().is_some_and(|&flag| flag != 0)).then(|| Flagged {
|
||||
flagged: flagged.then(|| Flagged {
|
||||
first: u32::MAX - first,
|
||||
last: last.saturating_sub(1),
|
||||
blocks,
|
||||
}),
|
||||
flagged_triangles: set(4).fold(0u32, u32::saturating_add),
|
||||
straddling_triangles: set(STRADDLE_SET as usize).fold(0u32, u32::saturating_add),
|
||||
bounds: flagged.then(|| bounds.collect()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,6 +228,38 @@ pub(super) fn parts(flagged: &Flagged, triangles: u32, even: bool) -> Vec<Part>
|
||||
parts
|
||||
}
|
||||
|
||||
/// The bounds of a run of a flagged draw's blocks drawn region by region (the module docs,
|
||||
/// **Parts**), `part`, of the draw's blocks' `bounds` (`Probed::bounds`): the buckets of segments
|
||||
/// of each axis its blocks' triangles reach, x's in bits 0 to 15 and y's in bits 16 to 31
|
||||
/// (`bind::fan_out::PROBE_BOUNDS_AT`).
|
||||
pub(super) fn run_bounds(bounds: &[u32], part: &Part) -> u32 {
|
||||
let block = |triangle: u32| (triangle / BLOCK_TRIANGLES).min(PROBE_BLOCKS - 1) as usize;
|
||||
let last = part.first + part.count.max(1) - 1;
|
||||
(bounds.get(block(part.first)..=block(last)))
|
||||
.map_or(u32::MAX, |blocks| blocks.iter().fold(0, |all, &b| all | b))
|
||||
}
|
||||
|
||||
/// The regions of a table of `[nx, ny]` segments, in its order, that a run of bounds `bounds`
|
||||
/// reaches ([`run_bounds`]): each region `k` of segments `(k mod nx, k / nx)` whose x segment's
|
||||
/// bucket and y segment's bucket are among its bits (`bind::fan_out::bucket`), as the ranges of
|
||||
/// consecutive regions they make.
|
||||
pub(super) fn run_regions([nx, ny]: [u32; 2], bounds: u32) -> Vec<std::ops::Range<u32>> {
|
||||
let held = |segment: u32, segments: u32, shift: u32| {
|
||||
bounds >> (shift + bucket(segment, segments).min(BOUND_BUCKETS - 1)) & 1 != 0
|
||||
};
|
||||
let mut ranges: Vec<std::ops::Range<u32>> = Vec::new();
|
||||
for sy in (0..ny).filter(|&sy| held(sy, ny, BOUND_BUCKETS)) {
|
||||
for sx in (0..nx).filter(|&sx| held(sx, nx, 0)) {
|
||||
let k = sy * nx + sx;
|
||||
match ranges.last_mut() {
|
||||
Some(range) if range.end == k => range.end += 1,
|
||||
_ => ranges.push(k..k + 1),
|
||||
}
|
||||
}
|
||||
}
|
||||
ranges
|
||||
}
|
||||
|
||||
/// An encoder's run of an execution's commands where its host step fans the pass's triangles
|
||||
/// out: probing their draws, or drawing them by the probe's words.
|
||||
pub(super) enum FanOutRun {
|
||||
@@ -279,6 +328,17 @@ impl FanOutRun {
|
||||
}
|
||||
}
|
||||
|
||||
/// The blocks' bounds of the flagged draw of index `index` the probe found
|
||||
/// (`Probed::bounds`), where the route draws by the probe's words.
|
||||
pub(super) fn bounds(&self, index: u32) -> Option<Arc<[u32]>> {
|
||||
match self {
|
||||
FanOutRun::Probe(_) => None,
|
||||
FanOutRun::Route(routes) => {
|
||||
(routes.probed.get(index as usize)).and_then(|probed| probed.bounds.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// After the draw of the command at `place`: whether it ran its fan-out variant (`fanned`),
|
||||
/// and whether its pipeline writes memory (`writes`).
|
||||
pub(super) fn end(&mut self, place: usize, fanned: bool, writes: bool) {
|
||||
@@ -372,7 +432,7 @@ fn target_rect([width, height]: [u32; 2]) -> [f32; 4] {
|
||||
pub(super) fn table(
|
||||
regions: &[(vk::Viewport, vk::Rect2D)],
|
||||
extent: [u32; 2],
|
||||
) -> Option<(Vec<u8>, Vec<vk::Rect2D>)> {
|
||||
) -> Option<FanTableMade> {
|
||||
if !(regions.iter()).any(|(_, s)| s.extent.width > 0 && s.extent.height > 0) {
|
||||
return None;
|
||||
}
|
||||
@@ -399,7 +459,22 @@ pub(super) fn table(
|
||||
})
|
||||
})
|
||||
.collect::<Option<_>>()?;
|
||||
Some((table, scissors))
|
||||
// The table's segments of each axis, its first entry's first two words.
|
||||
let word = |at: usize| Some(u32::from_le_bytes(table.get(at..at + 4)?.try_into().ok()?));
|
||||
let grid = [word(0)?, word(4)?];
|
||||
Some(FanTableMade {
|
||||
table,
|
||||
scissors,
|
||||
grid,
|
||||
})
|
||||
}
|
||||
|
||||
/// A fan-out draw's region table ([`table`]): its bytes, its regions' scissors in its order, and
|
||||
/// its segments of each axis, which pick the regions a run's bounds reach ([`run_regions`]).
|
||||
pub(super) struct FanTableMade {
|
||||
pub(super) table: Vec<u8>,
|
||||
pub(super) scissors: Vec<vk::Rect2D>,
|
||||
pub(super) grid: [u32; 2],
|
||||
}
|
||||
|
||||
/// The viewports a recording of a draw through its region-copy variant sets, every one the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{parts, Flagged, Part, Probed, MOST_RUNS};
|
||||
use metal2vulkan::bind::fan_out::{
|
||||
BLOCK_TRIANGLES, PROBE_BLOCKS, PROBE_COUNT_WORDS, PROBE_DRAW_WORDS,
|
||||
BLOCK_TRIANGLES, PROBE_BLOCKS, PROBE_BOUNDS_AT, PROBE_COUNT_WORDS, PROBE_DRAW_WORDS,
|
||||
};
|
||||
|
||||
/// A part of `count` triangles from `first`.
|
||||
@@ -141,6 +141,8 @@ fn a_probed_draw_s_words_name_its_first_and_last_flagged_triangle() {
|
||||
wide: false,
|
||||
flagged: None,
|
||||
flagged_triangles: 0,
|
||||
straddling_triangles: 0,
|
||||
bounds: None,
|
||||
}
|
||||
);
|
||||
words[0] = 1;
|
||||
@@ -156,8 +158,14 @@ fn a_probed_draw_s_words_name_its_first_and_last_flagged_triangle() {
|
||||
// Their blocks' bits: 9's and 40's block 0, and a third's block 33.
|
||||
words[1 + 5 * lanes] = 1;
|
||||
words[1 + 5 * lanes + 1] = 2;
|
||||
// A straddling one in triangle 40's lane, and the bounds of blocks 0 and 33.
|
||||
words[1 + 6 * lanes + 8] = 1;
|
||||
words[PROBE_BOUNDS_AT as usize] = 0x0003_0006;
|
||||
words[PROBE_BOUNDS_AT as usize + 33] = u32::MAX;
|
||||
let mut blocks = [0u32; PROBE_COUNT_WORDS as usize];
|
||||
(blocks[0], blocks[1]) = (1, 2);
|
||||
let mut bounds = vec![0u32; PROBE_BLOCKS as usize];
|
||||
(bounds[0], bounds[33]) = (0x0003_0006, u32::MAX);
|
||||
assert_eq!(
|
||||
Probed::of(&words),
|
||||
Probed {
|
||||
@@ -169,6 +177,29 @@ fn a_probed_draw_s_words_name_its_first_and_last_flagged_triangle() {
|
||||
blocks,
|
||||
}),
|
||||
flagged_triangles: 3,
|
||||
straddling_triangles: 1,
|
||||
bounds: Some(bounds.into()),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// A run's bounds are its blocks' bounds together, and the regions they reach the table's regions
|
||||
/// whose segments' buckets they hold, as ranges of consecutive regions in its order.
|
||||
#[test]
|
||||
fn a_run_reaches_the_regions_its_blocks_bounds_hold() {
|
||||
use super::{run_bounds, run_regions};
|
||||
let mut bounds = vec![0u32; PROBE_BLOCKS as usize];
|
||||
// Block 0 reaches x bucket 1 and y bucket 0; block 1 x buckets 2 and 3, y bucket 1.
|
||||
(bounds[0], bounds[1]) = (0x0001_0002, 0x0002_000c);
|
||||
let run = part(10, 100, false);
|
||||
assert_eq!(run_bounds(&bounds, &run), 0x0003_000e);
|
||||
assert_eq!(run_bounds(&bounds, &part(10, 20, false)), 0x0001_0002);
|
||||
// 32 segments a side, two to a bucket: x segments 2 to 7 of y segments 0 to 3.
|
||||
assert_eq!(
|
||||
run_regions([32, 32], 0x0003_000e),
|
||||
[2..8, 34..40, 66..72, 98..104]
|
||||
);
|
||||
// Every bucket, every region, in one range.
|
||||
assert_eq!(run_regions([5, 3], u32::MAX), [0..15]);
|
||||
assert!(run_regions([5, 3], 0).is_empty());
|
||||
}
|
||||
@@ -421,9 +421,13 @@ fn a_host_step_fans_out_the_commands_the_probe_does_not_flag() {
|
||||
let wait = after.rate_map_probe_wait_nanos - before.rate_map_probe_wait_nanos;
|
||||
let flagged = after.rate_map_flagged_triangles - before.rate_map_flagged_triangles;
|
||||
let runs = after.rate_map_region_runs - before.rate_map_region_runs;
|
||||
let run_regions = after.rate_map_run_region_draws - before.rate_map_run_region_draws;
|
||||
let every_region = after.rate_map_runs_every_region - before.rate_map_runs_every_region;
|
||||
let straddling = after.rate_map_straddling_triangles - before.rate_map_straddling_triangles;
|
||||
eprintln!(
|
||||
"RATE-MAP-FAN-OUT counts {counts:?} probe_gpu_nanos {probe_nanos}, waited {wait} ns; \
|
||||
{flagged} flagged triangles; \
|
||||
{flagged} flagged triangles, {straddling} straddling; runs drawn into {run_regions} \
|
||||
regions, {every_region} into every one; \
|
||||
fan-out pipelines {ready} ready, {waited} waited for; {made} made at the step; {tables} \
|
||||
region tables uploaded; {few} drawn of few copies; {by_regions} triangles of draws in \
|
||||
parts region by region, in {runs} runs; draws through the region-copy variant and \
|
||||
|
||||
@@ -250,6 +250,9 @@ pub(crate) struct Counters {
|
||||
rate_map_fan_tables_uploaded: AtomicU64,
|
||||
rate_map_region_copy_draws: AtomicU64,
|
||||
rate_map_region_copy_recordings: AtomicU64,
|
||||
rate_map_run_region_draws: AtomicU64,
|
||||
rate_map_runs_every_region: AtomicU64,
|
||||
rate_map_straddling_triangles: AtomicU64,
|
||||
encoder_primaries_begun_ahead: AtomicU64,
|
||||
primaries_begun_ahead: AtomicU64,
|
||||
barrier_buffers_kept: AtomicU64,
|
||||
@@ -2988,10 +2991,11 @@ impl Counters {
|
||||
/// A host step's probe of a rate-mapped pass's draws was submitted and waited for
|
||||
/// (`rate_mapped_pass.rs`, **Fan-out**), of which it flagged `flagged` draws, of `triangles`
|
||||
/// flagged triangles.
|
||||
pub(crate) fn rate_map_probe(&self, flagged: u64, triangles: u64) {
|
||||
pub(crate) fn rate_map_probe(&self, flagged: u64, triangles: u64, straddling: u64) {
|
||||
(self.rate_map_probes).fetch_add(1, Ordering::Relaxed);
|
||||
(self.rate_map_flagged_draws).fetch_add(flagged, Ordering::Relaxed);
|
||||
(self.rate_map_flagged_triangles).fetch_add(triangles, Ordering::Relaxed);
|
||||
(self.rate_map_straddling_triangles).fetch_add(straddling, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A host step that fans its pass's triangles out took the making of a probe's or a
|
||||
@@ -3018,6 +3022,14 @@ impl Counters {
|
||||
(self.rate_map_region_copy_recordings).fetch_add(recordings, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A run of a flagged draw's blocks drawn through its region-copy variant into the `regions`
|
||||
/// its bounds reach, `every` region of the plan where they reach them all
|
||||
/// (`render/fan_out.rs`, `run_regions`).
|
||||
pub(crate) fn rate_map_run_regions(&self, regions: u64, every: bool) {
|
||||
(self.rate_map_run_region_draws).fetch_add(regions, Ordering::Relaxed);
|
||||
(self.rate_map_runs_every_region).fetch_add(u64::from(every), Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A host step's probe ran for `nanos` of GPU time, read from its timestamps once it completed
|
||||
/// (`rate_mapped_pass.rs`, **Fan-out**).
|
||||
pub(crate) fn rate_map_probe_time(&self, nanos: u64) {
|
||||
@@ -7458,6 +7470,18 @@ pub struct WorkCounts {
|
||||
/// The recordings they made: one per region, or per as many regions as one multi-draw
|
||||
/// command draws where the draw is direct and the device has the multi-draw commands.
|
||||
pub rate_map_region_copy_recordings: u64,
|
||||
/// The regions the runs of flagged draws' blocks drawn through their region-copy variant
|
||||
/// were drawn into, summed over the runs (each recording of a run cut into index ranges
|
||||
/// counted apart): the regions each run's blocks' bounds reach, as the probe found them
|
||||
/// (`bind::fan_out::PROBE_BOUNDS_AT`).
|
||||
pub rate_map_run_region_draws: u64,
|
||||
/// Those runs whose bounds reached every region of the plan: their triangles reached every
|
||||
/// bucket of segments of each axis (a triangle with some `w` not positive beside a positive
|
||||
/// one by its part where `w` is positive), or the probe's blocks ended before the run's.
|
||||
pub rate_map_runs_every_region: u64,
|
||||
/// The triangles the probes flagged that have some `w` not positive beside a positive one,
|
||||
/// among `rate_map_flagged_triangles`.
|
||||
pub rate_map_straddling_triangles: u64,
|
||||
/// Render passes whose first instance did not record inline, its draws in a secondary command
|
||||
/// buffer, by the first check that ruled it out (`render/inline_first.rs`), counted as the pass
|
||||
/// opens or at its first draw that records: here, the encoder encodes an ended encoder's calls
|
||||
@@ -10709,6 +10733,11 @@ impl Device {
|
||||
.load(Ordering::Relaxed),
|
||||
rate_map_region_copy_recordings: (counters.rate_map_region_copy_recordings)
|
||||
.load(Ordering::Relaxed),
|
||||
rate_map_run_region_draws: (counters.rate_map_run_region_draws).load(Ordering::Relaxed),
|
||||
rate_map_runs_every_region: (counters.rate_map_runs_every_region)
|
||||
.load(Ordering::Relaxed),
|
||||
rate_map_straddling_triangles: (counters.rate_map_straddling_triangles)
|
||||
.load(Ordering::Relaxed),
|
||||
passes_not_inline_encoders: not_inline(NotInline::Encoders),
|
||||
passes_not_inline_layouts: not_inline(NotInline::Layouts),
|
||||
passes_not_inline_memoryless: not_inline(NotInline::Memoryless),
|
||||
|
||||
@@ -115,8 +115,10 @@ const PIECE_LIMIT: Duration = Duration::from_secs(1);
|
||||
/// timed, their GPU time and the longest's; the probes, the draws they flagged, the draws fanned
|
||||
/// out and the probes' GPU time; the host step's time and making; the fan-out's pipelines; the
|
||||
/// draws of few copies; the draws in parts and their triangles drawn region by region; the
|
||||
/// host's wait for the probes; the triangles the probes flagged; their runs drawn region by region.
|
||||
fn counts(work: &WorkCounts) -> [u64; 20] {
|
||||
/// host's wait for the probes; the triangles the probes flagged; their runs drawn region by region;
|
||||
/// the regions the runs were drawn into and the runs that reached every region; the flagged
|
||||
/// triangles that straddle `w = 0`; the recordings through the region-copy variant.
|
||||
fn counts(work: &WorkCounts) -> [u64; 24] {
|
||||
[
|
||||
work.rate_map_pieces,
|
||||
work.rate_map_index_ranges,
|
||||
@@ -138,6 +140,10 @@ fn counts(work: &WorkCounts) -> [u64; 20] {
|
||||
work.rate_map_probe_wait_nanos,
|
||||
work.rate_map_flagged_triangles,
|
||||
work.rate_map_region_runs,
|
||||
work.rate_map_run_region_draws,
|
||||
work.rate_map_runs_every_region,
|
||||
work.rate_map_straddling_triangles,
|
||||
work.rate_map_region_copy_recordings,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -395,6 +401,7 @@ fn pieces_frame(step: bool, policy: RateMapRegionPolicy, scale: u32, triangles:
|
||||
let few = delta(14);
|
||||
let [parted, by_regions, probe_wait, flagged_triangles] = [15, 16, 17, 18].map(delta);
|
||||
let runs = delta(19);
|
||||
let [run_regions, every_region, straddling, copy_recordings] = [20, 21, 22, 23].map(delta);
|
||||
let most = Duration::from_nanos(after[4]);
|
||||
let indices: u64 = draws.iter().map(|&count| u64::from(count)).sum();
|
||||
let mean = Duration::from_nanos(nanos / timed.max(1));
|
||||
@@ -412,7 +419,9 @@ fn pieces_frame(step: bool, policy: RateMapRegionPolicy, scale: u32, triangles:
|
||||
longest {:.2} ms, the mean {:.2} ms; {probes} probes of {:.2} ms, waited for {:.2} ms, \
|
||||
{flagged} draws flagged, {fanned} fanned out ({few} of few copies), {parted} drawn in \
|
||||
parts ({by_regions} triangles region by region in {runs} runs, {flagged_triangles} of \
|
||||
them flagged); the host step {:.1} ms, \
|
||||
them flagged, {straddling} straddling w = 0; the runs drawn into {run_regions} \
|
||||
regions, {every_region} into every region; {copy_recordings} region-copy \
|
||||
recordings); the host step {:.1} ms, \
|
||||
{made} pipelines made there, \
|
||||
{:.1} ms creating render pipelines; the fan-out's pipelines {ready} ready at the \
|
||||
step, {waited} waited for; the commit {:.1} ms",
|
||||
|
||||
@@ -61,23 +61,52 @@
|
||||
//! 0)`.
|
||||
|
||||
/// The words of a probe's flags each probed draw takes: its flag, then [`PROBE_SETS`] sets of
|
||||
/// [`PROBE_COUNT_WORDS`] (`pipeline::link::fan_out`, the probe), from word `PROBE_DRAW_WORDS·i`
|
||||
/// for the draw of index `i`, each zero before the probe. The consumer sums a draw's counts,
|
||||
/// draws a draw none of whose wide words is marked through its variant of few copies
|
||||
/// (`RegionFanOut::DrawFew`), takes the first and the last flagged primitive of a flagged draw
|
||||
/// from the least of the third set and the greatest of the fourth, sums the fifth for its
|
||||
/// flagged triangles, and reads the sixth as the bits of its blocks that hold a flagged one,
|
||||
/// which it draws region by region.
|
||||
pub const PROBE_DRAW_WORDS: u32 = 1 + PROBE_SETS * PROBE_COUNT_WORDS;
|
||||
/// [`PROBE_COUNT_WORDS`] (`pipeline::link::fan_out`, the probe), then its blocks' bounds
|
||||
/// ([`PROBE_BOUNDS_AT`]), from word `PROBE_DRAW_WORDS·i` for the draw of index `i`, each zero
|
||||
/// before the probe. The consumer sums a draw's counts, draws a draw none of whose wide words is
|
||||
/// marked through its variant of few copies (`RegionFanOut::DrawFew`), takes the first and the
|
||||
/// last flagged primitive of a flagged draw from the least of the third set and the greatest of
|
||||
/// the fourth, sums the fifth for its flagged triangles, reads the sixth as the bits of its
|
||||
/// blocks that hold a flagged one, which it draws region by region, sums the seventh for its
|
||||
/// flagged triangles with some `w` not positive beside a positive one, and draws a run of blocks
|
||||
/// only into the regions its blocks' bounds reach.
|
||||
pub const PROBE_DRAW_WORDS: u32 = PROBE_BOUNDS_AT + PROBE_BLOCKS;
|
||||
|
||||
/// The sets of [`PROBE_COUNT_WORDS`] after a probed draw's flag ([`PROBE_DRAW_WORDS`]), in
|
||||
/// order: the counts its triangles add their copies into; the marks of its triangles that it
|
||||
/// does not flag and that reach more than [`FEW_COPIES`] pairs of segments; the greatest
|
||||
/// `u32::MAX − PrimitiveId` of its flagged triangles; the greatest `PrimitiveId + 1` of them;
|
||||
/// the counts its flagged triangles add one each into; and the bits of its blocks of
|
||||
/// the counts its flagged triangles add one each into; the bits of its blocks of
|
||||
/// [`BLOCK_TRIANGLES`] that hold a flagged triangle, block `b` bit `b mod 32` of word `b / 32`
|
||||
/// ([`PROBE_BLOCKS`] of them, the last also every triangle past them).
|
||||
pub const PROBE_SETS: u32 = 6;
|
||||
/// ([`PROBE_BLOCKS`] of them, the last also every triangle past them; [`BLOCK_SET`]); and the
|
||||
/// counts its flagged triangles with some `w` not positive beside a positive one add one each
|
||||
/// into ([`STRADDLE_SET`]).
|
||||
pub const PROBE_SETS: u32 = 7;
|
||||
|
||||
/// The set of a probed draw's words that holds the bits of its blocks ([`PROBE_SETS`]).
|
||||
pub const BLOCK_SET: u32 = 5;
|
||||
|
||||
/// The set of a probed draw's words its flagged triangles with some `w` not positive beside a
|
||||
/// positive one count into ([`PROBE_SETS`]).
|
||||
pub const STRADDLE_SET: u32 = 6;
|
||||
|
||||
/// The word of a probed draw's words ([`PROBE_DRAW_WORDS`]) its blocks' bounds begin at: one
|
||||
/// word a block of [`BLOCK_TRIANGLES`] ([`PROBE_BLOCKS`] of them, the last also every triangle
|
||||
/// past them), the bits of the [`BOUND_BUCKETS`] buckets of each axis its triangles' bounds
|
||||
/// reach ([`bucket`]), x's in bits 0 to 15 and y's in bits 16 to 31, widened as the probe's
|
||||
/// bounds are; for a triangle with some `w` not positive beside a positive one, the bounds of
|
||||
/// its part where `w` is positive, unbounded on each side an edge crosses `w = 0`.
|
||||
pub const PROBE_BOUNDS_AT: u32 = 1 + PROBE_SETS * PROBE_COUNT_WORDS;
|
||||
|
||||
/// The buckets of segments of each axis a block's bounds hold ([`PROBE_BOUNDS_AT`], [`bucket`]).
|
||||
pub const BOUND_BUCKETS: u32 = 16;
|
||||
|
||||
/// The bucket of segment `segment` of an axis of `segments` segments ([`BOUND_BUCKETS`]):
|
||||
/// `segment · BOUND_BUCKETS / segments`, so each bucket holds consecutive segments and every
|
||||
/// segment one bucket.
|
||||
pub const fn bucket(segment: u32, segments: u32) -> u32 {
|
||||
segment * BOUND_BUCKETS / segments
|
||||
}
|
||||
|
||||
/// The triangles of a probed draw's block (`PrimitiveId / BLOCK_TRIANGLES`; [`PROBE_SETS`]):
|
||||
/// [`PROBE_BLOCKS`] of them cover 65,536 triangles, more than a command of the pieces lane draws
|
||||
|
||||
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 = 2099;
|
||||
pub const SEMANTICS_VERSION: u32 = 2100;
|
||||
|
||||
/// 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 = 520;
|
||||
/// 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 = 2247;
|
||||
pub const RUNTIME_VERSION: u32 = 2248;
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -37,14 +37,18 @@
|
||||
//! `u32::MAX − PrimitiveId`, and of the as many after them to `PrimitiveId + 1`, so the
|
||||
//! consumer finds the draw's first and last flagged triangle, adds one into the word it
|
||||
//! picks of the fifth set, so the consumer counts them, and sets the bit of its block of
|
||||
//! [`BLOCK_TRIANGLES`] in the last ([`PROBE_SETS`]), so the consumer draws only the blocks that
|
||||
//! hold a flagged triangle region by region. Its writes need
|
||||
//! `vertexPipelineStoresAndAtomics`.
|
||||
//! [`BLOCK_TRIANGLES`] in the sixth ([`BLOCK_SET`]), so the consumer draws only the blocks that
|
||||
//! hold a flagged triangle region by region; for a flagged triangle with some `w` not positive
|
||||
//! beside a positive one, adds one into the word it picks of the seventh ([`STRADDLE_SET`]).
|
||||
//! Of every triangle it reaches, it sets the bits of the buckets of segments its widened bounds
|
||||
//! reach in its block's bounds ([`PROBE_BOUNDS_AT`], [`BOUND_BUCKETS`]), every bit for one with
|
||||
//! some `w` not positive beside a positive one, so the consumer draws a run of blocks only into
|
||||
//! the regions its blocks reach. Its writes need `vertexPipelineStoresAndAtomics`.
|
||||
|
||||
use super::geometry::{array, kf, ku, scalar, GeometryStages};
|
||||
use crate::bind::fan_out::{
|
||||
clip_entry, line_entry, BLOCK_TRIANGLES, FEW_COPIES, MAX_SEGMENTS, PROBE_BLOCKS,
|
||||
PROBE_COUNT_WORDS, PROBE_DRAW_WORDS, PROBE_SETS,
|
||||
clip_entry, line_entry, BLOCK_SET, BLOCK_TRIANGLES, BOUND_BUCKETS, FEW_COPIES, MAX_SEGMENTS,
|
||||
PROBE_BLOCKS, PROBE_BOUNDS_AT, PROBE_COUNT_WORDS, PROBE_DRAW_WORDS, STRADDLE_SET,
|
||||
};
|
||||
use crate::pipeline::graphics::RegionFanOut;
|
||||
use crate::pipeline::stage_io::IoNumeric;
|
||||
@@ -181,6 +185,60 @@ fn find(
|
||||
Ok(lo)
|
||||
}
|
||||
|
||||
/// The least and the greatest normalized coordinate of axis `axis` (0 x, 1 y) that a triangle of
|
||||
/// clip-space `positions` reaches where its `w` is positive (`positive`, a vertex's; `ndc`, its
|
||||
/// coordinate over its `w`), as the probe bounds a straddling triangle's block: those of its
|
||||
/// vertices of positive `w`, and infinity on each side an edge from such a vertex `a` to one `b`
|
||||
/// of `w` not positive crosses `w = 0`, the sign of `w_a·v_b − v_a·w_b`, a sign within a
|
||||
/// rounding margin of zero (or not a number) taking both sides. A triangle of every `w` positive
|
||||
/// reaches from its least vertex's to its greatest's; one of none, nothing.
|
||||
fn visible_reach(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
positions: [Value; 3],
|
||||
positive: [Value; 3],
|
||||
ndc: [Value; 3],
|
||||
axis: u32,
|
||||
) -> BResult<(Value, Value)> {
|
||||
let below = kf(fb, f32::NEG_INFINITY)?;
|
||||
let above = kf(fb, f32::INFINITY)?;
|
||||
let mut least = Vec::with_capacity(3);
|
||||
let mut greatest = Vec::with_capacity(3);
|
||||
for (&positive, &v) in positive.iter().zip(&ndc) {
|
||||
least.push(fb.select(positive, v, above)?);
|
||||
greatest.push(fb.select(positive, v, below)?);
|
||||
}
|
||||
let mut lo = extreme(fb, GlslOp::FMin, [least[0], least[1], least[2]])?;
|
||||
let mut hi = extreme(fb, GlslOp::FMax, [greatest[0], greatest[1], greatest[2]])?;
|
||||
let zero = kf(fb, 0.0)?;
|
||||
// The margin: 2^-16 of the products' magnitudes, past a float's rounding of their difference.
|
||||
let margin = kf(fb, 1.0 / 65536.0)?;
|
||||
for (a, b) in [(0, 1), (1, 2), (2, 0)] {
|
||||
let crosses = fb.binary(BinOp::LogicalNotEqual, positive[a], positive[b])?;
|
||||
let v_a = fb.composite_extract(positions[a], &[axis])?;
|
||||
let w_a = fb.composite_extract(positions[a], &[3])?;
|
||||
let v_b = fb.composite_extract(positions[b], &[axis])?;
|
||||
let w_b = fb.composite_extract(positions[b], &[3])?;
|
||||
let m = fb.binary(BinOp::FMul, w_a, v_b)?;
|
||||
let n = fb.binary(BinOp::FMul, v_a, w_b)?;
|
||||
let side = fb.binary(BinOp::FSub, m, n)?;
|
||||
let flipped = fb.unary(UnOp::FNegate, side)?;
|
||||
let side = fb.select(positive[a], side, flipped)?;
|
||||
let m = fb.glsl(GlslOp::FAbs, &[m])?;
|
||||
let n = fb.glsl(GlslOp::FAbs, &[n])?;
|
||||
let size = fb.binary(BinOp::FAdd, m, n)?;
|
||||
let size = fb.binary(BinOp::FMul, size, margin)?;
|
||||
let up = fb.binary(BinOp::FAdd, side, size)?;
|
||||
let up = fb.binary(BinOp::FUnordGreaterThanEqual, up, zero)?;
|
||||
let up = fb.binary(BinOp::LogicalAnd, crosses, up)?;
|
||||
let down = fb.binary(BinOp::FSub, side, size)?;
|
||||
let down = fb.binary(BinOp::FUnordLessThanEqual, down, zero)?;
|
||||
let down = fb.binary(BinOp::LogicalAnd, crosses, down)?;
|
||||
hi = fb.select(up, above, hi)?;
|
||||
lo = fb.select(down, below, lo)?;
|
||||
}
|
||||
Ok((lo, hi))
|
||||
}
|
||||
|
||||
/// The least or the greatest of three floats.
|
||||
fn extreme(fb: &mut FunctionBuilder<'_>, op: GlslOp, v: [Value; 3]) -> BResult<Value> {
|
||||
let two = fb.glsl(op, &[v[0], v[1]])?;
|
||||
@@ -421,8 +479,16 @@ pub(super) fn module(stages: &GeometryStages, fan: FanOutStage) -> BResult<Typed
|
||||
ndc.push(fb.binary(BinOp::FDiv, v, w)?);
|
||||
}
|
||||
let ndc = [ndc[0], ndc[1], ndc[2]];
|
||||
let mut lo = extreme(&mut fb, GlslOp::FMin, ndc)?;
|
||||
let mut hi = extreme(&mut fb, GlslOp::FMax, ndc)?;
|
||||
let (mut lo, mut hi) = match probe {
|
||||
Some(_) => {
|
||||
let positive = [positive[0], positive[1], positive[2]];
|
||||
visible_reach(&mut fb, positions, positive, ndc, axis)?
|
||||
}
|
||||
None => (
|
||||
extreme(&mut fb, GlslOp::FMin, ndc)?,
|
||||
extreme(&mut fb, GlslOp::FMax, ndc)?,
|
||||
),
|
||||
};
|
||||
if probe.is_some() {
|
||||
let widen = component(&mut fb, table_f, 1, None, axis)?;
|
||||
lo = fb.binary(BinOp::FSub, lo, widen)?;
|
||||
@@ -495,7 +561,7 @@ pub(super) fn module(stages: &GeometryStages, fan: FanOutStage) -> BResult<Typed
|
||||
let block = fb.glsl(GlslOp::UMin, &[block, most_block])?;
|
||||
let five = ku(&mut fb, 5)?;
|
||||
let block_word = fb.binary(BinOp::ShiftRightLogical, block, five)?;
|
||||
let blocks = ku(&mut fb, 1 + (PROBE_SETS - 1) * PROBE_COUNT_WORDS)?;
|
||||
let blocks = ku(&mut fb, 1 + BLOCK_SET * PROBE_COUNT_WORDS)?;
|
||||
let block_at = fb.binary(BinOp::IAdd, flag_at, blocks)?;
|
||||
let block_at = fb.binary(BinOp::IAdd, block_at, block_word)?;
|
||||
let low = ku(&mut fb, 31)?;
|
||||
@@ -522,6 +588,49 @@ pub(super) fn module(stages: &GeometryStages, fan: FanOutStage) -> BResult<Typed
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut ctx, flagged, arm, None)?;
|
||||
// A straddling triangle: one added into the straddle count its `PrimitiveId` picks.
|
||||
let straddle_at = ku(&mut fb, 1 + STRADDLE_SET * PROBE_COUNT_WORDS)?;
|
||||
let straddle_at = fb.binary(BinOp::IAdd, flag_at, straddle_at)?;
|
||||
let lane_at = fb.binary(BinOp::ISub, lane, one)?;
|
||||
let straddle_at = fb.binary(BinOp::IAdd, straddle_at, lane_at)?;
|
||||
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, straddle_at)?;
|
||||
let one = ku(fb, 1)?;
|
||||
fb.atomic(AtomicOp::IAdd, ptr, Scope::Device, Semantics::RELAXED, one)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut ctx, straddles, arm, None)?;
|
||||
// Its block's bounds: the buckets of segments its widened bounds reach of each axis
|
||||
// where its `w` is positive (`visible_reach`), x's in the low half and y's in the
|
||||
// high, for a triangle of some `w` positive that reaches the regions
|
||||
// (`bind::fan_out::PROBE_BOUNDS_AT`).
|
||||
let buckets = ku(&mut fb, BOUND_BUCKETS)?;
|
||||
let mut halves = Vec::with_capacity(2);
|
||||
for (from, span, n) in [(x0, xs, nx), (y0, ys, ny)] {
|
||||
let lo = fb.binary(BinOp::IMul, from, buckets)?;
|
||||
let lo = fb.binary(BinOp::UDiv, lo, n)?;
|
||||
let to = fb.binary(BinOp::IAdd, from, span)?;
|
||||
let to = fb.binary(BinOp::ISub, to, one)?;
|
||||
let hi = fb.binary(BinOp::IMul, to, buckets)?;
|
||||
let hi = fb.binary(BinOp::UDiv, hi, n)?;
|
||||
let two = ku(&mut fb, 2)?;
|
||||
let past = fb.binary(BinOp::ShiftLeftLogical, two, hi)?;
|
||||
let below = fb.binary(BinOp::ShiftLeftLogical, one, lo)?;
|
||||
halves.push(fb.binary(BinOp::ISub, past, below)?);
|
||||
}
|
||||
let sixteen = ku(&mut fb, 16)?;
|
||||
let high = fb.binary(BinOp::ShiftLeftLogical, halves[1], sixteen)?;
|
||||
let bounds = fb.binary(BinOp::BitwiseOr, halves[0], high)?;
|
||||
let bounded = fb.binary(BinOp::LogicalAnd, some, both)?;
|
||||
let bounds_at = ku(&mut fb, PROBE_BOUNDS_AT)?;
|
||||
let bounds_at = fb.binary(BinOp::IAdd, flag_at, bounds_at)?;
|
||||
let bounds_at = fb.binary(BinOp::IAdd, bounds_at, block)?;
|
||||
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, bounds_at)?;
|
||||
fb.atomic(AtomicOp::Or, ptr, Scope::Device, Semantics::RELAXED, bounds)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
fb.if_(&mut ctx, bounded, arm, None)?;
|
||||
let counted = fb.binary(BinOp::UGreaterThan, count, none)?;
|
||||
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let ptr = word_ptr(fb, count_at)?;
|
||||
|
||||
@@ -166,7 +166,10 @@ fn instructions(words: &[u32], op: crate::spv::Op) -> Vec<&[u32]> {
|
||||
/// (masked by their number less one), whether or not the fragment function reads the primitive's
|
||||
/// index: no one word takes every triangle's add. A flagged triangle raises its draw's first's and
|
||||
/// last's words once each, adds one into its flagged count once, and sets its block's bit once,
|
||||
/// the block its primitive's index shifted by the block's triangles picks.
|
||||
/// the block its primitive's index shifted by the block's triangles picks; a straddling one adds
|
||||
/// one into its straddle count once; and a triangle raises its block's bounds once, a straddling
|
||||
/// one's those of its part where `w` is positive, reaching infinity on a side an edge crosses
|
||||
/// `w = 0`.
|
||||
#[test]
|
||||
fn a_probe_adds_a_triangle_s_copies_into_the_count_its_primitive_picks() {
|
||||
use crate::spv::{BuiltIn, Decoration, Op};
|
||||
@@ -183,14 +186,30 @@ fn a_probe_adds_a_triangle_s_copies_into_the_count_its_primitive_picks() {
|
||||
.find(|(_, class)| *class == Class::Triangle)
|
||||
.expect("the triangle stage");
|
||||
let words = &module.spirv;
|
||||
// The copies' add, and a flagged triangle's count.
|
||||
assert_eq!(instructions(words, Op::AtomicIAdd).len(), 2, "two adds");
|
||||
// The copies' add, a flagged triangle's count, and a straddling one's.
|
||||
assert_eq!(instructions(words, Op::AtomicIAdd).len(), 3, "three adds");
|
||||
// The flag's store, and the wide word's.
|
||||
assert_eq!(instructions(words, Op::AtomicStore).len(), 2, "two stores");
|
||||
// A flagged triangle's raise of the first's and the last's words.
|
||||
assert_eq!(instructions(words, Op::AtomicUMax).len(), 2, "two raises");
|
||||
// A flagged triangle's block bit.
|
||||
assert_eq!(instructions(words, Op::AtomicOr).len(), 1, "one block bit");
|
||||
// A flagged triangle's block bit, and a triangle's block bounds.
|
||||
assert_eq!(instructions(words, Op::AtomicOr).len(), 2, "two ors");
|
||||
// A straddling triangle's bounds: infinity on each side, where an edge crossing `w = 0`
|
||||
// takes it, a sign within the margin taking both.
|
||||
let infinities = (instructions(words, Op::Constant).into_iter())
|
||||
.filter(|c| {
|
||||
[f32::INFINITY, f32::NEG_INFINITY]
|
||||
.map(f32::to_bits)
|
||||
.contains(&c[2])
|
||||
})
|
||||
.count();
|
||||
assert_eq!(infinities, 2, "the bounds' infinities");
|
||||
assert_eq!(
|
||||
instructions(words, Op::FUnordGreaterThanEqual).len()
|
||||
+ instructions(words, Op::FUnordLessThanEqual).len(),
|
||||
12,
|
||||
"an edge's side of each axis, up and down"
|
||||
);
|
||||
let shift = crate::bind::fan_out::BLOCK_TRIANGLES.ilog2();
|
||||
let shifts: Vec<u32> = (instructions(words, Op::Constant).into_iter())
|
||||
.filter(|c| c.get(2) == Some(&shift))
|
||||
|
||||
@@ -1039,14 +1039,18 @@ const metal2vulkan::bind::METAL_OBJECT_GRID_TOTAL pub const METAL_OBJECT_GRID_TO
|
||||
const metal2vulkan::bind::NEUTRAL_HEAP_ELEMENT pub const NEUTRAL_HEAP_ELEMENT: u32
|
||||
const metal2vulkan::bind::SRGB_RESOLVE_LINEAR pub const SRGB_RESOLVE_LINEAR: [u16; 256]
|
||||
const metal2vulkan::bind::SRGB_RESOLVE_THRESHOLDS pub const SRGB_RESOLVE_THRESHOLDS: [u16; 255]
|
||||
const metal2vulkan::bind::fan_out::BLOCK_SET pub const BLOCK_SET: u32
|
||||
const metal2vulkan::bind::fan_out::BLOCK_TRIANGLES pub const BLOCK_TRIANGLES: u32
|
||||
const metal2vulkan::bind::fan_out::BOUND_BUCKETS pub const BOUND_BUCKETS: u32
|
||||
const metal2vulkan::bind::fan_out::FEW_COPIES pub const FEW_COPIES: u32
|
||||
const metal2vulkan::bind::fan_out::HEADER_ENTRIES pub const HEADER_ENTRIES: u32
|
||||
const metal2vulkan::bind::fan_out::MAX_SEGMENTS pub const MAX_SEGMENTS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_BLOCKS pub const PROBE_BLOCKS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_BOUNDS_AT pub const PROBE_BOUNDS_AT: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_COUNT_WORDS pub const PROBE_COUNT_WORDS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_DRAW_WORDS pub const PROBE_DRAW_WORDS: u32
|
||||
const metal2vulkan::bind::fan_out::PROBE_SETS pub const PROBE_SETS: u32
|
||||
const metal2vulkan::bind::fan_out::STRADDLE_SET pub const STRADDLE_SET: u32
|
||||
const metal2vulkan::bind::fan_out::TABLE_BYTES pub const TABLE_BYTES: u64
|
||||
const metal2vulkan::bind::fan_out::WIDEN_PIXELS pub const WIDEN_PIXELS: f64
|
||||
const metal2vulkan::bind::indirect_commands::BINDING_COUNT pub const BINDING_COUNT: usize
|
||||
@@ -1119,14 +1123,18 @@ const-value metal2vulkan::bind::METAL_OBJECT_GRID_TOTAL 1 <<29
|
||||
const-value metal2vulkan::bind::NEUTRAL_HEAP_ELEMENT NEUTRAL_ELEMENT
|
||||
const-value metal2vulkan::bind::SRGB_RESOLVE_LINEAR [0, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 14, 15, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 42, 45, 48, 50, 53, 56, 59, 62, 66, 69, 72, 76, 79, 83, 87, 91, 95, 99, 103, 107, 112, 116, 121, 126, 131, 136, 141, 146, 151, 156, 162, 168, 173, 179, 185, 191, 197, 204, 210, 216, 223, 230, 237, 244, 251, 258, 265, 273, 280, 288, 296, 304, 312, 320, 329, 337, 346, 354, 363, 372, 381, 390, 400, 409, 419, 428, 438, 448, 458, 469, 479, 490, 500, 511, 522, 533, 544, 555, 567, 578, 590, 602, 614, 626, 639, 651, 664, 676, 689, 702, 715, 728, 742, 755, 769, 783, 797, 811, 825, 840, 854, 869, 884, 899, 914, 929, 945, 960, 976, 992, 1008, 1024, 1041, 1057, 1074, 1091, 1108, 1125, 1142, 1159, 1177, 1195, 1213, 1231, 1249, 1267, 1286, 1304, 1323, 1342, 1361, 1381, 1400, 1420, 1440, 1459, 1480, 1500, 1520, 1541, 1562, 1582, 1603, 1625, 1646, 1668, 1689, 1711, 1733, 1755, 1778, 1800, 1823, 1846, 1869, 1892, 1916, 1939, 1963, 1987, 2011, 2035, 2059, 2084, 2109, 2133, 2159, 2184, 2209, 2235, 2260, 2286, 2312, 2339, 2365, 2392, 2419, 2446, 2473, 2500, 2527, 2555, 2583, 2611, 2639, 2668, 2696, 2725, 2754, 2783, 2812, 2841, 2871, 2901, 2931, 2961, 2991, 3022, 3052, 3083, 3114, 3146, 3177, 3209, 3240, 3272, 3304, 3337, 3369, 3402, 3435, 3468, 3501, 3535, 3568, 3602, 3636, 3670, 3705, 3739, 3774, 3809, 3844, 3879, 3915, 3950, 3986, 4022, 4059, 4095]
|
||||
const-value metal2vulkan::bind::SRGB_RESOLVE_THRESHOLDS [1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 14, 15, 16, 18, 19, 21, 23, 24, 26, 28, 30, 32, 34, 37, 39, 42, 44, 47, 49, 52, 55, 58, 61, 64, 68, 71, 74, 78, 82, 85, 89, 93, 97, 102, 106, 110, 115, 119, 124, 129, 134, 139, 144, 149, 154, 160, 165, 171, 177, 183, 189, 195, 201, 207, 214, 220, 227, 234, 241, 248, 255, 262, 270, 277, 285, 293, 300, 308, 317, 325, 333, 342, 350, 359, 368, 377, 386, 395, 405, 414, 424, 434, 444, 454, 464, 474, 485, 495, 506, 517, 528, 539, 550, 562, 573, 585, 597, 609, 621, 633, 645, 658, 670, 683, 696, 709, 722, 736, 749, 763, 777, 790, 804, 819, 833, 848, 862, 877, 892, 907, 922, 938, 953, 969, 985, 1001, 1017, 1033, 1049, 1066, 1083, 1100, 1117, 1134, 1151, 1169, 1186, 1204, 1222, 1240, 1259, 1277, 1296, 1314, 1333, 1352, 1371, 1391, 1410, 1430, 1450, 1470, 1490, 1510, 1531, 1552, 1572, 1593, 1615, 1636, 1657, 1679, 1701, 1723, 1745, 1767, 1790, 1812, 1835, 1858, 1881, 1904, 1928, 1951, 1975, 1999, 2023, 2048, 2072, 2097, 2121, 2146, 2172, 2197, 2222, 2248, 2274, 2300, 2326, 2352, 2379, 2406, 2433, 2460, 2487, 2514, 2542, 2569, 2597, 2626, 2654, 2682, 2711, 2740, 2769, 2798, 2827, 2857, 2886, 2916, 2946, 2977, 3007, 3038, 3068, 3099, 3130, 3162, 3193, 3225, 3257, 3289, 3321, 3354, 3386, 3419, 3452, 3485, 3518, 3552, 3586, 3620, 3654, 3688, 3722, 3757, 3792, 3827, 3862, 3897, 3933, 3969, 4005, 4041, 4077]
|
||||
const-value metal2vulkan::bind::fan_out::BLOCK_SET 5
|
||||
const-value metal2vulkan::bind::fan_out::BLOCK_TRIANGLES 64
|
||||
const-value metal2vulkan::bind::fan_out::BOUND_BUCKETS 16
|
||||
const-value metal2vulkan::bind::fan_out::FEW_COPIES 4
|
||||
const-value metal2vulkan::bind::fan_out::HEADER_ENTRIES 2
|
||||
const-value metal2vulkan::bind::fan_out::MAX_SEGMENTS 128
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_BLOCKS 32 * PROBE_COUNT_WORDS
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_BOUNDS_AT 1 + PROBE_SETS * PROBE_COUNT_WORDS
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_COUNT_WORDS 32
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_DRAW_WORDS 1 + PROBE_SETS * PROBE_COUNT_WORDS
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_SETS 6
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_DRAW_WORDS PROBE_BOUNDS_AT + PROBE_BLOCKS
|
||||
const-value metal2vulkan::bind::fan_out::PROBE_SETS 7
|
||||
const-value metal2vulkan::bind::fan_out::STRADDLE_SET 6
|
||||
const-value metal2vulkan::bind::fan_out::TABLE_BYTES (HEADER_ENTRIES as u64 + 4 * MAX_SEGMENTS as u64) * 16
|
||||
const-value metal2vulkan::bind::fan_out::WIDEN_PIXELS 0.125
|
||||
const-value metal2vulkan::bind::indirect_commands::BINDING_COUNT 32
|
||||
@@ -3318,6 +3326,9 @@ field metal2vulkan-runtime::WorkCounts.rate_map_probes pub rate_map_probes: u64
|
||||
field metal2vulkan-runtime::WorkCounts.rate_map_region_copy_draws pub rate_map_region_copy_draws: u64
|
||||
field metal2vulkan-runtime::WorkCounts.rate_map_region_copy_recordings pub rate_map_region_copy_recordings: u64
|
||||
field metal2vulkan-runtime::WorkCounts.rate_map_region_runs pub rate_map_region_runs: u64
|
||||
field metal2vulkan-runtime::WorkCounts.rate_map_run_region_draws pub rate_map_run_region_draws: u64
|
||||
field metal2vulkan-runtime::WorkCounts.rate_map_runs_every_region pub rate_map_runs_every_region: u64
|
||||
field metal2vulkan-runtime::WorkCounts.rate_map_straddling_triangles pub rate_map_straddling_triangles: u64
|
||||
field metal2vulkan-runtime::WorkCounts.reading_draws_by_coverage pub reading_draws_by_coverage: u64
|
||||
field metal2vulkan-runtime::WorkCounts.reading_draws_in_place pub reading_draws_in_place: u64
|
||||
field metal2vulkan-runtime::WorkCounts.reading_draws_pinned pub reading_draws_pinned: u64
|
||||
@@ -5350,6 +5361,7 @@ fn metal2vulkan::bind::etc_decode_module pub fn etc_decode_module(device: &Devic
|
||||
fn metal2vulkan::bind::extended_canonical_module pub fn extended_canonical_module(device: &Device) -> Result<ExtendedCanonicalModule, Error>
|
||||
fn metal2vulkan::bind::extended_range_canonical pub fn extended_range_canonical([low, high]: [u32; 2]) -> [u32; 2]
|
||||
fn metal2vulkan::bind::extended_shadow_module pub fn extended_shadow_module(device: &Device, form: ExtendedRange) -> Result<ExtendedShadowModule, Error>
|
||||
fn metal2vulkan::bind::fan_out::bucket pub const fn bucket(segment: u32, segments: u32) -> u32
|
||||
fn metal2vulkan::bind::fan_out::clip_entry pub const fn clip_entry(axis: u32, k: u32) -> u32
|
||||
fn metal2vulkan::bind::fan_out::line_entry pub const fn line_entry(axis: u32, k: u32) -> u32
|
||||
fn metal2vulkan::bind::fan_out::scissors pub fn scissors(regions: &[([f32; 4], [u32; 4])]) -> Option<Vec<[u32; 4]>>
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -826,16 +826,21 @@ surface! {
|
||||
mod indirect_commands;
|
||||
}
|
||||
"bind::fan_out" => metal2vulkan::bind::fan_out {
|
||||
const BLOCK_SET;
|
||||
const BLOCK_TRIANGLES;
|
||||
const BOUND_BUCKETS;
|
||||
const FEW_COPIES;
|
||||
const HEADER_ENTRIES;
|
||||
const MAX_SEGMENTS;
|
||||
const PROBE_BLOCKS;
|
||||
const PROBE_BOUNDS_AT;
|
||||
const PROBE_COUNT_WORDS;
|
||||
const PROBE_DRAW_WORDS;
|
||||
const PROBE_SETS;
|
||||
const STRADDLE_SET;
|
||||
const TABLE_BYTES;
|
||||
const WIDEN_PIXELS;
|
||||
fn bucket;
|
||||
fn clip_entry;
|
||||
fn line_entry;
|
||||
fn scissors;
|
||||
|
||||
+5
-2
@@ -5886,8 +5886,11 @@ each item named states the rule in full.
|
||||
fewer than 170 triangles apart joined and at most four a draw, the triangles before, between
|
||||
and after them fanned out (`WorkCounts::rate_map_parted_draws`, the runs
|
||||
`rate_map_region_runs`, their triangles `rate_map_parted_region_triangles` and of those the
|
||||
ones the probe flagged `rate_map_flagged_triangles`); another flagged draw is drawn region by
|
||||
region. On such a device every draw of the pass the fan-out's variant takes and does not fan
|
||||
ones the probe flagged `rate_map_flagged_triangles`), each run only into the regions its
|
||||
blocks' triangles reach by the probe's bounds, a triangle crossing `w = 0` by its part where
|
||||
`w` is positive (`rate_map_run_region_draws` the regions the runs are drawn into,
|
||||
`rate_map_runs_every_region` the runs drawn into every one, `rate_map_straddling_triangles`
|
||||
the flagged triangles crossing `w = 0`); another flagged draw is drawn region by region. On such a device every draw of the pass the fan-out's variant takes and does not fan
|
||||
out (the encoder's own, those the probe flags or does not probe) is drawn region by region
|
||||
through its region-copy variant where the device also enables `multiViewport`,
|
||||
`shaderOutputViewportIndex` and `shaderDrawParameters`, whose vertex function puts each vertex
|
||||
|
||||
+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`), 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; 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 `multiViewport`, `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), a recording per region or per as many regions as a direct draw's multi-draw takes, each pushing its first region, the vertex function storing its draw's index as `ViewportIndex`, every viewport the recording sets the fan-out's over the render area and the scissor at a draw's index its region's (`bind::fan_out::scissors`; Vulkan's viewport transform is determined by the selected viewport's extent, centre and depth range, *Controlling the Viewport*), so every route of the pass puts a vertex in a region at one window position and a later pass's `Equal` depth test meets the depth another route stored. A copy's window coordinates are the region viewport's computed in the geometry stage, so a pixel centre within a rounding error of a triangle's edge may be covered under one policy and not the other | `rate_map_regions = RateMapRegionPolicy::FanOut` | `rate_map_regions = RateMapRegionPolicy::Exact`: every draw recorded once per region of the map's plan, each through its own viewport and scissor, its vertex function run once per region | No note of its own: the map's creation announces the pass as a near-equivalent (`rasterization-rate-map`). `WorkCounts::rate_map_probes`, `rate_map_flagged_draws` and `rate_map_fanned_draws` count the probes, the draws they flagged and the draws fanned out whole, `rate_map_fanned_few_draws` the fanned-out draws of four copies, `rate_map_parted_draws` the flagged draws drawn in parts, `rate_map_region_runs` their runs drawn region by region and `rate_map_parted_region_triangles` those runs' triangles; `rate_map_region_copy_draws` the draws drawn region by region through the region-copy variant and `rate_map_region_copy_recordings` their recordings; `WorkCounts::rate_map_probe_gpu_nanos` the probes' GPU time and `rate_map_probe_wait_nanos` the host's wait for them; `tests::rate_mapped_depth_equal` (an `Equal` pass over a prepass's depth, each by either route: 44,666 of 89,483 pixels failed it on lavapipe through the regions' own viewports beside the fan-out, none under `Exact` or through the region-copy variant) | Measured at tLine 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`; `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; 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 `multiViewport`, `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), a recording per region or per as many regions as a direct draw's multi-draw takes, each pushing its first region, the vertex function storing its draw's index as `ViewportIndex`, every viewport the recording sets the fan-out's over the render area and the scissor at a draw's index its region's (`bind::fan_out::scissors`; Vulkan's viewport transform is determined by the selected viewport's extent, centre and depth range, *Controlling the Viewport*), so every route of the pass puts a vertex in a region at one window position and a later pass's `Equal` depth test meets the depth another route stored. A copy's window coordinates are the region viewport's computed in the geometry stage, so a pixel centre within a rounding error of a triangle's edge may be covered under one policy and not the other | `rate_map_regions = RateMapRegionPolicy::FanOut` | `rate_map_regions = RateMapRegionPolicy::Exact`: every draw recorded once per region of the map's plan, each through its own viewport and scissor, its vertex function run once per region | No note of its own: the map's creation announces the pass as a near-equivalent (`rasterization-rate-map`). `WorkCounts::rate_map_probes`, `rate_map_flagged_draws` and `rate_map_fanned_draws` count the probes, the draws they flagged and the draws fanned out whole, `rate_map_fanned_few_draws` the fanned-out draws of four copies, `rate_map_parted_draws` the flagged draws drawn in parts, `rate_map_region_runs` their runs drawn region by region and `rate_map_parted_region_triangles` those runs' triangles, `rate_map_run_region_draws` the regions the runs are drawn into, `rate_map_runs_every_region` the runs whose bounds reach every region and `rate_map_straddling_triangles` the flaggLine 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 |
|
||||
|
||||
All at once: `DevicePolicy::exact_answers()` sets every switch above; each row states its own cost.
|
||||
|
||||
Reference in new issue
Block a user