Pooled memory: no bound on a texture's bytes; ShadowCause::LinearCost is gone

The owner, through reims: zero copy, in place where possible, shadow copies a fallback and never
a first option. A tracked texture over a Private buffer of the runtime's pooled memory whose rows
the device's own linear image lays out otherwise was a shadow past 48 KiB to its pitch
(TextureShadowReason::LinearCost), a speed choice measured on an Iris Xe alone that shadowed 1001
of an RTX 2080 guest boot's 1366 textures. It now takes its DRM_FORMAT_MOD_LINEAR image at Metal's
pitch at any size, wherever the device makes one and its check of the pooled memory passed, as a
texture over a Shared buffer already did; it is a shadow only where the device makes no such
image (its format, usage, pitch or limits), its policy is HostPageTexturePolicy::Shadow, or the
check failed or is pending (a pending one still moves in place once it passes).

Removed with the bound: in_place::POOLED_PITCHED_BYTES, ShadowCause::LinearCost and the public
TextureShadowReason::LinearCost (a breaking change of metal2vulkan-runtime's surface:
api_signatures.tsv loses its variant), texture_spans.rs (the runs of bytes textures were made
over, which only the bound read) and the moves it fed (MoveAfter::Aliases, LoneShadow, the
buffer's note and wait), Texels::only_commands_write (the bound's alone), the bench behind the
bound (runtime_lane::pooled_draw_costs, its crossover additions included) and
aliased_surfaces' cost bench. aliased_surfaces' first check now asserts every texture over one
surface's bytes takes the image at Metal's pitch, the first included, and a read copies nothing;
its one-after-another check, about the first texture's shadow, is gone. storage_over_buffer is
one function again (REFUSALS.md regenerated for the name). API.md, HOWTO.md, FAST-PATHS.md (the
in-place row) say "at any size".

RUNTIME_VERSION is not bumped here: the landing bumps it and re-pins the runtime sources.
This commit is contained in:
Anees Iqbal committed 2026-11-12 01:50:58 -08:00
1 parent 20d84ebf33
commit 0d144ec0de
21 files changed
+69 -1597

No files matched your search

