rt: time a texture's and an exported surface's make by part

Seven new Metrics parts, each a Timed as the take's parts: image_creates
(vkCreateImage of a texture's, a shadow's and a surface plane's make), image_binds
(vkBindImageMemory of those images), image_view_creates (every vkCreateImageView),
texture_place_lock_waits (a texture placement's wait for the arrays' lock),
home_lock_waits (a new texture's, shadow's or acquired drawable's wait for the work
lock in Work::home), surface_allocations (an in-place surface's exportable
vkAllocateMemory) and surface_handles (each export of its handle). Counters only:
no policy, no switch. README parts list and api_signatures.tsv updated.

Tests: make_parts (a texture made at an index is one call of each texture part; an
in-place surface of one plane adds one allocation and one or three handle exports).

A texture's place in a texture block is not among the takes: only a texture block that the
place takes is; the place itself, under the places lock, is untimed (README).

Why: on the RTX 3090 (consumer walk m3-max-65677) 25 of 96 makes of 1 ms or more showed no part
rising on any thread; these parts time what such a make does that no part timed.

Driver calls made under a runtime lock, seen while adding the timers (no locking changed): the
arrays lock across vkUpdateDescriptorSets (Arrays::place_texture), and the work lock across
Upload::begin's vkCreateCommandPool, vkAllocateCommandBuffers, vkBeginCommandBuffer,
vkCreateQueryPool, vkResetQueryPool and vkCmdWriteTimestamp2 (Work::home). A lock wait counts in
the waiting make's own part; the holder's time is in no part.

Verified at f6c36e2e91: compile job m3-max-65788 (fmt, signatures, refusal surface, clippy
plain / --cfg m2v_gpu / --cfg m2v_cpu_icd, workspace Rustdoc -D warnings, api-docs) green; the
runtime suite on lavapipe 637 passed, 3 skipped, the make_parts tests with opaque-fd and dma-buf
surfaces made in place. The README sentence fix on top is not compiled or read by a test.
This commit is contained in:
Anees Iqbal committed 2026-11-21 20:38:38 -08:00
1 parent ed872f4dd2
commit 6cf6ee19d0
10 files changed
+272 -44

No files matched your search

+9 -1
View File
@@ -271,7 +271,15 @@ in its memory.
made its block), `export_allocations` (its `vkAllocateMemory`, exportable and dedicated to its
buffer), `export_handles` (the handle's export, `vkGetMemoryFdKHR` or
`vkGetMemoryWin32HandleKHR`) and `export_claims` (the block's claim, which enters the device's
map of claims); the rest of a make is the buffer's creation, the binding and the address.
map of claims); the rest of a make is the buffer's creation, the binding and the address. A
texture's make is timed by step: `image_creates` (`vkCreateImage`, a surface plane's too),
`image_binds` (`vkBindImageMemory`), `image_view_creates` (every `vkCreateImageView`),
`texture_place_lock_waits` (its placement's wait for the arrays' lock, at an index) and
`home_lock_waits` (its entry's wait for the work lock in the next commit's upload, which moves
it to its home layout). A texture block it takes is among the `takes`; its place in a block,
found under the texture blocks' lock, is not timed. An exported surface's in-place make adds
`surface_allocations` (its exportable `vkAllocateMemory`) and `surface_handles` (each export of
its handle).
- The runtime's fixed-size internals are made by the block-maker thread, never on a caller's
thread and never inside `Device::new`: its first work once `Device::new` starts it is the zero
source (64 KiB), the parameter ring's first block (2 MiB) and the staging region (16 MiB). The
+2 -2
View File
@@ -36,7 +36,7 @@
//! take 1 to 65,535, an index valid in both texture arrays; samplers 1 to 3,999. Index 0 is nil
//! and never granted.
use crate::counters::{Counters, Gauge, Metric};
use crate::counters::{Counters, Gauge, Metric, Part};
use crate::device::lock;
use crate::error::{Error, Limit, Refusal};
use crate::floor::{BelowFloor, Missing, SAMPLERS, SAMPLER_ARRAYS, TEXTURES};
@@ -366,7 +366,7 @@ impl Arrays {
),
looped: Option<vk::ImageView>,
) -> Result<Owner, Error> {
let mut grants = lock(&self.grants);
let mut grants = counters.time(Part::TexturePlaceLock, 0, || lock(&self.grants));
let Placed { owner, displaced } = grants.place(IndexClass::Texture, index)?;
if !displaced {
counters.rise(Gauge::DescriptorSlots);
+62 -9
View File
@@ -68,8 +68,8 @@ pub(crate) enum Stage {
GpuEndToHandler,
}
/// A part of the consumer's takes, buffer makes and exported block makes the runtime times,
/// counted on its own in [`Metrics`].
/// A part of the consumer's takes, buffer makes, exported block makes, texture makes and exported
/// surface makes the runtime times, counted on its own in [`Metrics`].
#[derive(Clone, Copy)]
pub(crate) enum Part {
/// [`Metrics::takes`].
@@ -94,10 +94,24 @@ pub(crate) enum Part {
ExportHandle,
/// [`Metrics::export_claims`].
ExportClaim,
/// [`Metrics::texture_place_lock_waits`].
TexturePlaceLock,
/// [`Metrics::home_lock_waits`].
HomeLock,
/// [`Metrics::image_creates`].
ImageCreate,
/// [`Metrics::image_binds`].
ImageBind,
/// [`Metrics::image_view_creates`].
ImageViewCreate,
/// [`Metrics::surface_allocations`].
SurfaceAllocation,
/// [`Metrics::surface_handles`].
SurfaceHandle,
}
/// The number of [`Part`]s.
const PARTS: usize = Part::ExportClaim as usize + 1;
const PARTS: usize = Part::SurfaceHandle as usize + 1;
/// Where a first-use wait made the `VkPipeline` it waited for ([`Metrics::first_use_waits`]).
#[derive(Clone, Copy)]
@@ -1161,6 +1175,14 @@ impl Counters {
}
}
/// `call`'s answer, the call timed as one of `part` of `bytes` bytes that made no allocation.
pub(crate) fn time<T>(&self, part: Part, bytes: u64, call: impl FnOnce() -> T) -> T {
let started = crate::host_time();
let answer = call();
self.timed(part, bytes, crate::host_time() - started, false);
answer
}
/// A call that waited `nanos` nanoseconds for the block-maker thread's make of an internal it
/// needs ([`Metrics::maker_waits`]).
pub(crate) fn maker_wait(&self, nanos: u64) {
@@ -1697,6 +1719,13 @@ impl Counters {
export_allocations: part(Part::ExportAllocation),
export_handles: part(Part::ExportHandle),
export_claims: part(Part::ExportClaim),
texture_place_lock_waits: part(Part::TexturePlaceLock),
home_lock_waits: part(Part::HomeLock),
image_creates: part(Part::ImageCreate),
image_binds: part(Part::ImageBind),
image_view_creates: part(Part::ImageViewCreate),
surface_allocations: part(Part::SurfaceAllocation),
surface_handles: part(Part::SurfaceHandle),
}
}
@@ -2566,11 +2595,34 @@ pub struct Metrics {
/// Of those makes, each claim of the made block, which enters it in the device's map of
/// claims; their bytes the allocations'.
pub export_claims: Timed,
/// Each wait of a texture's placement at its index for the arrays' lock, which every
/// placement and vacating of an index takes; no bytes.
pub texture_place_lock_waits: Timed,
/// Each wait for the submit side's work lock of a new texture's or shadow's entry, or an
/// acquired drawable's, in the next commit's upload, which moves it to its home layout; no
/// bytes.
pub home_lock_waits: Timed,
/// Each `vkCreateImage` of a texture's or a shadow's make and of an exported surface's
/// planes; their bytes the images' memory requirements'.
pub image_creates: Timed,
/// Each `vkBindImageMemory` of those images; their bytes the images' memory requirements'.
pub image_binds: Timed,
/// Each `vkCreateImageView`: a texture's own views (a drawable's and a surface plane's among
/// them), a texture view's, a shadow's and a render target's attachment views; no bytes.
pub image_view_creates: Timed,
/// Of the in-place makes of
/// [`Device::new_exported_surface`](crate::Device::new_exported_surface), each
/// `vkAllocateMemory` of the surface's exportable memory; their bytes the allocations'.
pub surface_allocations: Timed,
/// Of those makes, each export of the memory's handle (`vkGetMemoryFdKHR`,
/// `vkGetMemoryWin32HandleKHR`): one for an opaque handle, and for a dma-buf one for each
/// plane's import and two more; their bytes the allocation's.
pub surface_handles: Timed,
}
/// No Metal counterpart: the calls of one part of the consumer's takes, buffer makes and exported
/// block makes ([`Metrics::takes`] and the others'), each timed alone with
/// [`host_time`](crate::host_time).
/// No Metal counterpart: the calls of one part of the consumer's takes, buffer makes, exported
/// block makes, texture makes and exported surface makes ([`Metrics::takes`] and the others'),
/// each timed alone with [`host_time`](crate::host_time).
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Timed {
@@ -2587,9 +2639,10 @@ pub struct Timed {
/// [`longest_nanos`](Self::longest_nanos), from the same call.
pub longest_bytes: u64,
/// Whether the longest call made an allocation of its own: for
/// [`Metrics::takes`], a take no free range fit; every take make, maker make, export make and
/// export allocation is one ([`Metrics::take_makes`], [`Metrics::maker_makes`],
/// [`Metrics::export_makes`], [`Metrics::export_allocations`]); false for the other parts.
/// [`Metrics::takes`], a take no free range fit; every take make, maker make, export make,
/// export allocation and surface allocation is one ([`Metrics::take_makes`],
/// [`Metrics::maker_makes`], [`Metrics::export_makes`], [`Metrics::export_allocations`],
/// [`Metrics::surface_allocations`]); false for the other parts.
/// From the same call as [`longest_nanos`](Self::longest_nanos).
pub longest_made: bool,
/// Those longer than 1 ms.
+5 -1
View File
@@ -2450,7 +2450,8 @@ pub(crate) unsafe fn export(
/// device addresses, counted against the device's allocations ([`allocate`]), and its numbers. It
/// holds no buffer: the surface's plane images are bound in it, and its block's buffer is null
/// and its address 0. The surface's buffer, where the consumer asks for one, is bound in it later
/// ([`surface_view`]). Counted as an export.
/// ([`surface_view`]). Counted as an export; its `vkAllocateMemory` timed in
/// [`Metrics::surface_allocations`](crate::Metrics::surface_allocations).
///
/// Err: [`Limit::BlockLen`] past the device's longest allocation; [`Limit::MemoryAllocations`];
/// [`Limit::BlockIds`]; [`Error::Vulkan`] where the allocation fails.
@@ -2476,8 +2477,11 @@ pub(crate) unsafe fn export_surface(
.memory_type_index(index)
.push_next(&mut export)
.push_next(&mut flags);
let started = crate::host_time();
// SAFETY: the caller's; the type is the images'.
let memory = unsafe { allocate(device, &core.counters, core.max_allocations, &info, None) }?;
let nanos = crate::host_time() - started;
(core.counters).timed(Part::SurfaceAllocation, len, nanos, true);
let (id, allocation) = match core.pool.own_numbers() {
Ok(numbers) => numbers,
Err(error) => {
+2 -2
View File
@@ -62,7 +62,7 @@ use crate::buffer::{BufferInner, BufferObject, DeviceCopy};
use crate::capture::{self, Changes, CopyIn, Modified};
use crate::command::{self, CbInner, CommandBufferError, DeviceLoss, Handler, Pending, Segment};
use crate::complete;
use crate::counters::{Counters, Gauge, Metric, Site};
use crate::counters::{Counters, Gauge, Metric, Part, Site};
use crate::device::{lock, Core};
use crate::error::Error;
use crate::event::EventInner;
@@ -1034,7 +1034,7 @@ impl Work {
if image.copies_zeros() {
fill::zeros(core)?;
}
let mut state = self.lock();
let mut state = (core.counters).time(Part::HomeLock, 0, || self.lock());
if state.closed {
return Err(Error::Quiesced);
}
+32 -14
View File
@@ -25,7 +25,7 @@ use crate::block::Block;
use crate::buffer::{Buffer, BufferObject};
#[cfg(unix)]
use crate::counters::Gauge;
use crate::counters::Metric;
use crate::counters::{Metric, Part};
use crate::device::{lock, Core, Device};
use crate::error::{Error, Gap, Limit, Refusal};
use crate::export::{Export, ExportHandle};
@@ -659,13 +659,13 @@ struct Made {
/// Makes a plane's image of `format`, `usage` and view-format `list`, external as `handle`, in
/// `tiling`: for a dma-buf, `DRM_FORMAT_MOD_LINEAR` with the implicit list where `at` is `None`,
/// else the explicit layout at `at` (offset, pitch). Its requirements and its subresource layout
/// come with it.
/// come with it. Timed in [`Metrics::image_creates`](crate::Metrics::image_creates).
///
/// # Safety
///
/// The device makes such an image ([`Query::plane`] accepted it), its extensions enabled.
unsafe fn make_image(
device: &ash::Device,
core: &Core,
descriptor: &TextureDescriptor,
(format, usage, list): (vk::Format, vk::ImageUsageFlags, &[vk::Format]),
handle: ExportHandle,
@@ -723,8 +723,11 @@ unsafe fn make_image(
None => info.push_next(&mut implicit),
};
}
let device = &core.device;
let started = host_time();
// SAFETY: the caller's contract.
let image = unsafe { device.create_image(&info, None) }?;
let created = host_time() - started;
let mut dedicated = vk::MemoryDedicatedRequirements::default();
let mut needs = vk::MemoryRequirements2::default().push_next(&mut dedicated);
// SAFETY: the image is the device's.
@@ -734,6 +737,8 @@ unsafe fn make_image(
&mut needs,
)
};
let bytes = needs.memory_requirements.size;
(core.counters).timed(Part::ImageCreate, bytes, created, false);
let sub = vk::ImageSubresource {
aspect_mask: aspect,
mip_level: 0,
@@ -1006,7 +1011,7 @@ impl Device {
// SAFETY: the query accepted the image; the handle's extensions are enabled.
let image = unsafe {
make_image(
device,
core,
&plane.descriptor,
(plan.format, usage, &list),
spec.handle,
@@ -1063,10 +1068,11 @@ impl Device {
let block = Arc::new(memory::Block::new(memory, Arc::clone(core)));
step!("allocate");
for at in 0..made.len() {
let (image, start) = (made[at].image, starts[at]);
let (image, start, size) = (made[at].image, starts[at], made[at].needs.size);
// SAFETY: the allocation holds the image's size from its start, at its alignment, in a
// type its requirements list, exportable as a handle the image was made for.
if let Err(result) = unsafe { device.bind_image_memory(image, raw, start) } {
let bind = || unsafe { device.bind_image_memory(image, raw, start) };
if let Err(result) = core.counters.time(Part::ImageBind, size, bind) {
destroy(device, made);
return Err(Error::Vulkan {
call: "vkBindImageMemory",
@@ -1075,7 +1081,11 @@ impl Device {
}
}
step!("bind");
let fd = match core.exports.handle(raw, spec.handle) {
let bytes = block.memory.len;
let exported = core.counters.time(Part::SurfaceHandle, bytes, || {
core.exports.handle(raw, spec.handle)
});
let fd = match exported {
Ok(fd) => fd,
Err(error) => {
destroy(device, made);
@@ -1148,7 +1158,7 @@ impl Device {
// SAFETY: the query accepted the image; the extensions are enabled.
let implicit = unsafe {
make_image(
device,
core,
&plane.descriptor,
(plan.format, usage, &list),
spec.handle,
@@ -1181,7 +1191,7 @@ impl Device {
// SAFETY: as above; the layout is the driver's to refuse.
let stated = unsafe {
make_image(
device,
core,
&plane.descriptor,
parts,
spec.handle,
@@ -1197,7 +1207,7 @@ impl Device {
// SAFETY: as above.
let at_zero = unsafe {
make_image(
device,
core,
&plane.descriptor,
parts,
spec.handle,
@@ -1258,6 +1268,7 @@ impl Device {
.push_next(&mut export)
.push_next(&mut flags);
step!("layout");
let started = host_time();
// SAFETY: an exportable allocation of a type every image takes, bound to nothing.
let block = match unsafe {
memory::allocate(device, &core.counters, core.max_allocations, &info, None)
@@ -1268,6 +1279,11 @@ impl Device {
return Err(error);
}
};
(core.counters).timed(Part::SurfaceAllocation, len, host_time() - started, true);
let exported = || {
let handle = || core.exports.handle(block, spec.handle);
core.counters.time(Part::SurfaceHandle, len, handle)
};
step!("allocate");
let free_block = || {
// SAFETY: nothing is bound to the allocation; the imports and the handles hold the
@@ -1302,7 +1318,7 @@ impl Device {
for at in 0..made.len() {
let (image, image_bits, size) =
(made[at].image, made[at].needs.memory_type_bits, sizes[at]);
let fd = match core.exports.handle(block, spec.handle) {
let fd = match exported() {
Ok(fd) => fd,
Err(error) => return undo(imported, made, error),
};
@@ -1356,17 +1372,19 @@ impl Device {
imported.push(memory);
step!("import");
// SAFETY: the memory is the image's dedicated import, of its size and a type it lists.
if let Err(result) = unsafe { device.bind_image_memory(image, memory, 0) } {
let bind = || unsafe { device.bind_image_memory(image, memory, 0) };
let bound = (core.counters).time(Part::ImageBind, made[at].needs.size, bind);
if let Err(result) = bound {
return undo(imported, made, vulkan("vkBindImageMemory")(result));
}
step!("bind");
}
let handle = match core.exports.handle(block, spec.handle) {
let handle = match exported() {
Ok(fd) => fd,
Err(error) => return undo(imported, made, error),
};
// The runtime's own fd, which the surface's buffer's import duplicates.
let spare = match core.exports.handle(block, spec.handle) {
let spare = match exported() {
Ok(fd) => fd,
Err(error) => return undo(imported, made, error),
};
@@ -0,0 +1,129 @@
//! The timed parts of a texture's and an exported surface's make (`Metrics::image_creates` and
//! the others'), under a device cfg, on every device of the cfg's kind: a texture made at an index
//! is one image create and one bind, each of its image's bytes, one view create for its sampled
//! view, one wait for the arrays' lock and one for the work lock, and no surface part; a surface
//! of one plane made in place is, beside its plane's image, bind, view and wait for the work lock,
//! one allocation and one export of its handle (an opaque one) or three (a dma-buf, which makes its
//! plane's image twice), each of the allocation's bytes. A surface of the copy form is printed.
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
mod on_device {
use crate::tests::command::on_device::each_device;
use crate::{
ExportHandle, IndexClass, Metrics, PixelFormat, PlaneSpec, SurfaceForm, SurfaceSpec,
TextureDescriptor, TextureType, TextureUsage,
};
/// The calls and bytes each make part added from `before` to `after`, by name.
fn added(before: &Metrics, after: &Metrics) -> [(&'static str, u64, u64); 7] {
let parts = |m: &Metrics| {
[
("image creates", m.image_creates),
("image binds", m.image_binds),
("image view creates", m.image_view_creates),
("texture place lock waits", m.texture_place_lock_waits),
("home lock waits", m.home_lock_waits),
("surface allocations", m.surface_allocations),
("surface handles", m.surface_handles),
]
};
let (was, now) = (parts(before), parts(after));
std::array::from_fn(|at| {
let ((name, was), (_, now)) = (was[at], now[at]);
(name, now.count - was.count, now.bytes - was.bytes)
})
}
#[test]
fn every_device_times_a_textures_make_by_part() {
each_device("make_parts texture", |name, _, device| {
let _grant = (device.grant_indices(IndexClass::Texture, 1, 1))
.unwrap_or_else(|error| panic!("{name}: {error}"));
let mut d =
TextureDescriptor::new(TextureType::Type2D, PixelFormat::RGBA8Unorm, 64, 64);
d.usage = TextureUsage::SHADER_READ;
let counters = device.counters();
let before = counters.metrics();
let texture =
(device.new_texture(&d, Some(1))).unwrap_or_else(|error| panic!("{name}: {error}"));
let added = added(&before, &counters.metrics());
let bytes = added[0].2;
assert!(bytes >= 64 * 64 * 4, "{name}: {added:?}");
assert_eq!(
added,
[
("image creates", 1, bytes),
("image binds", 1, bytes),
("image view creates", 1, 0),
("texture place lock waits", 1, 0),
("home lock waits", 1, 0),
("surface allocations", 0, 0),
("surface handles", 0, 0),
],
"{name}"
);
drop(texture);
});
}
#[test]
fn every_device_times_an_exported_surfaces_make_by_part() {
each_device("make_parts surface", |name, _, device| {
for handle in ExportHandle::ALL {
let exports = &device.core().exports;
if !exports.offers(handle) || (handle.foreign() && !exports.foreign) {
continue;
}
let mut descriptor =
TextureDescriptor::new(TextureType::Type2D, PixelFormat::R8Unorm, 256, 64);
descriptor.usage = TextureUsage::SHADER_READ;
let planes = [PlaneSpec {
descriptor,
index: None,
rows_below: 0,
}];
let spec = SurfaceSpec {
handle,
pitch_multiple: 1,
start_multiple: 1,
planes: &planes,
};
let counters = device.counters();
let before = counters.metrics();
let (surface, export) = (device.new_exported_surface(&spec))
.unwrap_or_else(|error| panic!("{name}: {handle:?}: {error}"));
let added = added(&before, &counters.metrics());
println!(
"make_parts: {name}: {handle:?}: {:?}: {added:?}",
export.form
);
if export.form != SurfaceForm::InPlace {
assert_eq!((added[5].1, added[6].1), (0, 0), "{name}: {handle:?}");
continue;
}
let (size, dma) = (export.export.size, handle == ExportHandle::DmaBuf);
let (images, handles) = if dma { (2, 3) } else { (1, 1) };
let counts = added.map(|(part, count, _)| (part, count));
assert_eq!(
counts,
[
("image creates", images),
("image binds", 1),
("image view creates", 1),
("texture place lock waits", 0),
("home lock waits", 1),
("surface allocations", 1),
("surface handles", handles),
],
"{name}: {handle:?}"
);
assert_eq!(
(added[5].2, added[6].2),
(size, handles * size),
"{name}: {handle:?}"
);
drop((surface, export));
}
});
}
}
@@ -56,6 +56,7 @@ mod linear_planes;
mod locks;
mod lost_writes;
mod lowered;
mod make_parts;
mod maker_yield;
mod managed;
mod memory;
+23 -15
View File
@@ -41,7 +41,7 @@
use crate::arrays::{Owner, ResourceId};
use crate::buffer::{Buffer, BufferInner, BufferObject};
use crate::copy_out;
use crate::counters::{Counters, Gauge, Metric, OverCause, Site};
use crate::counters::{Counters, Gauge, Metric, OverCause, Part, Site};
use crate::device::{lock, Core, Device};
use crate::error::{Error, Gap, Limit, Refusal, RenderPassKind, TextureViewKind};
use crate::hazard::HeapId;
@@ -1301,7 +1301,7 @@ impl Device {
let mut made = Made::default();
// SAFETY: the image is the device's and bound (the caller's contract), of the plan's
// format, and has the plan's usage.
let views = unsafe { made.views(&core.device, image, &shape, &plan, plan.usage) };
let views = unsafe { made.views(core, image, &shape, &plan, plan.usage) };
if views.is_err() {
// SAFETY: nothing else holds the views; `made` holds no image.
unsafe { made.destroy(core) };
@@ -2630,13 +2630,14 @@ pub(crate) fn components(
/// An image view of `range` of `image`, of `view_type` and `format`, with `components`, and with
/// `usage` where its format is another than the image's (`VkImageViewUsageCreateInfo`: the image's
/// usage that the format's features hold), else the image's.
/// usage that the format's features hold), else the image's. Timed in
/// [`Metrics::image_view_creates`](crate::Metrics::image_view_creates).
///
/// # Safety
///
/// `image` is the device's and bound, and takes such a view: its format, usage and range.
unsafe fn image_view(
device: &ash::Device,
core: &Core,
image: vk::Image,
view_type: vk::ImageViewType,
format: vk::Format,
@@ -2656,7 +2657,10 @@ unsafe fn image_view(
info = info.push_next(&mut usage_info);
}
// SAFETY: the caller's contract.
unsafe { device.create_image_view(&info, None) }.map_err(Error::vulkan("vkCreateImageView"))
let made = (core.counters).time(Part::ImageViewCreate, 0, || unsafe {
core.device.create_image_view(&info, None)
});
made.map_err(Error::vulkan("vkCreateImageView"))
}
/// Every level and layer of an image of `aspects`.
@@ -2879,9 +2883,11 @@ impl Made {
}
Bind::Pooled | Bind::Heap { .. } => info,
};
let started = crate::host_time();
// SAFETY: the caller's contract: the device makes such an image.
let image =
unsafe { device.create_image(&info, None) }.map_err(Error::vulkan("vkCreateImage"))?;
let created = crate::host_time() - started;
self.image = Some(image);
let mut dedicated = vk::MemoryDedicatedRequirements::default();
let mut needs = vk::MemoryRequirements2::default().push_next(&mut dedicated);
@@ -2889,6 +2895,7 @@ impl Made {
// SAFETY: the image is the device's.
unsafe { device.get_image_memory_requirements2(&of, &mut needs) };
let requirements = needs.memory_requirements;
(core.counters).timed(Part::ImageCreate, requirements.size, created, false);
let bits = requirements.memory_type_bits;
// A place in a texture block where the image takes the blocks' memory type and the device
// does not require an allocation of its own for it (preferring one is no reason): one of
@@ -3008,11 +3015,13 @@ impl Made {
self.backing = Some(backing);
// SAFETY: the place or allocation holds the image's size at its alignment, in memory of a
// type its requirements allow.
unsafe { device.bind_image_memory(image, memory, offset) }
.map_err(Error::vulkan("vkBindImageMemory"))?;
let bound = (core.counters).time(Part::ImageBind, requirements.size, || unsafe {
device.bind_image_memory(image, memory, offset)
});
bound.map_err(Error::vulkan("vkBindImageMemory"))?;
// SAFETY: the image is bound, of the plan's format, and has `info`'s usage.
let usage = info.usage;
let (sampled, storage) = unsafe { self.views(device, image, shape, plan, usage) }?;
let (sampled, storage) = unsafe { self.views(core, image, shape, plan, usage) }?;
Ok((image, backing, requirements.size, sampled, storage))
}
@@ -3025,7 +3034,7 @@ impl Made {
/// among it where the plan has a storage view.
unsafe fn views(
&mut self,
device: &ash::Device,
core: &Core,
image: vk::Image,
shape: &Shape,
plan: &Plan,
@@ -3036,7 +3045,7 @@ impl Made {
// SAFETY: the caller's contract.
let range = whole(aspect);
let view =
unsafe { image_view(device, image, view_type, format, components, range, None) }?;
unsafe { image_view(core, image, view_type, format, components, range, None) }?;
self.views.push(view);
Ok::<_, Error>(view)
};
@@ -3817,7 +3826,7 @@ impl Texture {
// the range: the texture's levels and layers hold the view's.
unsafe {
image_view(
&core.device,
core,
image,
view_type,
format,
@@ -4365,7 +4374,7 @@ pub(crate) trait TextureObject {
// the sampled view's range, and of the sampled usage.
let made = unsafe {
image_view(
&core.device,
core,
shadow,
at.view_type,
self.object().format,
@@ -4581,7 +4590,7 @@ pub(crate) trait TextureObject {
// render target usage or its resolves gave it (the caller's check).
let view = unsafe {
image_view(
&core.device,
core,
image.image,
kind,
self.object().format,
@@ -5482,8 +5491,7 @@ impl Device {
let mut views = Made::default();
// SAFETY: the image is the device's and bound, of the plan's format or mutable with it
// listed, with the plan's usage and more, which the plan's format's features hold.
let made_views =
unsafe { views.views(&core.device, made.image, &shape, &plan, made.usage) };
let made_views = unsafe { views.views(core, made.image, &shape, &plan, made.usage) };
let (sampled, storage) = match made_views {
Ok(made_views) => made_views,
Err(error) => {
@@ -1665,8 +1665,12 @@ field metal2vulkan-runtime::Metrics.held_release_starts pub held_release_starts:
field metal2vulkan-runtime::Metrics.held_releases pub held_releases: u64
field metal2vulkan-runtime::Metrics.held_start_gap_nanos pub held_start_gap_nanos: u64
field metal2vulkan-runtime::Metrics.held_starts pub held_starts: u64
field metal2vulkan-runtime::Metrics.home_lock_waits pub home_lock_waits: Timed
field metal2vulkan-runtime::Metrics.idle_frees_by_age pub idle_frees_by_age: [u64; 6]
field metal2vulkan-runtime::Metrics.idle_reuses_by_age pub idle_reuses_by_age: [u64; 7]
field metal2vulkan-runtime::Metrics.image_binds pub image_binds: Timed
field metal2vulkan-runtime::Metrics.image_creates pub image_creates: Timed
field metal2vulkan-runtime::Metrics.image_view_creates pub image_view_creates: Timed
field metal2vulkan-runtime::Metrics.long_take_zero_writes pub long_take_zero_writes: Timed
field metal2vulkan-runtime::Metrics.made_ahead_variant_nanos pub made_ahead_variant_nanos: u64
field metal2vulkan-runtime::Metrics.made_ahead_variants pub made_ahead_variants: u64
@@ -1754,6 +1758,8 @@ field metal2vulkan-runtime::Metrics.submit_call_nanos pub submit_call_nanos: u64
field metal2vulkan-runtime::Metrics.submit_call_nanos_during_frees pub submit_call_nanos_during_frees: u64
field metal2vulkan-runtime::Metrics.submit_calls_over_100_ms pub submit_calls_over_100_ms: u64
field metal2vulkan-runtime::Metrics.submit_infos pub submit_infos: u64
field metal2vulkan-runtime::Metrics.surface_allocations pub surface_allocations: Timed
field metal2vulkan-runtime::Metrics.surface_handles pub surface_handles: Timed
field metal2vulkan-runtime::Metrics.surface_wait_max_nanos pub surface_wait_max_nanos: u64
field metal2vulkan-runtime::Metrics.surface_wait_nanos pub surface_wait_nanos: u64
field metal2vulkan-runtime::Metrics.surface_wait_submissions pub surface_wait_submissions: u64
@@ -1771,6 +1777,7 @@ field metal2vulkan-runtime::Metrics.texture_block_allocations pub texture_block_
field metal2vulkan-runtime::Metrics.texture_clear_barriers pub texture_clear_barriers: u64
field metal2vulkan-runtime::Metrics.texture_clear_bytes pub texture_clear_bytes: u64
field metal2vulkan-runtime::Metrics.texture_clears pub texture_clears: u64
field metal2vulkan-runtime::Metrics.texture_place_lock_waits pub texture_place_lock_waits: Timed
field metal2vulkan-runtime::Metrics.translation_nanos pub translation_nanos: u64
field metal2vulkan-runtime::Metrics.translations pub translations: u64
field metal2vulkan-runtime::Metrics.translations_loaded pub translations_loaded: u64
Can't render this file because it is too large.