Device tests at pin 93b: staged records, queue plans, readers' own counts, unmade shadows
What (lane devlegs, the pin 93b device legs' test-side fixes):
- 308a8fe305 Device tests weigh readers by their own counts, bound command buffers by the peak seen, and expect staged records in generated executions
- 6951cb9635 Host-step notice checks of queue_order expect staged records too, through one helper
- 32d3d4eed7 Lane notice checks expect staged indirect records wherever the device staged them
- dcd14d9bb3 Lane tests that make a command queue per dispatch or per program take the queue plan
- ba649ccc4e The parity harness's runtime device takes its queue plan
- 7449dda069 shader_stencil's notice checks start from shared_kinds, staged records with it
- 6437e8482c fresh_pages: a shadow left unmade is announced as a reach makes it
- e0163a7a94 compute_inherited_buffers' runs share one command queue, whose kept barriers the first records
Why: at pin 93b (400efe7932) on lavapipe, the 780M, the XTX, the 3090 and
the 5080, device tests failed on expectations the runtime had moved past:
discrete devices stage indirect-command records (StagedIndirectRecords,
RUNTIME 2294), command queues take the device's queue plan, readers are
weighed by their own counts, begin-ahead primaries (spares) move begin
counts, NVIDIA's queue plan gives each command queue its own VkQueue
(a test's runs now share one queue), and since RUNTIME 2309 a shadow left unmade is made and announced
at the first reach. No runtime change: render/coverage.rs gains only a
cfg(test) constructor of ReaderKey for the device tests.
How verified: the lane's lavapipe runs of the touched modules; its check at
e0163a7a94 (build, clippy plain and cpu_icd, the touched modules on
lavapipe) and the device reruns run after landing.
Test-only: no RUNTIME bump.
This commit is contained in:
1 parent
c5b49b39d1
commit
c2154d174f
11 files changed
+231
-114
No files matched your search
@@ -71,6 +71,16 @@ pub(crate) struct ReaderKey {
|
||||
ordinal: u32,
|
||||
}
|
||||
|
||||
impl ReaderKey {
|
||||
/// The identity of the reader at `ordinal` among the readers of a texture in a pass of the
|
||||
/// state at `state` (`GraphicsState::address`): for the crate's device tests, which read its
|
||||
/// count (`Texture::learned_coverage`).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn of(state: usize, ordinal: u32) -> ReaderKey {
|
||||
ReaderKey { state, ordinal }
|
||||
}
|
||||
}
|
||||
|
||||
/// The counts a texture learned of its readers (`Texture::learned_coverage`), the latest of
|
||||
/// each, [`LEARNED`] at most.
|
||||
#[derive(Debug, Default)]
|
||||
|
||||
@@ -33,10 +33,11 @@
|
||||
//! counted (`host_texture_shadows_refused_pitch` or `_image`): MoltenVK lays a linear image's
|
||||
//! rows at a pitch of its own and enables no `VK_EXT_image_drm_format_modifier`, so on the M3 Max
|
||||
//! the texture at 512 bytes a row is a shadow and the one at its own pitch an image in place.
|
||||
//! Every shadow is announced (`shadowed-texture`) with its one cause counted, and an image in
|
||||
//! place neither. Either way a blit out of it reads the bytes the CPU wrote, and a render pass's
|
||||
//! clear through it reaches them once the command buffer completed, the bytes between its rows
|
||||
//! kept.
|
||||
//! Every shadow has its one cause counted, and is announced (`shadowed-texture`) as it is made:
|
||||
//! one whose rows lie in place (a refused pitch or image) at the first reach of its image
|
||||
//! (`texture/lazy_shadow.rs`). An image in place has neither. Either way a blit out of it reads
|
||||
//! the bytes the CPU wrote, and a render pass's clear through it reaches them once the command
|
||||
//! buffer completed, the bytes between its rows kept.
|
||||
//!
|
||||
//! Device tests: compiled only under the GPU safety cfgs (`m2v_gpu`, `m2v_cpu_icd`).
|
||||
|
||||
@@ -460,8 +461,11 @@ fn a_texture_over_a_long_buffer_is_its_bytes(
|
||||
after.host_textures_in_place - before.host_textures_in_place,
|
||||
u64::from(in_place)
|
||||
);
|
||||
// A shadow is announced, with its one cause counted; an image in place is neither.
|
||||
assert_eq!(announced, u64::from(shadow), "a shadow is announced");
|
||||
// A shadow has its one cause counted (below), and is announced as it is made: one left
|
||||
// unmade, its rows in place, as a reach makes it (`texture/lazy_shadow.rs`), which none
|
||||
// does here. An image in place has neither.
|
||||
let made = after.shadowed_textures - before.shadowed_textures;
|
||||
assert_eq!(announced, made, "a shadow made is announced");
|
||||
let one_cause: &[&str] = match (policy, in_place, renders_in_place) {
|
||||
(HostPageTexturePolicy::Shadow, ..) => {
|
||||
assert!(shadow, "a shadow under Shadow");
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
//! The plane is large enough that the area rule takes the snapshot through its whole scissor,
|
||||
//! as it weighs a leading reader even over a buffer's bytes (`RenderLowering::weigh_snapshot`).
|
||||
//! On a device that measures readers (`occlusionQueryPrecise`, queries reset on the host), a
|
||||
//! reader's pass after one that measured it is weighed by what it covered there
|
||||
//! (`render/coverage.rs`; a pass whose readers record once the pool made their pipeline measures
|
||||
//! none): the reader of the whole plane then splits with the copy, and the reader of a small
|
||||
//! square, through the same scissor, keeps its leading snapshot.
|
||||
//! reader whose identity holds a count from a pass that measured it (`Texture::learned_coverage`;
|
||||
//! a reader recorded once the pool made its pipeline is not measured) is weighed by what it
|
||||
//! covered there (`render/coverage.rs`): the reader of the whole plane then splits with the copy,
|
||||
//! and the reader of a small square, through the same scissor, keeps its leading snapshot.
|
||||
//!
|
||||
//! The same passes run again with the leading snapshots withheld too
|
||||
//! (`DeviceShared::leading_snapshots_withheld`): each reader then splits the pass and reads the
|
||||
@@ -30,6 +30,8 @@
|
||||
use super::blit_holds::{device, Scratch, WAIT};
|
||||
use super::encoder_holds::{bytes_of, library};
|
||||
use crate::framebuffer_fetch::through_storage;
|
||||
use crate::pipeline::RenderStateKind;
|
||||
use crate::render::coverage::ReaderKey;
|
||||
use crate::{
|
||||
Buffer, CommandQueue, Device, IoSurfacePlane, LoadAction, PipelineOptions,
|
||||
RenderPassDescriptor, RenderPipelineState, ResourceOptions, ScissorRect, StoreAction, Texture,
|
||||
@@ -61,6 +63,9 @@ const DRAWS: [(u8, std::ops::Range<u64>, [f32; 4]); 2] = [
|
||||
(0x55, 256..768, [-0.5, -0.5, -0.375, -0.375]),
|
||||
];
|
||||
|
||||
/// The pixels each reader of [`DRAWS`] covers: the whole plane, and the square.
|
||||
const COVERED: [u64; 2] = [WIDTH * HEIGHT, 64 * 64];
|
||||
|
||||
/// The rows `rows` of the plane, every column, as a scissor.
|
||||
const fn rows(rows: std::ops::Range<u64>) -> ScissorRect {
|
||||
ScissorRect {
|
||||
@@ -223,6 +228,15 @@ fn leads(device: &Device) -> bool {
|
||||
device.shared().color_write_masks.is_some() && through_storage(profile) && stores_none
|
||||
}
|
||||
|
||||
/// The identities of the readers of [`DRAWS`], in their order, all of the state `read`: its first
|
||||
/// and second readers of the plane in a pass (`render/coverage.rs`'s `ReaderKey`).
|
||||
fn reader_keys(read: &RenderPipelineState) -> [ReaderKey; 2] {
|
||||
let RenderStateKind::Graphics(state) = read.kind() else {
|
||||
panic!("a tile state of a render descriptor");
|
||||
};
|
||||
[0, 1].map(|ordinal| ReaderKey::of(state.address(), ordinal))
|
||||
}
|
||||
|
||||
/// Whether `device` measures readers (`render/coverage.rs`: `occlusionQueryPrecise`, and queries
|
||||
/// reset on the host).
|
||||
fn measures(device: &Device) -> bool {
|
||||
@@ -234,9 +248,11 @@ fn measures(device: &Device) -> bool {
|
||||
/// linear alias of the bytes without feedback loop usage, each pass after a fill of the bytes:
|
||||
/// with leading snapshots where the device takes them, then with them withheld. The passes leave
|
||||
/// Metal's bytes under both; the first run's readers take leading snapshots (no split, no texel
|
||||
/// copied in) where the device leads, but for the whole plane's reader in a pass after one that
|
||||
/// measured both readers, which splits by what it covered; every other reader splits the pass.
|
||||
/// A device that leads and measures readers weighs a pass's readers so at least once.
|
||||
/// copied in) where the device leads, but for the whole plane's reader once a pass measured it,
|
||||
/// which splits by what it covered; every other reader splits the pass. Each reader is weighed by
|
||||
/// the count its identity holds as its pass records, where it holds one, the pixels it covers;
|
||||
/// the others by the area rule. A device that leads and measures readers weighs a pass's readers
|
||||
/// so at least once.
|
||||
#[test]
|
||||
fn readers_through_leading_snapshots_leave_the_split_s_bytes() {
|
||||
let scratch = Scratch::new("leading-snapshots");
|
||||
@@ -257,13 +273,25 @@ fn readers_through_leading_snapshots_leave_the_split_s_bytes() {
|
||||
"the plane's image aliases its bytes (in-place checks settled: {settled})"
|
||||
);
|
||||
let (leads, measures) = (leads(&device), measures(&device));
|
||||
let keys = reader_keys(&tools.read);
|
||||
for withheld in [false, true] {
|
||||
(device.shared().leading_snapshots_withheld).store(withheld, Ordering::Relaxed);
|
||||
// Three times: the first pass's readers may record once the pool made their pipelines,
|
||||
// unmeasured (`render/coverage.rs`), the later ones' at once; a pass after one that
|
||||
// measured both readers weighs them by what they covered.
|
||||
let (mut measured, mut weighed) = (false, false);
|
||||
// Three times: a reader of the first pass may record once the pool made its pipeline,
|
||||
// unmeasured (`render/coverage.rs`), the later ones at once; a reader whose identity holds
|
||||
// a count, from the pass that last measured it, is weighed by it. The counts of a pass are
|
||||
// kept as its command buffer completes, before the later command buffers of its queue
|
||||
// (`command_buffer/mod.rs`): the read-back's, which the bytes waited for.
|
||||
let mut weighed = false;
|
||||
for round in 0..3 {
|
||||
let counted = keys.map(|key| texture.learned_coverage(key));
|
||||
for (reader, count) in counted.iter().enumerate() {
|
||||
let want = count.map(|_| COVERED[reader]);
|
||||
assert_eq!(*count, want, "reader {reader}'s count (round {round})");
|
||||
}
|
||||
assert!(
|
||||
measures || counted == [None; 2],
|
||||
"a device that measures no reader holds a count (round {round})"
|
||||
);
|
||||
tools.fill(&buffer, BEFORE);
|
||||
let counts = tools.pass(&texture);
|
||||
let pooled = counts.1.pipelines_pooled - counts.0.pipelines_pooled;
|
||||
@@ -271,7 +299,8 @@ fn readers_through_leading_snapshots_leave_the_split_s_bytes() {
|
||||
let took = took(counts);
|
||||
eprintln!(
|
||||
"LEADING-SNAPSHOTS {}: leads {leads}, measures {measures}, withheld {withheld}, \
|
||||
round {round}: {took:?}, pipelines pooled {pooled}, coverage queries {queries}",
|
||||
round {round}: the readers' counts held {counted:?}, {took:?}, pipelines pooled \
|
||||
{pooled}, coverage queries {queries}",
|
||||
device.name()
|
||||
);
|
||||
let left = tools.bytes(&buffer);
|
||||
@@ -280,12 +309,15 @@ fn readers_through_leading_snapshots_leave_the_split_s_bytes() {
|
||||
differs, None,
|
||||
"the first byte the readers left otherwise (withheld {withheld}, round {round})"
|
||||
);
|
||||
// The readers that split: none, or the whole plane's once it was measured (all of its
|
||||
// pixels, beyond the area rule's bound: the small square's are within it), or both.
|
||||
let (leading, by_coverage, shares) = match (leads && !withheld, measured) {
|
||||
(true, true) => (1, 2, [1, 0, 1]),
|
||||
(true, false) => (2, 0, [0; 3]),
|
||||
(false, _) => (0, 0, [0; 3]),
|
||||
// The readers that split: none, or the whole plane's where its identity held a count
|
||||
// (all of its pixels, beyond the area rule's bound: the small square's are within it),
|
||||
// or both.
|
||||
let (leading, by_coverage, shares) = match leads && !withheld {
|
||||
true => {
|
||||
let [plane, square] = counted.map(|count| u64::from(count.is_some()));
|
||||
(2 - plane, plane + square, [square, 0, plane])
|
||||
}
|
||||
false => (0, 0, [0; 3]),
|
||||
};
|
||||
let form = Took {
|
||||
leading,
|
||||
@@ -304,7 +336,13 @@ fn readers_through_leading_snapshots_leave_the_split_s_bytes() {
|
||||
"the splits' copies moved texels, and only theirs (round {round})"
|
||||
);
|
||||
weighed |= by_coverage > 0;
|
||||
measured = queries == 2;
|
||||
if queries == 2 {
|
||||
assert!(
|
||||
keys.iter()
|
||||
.all(|&key| texture.learned_coverage(key).is_some()),
|
||||
"a pass measured both readers, yet an identity holds no count (round {round})"
|
||||
);
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
weighed,
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
//! compute encoders that each wait for a fence the one before updated, so none records on in the
|
||||
//! one before's `VkCommandBuffer` (`encoder_fold.rs`) and the scheduler records a command buffer
|
||||
//! of barriers before each, many in flight, of a count of encoders that varies from one to the
|
||||
//! next (`spares.rs`): a guest's command buffers split into parts. Once each count ran with as
|
||||
//! many in flight, the spares hold what they take: the command buffers made stay flat, and they
|
||||
//! hold about what is in use at once; once the load falls, they shed down to it.
|
||||
//! next (`spares.rs`): a guest's command buffers split into parts. The device makes command
|
||||
//! buffers only as far as the most the load had in use at once needs, with what the pools out
|
||||
//! of the spares may hold unused: once warm, more are made only for a later, larger peak, and the
|
||||
//! spares free none and hold about what is in use at once; once the load falls, they shed down to
|
||||
//! it.
|
||||
//!
|
||||
//! Device tests: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`,
|
||||
//! `m2v_cpu_icd`). The kernel is `scale_and_offset` of the owned fixture
|
||||
@@ -17,6 +19,7 @@ use crate::{
|
||||
Buffer, CommandBuffer, CommandQueue, ComputePipelineState, Device, PipelineOptions,
|
||||
ResourceOptions, Size,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::mpsc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -89,36 +92,49 @@ impl Load {
|
||||
|
||||
/// `count` command buffers of `encoders(index)` encoders each, at most `in_flight` of them
|
||||
/// committed whose pools are not yet given back, then every one's given back, and the frees
|
||||
/// their give-backs posted. A completed handler runs once its command buffer's pools went back
|
||||
/// to the spares (`command_buffer/mod.rs`), so each is counted by its handler: a command
|
||||
/// buffer's completion seen by a waiter may come before its give-back.
|
||||
fn run(&self, count: usize, in_flight: usize, encoders: impl Fn(usize) -> usize) {
|
||||
/// their give-backs posted; and the most they held at once ([`Peak`]). A completed handler
|
||||
/// runs once its command buffer's pools went back to the spares (`command_buffer/mod.rs`), so
|
||||
/// each is counted by its handler: a command buffer's completion seen by a waiter may come
|
||||
/// before its give-back. As each command buffer is encoded, those committed whose handler had
|
||||
/// not run as it began, with it, hold at least what is in use until the next begins: those
|
||||
/// before it only complete meanwhile.
|
||||
fn run(&self, count: usize, in_flight: usize, encoders: impl Fn(usize) -> usize) -> Peak {
|
||||
let (given, back) = mpsc::channel();
|
||||
let mut out = 0;
|
||||
let mut out = BTreeMap::new();
|
||||
let mut peak = Peak::default();
|
||||
for index in 0..count {
|
||||
let command_buffer = self.encoded(encoders(index));
|
||||
while let Ok(done) = back.try_recv() {
|
||||
out.remove(&done);
|
||||
}
|
||||
let encoders = encoders(index);
|
||||
let before = out.values().copied().map(primaries).sum::<usize>();
|
||||
peak = peak.max(Peak {
|
||||
alive: out.len() + 1,
|
||||
primaries: before + primaries(encoders),
|
||||
});
|
||||
let command_buffer = self.encoded(encoders);
|
||||
let given = given.clone();
|
||||
(command_buffer.add_completed_handler(Box::new(move |_: &CommandBuffer| {
|
||||
let _ = given.send(());
|
||||
let _ = given.send(index);
|
||||
})))
|
||||
.unwrap();
|
||||
command_buffer.commit().unwrap();
|
||||
out += 1;
|
||||
while out > in_flight {
|
||||
back.recv_timeout(WAIT).unwrap();
|
||||
out -= 1;
|
||||
out.insert(index, encoders);
|
||||
while out.len() > in_flight {
|
||||
out.remove(&back.recv_timeout(WAIT).unwrap());
|
||||
}
|
||||
}
|
||||
for _ in 0..out {
|
||||
back.recv_timeout(WAIT).unwrap();
|
||||
while !out.is_empty() {
|
||||
out.remove(&back.recv_timeout(WAIT).unwrap());
|
||||
}
|
||||
self.device.shared().frees.drain();
|
||||
peak
|
||||
}
|
||||
|
||||
/// A round of [`ROUND`] command buffers of [`PARTS`] encoders in turn, [`IN_FLIGHT`] in
|
||||
/// flight.
|
||||
fn round(&self) {
|
||||
self.run(ROUND, IN_FLIGHT, |index| PARTS[index % PARTS.len()]);
|
||||
/// flight, and the most they held at once.
|
||||
fn round(&self) -> Peak {
|
||||
self.run(ROUND, IN_FLIGHT, |index| PARTS[index % PARTS.len()])
|
||||
}
|
||||
|
||||
/// The command buffers and command pools the device made so far, the command buffers the
|
||||
@@ -141,60 +157,96 @@ impl Load {
|
||||
/// The command buffers holding their pools at once: [`IN_FLIGHT`] committed, and the one encoding.
|
||||
const ALIVE: usize = IN_FLIGHT + 1;
|
||||
|
||||
/// The most a run's command buffers held at once ([`Load::run`]).
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
struct Peak {
|
||||
/// The command buffers holding their pools: those committed whose completed handler had not
|
||||
/// run, and the one encoding.
|
||||
alive: usize,
|
||||
/// The primaries those have in use, at most ([`primaries`]).
|
||||
primaries: usize,
|
||||
}
|
||||
|
||||
impl Peak {
|
||||
/// The larger of each.
|
||||
fn max(self, other: Peak) -> Peak {
|
||||
Peak {
|
||||
alive: self.alive.max(other.alive),
|
||||
primaries: self.primaries.max(other.primaries),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// At most the primaries a command buffer of `encoders` of the load's encoders has in use: each
|
||||
/// encoder's own and one of barriers before it, and the batch's own and its first's.
|
||||
fn primaries(encoders: usize) -> usize {
|
||||
2 * encoders + 2
|
||||
}
|
||||
|
||||
/// At most the primaries the load has in use at once, of [`ALIVE`] command buffers of [`PARTS`]
|
||||
/// encoders in turn, the largest counts together: each encoder's own and one of barriers before
|
||||
/// it, and the batch's own and its first's.
|
||||
/// encoders in turn, the largest counts together ([`primaries`]).
|
||||
fn in_use() -> usize {
|
||||
let each = |encoders: usize| 2 * encoders + 2;
|
||||
let mut largest = PARTS;
|
||||
largest.sort_unstable_by(|a, b| b.cmp(a));
|
||||
let whole = ALIVE / PARTS.len() * PARTS.iter().map(|&n| each(n)).sum::<usize>();
|
||||
let whole = ALIVE / PARTS.len() * PARTS.iter().copied().map(primaries).sum::<usize>();
|
||||
whole
|
||||
+ largest[..ALIVE % PARTS.len()]
|
||||
.iter()
|
||||
.map(|&n| each(n))
|
||||
.copied()
|
||||
.map(primaries)
|
||||
.sum::<usize>()
|
||||
}
|
||||
|
||||
/// Once each count ran with as many in flight, the spares hold what the load takes: the command
|
||||
/// buffers made stay flat, and the spares free none. The most the load takes at once follows the
|
||||
/// threads' timing, so a later peak may still make a few: fewer than one a command buffer of a
|
||||
/// round ([`ROUND`]) over the measured rounds here, where none were made after the fourth round
|
||||
/// in three release runs and after the sixth in a debug one, and sections that took no spare
|
||||
/// made about 60 a round (lavapipe). And the spares hold at most what the load has in use at once, with what the pools
|
||||
/// out may hold unused as a command buffer is made: a command buffer takes a pool only once the
|
||||
/// pools it took handed out every one of the level they held, so only its last may hold some
|
||||
/// unused, at most [`POOL_HOLDS`]; and each pool holds a primary begun ahead and a secondary
|
||||
/// besides. Before, the barriers' command buffers, recorded in a section of the exit guard, took
|
||||
/// no spare, and a command buffer made what it lacked in its first pool until it had handed out
|
||||
/// 16: the pools grew past what was in use at once to the bound, and each give-back shed the
|
||||
/// oldest whole, which the next takers made again (the module docs of `spares.rs`).
|
||||
/// After every round, the command buffers the device holds (made, less those the spares freed) are
|
||||
/// at most the primaries the load had in use at once so far, by the most its command buffers
|
||||
/// held at once that the test saw ([`Peak`]), with what the pools out of the spares may hold
|
||||
/// unused as a command buffer is made: the device makes one only where no spare holds one of
|
||||
/// its level, and a command buffer takes a pool only once the pools it took handed out every one
|
||||
/// of the level they held, so only its last may hold some unused, at most [`POOL_HOLDS`]; and
|
||||
/// each pool holds a primary begun ahead and a secondary besides. The most the load has in use at
|
||||
/// once follows the threads' timing, as a busier device keeps more in flight: once warm, more are
|
||||
/// made only as a later peak needs them, where the bound grows with it. Once warm, the spares free
|
||||
/// none. And the spares hold at most what the load can have in use at once ([`in_use`]), with what
|
||||
/// the pools out may hold unused. Before, the barriers' command buffers, recorded in a section of
|
||||
/// the exit guard, took no spare, and a command buffer made what it lacked in its first pool until
|
||||
/// it had handed out 16: the pools grew past what was in use at once to the bound, and each
|
||||
/// give-back shed the oldest whole, which the next takers made again (the module docs of
|
||||
/// `spares.rs`).
|
||||
#[test]
|
||||
fn fenced_command_buffers_in_flight_stay_flat_once_warm() {
|
||||
let scratch = std::env::temp_dir().join(format!("m2v-spares-parts-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&scratch).unwrap();
|
||||
let load = Load::new(device(&scratch));
|
||||
let mut rounds = Vec::new();
|
||||
let mut peak = Peak::default();
|
||||
for _ in 0..WARM + MEASURED {
|
||||
load.round();
|
||||
rounds.push(load.counts());
|
||||
peak = peak.max(load.round());
|
||||
let (made, pools, held, freed) = load.counts();
|
||||
rounds.push((made, pools, held, freed, peak.alive, peak.primaries));
|
||||
}
|
||||
let (warm, _, _, freed_warm) = rounds[WARM - 1];
|
||||
let (made, pools, after, freed) = *rounds.last().unwrap();
|
||||
let bound = in_use() + ALIVE * POOL_HOLDS + 2 * pools as usize;
|
||||
let (warm, _, _, freed_warm, _, _) = rounds[WARM - 1];
|
||||
let (made, pools, after, freed, _, _) = *rounds.last().unwrap();
|
||||
let unused = |pools: u64| ALIVE * POOL_HOLDS + 2 * pools as usize;
|
||||
let bound = in_use() + unused(pools);
|
||||
println!(
|
||||
"SPARES-PARTS {}: rounds of {ROUND} command buffers of {PARTS:?} fenced encoders, \
|
||||
{IN_FLIGHT} in flight: command buffers made, command pools made, command buffers the \
|
||||
spares hold and those they freed after each {rounds:?}; at most {} in use at once, the \
|
||||
bound {bound}",
|
||||
spares hold and those they freed after each, and the most command buffers alive at once \
|
||||
and the primaries they had in use so far {rounds:?}; {} made once warm; at most {} in \
|
||||
use at once, the bound {bound}",
|
||||
load.device.name(),
|
||||
made - warm,
|
||||
in_use()
|
||||
);
|
||||
assert!(
|
||||
made - warm < ROUND as u64,
|
||||
"{} command buffers made once warm",
|
||||
made - warm
|
||||
);
|
||||
for (round, &(made, pools, _, freed, _, needed)) in rounds.iter().enumerate() {
|
||||
let holds = made - freed.iter().sum::<u64>();
|
||||
let most = needed + unused(pools);
|
||||
assert!(
|
||||
holds <= most as u64,
|
||||
"after round {round} the device holds {holds} command buffers, past the {needed} \
|
||||
primaries the load had in use at once and what the pools may hold unused ({most})"
|
||||
);
|
||||
}
|
||||
assert!(after <= bound, "the spares hold {after}, past {bound}");
|
||||
assert_eq!(
|
||||
freed, freed_warm,
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
//! The runtime's side of the parity harness: [`Api`] on `metal2vulkan_runtime`, on the device
|
||||
//! the lane's cfg selects, under the validation layer (`runtime_lane::validated_device`).
|
||||
//! the lane's cfg selects, under the validation layer (`runtime_lane::validated_device_with`), at
|
||||
//! its queue plan (`runtime_lane::at_plan`): a fixture's command queues are its own, as many as
|
||||
//! it asks for, and the lane's queue limits would change the second one's placement.
|
||||
|
||||
use super::api::{Answer, Api, Completion, Fixture, Layout, Refused, Region, Times};
|
||||
use super::record::Refusal;
|
||||
use crate::air_library::AirLibrary;
|
||||
use crate::gpu::TEST_DEVICE;
|
||||
use crate::runtime_lane::{validated_device, Messages, ScratchCache};
|
||||
use crate::runtime_lane::{at_plan, validated_device_with, Messages, ScratchCache};
|
||||
use metal2vulkan_runtime::{
|
||||
BlitCommandEncoder, BlitOption, Buffer, CommandBuffer, CommandBufferStatus, CommandQueue,
|
||||
ComputeCommandEncoder, ComputePipelineState, Device, Error, EventRef, Fence, PipelineOptions,
|
||||
@@ -29,7 +31,7 @@ impl RuntimeApi {
|
||||
pub(crate) fn open() -> Result<RuntimeApi, String> {
|
||||
let cache = ScratchCache::new().map_err(|error| error.to_string())?;
|
||||
let messages = Messages::default();
|
||||
let device = validated_device(TEST_DEVICE, &messages, cache.path())?;
|
||||
let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), at_plan)?;
|
||||
Ok(RuntimeApi {
|
||||
device,
|
||||
messages,
|
||||
|
||||
@@ -14,7 +14,7 @@ use super::run::{pixel_format, swizzle};
|
||||
use super::FIXTURE;
|
||||
use crate::air_library::AirLibrary as _;
|
||||
use crate::gpu::TEST_DEVICE;
|
||||
use crate::runtime_lane::{validated_device_with, LaneChecks, Messages, ScratchCache};
|
||||
use crate::runtime_lane::{at_plan, validated_device_with, LaneChecks, Messages, ScratchCache};
|
||||
use ash::vk::Handle as _;
|
||||
use metal2vulkan::metal::{
|
||||
BarrierScope, DispatchType, PixelFormat, PrimitiveType, RenderStages, TextureType,
|
||||
@@ -80,7 +80,10 @@ impl RuntimeSeq {
|
||||
fn open_checked(checks: Option<LaneChecks>) -> Result<RuntimeSeq, String> {
|
||||
let cache = ScratchCache::new().map_err(|error| error.to_string())?;
|
||||
let messages = Messages::default();
|
||||
// A program's command queues are its own, as many as it asks for: the lane's queue limits
|
||||
// would change the second one's placement, so the device takes its plan.
|
||||
let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| {
|
||||
at_plan(options);
|
||||
if let Some(checks) = checks {
|
||||
checks.apply(options);
|
||||
}
|
||||
|
||||
@@ -1864,13 +1864,25 @@ fn case_bound_value_kinds(device: &Device, case: &PublicCase) -> BTreeSet<Degrad
|
||||
degrade_notices::bound_value_kinds(device, function.function_descriptor())
|
||||
}
|
||||
|
||||
/// The kind a test's first `Shared` buffer or texture of the default CPU cache mode forces on
|
||||
/// `device`: `shared-in-system-memory` where it has no unified memory
|
||||
/// (`degrade_notices::shared_in_system_memory`).
|
||||
/// The kinds a test's storage forces on `device` the first time, where its device has no unified
|
||||
/// memory: `shared-in-system-memory`, for its first `Shared` buffer or texture of the default CPU
|
||||
/// cache mode (`degrade_notices::shared_in_system_memory`); and `staged-indirect-records`, where
|
||||
/// a host access of indirect command buffer records was staged through the device's staging
|
||||
/// queue since the device was made, its counts from zero
|
||||
/// (`WorkCounts::icb_records_staged_accesses`): records a kernel wrote first, or a `Private`
|
||||
/// buffer's, lie in device-local memory, and a host step that reads them while its command buffer
|
||||
/// holds them reaches them so. With unified memory nothing is staged.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
fn shared_kinds(device: &Device) -> BTreeSet<Degradation> {
|
||||
let shared = degrade_notices::shared_in_system_memory(device);
|
||||
degrade_notices::forced(&[(Degradation::SharedInSystemMemory, shared)])
|
||||
let staged = device.work_counts().icb_records_staged_accesses;
|
||||
if device.properties().has_unified_memory {
|
||||
assert_eq!(staged, 0, "unified memory stages no records");
|
||||
}
|
||||
degrade_notices::forced(&[
|
||||
(Degradation::SharedInSystemMemory, shared),
|
||||
(Degradation::StagedIndirectRecords, staged > 0),
|
||||
])
|
||||
}
|
||||
|
||||
/// Whether `got`, a `float` channel a module converted from a texel's codes, holds as Metal's
|
||||
|
||||
@@ -33,7 +33,7 @@ use metal2vulkan::metal::{DispatchType, IndirectCommandType, ResourceUsage};
|
||||
use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource};
|
||||
use metal2vulkan_devtools::{engine_dir, llvm_assemble};
|
||||
use metal2vulkan_runtime::{
|
||||
ComputePipelineState, Device, DeviceOptions, HeapDescriptor, HeapType,
|
||||
CommandQueue, ComputePipelineState, Device, DeviceOptions, HeapDescriptor, HeapType,
|
||||
IndirectCommandBufferDescriptor, Library, PipelineOptions, ResourceOptions, Size,
|
||||
};
|
||||
|
||||
@@ -117,11 +117,15 @@ const GIVEN: Encoding = Encoding {
|
||||
|
||||
/// `writer` (`cid_encode`) writes [`COMMANDS`] commands into a buffer that inherits the encoder's
|
||||
/// state and buffers, then an encoder executes them as `encoding` says with `count` (`cid_count`)
|
||||
/// and its buffers: what `sums` holds, the records the host read across the run, whether the
|
||||
/// command buffer ran a flat variant (the GPU alone's execution record), the host steps recorded,
|
||||
/// and the pipeline barriers recorded.
|
||||
/// and its buffers, in a command buffer of `queue`: what `sums` holds, the records the host read
|
||||
/// across the run, whether the command buffer ran a flat variant (the GPU alone's execution
|
||||
/// record), the host steps recorded, and the pipeline barriers recorded. A test's runs share its
|
||||
/// one queue, whose kept barriers its first run records (`dispatch_executions::own_barriers`): a
|
||||
/// command queue of each run's own, at the device's queue plan, may take a `VkQueue` of its own,
|
||||
/// whose kept barriers each run would record again.
|
||||
fn run(
|
||||
device: &Device,
|
||||
queue: &CommandQueue,
|
||||
(writer, count): (&ComputePipelineState, &ComputePipelineState),
|
||||
encoding: Encoding,
|
||||
) -> (Vec<u32>, (u64, bool, u64, u64)) {
|
||||
@@ -153,7 +157,6 @@ fn run(
|
||||
let multiplier = buffer_with(device, &at(MULTIPLIER_AT, &words([MULTIPLIER]))).unwrap();
|
||||
// The execution range (location 0, length `COMMANDS`) a ranged execution reads.
|
||||
let range = buffer_with(device, &words([0, COMMANDS as u32])).unwrap();
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let command_buffer = queue.command_buffer().unwrap();
|
||||
let before = device.work_counts();
|
||||
let barriers_before = barriers(device);
|
||||
@@ -225,8 +228,9 @@ fn inherited_buffers_dispatch_on_the_gpu_alone() {
|
||||
&state(device, &library, "cid_encode"),
|
||||
&state(device, &library, "cid_count"),
|
||||
);
|
||||
let (cold, (read, flat, _, _)) = run(device, states, GIVEN);
|
||||
let (sums, (read_warm, flat_warm, steps, _)) = run(device, states, GIVEN);
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let (cold, (read, flat, _, _)) = run(device, &queue, states, GIVEN);
|
||||
let (sums, (read_warm, flat_warm, steps, _)) = run(device, &queue, states, GIVEN);
|
||||
let counted = (read_warm, flat_warm, steps);
|
||||
let notices = messages.take_notices();
|
||||
assert_eq!(
|
||||
@@ -265,17 +269,18 @@ fn a_host_step_orders_the_commands_by_their_barriers_alone() {
|
||||
&state(device, &library, "cid_encode"),
|
||||
&state(device, &library, "cid_count"),
|
||||
);
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let mut taken = Vec::new();
|
||||
for dispatch_type in [DispatchType::Serial, DispatchType::Concurrent] {
|
||||
let encoding = Encoding {
|
||||
dispatch_type,
|
||||
ranged: true,
|
||||
};
|
||||
let (cold, _) = run(device, states, encoding);
|
||||
let (cold, _) = run(device, &queue, states, encoding);
|
||||
assert_eq!(cold, expected(), "{dispatch_type:?}: the first run");
|
||||
let at = format!("{dispatch_type:?}");
|
||||
taken.push(own_barriers(device, &at, || {
|
||||
let (sums, (_, flat, steps, barriers)) = run(device, states, encoding);
|
||||
let (sums, (_, flat, steps, barriers)) = run(device, &queue, states, encoding);
|
||||
assert_eq!(sums, expected(), "{at}");
|
||||
assert_eq!((flat, steps), (false, 1), "{at}: in the host step");
|
||||
barriers
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
//! what each word is. Every answer is a small integer or a half, exact in `float`.
|
||||
|
||||
use super::{
|
||||
buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages,
|
||||
ScratchCache, WAIT,
|
||||
at_plan, buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with,
|
||||
Messages, ScratchCache, WAIT,
|
||||
};
|
||||
use crate::air_library::AirLibrary;
|
||||
use crate::gpu::TEST_DEVICE;
|
||||
@@ -162,7 +162,9 @@ fn pointers_a_closure_array_holds_answer_as_metal() {
|
||||
let messages = Messages::default();
|
||||
let cache = ScratchCache::new().unwrap();
|
||||
{
|
||||
let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |_| {}).unwrap();
|
||||
// A command queue for each dispatch: the lane's queue limits would change the second
|
||||
// one's placement, so the device takes its plan.
|
||||
let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), at_plan).unwrap();
|
||||
check(
|
||||
"pooled_closures",
|
||||
&dispatched(&device, "pooled_closures", None, &[]),
|
||||
|
||||
@@ -39,9 +39,7 @@
|
||||
//! over the `Private` buffer its color target lies over), reading it as it stood before.
|
||||
|
||||
use super::apart_writes::{layer_reported_nothing_but_apart_writes, NotedWrites};
|
||||
use super::degrade_notices::{
|
||||
assert_made_once, forced, made_render_kinds, on_device, on_device_with, shared_in_system_memory,
|
||||
};
|
||||
use super::degrade_notices::{assert_made_once, made_render_kinds, on_device, on_device_with};
|
||||
use super::indirect_command_buffers::{render_template_descriptor, render_template_state};
|
||||
use super::indirect_host_steps::{self, complete, param, HOST_STEPS};
|
||||
use super::patch_indices::Lane;
|
||||
@@ -277,15 +275,13 @@ pub(super) fn pass() -> RenderPassDescriptor {
|
||||
}
|
||||
|
||||
/// The kinds a test's steps force beside its own, where the device has not announced them: the
|
||||
/// makings of the pipeline states of `made`, and the `Shared` buffers' system memory.
|
||||
/// makings of the pipeline states of `made`, and what its `Shared` storage forces
|
||||
/// ([`shared_kinds`](super::shared_kinds)).
|
||||
pub(super) fn forced_with(
|
||||
device: &Device,
|
||||
made: &[metal2vulkan::pipeline::RenderPipelineDescriptor],
|
||||
) -> std::collections::BTreeSet<Degradation> {
|
||||
let mut kinds = forced(&[(
|
||||
Degradation::SharedInSystemMemory,
|
||||
shared_in_system_memory(device),
|
||||
)]);
|
||||
let mut kinds = super::shared_kinds(device);
|
||||
for descriptor in made {
|
||||
kinds.extend(made_render_kinds(device, descriptor));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
//! shadow's plan binds a neutral its state's creation made; beside a stencil, the shadow's run is
|
||||
//! one of another shape, whose render pass, framebuffer and shadow the host step makes.
|
||||
|
||||
use super::degrade_notices::shared_in_system_memory;
|
||||
use super::degrade_notices::{assert_made_once, forced, made_compute_kinds, made_render_kinds};
|
||||
use super::{
|
||||
buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages,
|
||||
@@ -732,7 +731,6 @@ fn a_stencil_output_tests_and_writes_the_stencil_as_metal() {
|
||||
.properties()
|
||||
.driver_facts
|
||||
.contains(&DriverFact::DontCareStoreIsMetals);
|
||||
let system_memory = shared_in_system_memory(&device);
|
||||
let lane = Lane::new(device);
|
||||
if !lane.outputs_stencil() {
|
||||
continue;
|
||||
@@ -788,10 +786,8 @@ fn a_stencil_output_tests_and_writes_the_stencil_as_metal() {
|
||||
Err(error) => panic!("{at} on {name}: {error}"),
|
||||
}
|
||||
// The passes draw from `Shared` buffers.
|
||||
let mut first = forced(&[
|
||||
(Degradation::DontCareStore, dont_care && !dont_care_metals),
|
||||
(Degradation::SharedInSystemMemory, system_memory),
|
||||
]);
|
||||
let mut first = forced(&[(Degradation::DontCareStore, dont_care && !dont_care_metals)]);
|
||||
first.extend(super::shared_kinds(&lane.device));
|
||||
first.extend(made);
|
||||
if shadow && drew {
|
||||
let mut kinds = vec![Degradation::ShaderSideStencil, Degradation::RenderPassSplit];
|
||||
@@ -846,7 +842,6 @@ fn executed_commands_test_and_write_the_stencil_as_metal() {
|
||||
);
|
||||
let form = if shadow { "shadow" } else { "export" };
|
||||
let name = device.name().to_owned();
|
||||
let system_memory = shared_in_system_memory(&device);
|
||||
let lane = Lane::new(device);
|
||||
if !lane.outputs_stencil() {
|
||||
continue;
|
||||
@@ -885,7 +880,7 @@ fn executed_commands_test_and_write_the_stencil_as_metal() {
|
||||
true => vec![Degradation::ShaderSideStencil, Degradation::RenderPassSplit],
|
||||
false => Vec::new(),
|
||||
};
|
||||
let mut first = forced(&[(Degradation::SharedInSystemMemory, system_memory)]);
|
||||
let mut first = super::shared_kinds(&lane.device);
|
||||
first.extend(made);
|
||||
let counts = assert_made_once(&messages, &kinds, &first);
|
||||
assert_eq!(
|
||||
@@ -930,7 +925,6 @@ fn a_host_step_s_draw_whose_stencil_output_reaches_no_attachment_binds_the_neutr
|
||||
);
|
||||
let form = if shadow { "shadow" } else { "export" };
|
||||
let name = device.name().to_owned();
|
||||
let system_memory = shared_in_system_memory(&device);
|
||||
let lane = Lane::new(device);
|
||||
if !lane.outputs_stencil() {
|
||||
continue;
|
||||
@@ -951,7 +945,7 @@ fn a_host_step_s_draw_whose_stencil_output_reaches_no_attachment_binds_the_neutr
|
||||
assert_eq!(color, [COLORS[0]; WIDTH as usize], "{form} on {name}");
|
||||
// The commands and the buffers are `Shared`.
|
||||
let descriptor = lane.stepped_descriptor(false);
|
||||
let mut first = forced(&[(Degradation::SharedInSystemMemory, system_memory)]);
|
||||
let mut first = super::shared_kinds(&lane.device);
|
||||
first.extend(made_render_kinds(&lane.device, &descriptor));
|
||||
let counts =
|
||||
assert_made_once(&messages, &super::indirect_host_steps::HOST_STEPS, &first);
|
||||
@@ -994,7 +988,6 @@ fn a_host_step_s_run_of_another_shape_makes_its_objects_and_draws() {
|
||||
);
|
||||
let form = if shadow { "shadow" } else { "export" };
|
||||
let name = device.name().to_owned();
|
||||
let system_memory = shared_in_system_memory(&device);
|
||||
let lane = Lane::new(device);
|
||||
if !lane.outputs_stencil() {
|
||||
continue;
|
||||
@@ -1018,10 +1011,10 @@ fn a_host_step_s_run_of_another_shape_makes_its_objects_and_draws() {
|
||||
// shape splits the pass around the shadow's copies.
|
||||
let descriptor = lane.stepped_descriptor(true);
|
||||
let mut first = forced(&[
|
||||
(Degradation::SharedInSystemMemory, system_memory),
|
||||
(Degradation::ShaderSideStencil, shadow),
|
||||
(Degradation::RenderPassSplit, shadow),
|
||||
]);
|
||||
first.extend(super::shared_kinds(&lane.device));
|
||||
first.extend(made_render_kinds(&lane.device, &descriptor));
|
||||
assert_made_once(&messages, &super::indirect_host_steps::HOST_STEPS, &first);
|
||||
drop(lane);
|
||||
|
||||
Reference in new issue
Block a user