rt: an exported block's BlockInfo states no device address, so its make hands none out
API change for the consumer: BlockInfo::gpu_address becomes Option<u64>. It is Some for every taken, imported and sparse block, as before, and None for an exported block (Device::new_exported_block). BlockInfo stays Clone + Copy. The only way to an address of an exported block's memory is now Buffer::gpu_address of a buffer in it, which marks the block and counts it in Metrics::exported_blocks_addressed asbe1b2cfe46built it. The consumer's reads of the field fail to build until each one is reviewed. At reims-vgpu 095001ddc6, `git grep -n -F '.gpu_address' 095001ddc6 -- 'crates/reims-vgpu-vulkan/src/rt_platform/*.rs' 'crates/reims-vgpu/src/pool/rt_blocks.rs' 'crates/reims-vgpu/src/platform/rt.rs' | grep -v 'gpu_address('` gives 39 lines. Some of them are the consumer's own structs; their types were not checked one by one. The rt BlockInfo reads among them include: - rt_platform/buffer.rs:793, the known-block map's key; - pool/rt_blocks.rs:118 and :170; - rt_platform/diag.rs:716; - rt_platform/fault.rs:1405; - platform/rt.rs:149. Why:be1b2cfe46counted the public make itself as handing the address out, because the Block handle derefs to BlockInfo and BlockInfo's pub field stated the address. The consumer calls new_exported_block for every buffer-form video cache (rt_platform/export.rs:208 at 095001ddc6). So every such cache's textures stayed in the over-copy class from their make on. With no address in the info there is nothing to read by accident. A bookkeeping read (a map keyed by address, a diagnostics line) now fails to build instead of silently turning the bound off. The Option says "this block has none", as contents: Option<NonNull<u8>> already does. How: - Memory::info() gives None where the memory is exported. - new_exported_block no longer marks its block at the make. Its body was the crate's exported_block(), which only the copy form of new_exported_surface called, and the two are now the same; the wrapper is gone and the surface calls new_exported_block. - No product code read the field. The runtime's tests and the validation crate's replay player read it only for taken and imported blocks, and now read the Option. Docs: the field's doc and new_exported_block's doc, the exported_blocks_addressed doc, the ExportedOvers doc, and the runtime README (Exported blocks, the address contract in Known gaps, the exported block's rule in Textures over a buffer). The signatures table and docs/REFUSALS.md (whose site column named exported_block) are regenerated. Test: an_exported_blocks_texture_is_copied_in_once_a_change. The block's handle states no address and the make counts 0. Then a new row on the block's own texture: three submissions that each read it and then write through an address into another buffer copy it in [0, 0, 0], with 0 blocks addressed. After Buffer::gpu_address on the buffer the texture is over, the count is 1, and three more such submissions copy [0, 1, 1]. The surface row follows, with the store_through kernel's state and buffers now made once for both rows. Verified: - Without the change: the base015ece4929product with this row printing instead of asserting, on lavapipe, job m3-max-66854. It printed "addressed at the make 1, rows [0, 1, 1] (addressed 1), then after the buffer's address [1, 1, 1] (addressed 1)". So the row fails without the change. - Compile job m3-max-66851 (tree a9636bbcf8, the same tree as this commit): signatures and refusal-surface checks, fmt, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd), workspace Rustdoc -D warnings and scripts/api-docs all exit 0. The runtime suite on lavapipe: 642 tests run, 642 passed, 3 skipped. - The m2v_gpu archive is from job m3-max-66852. Each card ran the test, then the runtime suite: - RX 550, job m3-max-66873: 644 passed, 3 skipped, peak 0.96 GiB. - Iris Xe, job m3-max-66874: 644 passed, 3 skipped, peak 3.72 GiB. - RTX 3090, job m3-max-66875: 644 passed (1 slow), 3 skipped, peak 2.44 GiB. Each card printed "OpaqueFd block: copies in a submission that writes through an address, the block's address not out: [0, 0, 0], then out: [0, 1, 1]; blocks addressed 0, then 1". Lavapipe printed the same line in m3-max-66851.
This commit is contained in:
1 parent
6bcd2062db
commit
85aa6c8dee
15 files changed
+146
-105
No files matched your search
@@ -660,8 +660,10 @@ handle may outlive the block, unused. Neither `BlockMappings` hook runs for an e
|
||||
its bytes are undefined until written, as a taken block's are. No image is made in its memory,
|
||||
which is dedicated to its buffer (`VUID-vkBindImageMemory-memory-10926`): a texture over a buffer
|
||||
in it is the counted copy, as over host memory's import, and a heap texture in it is
|
||||
`Gap::HeapTexture`. The `Block` handle states the block's `gpu_address`, so the make counts in
|
||||
`Metrics::exported_blocks_addressed` (Textures over a buffer, the exported block's rule).
|
||||
`Gap::HeapTexture`. The `Block` handle states no address (`BlockInfo::gpu_address` is `None`): an
|
||||
address of the block's memory goes out only as `Buffer::gpu_address` of a buffer in it, which
|
||||
counts in `Metrics::exported_blocks_addressed` (Textures over a buffer, the exported block's
|
||||
rule).
|
||||
|
||||
Once the other API's work that accessed the block has completed (work that wrote it, or that read it
|
||||
after a release; the consumer's own wait on the decoder), the consumer calls
|
||||
@@ -950,8 +952,8 @@ the Direct3D 11 texture's payload until it is freed.
|
||||
and a buffer the consumer did not place at the address its guest asked for has a `gpu_address`
|
||||
other than that one. A stale address, of a released buffer, can still fault the device. An
|
||||
address in an exported block is one the consumer read from rt before the commit of the command
|
||||
buffer that writes through it (`Buffer::gpu_address`, or the block's own from
|
||||
`Device::new_exported_block`): a write through an address made any other way does not reach
|
||||
buffer that writes through it (`Buffer::gpu_address` of a buffer in the block, whose
|
||||
`BlockInfo` states no address): a write through an address made any other way does not reach
|
||||
the textures over the block, whose copies in owe nothing for it (Textures over a buffer).
|
||||
- An app buffer too large for the consumer's map budget is copied, on drivers whose dma-buf query
|
||||
offers a non-host-visible type first.
|
||||
@@ -1436,16 +1438,16 @@ made, with no lock, and never rewritten for layouts.
|
||||
write through an address outside the command's bound slots and declared resources changes
|
||||
the bytes of every such texture whose block's address a public call handed out before that
|
||||
submission, and of no other: `Buffer::gpu_address` of a buffer whose bytes shaders reach in
|
||||
the block (a Managed buffer's device copy placed there included), the `Block` that
|
||||
`Device::new_exported_block` answers, whose `gpu_address` states the block's address, and a
|
||||
texture buffer's storage element at an index over the block's bytes. An exported surface's
|
||||
block in the copy form is the surface's own, so only `Surface::buffer`'s `gpu_address`
|
||||
hands it out; the planes' resource IDs reach their own images. Each such block counts once in
|
||||
`Metrics::exported_blocks_addressed`. A command recorded while no texture over a buffer in an
|
||||
image of its own lived is untracked, and changes every such texture's bytes. The upload that
|
||||
leads the next submission that uses the texture makes the copy; a submission that only reads
|
||||
the texture copies nothing. The block is Private, so no host write reaches it, and the other
|
||||
API's writes are the consumer's to announce by the acquire.
|
||||
the block (a Managed buffer's device copy placed there included), and a texture buffer's
|
||||
storage element at an index over the block's bytes; the block's own `BlockInfo` states no
|
||||
address. An exported surface's block in the copy form is the surface's own, so only
|
||||
`Surface::buffer`'s `gpu_address` hands it out; the planes' resource IDs reach their own
|
||||
images. Each such block counts once in `Metrics::exported_blocks_addressed`. A command
|
||||
recorded while no texture over a buffer in an image of its own lived is untracked, and changes
|
||||
every such texture's bytes. The upload that leads the next submission that uses the texture
|
||||
makes the copy; a submission that only reads the texture copies nothing. The block is Private,
|
||||
so no host write reaches it, and the other API's writes are the consumer's to announce by the
|
||||
acquire.
|
||||
- Over a Managed buffer's device copy, only at Metal's own Managed events, each texture keeping
|
||||
one flag of each kind: in, after a `did_modify_range` over its range, by the commit that
|
||||
captures the range, after its copies into the device copy; and at its making, or where device
|
||||
|
||||
@@ -2535,12 +2535,12 @@ pub struct Metrics {
|
||||
/// [`SurfaceForm::Copy`](crate::SurfaceForm::Copy)).
|
||||
pub surfaces_copied: u64,
|
||||
/// Exported blocks a public call handed out a device address of, each counted at the first:
|
||||
/// [`Buffer::gpu_address`](crate::Buffer::gpu_address) answering an address in one,
|
||||
/// [`Device::new_exported_block`](crate::Device::new_exported_block), whose handle states its
|
||||
/// block's, and a texture buffer's storage element at an index over its bytes. A write
|
||||
/// through an address makes the textures over an exported block owe their copies in only
|
||||
/// once its address went out; 0 where none went out, as for a surface's block in the copy
|
||||
/// form whose buffer's address nothing read.
|
||||
/// [`Buffer::gpu_address`](crate::Buffer::gpu_address) answering an address in one, and a
|
||||
/// texture buffer's storage element at an index over its bytes; the block's own handle states
|
||||
/// none ([`BlockInfo::gpu_address`](crate::BlockInfo::gpu_address)). A write through an
|
||||
/// address makes the textures over an exported block owe their copies in only once its
|
||||
/// address went out; 0 where none went out, as for a surface's block in the copy form whose
|
||||
/// buffer's address nothing read.
|
||||
pub exported_blocks_addressed: u64,
|
||||
/// Waits of surfaces made in place for the submission that moves their planes to the general
|
||||
/// layout ([`Surface::wait_until_ready`](crate::Surface::wait_until_ready)), on the
|
||||
|
||||
@@ -202,10 +202,11 @@ impl Device {
|
||||
/// No image is made in its memory, which is dedicated to its buffer
|
||||
/// (`VUID-vkBindImageMemory-memory-10926`): a texture over a buffer in it is copied, as over
|
||||
/// host memory's import ([`Buffer::new_texture`](crate::Buffer::new_texture)), and it is no
|
||||
/// heap's memory ([`Device::new_heap_texture`]). The block's handle states its device address
|
||||
/// ([`BlockInfo::gpu_address`](crate::BlockInfo::gpu_address)), so the make counts in
|
||||
/// [`Metrics::exported_blocks_addressed`](crate::Metrics::exported_blocks_addressed), as
|
||||
/// [`Buffer::gpu_address`](crate::Buffer::gpu_address) does.
|
||||
/// heap's memory ([`Device::new_heap_texture`]). The block's handle states no device address
|
||||
/// ([`BlockInfo::gpu_address`](crate::BlockInfo::gpu_address) is `None`): an address of its
|
||||
/// memory goes out only as [`Buffer::gpu_address`](crate::Buffer::gpu_address) of a buffer in
|
||||
/// it, which counts in
|
||||
/// [`Metrics::exported_blocks_addressed`](crate::Metrics::exported_blocks_addressed).
|
||||
///
|
||||
/// Err: [`Limit::NoExport`] where the device does not export the handle;
|
||||
/// [`Limit::ExportType`] for a dma-buf on a device without the foreign queue family, or where
|
||||
@@ -218,18 +219,6 @@ impl Device {
|
||||
&self,
|
||||
handle: ExportHandle,
|
||||
len: u64,
|
||||
) -> Result<(Block, Export), Error> {
|
||||
let (block, export) = self.exported_block(handle, len)?;
|
||||
block.held()?.1.address_out();
|
||||
Ok((block, export))
|
||||
}
|
||||
|
||||
/// An exported block, as [`Device::new_exported_block`] makes it, whose address no call has
|
||||
/// handed out yet: an exported surface's in the copy form, whose handle the surface keeps.
|
||||
pub(crate) fn exported_block(
|
||||
&self,
|
||||
handle: ExportHandle,
|
||||
len: u64,
|
||||
) -> Result<(Block, Export), Error> {
|
||||
let started = crate::host_time();
|
||||
let core = self.core();
|
||||
|
||||
@@ -246,8 +246,9 @@ pub struct BlockInfo {
|
||||
/// The offset of its first byte in that allocation.
|
||||
pub offset: u64,
|
||||
/// `gpuAddress` of the block's first byte: its allocation's device address plus
|
||||
/// [`offset`](Self::offset).
|
||||
pub gpu_address: u64,
|
||||
/// [`offset`](Self::offset); `None` for an exported block, an address of whose memory goes
|
||||
/// out only as [`Buffer::gpu_address`](crate::Buffer::gpu_address) of a buffer in it.
|
||||
pub gpu_address: Option<u64>,
|
||||
/// `contents` of the block's first byte: the host mapping of a Shared block, `None` for a
|
||||
/// Private one; for an imported block, the host memory imported, or `None` for a dma-buf,
|
||||
/// whose pages the consumer reaches through its own mappings.
|
||||
@@ -436,7 +437,7 @@ impl Memory {
|
||||
len: self.len,
|
||||
allocation: self.allocation,
|
||||
offset: self.base,
|
||||
gpu_address: self.address,
|
||||
gpu_address: (!self.exported()).then_some(self.address),
|
||||
contents: self.mapping.map(Mapping::get),
|
||||
device_local: self.device_local,
|
||||
}
|
||||
|
||||
@@ -628,8 +628,7 @@ struct Exported {
|
||||
/// submitted command's write of memory its texels lie in, a write through an address once an
|
||||
/// address of the block went out (every such texture), or another texture's copy back over those
|
||||
/// bytes. An address goes out by a public call alone: [`crate::Buffer::gpu_address`] of a buffer
|
||||
/// whose bytes shaders reach in the block (a Managed buffer's device copy included), the handle
|
||||
/// [`crate::Device::new_exported_block`] answers, which states the block's address, and a texture
|
||||
/// whose bytes shaders reach in the block (a Managed buffer's device copy included), and a texture
|
||||
/// buffer's storage element at an index over such bytes. A surface's block in the copy form is
|
||||
/// the surface's own, so its address goes out only through its buffer
|
||||
/// ([`crate::Surface::buffer`]). Within a segment the Shared rules stand.
|
||||
|
||||
@@ -945,7 +945,7 @@ impl Device {
|
||||
.checked_next_multiple_of(multiple)
|
||||
.ok_or_else(too_long)?;
|
||||
let (starts, end) = lay(spec, plans, pitch).ok_or_else(too_long)?;
|
||||
let (block, export) = self.exported_block(spec.handle, end)?;
|
||||
let (block, export) = self.new_exported_block(spec.handle, end)?;
|
||||
let buffer = self.new_buffer(block.id, 0, block.len, None)?;
|
||||
let planes = (spec.planes.iter().zip(&starts))
|
||||
.map(|(plane, &start)| {
|
||||
|
||||
@@ -299,8 +299,8 @@ mod on_device {
|
||||
};
|
||||
println!(
|
||||
"{name}: the heap's block at {:#x}..{:#x}",
|
||||
heap_block.gpu_address,
|
||||
heap_block.gpu_address + len
|
||||
heap_block.gpu_address.expect("a taken block's address"),
|
||||
heap_block.gpu_address.expect("a taken block's address") + len
|
||||
);
|
||||
let descriptor = |format| {
|
||||
let mut d = TextureDescriptor::new(TextureType::Type2D, format, SIDE, SIDE);
|
||||
|
||||
@@ -275,7 +275,7 @@ mod on_device {
|
||||
"{name}: one bind"
|
||||
);
|
||||
let buffer = (device.new_buffer(block.id, 0, total, None)).expect("a buffer");
|
||||
assert_eq!(buffer.gpu_address(), block.gpu_address, "{name}");
|
||||
assert_eq!(Some(buffer.gpu_address()), block.gpu_address, "{name}");
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
rounds(
|
||||
name,
|
||||
|
||||
@@ -3,20 +3,23 @@
|
||||
//! counted in `Metrics::over_copies` and `Metrics::over_copy_bytes`. After a fill of the buffer and
|
||||
//! the block's acquire, four submissions that read the texture copy it in once; a fill between
|
||||
//! makes one copy more, and a zero fill of the block's range one more; reads with no event between
|
||||
//! copy nothing. Each read finds the bytes of the last event. The block's make states its address,
|
||||
//! counted in `Metrics::exported_blocks_addressed`.
|
||||
//! copy nothing. Each read finds the bytes of the last event. The block's handle states no address
|
||||
//! (`BlockInfo::gpu_address` is `None`), so `Metrics::exported_blocks_addressed` reads 0.
|
||||
//!
|
||||
//! A write through an address owes such a texture its copy in only once an address of its block
|
||||
//! went out. A plane of an exported surface in the copy form, read by four submissions that each
|
||||
//! then write through an address into another buffer (`store_through`), is copied in once, and the
|
||||
//! count of blocks whose address went out reads 0; once its buffer's `gpu_address` is read, it
|
||||
//! reads 1, and each submission after the next copies the plane in again.
|
||||
//! went out. The texture, read by three submissions that each then write through an address into
|
||||
//! another buffer (`store_through`), is copied in by none of them, and the count of blocks whose
|
||||
//! address went out reads 0; once the buffer the texture is over answers `gpu_address`, it reads
|
||||
//! 1, and each submission after the next copies the texture in again. A plane of an exported
|
||||
//! surface in the copy form, read by four such submissions, is copied in once, and the count reads
|
||||
//! 0; once its buffer's `gpu_address` is read, it reads 1, and each submission after the next
|
||||
//! copies the plane in again.
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::tests::command::on_device::{each_device, finished};
|
||||
use crate::{
|
||||
Buffer, BufferLayout, CommandQueue, ComputePipelineDescriptor, ComputePipelineState,
|
||||
Block, Buffer, BufferLayout, CommandQueue, ComputePipelineDescriptor, ComputePipelineState,
|
||||
Device, DispatchType, ExportHandle, FunctionDescriptor, IndexClass, Library, MemoryClass,
|
||||
PixelFormat, PlaneSpec, Resource, ResourceUsage, StageSource, StorageMode, SurfaceForm,
|
||||
SurfaceSpec, Texture, TextureDescriptor, TexturePlace, TextureType, TextureUsage,
|
||||
@@ -197,6 +200,36 @@ entry:
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// `store_through`'s state, and the block of the two Shared buffers it reaches: the argument
|
||||
/// buffer, which holds the target's address, and the target.
|
||||
fn store_through(
|
||||
name: &str,
|
||||
device: &Device,
|
||||
library: &Library,
|
||||
) -> (ComputePipelineState, Block, Buffer, Buffer) {
|
||||
let function = library.function("store_through").expect("the kernel");
|
||||
let kernel = ComputePipelineDescriptor::new(StageSource::Function(
|
||||
FunctionDescriptor::new(function),
|
||||
));
|
||||
let state = (device
|
||||
.new_compute_pipeline_state(&kernel, crate::tests::no_constexpr_samplers))
|
||||
.unwrap_or_else(|error| panic!("{name}: store_through: {error}"));
|
||||
let interface = &state.inner.compiled.whole.interface;
|
||||
assert!(
|
||||
interface.writes_unbound,
|
||||
"{name}: store_through writes through an address"
|
||||
);
|
||||
let block = (device.take_block(MemoryClass::Shared, 2 * ROW))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let target = (device.new_buffer(block.id, 0, ROW, Some(0))).expect("a buffer");
|
||||
let held = (device.new_buffer(block.id, ROW, 8, Some(0))).expect("a buffer");
|
||||
let address = target.gpu_address().to_le_bytes();
|
||||
let contents = held.contents().expect("Shared");
|
||||
// SAFETY: the buffer holds 8 bytes, and no command reaches them.
|
||||
unsafe { std::ptr::copy_nonoverlapping(address.as_ptr(), contents.as_ptr(), 8) };
|
||||
(state, block, held, target)
|
||||
}
|
||||
|
||||
/// A plane of an exported surface in the copy form, over a block whose address no call has
|
||||
/// handed out, read by submissions that each then write through an address into another
|
||||
/// buffer: the copies in each made before and after its buffer's `gpu_address` is read, and
|
||||
@@ -205,7 +238,7 @@ entry:
|
||||
name: &str,
|
||||
at: (&Device, &CommandQueue),
|
||||
out: &Buffer,
|
||||
library: &Library,
|
||||
writer: &Writer<'_>,
|
||||
) -> Option<(Vec<u64>, Vec<u64>, SurfaceForm)> {
|
||||
let device = at.0;
|
||||
let mut d =
|
||||
@@ -242,33 +275,8 @@ entry:
|
||||
(encoder.fill_buffer(&buffer, 0..buffer.length(), 0x3c))
|
||||
.unwrap_or_else(|error| panic!("{name}: the fill: {error}"));
|
||||
});
|
||||
let function = library.function("store_through").expect("the kernel");
|
||||
let kernel = ComputePipelineDescriptor::new(StageSource::Function(
|
||||
FunctionDescriptor::new(function),
|
||||
));
|
||||
let state = (device
|
||||
.new_compute_pipeline_state(&kernel, crate::tests::no_constexpr_samplers))
|
||||
.unwrap_or_else(|error| panic!("{name}: store_through: {error}"));
|
||||
let interface = &state.inner.compiled.whole.interface;
|
||||
assert!(
|
||||
interface.writes_unbound,
|
||||
"{name}: store_through writes through an address"
|
||||
);
|
||||
let block = (device.take_block(MemoryClass::Shared, 2 * ROW))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let target = (device.new_buffer(block.id, 0, ROW, Some(0))).expect("a buffer");
|
||||
let held = (device.new_buffer(block.id, ROW, 8, Some(0))).expect("a buffer");
|
||||
let address = target.gpu_address().to_le_bytes();
|
||||
let contents = held.contents().expect("Shared");
|
||||
// SAFETY: the buffer holds 8 bytes, and no command reaches them.
|
||||
unsafe { std::ptr::copy_nonoverlapping(address.as_ptr(), contents.as_ptr(), 8) };
|
||||
let writer = Writer {
|
||||
state: &state,
|
||||
held: &held,
|
||||
target: &target,
|
||||
};
|
||||
let over = (&surface.planes()[0], out);
|
||||
let before = written_reads(name, at, over, &writer, 4, 0x3c);
|
||||
let before = written_reads(name, at, over, writer, 4, 0x3c);
|
||||
assert_eq!(before, [1, 0, 0, 0], "{name}: no address of the block out");
|
||||
assert_eq!(addressed() - made, 0, "{name}: no address of the block out");
|
||||
assert_ne!(
|
||||
@@ -282,7 +290,7 @@ entry:
|
||||
"{name}: the surface buffer's address read"
|
||||
);
|
||||
// The submission before the read owes nothing: no address of the block was out then.
|
||||
let after = written_reads(name, at, over, &writer, 3, 0x3c);
|
||||
let after = written_reads(name, at, over, writer, 3, 0x3c);
|
||||
assert_eq!(after, [0, 1, 1], "{name}: the block's address out");
|
||||
Some((before, after, export.form))
|
||||
}
|
||||
@@ -308,10 +316,14 @@ entry:
|
||||
let made = addressed();
|
||||
let (block, _export) = (device.new_exported_block(handle, LEN))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert_eq!(
|
||||
block.gpu_address, None,
|
||||
"{name}: the block's handle states no address"
|
||||
);
|
||||
assert_eq!(
|
||||
addressed() - made,
|
||||
1,
|
||||
"{name}: the block's handle states its address"
|
||||
0,
|
||||
"{name}: the make hands out no address"
|
||||
);
|
||||
let buffer = (device.new_buffer(block.id, 0, LEN, None)).expect("a buffer");
|
||||
let pitch = (device.minimum_linear_texture_alignment(PixelFormat::RGBA8Unorm))
|
||||
@@ -360,7 +372,26 @@ entry:
|
||||
let Some(library) = &library else {
|
||||
return;
|
||||
};
|
||||
if let Some((before, after, form)) = through_addresses(name, at, &out, library) {
|
||||
let (state, _block, held, target) = store_through(name, &device, library);
|
||||
let writer = Writer {
|
||||
state: &state,
|
||||
held: &held,
|
||||
target: &target,
|
||||
};
|
||||
let before = written_reads(name, at, over, &writer, 3, 0);
|
||||
assert_eq!(before, [0, 0, 0], "{name}: no address of the block out");
|
||||
assert_eq!(addressed() - made, 0, "{name}: no address of the block out");
|
||||
assert_ne!(buffer.gpu_address(), 0, "{name}: the buffer's address");
|
||||
assert_eq!(addressed() - made, 1, "{name}: the buffer's address read");
|
||||
// The submission before the read owes nothing: no address of the block was out then.
|
||||
let after = written_reads(name, at, over, &writer, 3, 0);
|
||||
assert_eq!(after, [0, 1, 1], "{name}: the block's address out");
|
||||
println!(
|
||||
"exported_overs: {name}: {handle:?} block: copies in a submission that writes \
|
||||
through an address, the block's address not out: {before:?}, then out: \
|
||||
{after:?}; blocks addressed 0, then 1"
|
||||
);
|
||||
if let Some((before, after, form)) = through_addresses(name, at, &out, &writer) {
|
||||
println!(
|
||||
"exported_overs: {name}: {OPAQUE:?} surface, {form:?}: copies in a \
|
||||
submission that writes through an address, the block's address not out: \
|
||||
|
||||
@@ -283,14 +283,14 @@ mod on_device {
|
||||
command_buffer
|
||||
};
|
||||
let first = take(SMALL);
|
||||
let first_address = first.gpu_address;
|
||||
let first_address = first.gpu_address.expect("a taken block's address");
|
||||
let buffer = (device.new_buffer(first.id, 0, SMALL, Some(0))).expect("a buffer");
|
||||
let command_buffer = encode(&buffer);
|
||||
drop((buffer, first));
|
||||
let second = take(SMALL);
|
||||
let second_address = second.gpu_address.expect("a taken block's address");
|
||||
assert!(
|
||||
second.gpu_address + SMALL <= first_address
|
||||
|| first_address + SMALL <= second.gpu_address,
|
||||
second_address + SMALL <= first_address || first_address + SMALL <= second_address,
|
||||
"{name}: a take got the range an encoded command buffer holds"
|
||||
);
|
||||
let contents = second.contents.expect("a Shared block").cast::<u32>();
|
||||
|
||||
@@ -392,7 +392,7 @@ pub(crate) mod on_device {
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert_eq!(
|
||||
managed.gpu_address(),
|
||||
cpu.gpu_address + AT,
|
||||
cpu.gpu_address.expect("a taken block's address") + AT,
|
||||
"{name}: one copy"
|
||||
);
|
||||
let private = (device.take_block(MemoryClass::Private, BLOCK))
|
||||
@@ -446,7 +446,7 @@ pub(crate) mod on_device {
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert_eq!(
|
||||
managed.gpu_address(),
|
||||
private.gpu_address + AT,
|
||||
private.gpu_address.expect("a taken block's address") + AT,
|
||||
"{name}: the copy where the consumer placed it"
|
||||
);
|
||||
// The consumer's write into its slack, in the commit that takes the first bytes in.
|
||||
@@ -551,10 +551,14 @@ pub(crate) mod on_device {
|
||||
match © {
|
||||
Some(copy) => assert_eq!(
|
||||
managed.gpu_address(),
|
||||
copy.gpu_address + 4096,
|
||||
copy.gpu_address.expect("a taken block's address") + 4096,
|
||||
"{name}: a device that is not unified keeps a device copy where it is placed"
|
||||
),
|
||||
None => assert_eq!(managed.gpu_address(), cpu.gpu_address, "{name}: one copy"),
|
||||
None => assert_eq!(
|
||||
Some(managed.gpu_address()),
|
||||
cpu.gpu_address,
|
||||
"{name}: one copy"
|
||||
),
|
||||
}
|
||||
let host: Vec<u32> = (0..WORDS as u32).map(|i| i * 3 + 7).collect();
|
||||
let bytes =
|
||||
|
||||
@@ -230,7 +230,7 @@ mod on_device {
|
||||
block.contents.map(|c| c.as_ptr() as usize)
|
||||
),
|
||||
(
|
||||
allocation.gpu_address + block.offset,
|
||||
Some(allocation.gpu_address + block.offset),
|
||||
allocation.contents.map(|c| c + block.offset as usize)
|
||||
),
|
||||
"{name}: block {:?}'s address and mapping",
|
||||
@@ -437,7 +437,7 @@ mod on_device {
|
||||
.new_buffer(block.id, 0, MAX_BUFFER_LENGTH, None)
|
||||
.expect("a buffer of 2 GiB");
|
||||
assert_eq!(
|
||||
(buffer.gpu_address(), buffer.length()),
|
||||
(Some(buffer.gpu_address()), buffer.length()),
|
||||
(block.gpu_address, MAX_BUFFER_LENGTH),
|
||||
"{name}"
|
||||
);
|
||||
@@ -493,7 +493,10 @@ mod on_device {
|
||||
(shared.class, shared.len),
|
||||
(MemoryClass::Shared, MemoryClass::Shared.block_len())
|
||||
);
|
||||
assert_ne!(shared.gpu_address, 0, "{name}: a Shared block's address");
|
||||
assert!(
|
||||
shared.gpu_address.is_some_and(|address| address != 0),
|
||||
"{name}: a Shared block's address"
|
||||
);
|
||||
let host = bytes(&shared);
|
||||
|
||||
// A new Private block, unmapped.
|
||||
@@ -504,7 +507,10 @@ mod on_device {
|
||||
(private.class, private.len, private.contents),
|
||||
(MemoryClass::Private, MemoryClass::Private.block_len(), None)
|
||||
);
|
||||
assert_ne!(private.gpu_address, 0, "{name}: a Private block's address");
|
||||
assert!(
|
||||
private.gpu_address.is_some_and(|address| address != 0),
|
||||
"{name}: a Private block's address"
|
||||
);
|
||||
assert_ne!(private.id, shared.id);
|
||||
hook.assert_mapped(name, &shared);
|
||||
hook.assert_mapped(name, &private);
|
||||
@@ -514,7 +520,10 @@ mod on_device {
|
||||
.new_buffer(shared.id, 4096, 256, None)
|
||||
.expect("a Shared buffer");
|
||||
let base = shared.contents.unwrap().as_ptr() as usize;
|
||||
assert_eq!(view.gpu_address(), shared.gpu_address + 4096);
|
||||
assert_eq!(
|
||||
view.gpu_address(),
|
||||
shared.gpu_address.expect("a taken block's address") + 4096
|
||||
);
|
||||
assert_eq!(
|
||||
view.contents().map(|c| c.as_ptr() as usize),
|
||||
Some(base + 4096)
|
||||
@@ -527,7 +536,7 @@ mod on_device {
|
||||
.new_buffer(private.id, 0, MemoryClass::Private.block_len(), None)
|
||||
.expect("a Private buffer");
|
||||
assert_eq!(
|
||||
(whole.gpu_address(), whole.contents()),
|
||||
(Some(whole.gpu_address()), whole.contents()),
|
||||
(private.gpu_address, None)
|
||||
);
|
||||
let clone = view.clone();
|
||||
@@ -1552,7 +1561,10 @@ mod on_device {
|
||||
.unwrap_or_else(|error| panic!("{name}: a block of 1 MiB: {error}"));
|
||||
let long = (device.take_block(MemoryClass::Shared, 64 * MIB))
|
||||
.unwrap_or_else(|error| panic!("{name}: a block of 64 MiB: {error}"));
|
||||
let (allocation, address) = (long.allocation, long.gpu_address);
|
||||
let (allocation, address) = (
|
||||
long.allocation,
|
||||
long.gpu_address.expect("a taken block's address"),
|
||||
);
|
||||
device.release_block(long).expect("a release");
|
||||
wait_until("the long allocation freed", || {
|
||||
core.pool.frees().len() == 1 && !core.submit_calls.freeing()
|
||||
@@ -1572,7 +1584,10 @@ mod on_device {
|
||||
[(kind, address, 64 * MIB, Some((0, None)))],
|
||||
"{name}: the freed allocation alone, nothing in flight at its free: {freed}"
|
||||
);
|
||||
let held = core.spans.place(&at(live.gpu_address), crate::host_time());
|
||||
let held = core.spans.place(
|
||||
&at(live.gpu_address.expect("a taken block's address")),
|
||||
crate::host_time(),
|
||||
);
|
||||
let kind = crate::RangeKind::Allocation(live.allocation, MemoryClass::Shared);
|
||||
assert!(
|
||||
matches!(held.holders.as_slice(),
|
||||
|
||||
@@ -470,7 +470,7 @@ fn block_span(object: u64, range: &rt::HeapRange, block: &rt::Block) -> faulted:
|
||||
faulted::Span {
|
||||
object,
|
||||
heap: true,
|
||||
start: block.gpu_address + range.offset,
|
||||
start: block.gpu_address.expect("a taken block's address") + range.offset,
|
||||
len: range.len,
|
||||
}
|
||||
}
|
||||
@@ -1978,7 +1978,7 @@ impl NewRuntime {
|
||||
self.unwritten.block(call.result);
|
||||
}
|
||||
let made = Made {
|
||||
address: Some(block.gpu_address),
|
||||
address: block.gpu_address,
|
||||
};
|
||||
let range = rt::HeapRange {
|
||||
block: block.id,
|
||||
|
||||
@@ -1301,7 +1301,7 @@ field metal2vulkan-runtime::BlockInfo.allocation pub allocation: AllocationId
|
||||
field metal2vulkan-runtime::BlockInfo.class pub class: MemoryClass
|
||||
field metal2vulkan-runtime::BlockInfo.contents pub contents: Option<NonNull<u8>>
|
||||
field metal2vulkan-runtime::BlockInfo.device_local pub device_local: bool
|
||||
field metal2vulkan-runtime::BlockInfo.gpu_address pub gpu_address: u64
|
||||
field metal2vulkan-runtime::BlockInfo.gpu_address pub gpu_address: Option<u64>
|
||||
field metal2vulkan-runtime::BlockInfo.id pub id: BlockId
|
||||
field metal2vulkan-runtime::BlockInfo.len pub len: u64
|
||||
field metal2vulkan-runtime::BlockInfo.offset pub offset: u64
|
||||
|
||||
|
Can't render this file because it is too large.
|
+4
-4
@@ -340,8 +340,8 @@ Columns:
|
||||
| `ImportType` | An import whose handle's memory type query offers no type the import takes, so nothing is imported | at the device's limit | `device`: the handle's memory type query and the buffer's or image's memory requirements | 4: `crates/metal2vulkan-runtime/src/d3d11.rs (d3d11_plane)`, `crates/metal2vulkan-runtime/src/import.rs (import_dma_buf)` (+2) | `-` |
|
||||
| `ImportAlignment` | An import of no bytes, or one whose address or length is not a multiple of `alignment` | at the device's limit | `device`: `minImportedHostPointerAlignment` and the buffer's memory requirements | 4: `crates/metal2vulkan-runtime/src/import.rs (check_len)`, `crates/metal2vulkan-runtime/src/import.rs (check_size)` (+2) | `-` |
|
||||
| `SparseAddressSpace` | An import over several dma-bufs (`Device::import_dma_bufs`, on Unix) whose sparse buffer would take the device's sparse address space past its... | at the device's limit | `device`: `sparseAddressSpaceSize` | 1: `crates/metal2vulkan-runtime/src/import.rs (reserve)` | `-` |
|
||||
| `NoExport` | An export of a handle the device does not give (`Device::new_exported_block`) | at the device's limit | `device`: the device's extensions and its external buffer properties | 5: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`, `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)` (+2) | `-` |
|
||||
| `ExportType` | An export of a handle the device gives, but not in the one form an export takes (`Device::new_exported_block`) | at the device's limit | `device`: its extensions and the buffer's memory requirements | 6: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`, `crates/metal2vulkan-runtime/src/import.rs (surface_import)` (+4) | `-` |
|
||||
| `NoExport` | An export of a handle the device does not give (`Device::new_exported_block`) | at the device's limit | `device`: the device's extensions and its external buffer properties | 5: `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`, `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)` (+2) | `-` |
|
||||
| `ExportType` | An export of a handle the device gives, but not in the one form an export takes (`Device::new_exported_block`) | at the device's limit | `device`: its extensions and the buffer's memory requirements | 6: `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`, `crates/metal2vulkan-runtime/src/import.rs (surface_import)` (+4) | `-` |
|
||||
| `TextureSamples` | A multisample texture of a sample count the device does not make for its format, type and usage | at the device's limit | `device`: the image format query's `sampleCounts` | 1: `crates/metal2vulkan-runtime/src/texture.rs (plan)` | `-` |
|
||||
|
||||
## 9. The runtime's `Gap` (`Error::Unsupported(Gap)`)
|
||||
@@ -636,8 +636,8 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Limit::ImportType`: `crates/metal2vulkan-runtime/src/d3d11.rs (d3d11_plane)`; `crates/metal2vulkan-runtime/src/import.rs (import_dma_buf)`; `crates/metal2vulkan-runtime/src/import.rs (import_dma_bufs)`; `crates/metal2vulkan-runtime/src/import.rs (import_host_memory)`
|
||||
- `rt:Limit::ImportAlignment`: `crates/metal2vulkan-runtime/src/import.rs (check_len)`; `crates/metal2vulkan-runtime/src/import.rs (check_size)`; `crates/metal2vulkan-runtime/src/import.rs (import_dma_bufs)`; `crates/metal2vulkan-runtime/src/import.rs (import_host_memory)`
|
||||
- `rt:Limit::SparseAddressSpace`: `crates/metal2vulkan-runtime/src/import.rs (reserve)`
|
||||
- `rt:Limit::NoExport`: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`; `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
|
||||
- `rt:Limit::ExportType`: `crates/metal2vulkan-runtime/src/export.rs (exported_block)`; `crates/metal2vulkan-runtime/src/import.rs (surface_import)`; `crates/metal2vulkan-runtime/src/memory.rs (export)`; `crates/metal2vulkan-runtime/src/memory.rs (surface_view)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
|
||||
- `rt:Limit::NoExport`: `crates/metal2vulkan-runtime/src/export.rs (handle, 2 sites)`; `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
|
||||
- `rt:Limit::ExportType`: `crates/metal2vulkan-runtime/src/export.rs (new_exported_block)`; `crates/metal2vulkan-runtime/src/import.rs (surface_import)`; `crates/metal2vulkan-runtime/src/memory.rs (export)`; `crates/metal2vulkan-runtime/src/memory.rs (surface_view)`; `crates/metal2vulkan-runtime/src/surface.rs (dma_buf_in_place)`; `crates/metal2vulkan-runtime/src/surface.rs (new_exported_surface)`
|
||||
- `rt:Limit::TextureSamples`: `crates/metal2vulkan-runtime/src/texture.rs (plan)`
|
||||
- `rt:Gap::IndirectCommandBuffers`: `crates/metal2vulkan-runtime/src/indirect.rs (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/indirect.rs (shape)`; `crates/metal2vulkan-runtime/src/pipeline.rs (compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (execution_part)`
|
||||
- `rt:Gap::KernelInput`: `crates/metal2vulkan-runtime/src/pipeline.rs (gap)`
|
||||
|
||||
Reference in new issue
Block a user