rt: Gauges::textures_copied_over; the player counts its textures over buffers in place and copied
Gauges::textures_copied_over is the live textures over a buffer the runtime holds in an image of their own (where the device's linear image does not take the texture, or the buffer's bytes are imported), Managed device copies' included: it rises at such a texture's making and falls at its drop, as copied_overs does for the Shared ones, and reads zero at device drop like every gauge. Its doc line names the over-copy metrics, and over_copies' names it. The player's rt backend counts each texture over a buffer it makes (not substituted) as in place or held in an image of its own by the gauge's rise across the making, and reports them on a textures over buffers line; the gauge goes out with the drop gauges and the frames' live ones. Tests: copy_over's device test asserts the gauge rises with its texture; the player's no-copy test asserts its texture over an import counts in an image of its own, and its drop gauges (this one included) read zero. Verified so far: signatures.py --check; the build and tests run in the check job.
This commit is contained in:
1 parent
01d40ad5fc
commit
296e110c0f
6 files changed
+47
-1
No files matched your search
@@ -203,6 +203,8 @@ pub(crate) enum Gauge {
|
||||
Shadows,
|
||||
/// [`Gauges::shadow_bytes`].
|
||||
ShadowBytes,
|
||||
/// [`Gauges::textures_copied_over`].
|
||||
TexturesCopiedOver,
|
||||
/// [`Gauges::timestamp_pools`].
|
||||
TimestampPools,
|
||||
/// [`Gauges::imports`].
|
||||
@@ -327,6 +329,7 @@ struct Atomics {
|
||||
pipeline_cache_bytes: AtomicU64,
|
||||
shadows: AtomicU64,
|
||||
shadow_bytes: AtomicU64,
|
||||
textures_copied_over: AtomicU64,
|
||||
timestamp_pools: AtomicU64,
|
||||
imports: AtomicU64,
|
||||
/// Segment ends whose barrier reaches the host, for the tests.
|
||||
@@ -680,6 +683,7 @@ impl Counters {
|
||||
Gauge::PipelineCacheBytes => &a.pipeline_cache_bytes,
|
||||
Gauge::Shadows => &a.shadows,
|
||||
Gauge::ShadowBytes => &a.shadow_bytes,
|
||||
Gauge::TexturesCopiedOver => &a.textures_copied_over,
|
||||
Gauge::TimestampPools => &a.timestamp_pools,
|
||||
Gauge::Imports => &a.imports,
|
||||
}
|
||||
@@ -808,6 +812,7 @@ impl Counters {
|
||||
pipeline_cache_bytes: a.pipeline_cache_bytes.load(Relaxed),
|
||||
shadows: a.shadows.load(Relaxed),
|
||||
shadow_bytes: a.shadow_bytes.load(Relaxed),
|
||||
textures_copied_over: a.textures_copied_over.load(Relaxed),
|
||||
timestamp_pools: a.timestamp_pools.load(Relaxed),
|
||||
imports: a.imports.load(Relaxed),
|
||||
}
|
||||
@@ -987,6 +992,7 @@ pub struct Metrics {
|
||||
/// and its image of its own ([`Buffer::new_texture`](crate::Buffer::new_texture)): the
|
||||
/// buffer's bytes into the image, in the upload that leads a submission or after a command
|
||||
/// wrote the buffer, and the image back into the buffer after a command wrote the texture.
|
||||
/// The textures held so are [`Gauges::textures_copied_over`].
|
||||
pub over_copies: u64,
|
||||
/// The bytes of those copies, which count in [`bytes_copied`](Self::bytes_copied) too.
|
||||
pub over_copy_bytes: u64,
|
||||
@@ -1214,6 +1220,12 @@ pub struct Gauges {
|
||||
pub shadows: u64,
|
||||
/// The bytes of the shadows' memory.
|
||||
pub shadow_bytes: u64,
|
||||
/// Textures over a buffer the runtime holds in an image of their own, where the device's
|
||||
/// linear image does not take the texture or the buffer's bytes are imported
|
||||
/// ([`Buffer::new_texture`](crate::Buffer::new_texture)): the copies between them and their
|
||||
/// buffers are [`Metrics::over_copies`]. A view is its texture's. The rest of the textures over
|
||||
/// buffers are in place.
|
||||
pub textures_copied_over: u64,
|
||||
/// The device's timestamp query pools, each of 4096 queries, a pair for each command buffer
|
||||
/// from its first record until its times are read at its completion: made as command buffers
|
||||
/// need them, and kept until the device drops.
|
||||
|
||||
@@ -163,12 +163,15 @@ mod on_device {
|
||||
.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
let mut now: Vec<u8> = (0..LEN).map(|i| (i % 251) as u8).collect();
|
||||
write(&buffer, &now);
|
||||
let held = || device.counters().gauges().textures_copied_over;
|
||||
let before = held();
|
||||
let texture = (buffer.new_texture(&descriptor(), None, 0, pitch))
|
||||
.unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
assert!(
|
||||
texture.copied_over().is_some(),
|
||||
"{name}: an image of its own"
|
||||
);
|
||||
assert_eq!(held(), before + 1, "{name}: the gauge counts it");
|
||||
let scratch = plain(name, &device, &texels(0));
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
for round in 0..3 {
|
||||
|
||||
@@ -602,6 +602,7 @@ impl Drop for TextureInner {
|
||||
// A view's id and image are its parent's, which it keeps.
|
||||
if self.view.is_none() {
|
||||
if let Some(named) = (self.named.as_ref()).filter(|named| named.form == Form::Copied) {
|
||||
core.counters.fall(Gauge::TexturesCopiedOver);
|
||||
match named.buffer.held().1 {
|
||||
// Its buffer keeps its image where a copy back is owed
|
||||
// (`crate::over::ManagedOvers`).
|
||||
@@ -1204,6 +1205,9 @@ impl Device {
|
||||
// Over a buffer of no device copy, the commands track what they write while it lives
|
||||
// (`crate::over`).
|
||||
let copied = (inner.named.as_ref()).filter(|named| named.form == Form::Copied);
|
||||
if copied.is_some() {
|
||||
core.counters.rise(Gauge::TexturesCopiedOver);
|
||||
}
|
||||
if copied.is_some_and(|named| named.buffer.held().1.is_none()) {
|
||||
core.copied_overs.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
@@ -350,6 +350,9 @@ pub struct NewRuntime {
|
||||
host_alignment: Option<u64>,
|
||||
/// The no-copy buffers by how they play, and the recorded ranges of the stream's blocks.
|
||||
no_copies: imports::NoCopies,
|
||||
/// The textures over buffers made (not substituted): in place, and held in an image of their
|
||||
/// own (`rt::Gauges::textures_copied_over` rose across the making).
|
||||
textures_over: [u64; 2],
|
||||
}
|
||||
|
||||
/// The objects `values` name, lists included.
|
||||
@@ -656,6 +659,7 @@ fn named(gauges: rt::Gauges) -> Vec<(&'static str, u64)> {
|
||||
("pipeline_cache_bytes", gauges.pipeline_cache_bytes),
|
||||
("shadows", gauges.shadows),
|
||||
("shadow_bytes", gauges.shadow_bytes),
|
||||
("textures_copied_over", gauges.textures_copied_over),
|
||||
("timestamp_pools", gauges.timestamp_pools),
|
||||
]
|
||||
}
|
||||
@@ -681,6 +685,7 @@ impl NewRuntime {
|
||||
places: Places::new(device.clone()),
|
||||
host_alignment: imports::host_alignment(&device),
|
||||
no_copies: imports::NoCopies::default(),
|
||||
textures_over: [0; 2],
|
||||
device,
|
||||
objects: HashMap::new(),
|
||||
indices: indices::Indices::default(),
|
||||
@@ -1126,6 +1131,12 @@ impl NewRuntime {
|
||||
addressed(buffer, place)
|
||||
}
|
||||
|
||||
/// The runtime's live textures over buffers in an image of their own. A copied texture freed
|
||||
/// on another thread between two reads moves it too, so a making counts by it nearly always.
|
||||
fn copied_over(&self) -> u64 {
|
||||
self.device.counters().gauges().textures_copied_over
|
||||
}
|
||||
|
||||
/// A texture of `descriptor`, at an index where shaders reach it: the next of its class's
|
||||
/// sequence, or for a texture `outside` the program's IDs one outside it.
|
||||
fn new_texture(
|
||||
@@ -1868,7 +1879,12 @@ impl NewRuntime {
|
||||
}
|
||||
let (offset, bytes_per_row) = (uint(call, 1)?, uint(call, 2)?);
|
||||
let make = |index| buffer.new_texture(&descriptor, index, offset, bytes_per_row);
|
||||
self.texture_or_substitute(call, descriptor.usage, &descriptor, make)
|
||||
let (gaps, copied) = (self.substitutes.gaps, self.copied_over());
|
||||
let made = self.texture_or_substitute(call, descriptor.usage, &descriptor, make)?;
|
||||
if self.substitutes.gaps == gaps {
|
||||
self.textures_over[usize::from(self.copied_over() > copied)] += 1;
|
||||
}
|
||||
Ok(made)
|
||||
}
|
||||
"newTiledTextureWithDescriptor:offset:bytesPerRow:" => {
|
||||
let descriptor = self.texture_descriptor(call, 0)?;
|
||||
@@ -2430,6 +2446,7 @@ impl Backend for NewRuntime {
|
||||
("imports", gauges.imports),
|
||||
("buffers", gauges.buffers),
|
||||
("textures", gauges.textures),
|
||||
("textures_copied_over", gauges.textures_copied_over),
|
||||
("pipelines", gauges.pipelines),
|
||||
("kernels", gauges.kernels),
|
||||
("command_buffers", gauges.command_buffers),
|
||||
@@ -2510,6 +2527,12 @@ impl Backend for NewRuntime {
|
||||
lines.push(self.seconds.line());
|
||||
}
|
||||
lines.push(self.no_copies.line());
|
||||
let [in_place, copied] = self.textures_over;
|
||||
lines.push(format!(
|
||||
"textures over buffers {}: {in_place} in place, {copied} in an image of their own, \
|
||||
copied at use (the runtime's gauge rose across the making)",
|
||||
in_place + copied
|
||||
));
|
||||
lines.push(self.asides.line());
|
||||
lines.push(self.places.line());
|
||||
lines.push(self.unwritten.line());
|
||||
|
||||
@@ -1135,6 +1135,9 @@ fn a_no_copy_buffer_is_an_import_and_a_texture_over_it_the_counted_copy() {
|
||||
kinds.is_some_and(|line| line.starts_with(counted) && line.contains("; bytes-form 1 (")),
|
||||
"{lines:?}"
|
||||
);
|
||||
// The texture over the import is held in an image of its own.
|
||||
let over = "textures over buffers 1: 0 in place, 1 in an image of their own";
|
||||
assert!(lines.iter().any(|line| line.starts_with(over)), "{lines:?}");
|
||||
// The texture's bytes into its image of its own, once.
|
||||
let executed = &report.total.executed;
|
||||
assert_eq!(executed["over_copies"], 1, "{executed:?}");
|
||||
|
||||
@@ -2338,6 +2338,7 @@ field metal2vulkan-rt::Gauges.stage_entries pub stage_entries: u64
|
||||
field metal2vulkan-rt::Gauges.stage_entry_bytes pub stage_entry_bytes: u64
|
||||
field metal2vulkan-rt::Gauges.staging_bytes pub staging_bytes: u64
|
||||
field metal2vulkan-rt::Gauges.textures pub textures: u64
|
||||
field metal2vulkan-rt::Gauges.textures_copied_over pub textures_copied_over: u64
|
||||
field metal2vulkan-rt::Gauges.threads pub threads: [u64; THREADS]
|
||||
field metal2vulkan-rt::Gauges.timestamp_pools pub timestamp_pools: u64
|
||||
field metal2vulkan-rt::HeapRange.block pub block: BlockId
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user