-30
View File
@@ -39,7 +39,6 @@ use super::host_memory::{HeldBack, HostParts, KeepAlive, Release};
use super::host_ram::RamOnDevice;
#[cfg(unix)]
use super::host_residency::{Again, Residency};
use super::in_place::PendingMove;
use super::managed_copy::{CallerCopy, SyncTarget};
use super::memory::{
BoundMemory, Holds, Mapped, MemoryClass, Placement, BLOCK_BYTES, FD_BLOCKS_HANDLE,
@@ -51,7 +50,6 @@ use super::recycle::{self, BufferMaking};
use super::resource::{Identity, ObjectId, ResourceKey};
use super::retained::HeldBy;
use super::texture::first_move::{Filled, Mine};
use super::texture_spans::{LoneShadow, TextureSpans};
use super::values::{CpuCacheMode, HazardTrackingMode, ResourceOptions, StorageMode};
use super::Device;
use crate::release;
@@ -129,9 +127,6 @@ struct BufferShared {
carried: AtomicBool,
/// The calls outside a command buffer's work under way on these parts ([`Buffer::held_parts`]).
calls: Mutex<LinkCalls>,
/// The bytes textures were made over, and the shadows of their linear cost that wait for
/// another texture over theirs (`texture_spans.rs`).
texture_spans: Mutex<TextureSpans>,
}
/// Where a buffer's bytes are.
@@ -3441,7 +3436,6 @@ impl Device {
next: OnceLock::new(),
carried: AtomicBool::new(false),
calls: Mutex::default(),
texture_spans: Mutex::default(),
}))
}
@@ -3696,7 +3690,6 @@ impl Heap {
next: OnceLock::new(),
carried: AtomicBool::new(false),
calls: Mutex::default(),
texture_spans: Mutex::default(),
}))
}
}
@@ -4017,28 +4010,6 @@ impl Buffer {
}
}
/// Whether a texture was made over any of its `bytes` (`texture_spans.rs`).
pub(super) fn textures_made_over(&self, bytes: &Range<u64>) -> bool {
lock(&self.s().texture_spans).made_over(bytes)
}
/// Note a texture made over its `bytes`: the shadows of their linear cost that waited for
/// another texture over them, which the caller moves (`texture_spans.rs`).
pub(super) fn note_texture_made(&self, bytes: Range<u64>) -> Vec<LoneShadow> {
lock(&self.s().texture_spans).note(bytes)
}
/// `texture`, a shadow of its linear cost over its `bytes` that no other texture was made
/// over, waits for one, to move in place with `pending` (`texture_spans.rs`).
pub(super) fn wait_for_texture_over(
&self,
bytes: Range<u64>,
texture: Weak<dyn Any + Send + Sync>,
pending: PendingMove,
) {
lock(&self.s().texture_spans).wait(bytes, texture, pending);
}
/// Note, as it is made, that its maker declared the bytes between a texture's rows and slices
/// over it unobserved (`BufferDescriptor::padding_unobserved`).
pub(super) fn declare_padding_unobserved(&self) {
@@ -5107,7 +5078,6 @@ impl Buffer {
next: OnceLock::new(),
carried: AtomicBool::new(false),
calls: Mutex::default(),
texture_spans: Mutex::default(),
}));
// A two-copy buffer's device copy takes the pages' bytes, its GPU writes not synchronized
// lost with the `VkDevice` (`managed_copy.rs`).
@@ -1868,20 +1868,6 @@ impl Texels {
Backing::of(&self.buffer, self.surface)
}
/// Whether only the runtime's commands write the texels' bytes, as a shadow of them finds
/// (`ShadowCopies::only_commands_write`): a tracked texture's over a buffer of private or
/// memoryless storage the runtime allocated. A shadow of these may stand across command
/// buffers, copied in once (`shadow_standing.rs`); a shadow of others copies them in at every
/// command buffer that uses it, as the CPU or work the runtime does not order may have written
/// them.
pub(super) fn only_commands_write(&self) -> bool {
let private = matches!(
self.backing(),
Backing::PrivateBuffer | Backing::PrivateSurface
);
self.tracked() && private
}
/// Where the CPU's `replace_region` and `get_bytes` find the texels.
pub(super) fn cpu_layout(&self) -> BufferLayout {
self.cpu
+1 -65
View File
@@ -73,7 +73,7 @@
//! memory whose rows the device's own linear image lays out otherwise (a pitch the driver does
//! not take: ANV lays linear rows tight, RADV at multiples of 256 bytes) takes a
//! `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch bound in the buffer's memory, no external
//! memory, where the device makes one ([`PagesClass::Pooled`], `texture.rs`'s
//! memory, at any size, where the device makes one ([`PagesClass::Pooled`], `texture.rs`'s
//! `pooled_pitched_image`): Vulkan lets such an image be bound to memory of no external handle
//! type (`VUID-VkImageCreateInfo-tiling-02261`, `VUID-vkBindImageMemory-image-01445`), but it
//! starts `UNDEFINED` (`VUID-VkImageCreateInfo-initialLayout-12478`), so its first move may
@@ -642,66 +642,8 @@ pub(crate) enum ShadowCause {
Unchecked(PagesClass, Access, RowEnds),
/// The device makes no image over its texels as Metal lays them out: why, and the words.
Refused(Refusal, String),
/// Over the runtime's pooled memory ([`PagesClass::Pooled`]) that only the runtime's
/// commands write (a tracked texture's over a `Private` buffer), its rows to their pitch take
/// this many bytes, past [`POOLED_PITCHED_BYTES`], and no other texture was made over its
/// bytes (`texture_spans.rs`): a `DRM_FORMAT_MOD_LINEAR` image of them renders and samples
/// slower than the shadow's own image with its copies.
LinearCost(u64),
}
/// The most bytes (a texture's rows to their pitch) a tracked texture over a `Private` buffer of
/// the runtime's pooled memory takes a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch for
/// ([`PagesClass::Pooled`]); past it the texture is a shadow ([`ShadowCause::LinearCost`]). Only
/// the runtime's commands write such bytes (`Texels::only_commands_write`): no CPU reads them and
/// the device's check judges the image's first move, so both forms give the same answer, and the
/// bound chooses between two speeds: a shadow's copy per command buffer that
/// writes the texture costs a fixed few microseconds, which a small texture's linear image saves,
/// and every draw into a linear image costs more than into the shadow's optimal one, about 270
/// picoseconds a pixel against 74 on an Iris Xe whatever the texture's size, so the crossover
/// falls as a frame draws more into the texture. Measured on an Iris Xe (ANV, Mesa 26.2.6;
/// `runtime_lane::pooled_draw_costs`), each frame a pass that clears and stores each of four
/// `BGRA8Unorm` textures over `Private` buffers, drawing 0, 1, 4 or 16 blended rectangles over the
/// whole texture, then a draw that reads each whole, a frame's GPU time in microseconds as shadows
/// against in place: 104x52 at 448-byte rows (23 KB) 98.6/83.2, 110.4/99.2, 112.4/114.9,
/// 124.1/177.2; 136x68 at 576 (39 KB) 107.9/92.7, 119.8/112.4, 123.2/139.3, 143.2/246.1; 172x67 at
/// 704 (47 KB) 110.3/97.1, 123.3/119.0, 127.7/152.1, 152.9/285.5; 250x125 at 1024 (128 KB)
/// 138.1/132.0, 153.7/172.4, 169.4/260.1, 239.0/608.7; 200x200 at 832 (166 KB) 160.8/150.0,
/// 177.7/197.6, 198.3/306.7, 290.5/743.3; 250x250 at 1024 (256 KB) 187.8/190.1, 208.2/258.9,
/// 242.0/430.8, 388.3/1114.9. A texture of up to 47 KB drawn at most once a frame runs faster in
/// place; past that one draw a frame runs faster as a shadow, and four or more draws a frame do at
/// every size measured. Over bytes the CPU may write (a `Shared` or `Managed` buffer's) and an
/// untracked texture's, a texture of any access takes the image at any size wherever the device's
/// check passed, as over host pages: the GPU works on CPU-visible memory in place however much
/// slower, a shadow there only where in place is impossible (the owner's ruling, 2026-11-07).
/// There a texture that only samples gains as well, as its shadow is copied in whole at every
/// command buffer that samples it: each frame a command buffer that samples each of four
/// `BGRA8Unorm` textures whole after the CPU wrote a texel of each
/// (`runtime_lane::pooled_draw_costs::pooled_sample_costs`), a frame's GPU time in microseconds as
/// shadows at a padded pitch against linear images at the tight one, over `Shared` buffers:
/// 1308x512 (2.7 MB) 327.8/215.9, 1324x940 (5.0 MB) 802.2/380.1, 3648x2038 (30 MB)
/// 5789.3/2601.6; over `Private` ones, whose shadows stand copied in once (`shadow_standing.rs`),
/// 237.7/216.2, 404.4/409.4 and 2028.1/2433.2. A Radeon 780M (RADV) makes no such image at a pitch
/// off a multiple of 256 bytes, at which its own linear image lays rows, so no texture there takes
/// one. The same bound on every device.
///
/// The bound weighs one texture over the bytes. Past it, each texture over the same bytes would be
/// a shadow of its own: an image of its own, copied in whole at its first use, and copied in whole
/// again after a write through any other texture over the bytes, which lets go of its standing,
/// and copied back whole after a kernel's write. So a texture over bytes another texture was made
/// over takes the image at any size (`texture_spans.rs`), and the first texture's shadow moves to
/// its image once another texture is made over its bytes. Measured with a guest's surface, 36
/// textures (25 `BGRA8Unorm`, 11 `R32Uint`) of 6016x6016 at rows of 24,576 bytes over one
/// `Private` buffer, a kernel writing a 1024x1024-texel square of two of them and reading a
/// 256x256-texel square of four others each frame
/// (`runtime_lane::aliased_surfaces::aliased_surface_costs`): with each texture a shadow of its
/// own (5211 MB of them), a frame copied 869 MB in and 290 MB back and took 28.22 ms of GPU time
/// on a Radeon 780M (RADV), 32.80 ms on an Iris Xe (ANV) and 119.08 ms on lavapipe; with one
/// shadow and 35 images at Metal's pitch, it copied nothing and took 0.22, 1.40 and 1.48 ms. With
/// four textures made each frame and dropped after it, four shadows (579 MB) were made a frame,
/// at 26.67, 28.37 and 102.05 ms a frame; with the images, none, at 0.18, 0.83 and 1.28 ms.
pub(crate) const POOLED_PITCHED_BYTES: u64 = 48 << 10;
/// Why the device makes no image in place over a texture's texels.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum Refusal {
@@ -789,12 +731,6 @@ impl ShadowCause {
rows.words()
),
ShadowCause::Refused(_, why) => why.clone(),
ShadowCause::LinearCost(bytes) => format!(
"its rows take {bytes} bytes to their pitch, past the {POOLED_PITCHED_BYTES} past \
which a DRM_FORMAT_MOD_LINEAR image at Metal's pitch renders and samples slower \
than the shadow's own image with its copies, and no other texture was made over \
its bytes"
),
}
}
}
-1
View File
@@ -242,7 +242,6 @@ mod tessellation;
mod texture;
mod texture_descriptor;
mod texture_placement;
mod texture_spans;
mod this_thread;
mod tile_pass;
mod tracker;
@@ -271,7 +271,6 @@ fn every_shadow_cause_names_itself() {
ShadowCause::Unchecked(PagesClass::DmaBuf, Access::NarrowBufferWrites, on),
ShadowCause::StoreWidth(3),
ShadowCause::Unchecked(PagesClass::Pooled, Access::Renders, inside),
ShadowCause::LinearCost(1 << 20),
ShadowCause::CheckFailed(PagesClass::Pooled, Access::UnobservedRenders, inside),
];
let words: Vec<String> = causes.iter().map(ShadowCause::words).collect();
@@ -295,8 +294,7 @@ fn every_shadow_cause_names_itself() {
assert!(words[14].contains("over a buffer's rows, beside their padding"));
assert!(words[15].contains("not answered") && words[15].contains("over a buffer's rows"));
assert!(words[19].contains("pooled memory"));
assert!(words[20].contains("1048576 bytes") && words[20].contains("slower"));
assert!(words[21].contains("render pass") && words[21].contains("declares unobserved"));
assert!(words[20].contains("render pass") && words[20].contains("declares unobserved"));
}
/// A driver identity, every field set.
@@ -612,7 +612,6 @@ mod texture_placement;
mod texture_placement_device;
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
mod texture_resource_options;
mod texture_spans;
mod this_thread;
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
mod tile_pending;
@@ -85,9 +85,7 @@ fn expected(placement: TexturePlacement) -> Took {
TexturePlacement::Shadow(R::Unchecked { .. }) => Took::Unchecked,
TexturePlacement::Shadow(R::Refused(refusal)) => Took::Refused(refusal),
TexturePlacement::Shadow(R::DeviceCopy) => Took::DeviceCopy,
TexturePlacement::Shadow(
R::PastLength | R::Mipmapped { .. } | R::BytesBetweenRows | R::LinearCost { .. },
)
TexturePlacement::Shadow(R::PastLength | R::Mipmapped { .. } | R::BytesBetweenRows)
| TexturePlacement::NotHostPages
| TexturePlacement::OtherShape => Took::Uncounted,
}
@@ -1,43 +0,0 @@
//! The runs of a buffer's bytes that textures were made over (`texture_spans.rs`), which the
//! pooled bound reads: a texture made over bytes no run holds is the first over them, one made
//! over bytes a run holds is not, whether or not the textures noted there still live; runs that
//! meet join, and past the most runs kept a new one joins the nearest, which errs toward holding
//! bytes no texture was made over.
use crate::texture_spans::TextureSpans;
#[test]
fn bytes_a_texture_was_made_over_stay_noted() {
let mut spans = TextureSpans::default();
assert!(!spans.made_over(&(0..100)), "no texture yet");
assert!(spans.note(0..100).is_empty(), "no shadow waited");
assert!(spans.made_over(&(0..100)), "the same bytes");
assert!(spans.made_over(&(99..200)), "bytes that meet them");
assert!(!spans.made_over(&(100..200)), "the bytes after them");
// A second texture over bytes apart from the first's, then one over both: one run.
spans.note(300..400);
assert!(!spans.made_over(&(100..300)), "the bytes between two runs");
spans.note(50..350);
assert!(spans.made_over(&(100..300)), "the joined run");
assert!(!spans.made_over(&(400..500)), "past every run");
}
#[test]
fn past_the_most_runs_a_new_run_joins_the_nearest() {
let mut spans = TextureSpans::default();
// Runs 1000 bytes apart, more of them than are kept apart.
for n in 0..20u64 {
spans.note(n * 1000..n * 1000 + 10);
}
for n in 0..20u64 {
assert!(
spans.made_over(&(n * 1000..n * 1000 + 10)),
"every texture's bytes stay noted ({n})"
);
}
// Some gap between runs is now held: the runs err toward the image in place.
let held_gaps = (0..19u64)
.filter(|n| spans.made_over(&(n * 1000 + 10..n * 1000 + 1000)))
.count();
assert!(held_gaps > 0, "joined runs hold a gap");
}
+17 -91
View File
@@ -546,15 +546,6 @@ impl TextureShared {
}
}
/// What a shadow over a buffer's bytes waits for to move in place
/// (`Device::storage_over_buffer`), with what it moves with.
enum MoveAfter {
/// Its class's in-place verdicts, made before them (`texture/storage_form.rs`).
Verdicts(in_place::PendingMove),
/// Another texture made over its bytes: a shadow of its linear cost (`texture_spans.rs`).
Aliases(in_place::PendingMove),
}
/// What holds a texture's texels; a view's are its texture's (the `Arc`s cloned).
#[derive(Clone)]
enum Storage {
@@ -2440,22 +2431,13 @@ impl Device {
) -> Result<Texture, Error> {
let record = ViewRecord::of_descriptor(layout, descriptor);
let mut pending = None;
let texels = Arc::new(texels);
let over = (Arc::clone(&texels), &mut pending);
let over = (Arc::new(texels), &mut pending);
let storage = self.storage_over_buffer(call, over, descriptor, layout)?;
let texture = Texture::made(self, storage, record, None, id_use);
match pending {
// A shadow made before its pages' (or its pooled memory's) in-place verdict moves in
// place once it passes.
Some(MoveAfter::Verdicts(pending)) => texture.wait_to_move_in_place(pending),
// A shadow of its linear cost over bytes no other texture was made over moves once
// one is (`texture_spans.rs`).
Some(MoveAfter::Aliases(pending)) => {
let shared: Arc<dyn Any + Send + Sync> = Arc::clone(&texture.0) as _;
let bytes = texels.layout.offset..texels.layout.end();
(texels.buffer).wait_for_texture_over(bytes, Arc::downgrade(&shared), pending);
}
None => {}
// A shadow made before its pages' (or its pooled memory's) in-place verdict moves in
// place once it passes.
if let Some(pending) = pending {
texture.wait_to_move_in_place(pending);
}
Ok(texture)
}
@@ -2466,36 +2448,11 @@ impl Device {
/// A shadow over host pages made before their class's verdict for its access, or over the
/// device's pooled memory before its class's verdict for an image at Metal's pitch there
/// (`Device::pooled_pitched_image`), sets `pending` to what it needs to move in place once the
/// verdict passes; a shadow of its linear cost there, to what it needs to move once another
/// texture is made over its bytes. Once made, the texture's bytes are noted as a texture's
/// (`texture_spans.rs`), and the shadows of their linear cost that waited for another texture
/// over them wait to move in place. Refused as it is.
/// verdict passes. Refused as it is.
fn storage_over_buffer(
&self,
call: &'static str,
(texels, pending): (Arc<Texels>, &mut Option<MoveAfter>),
descriptor: &TextureDescriptor,
layout: &TextureLayout,
) -> Result<Storage, Error> {
let bytes = texels.layout.offset..texels.layout.end();
let buffer = texels.buffer.clone();
let storage = self.storage_decided(call, (texels, pending), descriptor, layout)?;
if !in_place::checking() {
for lone in buffer.note_texture_made(bytes) {
let texture = lone.texture.upgrade().map(Arc::downcast::<TextureShared>);
if let Some(Ok(texture)) = texture {
Texture(texture).wait_to_move_in_place(lone.pending);
}
}
}
Ok(storage)
}
/// [`storage_over_buffer`](Self::storage_over_buffer)'s storage, its bytes not noted.
fn storage_decided(
&self,
call: &'static str,
(texels, pending): (Arc<Texels>, &mut Option<MoveAfter>),
(texels, pending): (Arc<Texels>, &mut Option<in_place::PendingMove>),
descriptor: &TextureDescriptor,
layout: &TextureLayout,
) -> Result<Storage, Error> {
@@ -2595,29 +2552,14 @@ impl Device {
// been made then (`texture/storage_form.rs`).
Err((why, Some(ShadowCause::CheckPending(class, _, rows)))) => {
let line = self.shared().in_place.line();
*pending = Some(MoveAfter::Verdicts(in_place::PendingMove {
*pending = Some(in_place::PendingMove {
class,
rows,
padding: texels.padding(line),
usage,
plan: plan.clone(),
descriptor: *descriptor,
}));
why
}
// A shadow of its linear cost, made over bytes no other texture was made
// over (`Device::pooled_pitched_image`): it moves to the image at Metal's
// pitch once another texture is made over them (`texture_spans.rs`).
Err((why, Some(ShadowCause::LinearCost(_)))) => {
let line = self.shared().in_place.line();
*pending = Some(MoveAfter::Aliases(in_place::PendingMove {
class: PagesClass::Pooled,
rows: texels.rows(line),
padding: texels.padding(line),
usage,
plan: plan.clone(),
descriptor: *descriptor,
}));
});
why
}
Err((why, _)) => why,
@@ -2792,20 +2734,20 @@ impl Device {
),
(usage, plan): (TextureUsage, &ImagePlan),
descriptor: &TextureDescriptor,
pending: &mut Option<MoveAfter>,
pending: &mut Option<in_place::PendingMove>,
) -> Result<String, Error> {
if in_place::checking() {
return Err(Error::NotInPlace(NotInPlace { why: cause.words() }));
}
if let ShadowCause::CheckPending(..) = cause {
*pending = Some(MoveAfter::Verdicts(in_place::PendingMove {
*pending = Some(in_place::PendingMove {
class,
rows,
padding,
usage,
plan: plan.clone(),
descriptor: *descriptor,
}));
});
}
let renders = in_place::Access::Renders.takes(usage);
let accesses = (renders, in_place::Access::Writes.takes(usage));
@@ -3324,13 +3266,11 @@ impl Device {
/// one plane at Metal's pitch (`VkImageDrmFormatModifierExplicitCreateInfoEXT`), no external
/// memory (`dma_buf::ModifierMemory::Own`), unbound and made `UNDEFINED`
/// (`Device::pitched_image`), for a texture of Metal `usage` whose texels the device's own
/// linear image lays out otherwise: where the device makes such images, the texture's rows to
/// their pitch take no more than `in_place::POOLED_PITCHED_BYTES` (past it, a linear image
/// renders and samples slower than the shadow), and its policy and its check of the pooled
/// class ([`PagesClass::Pooled`]) take each access the usage takes
/// for texels that lie in its lines as these do (`in_place::in_place`; a pending verdict
/// starts the check, and the texture is a shadow meanwhile); the check's own textures whatever
/// the verdicts. Why not.
/// linear image lays out otherwise, at any size: where the device makes such images, and its
/// policy and its check of the pooled class ([`PagesClass::Pooled`]) take each access the
/// usage takes for texels that lie in its lines as these do (`in_place::in_place`; a pending
/// verdict starts the check, and the texture is a shadow meanwhile); the check's own textures
/// whatever the verdicts. Why not.
///
/// Vulkan lets such an image be bound to memory of no external handle type: an image of a DRM
/// format modifier's tiling names its modifier and plane layout
@@ -3360,20 +3300,6 @@ impl Device {
)));
}
if !in_place::checking() {
let layout = &texels.layout;
let bytes = layout.slice_pitch * (layout.slices - 1) + layout.row_pitch * layout.rows;
// The bound chooses between two speeds over bytes only the runtime's commands write
// (a tracked `Private` buffer's), where both forms give the same answer, for one
// texture over them: over bytes another texture was made over, each shadow would be
// an image of its own with copies of its own (`texture_spans.rs`). Over bytes the CPU
// may write, or an untracked texture's, the image lies at any size wherever the
// device's check passed, as over host pages, however much slower.
if bytes > in_place::POOLED_PITCHED_BYTES
&& texels.only_commands_write()
&& !(texels.buffer).textures_made_over(&(layout.offset..layout.end()))
{
return Ok(Err(ShadowCause::LinearCost(bytes)));
}
let line = self.shared().in_place.line();
let pages = (
PagesClass::Pooled,
@@ -132,21 +132,6 @@ pub enum TextureShadowReason {
/// rows the log reports changed (`WorkCounts::device_copy_textures`), the GPU's copy of the two
/// a `Managed` resource is on a Mac with a discrete GPU. Not announced.
DeviceCopy,
/// Over a `Private` buffer of the device's own memory whose rows the device's own linear
/// image lays out otherwise than Metal, a tracked texture: its rows take `bytes` bytes to their
/// pitch, past the bound up to which it takes a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch
/// ([`TexturePlacement::NotHostPages`]), as such an image renders and samples slower than the
/// shadow's own image with its copies past it, and over memory only the runtime's commands
/// write both give the same answer. The same bound on every device. Over a `Shared` or
/// `Managed` buffer, and for an untracked texture, the image is taken at any size. So it is
/// over bytes another texture was made over (another format's, a view's, one made again):
/// each shadow would be an image of its own with copies of its own, so a texture over such
/// bytes takes the image at any size, and the shadow of the first moves to it once another
/// texture is made over its bytes, at a quiet commit (`WorkCounts::pooled_textures_moved_in_place`).
LinearCost {
/// The bytes of the texture's rows, each to its pitch.
bytes: u64,
},
}
/// What a texture over host pages does with its image in place, each checked apart by the
@@ -277,11 +262,6 @@ impl TextureShadowReason {
TextureShadowReason::DeviceCopy => "it is a copy in the device's memory of bytes \
whose memory carries a log of its writes"
.to_owned(),
TextureShadowReason::LinearCost { bytes } => format!(
"its rows take {bytes} bytes to their pitch, past the bound up to which it takes \
a DRM_FORMAT_MOD_LINEAR image at Metal's pitch, and no other texture was made \
over its bytes"
),
}
}
}
@@ -410,7 +390,6 @@ impl ShadowCause {
ShadowCause::Refused(refusal, _) => {
TextureShadowReason::Refused(InPlaceRefusal::of(refusal))
}
ShadowCause::LinearCost(bytes) => TextureShadowReason::LinearCost { bytes },
};
TexturePlacement::Shadow(reason)
}
@@ -1,109 +0,0 @@
//! The bytes of a buffer that textures were made over, which the pooled bound reads
//! (`in_place::POOLED_PITCHED_BYTES`, `texture.rs`'s `pooled_pitched_image`).
//!
//! - **Why.** Past the bound, a tracked texture over a `Private` buffer is a shadow of its linear
//! cost (`ShadowCause::LinearCost`): a `DRM_FORMAT_MOD_LINEAR` image renders and samples slower
//! than the shadow's own image, and a shadow whose truth only the runtime's commands write
//! stands across command buffers, copied in once (`shadow_standing.rs`). That holds for one
//! texture over the bytes. A shadow is its texture's own: every other texture over the same
//! bytes (a surface's textures of other formats, made again each frame, its views) makes an
//! image of its own, whose first use copies every texel in, and a write through any of them is
//! a write of the bytes that lets go of every other shadow's standing, whose next use copies
//! every texel in again. A texture over bytes another texture was made over takes the image at
//! Metal's pitch instead, at any size, as over memory the CPU writes: one image over the bytes
//! per texture, no copy, the bytes' own aliasing.
//! - **What is kept.** The runs of bytes textures were made over ([`TextureSpans::note`]), each
//! the texels' first byte to their last, runs that meet joined, at most [`RUNS`] of them: past
//! that, a new run joins the nearest, so a run may hold bytes no texture was made over. That
//! errs toward the image in place, which is as exact as the shadow. A texture's making notes its
//! run once its storage is decided, whatever it took, over any buffer; the placement query reads
//! the runs and notes nothing.
//! - **The first shadow moves.** A shadow of its linear cost made over bytes no other texture was
//! made over waits ([`LoneShadow`]): once a later texture is made over its bytes, it moves to the
//! image at Metal's pitch as a shadow made before its pooled memory's verdicts does
//! (`texture/storage_form.rs`: at the commit of the device's only uncommitted command buffer,
//! with no copy), where the device makes that image then. A view's shadow never moves, as a
//! view's storage never does. One waiting shadow is kept per run at most: a second texture over
//! it takes the waiting one.
use super::in_place::PendingMove;
use std::any::Any;
use std::ops::Range;
use std::sync::Weak;
/// The most runs a buffer keeps apart (the module docs).
const RUNS: usize = 8;
/// The bytes of a buffer that textures were made over, and the shadows of their linear cost
/// that wait for another texture over their bytes (the module docs).
#[derive(Default)]
pub(super) struct TextureSpans {
runs: Vec<Range<u64>>,
lone: Vec<LoneShadow>,
}
/// A shadow of its linear cost made over bytes no other texture was made over: its texture,
/// held weakly and by type erased (`texture.rs`'s `TextureShared`, whose device holds buffers),
/// what it moves with, and its texels' bytes.
pub(super) struct LoneShadow {
pub(super) texture: Weak<dyn Any + Send + Sync>,
pub(super) pending: PendingMove,
bytes: Range<u64>,
}
/// Whether two runs of bytes share one.
fn meet(a: &Range<u64>, b: &Range<u64>) -> bool {
a.start < b.end && b.start < a.end
}
impl TextureSpans {
/// Whether a texture was made over any of `bytes`.
pub(super) fn made_over(&self, bytes: &Range<u64>) -> bool {
self.runs.iter().any(|run| meet(run, bytes))
}
/// Note a texture made over `bytes`: the shadows that waited for another texture over them,
/// which stop waiting here and are the caller's to move (the module docs).
pub(super) fn note(&mut self, bytes: Range<u64>) -> Vec<LoneShadow> {
let mut joined = bytes.clone();
self.runs.retain(|run| {
let meets = meet(run, &joined);
if meets {
joined = joined.start.min(run.start)..joined.end.max(run.end);
}
!meets
});
if self.runs.len() == RUNS {
// The run nearest the new one (by the gap between them) takes it.
let gap = |run: &Range<u64>| match run.end <= joined.start {
true => joined.start - run.end,
false => run.start.saturating_sub(joined.end),
};
if let Some(near) = (0..self.runs.len()).min_by_key(|&i| gap(&self.runs[i])) {
let run = self.runs.swap_remove(near);
joined = joined.start.min(run.start)..joined.end.max(run.end);
}
}
self.runs.push(joined);
self.lone.retain(|lone| lone.texture.strong_count() > 0);
self.lone
.extract_if(.., |lone| meet(&lone.bytes, &bytes))
.collect()
}
/// A shadow of its linear cost was made over `bytes`, which no other texture was made over:
/// it waits for one (the module docs).
pub(super) fn wait(
&mut self,
bytes: Range<u64>,
texture: Weak<dyn Any + Send + Sync>,
pending: PendingMove,
) {
self.lone.retain(|lone| lone.texture.strong_count() > 0);
self.lone.push(LoneShadow {
texture,
pending,
bytes,
});
}
}
@@ -3923,9 +3923,6 @@ impl Counters {
C::CheckFailed(..) => &self.host_texture_shadows_check_failed,
C::Unchecked(..) => &self.host_texture_shadows_unchecked,
C::Refused(refusal, _) => &self.host_texture_shadows_refused[refusal.index()],
// A texture over the runtime's pooled memory, no texture over host pages: counted as
// a shadow (`shadowed_textures`) alone.
C::LinearCost(_) => return,
};
counter.fetch_add(1, Ordering::Relaxed);
if renders {
@@ -8421,10 +8418,7 @@ pub struct WorkCounts {
/// over host pages): each is counted in `pooled_pitched_images` too from then on. Over memory
/// the runtime exports (`MemoryExport`), likewise once the check of that exported memory
/// passed, to the linear image or the `DRM_FORMAT_MOD_LINEAR` one made for its handle type
/// (the latter counted in `pooled_pitched_images`). And tracked textures over a `Private`
/// buffer made shadows of their linear cost (`TextureShadowReason::LinearCost`), the first
/// over their bytes, that moved to that image the same way once another texture was made over
/// their bytes. A runtime extension: Metal has none.
/// (the latter counted in `pooled_pitched_images`). A runtime extension: Metal has none.
pub pooled_textures_moved_in_place: u64,
/// Shadow images of textures that moved in place over the device's pooled memory
/// (`pooled_textures_moved_in_place`) let go of once the command buffer that took the move
@@ -716,8 +716,6 @@ mod pool_churn;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
mod pool_slots;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
mod pooled_draw_costs;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
mod post_depth_coverage;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
mod posted_frees;
@@ -4,47 +4,31 @@
//! `BGRA8Unorm` and `R32Uint` views of the same bytes with shader read and write usage, and writes
//! and reads a few of them each frame. Each surface's maker declares the bytes between its rows
//! unobserved (`BufferDescriptor::padding_unobserved`), as the guest's do. Each texture over a
//! `Private` buffer whose rows the device's
//! own linear image lays out otherwise is a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch inside
//! the pooled bound (`in_place::POOLED_PITCHED_BYTES`), else a shadow
//! (`TextureShadowReason::LinearCost`); a shadow is an image of its own, copied in and back apart
//! from every other texture's over the same bytes.
//! `Private` buffer whose rows the device's own linear image lays out otherwise is a
//! `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch, at any size, where the device makes one and its
//! check of its pooled memory passed: each texture over the bytes an image of its own over them,
//! no copy.
//!
//! - [`textures_over_one_surface_s_bytes_take_one_shadow`]: four textures (two of each format) over
//! one `Private` surface past the bound, where the device makes such images: the first is a
//! shadow of its linear cost, and every later one over the same bytes takes the image at Metal's
//! pitch (`WorkCounts::pooled_pitched_images`), so the textures hold one shadow's bytes, not four;
//! the first's shadow moves to its image at the next quiet commit that takes storage forms (a
//! blit's, here, as `in_place_textures`' move checks commit;
//! `WorkCounts::pooled_textures_moved_in_place`), and a read through it then copies nothing.
//! - [`textures_made_one_after_another_over_one_surface_s_bytes_take_one_shadow`]: the same four
//! made one after another, each written and released before the next is made, as a guest's
//! frames make them: the first is a shadow, every later one takes the image.
//! - [`textures_over_one_surface_s_bytes_each_take_the_image_at_metal_s_pitch`]: four textures
//! (two of each format) over one `Private` surface, where the device makes such images: each
//! takes the image at Metal's pitch (`WorkCounts::pooled_pitched_images`), none is a shadow, and
//! a read through the first copies nothing.
//! - [`writes_through_one_texture_reach_every_texture_over_the_bytes`]: a kernel's write through
//! each of those textures in turn is what a kernel reads through every other one, in the same
//! command buffer and in the next, and what the surface's bytes hold: Metal's aliasing of
//! textures over the same bytes.
//! - [`aliased_surface_costs`] (ignored, release builds): the guest's surface, 6016x6016 at rows of
//! 24,576 bytes in a buffer of 150,994,944, with 36 textures over it (25 `BGRA8Unorm`, 11
//! `R32Uint`) alive across the frames, or four made each frame and dropped after it, a kernel
//! writing a square of two of them and another reading a square of others each frame
//! (`ALIASED-SURFACE-COST`): the textures' forms, the shadows made and their bytes, a frame's
//! GPU time and its shadow copies and texels copied in and back, and the device memory the
//! process holds at its peak (Linux: the DRM file descriptors' resident bytes, and the process's
//! resident set, where lavapipe's memory lies).
use super::first_use_writes::CHECK_WAIT;
use super::in_place_textures::in_place;
use super::{validated_device_with, Messages, ScratchCache, WAIT};
use super::WAIT;
use crate::air_library::AirLibrary;
use crate::gpu::TEST_DEVICE;
use metal2vulkan::metal::{PixelFormat, TextureUsage};
use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource};
use metal2vulkan_devtools::llvm_assemble_text;
use metal2vulkan_runtime::{
BlitOption, Buffer, BufferContents, BufferDescriptor, CommandBuffer, ComputePipelineState,
Device, IoSurfacePlane, Origin, PipelineOptions, ResourceOptions, Size, Texture,
TextureDescriptor, TexturePlacement, TextureShadowReason, WorkCounts,
TextureDescriptor, TexturePlacement,
};
/// The kernels: `fill_float` and `fill_uint` write constant buffer 0's value at every thread's
@@ -259,7 +243,7 @@ fn words_read(texture: &Texture, out: &Buffer, side: u64) -> Vec<u32> {
/// The shape of the checks' surface, (width, rows, row bytes): 256 texels of 4 bytes a row (1024
/// bytes, a multiple of 256 at which RADV lays linear rows, and the tight rows ANV lays) at a
/// pitch of 1280 bytes, 64 rows (81,920 bytes, past the pooled bound).
/// pitch of 1280 bytes, 64 rows (81,920 bytes).
const SMALL: (u64, u64, u64) = (256, 64, 1280);
/// A surface of `length` bytes of `options`, zeros, made as the guest's: its maker declares the
@@ -278,8 +262,7 @@ fn small_surface(device: &Device) -> Buffer {
}
/// Whether the device takes a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch for a texture of
/// `SMALL`'s shape over its pooled memory where the bound does not hold it back: over a `Shared`
/// buffer, whose textures take it at any size where the device's check passed.
/// `SMALL`'s shape over its pooled memory, over a `Shared` buffer, where its check passed.
fn takes_pitched(device: &Device) -> bool {
let (_, height, pitch) = SMALL;
let shared = made_surface(device, pitch * height, ResourceOptions::shared());
@@ -297,7 +280,7 @@ const FORMATS: [PixelFormat; 4] = [
];
#[test]
fn textures_over_one_surface_s_bytes_take_one_shadow() {
fn textures_over_one_surface_s_bytes_each_take_the_image_at_metal_s_pitch() {
super::host_memory::on_device_with(in_place, |device| {
assert!(
device.settle_in_place_checks(CHECK_WAIT),
@@ -315,7 +298,6 @@ fn textures_over_one_surface_s_bytes_take_one_shadow() {
let surface = small_surface(device);
let (width, height, pitch) = SMALL;
let bytes = pitch * height;
let linear_cost = TexturePlacement::Shadow(TextureShadowReason::LinearCost { bytes });
let before = device.work_counts();
let mut answers = Vec::new();
let textures: Vec<Texture> = FORMATS
@@ -329,152 +311,51 @@ fn textures_over_one_surface_s_bytes_take_one_shadow() {
let after = device.work_counts();
let shadows = after.shadowed_textures - before.shadowed_textures;
let pitched = after.pooled_pitched_images - before.pooled_pitched_images;
// Each shadow here is an image of the texture's whole extent, 4 bytes a texel.
let shadow_bytes = shadows * width * height * 4;
eprintln!(
"ALIASED-SURFACE {}: {} textures over one Private surface of {bytes} bytes: answers \
{answers:?}; {shadows} shadows ({shadow_bytes} bytes), {pitched} images at Metal's \
pitch",
{answers:?}; {shadows} shadows, {pitched} images at Metal's pitch",
device.name(),
textures.len(),
);
assert_eq!(answers[0], linear_cost, "the first texture over the bytes");
for (answer, format) in answers.iter().zip(FORMATS).skip(1) {
for (answer, format) in answers.iter().zip(FORMATS) {
assert_eq!(
*answer,
TexturePlacement::NotHostPages,
"a later {format:?} texture over the same bytes"
"a {format:?} texture over the bytes"
);
}
assert_eq!(shadows, 1, "one shadow over the bytes");
assert_eq!(
pitched,
FORMATS.len() as u64 - 1,
"every later texture in place"
);
assert_eq!(shadow_bytes, width * height * 4, "one shadow's bytes");
// The first texture's shadow moves to its image at Metal's pitch at the next commit of the
// device's only uncommitted command buffer that takes storage forms (a blit's), and goes
// once that command buffer completed: a later command buffer that reads it copies
// nothing.
assert_eq!(shadows, 0, "no shadow over the bytes");
assert_eq!(pitched, FORMATS.len() as u64, "every texture in place");
// A read through the first texture copies nothing.
let queue = device.new_command_queue().unwrap();
let row = width * 4;
let out = device
.new_buffer(row * height, ResourceOptions::shared())
.unwrap();
let read = |texture: &Texture| {
let command_buffer = queue.command_buffer().unwrap();
let mut blit = command_buffer.blit_command_encoder().unwrap();
blit.copy_from_texture_to_buffer(
texture,
0,
0,
Origin::new(0, 0, 0),
Size::new(width, height, 1),
&out,
0,
row,
row * height,
BlitOption::None,
)
.unwrap();
blit.end_encoding().unwrap();
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
};
read(&textures[0]);
let moved = device.work_counts();
read(&textures[0]);
let again = device.work_counts();
eprintln!(
"ALIASED-SURFACE {}: the first texture's shadow moved in place {}, freed {}; the \
next read's shadow copies {}",
device.name(),
moved.pooled_textures_moved_in_place - after.pooled_textures_moved_in_place,
again.pooled_texture_shadows_freed_after_move
- after.pooled_texture_shadows_freed_after_move,
again.shadow_copies - moved.shadow_copies,
);
assert_eq!(
moved.pooled_textures_moved_in_place - after.pooled_textures_moved_in_place,
1,
"the first texture's shadow moved in place"
);
assert_eq!(
again.shadow_copies - moved.shadow_copies,
let command_buffer = queue.command_buffer().unwrap();
let mut blit = command_buffer.blit_command_encoder().unwrap();
blit.copy_from_texture_to_buffer(
&textures[0],
0,
"a read after the move copies nothing"
);
});
}
#[test]
fn textures_made_one_after_another_over_one_surface_s_bytes_take_one_shadow() {
super::host_memory::on_device_with(in_place, |device| {
assert!(
device.settle_in_place_checks(CHECK_WAIT),
"the check settles"
);
if !takes_pitched(device) {
eprintln!(
"ALIASED-SURFACE {}: no DRM_FORMAT_MOD_LINEAR image at a {}-byte pitch: nothing \
to check",
device.name(),
SMALL.2
);
return;
}
let kernels = Kernels::new(device);
let queue = device.new_command_queue().unwrap();
let surface = small_surface(device);
let (width, height, pitch) = SMALL;
let bytes = pitch * height;
let linear_cost = TexturePlacement::Shadow(TextureShadowReason::LinearCost { bytes });
let before = device.work_counts();
// Each texture made, written by a kernel, and released once its command buffer completed,
// before the next is made over the same bytes, as a guest's frames make them.
let answers: Vec<TexturePlacement> = FORMATS
.iter()
.enumerate()
.map(|(n, &format)| {
let (texture, answer) = surface_texture(&surface, format, (width, height, pitch));
let command_buffer = queue.command_buffer().unwrap();
kernels.fill(
&command_buffer,
&texture,
0x0102_0304 * (n as u32 + 1),
height,
);
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
answer
})
.collect();
let after = device.work_counts();
let shadows = after.shadowed_textures - before.shadowed_textures;
let pitched = after.pooled_pitched_images - before.pooled_pitched_images;
eprintln!(
"ALIASED-SURFACE {}: {} textures made one after another over one Private surface of \
{bytes} bytes, each released before the next: answers {answers:?}; {shadows} \
shadows, {pitched} images at Metal's pitch",
device.name(),
answers.len(),
);
assert_eq!(answers[0], linear_cost, "the first texture over the bytes");
for (answer, format) in answers.iter().zip(FORMATS).skip(1) {
assert_eq!(
*answer,
TexturePlacement::NotHostPages,
"a later {format:?} texture over bytes a released texture was made over"
);
}
assert_eq!(shadows, 1, "one shadow over the bytes");
0,
Origin::new(0, 0, 0),
Size::new(width, height, 1),
&out,
0,
row,
row * height,
BlitOption::None,
)
.unwrap();
blit.end_encoding().unwrap();
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
let read = device.work_counts();
assert_eq!(
pitched,
FORMATS.len() as u64 - 1,
"every later texture in place"
read.shadow_copies - after.shadow_copies,
0,
"a read copies nothing"
);
});
}
@@ -564,247 +445,3 @@ fn writes_through_one_texture_reach_every_texture_over_the_bytes() {
}
});
}
/// The measurement's surface, (width, rows, row bytes) and its buffer's length: the guest's.
const GUEST: (u64, u64, u64) = (6016, 6016, 24_576);
const GUEST_BYTES: u64 = 150_994_944;
/// The textures over it alive across the frames, and how many of them are `R32Uint`.
const LIVE: usize = 36;
const LIVE_UINT: usize = 11;
/// The textures made over it each frame of the transient case, half of each format.
const TRANSIENT: usize = 4;
/// The square a frame's kernel writes through each written texture, and the one it reads.
const WRITTEN: u64 = 1024;
const READ: u64 = 256;
/// The untimed and the timed frames of each case.
const WARM: usize = 1;
const TIMED: usize = if cfg!(m2v_cpu_icd) { 3 } else { 6 };
/// The bytes of device memory the process holds now, `(drm, resident)`: the resident (else
/// total) memory its DRM file descriptors report (`/proc/self/fdinfo`, the `drm-resident-*` or
/// `drm-memory-*` keys), and its resident set (`VmRSS`), where a CPU device's memory lies. Zeros
/// where the system reports neither.
fn memory_now() -> (u64, u64) {
let bytes = |value: &str| -> u64 {
let mut parts = value.split_whitespace();
let number: u64 = parts.next().and_then(|n| n.parse().ok()).unwrap_or(0);
match parts.next() {
Some("KiB") | Some("kB") => number << 10,
Some("MiB") => number << 20,
Some("GiB") => number << 30,
_ => number,
}
};
let mut drm = 0;
if let Ok(entries) = std::fs::read_dir("/proc/self/fdinfo") {
for entry in entries.flatten() {
let Ok(text) = std::fs::read_to_string(entry.path()) else {
continue;
};
if !text.contains("drm-driver") {
continue;
}
let lines: Vec<(&str, &str)> = text
.lines()
.filter_map(|line| line.split_once(':'))
.map(|(k, v)| (k.trim(), v.trim()))
.collect();
let resident: u64 = lines
.iter()
.filter(|(k, _)| k.starts_with("drm-resident-"))
.map(|(_, v)| bytes(v))
.sum();
let memory: u64 = lines
.iter()
.filter(|(k, _)| k.starts_with("drm-memory-"))
.map(|(_, v)| bytes(v))
.sum();
drm += resident.max(memory);
}
}
let rss = std::fs::read_to_string("/proc/self/status")
.ok()
.and_then(|status| {
status
.lines()
.find_map(|line| line.strip_prefix("VmRSS:").map(bytes))
})
.unwrap_or(0);
(drm, rss)
}
/// A measurement device: the in-place policy, without the validation layer, its check settled.
fn measured_device(cache: &ScratchCache, messages: &Messages) -> Device {
let device = validated_device_with(TEST_DEVICE, messages, cache.path(), |options| {
options.layers.clear();
in_place(options);
})
.unwrap();
assert!(
device.settle_in_place_checks(CHECK_WAIT),
"the check settles"
);
device
}
/// What one case's frames moved and took, printed as an `ALIASED-SURFACE-COST` line.
struct Tally {
times: Vec<f64>,
first: WorkCounts,
last: WorkCounts,
peak: (u64, u64),
}
impl Tally {
fn print(&self, device: &Device, case: &str, forms: &str) {
let mut times = self.times.clone();
times.sort_by(f64::total_cmp);
let frames = times.len() as f64;
let per = |f: fn(&WorkCounts) -> u64| (f(&self.last) - f(&self.first)) as f64 / frames;
let shadow = GUEST.0 * GUEST.1 * 4;
println!(
"ALIASED-SURFACE-COST {} {case}: {forms}; a frame's GPU time median {:.2} ms, slowest \
{:.2} ms; per frame: shadows made {:.1} ({:.0} MB), shadow copies {:.1}, texels \
copied in {:.0} ({:.0} MB), back {:.0} ({:.0} MB), merge words examined {:.0}, \
memory allocated {:.0} MB; peak device memory {:.0} MB (DRM), resident set {:.0} MB",
device.name(),
times[times.len() / 2] * 1e3,
times[times.len() - 1] * 1e3,
per(|c| c.shadowed_textures),
per(|c| c.shadowed_textures) * shadow as f64 / 1e6,
per(|c| c.shadow_copies),
per(|c| c.shadow_texels_copied_in),
per(|c| c.shadow_texels_copied_in) * 4.0 / 1e6,
per(|c| c.shadow_texels_copied_back),
per(|c| c.shadow_texels_copied_back) * 4.0 / 1e6,
per(|c| c.shadow_merge_words_examined),
per(|c| c.device_memory_allocated) / 1e6,
self.peak.0 as f64 / 1e6,
self.peak.1 as f64 / 1e6,
);
}
}
/// The format of the `i`th of the [`LIVE`] textures: [`LIVE_UINT`] of them `R32Uint`, spread
/// among the rest.
fn live_format(i: usize) -> PixelFormat {
match (i * LIVE_UINT) % LIVE < LIVE_UINT {
true => PixelFormat::R32Uint,
false => PixelFormat::BGRA8Unorm,
}
}
/// Run `frames` frames of `frame` (which returns the command buffer it committed), timed after
/// [`WARM`], the memory sampled after each.
fn tally(device: &Device, mut frame: impl FnMut(usize) -> f64) -> Tally {
let mut peak = memory_now();
for n in 0..WARM {
frame(n);
}
let first = device.work_counts();
let mut times = Vec::new();
for n in WARM..WARM + TIMED {
times.push(frame(n));
let (drm, rss) = memory_now();
peak = (peak.0.max(drm), peak.1.max(rss));
}
Tally {
times,
first,
last: device.work_counts(),
peak,
}
}
#[test]
#[ignore = "a release-mode measurement: run by name"]
fn aliased_surface_costs() {
let cache = ScratchCache::new().unwrap();
let messages = Messages::default();
let device = measured_device(&cache, &messages);
let kernels = Kernels::new(&device);
let queue = device.new_command_queue().unwrap();
let out = device
.new_buffer(READ * READ * 16, ResourceOptions::private())
.unwrap();
println!(
"ALIASED-SURFACE-COST {} start: device memory {:?} (DRM, resident set)",
device.name(),
memory_now()
);
for options in [ResourceOptions::private(), ResourceOptions::shared()] {
let storage = format!("{:?}", options.storage_mode());
// Live: the textures made once, a frame writing two and reading four.
{
let surface = made_surface(&device, GUEST_BYTES, options);
let before = device.work_counts();
let made: Vec<(Texture, TexturePlacement)> = (0..LIVE)
.map(|i| surface_texture(&surface, live_format(i), GUEST))
.collect();
let after = device.work_counts();
let shadows = after.shadowed_textures - before.shadowed_textures;
let pitched = after.pooled_pitched_images - before.pooled_pitched_images;
let forms = format!(
"{LIVE} textures over a {storage} surface, first answered {:?}, last {:?}: \
{shadows} shadows ({} MB), {pitched} images at Metal's pitch",
made[0].1,
made[LIVE - 1].1,
shadows * GUEST.0 * GUEST.1 * 4 / 1_000_000
);
let (uints, floats): (Vec<&Texture>, Vec<&Texture>) = made
.iter()
.map(|(t, _)| t)
.partition(|t| t.pixel_format() == PixelFormat::R32Uint);
let tally = tally(&device, |n| {
let command_buffer = queue.command_buffer().unwrap();
let word = 0x8040_2010 ^ n as u32;
kernels.fill(&command_buffer, floats[n % floats.len()], word, WRITTEN);
kernels.fill(&command_buffer, uints[n % uints.len()], word, WRITTEN);
for k in 1..3 {
kernels.read(&command_buffer, floats[(n + k) % floats.len()], &out, READ);
kernels.read(&command_buffer, uints[(n + k) % uints.len()], &out, READ);
}
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
command_buffer.gpu_end_time().unwrap() - command_buffer.gpu_start_time().unwrap()
});
tally.print(&device, "live", &forms);
}
// Transient: four textures made each frame and dropped after it, two written, two read.
{
let surface = made_surface(&device, GUEST_BYTES, options);
let mut answers = Vec::new();
let tally = tally(&device, |n| {
let made: Vec<(Texture, TexturePlacement)> = (0..TRANSIENT)
.map(|i| {
let format = match i % 2 {
0 => PixelFormat::BGRA8Unorm,
_ => PixelFormat::R32Uint,
};
surface_texture(&surface, format, GUEST)
})
.collect();
if answers.len() < 2 * TRANSIENT {
answers.extend(made.iter().map(|(_, answer)| *answer));
}
let command_buffer = queue.command_buffer().unwrap();
let word = 0x0102_0408 ^ n as u32;
kernels.fill(&command_buffer, &made[0].0, word, WRITTEN);
kernels.fill(&command_buffer, &made[1].0, word, WRITTEN);
kernels.read(&command_buffer, &made[2].0, &out, READ);
kernels.read(&command_buffer, &made[3].0, &out, READ);
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
command_buffer.gpu_end_time().unwrap() - command_buffer.gpu_start_time().unwrap()
});
let forms = format!(
"{TRANSIENT} textures a frame over a {storage} surface, the first two frames' \
answers {answers:?}"
);
tally.print(&device, "transient", &forms);
}
}
messages.take_notices();
}
@@ -1680,9 +1680,8 @@ const DEVICE_CACHES: [(u64, u64, u64, usize); 11] = [
/// [`DEVICE_CACHES`] over buffers that declare the bytes between rows unobserved
/// (`BufferDescriptor::padding_unobserved`) and over ones that do not, under the in-place policy
/// with the device's check settled. The undeclared ones are shadows (`shadowed_textures`); a
/// declared one is a `DRM_FORMAT_MOD_LINEAR` image at its pitch where the device's linear image
/// lays its rows out otherwise, its rows take no more than the pooled bound
/// (`TextureShadowReason::LinearCost` past it) and the device's check passed for its pooled memory
/// declared one is a `DRM_FORMAT_MOD_LINEAR` image at its pitch, at any size, where the device's
/// linear image lays its rows out otherwise and the device's check passed for its pooled memory
/// (`pooled_pitched_images`), else the device's linear image or a shadow. Each frame one command
/// buffer clears and stores every cache and then reads each whole through a fragment function's
/// `read`. Printed (`POOLED-PITCHED-COST`): each form's caches in place and as shadows, and the
@@ -1,782 +0,0 @@
//! What a device cache's draws cost as a shadow and in place at its pitch, on the device the cfg
//! selects, without the validation layer: report only, in release builds, to weigh the pooled
//! bound (`in_place::POOLED_PITCHED_BYTES`, `TextureShadowReason::LinearCost`) against how much
//! a frame draws into each cache.
//!
//! The textures are a guest's device caches, `BGRA8Unorm` with render target and shader read
//! usage over `Private` buffers of the runtime's own, [`TEXTURES`] of each of [`SHAPES`]: over
//! buffers that declare the bytes between rows unobserved (`BufferDescriptor::padding_unobserved`),
//! which lie in place at their pitch as a `DRM_FORMAT_MOD_LINEAR` image where the device takes one
//! and the bound allows, and over ones that do not, which are shadows. Each frame is one command
//! buffer: for each cache a pass that clears it and stores it, drawing each of [`DRAWS`] times a
//! rectangle over the whole cache blended premultiplied (`tob_rect`, `tob_solid`), then for each
//! cache a draw into a private target that reads it whole (`tob_read`), as
//! `in_place_textures::pooled_pitched_costs` does with no draw. [`WARM`] frames run untimed, then
//! [`TIMED`] frames are printed per shape, draws and form (`POOLED-DRAW-COST`): the caches in
//! place at their pitch and as shadows, the median and fastest GPU time of a frame, and the shadow
//! copies a frame.
//!
//! [`pooled_surface_costs`] weighs a guest window server's desktop device cache, past the bound,
//! against a private texture: frames of many passes into it, each its own encoder.
//!
//! [`pooled_sample_costs`] weighs caches a frame only samples, as a window server samples the
//! surfaces an app drew, over `Shared` buffers the CPU writes each frame and over `Private` ones:
//! at a padded pitch (a shadow past the bound) and at their tight one (the device's own linear
//! image, in place at any size).
//!
//! [`pooled_crossover_costs`] weighs one texture over a `Private` buffer, from 16 KiB to 4 MiB,
//! in place at its pitch against a shadow, as a compositor samples it each frame, the texture
//! changing every frame or every 60th: the pooled bound's crossover on the device.
//!
//! Ignored by default: measurements, not checks. Run them by name with `--run-ignored all`.
use super::attachment_reads::{floats, function};
use super::first_use_writes::CHECK_WAIT;
use super::in_place_textures::in_place;
use super::no_copy_textures::staged;
use super::pitched_surfaces::reading;
use super::{validated_device_with, Messages, ScratchCache, WAIT};
use crate::gpu::TEST_DEVICE;
use metal2vulkan::bind::SamplerDescriptor;
use metal2vulkan::metal::{
BlendFactor, PixelFormat, PrimitiveType, SamplerMinMagFilter, TextureUsage,
};
use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor};
use metal2vulkan_runtime::{
Buffer, BufferContents, BufferDescriptor, ClearColor, Device, LoadAction, PipelineOptions,
RenderPassDescriptor, RenderPipelineState, ResourceOptions, ScissorRect, StoreAction, Texture,
TextureDescriptor, TexturePlacement, TextureShadowReason,
};
/// The caches' shapes, (width, rows, row bytes): the consumer's three most common device caches
/// on the Iris Xe and the shapes of the sweep behind the pooled bound, from 23 KB to 1.36 MB.
const SHAPES: [(u64, u64, u64); 9] = [
(104, 52, 448),
(136, 68, 576),
(172, 67, 704),
(250, 125, 1024),
(200, 200, 832),
(250, 250, 1024),
(360, 360, 1472),
(540, 270, 2176),
(820, 410, 3328),
];
/// The caches of each shape a frame draws.
const TEXTURES: usize = 4;
/// The draws into each cache a frame.
const DRAWS: [usize; 4] = [0, 1, 4, 16];
/// The untimed and the timed frames of each case.
const WARM: usize = 5;
const TIMED: usize = 40;
/// A device of the in-place policy, without the validation layer, its in-place check settled.
fn settled_device(cache: &ScratchCache, messages: &Messages) -> Device {
let device = validated_device_with(TEST_DEVICE, messages, cache.path(), |options| {
options.layers.clear();
in_place(options);
})
.unwrap();
assert!(
device.settle_in_place_checks(CHECK_WAIT),
"the check settles"
);
device
}
/// The `tob_rect` and `tob_solid` state into a color of `pf`, blended premultiplied.
fn blending(device: &Device, pf: PixelFormat) -> RenderPipelineState {
let mut d = RenderPipelineDescriptor::new(function(device, "tob_rect", "tob_renders.ll"));
d.fragment = Some(function(device, "tob_solid", "tob_renders.ll"));
let mut color = ColorAttachmentDescriptor::new(pf);
color.blending_enabled = true;
color.source_rgb_blend_factor = BlendFactor::One;
color.source_alpha_blend_factor = BlendFactor::One;
color.destination_rgb_blend_factor = BlendFactor::OneMinusSourceAlpha;
color.destination_alpha_blend_factor = BlendFactor::OneMinusSourceAlpha;
d.color_attachments[0] = Some(color);
device
.new_render_pipeline_state(&d, &PipelineOptions::default())
.unwrap()
}
/// A `BGRA8Unorm` texture of render target and shader read usage, `w` by `h`, over a new `Private`
/// buffer of rows `bpr` apart, which declares the bytes between them unobserved where `declared`.
fn cache_texture(
device: &Device,
(w, h, bpr): (u64, u64, u64),
declared: bool,
) -> (Buffer, Texture) {
let descriptor =
BufferDescriptor::new(bpr * h, ResourceOptions::private(), BufferContents::Zero);
let descriptor = match declared {
true => descriptor.with_padding_unobserved(),
false => descriptor,
};
let buffer = device.new_buffer_with_descriptor(descriptor).unwrap();
let mut d = TextureDescriptor::texture_2d(PixelFormat::BGRA8Unorm, w, h, false);
d.usage = TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET;
d.resource_options = buffer.resource_options();
let texture = buffer.new_texture(&d, 0, bpr).unwrap();
(buffer, texture)
}
#[test]
#[ignore = "a release-mode measurement: run by name"]
fn pooled_draw_costs() {
let cache = ScratchCache::new().unwrap();
let messages = Messages::default();
let device = settled_device(&cache, &messages);
let queue = device.new_command_queue().unwrap();
let bgra = PixelFormat::BGRA8Unorm;
let reads = reading(&device, bgra, "tob_read");
let blends = blending(&device, bgra);
let corners = staged(&device, &floats([-1.0, -1.0, 1.0, 1.0]));
let half = floats([0.25, 0.125, 0.0625, 0.5]);
let mut d = TextureDescriptor::texture_2d(bgra, 1640, 820, false);
d.usage = TextureUsage::RENDER_TARGET;
d.resource_options = ResourceOptions::private();
let target = device.new_texture(&d).unwrap();
for (w, h, bpr) in SHAPES {
for declared in [false, true] {
let before = device.work_counts();
let caches: Vec<_> = (0..TEXTURES)
.map(|_| cache_texture(&device, (w, h, bpr), declared))
.collect();
let after = device.work_counts();
let pitched = after.pooled_pitched_images - before.pooled_pitched_images;
let shadows = after.shadowed_textures - before.shadowed_textures;
for draws in DRAWS {
let frame = |n: usize| {
let command_buffer = queue.command_buffer().unwrap();
for (_, texture) in &caches {
let mut pass = RenderPassDescriptor::new();
let color = &mut pass.color_attachments[0];
color.texture = Some(texture.clone());
color.load_action = LoadAction::Clear;
color.clear_color = ClearColor::new(n as f64 / 64.0, 0.5, 0.25, 1.0);
color.store_action = StoreAction::Store;
let mut encoder = command_buffer.render_command_encoder(&pass).unwrap();
if draws > 0 {
encoder.set_render_pipeline_state(&blends).unwrap();
encoder.set_vertex_buffer(Some(&corners), 0, 0).unwrap();
encoder.set_fragment_bytes(&half, 0).unwrap();
}
for _ in 0..draws {
encoder
.draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0)
.unwrap();
}
encoder.end_encoding().unwrap();
}
for (_, texture) in &caches {
let mut pass = RenderPassDescriptor::new();
let color = &mut pass.color_attachments[0];
color.texture = Some(target.clone());
color.load_action = LoadAction::DontCare;
color.store_action = StoreAction::Store;
let mut encoder = command_buffer.render_command_encoder(&pass).unwrap();
encoder.set_render_pipeline_state(&reads).unwrap();
encoder
.set_scissor_rect(ScissorRect::new(0, 0, w, h))
.unwrap();
encoder.set_vertex_buffer(Some(&corners), 0, 0).unwrap();
encoder.set_fragment_texture(Some(texture), 0).unwrap();
encoder
.draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0)
.unwrap();
encoder.end_encoding().unwrap();
}
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
command_buffer.gpu_end_time().unwrap()
- command_buffer.gpu_start_time().unwrap()
};
for n in 0..WARM {
frame(n);
}
let copies = device.work_counts().shadow_copies;
let mut times: Vec<f64> = (WARM..WARM + TIMED).map(&frame).collect();
let copies = device.work_counts().shadow_copies - copies;
times.sort_by(f64::total_cmp);
println!(
"POOLED-DRAW-COST {} {TEXTURES} caches {w}x{h} at {bpr} ({} KB) {draws} draws \
each, declared {declared}: {pitched} in place at their pitch, {shadows} \
shadows; a frame's GPU time median {:.1} us, fastest {:.1} us; shadow copies \
{:.1} a frame",
device.name(),
bpr * h / 1000,
times[TIMED / 2] * 1e6,
times[0] * 1e6,
copies as f64 / TIMED as f64,
);
}
}
}
messages.take_notices();
}
/// The `pooled_surface_costs` caches, (width, rows, row bytes, declared): the guest window server's
/// desktop device cache at its 3662-texel width and 14848-byte rows, over a buffer that declares
/// its padding unobserved (past the pooled bound: `LinearCost`) and over one that does not; and the
/// 3648x2038 one of a guest whose modes are a multiple of 16 texels wide, at its 14592-byte rows.
const SURFACES: [(u64, u64, u64, bool); 3] = [
(3662, 2038, 14848, true),
(3662, 2038, 14848, false),
(3648, 2038, 14592, true),
];
/// The passes of a `pooled_surface_costs` frame, and the draws of each.
const SURFACE_PASSES: [usize; 3] = [1, 8, 30];
const SURFACE_DRAWS: usize = 3;
/// What a guest's desktop device cache costs a frame of render passes: over a private texture and
/// over each of [`SURFACES`], one command buffer a frame of each count of [`SURFACE_PASSES`]
/// passes, each an encoder of its own that loads and stores the cache and draws [`SURFACE_DRAWS`]
/// blended 600x400 rectangles at places of their own, through no scissor or through a scissor of
/// each rectangle; then a draw that reads the whole cache into a private target, as the
/// consumer's present samples it. Printed per case (`POOLED-SURFACE-COST`): the cache's form, the
/// median GPU time of a frame of [`TIMED`] after [`WARM`], and per frame the shadow copies and the
/// texels they copy in and back.
#[test]
#[ignore = "a release-mode measurement: run by name"]
fn pooled_surface_costs() {
let cache = ScratchCache::new().unwrap();
let messages = Messages::default();
let device = settled_device(&cache, &messages);
let queue = device.new_command_queue().unwrap();
let bgra = PixelFormat::BGRA8Unorm;
let reads = reading(&device, bgra, "tob_read");
let blends = blending(&device, bgra);
let whole = staged(&device, &floats([-1.0, -1.0, 1.0, 1.0]));
let half = floats([0.25, 0.125, 0.0625, 0.5]);
let mut d = TextureDescriptor::texture_2d(bgra, 3662, 2038, false);
d.usage = TextureUsage::RENDER_TARGET;
d.resource_options = ResourceOptions::private();
let presented = device.new_texture(&d).unwrap();
d.usage = TextureUsage::RENDER_TARGET | TextureUsage::SHADER_READ;
let private = device.new_texture(&d).unwrap();
let mut caches = vec![(private, "private".to_owned(), None)];
for (w, h, bpr, declared) in SURFACES {
let before = device.work_counts();
let (buffer, texture) = cache_texture(&device, (w, h, bpr), declared);
let after = device.work_counts();
let form = match after.shadowed_textures - before.shadowed_textures {
0 => "in place",
_ => "a shadow",
};
caches.push((
texture,
format!("{w}x{h} at {bpr}, declared {declared}, {form}"),
Some(buffer),
));
}
for (texture, kind, _) in &caches {
let (w, h) = (texture.width(), texture.height());
let rect = |n: usize| {
let n = n as u64;
let (x, y) = (n * 1373 % (w - 600), (n * 3 + 1) * 787 % (h - 400));
[x, y, x + 600, y + 400]
};
let corners = |[x0, y0, x1, y1]: [u64; 4]| {
let x = |p: u64| p as f32 / w as f32 * 2.0 - 1.0;
let y = |p: u64| 1.0 - p as f32 / h as f32 * 2.0;
floats([x(x0), y(y1), x(x1), y(y0)])
};
for passes in SURFACE_PASSES {
for scissored in [false, true] {
let frame = |n: usize| {
let command_buffer = queue.command_buffer().unwrap();
for pass in 0..passes {
let mut d = RenderPassDescriptor::new();
let color = &mut d.color_attachments[0];
color.texture = Some(texture.clone());
color.load_action = LoadAction::Load;
color.store_action = StoreAction::Store;
let mut encoder = command_buffer.render_command_encoder(&d).unwrap();
encoder.set_render_pipeline_state(&blends).unwrap();
encoder.set_fragment_bytes(&half, 0).unwrap();
for draw in 0..SURFACE_DRAWS {
let r @ [x0, y0, x1, y1] = rect(n + pass * SURFACE_DRAWS + draw);
if scissored {
encoder
.set_scissor_rect(ScissorRect::new(x0, y0, x1 - x0, y1 - y0))
.unwrap();
}
encoder.set_vertex_bytes(&corners(r), 0).unwrap();
encoder
.draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0)
.unwrap();
}
encoder.end_encoding().unwrap();
}
let mut d = RenderPassDescriptor::new();
let color = &mut d.color_attachments[0];
color.texture = Some(presented.clone());
color.load_action = LoadAction::DontCare;
color.store_action = StoreAction::Store;
let mut encoder = command_buffer.render_command_encoder(&d).unwrap();
encoder.set_render_pipeline_state(&reads).unwrap();
encoder.set_vertex_buffer(Some(&whole), 0, 0).unwrap();
encoder.set_fragment_texture(Some(texture), 0).unwrap();
encoder
.draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0)
.unwrap();
encoder.end_encoding().unwrap();
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
command_buffer.gpu_end_time().unwrap()
- command_buffer.gpu_start_time().unwrap()
};
for n in 0..WARM {
frame(n);
}
let before = device.work_counts();
let mut times: Vec<f64> = (WARM..WARM + TIMED).map(&frame).collect();
let after = device.work_counts();
times.sort_by(f64::total_cmp);
let per = |a: u64, b: u64| (b - a) as f64 / TIMED as f64;
println!(
"POOLED-SURFACE-COST {} {kind}: {passes} passes of {SURFACE_DRAWS} draws, \
scissored {scissored}: GPU {:.3} ms/frame (median); per frame: shadow copies \
{:.1}, texels copied in {:.0}, back {:.0}",
device.name(),
times[TIMED / 2] * 1e3,
per(before.shadow_copies, after.shadow_copies),
per(
before.shadow_texels_copied_in,
after.shadow_texels_copied_in
),
per(
before.shadow_texels_copied_back,
after.shadow_texels_copied_back
),
);
}
}
}
drop(caches);
messages.take_notices();
}
/// The `pooled_sample_costs` caches, (width, rows, padded row bytes): one of the consumer's common
/// small device caches, a browser's tile, a browser's window and the desktop; each also at its
/// tight rows, a multiple of the 16 bytes Metal's pitch takes here (each width a multiple of 4).
const SAMPLED: [(u64, u64, u64); 4] = [
(172, 67, 704),
(1308, 512, 5248),
(1324, 940, 5312),
(3648, 2038, 14848),
];
/// What a frame that samples each cache whole costs: [`TEXTURES`] `BGRA8Unorm` textures of shader
/// read usage alone of each of [`SAMPLED`] at its padded pitch over a buffer that declares its
/// padding unobserved and at its tight one, over `Shared` buffers whose first texels the CPU
/// writes before each frame's commit and over `Private` ones; each frame one command buffer of a
/// draw into a private target that reads each texture whole (`tob_read`). Printed per case
/// (`POOLED-SAMPLE-COST`): the textures in place and as shadows, the median GPU time of a frame of
/// [`TIMED`] after [`WARM`], and per frame the shadow copies and the texels they copy in.
#[test]
#[ignore = "a release-mode measurement: run by name"]
fn pooled_sample_costs() {
let cache = ScratchCache::new().unwrap();
let messages = Messages::default();
let device = settled_device(&cache, &messages);
let queue = device.new_command_queue().unwrap();
let bgra = PixelFormat::BGRA8Unorm;
let reads = reading(&device, bgra, "tob_read");
let corners = staged(&device, &floats([-1.0, -1.0, 1.0, 1.0]));
let mut d = TextureDescriptor::texture_2d(bgra, 3648, 2038, false);
d.usage = TextureUsage::RENDER_TARGET;
d.resource_options = ResourceOptions::private();
let target = device.new_texture(&d).unwrap();
for (w, h, padded) in SAMPLED {
for options in [ResourceOptions::shared(), ResourceOptions::private()] {
for bpr in [padded, 4 * w] {
let before = device.work_counts();
let textures: Vec<_> = (0..TEXTURES)
.map(|_| {
let descriptor =
BufferDescriptor::new(bpr * h, options, BufferContents::Zero)
.with_padding_unobserved();
let buffer = device.new_buffer_with_descriptor(descriptor).unwrap();
let mut d = TextureDescriptor::texture_2d(bgra, w, h, false);
d.usage = TextureUsage::SHADER_READ;
d.resource_options = buffer.resource_options();
let texture = buffer.new_texture(&d, 0, bpr).unwrap();
(buffer, texture)
})
.collect();
let after = device.work_counts();
let shadows = after.shadowed_textures - before.shadowed_textures;
let frame = |n: usize| {
for (buffer, _) in &textures {
if let Some(contents) = buffer.contents() {
let texel = [n as u8, 0x40, 0x80, 0xff];
// SAFETY: a `Shared` buffer of at least a texel, which no command
// uses now (the frame before was waited for).
unsafe {
std::ptr::copy_nonoverlapping(texel.as_ptr(), contents.as_ptr(), 4)
};
}
}
let command_buffer = queue.command_buffer().unwrap();
let mut pass = RenderPassDescriptor::new();
let color = &mut pass.color_attachments[0];
color.texture = Some(target.clone());
color.load_action = LoadAction::DontCare;
color.store_action = StoreAction::Store;
let mut encoder = command_buffer.render_command_encoder(&pass).unwrap();
encoder.set_render_pipeline_state(&reads).unwrap();
encoder.set_vertex_buffer(Some(&corners), 0, 0).unwrap();
encoder
.set_scissor_rect(ScissorRect::new(0, 0, w, h))
.unwrap();
for (_, texture) in &textures {
encoder.set_fragment_texture(Some(texture), 0).unwrap();
encoder
.draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0)
.unwrap();
}
encoder.end_encoding().unwrap();
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
command_buffer.gpu_end_time().unwrap()
- command_buffer.gpu_start_time().unwrap()
};
for n in 0..WARM {
frame(n);
}
let before = device.work_counts();
let mut times: Vec<f64> = (WARM..WARM + TIMED).map(&frame).collect();
let after = device.work_counts();
times.sort_by(f64::total_cmp);
let per = |a: u64, b: u64| (b - a) as f64 / TIMED as f64;
println!(
"POOLED-SAMPLE-COST {} {TEXTURES} textures {w}x{h} at {bpr} ({} KB) over {:?} \
buffers: {} in place, {shadows} shadows; a frame's GPU time median {:.1} us; \
per frame: shadow copies {:.1}, texels copied in {:.0}",
device.name(),
bpr * h / 1000,
options.storage_mode(),
TEXTURES as u64 - shadows,
times[TIMED / 2] * 1e6,
per(before.shadow_copies, after.shadow_copies),
per(
before.shadow_texels_copied_in,
after.shadow_texels_copied_in
),
);
}
}
}
messages.take_notices();
}
/// The `pooled_crossover_costs` textures, (bytes of a row's texels, rows, row bytes): from 16 KiB
/// to 4 MiB to their pitch, each pitch a multiple of 256 bytes at least 256 past the multiple of
/// 256 its texels' bytes round up to, so that no device's own linear image lays rows there; and,
/// of `BGRA8Unorm`, the shape of a guest's most common shadow of its linear cost on an RTX 2080
/// (723x625 at 3072-byte rows), which a device that lays linear rows on 256 bytes takes as its
/// own linear image.
const CROSSOVER: [(u64, u64, u64); 10] = [
(240, 32, 512),
(240, 64, 512),
(720, 64, 1024),
(720, 128, 1024),
(1760, 128, 2048),
(1760, 256, 2048),
(1760, 512, 2048),
(2892, 625, 3072),
(3840, 512, 4096),
(3840, 1024, 4096),
];
/// The frames from one change of a `pooled_crossover_costs` texture to the next.
const PERIODS: [usize; 2] = [1, 60];
/// The timed frames of each `pooled_crossover_costs` case: two changes at every 60th frame.
const CROSSOVER_TIMED: usize = 120;
/// How a `pooled_crossover_costs` texture changes: through a pass that clears it and draws a
/// blended rectangle over it whole (a shadow's image copied back after it), or through a blit that
/// copies its buffer's bytes whole from another buffer (a shadow's image copied in at its next
/// use).
#[derive(Clone, Copy, Debug)]
enum Change {
Render,
Blit,
}
/// What one texture over a `Private` buffer costs a frame in place at its pitch and as a shadow:
/// of `BGRA8Unorm` and `RGBA16Float`, render target and shader read usage, each of [`CROSSOVER`],
/// in place over a buffer that declares its padding unobserved, over which a one-row texture was
/// made first (so the measured one takes the `DRM_FORMAT_MOD_LINEAR` image at any size,
/// `texture_spans.rs`), and a shadow over one that does not declare it. Each frame is one command
/// buffer: every [`PERIODS`]th frame the texture changes ([`Change`]), then a draw samples it
/// whole, one texel a pixel through a linear filter (`tob_sample`), into a private target, as a
/// compositor draws a window's surface. [`WARM`] frames run untimed, then [`CROSSOVER_TIMED`]
/// frames; printed per case (`POOLED-CROSSOVER`): each form's mean GPU time and wall time (encode,
/// commit and wait) of a frame and the shadow's copies a frame. `POOLED-CROSSOVER-FORMS` names
/// each texture's placement as the query answers it and whether it was made in that form.
#[test]
#[ignore = "a release-mode measurement: run by name"]
fn pooled_crossover_costs() {
let cache = ScratchCache::new().unwrap();
let messages = Messages::default();
let device = settled_device(&cache, &messages);
let queue = device.new_command_queue().unwrap();
let bgra = PixelFormat::BGRA8Unorm;
let samples = reading(&device, bgra, "tob_sample");
let mut sd = SamplerDescriptor::new();
sd.min_filter = SamplerMinMagFilter::Linear;
sd.mag_filter = SamplerMinMagFilter::Linear;
let sampler = device.new_sampler_state(&sd).unwrap();
let corners = staged(&device, &floats([-1.0, -1.0, 1.0, 1.0]));
let half = floats([0.25, 0.125, 0.0625, 0.5]);
let mut d = TextureDescriptor::texture_2d(bgra, 1024, 1024, false);
d.usage = TextureUsage::RENDER_TARGET;
d.resource_options = ResourceOptions::private();
let target = device.new_texture(&d).unwrap();
let private = ResourceOptions::private();
for (pf, texel) in [(bgra, 4), (PixelFormat::RGBA16Float, 8)] {
let blends = blending(&device, pf);
for (row, h, bpr) in CROSSOVER {
let (w, bytes) = (row / texel, bpr * h);
let mut d = TextureDescriptor::texture_2d(pf, w, h, false);
d.usage = TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET;
d.resource_options = private;
let declared = BufferDescriptor::new(bytes, private, BufferContents::Zero)
.with_padding_unobserved();
let aliased = device.new_buffer_with_descriptor(declared).unwrap();
let mut first = d;
first.height = 1;
let first = aliased.new_texture(&first, 0, bpr).unwrap();
let placed_in = aliased.texture_placement(&d, 0, bpr).unwrap();
let before = device.work_counts();
let placed = aliased.new_texture(&d, 0, bpr).unwrap();
let after = device.work_counts();
let in_place_made = after.shadowed_textures == before.shadowed_textures
&& after.pooled_pitched_images > before.pooled_pitched_images;
let plain = BufferDescriptor::new(bytes, private, BufferContents::Zero);
let plain = device.new_buffer_with_descriptor(plain).unwrap();
let placed_shadow = plain.texture_placement(&d, 0, bpr).unwrap();
let before = device.work_counts();
let shadow = plain.new_texture(&d, 0, bpr).unwrap();
let shadow_made = device.work_counts().shadowed_textures > before.shadowed_textures;
println!(
"POOLED-CROSSOVER-FORMS {} {pf:?} {w}x{h} at {bpr} ({bytes} bytes): in place \
{placed_in:?}, made {in_place_made}; shadow {placed_shadow:?}, made {shadow_made}",
device.name(),
);
let source = BufferDescriptor::new(bytes, private, BufferContents::Zero);
let source = device.new_buffer_with_descriptor(source).unwrap();
let forms = [
("in place", in_place_made, &aliased, &placed),
("shadow", shadow_made, &plain, &shadow),
];
for change in [Change::Render, Change::Blit] {
for period in PERIODS {
let mut costs = Vec::new();
for (form, made, buffer, texture) in forms {
if !made {
costs.push(format!("{form} not made"));
continue;
}
let frame = |n: usize| {
let start = std::time::Instant::now();
let command_buffer = queue.command_buffer().unwrap();
if n % period == 0 {
match change {
Change::Render => {
let mut pass = RenderPassDescriptor::new();
let color = &mut pass.color_attachments[0];
color.texture = Some(texture.clone());
color.load_action = LoadAction::Clear;
color.clear_color =
ClearColor::new(n as f64 / 256.0, 0.5, 0.25, 1.0);
color.store_action = StoreAction::Store;
let mut encoder =
command_buffer.render_command_encoder(&pass).unwrap();
encoder.set_render_pipeline_state(&blends).unwrap();
encoder.set_vertex_buffer(Some(&corners), 0, 0).unwrap();
encoder.set_fragment_bytes(&half, 0).unwrap();
encoder
.draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0)
.unwrap();
encoder.end_encoding().unwrap();
}
Change::Blit => {
let mut encoder =
command_buffer.blit_command_encoder().unwrap();
encoder
.copy_from_buffer_to_buffer(
&source, 0, buffer, 0, bytes,
)
.unwrap();
encoder.end_encoding().unwrap();
}
}
}
let mut pass = RenderPassDescriptor::new();
let color = &mut pass.color_attachments[0];
color.texture = Some(target.clone());
color.load_action = LoadAction::DontCare;
color.store_action = StoreAction::Store;
let mut encoder = command_buffer.render_command_encoder(&pass).unwrap();
encoder.set_render_pipeline_state(&samples).unwrap();
encoder
.set_scissor_rect(ScissorRect::new(0, 0, w, h))
.unwrap();
encoder.set_vertex_buffer(Some(&corners), 0, 0).unwrap();
encoder.set_fragment_texture(Some(texture), 0).unwrap();
encoder
.set_fragment_sampler_state(Some(&sampler), 0)
.unwrap();
encoder
.draw_primitives(PrimitiveType::Triangle, 0, 6, 1, 0)
.unwrap();
encoder.end_encoding().unwrap();
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
assert_eq!(command_buffer.error(), None);
let wall = start.elapsed().as_secs_f64();
let gpu = command_buffer.gpu_end_time().unwrap()
- command_buffer.gpu_start_time().unwrap();
(gpu, wall)
};
for n in 0..WARM {
frame(n);
}
let copies = device.work_counts().shadow_copies;
let times: Vec<(f64, f64)> =
(WARM..WARM + CROSSOVER_TIMED).map(&frame).collect();
let copies = device.work_counts().shadow_copies - copies;
let mean = |f: fn(&(f64, f64)) -> f64| {
times.iter().map(f).sum::<f64>() / CROSSOVER_TIMED as f64 * 1e6
};
costs.push(format!(
"{form} GPU {:.1} us wall {:.1} us copies {:.2}",
mean(|t| t.0),
mean(|t| t.1),
copies as f64 / CROSSOVER_TIMED as f64,
));
}
println!(
"POOLED-CROSSOVER {} {pf:?} {w}x{h} at {bpr} ({bytes} bytes) changes by \
{change:?} every {period}: {}",
device.name(),
costs.join("; "),
);
}
}
drop(first);
}
}
messages.take_notices();
}
/// A guest's textures that its boot on an RTX 2080 made shadows of their linear cost, over
/// `Private` buffers that declare their padding unobserved: (format, width, rows, row bytes,
/// usage, how many it made).
const GUEST_SET: [(PixelFormat, u64, u64, u64, TextureUsage, u64); 15] = [
(
PixelFormat::BGRA8Unorm,
723,
625,
3072,
SAMPLES_RENDERS,
661,
),
(PixelFormat::BGRA8Unorm, 6016, 6016, 24576, WRITES, 150),
(PixelFormat::R32Uint, 6016, 6016, 24576, WRITES, 66),
(
PixelFormat::RGBA16Float,
82,
82,
704,
TextureUsage::SHADER_READ,
13,
),
(
PixelFormat::RGBA16Float,
84,
81,
704,
TextureUsage::SHADER_READ,
10,
),
(PixelFormat::RGBA16Float, 82, 82, 704, SAMPLES_RENDERS, 9),
(PixelFormat::RGBA16Float, 84, 81, 704, SAMPLES_RENDERS, 8),
(PixelFormat::RGBA16Float, 84, 70, 704, SAMPLES_RENDERS, 6),
(PixelFormat::RGBA16Float, 116, 116, 960, SAMPLES_RENDERS, 4),
(
PixelFormat::RGBA16Float,
98,
64,
832,
TextureUsage::SHADER_READ,
4,
),
(PixelFormat::RGBA16Float, 74, 74, 1024, ALL_THREE, 4),
(PixelFormat::RGBA16Float, 70, 70, 1024, ALL_THREE, 3),
(PixelFormat::RGBA16Float, 70, 54, 1024, ALL_THREE, 3),
(PixelFormat::R32Uint, 299, 299, 1216, WRITES, 1),
(PixelFormat::BGRA8Unorm, 299, 299, 1216, READS_WRITES, 1),
];
const SAMPLES_RENDERS: TextureUsage = TextureUsage::SHADER_READ.union(TextureUsage::RENDER_TARGET);
const WRITES: TextureUsage = TextureUsage::SHADER_WRITE;
const READS_WRITES: TextureUsage = TextureUsage::SHADER_READ.union(TextureUsage::SHADER_WRITE);
const ALL_THREE: TextureUsage = SAMPLES_RENDERS.union(TextureUsage::SHADER_WRITE);
/// Where each of [`GUEST_SET`]'s textures lies on the device, as the placement query answers it
/// over a buffer of its own: alone over its bytes (the pooled bound read), and beside a one-row
/// texture made over them first (the image at Metal's pitch at any size, where the device makes
/// it). Printed per shape (`POOLED-GUEST-SET`) and summed, each weighed by how many the guest
/// made: textures in place, shadows of their linear cost, and other shadows.
#[test]
#[ignore = "a measurement: run by name"]
fn pooled_guest_set() {
let cache = ScratchCache::new().unwrap();
let messages = Messages::default();
let device = settled_device(&cache, &messages);
let private = ResourceOptions::private();
let kind = |placement: &TexturePlacement| match placement {
TexturePlacement::NotHostPages => 0,
TexturePlacement::Shadow(TextureShadowReason::LinearCost { .. }) => 1,
_ => 2,
};
let mut sums = [[0u64; 3]; 2];
for (pf, w, h, bpr, usage, made) in GUEST_SET {
let mut d = TextureDescriptor::texture_2d(pf, w, h, false);
d.usage = usage;
d.resource_options = private;
let descriptor =
BufferDescriptor::new(bpr * h, private, BufferContents::Zero).with_padding_unobserved();
let buffer = device.new_buffer_with_descriptor(descriptor).unwrap();
let alone = buffer.texture_placement(&d, 0, bpr).unwrap();
let mut row = d;
row.height = 1;
let first = buffer.new_texture(&row, 0, bpr).unwrap();
let beside = buffer.texture_placement(&d, 0, bpr).unwrap();
sums[0][kind(&alone)] += made;
sums[1][kind(&beside)] += made;
println!(
"POOLED-GUEST-SET {} {made} x {pf:?} {w}x{h} at {bpr} ({} bytes) {usage:?}: alone \
{alone:?}; beside another {beside:?}",
device.name(),
bpr * h,
);
drop(first);
}
for (sum, how) in sums.iter().zip(["alone", "beside another"]) {
println!(
"POOLED-GUEST-SET {} {how}: {} in place, {} shadows of their linear cost, {} other \
shadows",
device.name(),
sum[0],
sum[1],
sum[2],
);
}
messages.take_notices();
}
@@ -12727,7 +12727,6 @@ variant metal2vulkan-runtime::TextureProblem::ZeroExtent ZeroExtent
variant metal2vulkan-runtime::TextureShadowReason::BytesBetweenRows BytesBetweenRows
variant metal2vulkan-runtime::TextureShadowReason::CheckFailed CheckFailed { access: InPlaceAccess, row_ends: InPlaceRowEnds }
variant metal2vulkan-runtime::TextureShadowReason::DeviceCopy DeviceCopy
variant metal2vulkan-runtime::TextureShadowReason::LinearCost LinearCost { bytes: u64 }
variant metal2vulkan-runtime::TextureShadowReason::Mipmapped Mipmapped { levels: u32 }
variant metal2vulkan-runtime::TextureShadowReason::PastLength PastLength
variant metal2vulkan-runtime::TextureShadowReason::Policy Policy
Can't render this file because it is too large.
+2 -10
View File
@@ -1903,16 +1903,8 @@ bound.
the RX 550 makes no such image);
for one that renders, whose rows each to its
pitch share no line with bytes past them, the check of renders that lets the rows' padding
change, as the declaration does, and no byte past the last row's pitch); past a bound in bytes of its rows to their
pitch, the same on every device, such a texture over a `Private` buffer, tracked, stays a shadow
too (`TextureShadowReason::LinearCost`): there a linear image renders and samples slower than the
shadow's own image with its copies, and over memory only the runtime's commands write both give
the same answer, for one texture over the bytes (over a `Shared` or `Managed` buffer, for an
untracked texture, and over bytes another texture was made over, the image is taken at any size:
there each texture's shadow would be an image of its own, copied in whole at its first use and
again after a write through any other; the first texture's shadow moves to its image once
another texture is made over its bytes, at a quiet commit,
`WorkCounts::pooled_textures_moved_in_place`);
change, as the declaration does, and no byte past the last row's pitch), the image taken at any
size over any buffer of the runtime's own;
or the buffer is over the caller's
`VkBuffer`, whose memory backs no image of the runtime's; or it is a tiled texture of more than
one level (`Buffer::new_tiled_texture`), over any buffer: no image over the buffer's memory holds
+1 -1
View File
@@ -38,7 +38,7 @@ three consumer pipelines: A2X (`a2x-s4`, `a2x-s96`), Xgc14 (`xgc14-bgra8`) and X
| Batches of command buffers on one `VkQueue`, on a driver measured to start no kernel submission of a queue before the one before it completed (ANV, RADV and NVIDIA's; `batch_order.rs`), are ordered by their ends: each ends with a barrier ordering its work before every later command of its `VkQueue` (the exact form's end orders it before the host's reads and writes alone), so a batch that depends on an earlier one there begins with no barrier of its own, often no command buffer of barriers, and its first encoder's GPU start is written at the bottom of the pipe, once everything before it completed. Metal starts an independent command buffer committed behind running work while that work runs (an M3 Max under macOS 27.0.1, probe `gpustart`); those drivers ran two batches of independent work one after the other under every shape measured (no end barrier, the host's or the widened one; in one `vkQueueSubmit` or two, merged into one kernel submission or not), where two dispatches of one command buffer ran side by side. The runtime's: no pipeline differs. | `batch_order = BatchOrderPolicy::Ends` | `batch_order = BatchOrderPolicy::Exact`: a barrier for each dependency of a batch's work on an earlier batch's of its `VkQueue`, the end's barrier to the host's reads and writes alone, the GPU start written at the top of the pipe; every other driver takes it under either value | None: on those drivers each batch starts once the one before it completed under either value, so the work's order, its results and its GPU times are the same, and a batch's GPU start is the end of the work before it, when such a driver starts it. Not announced; `runtime_lane::commit_work` and `runtime_lane::gpu_times` test both values | UHD 770 (ANV, RPL-S), the consumer's frame shape over 520 host imports, 67 command buffers a frame, Grouped completion, the widened end barrier against the exact form (a probe build of each): with no fill ahead of each command buffer, 67.0 command buffers submitted a frame against 129.3-129.7, the GPU's span a frame 1.84-1.90 ms against 1.99-2.06 ms, a frame through completion 2.13-2.22 ms against 2.27-2.38 ms; with a 1 MiB fill ahead of each, 134.0 against 262.9, 8.03-8.22 ms against 8.32-8.42 ms, 9.00-9.15 ms against 9.25-9.36 ms. Radeon 780M (RADV, Mesa 26.0.8), this switch: with no fill, 67.0 against 128.9-129.0, a frame through completion 48.3-48.6 ms against 42.6-47.0 ms; with a 16 MiB fill committed at once, 134.0 against 251.0-251.1, 50.6-50.8 ms against 50.8-57.3 ms; committed every 1 ms, 134.0 against 249.7-250.2, 71.3-83.6 ms against 106.3-113.6 ms (each kernel submission there leaves about 2.5 ms of the GPU idle over 520 host imports, which sets these frames) |
| Command queues on a device whose GPU idles when consecutive work comes from another `VkQueue` share `VkQueue`s by choice (`queue_share.rs`): the runtime's own self-check, not a `DriverFact` row, measures that idling once per driver, release and runtime on a thread of its own and keeps its verdict (`Idles`, `DoesNotIdle`, `Unchecked`) in the shader cache's directory, as the in-place check keeps its own (`queue_switch_check.rs`: 48.7 to 51.3 us a switch on the RTX 5080 Laptop GPU, NVIDIA 615.71.09, `Idles` above 20 us). A command queue that makes a command buffer while it holds no other uncompleted one moves onto the busy `VkQueue` of its family whose oldest batch has run under 0.5 ms, the most batches in flight first, so short command buffers of several queues run with no switch between them. A queue one of whose command buffers ran on the GPU for over 2 ms, by its own timestamps (not the host's view of how long it ran as its `VkQueue`'s oldest, which also holds its wait for the GPU to start it and the waiter's lateness to see it complete), or held its `VkQueue` for over 2 ms from the submission of a batch that waited on the GPU for another `VkQueue`'s work (an `MTLEvent`'s signal, the tracker's wait, new resources' first work) to its own GPU end, is long: no queue joins its `VkQueue` while it lives, and it moves once more, at its next idle point, to an idle `VkQueue` no long or unshared queue holds. A queue whose command buffers must never wait behind another queue's (a compositor's beside an application's) is made with `Device::new_command_queue_unshared`: it never moves and no queue joins its `VkQueue`. Under either value, as a queue is made, it takes the round robin's `VkQueue` the fewest live command queues hold, of those no unshared queue holds, in turn among equals, and an unshared queue one no command queue holds where one is free (one pass over the `VkQueue`s' counts; one that finds none shares the one the fewest hold, `WorkCounts::unshared_queues_sharing_a_vk_queue`). Presenting queues and a queue that lent its `VkQueue` (`with_vk_queue`) never move. Before the verdict, and where it is not `Idles` or there are no two `VkQueue`s of one family (MoltenVK, RADV, lavapipe), every queue keeps the `VkQueue` it took at its creation; so does every queue of a device whose command buffers write no GPU timestamps it reads (`gpu_times_from_host`, or a driver whose timestamps wait for every queue's), which does not share and is counted (`WorkCounts::queue_sharing_untimed`). The runtime's: no pipeline differs. | `queue_sharing = QueueSharingPolicy::Adaptive` | `queue_sharing = QueueSharingPolicy::PerQueue`: each command queue keeps the `VkQueue` it took at its creation (the fewest live queues' as above), and the check does not run | A command buffer waits behind the command buffers of the queues sharing its `VkQueue`, where Metal's queues wait for each other only inside one command. The residual stall: once per logical queue that goes long, for a queue that joined its `VkQueue` during its short phase, about one long command buffer's length: the command buffers committed behind that queue's first long one there wait for its whole length (and those behind its later ones while it holds work, until its next idle point). Measured on the RTX 5080 Laptop GPU beside an application that alternates draws with 30 ms command buffers: a shared compositor's commits at 4,800 a second had 64 completions over 10 ms, at most 26.4 to 30.1 ms, in each of 3 runs of each of two such shapes (one join each), against none over 10 ms under `PerQueue` in those 6 runs (at most 5.6 to 9.7 ms); with 2 ms of draws between long command buffers, none over 10 ms in 3 runs (at most 5.7 to 9.8 ms) against 7, 0 and 0 under `PerQueue` (at most 6.9 to 11.2 ms). On an unshared queue, 0 over 10 ms in every run. A command buffer's GPU start time includes the other queues' work before it. `QueueSharing` (`queue-sharing`), at the device's first join | Command buffers a second on the RTX 5080 Laptop GPU, one-draw command buffers, each thread its own queue, the default against `PerQueue`, runs after a lock hold's first: 8 threads with 3 in flight 50.7k to 54.7k against 27.4k to 28.0k (5 runs each); 8 threads with 1 in flight 47.0k to 50.1k against 13.9k to 14.3k (5); 2 threads with 3 in flight 28.0k to 53.7k against 21.4k to 28.0k (10 each, in turn, the default above `PerQueue` in each pair; no thread's queue marked long), and beside another process's 30 ms command buffers 5.1k to 6.7k against 4.0k to 4.1k (3 each; the host's view marked a thread's queue long in 1 of 3 runs, which then ran at `PerQueue`'s 4.1k); 2 threads with 1 in flight 16.9k to 20.7k against 10.1k to 11.5k (5); one thread over 16 queues in turn 21.7k to 43.3k against 10.2k to 11.1k, over 2,048 20.0k to 39.2k against 10.2k to 11.2k (4). Beside an application whose queue never shared with the compositor (isolation, 300 and 30 dispatches), both 0 over 10 ms |
| A chain of `half` additions, subtractions and products on a device without `shaderFloat16` (vk12-floor, SwiftShader, Pascal; capability emulation: the module computes each in `float` and rounds it by the device's `OpQuantizeToF16`): an operation whose flags hold `contract` and `reassoc` and whose result only such operations read is held at `float` precision unrounded, so the chain rounds where a value leaves it (a store, an output, a conversion, a comparison, a call, a phi, a vector move, an operation without both flags), one quantize per exit instead of one per operation (`lower::arith::half_chain`). A device with `shaderFloat16` computes `half` alike under either value. | `half_chains = HalfChainPolicy::AtExits` | `half_chains = HalfChainPolicy::EachOperation`: every operation's result rounded to `half`, as the AIR computes it | The result may differ from the rounded operations' by the roundings the chain skips, each within half a unit in the last place of a `half` at its step, compounded along the chain; a value inside the chain past `half`'s range (65504) stays finite where the rounded operations reach infinity. Within the AIR's flags, which let a compiler regroup and fuse such operations. `FastMathRewrites` (`fast-math-rewrites`) | Not timed. Size on vk12-floor (the fixtures' SPIR-V words, the default against the accurate form): `hfb_filter_bank` 121,270 against 131,766 (1,024 quantizes against 2,464), `grd_half_many_samples` 82,019 against 84,627, `nan_half_fast` 9,808 against 9,832 |
| A texture that samples, reads, renders into it or is written through a shader (`ShaderWrite` or `ShaderAtomic` usage, of texels of 1, 2, 4, 8 or 16 bytes) over host pages (a no-copy buffer's, or a no-copy heap's buffer's, imported by their pointer or as dma-bufs; or a buffer in fresh pages; or a copied host buffer's copy of them, `copied.rs`, its image bound in the copy's memory where the check passed for the pages, and for the copy's fresh pages or, for a `DRM_FORMAT_MOD_LINEAR` image in memory the device allocates, its pooled memory, `WorkCounts::copied_textures_in_place`) is a linear image aliasing the pages in place, where the device makes the image (its format and usage linear, at the pages' pitch) and its own check shows that the operations Vulkan lets read and write every byte bound to it leave every byte alone while the CPU writes beside it: the image's first move (`VUID-VkImageCreateInfo-pNext-01443` makes such an image start `UNDEFINED`), and for one that renders a render pass's load and store operations and its moves into `ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT` and back, and for one a shader writes a kernel's storage writes of its texels (which of a linear image a driver may widen past a texel), each access checked apart (a shader's writes of 1- or 2-byte texels apart from those of wider ones, which a driver may store through a wider access), and each apart for texels that share a line of the device's memory (`nonCoherentAtomSize`, "the size and alignment in bytes that bounds concurrent access to host-mapped device memory") with bytes beside them and for texels that share none (their start, their end and, with bytes between rows, each row's start and end on a line; `in_place::RowEnds`): a byte changed beside texels that share none fails both, one changed beside texels that share one fails those alone (the Iris Xe, ANV, Mesa 26.2.6, whose clear and store, and draws, write back whole the 64-byte line that holds a row's last texels, fails renders, and writes, for rows that end inside a line, a byte between rows changed, and passes both for rows that end on one: a 3840x2160 `BGRA8Unorm` surface's 15360-byte rows are 240 lines each). A kernel's writes of a texture over a buffer's rows (no IOSurface plane's) whose rows, each to its pitch, start and end on a line, its buffer holding the last row to its pitch, take a verdict of their own from the same rounds, which a round that changed only bytes of its rows' padding (after a row's last texel, before its pitch, the last row's included) passes (`in_place::Padding`, `Access::BufferWrites`): Metal leaves those bytes to the GPU there (an Intel UHD Graphics 630 under macOS 26.7.1 wrote older values back over the CPU's writes to them under a kernel's writes of a texture over a buffer, the last row's included, where an M3 Max under macOS 27.0.1 and a Radeon Pro 5300M kept them, and all three kept them under draws, clears and stores and over IOSurfaces; `crates/metal2vulkan-conformance/probes/row_padding_writes.m`), and the rule follows the x86 Macs' envelope (docs/API.md, section 10, **Kernels**), so the Iris Xe's written textures over a buffer take the image in place whatever their rows' ends. A deliberate, scoped exception to relying on documented Vulkan behaviour alone, the owner's rulings (2026-10-26, and 2026-10-27 and 2026-11-07 for render targets and written textures: the GPU works on the caller's pages in place as a Mac's does, whatever a linear image costs it, on a discrete GPU too; `in_place.rs`). A texture over a buffer of the runtime's pooled memory whose rows the device's own linear image lays out otherwise (a padded pitch the driver does not take: ANV lays linear rows tight; rows apart only over a buffer that declares them unobserved, `BufferDescriptor::padding_unobserved`) is, by the same rule, a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch bound in the buffer's memory where the device makes one (no external memory, which Vulkan allows: `VUID-VkImageCreateInfo-tiling-02261`, `VUID-vkBindImageMemory-image-01445`), made `UNDEFINED` (`VUID-VkImageCreateInfo-initialLayout-12478`), whose first move the check's pooled class judges (`PagesClass::Pooled`: a buffer of that memory, its images at Metal's pitch alone; `WorkCounts::pooled_pitched_images`); a texture made before that class's verdict is a shadow that moves to that image once the verdict passes, as one over host pages moves in place (below; `WorkCounts::pooled_textures_moved_in_place`, `pooled_texture_shadows_freed_after_move`). A texture over a buffer whose memory the runtime exports (`exported_memory.rs`: a block that exportable buffers of one handle type share) is, by the same rule, the device's linear image or that `DRM_FORMAT_MOD_LINEAR` image made for the memory's handle type, which an image bound there must name (`VUID-vkBindImageMemory-memory-02728`), and so made `UNDEFINED` (`VUID-VkImageCreateInfo-pNext-01443`), whose first move the check's exported classes judge, one per handle tyLine truncated
| A texture that samples, reads, renders into it or is written through a shader (`ShaderWrite` or `ShaderAtomic` usage, of texels of 1, 2, 4, 8 or 16 bytes) over host pages (a no-copy buffer's, or a no-copy heap's buffer's, imported by their pointer or as dma-bufs; or a buffer in fresh pages; or a copied host buffer's copy of them, `copied.rs`, its image bound in the copy's memory where the check passed for the pages, and for the copy's fresh pages or, for a `DRM_FORMAT_MOD_LINEAR` image in memory the device allocates, its pooled memory, `WorkCounts::copied_textures_in_place`) is a linear image aliasing the pages in place, where the device makes the image (its format and usage linear, at the pages' pitch) and its own check shows that the operations Vulkan lets read and write every byte bound to it leave every byte alone while the CPU writes beside it: the image's first move (`VUID-VkImageCreateInfo-pNext-01443` makes such an image start `UNDEFINED`), and for one that renders a render pass's load and store operations and its moves into `ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT` and back, and for one a shader writes a kernel's storage writes of its texels (which of a linear image a driver may widen past a texel), each access checked apart (a shader's writes of 1- or 2-byte texels apart from those of wider ones, which a driver may store through a wider access), and each apart for texels that share a line of the device's memory (`nonCoherentAtomSize`, "the size and alignment in bytes that bounds concurrent access to host-mapped device memory") with bytes beside them and for texels that share none (their start, their end and, with bytes between rows, each row's start and end on a line; `in_place::RowEnds`): a byte changed beside texels that share none fails both, one changed beside texels that share one fails those alone (the Iris Xe, ANV, Mesa 26.2.6, whose clear and store, and draws, write back whole the 64-byte line that holds a row's last texels, fails renders, and writes, for rows that end inside a line, a byte between rows changed, and passes both for rows that end on one: a 3840x2160 `BGRA8Unorm` surface's 15360-byte rows are 240 lines each). A kernel's writes of a texture over a buffer's rows (no IOSurface plane's) whose rows, each to its pitch, start and end on a line, its buffer holding the last row to its pitch, take a verdict of their own from the same rounds, which a round that changed only bytes of its rows' padding (after a row's last texel, before its pitch, the last row's included) passes (`in_place::Padding`, `Access::BufferWrites`): Metal leaves those bytes to the GPU there (an Intel UHD Graphics 630 under macOS 26.7.1 wrote older values back over the CPU's writes to them under a kernel's writes of a texture over a buffer, the last row's included, where an M3 Max under macOS 27.0.1 and a Radeon Pro 5300M kept them, and all three kept them under draws, clears and stores and over IOSurfaces; `crates/metal2vulkan-conformance/probes/row_padding_writes.m`), and the rule follows the x86 Macs' envelope (docs/API.md, section 10, **Kernels**), so the Iris Xe's written textures over a buffer take the image in place whatever their rows' ends. A deliberate, scoped exception to relying on documented Vulkan behaviour alone, the owner's rulings (2026-10-26, and 2026-10-27 and 2026-11-07 for render targets and written textures: the GPU works on the caller's pages in place as a Mac's does, whatever a linear image costs it, on a discrete GPU too; `in_place.rs`). A texture over a buffer of the runtime's pooled memory whose rows the device's own linear image lays out otherwise (a padded pitch the driver does not take: ANV lays linear rows tight; rows apart only over a buffer that declares them unobserved, `BufferDescriptor::padding_unobserved`) is, by the same rule, a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch bound in the buffer's memory, at any size, where the device makes one (no external memory, which Vulkan allows: `VUID-VkImageCreateInfo-tiling-02261`, `VUID-vkBindImageMemory-image-01445`), made `UNDEFINED` (`VUID-VkImageCreateInfo-initialLayout-12478`), whose first move the check's pooled class judges (`PagesClass::Pooled`: a buffer of that memory, its images at Metal's pitch alone; `WorkCounts::pooled_pitched_images`); a texture made before that class's verdict is a shadow that moves to that image once the verdict passes, as one over host pages moves in place (below; `WorkCounts::pooled_textures_moved_in_place`, `pooled_texture_shadows_freed_after_move`). A texture over a buffer whose memory the runtime exports (`exported_memory.rs`: a block that exportable buffers of one handle type share) is, by the same rule, the device's linear image or that `DRM_FORMAT_MOD_LINEAR` image made for the memory's handle type, which an image bound there must name (`VUID-vkBindImageMemory-memory-02728`), and so made `UNDEFINED` (`VUID-VkImageCreateInfo-pNext-01443`), whose first move the check's exported classes judge, oneLine truncated
| A render or compute state's creation hands the driver's making of its predicted pipeline (`pipeline/predicted.rs`, `pipeline/dispatch_making.rs`) to the runtime's pool, kept by the state as a draw's or dispatch's making is, and waits for it `pipeline_creation_wait` at most; a committed command buffer's recordings wait until its commit plus `pipeline_commit_wait` at most, one deadline its commands share, for its draws' and dispatches' (a compute encoder's, a render pass's tile dispatches) pipelines still being made (the scheduler wakes at the bound, `StepWaits::until`), an execution's replayed draws (`render/pending.rs`) among them, whose pipelines the commit's settle hands to the pool (a device replay's, one recording for every command, waits until made under either value), then record each such command as nothing: a draw's barriers and visibility query, a dispatch's barrier (a tile dispatch's copies into its scratch and back), no draw or dispatch, the command buffer running on without error. The making goes on, and the command buffers after it draw and dispatch with the pipeline once made. Metal compiles inside `newRenderPipelineState`, so no draw of a made state waits or is dropped; a host that creates a state inside a command buffer's encoding (the consumer creates a guest's state at an execution's first lookup of it) held that execution through the driver's whole compile: 11.59 s inside one execution on an M2 Pro (MoltenVK 1.4.2, a cold Metal compiler service; a sample of such a stall finds the compile's thread waiting in `MVKMetalCompiler::compile` for Metal's compiler), past the guest's 10 s FIFO check, which ended the guest's task. Each bound is 4.5 s: a creation and a commit may fall in one step of the guest's FIFO (a task's jobs run one after another, and a draw's own variant waits under its command buffer's bound), and no runtime call waits for both, so one step waits 9 s at most for makings, under that 10 s check. A creation waits on no command buffer's deadline and a `commit` on no creation's; a `commit` waits until its own deadline at most (it records there what it can, an execution of render commands the CPU writes among them), every other recording on the scheduler's thread, a host step's on one of the steps' threads. Made until made under either value, in the call that makes them: a draw that records nothing, one in a pass of custom sample positions and one recorded again into another instance of its pass (each in the draw's call or an execution's replay), a device replay's draws (in its `commit`), and a failed making made again (`PipelineWaitPolicy`'s docs). The runtime's: no pipeline differs. | `pipeline_waits = PipelineWaitPolicy::Bounded`, `pipeline_creation_wait = 4.5 s`, `pipeline_commit_wait = 4.5 s` | `pipeline_waits = PipelineWaitPolicy::Exact`: the creation makes its predicted pipeline before it returns (a render state's first key on its own thread, the rest on the pool, joined; a compute state's on its own thread), an execution's settle makes its replayed draws' pipelines at the commit, and a command buffer waits for each draw's and dispatch's pipeline until it is made | A draw whose pipeline was still being made `pipeline_commit_wait` after its command buffer's commit renders nothing in that command buffer (only there: later ones draw it), where Metal's renders: content drawn once (a layer, a glyph cache) stays without it until redrawn. A creation returns after `pipeline_creation_wait` at most with its making in flight (`WorkCounts::creations_left_making`). `DrawDroppedStillMaking` (`draw-dropped-still-making`), at each such draw where `DeviceOptions::announce_each` asks, else once per device; `CommandBuffer::dropped_draw` names the first with `VK_TIMEOUT`; `WorkCounts::draws_dropped_still_making`; `deferred_calls::a_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing` and `under_the_exact_wait_a_held_making_holds_its_command_buffer_until_it_lands`. A dispatch whose pipeline was still being made then writes nothing in that command buffer, where Metal's runs: `DispatchDroppedStillMaking` (`dispatch-dropped-still-making`), `WorkCounts::dispatches_dropped_still_making`, the first named by `dropped_draw`; `deferred_calls::a_dispatch_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing`, `a_compute_state_s_creation_waits_its_bound_for_its_predicted_making` and `a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing` | No GPU cost. The exact form holds the creating thread, and the command buffer, for the whole compile: up to 11.59 s on the M2 Pro's cold boot (that boot's 2,483 render state creations, translation included: 300 over 16 ms, 151 over 100 ms, 14 over 250 ms, 3 over 1 s, the longest 11.59 s, 5.82 s and 1.17 s), where the default holds a creation for 4.5 s at most and a command buffer for 4.5 s from its commit, which drops the draws of the compiles that outlast those (2 of that boot's 2,483 were over 4.5 s) for the command bufferLine truncated
| A line Apple's `setLineWidth:` widens (`w' = floor(16 w) / 16`, other than 1), and a triangle's edge in fill mode `Lines`, is drawn by the device's own lines at `w'` wherever it draws that width (`wideLines`, `w'` in `lineWidthRange` and above 0), where Metal draws the parallelogram Vulkan's non-strict wide lines may be (`render/line_width.rs`). No device's are taken as it, announced on every device: a strict device's rectangle with square ends (lavapipe, NVIDIA), lines Vulkan does not state as parallelograms (ANV, and every width below 1), a width rounded to the granularity, and a driver's parallelograms (`strictLines` unset, `nonStrictWideLinesUseParallelogram` set), whose ends the driver places (RADV on the Radeon RX 7900 XTX draws 21 of `runtime_lane::line_widths`'s 48 scattered lines at width 2.5 a row or a column off Metal's at an end). A mesh draw's lines and edges and a tessellated patch draw's edges take the device's lines under either value, the band not drawing them (at the nearest width they draw where they do not draw `w'`, announced `lines-at-nearest-width`: a known gap below). The runtime's: no pipeline's code differs. | `wide_lines = WideLinePolicy::Device` | `wide_lines = WideLinePolicy::Exact`: a draw of lines or edges the device's lines draw is the pipeline's band variant (`VariantKey::line_band`, `pipeline::link::band`) on a device with `tessellationShader` (the device's lines where it has none, or where the translator refuses the state's band or the draw's): two triangles over each line's parallelogram, and each triangle's three edges' parallelograms facing as the triangle, through a tessellation control and evaluation stage; every other width other than 1 is the band under either value | The lines can cover pixels the parallelogram does not, and miss others, at each end and along each edge: up to half the width past each end (square ends), a rounded width, and a row or a column at an end (a driver's parallelograms). `DeviceWideLines` (`device-wide-lines`), at each such draw where `DeviceOptions::announce_each` asks, else once per device; `WorkCounts::device_wide_line_draws`, `line_band_draws`, `nearest_width_line_draws`; `runtime_lane::line_widths` (the band matches Metal's maps of lines and of triangles' edges, their facing, culling, flat inputs, primitive IDs and depth on MoltenVK under both values, which has no `wideLines`; a band of edges under a depth bias is announced `wide-edge-depth-bias`) | Not measured. Expected from the band's form: a second pipeline variant made for each render state that draws such lines or edges (its two synthesized stages), each line tessellated as a patch of two control points into four corners and each triangle as a patch of three into 21 triangles (12 degenerate), and a strip, loop or fan drawn as the list of its primitives |
| A blit or fill through a `BGRA10_XR` or `BGRA10_XR_sRGB` texture Metal keeps losslessly compressed (`allowGPUOptimizedContents`, 16 texels or more a side, neither `ShaderWrite` nor `PixelFormatView` usage, one sample, not over a buffer) is the device's copy, which keeps the bytes it moves, on every device: Metal's GPU blit into, out of or between such textures moves the texels through its compression, which writes each 16-bit field's low six bits cleared and the alpha code clamped to `[384, 894]`, and its fill clears the low six bits alone (an Apple M3 Max under macOS 27.0.1, every direction, storage mode, usage and size that decides the compression; CPU copies keep the bytes on Metal too). A pass's draws through such an attachment are the device-gap row below. The runtime's choice: no pipeline differs (`compressed_blit.rs`). | `extended_range_blits = ExtendedRangeBlitPolicy::Kept` | `extended_range_blits = ExtendedRangeBlitPolicy::Canonical`: after a blit writes such a texture's region, or a blit out of one writes a buffer's words, a texture over a buffer's or another texture's, a compute dispatch (`bind::extended_canonical_module`, `extended_canonical.rs`) rewrites the texels it wrote in Metal's encoding: in place in a buffer's bytes, an image's through a scratch buffer, a copy out and back around the dispatch; a fill's texel is encoded before it is written. A buffer whose words the device cannot bind (an offset or pitch off 4 bytes, a region past `maxStorageBufferRange`) and a texture over a buffer whose rows share bytes keep the bytes under either value, announced | Bytes no Metal write left (uploaded, CPU-copied or kernel-written texels: a field's low six bits, an alpha code outside `[384, 894]`) keep what Metal's blit would rewrite; a texel reads the same value either way, its low six bits unread and its alpha read clamped. `ExtendedRangeBitsKept` (`extended-range-bits-kept`), once per device; under `Canonical` not for the blits it makes exact; `runtime_lane::compressed_blits` (both values on MoltenVK), the conformance cases `compressed-blits-bgra10xr` and `compressed-blits-bgra10xr-srgb` | Measured, `Canonical` against `Kept`, on `Private` `BGRA10_XR` textures Metal keeps compressed (the sRGB twin and fills not measured), 256x256 and 2048x2048, one whole-texture blit a command buffer: p50 of 300 blits a run, the two values interleaved in one process, three runs a host. RTX 5080 Laptop (NVIDIA 615.71.09, the command buffer's GPU time): a buffer into the texture 23.5 against 11.5 us and 761 against 244 us from a `Private` buffer, 42 against 30 us and 1,945 against 1,176 us from a `Shared` one; the texture into a `Private` buffer 14.1 against 11.2 us and 287 against 246 us, into a `Shared` one, whose words the dispatch rewrites in system memory, 66 against 27 us and 3,386 against 1,182 us; texture into texture 22.5 against 9.7 us and 630 against 80 us. Apple M3 Max (MoltenVK 1.4.2, whose GPU times are the host's, so per blit of 16 in one command buffer), the same blits: into the texture +38 to +57 us and +536 to +548 us, out of it into a buffer +15 us and +84 to +94 us, texture into texture +46 to +48 us and +535 to +541 us. Every figure is above its `Kept` one in every run, by more than the runs' spread (under 1 us on the 5080): measurable at both sizes on both hosts. Into an image a blit adds a copy out into a scratch buffer of the region's size, the dispatch, a copy back and the barriers between them; into a buffer the dispatch and a barrier. The scratch is made without zeros, since the copy out writes every byte the dispatch and the copy back read; the figures above were taken while it was zeroed first, by a command buffer of its own (a fill on the 5080, a copy on MoltenVK). CPU from the command buffer's making through its commit, a blit alone: +1 to +3 us on the M3 Max, +1 to +127 us on the 5080, whose host other builds loaded; 16 blits into 2048x2048 images in one command buffer hold 16 scratch buffers of 32 MiB, and encoding each costs 141 to 165 us (5080) and 286 to 356 us (M3 Max), new memory blocks among it, against 2 to 6 us under `Kept`. Nothing for a texture Metal keeps uncompressed or of another format |
+1 -5
View File
@@ -391,11 +391,7 @@ over it is then a linear image at its pitch wherever the device lays one out so,
the device makes `DRM_FORMAT_MOD_LINEAR` images (`VK_EXT_image_drm_format_modifier`), one at the
pitch where its in-place check passed for its pooled memory (for a texture that renders, the
check of renders that lets a pass change those bytes, as the declaration does, and no byte past the
last row's pitch) and, for a tracked texture over a `Private` buffer, its rows take no more bytes
than a bound past which such an image renders and samples slower than the shadow (over a `Shared`
or `Managed` buffer, for an untracked texture, and over bytes another texture was made over, any
size; the first texture's shadow moves to its image once another is made over its bytes)
(`WorkCounts::pooled_pitched_images`; `TextureShadowReason::LinearCost` past it;
last row's pitch), at any size (`WorkCounts::pooled_pitched_images`;
`HostPageTexturePolicy::Shadow` turns it off; one made before that check answered is a shadow
that moves to the image at a quiet commit once it passed, as one over host pages moves in place,
`WorkCounts::pooled_textures_moved_in_place`), its subresources holding each row's bytes after its
+1 -1
View File
@@ -705,7 +705,7 @@ Each refusal's sites, with the function that builds it.
- `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs (require_seq_cst)`
- `feature::PostDepthCoverage`: `crates/metal2vulkan-runtime/src/families/features.rs (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`
- `feature::WideLines`: `crates/metal2vulkan/src/pipeline/link/band.rs (plan, 3 sites)`
- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs (host_copy)`; `crates/metal2vulkan-runtime/src/texture.rs (image)`; `crates/metal2vulkan-runtime/src/texture.rs (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs (storage_decided)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs (new_surface_planes_texture)`
- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs (host_copy)`; `crates/metal2vulkan-runtime/src/texture.rs (image)`; `crates/metal2vulkan-runtime/src/texture.rs (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs (new_surface_planes_texture)`
- `gap::ResourceHeap`: `crates/metal2vulkan-runtime/src/binding.rs (descriptor)`
- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs (make_aliasable)`
- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs (sparse_zeroing, 2 sites)`