diff --git a/crates/metal2vulkan-runtime/examples/icb_reads.rs b/crates/metal2vulkan-runtime/examples/icb_reads.rs index e46edaae1..04220a537 100644 --- a/crates/metal2vulkan-runtime/examples/icb_reads.rs +++ b/crates/metal2vulkan-runtime/examples/icb_reads.rs @@ -3,7 +3,8 @@ //! //! ```sh //! cargo run --release -p metal2vulkan-runtime --example icb_reads -- \ -//! [--commands N] [--runs R] [--only SHAPE,...] [--idle S] [--heap-textures H] [--no-twin] +//! [--commands N] [--runs R] [--only SHAPE,...] [--idle S] [--heap-textures H] [--no-twin] \ +//! [--rate-map] [--wide-every W] //! ``` //! //! Each shape's buffer holds `N` draw commands (8192 by default) that inherit the pipeline state, @@ -33,6 +34,15 @@ //! server's buffers do, so each command's slots are looked at for read twins //! (`binding::TwinSlots`); `--no-twin` makes none. //! +//! With `--rate-map`, every shape's pass is over a rasterization-rate map of a guest's rate-mapped +//! frame (`rate_mapped_pieces`' in the validation crate's runtime lane): one layer over a +//! [`MAP_SCREEN`] screen whose quality falls from 1 at the centre to 0.3 at the edges on both axes +//! ([`MAP_QUALITY`]), into a target of its physical size, so the `gpu-step` shape's host step fans +//! the commands' triangles out to the map's regions after a probe (`rate_mapped_pass.rs`, +//! **Fan-out**). With `--wide-every W` too, every `W`th command's triangle covers the screen, +//! which touches more regions than the fan-out's copies: the probe flags it, and its draw is drawn +//! in parts. The read-back check is left out over a map, whose regions move the texels. +//! //! Each line is the median over `R` runs (9 by default) after one not counted, of each command //! buffer's GPU time (`gpu_start_time` to `gpu_end_time`) a command, the writer's (`encode`, the //! kernel's command buffer; none for the CPU's) and the pass's (`execute`), and the host's time a @@ -62,6 +72,7 @@ //! validation/fixtures/public/kernel_icb_encode_render_commands.ll`, built in), each assembled by //! `llvm-as` from `PATH`. +use metal2vulkan::bind::{RateMapDescriptor, RateMapLayerDescriptor}; use metal2vulkan::metal::{ IndirectCommandType, PixelFormat, PrimitiveType, RenderStages, ResourceUsage, TextureUsage, }; @@ -72,8 +83,8 @@ use metal2vulkan_runtime::{ BlitOption, Buffer, ClearColor, CommandBuffer, CommandBufferStatus, ComputePipelineState, Device, Heap, HeapDescriptor, HeapType, HostMemory, IndirectCommandBuffer, IndirectCommandBufferDescriptor, Library, LoadAction, Origin, PipelineOptions, - RenderPassDescriptor, RenderPipelineState, ResourceOptions, Size, StoreAction, Texture, - TextureDescriptor, WorkCounts, + RasterizationRateMap, RenderPassDescriptor, RenderPipelineState, ResourceOptions, Size, + StoreAction, Texture, TextureDescriptor, WorkCounts, }; use std::collections::BTreeMap; use std::io::Write; @@ -129,6 +140,10 @@ entry:\n\ !28 = !{}\n\ !30 = !{ptr @icb_fragment, !26, !28}\n"; +/// The screen of `--rate-map`'s map, and its quality samples on both axes. +const MAP_SCREEN: [u32; 2] = [3648, 1734]; +const MAP_QUALITY: [f32; 5] = [0.3, 0.6, 1.0, 0.6, 0.3]; + /// The textures of a `gpu-step` command's material, which its fragment function samples. const TEXTURES: u32 = 8; @@ -268,6 +283,8 @@ struct Args { idle: Option, heap_textures: u64, twin: bool, + rate_map: bool, + wide_every: Option, } impl Args { @@ -279,6 +296,8 @@ impl Args { idle: None, heap_textures: 512, twin: true, + rate_map: false, + wide_every: None, }; let mut args = std::env::args().skip(1); while let Some(arg) = args.next() { @@ -290,6 +309,8 @@ impl Args { "--idle" => parsed.idle = Some(value()?.parse()?), "--heap-textures" => parsed.heap_textures = value()?.parse()?, "--no-twin" => parsed.twin = false, + "--rate-map" => parsed.rate_map = true, + "--wide-every" => parsed.wide_every = Some(value()?.parse()?), other => return Err(format!("unknown argument {other}").into()), } } @@ -300,6 +321,12 @@ impl Args { if parsed.heap_textures < u64::from(TEXTURES) { return Err(format!("the heap holds at least {TEXTURES} textures").into()); } + if parsed + .wide_every + .is_some_and(|every| every == 0 || !parsed.rate_map) + { + return Err("--wide-every takes a count of 1 or more, with --rate-map".into()); + } Ok(parsed) } @@ -381,6 +408,8 @@ struct Ours<'a> { heap: Heap, material: Buffer, target: Texture, + /// The passes' rasterization-rate map, with `--rate-map`. + rate_map: Option, /// Three vertices a command: the lower half of its cell. vertices: Buffer, /// The writer's third argument, a word a thread. @@ -464,6 +493,7 @@ impl Ours<'_> { color.load_action = LoadAction::Clear; color.store_action = StoreAction::Store; color.clear_color = ClearColor::new(0.0, 0.0, 0.0, 0.0); + pass.rasterization_rate_map = self.rate_map.clone(); let mut encoder = command_buffer.render_command_encoder(&pass)?; match shape { Shape::GpuStep => { @@ -627,12 +657,16 @@ fn twinned(device: &Device, bytes: usize) -> Result { } /// Three vertices a command, in normalized device coordinates: its cell's lower half, the cells in -/// rows from the bottom left. -fn vertices(commands: u64) -> Vec { +/// rows from the bottom left; with `wide_every`, every that many commands' a triangle over the +/// whole screen instead. +fn vertices(commands: u64, wide_every: Option) -> Vec { let across = SIDE / CELL; let step = 2.0 * CELL as f32 / SIDE as f32; (0..commands) .flat_map(|command| { + if wide_every.is_some_and(|every| command % every == every - 1) { + return [[-1.0, -1.0], [3.0, -1.0], [-1.0, 3.0]]; + } let x = -1.0 + step * (command % across) as f32; let y = -1.0 + step * (command / across) as f32; [[x, y], [x + step, y], [x, y + step]] @@ -705,7 +739,25 @@ fn main() -> Result<()> { } false => None, }; - let mut target = TextureDescriptor::texture_2d(PixelFormat::RGBA8Unorm, SIDE, SIDE, false); + let rate_map = match args.rate_map { + true => { + let mut map = RateMapDescriptor::new(MAP_SCREEN); + map.layers = vec![RateMapLayerDescriptor::new( + MAP_QUALITY.to_vec(), + MAP_QUALITY.to_vec(), + )]; + Some(device.new_rasterization_rate_map(&map)?) + } + false => None, + }; + let (width, height) = match &rate_map { + Some(map) => { + let size = map.physical_size_for_layer(0); + (size.width, size.height) + } + None => (SIDE, SIDE), + }; + let mut target = TextureDescriptor::texture_2d(PixelFormat::RGBA8Unorm, width, height, false); target.usage = TextureUsage::RENDER_TARGET; target.resource_options = ResourceOptions::private(); let ours = Ours { @@ -718,7 +770,8 @@ fn main() -> Result<()> { heap, material, target: device.new_texture(&target)?, - vertices: private_with(&device, &vertices(args.commands))?, + rate_map, + vertices: private_with(&device, &vertices(args.commands, args.wide_every))?, out: device.new_buffer(4 * args.commands, ResourceOptions::private())?, commands: args.commands, }; @@ -782,7 +835,9 @@ fn main() -> Result<()> { } } } - ours.check(shape)?; + if ours.rate_map.is_none() { + ours.check(shape)?; + } let median = |sample: &mut Vec| { sample.sort_by(f64::total_cmp); sample[sample.len() / 2] diff --git a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs index 529e58e54..9ab3aef8a 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs @@ -2815,24 +2815,37 @@ impl CommandBuffer { &self.0.root } - /// Submit `raws`, ended, in order, on its `VkQueue`, and wait for them to complete: a host - /// step's own submission, its probe of a rate-mapped pass's draws (`rate_mapped_pass.rs`, - /// **Fan-out**), as a predicated loop's run again's (`rerun.rs`), `what` naming it for the - /// encoder trail (`encoder_trail.rs`). Whether they completed: `false` where the driver - /// relayed a failure for them, which fails the command buffer at its completion, or the - /// process is exiting. + /// Submit `raws`, ended, in order, on its `VkQueue` with a fence, for the host to wait for + /// later ([`wait_fenced`](Self::wait_fenced)): a host step's own submission, a part of its + /// probe of a rate-mapped pass's draws (`render/executions.rs`, + /// `DeferredPass::probe_parts`), as a predicated loop's run again is (`rerun.rs`), `what` + /// naming it for the encoder trail (`encoder_trail.rs`). `None` where the process is exiting, + /// with nothing submitted. /// /// # Safety /// /// Each of `raws` is a command buffer of its pool, ended, in no pending submission, and - /// recorded for this submission alone; what it uses lives until it completes. - pub(crate) unsafe fn submit_waited( + /// recorded for this submission alone; what it uses lives until it completed, which a wait + /// for it sees. + pub(crate) unsafe fn submit_fenced( &self, raws: &[vk::CommandBuffer], what: &str, - ) -> Result { + ) -> Result, Error> { // SAFETY: the caller's. - match unsafe { rerun::submit_waited(&self.0, raws, what) } { + match unsafe { rerun::submit_fenced(&self.0, raws, what) } { + Ok(fenced) => Ok(Some(fenced)), + Err(rerun::Waited::Failed(error)) => Err(self.device().failed(error)), + Err(_) => Ok(None), + } + } + + /// Wait for every submission of `fenced` ([`submit_fenced`](Self::submit_fenced)'s) to + /// complete, `what` naming them for the encoder trail: whether they completed, `false` where + /// the driver relayed a failure for them, which fails the command buffer at its completion, + /// or the process is exiting. + pub(crate) fn wait_fenced(&self, fenced: &[rerun::Fenced], what: &str) -> Result { + match rerun::wait_fenced(&self.0, fenced, what) { rerun::Waited::Completed => Ok(true), rerun::Waited::Relayed | rerun::Waited::Exiting => Ok(false), rerun::Waited::Failed(error) => Err(self.device().failed(error)), diff --git a/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs b/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs index 956d9bd12..3e5c43e53 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs @@ -413,30 +413,57 @@ pub(super) enum Waited { } /// Submit `raws` (ended, in order) on `buffer`'s `VkQueue` and wait for them to complete, in -/// slices: a predicated loop's run again ([`LoopCheck`]), a host step's probe of a rate-mapped -/// pass (`rate_mapped_pass.rs`, **Fan-out**). `what` names it for the encoder trail's line, where -/// the device's trail is on and it ran for its bound (`encoder_trail.rs`, **Host steps**). +/// slices: a predicated loop's run again ([`LoopCheck`]). `what` names it for the encoder trail's +/// line, where the device's trail is on and it ran for its bound (`encoder_trail.rs`, **Host +/// steps**). /// /// # Safety /// -/// Each of `raws` is a command buffer of `buffer`'s device, ended, in no pending submission, and -/// begun to be submitted again or recorded for this submission alone; what it uses lives until -/// it completes. +/// As [`submit_fenced`]'s. pub(super) unsafe fn submit_waited( buffer: &CommandBufferShared, raws: &[vk::CommandBuffer], what: &str, ) -> Waited { + // SAFETY: the caller's. + match unsafe { submit_fenced(buffer, raws, what) } { + Ok(fenced) => wait_fenced(buffer, &[fenced], what), + Err(ended) => ended, + } +} + +/// A submission of [`submit_fenced`]'s, not yet waited for: its fence, of the device's, in the +/// relay's log until [`wait_fenced`] sees it signaled and gives it back. +pub(crate) struct Fenced { + fence: vk::Fence, + queue: usize, +} + +/// Submit `raws` (ended, in order) on `buffer`'s `VkQueue` with a fence of the device's, logged +/// for the command buffer's relayed failures (`device/relay.rs`), for the host to wait for later +/// ([`wait_fenced`]): a host step's probe of a rate-mapped pass, in parts (`render/executions.rs`, +/// `DeferredPass::probe_parts`). Its submission's failure, or the process's exit, ends it so. +/// +/// # Safety +/// +/// Each of `raws` is a command buffer of `buffer`'s device, ended, in no pending submission, and +/// begun to be submitted again or recorded for this submission alone; what it uses lives until +/// it completes, which a wait for it ([`wait_fenced`]) sees. +pub(super) unsafe fn submit_fenced( + buffer: &CommandBufferShared, + raws: &[vk::CommandBuffer], + what: &str, +) -> Result { let device = &buffer.device; - let Some(busy) = exit_guard::enter() else { - return Waited::Exiting; + let Some(_busy) = exit_guard::enter() else { + return Err(Waited::Exiting); }; let shared = device.shared(); let raw = shared.vk(); // SAFETY: the device's fences, inside a section. let fence = match unsafe { shared.fences.take(raw) } { Ok(fence) => fence, - Err(error) => return Waited::Failed(error), + Err(error) => return Err(Waited::Failed(error)), }; let queue = buffer.queue.vk_queue(); let submits = [vk::SubmitInfo::default().command_buffers(raws)]; @@ -467,9 +494,21 @@ pub(super) unsafe fn submit_waited( }); // SAFETY: a fence no submission took. unsafe { crate::release::object(raw, fence) }; - return Waited::Failed(error); + return Err(Waited::Failed(error)); } - drop(busy); + Ok(Fenced { fence, queue }) +} + +/// Wait, in slices, until every submission of `fenced` (each [`submit_fenced`]'s on `buffer`'s +/// `VkQueue`) completed, then give their fences back: how they ended. `what` names them for the +/// encoder trail's line, as [`submit_waited`]'s. +pub(super) fn wait_fenced(buffer: &CommandBufferShared, fenced: &[Fenced], what: &str) -> Waited { + let Some(last) = fenced.last() else { + return Waited::Completed; + }; + let device = &buffer.device; + let shared = device.shared(); + let mut fences: Vec = fenced.iter().map(|fenced| fenced.fence).collect(); // The encoder trail's line is due once, past its bound. let began = std::time::Instant::now(); let mut trailed = !shared.encoder_trail; @@ -477,42 +516,48 @@ pub(super) unsafe fn submit_waited( let Some(_busy) = exit_guard::enter() else { return Waited::Exiting; }; - // SAFETY: the device's fence, submitted above. - let waited = unsafe { raw.wait_for_fences(&[fence], true, WAIT_SLICE.as_nanos() as u64) }; + // The device's functions, reached inside a section (`DeviceShared::vk`). + let raw = shared.vk(); + // SAFETY: the device's fences, each submitted by `submit_fenced`. + let waited = unsafe { raw.wait_for_fences(&fences, true, WAIT_SLICE.as_nanos() as u64) }; exit_guard::called(Call::WaitForFences); match waited { Ok(()) => break, Err(vk::Result::TIMEOUT) => { if !trailed && began.elapsed() >= crate::encoder_trail::AFTER { trailed = true; - trail_waited(buffer, queue, what, began.elapsed()); + trail_waited(buffer, last.queue, what, began.elapsed()); } continue; } - // The fence stays in the relay's log, as a failed batch's does, never released. + // The fences stay in the relay's log, as a failed batch's do, never released. Err(error) => return Waited::Failed(error), } } let Some(_busy) = exit_guard::enter() else { return Waited::Exiting; }; - // Out of the relay's log before it goes back: its submission completed. - if let Some(flights) = shared.flights(queue) { - flights.let_go(fence); + let raw = shared.vk(); + // Out of the relay's log before they go back: their submissions completed. + for fenced in fenced { + if let Some(flights) = shared.flights(fenced.queue) { + flights.let_go(fenced.fence); + } } - // SAFETY: the fence is signaled and its submission completed. - let reset = unsafe { raw.reset_fences(&[fence]) }; + // SAFETY: the fences are signaled and their submissions completed. + let reset = unsafe { raw.reset_fences(&fences) }; exit_guard::called(Call::ResetFences); - let mut fences = vec![fence]; match reset { // SAFETY: unsignaled and in no pending submission; inside a section. Ok(()) => unsafe { shared.fences.give(raw, &mut fences) }, Err(_) => { - // SAFETY: in no pending submission. - unsafe { crate::release::object(raw, fence) }; + for fence in fences { + // SAFETY: in no pending submission. + unsafe { crate::release::object(raw, fence) }; + } } } - // A failure the driver relayed for it fails the command buffer at its completion. + // A failure the driver relayed for them fails the command buffer at its completion. match buffer.relayed.failure() { Some(_) => Waited::Relayed, None => Waited::Completed, diff --git a/crates/metal2vulkan-runtime/src/render/executions.rs b/crates/metal2vulkan-runtime/src/render/executions.rs index 42d200be1..c3f263af5 100644 --- a/crates/metal2vulkan-runtime/src/render/executions.rs +++ b/crates/metal2vulkan-runtime/src/render/executions.rs @@ -295,6 +295,7 @@ use crate::argument_table::ArgumentTable; use crate::attachment_stand_in::{self, Cause, StandIn, StandInCopies}; use crate::blit::reads; use crate::buffer::Buffer; +use crate::command_buffer::rerun::Fenced; use crate::command_buffer::CommandBuffer; use crate::degradation::{Degradation, HostStepKey, SplitCauses}; use crate::device::functions::Vk; @@ -1040,11 +1041,75 @@ struct Snapshot { /// A command to run: its record, and the render pipeline state it names (`None`: none). pub(super) type Command = (CommandRecord, Option); -/// An execution's probe at a host step that fans the pass's triangles out -/// ([`RenderExecution::probe`]): its secondary, ended, and the index of each command's draw among -/// the probe's draws, by its place among the commands that run, where it was probed; `None` where -/// its commands are drawn region by region. -type ProbeRun = Option<(vk::CommandBuffer, Vec>)>; +/// An execution's probe at a host step that fans the pass's triangles out, of all its parts +/// ([`DeferredPass::probe_parts`]): the index of each command's draw among the probe's draws, by +/// its place among the commands that run, where it was probed; `None` where its commands are drawn +/// region by region. +type ProbeRun = Option>>; + +/// The fewest commands a part of a host step's probe holds, and the most parts it is recorded in +/// ([`DeferredPass::probe_parts`]): each part is submitted once it is recorded, so the GPU runs it +/// while the host records the next, and the host waits once, after the last. +const PROBE_PART_COMMANDS: usize = 32; +const PROBE_PARTS: usize = 8; + +/// A part of a host step's probe as [`DeferredPass::submit_probe`] submitted it: its fence +/// (`None` where nothing was submitted), its recording, its command buffers taken out, and its GPU +/// time's slot. +type SubmittedPart = ( + Option, + RecordedSegment, + Option, +); + +/// The host step's commands of an execution, read once for its probe and its recording +/// ([`RenderExecution::step_commands`]): the commands, `None` where a record runs nothing for a +/// fault, the command they start at, and the faults the range and the records hold. +type StepCommands = (Vec>, u32, ReplayFaults); + +/// What [`RenderExecution::probe`] recorded of a part of an execution's commands. +struct ProbedPart { + /// The index the next part's draws take. + next: u32, + /// Its secondary, ended, where its commands recorded in one run of the instance's shape and + /// it probed a draw. + draws: Option, + /// The index of each command's draw among the probe's draws, by its place among the part's + /// commands that run, where it was probed. + slots: Vec>, + /// Its commands recorded in more than one run, or not in the instance's shape: the + /// execution's commands are drawn region by region. + apart: bool, + /// A command's barrier or a draw that writes memory stopped the probe: no later command of + /// the execution is probed. + stopped: bool, +} + +/// A host step's probe as its parts are submitted ([`DeferredPass::probe_parts`]): each part's +/// fence, its recording, its command buffers taken out, and its GPU time's slot; the parts; and +/// whether a part was left unsubmitted, the process exiting. +#[derive(Default)] +struct ProbeParts { + fenced: Vec, + recorded: Vec, + times: Vec, + parts: u64, + unsubmitted: bool, +} + +impl ProbeParts { + /// Take part `fenced`, recorded as `recorded`, timed by `times`: `None` where it was not + /// submitted. + fn add(&mut self, (fenced, recorded, times): SubmittedPart) { + match fenced { + Some(fenced) => self.fenced.push(fenced), + None => self.unsubmitted = true, + } + self.recorded.push(recorded); + self.times.extend(times); + self.parts += 1; + } +} /// What an execution's recording found: resident-set misses and faults, and the runs its draws /// that reach the tile threadgroup memory began, those its draws that reach interlocked storage @@ -2399,20 +2464,20 @@ impl RenderExecution { Ok((commands, start, ReplayFaults(faults.0 | written.0))) } - /// Record the probe of `commands`, the host step's ([`step_commands`](Self::step_commands)), - /// through an encoder of `core` into a secondary begun against the execution's instance, over - /// the pass's `storage`, with `residency`, the command buffer's, its draws taking indices of - /// `flags` from `from` (`render/fan_out.rs`): the core back, the index the next execution's - /// draws take, and the secondary, ended, with each command's index among the probe's draws, - /// where the commands recorded in one run of the instance's shape and probed a draw; `None` - /// where not, and every command is drawn region by region. + /// Record the probe of `commands`, a part of the host step's + /// ([`step_commands`](Self::step_commands)), through an encoder of `core` into a secondary + /// begun against the execution's instance, over the pass's `storage`, with `residency`, the + /// command buffer's, its draws taking indices of `flags` from `from` (`render/fan_out.rs`): + /// the core back, and what it recorded ([`ProbedPart`]): where its commands recorded in more + /// than one run, or not in the instance's shape, every command of the execution is drawn + /// region by region. fn probe( &self, core: EncoderCore, (command_buffer, residency): (&CommandBuffer, &Residency), commands: &[Option], (flags, from, storage): (vk::DescriptorBufferInfo, u32, PassStorage), - ) -> Result<(EncoderCore, u32, ProbeRun), Error> { + ) -> Result<(EncoderCore, ProbedPart), Error> { let snapshot = &self.snapshot; let layout = snapshot.layout.clone(); let large = BufferForms::Large; @@ -2438,6 +2503,8 @@ impl RenderExecution { unsafe { core.command_buffer().end_raw(run.draws) }.map_err(vulkan)?; } let core = EncoderCore::unboxed(core); + // A probe that stopped probes no later command (`FanOutRun::begin`). + let stopped = fan_run.as_ref().is_some_and(|run| run.begin(0).is_none()); let Some(FanOutRun::Probe(probe)) = fan_run else { return Err(internal("a probe's recording without its probe")); }; @@ -2447,10 +2514,23 @@ impl RenderExecution { && current.before.is_empty() && *current.shape == snapshot.shape && current.views == ViewSetup::default(); - match one && next > from { - true => Ok((core, next, Some((current.draws, slots)))), - false => Ok((core, from, None)), - } + let part = match one { + true => ProbedPart { + next, + draws: (next > from).then_some(current.draws), + slots, + apart: false, + stopped, + }, + false => ProbedPart { + next: from, + draws: None, + slots: Vec::new(), + apart: true, + stopped, + }, + }; + Ok((core, part)) } /// [`record`](Self::record) at a host step that fans the pass's triangles out, of the commands @@ -4324,51 +4404,60 @@ impl DeferredPass { .buffer(flags.raw()) .offset(flags.offset()) .range(flags.len()); - let mut core = EncoderCore::segment(command_buffer, false)?; - let mut next = 0; - for ((execution, read), home) in self.executions.iter().zip(&reads).zip(&homes) { - let (Some((commands, ..)), Some(_)) = (read, home) else { - probes.push(None); - continue; - }; - let at = (command_buffer, residency); - let probing = (info, next, self.storage.clone()); - let (back, after, probe) = execution.probe(core, at, commands, probing)?; - core = back; - next = after; - probes.push(probe); + // The probe in parts, each submitted once it is recorded; then one wait for them + // all, every part submitted waited for, a failed recording's too: what a part uses + // lives until it completed. + let part = commands.div_ceil(PROBE_PARTS).max(PROBE_PART_COMMANDS); + let mut parts = ProbeParts::default(); + let recorded = self.probe_parts( + command_buffer, + (residency, &reads, &homes), + (info, part), + (&mut probes, &mut parts), + ); + let started = Instant::now(); + let what = "the rasterization-rate map's fan-out probe"; + let completed = command_buffer.wait_fenced(&parts.fenced, what); + if parts.parts > 0 { + let counts = &device.shared().counts; + counts.rate_map_probe_waited(started.elapsed()); + counts.rate_map_probe_parts(parts.parts); } - if next > 0 { - let (recorded, completed) = - self.submit_probe(core, command_buffer, (&homes, &probes))?; - if completed { - let read = draw_words * u64::from(next); - let mut read_words = vec![0u32; read as usize]; - // SAFETY: the probe that wrote the flags completed, its writes made visible to - // the host by its last barrier; the words are writable and apart from the - // region. - unsafe { flags.copy_out(0, read_words.as_mut_ptr().cast(), 4 * read) }; - // What the probe found of each draw (`fan_out::Probed`). - let draws: Vec = (read_words.chunks(PROBE_DRAW_WORDS as usize)) - .map(Probed::of) - .collect(); - let flagged = draws.iter().filter(|draw| draw.flagged.is_some()).count(); - let triangles = draws.iter().map(|d| u64::from(d.flagged_triangles)); - 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); + // Their times read and counted, their submissions done. + drop(parts.times); + let next = recorded?; + let completed = completed? && !parts.unsubmitted; + if next > 0 && completed { + let read = draw_words * u64::from(next); + let mut read_words = vec![0u32; read as usize]; + // SAFETY: the probe's parts that wrote the flags completed, the writes of each made + // visible to the host by its last barrier; the words are writable and apart from + // the region. + unsafe { flags.copy_out(0, read_words.as_mut_ptr().cast(), 4 * read) }; + // What the probe found of each draw (`fan_out::Probed`). + let draws: Vec = (read_words.chunks(PROBE_DRAW_WORDS as usize)) + .map(Probed::of) + .collect(); + let flagged = draws.iter().filter(|draw| draw.flagged.is_some()).count(); + let triangles = draws.iter().map(|d| u64::from(d.flagged_triangles)); + 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(); } + // The parts' recordings, which ran: what they used and took, held with the pass's. + probed = parts.recorded.into_iter().reduce(|mut joined, part| { + joined.join(part); + joined + }); } let routes = (reads.into_iter().enumerate()) .map(|(at, read)| { let (commands, start, faults) = read?; - let slots = (probes.get(at).cloned().flatten()).map_or_else(Vec::new, |(_, s)| s); + let slots = probes.get(at).cloned().flatten().unwrap_or_default(); Some(Arc::new(FanOutRoutes { commands, start, @@ -4381,24 +4470,93 @@ impl DeferredPass { Ok((routes, probed)) } - /// Record the probes of the pass's executions, `probes` (each with its instance among - /// `homes`), into `core`, each instance's in a render pass instance of its instance's - /// framebuffer that loads and stores every attachment, then submit and wait for them - /// (`render/fan_out.rs`): the recording, its command buffers taken out, and whether they - /// completed. + /// Record the probes of the pass's executions' commands, `reads` (each execution in its + /// instance among `homes`), with `residency`, the command buffer's, their draws taking indices + /// of `flags` from 0, in parts of `part` commands, each part submitted once it is recorded + /// ([`submit_probe`](Self::submit_probe)) and added to `parts`, so the GPU runs it while the + /// host records the next; and push each execution's run onto `probes`. The index past the + /// last draw probed. A part holds the commands of one execution or of several, and its flags + /// lie where one recording of every command would put them, so the probe's words are the + /// same in any parts. + fn probe_parts( + &self, + command_buffer: &CommandBuffer, + (residency, reads, homes): (&Residency, &[Option], &[Option]), + (flags, part): (vk::DescriptorBufferInfo, usize), + (probes, parts): (&mut Vec, &mut ProbeParts), + ) -> Result { + let mut next = 0; + let mut core = EncoderCore::segment(command_buffer, false)?; + // The part's draws, each with its instance, and the commands it holds. + let mut draws: Vec<(usize, vk::CommandBuffer)> = Vec::new(); + let mut held = 0; + for ((execution, read), home) in self.executions.iter().zip(reads).zip(homes) { + let (Some((commands, ..)), Some(home)) = (read, home) else { + probes.push(None); + continue; + }; + let mut slots = Vec::new(); + let mut placed = 0; + let mut apart = false; + let mut at = 0; + while at < commands.len() { + let take = (part - held).min(commands.len() - at); + let these = &commands[at..at + take]; + let probing = (flags, next, self.storage.clone()); + let (back, probed) = + execution.probe(core, (command_buffer, residency), these, probing)?; + core = back; + if probed.apart { + apart = true; + break; + } + next = probed.next; + // Each command's draw by its place among the execution's commands that run. + slots.resize(placed, None); + slots.extend(probed.slots); + placed += these.iter().flatten().count(); + draws.extend(probed.draws.map(|draws| (*home, draws))); + at += take; + held += take; + if held >= part { + held = 0; + if !draws.is_empty() { + parts.add(self.submit_probe(core, command_buffer, &draws)?); + draws.clear(); + core = EncoderCore::segment(command_buffer, false)?; + } + } + if probed.stopped { + break; + } + } + probes.push((!apart).then_some(slots)); + } + if !draws.is_empty() { + parts.add(self.submit_probe(core, command_buffer, &draws)?); + } + Ok(next) + } + + /// Record a part of the probes of the pass's executions, `draws` (each secondary with its + /// instance), into `core`, each instance's in a render pass instance of its instance's + /// framebuffer that loads and stores every attachment, then submit it with a fence, for the + /// host to wait for later (`render/fan_out.rs`): its fence (`None` where the process is + /// exiting, and nothing was submitted), its recording, its command buffers taken out, and its + /// GPU time's slot, which counts that time once it is let go of after the wait. fn submit_probe( &self, mut core: EncoderCore, command_buffer: &CommandBuffer, - (homes, probes): (&[Option], &[ProbeRun]), - ) -> Result<(RecordedSegment, bool), Error> { + draws: &[(usize, vk::CommandBuffer)], + ) -> Result { let device = command_buffer.device(); let mut passes = Vec::new(); let mut runs = Vec::new(); for (index, instance) in self.instances.iter().enumerate() { - let draws: Vec = (homes.iter().zip(probes)) - .filter(|(home, _)| **home == Some(index)) - .filter_map(|(_, probe)| probe.as_ref().map(|(draws, _)| *draws)) + let draws: Vec = (draws.iter()) + .filter(|(home, _)| *home == index) + .map(|(_, draws)| *draws) .collect(); if draws.is_empty() { continue; @@ -4445,20 +4603,15 @@ impl DeferredPass { }); core.retain(passes); let mut recorded = core.end_segment()?; - // The host's wait for it, counted. - let started = Instant::now(); // SAFETY: the segment's command buffers, of the command buffer's pool, ended and // recorded for this submission alone; what they use the segment holds, which the pass's - // joins. + // joins, and the host waits for the submission before the step ends. let what = "the rasterization-rate map's fan-out probe"; - let completed = unsafe { command_buffer.submit_waited(&recorded.raws, what) }?; - (device.shared().counts).rate_map_probe_waited(started.elapsed()); - // Its time read and counted, its submission done. - drop(times); + let fenced = unsafe { command_buffer.submit_fenced(&recorded.raws, what) }?; recorded.raws.clear(); recorded.piece_ends.clear(); recorded.executions.clear(); - Ok((recorded, completed)) + Ok((fenced, recorded, times)) } /// Whether the host step that records it fans its triangles out, where its executions' draws diff --git a/crates/metal2vulkan-runtime/src/tests/rate_mapped_fan_out.rs b/crates/metal2vulkan-runtime/src/tests/rate_mapped_fan_out.rs index 9b0ee7b77..df5db12b9 100644 --- a/crates/metal2vulkan-runtime/src/tests/rate_mapped_fan_out.rs +++ b/crates/metal2vulkan-runtime/src/tests/rate_mapped_fan_out.rs @@ -48,6 +48,10 @@ use std::path::Path; /// them, the triangles they replace, in blocks far apart. const GRID: u32 = 16; const COMMANDS: u32 = 8; +/// The commands of a frame whose probe is submitted in parts (`render/executions.rs`, +/// `DeferredPass::probe_parts`: at least 32 commands a part): the eight's pattern nine times, in +/// parts of 32, 32 and 8 commands. +const PARTED: u32 = 9 * COMMANDS; const FLAT: u32 = 0; const LARGE: u32 = 3; const MEDIUM: u32 = 5; @@ -80,16 +84,18 @@ struct Workload { colors: Buffer, icb: IndirectCommandBuffer, map: RasterizationRateMap, + /// Its commands, each drawing as its place in the eight's pattern ([`draw_of`]). + commands: u32, } -/// What a command draws: its pipeline, its positions, its indices (`None`: none, its vertices in -/// order) and their count. +/// What a command draws, by its place in the eight's pattern: its pipeline, its positions, its +/// indices (`None`: none, its vertices in order) and their count. fn draw_of( workload: &Workload, command: u32, ) -> (&RenderPipelineState, &Buffer, Option<&Buffer>, u32) { let (plain, behind) = (&workload.pipeline, &workload.behind_pipeline); - match command { + match command % COMMANDS { LARGE => (plain, &workload.large, Some(&workload.large_indices), 3), MEDIUM => (plain, &workload.large, Some(&workload.medium_indices), 3), BEHIND => (behind, &workload.behind, Some(&workload.large_indices), 3), @@ -105,7 +111,8 @@ fn draw_of( } impl Workload { - fn new(device: Device) -> Workload { + /// The workload of `commands` commands on `device`. + fn new(device: Device, commands: u32) -> Workload { let renders = library(&device, "engine/tob_renders.ll"); let function = |name| { StageSource::Function( @@ -203,10 +210,10 @@ impl Workload { let indices = |at: [u32; 3]| -> Vec { at.iter().flat_map(|i| i.to_le_bytes()).collect() }; let (large_indices, medium_indices) = (indices([0, 1, 2]), indices([3, 4, 5])); - // Each command's colour at half alpha, 256 bytes apart. - let colors: Vec = (0..COMMANDS) + // Each command's colour at half alpha, by its place in the pattern, 256 bytes apart. + let colors: Vec = (0..commands) .flat_map(|k| { - let k = k as f32; + let k = (k % COMMANDS) as f32; let mut slot = [k / 8.0, 1.0 - k / 8.0, 0.25 + k / 16.0, 0.5] .map(f32::to_le_bytes) .concat(); @@ -223,7 +230,7 @@ impl Workload { icb.max_vertex_buffer_bind_count = 1; icb.max_fragment_buffer_bind_count = 1; let icb = device - .new_indirect_command_buffer(&icb, u64::from(COMMANDS), ResourceOptions::shared()) + .new_indirect_command_buffer(&icb, u64::from(commands), ResourceOptions::shared()) .unwrap(); let mut map = RateMapDescriptor::new([SCREEN, SCREEN]); map.layers = vec![RateMapLayerDescriptor::new( @@ -247,8 +254,9 @@ impl Workload { icb, map, device, + commands, }; - for k in 0..COMMANDS { + for k in 0..commands { let command = workload .icb .indirect_render_command_at(u64::from(k)) @@ -303,10 +311,10 @@ impl Workload { encoder.set_render_pipeline_state(&self.pipeline).unwrap(); match executed { true => encoder - .execute_commands_in_buffer(&self.icb, 0..u64::from(COMMANDS)) + .execute_commands_in_buffer(&self.icb, 0..u64::from(self.commands)) .unwrap(), false => { - for k in 0..COMMANDS { + for k in 0..self.commands { let (pipeline, positions, indices, count) = draw_of(self, k); encoder.set_render_pipeline_state(pipeline).unwrap(); encoder.set_vertex_buffer(Some(positions), 0, 0).unwrap(); @@ -403,7 +411,10 @@ fn differing<'a>(a: &'a [u8], b: &'a [u8]) -> (usize, Option<(usize, &'a [u8], & #[test] fn a_host_step_fans_out_the_commands_the_probe_does_not_flag() { let scratch = Scratch::new("rate-mapped-fan-out"); - let workload = Workload::new(device_under(&scratch.0, RateMapRegionPolicy::FanOut)); + let workload = Workload::new( + device_under(&scratch.0, RateMapRegionPolicy::FanOut), + COMMANDS, + ); let (drawn, before, after) = workload.frame(false); assert_eq!(fan_counts(&before, &after), [0; 4], "the encoder's draws"); let encoder_copies = copy_counts(&before, &after); @@ -419,13 +430,15 @@ fn a_host_step_fans_out_the_commands_the_probe_does_not_flag() { let by_regions = after.rate_map_parted_region_triangles - before.rate_map_parted_region_triangles; let wait = after.rate_map_probe_wait_nanos - before.rate_map_probe_wait_nanos; + let parts = after.rate_map_probe_parts - before.rate_map_probe_parts; 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; \ + "RATE-MAP-FAN-OUT counts {counts:?} probe_gpu_nanos {probe_nanos}, waited {wait} ns in \ + {parts} parts; \ {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} \ @@ -450,6 +463,10 @@ fn a_host_step_fans_out_the_commands_the_probe_does_not_flag() { "the runs drawn through the region-copy variant" ); assert_eq!(counts, [1, 4, u64::from(COMMANDS - 4), 4]); + assert_eq!( + parts, 1, + "the probe's parts: its commands are fewer than a part holds" + ); assert_eq!(tables, 2, "region tables uploaded"); assert!( ready + waited >= 3, @@ -472,7 +489,7 @@ fn a_host_step_fans_out_the_commands_the_probe_does_not_flag() { assert!(wait > 0, "the host's wait for the probe"); } false => { - assert_eq!(counts, [0; 4]); + assert_eq!((counts, parts), ([0; 4], 0)); assert_eq!( [encoder_copies, copies], [[0; 2]; 2], @@ -492,6 +509,47 @@ fn a_host_step_fans_out_the_commands_the_probe_does_not_flag() { ); } +/// A host step of more commands than a part of its probe holds probes them in parts +/// (`render/executions.rs`, `DeferredPass::probe_parts`): [`PARTED`] commands in three parts, +/// each submitted once the host recorded it, its GPU time counted, and one wait. The probe is one, +/// and it flags, fans out and draws in parts the eight's pattern's draws, each time it comes: its +/// words are those one part would write. The pixels are the encoder's. +#[test] +fn a_host_step_probes_many_commands_in_parts() { + let scratch = Scratch::new("rate-mapped-fan-out-parts"); + let device = device_under(&scratch.0, RateMapRegionPolicy::FanOut); + let workload = Workload::new(device, PARTED); + let (drawn, _, _) = workload.frame(false); + let (fanned, before, after) = workload.frame(true); + let counts = fan_counts(&before, &after); + let parts = after.rate_map_probe_parts - before.rate_map_probe_parts; + let wait = after.rate_map_probe_wait_nanos - before.rate_map_probe_wait_nanos; + let probe_nanos = after.rate_map_probe_gpu_nanos - before.rate_map_probe_gpu_nanos; + let submitted = after.queue_submissions - before.queue_submissions; + eprintln!( + "RATE-MAP-FAN-OUT-PARTS counts {counts:?} in {parts} parts, probe_gpu_nanos \ + {probe_nanos}, waited {wait} ns; {submitted} queue submissions" + ); + match fans_out(&workload.device) { + true => { + let flagged = u64::from(PARTED / COMMANDS * 4); + assert_eq!(counts, [1, flagged, u64::from(PARTED) - flagged, flagged]); + assert_eq!(parts, 3, "the probe's parts of 32, 32 and 8 commands"); + assert!( + submitted >= parts, + "{submitted} submissions for {parts} parts" + ); + assert!(wait > 0, "the host's wait for the probe"); + } + false => assert_eq!((counts, parts), ([0; 4], 0)), + } + let (differ, first) = differing(&drawn, &fanned); + assert_eq!( + differ, 0, + "texels the fanned-out execution draws otherwise, the first {first:?}" + ); +} + /// With the encoder trail on (`encoder_trail.rs`), the host step notes the states its commands /// name and its probe is a waited submission the trail watches; the execution is fanned out as /// without, to the same pixels. @@ -501,7 +559,7 @@ fn the_encoder_trail_fans_out_the_same_pixels() { let mut options = options(&scratch.0); options.policy.rate_map_regions = RateMapRegionPolicy::FanOut; options.encoder_trail = true; - let workload = Workload::new(Device::system_default_with(&options).unwrap()); + let workload = Workload::new(Device::system_default_with(&options).unwrap(), COMMANDS); assert!(workload.device.shared().encoder_trail); let (drawn, _, _) = workload.frame(false); let (fanned, before, after) = workload.frame(true); @@ -524,7 +582,10 @@ fn the_encoder_trail_fans_out_the_same_pixels() { #[test] fn exact_regions_draw_every_command_region_by_region() { let scratch = Scratch::new("rate-mapped-fan-out-exact"); - let workload = Workload::new(device_under(&scratch.0, RateMapRegionPolicy::Exact)); + let workload = Workload::new( + device_under(&scratch.0, RateMapRegionPolicy::Exact), + COMMANDS, + ); let (drawn, before, after) = workload.frame(false); assert_eq!(copy_counts(&before, &after), [0; 2], "the encoder's draws"); let (exact, before, after) = workload.frame(true); diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index 96b0a57c3..8bfb1ba0b 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -251,6 +251,7 @@ pub(crate) struct Counters { rate_map_probes: AtomicU64, rate_map_probe_gpu_nanos: AtomicU64, rate_map_probe_wait_nanos: AtomicU64, + rate_map_probe_parts: AtomicU64, rate_map_flagged_draws: AtomicU64, rate_map_flagged_triangles: AtomicU64, rate_map_fanned_draws: AtomicU64, @@ -3318,13 +3319,20 @@ impl Counters { (self.rate_map_probe_gpu_nanos).fetch_add(nanos, Ordering::Relaxed); } - /// A host step waited `took` on the host's clock for its probe, from its submission until - /// the host saw it complete (`rate_mapped_pass.rs`, **Fan-out**). + /// A host step waited `took` on the host's clock for its probe, from its last part's + /// submission until the host saw every part complete (`rate_mapped_pass.rs`, **Fan-out**; + /// `render/executions.rs`, `DeferredPass::probe_parts`). pub(crate) fn rate_map_probe_waited(&self, took: std::time::Duration) { let nanos = u64::try_from(took.as_nanos()).unwrap_or(u64::MAX); (self.rate_map_probe_wait_nanos).fetch_add(nanos, Ordering::Relaxed); } + /// A host step's probe was submitted in `parts` parts (`render/executions.rs`, + /// `DeferredPass::probe_parts`). + pub(crate) fn rate_map_probe_parts(&self, parts: u64) { + (self.rate_map_probe_parts).fetch_add(parts, Ordering::Relaxed); + } + /// A draw the probe flagged was drawn in parts (`render/fan_out.rs`, **Parts**), of which /// `by_regions` triangles region by region, in `runs` parts. pub(crate) fn rate_map_drawn_in_parts(&self, by_regions: u64, runs: u64) { @@ -7985,17 +7993,25 @@ pub struct WorkCounts { pub rate_map_piece_gpu_nanos_most: u64, /// Probes host steps submitted and waited for before rate-mapped passes, each of the draws of /// a pass's executed commands, to fan the draws' triangles out to the map's regions - /// (`rate_mapped_pass.rs`, **Fan-out**; `RateMapRegionPolicy::FanOut`). + /// (`rate_mapped_pass.rs`, **Fan-out**; `RateMapRegionPolicy::FanOut`): one a host step, + /// however many parts it was submitted in + /// ([`rate_map_probe_parts`](Self::rate_map_probe_parts)). pub rate_map_probes: u64, - /// Their GPU time, in nanoseconds, read from timestamps written around each (none where the - /// device writes no timestamps or its driver's timestamps wait for every queue's). + /// Their GPU time, in nanoseconds, read from timestamps written around each part (none where + /// the device writes no timestamps or its driver's timestamps wait for every queue's). pub rate_map_probe_gpu_nanos: u64, - /// The host's wait for them, in nanoseconds on the host's clock, from each one's submission - /// until the host saw it complete: their GPU time - /// ([`rate_map_probe_gpu_nanos`](Self::rate_map_probe_gpu_nanos)), the submission's way to - /// the device and the completion's back, and the queue's work ahead of them. Part of + /// The host's wait for them, in nanoseconds on the host's clock, from each one's last part's + /// submission until the host saw every part complete: what is left then of their GPU time + /// ([`rate_map_probe_gpu_nanos`](Self::rate_map_probe_gpu_nanos)), after the host recorded + /// the parts while the GPU ran those before, the submission's way to the device and the + /// completion's back, and the queue's work ahead of them. Part of /// [`host_step_nanos`](Self::host_step_nanos). pub rate_map_probe_wait_nanos: u64, + /// The parts those probes were submitted in, each a `VkSubmitInfo` of its own with a fence and + /// a render pass instance for each instance whose commands it probes, submitted once the host + /// recorded it, so the GPU runs it while the host records the next (`render/executions.rs`, + /// `DeferredPass::probe_parts`: at least 32 commands a part, at most 8 parts a probe). + pub rate_map_probe_parts: u64, /// The draws they probed that they flagged: a triangle crosses `w = 0` or touches more /// regions than the fan-out's copies. Each is drawn in parts /// ([`rate_map_parted_draws`](Self::rate_map_parted_draws)), or region by region whole where @@ -11562,6 +11578,7 @@ impl Device { rate_map_probes: counters.rate_map_probes.load(Ordering::Relaxed), rate_map_probe_gpu_nanos: counters.rate_map_probe_gpu_nanos.load(Ordering::Relaxed), rate_map_probe_wait_nanos: (counters.rate_map_probe_wait_nanos).load(Ordering::Relaxed), + rate_map_probe_parts: counters.rate_map_probe_parts.load(Ordering::Relaxed), rate_map_flagged_draws: counters.rate_map_flagged_draws.load(Ordering::Relaxed), rate_map_flagged_triangles: (counters.rate_map_flagged_triangles) .load(Ordering::Relaxed), diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index 644ea01f0..cd7416d77 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 522; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 2313; +pub const RUNTIME_VERSION: u32 = 2314; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index a538c3375..2bb5108b0 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -3386,6 +3386,7 @@ field metal2vulkan-runtime::WorkCounts.rate_map_piece_gpu_nanos_most pub rate_ma field metal2vulkan-runtime::WorkCounts.rate_map_pieces pub rate_map_pieces: u64 field metal2vulkan-runtime::WorkCounts.rate_map_pieces_timed pub rate_map_pieces_timed: u64 field metal2vulkan-runtime::WorkCounts.rate_map_probe_gpu_nanos pub rate_map_probe_gpu_nanos: u64 +field metal2vulkan-runtime::WorkCounts.rate_map_probe_parts pub rate_map_probe_parts: u64 field metal2vulkan-runtime::WorkCounts.rate_map_probe_wait_nanos pub rate_map_probe_wait_nanos: u64 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 diff --git a/docs/API.md b/docs/API.md index 08acb04d4..a88450c4b 100644 --- a/docs/API.md +++ b/docs/API.md @@ -6178,9 +6178,12 @@ each item named states the rule in full. position and a depth `Equal` test across them holds where both pipelines compute the position alike; a draw the variant does not take is drawn through each region's viewport (`docs/FAST-PATHS.md`, known gaps). The - probe costs the host step a submission it waits for before the pass, which runs each probed - draw's vertex function and geometry stage once and shades nothing (`WorkCounts::rate_map_probes`, - `rate_map_probe_gpu_nanos`, the host's wait `rate_map_probe_wait_nanos`); a fanned-out draw + probe costs the host step submissions it waits for before the pass, which run each probed + draw's vertex function and geometry stage once and shade nothing: its parts, of at least 32 + commands and at most 8 a probe, each submitted once the host recorded it, so the GPU runs one + while the host records the next, and one wait after the last (`WorkCounts::rate_map_probes`, + `rate_map_probe_parts`, `rate_map_probe_gpu_nanos`, the host's wait + `rate_map_probe_wait_nanos`); a fanned-out draw runs its vertex function once where region by region it runs once per region (`rate_mapped_pass.rs`, **Fan-out**). - **A pass over a map of a zero screen extent is refused**, `RegionError::RegionExtent` on that