From a1b955eec90ba81ac136f16dd59882fa0370d4bc Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 25 Nov 2026 11:32:04 -0800 Subject: [PATCH] indirect_commands: the plumbing only the deleted runtime drove goes `bind::indirect_commands` kept entry points that the removed in-crate runtime used to execute indirect command buffers. Nothing calls them now: not the runtime crate, not the command line, not validation, conformance, harness, devtools or the translator, and not the consumer. Deleted, each with its own tests, its re-export, its api_surface row, its api_signatures rows and its docs/API.md sentence: - `RecordField` (referenced by nothing at all); - `records_address`, `RECORDS_ADDRESS_BASE`, `RECORDS_ID_LIMIT`, and the crate-private `RECORDS_ADDRESS_SHIFT` that only `records_address` read; - `written_flag_offset`, `WRITTEN_FLAG_BYTES`; - `BufferBinding::resolve_buffer`, `RegisteredBuffer` (+ `new`), `ResolvedBuffer`, `AddressError`; - `CommandRecord::resolve_bindings`, `ResolvedBindings`, `BindingError` (tests/inheritance.rs tested only these and goes whole); - `RenderDraws::PRIMITIVES` (its one user, a test, now spells the struct out); - `RecordView::action`, `barrier`, `kernel_pipeline`, `buffer`, `writes`. The fixed point inside the module adds `RecordError::Index`, which nothing constructs (its Display arm alone named it; it was the error of `RecordField`'s indexed fields), and an empty `impl CommandRecord {}`. Kept, because a live path calls them inside the module (validation's `CommandBuffer::decode` and `CommandDescriptor::validate_record`): `BufferStage::of` (descriptor.rs `validate_record`, host.rs `decode`), `CommandDescriptor::holds` (`validate_record`), `validate_header` (`decode`), and `RecordView` with the accessors `CommandRecord::decode` reads through `record_into` (`pipeline`, `retained_pipeline`, `threadgroup_memory_length`, `stage_in_region`, `imageblock_size`, `record`, `record_into`). `Bindings::buffers` becomes private: only descriptor.rs and host.rs call it, and validation reads a record's buffers through `buffers_mut` only. The build at the stack's tip answers whether anything else used it (an error would mean a user). `BufferBinding`'s doc no longer links it. Docs that named the deleted items or the deleted runtime say what is true now: the `bind::indirect_commands` module docs (validation's case model and Metal executor use it), host.rs's module docs, `BufferBinding::address`, `RecordError`, provenance.rs's `object_handle_load`, and docs/API.md's indirect-command-buffer section. Zeros, outside crates/metal2vulkan/src/indirect_commands* and the facade, at metal2vulkan 733b14ed24 and the consumer reims-vgpu d0a7c9614 (whose Cargo.toml pins metal2vulkan 0c9db49765): - `git grep -nw 733b14ed24 -- 'crates/*.rs' 'docs/*.md'` (the facade and tests/api_surface.rs excluded, comment-only lines dropped): 0 for RecordField, RECORDS_ADDRESS_BASE, RECORDS_ID_LIMIT, WRITTEN_FLAG_BYTES, resolve_buffer, RegisteredBuffer, ResolvedBuffer, AddressError, resolve_bindings, ResolvedBindings, BindingError. `records_address`: only other items of the name (metal2vulkan-air intrinsics/objects.rs:449, a predicate; provenance.rs:3251-3267, a local and that predicate) and provenance.rs:1831's comment, rewritten here. `written_flag_offset`: only docs/API.md:1352, rewritten here. - `git grep -nF 733b14ed24 -- 'crates/*.rs'` (same exclusions): 0 for `RenderDraws::PRIMITIVES`, `RecordView`, `RecordError::Index`. - Consumer: `git grep -nw d0a7c9614 -- '*.rs'` is 0 for every name above; `git grep -nE 'indirect_commands::' d0a7c9614 -- '*.rs'` is 0; `git grep -nE 'metal2vulkan::bind' d0a7c9614 -- '*.rs'` names only rt_platform/argument.rs and rt_platform/function_table.rs. Tables: `scripts/api-signatures/signatures.py --bless` removed 47 rows and added none; `scripts/refusal-surface/refusal_surface.py` leaves docs/REFUSALS.md unchanged. Build, clippy and suites run at the stack's tip. --- .../src/bind/indirect_commands.rs | 23 +- crates/metal2vulkan/src/indirect_commands.rs | 224 +----------------- .../src/indirect_commands/descriptor.rs | 10 - .../src/indirect_commands/host.rs | 105 +------- .../src/indirect_commands/tests.rs | 25 -- .../indirect_commands/tests/buffer_views.rs | 85 ------- .../indirect_commands/tests/inheritance.rs | 107 --------- .../src/indirect_commands/tests/records.rs | 29 +-- crates/metal2vulkan/src/memory/provenance.rs | 3 +- crates/metal2vulkan/tests/api_signatures.tsv | 47 ---- crates/metal2vulkan/tests/api_surface.rs | 11 - docs/API.md | 7 +- 12 files changed, 34 insertions(+), 642 deletions(-) delete mode 100644 crates/metal2vulkan/src/indirect_commands/tests/inheritance.rs diff --git a/crates/metal2vulkan/src/bind/indirect_commands.rs b/crates/metal2vulkan/src/bind/indirect_commands.rs index c037089ad..197de3bd7 100644 --- a/crates/metal2vulkan/src/bind/indirect_commands.rs +++ b/crates/metal2vulkan/src/bind/indirect_commands.rs @@ -3,24 +3,17 @@ //! writes it: a function's command encoders (`compute_command`, `render_command`) are refused, //! `Unsupported{GpuEncodedIndirectCommands, NotImplemented}`. //! -//! A consumer that runs its own runtime on the compile layer needs it to execute and read back -//! indirect command buffers: [`CommandBuffer::initialize`] writes the header a -//! [`CommandDescriptor`] and an [`Inheritance`] fix and resets every record, +//! A consumer that writes an indirect command buffer's records on the CPU and reads them back +//! uses it (validation's case model and Metal executor do): [`CommandBuffer::initialize`] writes +//! the header a [`CommandDescriptor`] and an [`Inheritance`] fix and resets every record, //! [`CommandRecord::encode_into`] writes one command as the CPU's encoder sets it, and //! [`CommandBuffer::decode`] checks the storage (its sticky encoding fault, the header, //! every record against the descriptor) before [`CommandBuffer::records`] reads a range back as -//! [`CommandRecord`]s. [`CommandRecord::resolve_bindings`] picks each command's pipeline and -//! buffers from itself or from the executing encoder, and [`BufferBinding::resolve_buffer`] finds -//! the [`RegisteredBuffer`] whose interval holds a buffer's address. Storage may hold a written flag per command past the -//! records ([`written_flag_offset`]), which the consumer's writes of a record set, so a reset need -//! touch only the flagged records. +//! [`CommandRecord`]s. -pub use crate::indirect_commands::records_address; -pub use crate::indirect_commands::written_flag_offset; pub use crate::indirect_commands::{ - Action, AddressError, BindingError, Bindings, BufferBinding, BufferStage, CommandBuffer, - CommandBufferError, CommandDescriptor, CommandRecord, ComputeDispatch, Inheritance, - RecordError, RecordField, RecordView, RegisteredBuffer, RenderDraws, ResolvedBindings, - ResolvedBuffer, StateSource, BINDING_COUNT, COMMAND_BUFFER_HEADER_BYTES, COMMAND_BYTES, - RECORDS_ADDRESS_BASE, RECORDS_ID_LIMIT, THREADGROUP_BUFFER_ARGUMENT_COUNT, WRITTEN_FLAG_BYTES, + Action, Bindings, BufferBinding, BufferStage, CommandBuffer, CommandBufferError, + CommandDescriptor, CommandRecord, ComputeDispatch, Inheritance, RecordError, RecordView, + RenderDraws, StateSource, BINDING_COUNT, COMMAND_BUFFER_HEADER_BYTES, COMMAND_BYTES, + THREADGROUP_BUFFER_ARGUMENT_COUNT, }; diff --git a/crates/metal2vulkan/src/indirect_commands.rs b/crates/metal2vulkan/src/indirect_commands.rs index aa239de43..5a856987a 100644 --- a/crates/metal2vulkan/src/indirect_commands.rs +++ b/crates/metal2vulkan/src/indirect_commands.rs @@ -9,7 +9,7 @@ mod descriptor; pub use descriptor::{CommandDescriptor, ComputeDispatch, RenderDraws}; mod host; -pub use host::{BindingError, CommandBuffer, CommandBufferError, RecordView, ResolvedBindings}; +pub use host::{CommandBuffer, CommandBufferError, RecordView}; use std::fmt; use std::num::NonZeroU64; @@ -48,46 +48,6 @@ pub const COMMAND_BYTES: usize = ((THREADGROUP_WORD + THREADGROUP_COUNT + 2) * 4).next_multiple_of(8); /// Host-initialized command count, atomic encoding-fault flag, descriptor flags, and packed binding counts. pub const COMMAND_BUFFER_HEADER_BYTES: usize = 16; -/// Bytes of one command's written flag (a `u32`), past every record ([`written_flag_offset`]). -pub const WRITTEN_FLAG_BYTES: usize = 4; - -/// The byte offset of command `index`'s written flag in the storage of a buffer of `capacity` -/// commands: the flags follow the records, one `u32` a command. No translated function writes a -/// record or its flag. A consumer whose storage holds the flags, and whose own writes of the -/// records set them, knows a record whose flag is clear to hold what it last reset it to, and may -/// reset only the flagged ones, clearing each flag with its record. -pub const fn written_flag_offset(capacity: u32, index: u32) -> u64 { - COMMAND_BUFFER_HEADER_BYTES as u64 - + capacity as u64 * COMMAND_BYTES as u64 - + index as u64 * WRITTEN_FLAG_BYTES as u64 -} - -/// The guest address of the records of the indirect command buffer of resource ID 0, the null -/// one, which no records lie at ([`records_address`]). -pub const RECORDS_ADDRESS_BASE: u64 = 1 << 63; -/// How far an indirect command buffer's resource ID is shifted to give the guest address its -/// records start at past [`RECORDS_ADDRESS_BASE`] ([`records_address`]): 2^31 bytes from one ID's -/// start to the next's. Records of more bytes run past the next IDs' starts. -pub(crate) const RECORDS_ADDRESS_SHIFT: u32 = 31; -/// The first resource ID whose records [`records_address`] cannot place, 2^31: the IDs of indirect -/// command buffers run from 1 below it, as Metal's do (on an M3 Max, a reservation of 2^31 - 2 -/// handed out 2^31 - 1 next, and one of 2^31 to 2^32 - 1 never returned). The last ID's records -/// start 2^62 bytes below 2^64, so records of any length a device holds fit after any ID's start. -pub const RECORDS_ID_LIMIT: u64 = 1 << 31; - -/// The guest address the records of the indirect command buffer whose resource ID is `id` (below -/// [`RECORDS_ID_LIMIT`]) start at: `2^63 + id * 2^31`. An argument buffer's command-buffer member -/// holds the ID, as Metal's `gpuResourceID` and `setIndirectCommandBuffer:atIndex:` give it (small -/// integers from 1, measured on an M3 Max and an M4, or the IDs a reservation leaves next, up to -/// 2^31 - 1 on an M3 Max). Records of more than 2^31 bytes run past the next IDs' starts, and the -/// resident set keeps each records range whole. So a consumer that makes an -/// indirect command buffer with ID `id` makes its record buffer resident at `records_address(id)`, -/// a range no Metal buffer reaches (each lies below 2^63). The null ID 0 gives an address no -/// records start at. No translated function reaches the records through it: every encoder -/// operation is refused (`GpuEncodedIndirectCommands`). -pub const fn records_address(id: u64) -> u64 { - RECORDS_ADDRESS_BASE | (id << RECORDS_ADDRESS_SHIFT) -} /// The byte offsets of the header's and a record's fields, which the CPU's encoder writes and the /// device replay reads (`bind::replay`). @@ -213,112 +173,18 @@ impl BufferStage { } /// A buffer slot a setter set: the address Metal's getter answers and the attribute stride form. -/// A slot no setter set, or one a reset cleared, is none ([`Bindings::buffers`]). +/// A slot no setter set, or one a reset cleared, is none in its [`Bindings`]. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct BufferBinding { /// The buffer's address plus the low 32 bits of the offset set, or, for a nil buffer, the low /// 32 bits of the offset alone, as Metal keeps and answers it. Below /// [`BufferBinding::MIN_BUFFER_ADDRESS`] it names no buffer ([`BufferBinding::names_buffer`]); - /// at or above it, it must identify registered device storage. + /// at or above it, it names one. pub address: u64, /// None uses the pipeline's static stride. The all-bits-set value is reserved for None. pub attribute_stride: Option, } -/// A live host resource and its device-address interval, which -/// [`BufferBinding::resolve_buffer`] resolves a record's buffer address against. Registration -/// does not transfer ownership. -pub struct RegisteredBuffer<'a, T> { - resource: &'a T, - address: u64, - length: u64, -} - -/// The selected allocation and exact interior offset; no memory is copied or rebound. -#[non_exhaustive] -pub struct ResolvedBuffer<'a, T> { - /// The registered resource whose interval holds the address. - pub resource: &'a T, - /// The address's offset from the start of the resource's interval. - pub offset: u64, - /// The bytes of the interval from that offset to its end. - pub available_bytes: u64, -} - -/// Why a buffer address does not resolve ([`RegisteredBuffer::new`], -/// [`BufferBinding::resolve_buffer`]). -#[non_exhaustive] -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum AddressError { - /// A registration whose address is below [`BufferBinding::MIN_BUFFER_ADDRESS`], which no - /// binding names, whose length is zero, or whose interval passes the end of the address - /// space. - InvalidAllocation { - /// The registered address. - address: u64, - /// The registered length. - length: u64, - }, - /// More than one registered interval holds the requested bytes at the address. - Ambiguous { - /// The binding's address. - address: u64, - /// The bytes requested from it. - required_bytes: u64, - }, - /// No registered interval holds the requested bytes at the address. - Unavailable { - /// The binding's address. - address: u64, - /// The bytes requested from it. - required_bytes: u64, - }, -} - -impl fmt::Display for AddressError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::InvalidAllocation { address, length } => write!( - f, - "invalid registered buffer interval at {address:#x} with {length} bytes" - ), - Self::Ambiguous { - address, - required_bytes, - } => write!( - f, - "multiple registered buffers cover {required_bytes} bytes at {address:#x}" - ), - Self::Unavailable { - address, - required_bytes, - } => write!( - f, - "no registered buffer covers {required_bytes} bytes at {address:#x}" - ), - } - } -} - -impl std::error::Error for AddressError {} - -impl<'a, T> RegisteredBuffer<'a, T> { - /// Registers `resource` as holding `length` bytes from device address `address`. - pub fn new(resource: &'a T, address: u64, length: u64) -> Result { - if address < BufferBinding::MIN_BUFFER_ADDRESS - || length == 0 - || address.checked_add(length - 1).is_none() - { - return Err(AddressError::InvalidAllocation { address, length }); - } - Ok(Self { - resource, - address, - length, - }) - } -} - impl BufferBinding { /// The lowest address that names a buffer, 2^32: every Metal buffer address lies at or /// above it (Apple silicon's, and the runtime's address space, `[2^32, 2^47)`), so a lower @@ -329,47 +195,6 @@ impl BufferBinding { pub const fn names_buffer(&self) -> bool { self.address >= Self::MIN_BUFFER_ADDRESS } - - /// Find a unique live allocation covering the requested span without descriptor alignment rules. - /// Multiple covering registrations are rejected rather than resolved by registration order. - /// A nil buffer's binding stays unbound; the caller owns nullability, access, and shader - /// alignment policy. - /// A zero-byte span at the allocation end grants no permission to dereference that address. - pub fn resolve_buffer<'a, T>( - self, - buffers: &[RegisteredBuffer<'a, T>], - required_bytes: u64, - ) -> Result>, AddressError> { - if !self.names_buffer() { - return Ok(None); - } - let mut resolved = None; - for buffer in buffers { - let Some(offset) = self.address.checked_sub(buffer.address) else { - continue; - }; - let Some(available_bytes) = buffer.length.checked_sub(offset) else { - continue; - }; - if required_bytes <= available_bytes { - if resolved.is_some() { - return Err(AddressError::Ambiguous { - address: self.address, - required_bytes, - }); - } - resolved = Some(ResolvedBuffer { - resource: buffer.resource, - offset, - available_bytes, - }); - } - } - resolved.map(Some).ok_or(AddressError::Unavailable { - address: self.address, - required_bytes, - }) - } } /// Action to execute after applying the command's buffer, pipeline, and memory state. @@ -514,7 +339,7 @@ impl Bindings { /// cleared it. A record holds none as an address and a stride of 0 and a set slot's stride /// form as all ones (the pipeline's) or the stride, the answers of Metal's getters on a buffer /// of dynamic attribute strides. - pub fn buffers(&self, stage: BufferStage) -> &[Option; BINDING_COUNT] { + fn buffers(&self, stage: BufferStage) -> &[Option; BINDING_COUNT] { &self.buffers[stage.index()] } @@ -573,8 +398,8 @@ pub struct CommandRecord { /// Why a record was refused: its length, an unknown action, a barrier flag other than 0 or 1, /// the all-ones attribute stride, which stands for the pipeline's static stride, a stage-in -/// region beside a draw whose arguments take its words, or a field's index past what a record -/// holds. +/// region beside a draw whose arguments take its words, a malformed pipeline state, or a +/// threadgroup length beside an indexed patch draw. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RecordError { Length { @@ -598,13 +423,6 @@ pub enum RecordError { /// takes the first two lengths' words (`layout::CONTROL_POINT_INDICES`): a render command /// sets none. ThreadgroupMemoryLength, - /// A field's index past what a record holds: a buffer slot - /// at or past [`BINDING_COUNT`], or a threadgroup length at or past - /// [`THREADGROUP_BUFFER_ARGUMENT_COUNT`]. - Index { - index: usize, - count: usize, - }, } impl fmt::Display for RecordError { @@ -630,10 +448,6 @@ impl fmt::Display for RecordError { "an indexed patch draw's control-point index buffer takes the threadgroup \ lengths' first words", ), - Self::Index { index, count } => write!( - f, - "indirect command field index {index} is past the record's {count}" - ), } } } @@ -777,32 +591,6 @@ pub(crate) fn writes_of(action: &Action, barrier: bool) -> crate::pipeline::Comm writes } -/// One field of a command's record, as one CPU setter writes it. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum RecordField { - /// The action ([`CommandRecord::action`]): a dispatch or a draw. - Action(Action), - /// The barrier flag ([`CommandRecord::barrier`]). - Barrier(bool), - /// The pipeline the command names ([`Bindings::pipeline`]), set: a pipeline a reset retained - /// goes ([`CommandRecord::retained_pipeline`]). - Pipeline(NonZeroU64), - /// Slot `slot` of `stage`'s buffers ([`Bindings::buffers`]), set, or unset with `None`. - Buffer { - stage: BufferStage, - slot: usize, - binding: Option, - }, - /// Threadgroup-memory length `index` ([`CommandRecord::threadgroup_memory_lengths`]). - ThreadgroupMemoryLength { index: usize, length: u32 }, - /// The stage-in region ([`CommandRecord::stage_in_region`]). - StageInRegion([u32; 6]), - /// The imageblock size ([`CommandRecord::imageblock_size`]). - ImageblockSize([u16; 2]), -} - -impl CommandRecord {} - fn require_length(bytes: &[u8]) -> Result<(), RecordError> { if bytes.len() == COMMAND_BYTES { Ok(()) diff --git a/crates/metal2vulkan/src/indirect_commands/descriptor.rs b/crates/metal2vulkan/src/indirect_commands/descriptor.rs index 480f0db24..af1148b3f 100644 --- a/crates/metal2vulkan/src/indirect_commands/descriptor.rs +++ b/crates/metal2vulkan/src/indirect_commands/descriptor.rs @@ -48,16 +48,6 @@ pub struct RenderDraws { } impl RenderDraws { - /// Draws of primitives alone, Metal's `Draw`. - pub const PRIMITIVES: RenderDraws = RenderDraws { - primitives: true, - indexed: false, - patches: false, - indexed_patches: false, - mesh_threadgroups: false, - mesh_threads: false, - }; - /// The header's policy bits of the draws. fn bits(self) -> u32 { [ diff --git a/crates/metal2vulkan/src/indirect_commands/host.rs b/crates/metal2vulkan/src/indirect_commands/host.rs index e3d803973..6cc730c6b 100644 --- a/crates/metal2vulkan/src/indirect_commands/host.rs +++ b/crates/metal2vulkan/src/indirect_commands/host.rs @@ -1,15 +1,14 @@ //! The host's side of the record format: initializing a command buffer, and decoding and -//! checking what a producer wrote, before a replay reads it. The runtime's indirect command -//! buffers, a consumer's own runtime, validation's oracle and case model, and the crate's tests -//! use it; the binder's device replay decodes records on the device instead. +//! checking what a producer wrote, before a replay reads it. Validation's case model and Metal +//! executor, and the crate's tests, use it. use super::descriptor::CommandDescriptor; #[cfg(doc)] use super::THREADGROUP_BUFFER_ARGUMENT_COUNT; use super::{ - layout, require_length, writes_of, Action, Bindings, BufferBinding, BufferStage, CommandRecord, - Inheritance, RecordError, StateSource, BINDING_COUNT, BUFFER_STAGES, BUFFER_WORDS, - COMMAND_BUFFER_HEADER_BYTES, COMMAND_BYTES, HEADER_WORDS, THREADGROUP_COUNT, THREADGROUP_WORD, + layout, require_length, Action, Bindings, BufferBinding, BufferStage, CommandRecord, + Inheritance, RecordError, StateSource, BUFFER_WORDS, COMMAND_BUFFER_HEADER_BYTES, + COMMAND_BYTES, HEADER_WORDS, THREADGROUP_COUNT, THREADGROUP_WORD, }; use std::fmt; use std::num::NonZeroU64; @@ -171,42 +170,6 @@ fn require_buffer_length(bytes: &[u8], capacity: u32) -> Result<(), CommandBuffe } } -/// Borrowed state selection. The host must still resolve resource identities and pipeline limits. -#[derive(Clone, Copy, Debug)] -pub struct ResolvedBindings<'a> { - pub pipeline: Option, - /// Encoded command-local lengths; buffer inheritance does not replace explicit lengths. - /// Replay must validate the allocation for every used dynamic binding. - pub threadgroup_memory_lengths: &'a [u32; THREADGROUP_COUNT], - buffers: &'a [[Option; BINDING_COUNT]; BUFFER_STAGES], -} - -impl ResolvedBindings<'_> { - pub fn buffers(&self, stage: BufferStage) -> &[Option; BINDING_COUNT] { - &self.buffers[stage.index()] - } -} - -/// Why a command's state could not be resolved: a command that runs has no pipeline from the -/// state source its descriptor names. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum BindingError { - MissingPipeline { source: StateSource }, -} - -impl fmt::Display for BindingError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::MissingPipeline { source } => write!( - f, - "indirect command requires a pipeline from {source:?} state" - ), - } - } -} - -impl std::error::Error for BindingError {} - fn validate_record(bytes: &[u8]) -> Result<(Action, bool), RecordError> { require_length(bytes)?; let grid = [get_word(bytes, 4), get_word(bytes, 5), get_word(bytes, 6)]; @@ -286,36 +249,6 @@ fn get_u64(bytes: &[u8], word: usize) -> u64 { } impl CommandRecord { - /// Resolve the descriptor's state sources without copying bindings or changing the record. - /// A nonempty command requires a pipeline from the selected source: the other source is never - /// a fallback. Threadgroup lengths come from the command; allocation and synchronization - /// remain separate replay responsibilities. - pub fn resolve_bindings<'a>( - &'a self, - inheritance: Inheritance, - parent: &'a Bindings, - ) -> Result, BindingError> { - let pipeline = match inheritance.pipeline { - // A pipeline a reset retained runs, as Metal's does. - StateSource::Command => self.bindings.pipeline.or(self.retained_pipeline), - StateSource::Parent => parent.pipeline, - }; - if self.action != Action::Empty && pipeline.is_none() { - return Err(BindingError::MissingPipeline { - source: inheritance.pipeline, - }); - } - let buffers = match inheritance.buffers { - StateSource::Command => &self.bindings.buffers, - StateSource::Parent => &parent.buffers, - }; - Ok(ResolvedBindings { - pipeline, - buffers, - threadgroup_memory_lengths: &self.threadgroup_memory_lengths, - }) - } - /// Decode persistent state without executing it or resolving its host resource identities. pub fn decode(bytes: &[u8]) -> Result { RecordView::new(bytes).map(|view| view.record()) @@ -358,16 +291,6 @@ impl<'a> RecordView<'a> { }) } - /// [`CommandRecord::action`]. - pub fn action(&self) -> Action { - self.action - } - - /// [`CommandRecord::barrier`]. - pub fn barrier(&self) -> bool { - self.barrier - } - /// [`Bindings::pipeline`]: none where a reset retained the pipeline. pub fn pipeline(&self) -> Option { self.pipeline.filter(|_| !self.retained) @@ -378,19 +301,6 @@ impl<'a> RecordView<'a> { self.pipeline.filter(|_| self.retained) } - /// [`CommandRecord::kernel_pipeline`]. - pub fn kernel_pipeline(&self) -> bool { - self.kernel - } - - /// Slot `slot` of `stage`'s buffers, as [`Bindings::buffers`] holds it; none past - /// [`BINDING_COUNT`]. - pub fn buffer(&self, stage: BufferStage, slot: usize) -> Option { - (slot < BINDING_COUNT) - .then(|| binding_at(self.bytes, stage.index() * BINDING_COUNT + slot)) - .flatten() - } - /// Threadgroup-memory length `index`, as [`CommandRecord::threadgroup_memory_lengths`] holds /// it: 0 for the first two beside an indexed patch draw, whose control-point index buffer /// takes their words; none past [`THREADGROUP_BUFFER_ARGUMENT_COUNT`]. @@ -426,11 +336,6 @@ impl<'a> RecordView<'a> { ] } - /// [`CommandRecord::writes`] of the record. - pub fn writes(&self) -> crate::pipeline::CommandWrites { - writes_of(&self.action, self.barrier) - } - /// The whole record ([`CommandRecord::decode`]). pub fn record(&self) -> CommandRecord { let mut record = CommandRecord::default(); diff --git a/crates/metal2vulkan/src/indirect_commands/tests.rs b/crates/metal2vulkan/src/indirect_commands/tests.rs index c3f70d529..4397ebee0 100644 --- a/crates/metal2vulkan/src/indirect_commands/tests.rs +++ b/crates/metal2vulkan/src/indirect_commands/tests.rs @@ -13,29 +13,4 @@ const TEST_DESCRIPTOR: CommandDescriptor = CommandDescriptor::Compute { }; mod buffer_views; -mod inheritance; mod records; - -/// Each resource ID's records start at an address of their own, `2^63 + id * 2^31`, above every -/// Metal address (below 2^63): ID 1's at `2^63 + 2^31`, the null ID's below it, in the IDs' order, -/// and the last ID's 2^62 bytes below 2^64, so records of any length a device holds fit after it. -#[test] -fn each_records_id_has_a_start_of_its_own_above_the_metal_addresses() { - let stride = 1u64 << 31; - assert_eq!(records_address(0), 1 << 63); - assert_eq!(records_address(1), (1 << 63) + stride); - assert_eq!(RECORDS_ID_LIMIT, 1 << 31); - let last = RECORDS_ID_LIMIT - 1; - assert!(u128::from(records_address(last)) + (1u128 << 62) <= 1u128 << 64); - for id in [1, 2, 3, 65_536, 70_000, 1 << 26, (1 << 30) + 6, last] { - assert_eq!( - records_address(id) - records_address(id - 1), - stride, - "{id}" - ); - assert_eq!( - (records_address(id) - RECORDS_ADDRESS_BASE) >> RECORDS_ADDRESS_SHIFT, - id - ); - } -} diff --git a/crates/metal2vulkan/src/indirect_commands/tests/buffer_views.rs b/crates/metal2vulkan/src/indirect_commands/tests/buffer_views.rs index e9c86a7cd..4510ac2e9 100644 --- a/crates/metal2vulkan/src/indirect_commands/tests/buffer_views.rs +++ b/crates/metal2vulkan/src/indirect_commands/tests/buffer_views.rs @@ -1,90 +1,5 @@ use super::*; -/// The base of the test's allocations: the lowest address a binding names a buffer at. -const BASE: u64 = BufferBinding::MIN_BUFFER_ADDRESS; - -/// A binding of `address`, at the pipeline's stride. -fn at(address: u64) -> BufferBinding { - BufferBinding { - address, - attribute_stride: None, - } -} - -#[test] -fn buffer_resolution_rejects_ambiguous_registrations_in_either_order() { - let first = 1; - let second = 2; - for reversed in [false, true] { - let mut buffers = [ - RegisteredBuffer::new(&first, BASE + 0x1000, 64).unwrap(), - RegisteredBuffer::new(&second, BASE + 0x1020, 32).unwrap(), - ]; - if reversed { - buffers.reverse(); - } - assert!(matches!( - at(BASE + 0x1024).resolve_buffer(&buffers, 4), - Err(AddressError::Ambiguous { - address, - required_bytes: 4 - }) if address == BASE + 0x1024 - )); - let unique = at(BASE + 0x1004) - .resolve_buffer(&buffers, 4) - .unwrap() - .unwrap(); - assert!(std::ptr::eq(unique.resource, &first)); - assert_eq!(unique.offset, 4); - } -} - -#[test] -fn buffer_resolution_preserves_interior_offsets_and_aliases() { - let allocation = [0u8; 64]; - let buffers = [RegisteredBuffer::new(&allocation, BASE + 0x1000, 64).unwrap()]; - for (address, required, offset, available) in - [(0x1004, 4, 4, 60), (0x1008, 56, 8, 56), (0x1040, 0, 64, 0)] - { - let view = at(BASE + address) - .resolve_buffer(&buffers, required) - .unwrap() - .unwrap(); - assert!(std::ptr::eq(view.resource, &allocation)); - assert_eq!((view.offset, view.available_bytes), (offset, available)); - } - // Below 2^32 an address is a nil buffer's offset: it names no buffer, an allocation there - // included. - let low = [RegisteredBuffer::new(&allocation, BASE, 64).unwrap()]; - for address in [0, 0x30, BASE - 1] { - assert!(at(address).resolve_buffer(&low, 4).unwrap().is_none()); - } - for (address, required_bytes) in [(0xfff, 1), (0x1040, 1), (0x1041, 0), (0x1004, u64::MAX)] { - assert!(matches!( - at(BASE + address).resolve_buffer(&buffers, required_bytes), - Err(AddressError::Unavailable { .. }) - )); - } - let last_bytes = [RegisteredBuffer::new(&allocation, u64::MAX - 3, 4).unwrap()]; - let last = at(u64::MAX) - .resolve_buffer(&last_bytes, 1) - .unwrap() - .unwrap(); - assert_eq!((last.offset, last.available_bytes), (3, 1)); - for (address, length) in [ - (0, 4), - (0x1000, 4), - (BASE - 1, 4), - (BASE + 0x1000, 0), - (u64::MAX - 3, 8), - ] { - assert!(matches!( - RegisteredBuffer::new(&allocation, address, length), - Err(AddressError::InvalidAllocation { .. }) - )); - } -} - #[test] fn a_malformed_later_record_prevents_exposing_earlier_commands() { let mut bytes = vec![0; COMMAND_BUFFER_HEADER_BYTES + 2 * COMMAND_BYTES]; diff --git a/crates/metal2vulkan/src/indirect_commands/tests/inheritance.rs b/crates/metal2vulkan/src/indirect_commands/tests/inheritance.rs deleted file mode 100644 index 347f36e33..000000000 --- a/crates/metal2vulkan/src/indirect_commands/tests/inheritance.rs +++ /dev/null @@ -1,107 +0,0 @@ -use super::*; - -#[test] -fn pipeline_and_buffer_inheritance_select_independent_sources() { - let mut record = CommandRecord { - action: Action::DispatchThreadgroups { - grid: [1; 3], - local_size: [1; 3], - }, - bindings: Bindings { - pipeline: NonZeroU64::new(20), - ..Default::default() - }, - ..Default::default() - }; - let mut parent = Bindings { - pipeline: NonZeroU64::new(10), - ..Default::default() - }; - record.bindings.buffers_mut(BufferStage::Kernel)[0] = Some(BufferBinding { - address: 2 << 32, - attribute_stride: None, - }); - record.threadgroup_memory_lengths[0] = 16; - record.threadgroup_memory_lengths[THREADGROUP_COUNT - 1] = 64; - parent.buffers_mut(BufferStage::Kernel)[0] = Some(BufferBinding { - address: 1 << 32, - attribute_stride: None, - }); - for (pipeline, expected_pipeline) in [(StateSource::Command, 20), (StateSource::Parent, 10)] { - for (buffers, expected_address) in [ - (StateSource::Command, 2 << 32), - (StateSource::Parent, 1 << 32), - ] { - let resolved = record - .resolve_bindings(Inheritance { pipeline, buffers }, &parent) - .unwrap(); - assert_eq!(resolved.pipeline.unwrap().get(), expected_pipeline); - assert_eq!(resolved.threadgroup_memory_lengths[0], 16); - assert_eq!( - resolved.threadgroup_memory_lengths[THREADGROUP_COUNT - 1], - 64 - ); - assert!(std::ptr::eq( - resolved.threadgroup_memory_lengths, - &record.threadgroup_memory_lengths - )); - assert_eq!( - resolved.buffers(BufferStage::Kernel)[0].map(|b| b.address), - Some(expected_address) - ); - let owner = match buffers { - StateSource::Command => &record.bindings, - StateSource::Parent => &parent, - }; - assert!(std::ptr::eq( - resolved.buffers(BufferStage::Kernel), - owner.buffers(BufferStage::Kernel) - )); - } - } - let before = record.clone(); - parent.pipeline = NonZeroU64::new(30); - let resolved = record - .resolve_bindings( - Inheritance { - pipeline: StateSource::Parent, - buffers: StateSource::Command, - }, - &parent, - ) - .unwrap(); - assert_eq!(resolved.pipeline.unwrap().get(), 30); - assert_eq!(record, before); -} - -#[test] -fn a_missing_selected_pipeline_does_not_fall_back_to_the_other_source() { - for source in [StateSource::Command, StateSource::Parent] { - let mut record = CommandRecord { - action: Action::DispatchThreads { - grid: [1; 3], - local_size: [1; 3], - }, - ..Default::default() - }; - let mut parent = Bindings::default(); - match source { - StateSource::Command => parent.pipeline = NonZeroU64::new(1), - StateSource::Parent => record.bindings.pipeline = NonZeroU64::new(2), - }; - let policy = Inheritance { - pipeline: source, - buffers: source, - }; - assert_eq!( - record.resolve_bindings(policy, &parent).unwrap_err(), - BindingError::MissingPipeline { source } - ); - record.action = Action::Empty; - assert!(record - .resolve_bindings(policy, &parent) - .unwrap() - .pipeline - .is_none()); - } -} diff --git a/crates/metal2vulkan/src/indirect_commands/tests/records.rs b/crates/metal2vulkan/src/indirect_commands/tests/records.rs index 160cf56c2..73828a81b 100644 --- a/crates/metal2vulkan/src/indirect_commands/tests/records.rs +++ b/crates/metal2vulkan/src/indirect_commands/tests/records.rs @@ -14,12 +14,12 @@ fn reset_clears_action_and_bindings_to_zero() { } /// A compute command's reset keeps the pipeline it executes with, reported cleared: the pipeline -/// word holds it and the state word flags it, `decode` reports it as `retained_pipeline` beside no -/// set pipeline, and `resolve_bindings` executes it. A retained pipeline beside a set one does -/// not encode; a state word with a bit other than `RETAINED` and `KERNEL_PIPELINE`, or -/// `RETAINED` without a pipeline, does not decode. +/// word holds it and the state word flags it, and `decode` reports it as `retained_pipeline` +/// beside no set pipeline. A retained pipeline beside a set one does not encode; a state word with +/// a bit other than `RETAINED` and `KERNEL_PIPELINE`, or `RETAINED` without a pipeline, does not +/// decode. #[test] -fn a_retained_pipeline_runs_and_reads_back_cleared() { +fn a_retained_pipeline_reads_back_cleared() { let token = NonZeroU64::new(0x0123_4567_89ab_cdef); let record = CommandRecord { action: Action::DispatchThreads { @@ -37,15 +37,6 @@ fn a_retained_pipeline_runs_and_reads_back_cleared() { let decoded = CommandRecord::decode(&bytes).unwrap(); assert_eq!(decoded, record); assert_eq!(decoded.bindings.pipeline, None); - let owned = Inheritance { - pipeline: StateSource::Command, - buffers: StateSource::Command, - }; - let parent = Bindings::default(); - assert_eq!( - decoded.resolve_bindings(owned, &parent).unwrap().pipeline, - token - ); // A set pipeline is reported, and its state word is 0. let set = CommandRecord { bindings: Bindings { @@ -108,7 +99,6 @@ fn a_kernel_s_pipeline_is_told_from_the_cpu_s() { record.encode_into(&mut bytes).unwrap(); assert_eq!(&bytes[state..state + 4], &word.to_le_bytes()); assert_eq!(&CommandRecord::decode(&bytes).unwrap(), record); - assert!(RecordView::new(&bytes).unwrap().kernel_pipeline()); } // Flagged beside no pipeline. let unnamed = CommandRecord { @@ -236,7 +226,14 @@ fn malformed_records_are_rejected_before_host_replay() { #[test] fn a_render_descriptor_allows_draws_and_refuses_dispatches() { let render = CommandDescriptor::Render { - draws: RenderDraws::PRIMITIVES, + draws: RenderDraws { + primitives: true, + indexed: false, + patches: false, + indexed_patches: false, + mesh_threadgroups: false, + mesh_threads: false, + }, max_vertex_buffer_bind_count: 2, max_fragment_buffer_bind_count: 3, max_object_buffer_bind_count: 0, diff --git a/crates/metal2vulkan/src/memory/provenance.rs b/crates/metal2vulkan/src/memory/provenance.rs index 7c95219e7..7f98c1770 100644 --- a/crates/metal2vulkan/src/memory/provenance.rs +++ b/crates/metal2vulkan/src/memory/provenance.rs @@ -1828,8 +1828,7 @@ fn exact_member_at<'e>( /// through a pointer whose roots are `roots` and whose offset range is `range` reads exactly one /// command-buffer or pipeline-state member's field at a translation-time constant offset in its /// argument buffer's first element, or `None`. The member's field is its word: the command buffer's -/// resource ID (its records lie at `indirect_commands::records_address` of it), or the pipeline -/// template's host-registered token. +/// resource ID, or the pipeline template's host-registered token. pub(crate) fn object_handle_load( e: &Entry, abi: &AbiIndex, diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 47d59a381..8d52ab84b 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -64,7 +64,6 @@ assoc-const metal2vulkan-runtime::Texture::FLOAT_DEPTH_UPLOAD_NOTE pub const FLO assoc-const metal2vulkan-runtime::TextureSwizzleChannels::DEFAULT pub const DEFAULT: TextureSwizzleChannels assoc-const metal2vulkan::bind::AstcDecode::BLOCK_BYTES pub const BLOCK_BYTES: u32 assoc-const metal2vulkan::bind::indirect_commands::BufferBinding::MIN_BUFFER_ADDRESS pub const MIN_BUFFER_ADDRESS: u64 -assoc-const metal2vulkan::bind::indirect_commands::RenderDraws::PRIMITIVES pub const PRIMITIVES: RenderDraws assoc-const metal2vulkan::device::ApiVersion::V1_2 pub const V1_2: ApiVersion assoc-const metal2vulkan::device::ApiVersion::V1_3 pub const V1_3: ApiVersion assoc-const metal2vulkan::device::DevicePolicy::RESIDENT_TABLES pub const RESIDENT_TABLES: DevicePolicy @@ -216,7 +215,6 @@ assoc-const-value metal2vulkan-runtime::Texture::FLOAT_DEPTH_UPLOAD_NOTE Precisi assoc-const-value metal2vulkan-runtime::TextureSwizzleChannels::DEFAULT TextureSwizzleChannels assoc-const-value metal2vulkan::bind::AstcDecode::BLOCK_BYTES 16 assoc-const-value metal2vulkan::bind::indirect_commands::BufferBinding::MIN_BUFFER_ADDRESS 1 <<32 -assoc-const-value metal2vulkan::bind::indirect_commands::RenderDraws::PRIMITIVES RenderDraws assoc-const-value metal2vulkan::device::ApiVersion::V1_2 ApiVersion assoc-const-value metal2vulkan::device::ApiVersion::V1_3 ApiVersion assoc-const-value metal2vulkan::device::DevicePolicy::RESIDENT_TABLES DevicePolicy @@ -360,10 +358,7 @@ const metal2vulkan::bind::MAX_SCREEN_EXTENT pub const MAX_SCREEN_EXTENT: u32 const metal2vulkan::bind::indirect_commands::BINDING_COUNT pub const BINDING_COUNT: usize const metal2vulkan::bind::indirect_commands::COMMAND_BUFFER_HEADER_BYTES pub const COMMAND_BUFFER_HEADER_BYTES: usize const metal2vulkan::bind::indirect_commands::COMMAND_BYTES pub const COMMAND_BYTES: usize -const metal2vulkan::bind::indirect_commands::RECORDS_ADDRESS_BASE pub const RECORDS_ADDRESS_BASE: u64 -const metal2vulkan::bind::indirect_commands::RECORDS_ID_LIMIT pub const RECORDS_ID_LIMIT: u64 const metal2vulkan::bind::indirect_commands::THREADGROUP_BUFFER_ARGUMENT_COUNT pub const THREADGROUP_BUFFER_ARGUMENT_COUNT: u32 -const metal2vulkan::bind::indirect_commands::WRITTEN_FLAG_BYTES pub const WRITTEN_FLAG_BYTES: usize const metal2vulkan::cache::ARTIFACT_FORMAT_VERSION pub const ARTIFACT_FORMAT_VERSION: u32 const metal2vulkan::cache::RUNTIME_VERSION pub const RUNTIME_VERSION: u32 const metal2vulkan::cache::SEMANTICS_VERSION pub const SEMANTICS_VERSION: u32 @@ -425,10 +420,7 @@ const-value metal2vulkan::bind::MAX_SCREEN_EXTENT 1 <<16 const-value metal2vulkan::bind::indirect_commands::BINDING_COUNT 32 const-value metal2vulkan::bind::indirect_commands::COMMAND_BUFFER_HEADER_BYTES 16 const-value metal2vulkan::bind::indirect_commands::COMMAND_BYTES ((THREADGROUP_WORD + THREADGROUP_COUNT + 2) * 4).next_multiple_of(8) -const-value metal2vulkan::bind::indirect_commands::RECORDS_ADDRESS_BASE 1 <<63 -const-value metal2vulkan::bind::indirect_commands::RECORDS_ID_LIMIT 1 <<31 const-value metal2vulkan::bind::indirect_commands::THREADGROUP_BUFFER_ARGUMENT_COUNT 31 -const-value metal2vulkan::bind::indirect_commands::WRITTEN_FLAG_BYTES 4 const-value metal2vulkan::metal::format::BICUBIC_TEXELS_UNBOUND crate::metal::bicubic::BicubicTexels::NEUTRAL.0 const-value metal2vulkan::metal::sampler::NOT_MIPMAPPED_MAX_LOD 0.25 const-value metal2vulkan::metal::vertex::MAX_VERTEX_ALIGNMENT 4 @@ -635,14 +627,11 @@ enum metal2vulkan::bind::EtcTexels #[cfg_attr(feature = "serde", derive(serde::S enum metal2vulkan::bind::RateMapError #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum RateMapError enum metal2vulkan::bind::UnpinnedCompile #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum UnpinnedCompile enum metal2vulkan::bind::indirect_commands::Action #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum Action -enum metal2vulkan::bind::indirect_commands::AddressError #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum AddressError -enum metal2vulkan::bind::indirect_commands::BindingError #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum BindingError enum metal2vulkan::bind::indirect_commands::BufferStage #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum BufferStage enum metal2vulkan::bind::indirect_commands::CommandBufferError #[derive(Clone, Debug, PartialEq, Eq)] pub enum CommandBufferError enum metal2vulkan::bind::indirect_commands::CommandDescriptor #[derive(Clone, Debug, PartialEq, Eq)] pub enum CommandDescriptor enum metal2vulkan::bind::indirect_commands::ComputeDispatch #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ComputeDispatch enum metal2vulkan::bind::indirect_commands::RecordError #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RecordError -enum metal2vulkan::bind::indirect_commands::RecordField #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RecordField enum metal2vulkan::bind::indirect_commands::StateSource #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum StateSource enum metal2vulkan::cache::ArtifactError #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum ArtifactError enum metal2vulkan::device::Exposure #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum Exposure @@ -1916,11 +1905,6 @@ field metal2vulkan::bind::indirect_commands::RenderDraws.mesh_threadgroups pub m field metal2vulkan::bind::indirect_commands::RenderDraws.mesh_threads pub mesh_threads: bool field metal2vulkan::bind::indirect_commands::RenderDraws.patches pub patches: bool field metal2vulkan::bind::indirect_commands::RenderDraws.primitives pub primitives: bool -field metal2vulkan::bind::indirect_commands::ResolvedBindings.pipeline pub pipeline: Option -field metal2vulkan::bind::indirect_commands::ResolvedBindings.threadgroup_memory_lengths pub threadgroup_memory_lengths: &'a [u32; THREADGROUP_COUNT] -field metal2vulkan::bind::indirect_commands::ResolvedBuffer.available_bytes pub available_bytes: u64 -field metal2vulkan::bind::indirect_commands::ResolvedBuffer.offset pub offset: u64 -field metal2vulkan::bind::indirect_commands::ResolvedBuffer.resource pub resource: &'a T field metal2vulkan::cache::SpecializationKey.data pub data: Vec field metal2vulkan::cache::SpecializationKey.entries pub entries: Vec field metal2vulkan::cache::VariantKey.address_maps pub address_maps: BTreeMap @@ -2807,8 +2791,6 @@ fn metal2vulkan::bind::alpha_test_code pub fn alpha_test_code(reference: f32) -> fn metal2vulkan::bind::clamped_depth pub const fn clamped_depth(bits: u32) -> u32 fn metal2vulkan::bind::function_table_entry_offset pub fn function_table_entry_offset(index: u32) -> u64 fn metal2vulkan::bind::function_table_header pub fn function_table_header(size: u32) -> [u32; 2] -fn metal2vulkan::bind::indirect_commands::records_address pub const fn records_address(id: u64) -> u64 -fn metal2vulkan::bind::indirect_commands::written_flag_offset pub const fn written_flag_offset(capacity: u32, index: u32) -> u64 fn metal2vulkan::device::vk_stage pub fn vk_stage(stage: Stage) -> vk::ShaderStage fn metal2vulkan::metal::format::alpha_in_red pub fn alpha_in_red(pf: PixelFormat, profile: &DeviceProfile) -> bool fn metal2vulkan::metal::format::alpha_in_red_format pub fn alpha_in_red_format(pf: PixelFormat) -> Option @@ -6221,7 +6203,6 @@ method metal2vulkan::bind::SamplerDescriptor::new pub fn new() -> SamplerDescrip method metal2vulkan::bind::SamplerDescriptor::shape pub fn shape(&self) -> SamplerShape method metal2vulkan::bind::StageInRegion::new pub fn new(origin: [u32; 3], size: [u32; 3]) -> StageInRegion method metal2vulkan::bind::indirect_commands::Action::writes pub fn writes(&self) -> crate::pipeline::CommandWrites -method metal2vulkan::bind::indirect_commands::Bindings::buffers pub fn buffers(&self, stage: BufferStage) -> &[Option; BINDING_COUNT] method metal2vulkan::bind::indirect_commands::Bindings::buffers_mut pub fn buffers_mut(&mut self, stage: BufferStage) -> &mut [Option; BINDING_COUNT] method metal2vulkan::bind::indirect_commands::BufferBinding::buffer_alignment pub fn buffer_alignment(&self) -> u64 method metal2vulkan::bind::indirect_commands::BufferBinding::buffer_data_size pub fn buffer_data_size(&self) -> u64 @@ -6229,7 +6210,6 @@ method metal2vulkan::bind::indirect_commands::BufferBinding::buffer_data_type pu method metal2vulkan::bind::indirect_commands::BufferBinding::buffer_pointer_type pub fn buffer_pointer_type(&self) -> Option<&PointerType> method metal2vulkan::bind::indirect_commands::BufferBinding::buffer_struct_type pub fn buffer_struct_type(&self) -> Option<&StructType> method metal2vulkan::bind::indirect_commands::BufferBinding::names_buffer pub const fn names_buffer(&self) -> bool -method metal2vulkan::bind::indirect_commands::BufferBinding::resolve_buffer pub fn resolve_buffer<'a, T>(self, buffers: &[RegisteredBuffer<'a, T>], required_bytes: u64) -> Result>, AddressError> method metal2vulkan::bind::indirect_commands::BufferStage::of pub const fn of(render: bool) -> [BufferStage; BUFFER_STAGES] method metal2vulkan::bind::indirect_commands::CommandBuffer::decode pub fn decode(bytes: &'a [u8], descriptor: &CommandDescriptor, inheritance: Inheritance) -> Result method metal2vulkan::bind::indirect_commands::CommandBuffer::initialize pub fn initialize(bytes: &mut [u8], capacity: u32, descriptor: &CommandDescriptor, inheritance: Inheritance) -> Result<(), CommandBufferError> @@ -6241,13 +6221,8 @@ method metal2vulkan::bind::indirect_commands::CommandDescriptor::validate_header method metal2vulkan::bind::indirect_commands::CommandDescriptor::validate_record pub fn validate_record(&self, record: &CommandRecord) -> Result<(), String> method metal2vulkan::bind::indirect_commands::CommandRecord::decode pub fn decode(bytes: &[u8]) -> Result method metal2vulkan::bind::indirect_commands::CommandRecord::encode_into pub fn encode_into(&self, bytes: &mut [u8]) -> Result<(), RecordError> -method metal2vulkan::bind::indirect_commands::CommandRecord::resolve_bindings pub fn resolve_bindings<'a>(&'a self, inheritance: Inheritance, parent: &'a Bindings) -> Result, BindingError> method metal2vulkan::bind::indirect_commands::CommandRecord::writes pub fn writes(&self) -> crate::pipeline::CommandWrites -method metal2vulkan::bind::indirect_commands::RecordView::action pub fn action(&self) -> Action -method metal2vulkan::bind::indirect_commands::RecordView::barrier pub fn barrier(&self) -> bool -method metal2vulkan::bind::indirect_commands::RecordView::buffer pub fn buffer(&self, stage: BufferStage, slot: usize) -> Option method metal2vulkan::bind::indirect_commands::RecordView::imageblock_size pub fn imageblock_size(&self) -> [u16; 2] -method metal2vulkan::bind::indirect_commands::RecordView::kernel_pipeline pub fn kernel_pipeline(&self) -> bool method metal2vulkan::bind::indirect_commands::RecordView::new pub fn new(bytes: &'a [u8]) -> Result, RecordError> method metal2vulkan::bind::indirect_commands::RecordView::pipeline pub fn pipeline(&self) -> Option method metal2vulkan::bind::indirect_commands::RecordView::record pub fn record(&self) -> CommandRecord @@ -6255,9 +6230,6 @@ method metal2vulkan::bind::indirect_commands::RecordView::record_into pub fn rec method metal2vulkan::bind::indirect_commands::RecordView::retained_pipeline pub fn retained_pipeline(&self) -> Option method metal2vulkan::bind::indirect_commands::RecordView::stage_in_region pub fn stage_in_region(&self) -> [u32; 6] method metal2vulkan::bind::indirect_commands::RecordView::threadgroup_memory_length pub fn threadgroup_memory_length(&self, index: usize) -> Option -method metal2vulkan::bind::indirect_commands::RecordView::writes pub fn writes(&self) -> crate::pipeline::CommandWrites -method metal2vulkan::bind::indirect_commands::RegisteredBuffer::new pub fn new(resource: &'a T, address: u64, length: u64) -> Result -method metal2vulkan::bind::indirect_commands::ResolvedBindings::buffers pub fn buffers(&self, stage: BufferStage) -> &[Option; BINDING_COUNT] method metal2vulkan::cache::PipelineKey::digest pub const fn digest(&self) -> &Hash256 method metal2vulkan::cache::PipelineKey::new pub const fn new(hash: Hash256) -> PipelineKey method metal2vulkan::cache::SpecializationKey::new pub fn new() -> SpecializationKey @@ -6937,10 +6909,7 @@ struct metal2vulkan::bind::indirect_commands::CommandBuffer pub struct CommandBu struct metal2vulkan::bind::indirect_commands::CommandRecord #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct CommandRecord struct metal2vulkan::bind::indirect_commands::Inheritance #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Inheritance struct metal2vulkan::bind::indirect_commands::RecordView #[derive(Clone, Copy, Debug)] pub struct RecordView<'a> -struct metal2vulkan::bind::indirect_commands::RegisteredBuffer pub struct RegisteredBuffer<'a, T> struct metal2vulkan::bind::indirect_commands::RenderDraws #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct RenderDraws -struct metal2vulkan::bind::indirect_commands::ResolvedBindings #[derive(Clone, Copy, Debug)] pub struct ResolvedBindings<'a> -struct metal2vulkan::bind::indirect_commands::ResolvedBuffer #[non_exhaustive] pub struct ResolvedBuffer<'a, T> struct metal2vulkan::cache::PipelineKey #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct PipelineKey(pub Hash256) struct metal2vulkan::cache::SpecializationKey #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct SpecializationKey struct metal2vulkan::cache::VariantKey #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct VariantKey @@ -7194,10 +7163,6 @@ trait-impl metal2vulkan::bind::RateMapError impl fmt::Display impl fmt::Display trait-impl metal2vulkan::bind::RateMapError impl std::error::Error impl std::error::Error for RateMapError trait-impl metal2vulkan::bind::SamplerDescriptor impl Default impl Default for SamplerDescriptor trait-impl metal2vulkan::bind::UnpinnedCompile impl fmt::Display impl fmt::Display for UnpinnedCompile -trait-impl metal2vulkan::bind::indirect_commands::AddressError impl fmt::Display impl fmt::Display for AddressError -trait-impl metal2vulkan::bind::indirect_commands::AddressError impl std::error::Error impl std::error::Error for AddressError -trait-impl metal2vulkan::bind::indirect_commands::BindingError impl fmt::Display impl fmt::Display for BindingError -trait-impl metal2vulkan::bind::indirect_commands::BindingError impl std::error::Error impl std::error::Error for BindingError trait-impl metal2vulkan::bind::indirect_commands::CommandBufferError impl fmt::Display impl fmt::Display for CommandBufferError trait-impl metal2vulkan::bind::indirect_commands::CommandBufferError impl std::error::Error impl std::error::Error for CommandBufferError trait-impl metal2vulkan::bind::indirect_commands::RecordError impl fmt::Display impl fmt::Display for RecordError @@ -8846,10 +8811,6 @@ variant metal2vulkan::bind::indirect_commands::Action::DrawMeshThreads DrawMeshT variant metal2vulkan::bind::indirect_commands::Action::DrawPatches DrawPatches { control_points: u32, patch_start: u32, patch_count: u32, patch_index_buffer: u64, instance_count: u32, base_instance: u32, factor_buffer: u64, factor_instance_stride: u32, factor_scale: u32 } variant metal2vulkan::bind::indirect_commands::Action::DrawPrimitives DrawPrimitives { primitive_type: u32, vertex_start: u32, vertex_count: u32, instance_count: u32, base_instance: u32 } variant metal2vulkan::bind::indirect_commands::Action::Empty Empty -variant metal2vulkan::bind::indirect_commands::AddressError::Ambiguous Ambiguous { address: u64, required_bytes: u64 } -variant metal2vulkan::bind::indirect_commands::AddressError::InvalidAllocation InvalidAllocation { address: u64, length: u64 } -variant metal2vulkan::bind::indirect_commands::AddressError::Unavailable Unavailable { address: u64, required_bytes: u64 } -variant metal2vulkan::bind::indirect_commands::BindingError::MissingPipeline MissingPipeline { source: StateSource } variant metal2vulkan::bind::indirect_commands::BufferStage::Fragment Fragment variant metal2vulkan::bind::indirect_commands::BufferStage::Kernel Kernel variant metal2vulkan::bind::indirect_commands::BufferStage::Mesh Mesh @@ -8868,19 +8829,11 @@ variant metal2vulkan::bind::indirect_commands::ComputeDispatch::Threadgroups Thr variant metal2vulkan::bind::indirect_commands::ComputeDispatch::Threads Threads variant metal2vulkan::bind::indirect_commands::RecordError::Action Action { value: u32 } variant metal2vulkan::bind::indirect_commands::RecordError::Barrier Barrier { value: u32 } -variant metal2vulkan::bind::indirect_commands::RecordError::Index Index { index: usize, count: usize } variant metal2vulkan::bind::indirect_commands::RecordError::Length Length { actual: usize } variant metal2vulkan::bind::indirect_commands::RecordError::PipelineState PipelineState variant metal2vulkan::bind::indirect_commands::RecordError::ReservedStride ReservedStride variant metal2vulkan::bind::indirect_commands::RecordError::StageInRegion StageInRegion variant metal2vulkan::bind::indirect_commands::RecordError::ThreadgroupMemoryLength ThreadgroupMemoryLength -variant metal2vulkan::bind::indirect_commands::RecordField::Action Action(Action) -variant metal2vulkan::bind::indirect_commands::RecordField::Barrier Barrier(bool) -variant metal2vulkan::bind::indirect_commands::RecordField::Buffer Buffer { stage: BufferStage, slot: usize, binding: Option } -variant metal2vulkan::bind::indirect_commands::RecordField::ImageblockSize ImageblockSize([u16; 2]) -variant metal2vulkan::bind::indirect_commands::RecordField::Pipeline Pipeline(NonZeroU64) -variant metal2vulkan::bind::indirect_commands::RecordField::StageInRegion StageInRegion([u32; 6]) -variant metal2vulkan::bind::indirect_commands::RecordField::ThreadgroupMemoryLength ThreadgroupMemoryLength { index: usize, length: u32 } variant metal2vulkan::bind::indirect_commands::StateSource::Command Command variant metal2vulkan::bind::indirect_commands::StateSource::Parent Parent variant metal2vulkan::cache::ArtifactError::Corrupt Corrupt diff --git a/crates/metal2vulkan/tests/api_surface.rs b/crates/metal2vulkan/tests/api_surface.rs index 544a91a61..9d4001cd2 100644 --- a/crates/metal2vulkan/tests/api_surface.rs +++ b/crates/metal2vulkan/tests/api_surface.rs @@ -463,8 +463,6 @@ surface! { } "bind::indirect_commands" => metal2vulkan::bind::indirect_commands { enum Action E; - enum AddressError N; - enum BindingError E; struct Bindings O; struct BufferBinding E; enum BufferStage E; @@ -475,22 +473,13 @@ surface! { enum ComputeDispatch E; struct Inheritance E; enum RecordError E; - enum RecordField E; struct RecordView<'static> O; - struct RegisteredBuffer<'static, u8> O; struct RenderDraws E; - struct ResolvedBindings O; - struct ResolvedBuffer<'static, u8> N; enum StateSource E; const BINDING_COUNT; const COMMAND_BUFFER_HEADER_BYTES; const COMMAND_BYTES; - const RECORDS_ADDRESS_BASE; - const RECORDS_ID_LIMIT; const THREADGROUP_BUFFER_ARGUMENT_COUNT; - const WRITTEN_FLAG_BYTES; - fn records_address; - fn written_flag_offset; } "cache" => metal2vulkan::cache { type Hash256; diff --git a/docs/API.md b/docs/API.md index face45465..27df8a10d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1346,12 +1346,7 @@ as its replay variant (`VariantKey::replay_bindings`), whose vertex and fragment each command's buffers from slot tables in memory, and as its merged variant (`VariantKey::merged_draws`), whose vertex function finds its command in one merged draw by a prefix of the commands' first vertices and runs the command's vertex, -instance and buffers, in the commands' order. A buffer's records start at -`bind::indirect_commands::records_address` of its ID, outside every Metal address; records may -run past later IDs' starts, and a resident set keeps each records range whole. Storage may hold a written flag per command, -a `u32` a command past the records (`bind::indirect_commands::written_flag_offset`): a consumer -whose own writes of the records set the flags may reset only the flagged records of a run of -commands, clearing each flag with its record. +instance and buffers, in the commands' order. ## 7. Caching