RUNTIME 2242: an ICB's setters write through one batch, mostly without the lock; set_render_command and set_compute_command
An indirect command buffer's CPU setters, after RUNTIME 2238's dense table and one hold: every setter write now goes through one per-command batch (one storage pointer, one count of the writes made without the lock), written into in place rather than handing back a ~180-byte plan (which made a first form slower than before). The written flag (SEMANTICS 2097) is set in the one write helper, write_field, by the rule unchanged: every setter write sets it, a write of the reset record clears it. A draw, a dispatch, a set barrier and a cleared barrier the edits' summary already holds, like a buffer slot before, take no lock where the GPU may not have written the buffer, checked against an atomic mirror of the summary set under the lock; a pipeline state the command already names is set again with no lock and no CallHold (an atomic (id, serial, kind) mirror per command; a recovery's carry forgets it, so the next set redoes every check). New public calls IndirectCommandBuffer::set_render_command / set_compute_command (an index and a list of sets, no handle and no Arc clone; index and kind refusals at place 0) and the handle's set_each; borrowed RenderAt/ComputeAt views. docs/API.md says which setter writes take no lock; the carry docs say a write made without the lock does not wait for a carry (as buffer slots' did; a set racing a device recovery may write through the old mapping). Verified (icbset, f403b6e922 on33de04117d), ns a command, median, 16384 commands, msi lavapipe (26658, two passes), developmente93b3f192e-> tip: full render slot 142.6/147.6 -> 100.7/100.1; compute slot 119.3/123.0 -> 77.5/77.5; three fields 77.1/78.8 -> 71.8/71.9; draw only 43.5/43.9 -> 34.0/34.0; set_render_command 94.7, set_compute_command 78.9. 780M (26754, 256 commands): full slot 154.3/167.7 -> 111.0/117.0, compute 123.3/122.7 -> 93.1/87.8. lavapipe ICB set 154/154, including a test of which way each write went and set_each/set_render_command against one setter at a time; negative control (a whole-record read-modify-write in write_field) fails the strengthened two-thread test (26658). 780M: the 6 ICB device tests and set_states pass. clippy plain / --cfg m2v_gpu / --cfg m2v_cpu_icd and rustdoc 0 (26682, 26756). RUNTIME_VERSION 2241 -> 2242.
This commit is contained in:
1 parent
fe048e0a64
commit
20d04dbd5e
13 files changed
+2672
-616
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -8,8 +8,10 @@
|
||||
//! they are; in pooled host-visible memory, new memory there, the records lost with the
|
||||
//! `VkDevice`, whose memory Vulkan makes undefined (vkspec 5.2.3, "Lost Device"), written again
|
||||
//! as a new buffer's: its header, every command reset, its slots past them zero. The CPU's
|
||||
//! writes of the records wait for the carry (`pipelines`), and a host read outside a command
|
||||
//! buffer's work holds the storage's parts it reads.
|
||||
//! writes of the records under `pipelines` wait for the carry; a setter's write without it
|
||||
//! (`Batch`: one that adds nothing to what the records may hold) does not, and one meanwhile
|
||||
//! races the carry. A host read outside a command buffer's work holds the storage's parts it
|
||||
//! reads.
|
||||
//! - **What stays.** The object, its records ID, address, `gpuResourceID`, `uniqueIdentifier` and
|
||||
//! label, which are the device's line's rather than a generation's (`device/line.rs`'s
|
||||
//! `Carried`); the threadgroup lengths past the last command's, which the host keeps; what its
|
||||
@@ -64,6 +66,9 @@ impl IndirectCommandBuffer {
|
||||
return Ok(Contents::Kept);
|
||||
}
|
||||
let mut commands = lock(&shared.pipelines);
|
||||
// Each command's next set of its state checked again against the generation it meets,
|
||||
// under the lock, whether the carry succeeds or not.
|
||||
commands.states.forget_keys();
|
||||
// The slots past the records first: a buffer whose storage stays the lost generation's
|
||||
// stays whole there, its device that of its storage (`generation`).
|
||||
if let Some(overflow) = &shared.overflow {
|
||||
|
||||
@@ -0,0 +1,576 @@
|
||||
//! A command's setters called in turn in one call ([`IndirectRenderCommand::set_each`],
|
||||
//! [`IndirectComputeCommand::set_each`], and without a command's handle
|
||||
//! [`IndirectCommandBuffer::set_render_command`] and
|
||||
//! [`IndirectCommandBuffer::set_compute_command`]): a runtime extension with no Metal
|
||||
//! counterpart, whose `MTLIndirectRenderCommand` and `MTLIndirectComputeCommand` have the setters
|
||||
//! alone. Each call does what its setter does, refusals included; the first refused stops the
|
||||
//! rest, its place answered with its error, and the calls before it stay made, as they would have
|
||||
//! one setter call at a time. Their writes are one [`Batch`]: the storage's bytes found once, and
|
||||
//! the writes made without the buffer's lock counted once.
|
||||
|
||||
use super::{
|
||||
Batch, ComputeAt, IndirectCommandBuffer, IndirectComputeCommand, IndirectRenderCommand,
|
||||
RenderAt,
|
||||
};
|
||||
use crate::depth_stencil::DepthStencilState;
|
||||
use crate::render_values::DrawPrimitiveType;
|
||||
use crate::values::{Region, Size};
|
||||
use crate::{Buffer, ComputePipelineState, Error, RenderPipelineState};
|
||||
use metal2vulkan::metal::{CullMode, DepthClipMode, IndexType, TriangleFillMode, Winding};
|
||||
|
||||
/// One call of an [`IndirectRenderCommand`]'s setters, for
|
||||
/// [`set_each`](IndirectRenderCommand::set_each): a variant a setter, named after it, its fields
|
||||
/// the setter's arguments, so each does what its setter's Metal counterpart does there (its
|
||||
/// docs). A runtime extension: Metal has no such value.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum IndirectRenderSet<'a> {
|
||||
/// [`set_render_pipeline_state`](IndirectRenderCommand::set_render_pipeline_state)
|
||||
/// (`setRenderPipelineState:`).
|
||||
SetRenderPipelineState(&'a RenderPipelineState),
|
||||
/// [`set_vertex_buffer`](IndirectRenderCommand::set_vertex_buffer)
|
||||
/// (`setVertexBuffer:offset:atIndex:`).
|
||||
SetVertexBuffer {
|
||||
/// `buffer`.
|
||||
buffer: Option<&'a Buffer>,
|
||||
/// `offset`.
|
||||
offset: u64,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`set_vertex_buffer_with_stride`](IndirectRenderCommand::set_vertex_buffer_with_stride)
|
||||
/// (`setVertexBuffer:offset:attributeStride:atIndex:`).
|
||||
SetVertexBufferWithStride {
|
||||
/// `buffer`.
|
||||
buffer: Option<&'a Buffer>,
|
||||
/// `offset`.
|
||||
offset: u64,
|
||||
/// `attributeStride`.
|
||||
stride: u64,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`set_fragment_buffer`](IndirectRenderCommand::set_fragment_buffer)
|
||||
/// (`setFragmentBuffer:offset:atIndex:`).
|
||||
SetFragmentBuffer {
|
||||
/// `buffer`.
|
||||
buffer: Option<&'a Buffer>,
|
||||
/// `offset`.
|
||||
offset: u64,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`set_object_buffer`](IndirectRenderCommand::set_object_buffer)
|
||||
/// (`setObjectBuffer:offset:atIndex:`).
|
||||
SetObjectBuffer {
|
||||
/// `buffer`.
|
||||
buffer: Option<&'a Buffer>,
|
||||
/// `offset`.
|
||||
offset: u64,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`set_mesh_buffer`](IndirectRenderCommand::set_mesh_buffer)
|
||||
/// (`setMeshBuffer:offset:atIndex:`).
|
||||
SetMeshBuffer {
|
||||
/// `buffer`.
|
||||
buffer: Option<&'a Buffer>,
|
||||
/// `offset`.
|
||||
offset: u64,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`set_object_threadgroup_memory_length`](IndirectRenderCommand::set_object_threadgroup_memory_length)
|
||||
/// (`setObjectThreadgroupMemoryLength:atIndex:`).
|
||||
SetObjectThreadgroupMemoryLength {
|
||||
/// `length`.
|
||||
length: u32,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`draw_primitives`](IndirectRenderCommand::draw_primitives)
|
||||
/// (`drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:`).
|
||||
DrawPrimitives {
|
||||
/// `primitiveType`.
|
||||
primitive_type: DrawPrimitiveType,
|
||||
/// `vertexStart`.
|
||||
vertex_start: u64,
|
||||
/// `vertexCount`.
|
||||
vertex_count: u64,
|
||||
/// `instanceCount`.
|
||||
instance_count: u64,
|
||||
/// `baseInstance`.
|
||||
base_instance: u64,
|
||||
},
|
||||
/// [`draw_indexed_primitives`](IndirectRenderCommand::draw_indexed_primitives)
|
||||
/// (`drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:`).
|
||||
DrawIndexedPrimitives {
|
||||
/// `primitiveType`.
|
||||
primitive_type: DrawPrimitiveType,
|
||||
/// `indexCount`.
|
||||
index_count: u64,
|
||||
/// `indexType`.
|
||||
index_type: IndexType,
|
||||
/// `indexBuffer`.
|
||||
index_buffer: &'a Buffer,
|
||||
/// `indexBufferOffset`.
|
||||
index_buffer_offset: u64,
|
||||
/// `instanceCount`.
|
||||
instance_count: u64,
|
||||
/// `baseVertex`.
|
||||
base_vertex: i64,
|
||||
/// `baseInstance`.
|
||||
base_instance: u64,
|
||||
},
|
||||
/// [`draw_patches`](IndirectRenderCommand::draw_patches)
|
||||
/// (`drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:`).
|
||||
DrawPatches {
|
||||
/// `numberOfPatchControlPoints`.
|
||||
number_of_patch_control_points: u64,
|
||||
/// `patchStart`.
|
||||
patch_start: u64,
|
||||
/// `patchCount`.
|
||||
patch_count: u64,
|
||||
/// `patchIndexBuffer`.
|
||||
patch_index_buffer: Option<&'a Buffer>,
|
||||
/// `patchIndexBufferOffset`.
|
||||
patch_index_buffer_offset: u64,
|
||||
/// `instanceCount`.
|
||||
instance_count: u64,
|
||||
/// `baseInstance`.
|
||||
base_instance: u64,
|
||||
/// `tessellationFactorBuffer`.
|
||||
tessellation_factor_buffer: &'a Buffer,
|
||||
/// `tessellationFactorBufferOffset`.
|
||||
tessellation_factor_buffer_offset: u64,
|
||||
/// `tessellationFactorBufferInstanceStride`.
|
||||
tessellation_factor_buffer_instance_stride: u64,
|
||||
},
|
||||
/// [`draw_indexed_patches`](IndirectRenderCommand::draw_indexed_patches)
|
||||
/// (`drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:`).
|
||||
DrawIndexedPatches {
|
||||
/// `numberOfPatchControlPoints`.
|
||||
number_of_patch_control_points: u64,
|
||||
/// `patchStart`.
|
||||
patch_start: u64,
|
||||
/// `patchCount`.
|
||||
patch_count: u64,
|
||||
/// `patchIndexBuffer`.
|
||||
patch_index_buffer: Option<&'a Buffer>,
|
||||
/// `patchIndexBufferOffset`.
|
||||
patch_index_buffer_offset: u64,
|
||||
/// `controlPointIndexBuffer`.
|
||||
control_point_index_buffer: Option<&'a Buffer>,
|
||||
/// `controlPointIndexBufferOffset`.
|
||||
control_point_index_buffer_offset: u64,
|
||||
/// `instanceCount`.
|
||||
instance_count: u64,
|
||||
/// `baseInstance`.
|
||||
base_instance: u64,
|
||||
/// `tessellationFactorBuffer`.
|
||||
tessellation_factor_buffer: &'a Buffer,
|
||||
/// `tessellationFactorBufferOffset`.
|
||||
tessellation_factor_buffer_offset: u64,
|
||||
/// `tessellationFactorBufferInstanceStride`.
|
||||
tessellation_factor_buffer_instance_stride: u64,
|
||||
},
|
||||
/// [`draw_mesh_threadgroups`](IndirectRenderCommand::draw_mesh_threadgroups)
|
||||
/// (`drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:`).
|
||||
DrawMeshThreadgroups {
|
||||
/// `threadgroupsPerGrid`.
|
||||
threadgroups_per_grid: Size,
|
||||
/// `threadsPerObjectThreadgroup`.
|
||||
threads_per_object_threadgroup: Size,
|
||||
/// `threadsPerMeshThreadgroup`.
|
||||
threads_per_mesh_threadgroup: Size,
|
||||
},
|
||||
/// [`draw_mesh_threads`](IndirectRenderCommand::draw_mesh_threads)
|
||||
/// (`drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:`).
|
||||
DrawMeshThreads {
|
||||
/// `threadsPerGrid`.
|
||||
threads_per_grid: Size,
|
||||
/// `threadsPerObjectThreadgroup`.
|
||||
threads_per_object_threadgroup: Size,
|
||||
/// `threadsPerMeshThreadgroup`.
|
||||
threads_per_mesh_threadgroup: Size,
|
||||
},
|
||||
/// [`set_barrier`](IndirectRenderCommand::set_barrier) (`setBarrier`).
|
||||
SetBarrier,
|
||||
/// [`clear_barrier`](IndirectRenderCommand::clear_barrier) (`clearBarrier`).
|
||||
ClearBarrier,
|
||||
/// [`reset`](IndirectRenderCommand::reset) (`reset`).
|
||||
Reset,
|
||||
/// [`set_depth_stencil_state`](IndirectRenderCommand::set_depth_stencil_state)
|
||||
/// (`setDepthStencilState:`).
|
||||
SetDepthStencilState(Option<&'a DepthStencilState>),
|
||||
/// [`set_depth_bias`](IndirectRenderCommand::set_depth_bias)
|
||||
/// (`setDepthBias:slopeScale:clamp:`).
|
||||
SetDepthBias {
|
||||
/// `depthBias`.
|
||||
depth_bias: f32,
|
||||
/// `slopeScale`.
|
||||
slope_scale: f32,
|
||||
/// `clamp`.
|
||||
clamp: f32,
|
||||
},
|
||||
/// [`set_depth_clip_mode`](IndirectRenderCommand::set_depth_clip_mode)
|
||||
/// (`setDepthClipMode:`).
|
||||
SetDepthClipMode(DepthClipMode),
|
||||
/// [`set_cull_mode`](IndirectRenderCommand::set_cull_mode) (`setCullMode:`).
|
||||
SetCullMode(CullMode),
|
||||
/// [`set_front_facing_winding`](IndirectRenderCommand::set_front_facing_winding)
|
||||
/// (`setFrontFacingWinding:`).
|
||||
SetFrontFacingWinding(Winding),
|
||||
/// [`set_triangle_fill_mode`](IndirectRenderCommand::set_triangle_fill_mode)
|
||||
/// (`setTriangleFillMode:`).
|
||||
SetTriangleFillMode(TriangleFillMode),
|
||||
}
|
||||
|
||||
/// One call of an [`IndirectComputeCommand`]'s setters, for
|
||||
/// [`set_each`](IndirectComputeCommand::set_each), as [`IndirectRenderSet`] is a render
|
||||
/// command's. A runtime extension: Metal has no such value.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum IndirectComputeSet<'a> {
|
||||
/// [`set_compute_pipeline_state`](IndirectComputeCommand::set_compute_pipeline_state)
|
||||
/// (`setComputePipelineState:`).
|
||||
SetComputePipelineState(&'a ComputePipelineState),
|
||||
/// [`set_kernel_buffer`](IndirectComputeCommand::set_kernel_buffer)
|
||||
/// (`setKernelBuffer:offset:atIndex:`).
|
||||
SetKernelBuffer {
|
||||
/// `buffer`.
|
||||
buffer: Option<&'a Buffer>,
|
||||
/// `offset`.
|
||||
offset: u64,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`set_kernel_buffer_with_stride`](IndirectComputeCommand::set_kernel_buffer_with_stride)
|
||||
/// (`setKernelBuffer:offset:attributeStride:atIndex:`).
|
||||
SetKernelBufferWithStride {
|
||||
/// `buffer`.
|
||||
buffer: Option<&'a Buffer>,
|
||||
/// `offset`.
|
||||
offset: u64,
|
||||
/// `attributeStride`.
|
||||
stride: u64,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`concurrent_dispatch_threadgroups`](IndirectComputeCommand::concurrent_dispatch_threadgroups)
|
||||
/// (`concurrentDispatchThreadgroups:threadsPerThreadgroup:`).
|
||||
ConcurrentDispatchThreadgroups {
|
||||
/// `threadgroupsPerGrid`.
|
||||
threadgroups: Size,
|
||||
/// `threadsPerThreadgroup`.
|
||||
threads_per_threadgroup: Size,
|
||||
},
|
||||
/// [`concurrent_dispatch_threads`](IndirectComputeCommand::concurrent_dispatch_threads)
|
||||
/// (`concurrentDispatchThreads:threadsPerThreadgroup:`).
|
||||
ConcurrentDispatchThreads {
|
||||
/// `threadsPerGrid`.
|
||||
threads: Size,
|
||||
/// `threadsPerThreadgroup`.
|
||||
threads_per_threadgroup: Size,
|
||||
},
|
||||
/// [`set_barrier`](IndirectComputeCommand::set_barrier) (`setBarrier`).
|
||||
SetBarrier,
|
||||
/// [`clear_barrier`](IndirectComputeCommand::clear_barrier) (`clearBarrier`).
|
||||
ClearBarrier,
|
||||
/// [`set_threadgroup_memory_length`](IndirectComputeCommand::set_threadgroup_memory_length)
|
||||
/// (`setThreadgroupMemoryLength:atIndex:`).
|
||||
SetThreadgroupMemoryLength {
|
||||
/// `length`.
|
||||
length: u32,
|
||||
/// `atIndex`.
|
||||
index: u32,
|
||||
},
|
||||
/// [`set_stage_in_region`](IndirectComputeCommand::set_stage_in_region)
|
||||
/// (`setStageInRegion:`).
|
||||
SetStageInRegion(Region),
|
||||
/// [`set_imageblock_size`](IndirectComputeCommand::set_imageblock_size)
|
||||
/// (`setImageblockWidth:height:`).
|
||||
SetImageblockSize {
|
||||
/// `width`.
|
||||
width: u64,
|
||||
/// `height`.
|
||||
height: u64,
|
||||
},
|
||||
/// [`reset`](IndirectComputeCommand::reset) (`reset`).
|
||||
Reset,
|
||||
}
|
||||
|
||||
impl IndirectCommandBuffer {
|
||||
/// `indirectRenderCommandAtIndex:` and the setters `sets` name on its command, called in turn
|
||||
/// ([`IndirectRenderSet`]), as [`IndirectRenderCommand::set_each`] calls them: a runtime
|
||||
/// extension, the calls Metal makes one at a time made in one, with no command's handle (the
|
||||
/// buffer's is not cloned). Command `index`'s refusals, as
|
||||
/// [`indirect_render_command_at`](Self::indirect_render_command_at)'s, are answered at place
|
||||
/// 0, before any setter is called, `sets` empty or not; a setter's refusal at its place, those
|
||||
/// before it made and those after it not taken.
|
||||
pub fn set_render_command<'a>(
|
||||
&self,
|
||||
index: u64,
|
||||
sets: impl IntoIterator<Item = IndirectRenderSet<'a>>,
|
||||
) -> Result<(), (usize, Error)> {
|
||||
const CALL: &str = "set_render_command";
|
||||
let index = (self.command_at(CALL, index, true)).map_err(|error| (0, error))?;
|
||||
RenderAt { icb: self, index }.set_each(sets)
|
||||
}
|
||||
|
||||
/// `indirectComputeCommandAtIndex:` and the setters `sets` name on its command, called in turn
|
||||
/// ([`IndirectComputeSet`]), as [`IndirectComputeCommand::set_each`] calls them: a runtime
|
||||
/// extension with no command's handle, as [`set_render_command`](Self::set_render_command)
|
||||
/// is. Command `index`'s refusals, as
|
||||
/// [`indirect_compute_command_at`](Self::indirect_compute_command_at)'s (a buffer of render
|
||||
/// command types among them), are answered at place 0, before any setter is called.
|
||||
pub fn set_compute_command<'a>(
|
||||
&self,
|
||||
index: u64,
|
||||
sets: impl IntoIterator<Item = IndirectComputeSet<'a>>,
|
||||
) -> Result<(), (usize, Error)> {
|
||||
const CALL: &str = "set_compute_command";
|
||||
let index = (self.command_at(CALL, index, false)).map_err(|error| (0, error))?;
|
||||
ComputeAt { icb: self, index }.set_each(sets)
|
||||
}
|
||||
}
|
||||
|
||||
impl IndirectRenderCommand {
|
||||
/// The setters `sets` name, called in turn ([`IndirectRenderSet`]): a runtime extension with
|
||||
/// no Metal counterpart, each call doing what its setter does. The first a setter refuses
|
||||
/// stops them, answered with its place among them and the setter's error; those before it
|
||||
/// stay made, and those after it are not taken, as one setter call at a time would leave the
|
||||
/// command.
|
||||
pub fn set_each<'a>(
|
||||
&self,
|
||||
sets: impl IntoIterator<Item = IndirectRenderSet<'a>>,
|
||||
) -> Result<(), (usize, Error)> {
|
||||
self.at().set_each(sets)
|
||||
}
|
||||
}
|
||||
|
||||
impl IndirectComputeCommand {
|
||||
/// The setters `sets` name, called in turn ([`IndirectComputeSet`]), as
|
||||
/// [`IndirectRenderCommand::set_each`] calls a render command's: a runtime extension with no
|
||||
/// Metal counterpart; the first refused stops them, answered with its place and error, those
|
||||
/// before it made.
|
||||
pub fn set_each<'a>(
|
||||
&self,
|
||||
sets: impl IntoIterator<Item = IndirectComputeSet<'a>>,
|
||||
) -> Result<(), (usize, Error)> {
|
||||
self.at().set_each(sets)
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderAt<'_> {
|
||||
/// [`IndirectRenderCommand::set_each`] of `sets`, their writes one [`Batch`].
|
||||
fn set_each<'a>(
|
||||
&self,
|
||||
sets: impl IntoIterator<Item = IndirectRenderSet<'a>>,
|
||||
) -> Result<(), (usize, Error)> {
|
||||
let mut batch = self.icb.batch(self.index);
|
||||
for (at, set) in sets.into_iter().enumerate() {
|
||||
self.set_one(&mut batch, set).map_err(|error| (at, error))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The setter `set` names: in `batch` where the setter writes a field, else the setter.
|
||||
fn set_one(&self, batch: &mut Batch<'_>, set: IndirectRenderSet<'_>) -> Result<(), Error> {
|
||||
use IndirectRenderSet as S;
|
||||
match set {
|
||||
S::SetRenderPipelineState(state) => self.pipeline_in(batch, state),
|
||||
S::SetVertexBuffer {
|
||||
buffer,
|
||||
offset,
|
||||
index,
|
||||
} => self.vertex_buffer_in(batch, buffer, offset, index),
|
||||
S::SetVertexBufferWithStride {
|
||||
buffer,
|
||||
offset,
|
||||
stride,
|
||||
index,
|
||||
} => self.vertex_buffer_with_stride_in(batch, buffer, offset, stride, index),
|
||||
S::SetFragmentBuffer {
|
||||
buffer,
|
||||
offset,
|
||||
index,
|
||||
} => self.fragment_buffer_in(batch, buffer, offset, index),
|
||||
S::SetObjectBuffer {
|
||||
buffer,
|
||||
offset,
|
||||
index,
|
||||
} => self.set_object_buffer(buffer, offset, index),
|
||||
S::SetMeshBuffer {
|
||||
buffer,
|
||||
offset,
|
||||
index,
|
||||
} => self.set_mesh_buffer(buffer, offset, index),
|
||||
S::SetObjectThreadgroupMemoryLength { length, index } => {
|
||||
self.set_object_threadgroup_memory_length(length, index)
|
||||
}
|
||||
S::DrawPrimitives {
|
||||
primitive_type,
|
||||
vertex_start,
|
||||
vertex_count,
|
||||
instance_count,
|
||||
base_instance,
|
||||
} => self.draw_primitives_in(
|
||||
batch,
|
||||
primitive_type,
|
||||
vertex_start,
|
||||
vertex_count,
|
||||
instance_count,
|
||||
base_instance,
|
||||
),
|
||||
S::DrawIndexedPrimitives {
|
||||
primitive_type,
|
||||
index_count,
|
||||
index_type,
|
||||
index_buffer,
|
||||
index_buffer_offset,
|
||||
instance_count,
|
||||
base_vertex,
|
||||
base_instance,
|
||||
} => self.draw_indexed_primitives_in(
|
||||
batch,
|
||||
primitive_type,
|
||||
index_count,
|
||||
index_type,
|
||||
index_buffer,
|
||||
index_buffer_offset,
|
||||
instance_count,
|
||||
base_vertex,
|
||||
base_instance,
|
||||
),
|
||||
S::DrawPatches {
|
||||
number_of_patch_control_points,
|
||||
patch_start,
|
||||
patch_count,
|
||||
patch_index_buffer,
|
||||
patch_index_buffer_offset,
|
||||
instance_count,
|
||||
base_instance,
|
||||
tessellation_factor_buffer,
|
||||
tessellation_factor_buffer_offset,
|
||||
tessellation_factor_buffer_instance_stride,
|
||||
} => self.draw_patches(
|
||||
number_of_patch_control_points,
|
||||
patch_start,
|
||||
patch_count,
|
||||
patch_index_buffer,
|
||||
patch_index_buffer_offset,
|
||||
instance_count,
|
||||
base_instance,
|
||||
tessellation_factor_buffer,
|
||||
tessellation_factor_buffer_offset,
|
||||
tessellation_factor_buffer_instance_stride,
|
||||
),
|
||||
S::DrawIndexedPatches {
|
||||
number_of_patch_control_points,
|
||||
patch_start,
|
||||
patch_count,
|
||||
patch_index_buffer,
|
||||
patch_index_buffer_offset,
|
||||
control_point_index_buffer,
|
||||
control_point_index_buffer_offset,
|
||||
instance_count,
|
||||
base_instance,
|
||||
tessellation_factor_buffer,
|
||||
tessellation_factor_buffer_offset,
|
||||
tessellation_factor_buffer_instance_stride,
|
||||
} => self.draw_indexed_patches(
|
||||
number_of_patch_control_points,
|
||||
patch_start,
|
||||
patch_count,
|
||||
patch_index_buffer,
|
||||
patch_index_buffer_offset,
|
||||
control_point_index_buffer,
|
||||
control_point_index_buffer_offset,
|
||||
instance_count,
|
||||
base_instance,
|
||||
tessellation_factor_buffer,
|
||||
tessellation_factor_buffer_offset,
|
||||
tessellation_factor_buffer_instance_stride,
|
||||
),
|
||||
S::DrawMeshThreadgroups {
|
||||
threadgroups_per_grid,
|
||||
threads_per_object_threadgroup,
|
||||
threads_per_mesh_threadgroup,
|
||||
} => self.draw_mesh_threadgroups(
|
||||
threadgroups_per_grid,
|
||||
threads_per_object_threadgroup,
|
||||
threads_per_mesh_threadgroup,
|
||||
),
|
||||
S::DrawMeshThreads {
|
||||
threads_per_grid,
|
||||
threads_per_object_threadgroup,
|
||||
threads_per_mesh_threadgroup,
|
||||
} => self.draw_mesh_threads(
|
||||
threads_per_grid,
|
||||
threads_per_object_threadgroup,
|
||||
threads_per_mesh_threadgroup,
|
||||
),
|
||||
S::SetBarrier => self.barrier_in(batch, true),
|
||||
S::ClearBarrier => self.barrier_in(batch, false),
|
||||
S::Reset => self.reset(),
|
||||
S::SetDepthStencilState(state) => self.set_depth_stencil_state(state),
|
||||
S::SetDepthBias {
|
||||
depth_bias,
|
||||
slope_scale,
|
||||
clamp,
|
||||
} => self.set_depth_bias(depth_bias, slope_scale, clamp),
|
||||
S::SetDepthClipMode(mode) => self.set_depth_clip_mode(mode),
|
||||
S::SetCullMode(mode) => self.set_cull_mode(mode),
|
||||
S::SetFrontFacingWinding(winding) => self.set_front_facing_winding(winding),
|
||||
S::SetTriangleFillMode(mode) => self.set_triangle_fill_mode(mode),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputeAt<'_> {
|
||||
/// [`IndirectComputeCommand::set_each`] of `sets`, their writes one [`Batch`].
|
||||
fn set_each<'a>(
|
||||
&self,
|
||||
sets: impl IntoIterator<Item = IndirectComputeSet<'a>>,
|
||||
) -> Result<(), (usize, Error)> {
|
||||
let mut batch = self.icb.batch(self.index);
|
||||
for (at, set) in sets.into_iter().enumerate() {
|
||||
self.set_one(&mut batch, set).map_err(|error| (at, error))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The setter `set` names: in `batch` where the setter writes a field, else the setter.
|
||||
fn set_one(&self, batch: &mut Batch<'_>, set: IndirectComputeSet<'_>) -> Result<(), Error> {
|
||||
use IndirectComputeSet as S;
|
||||
match set {
|
||||
S::SetComputePipelineState(state) => self.pipeline_in(batch, state),
|
||||
S::SetKernelBuffer {
|
||||
buffer,
|
||||
offset,
|
||||
index,
|
||||
} => self.kernel_buffer_in(batch, buffer, offset, index),
|
||||
S::SetKernelBufferWithStride {
|
||||
buffer,
|
||||
offset,
|
||||
stride,
|
||||
index,
|
||||
} => self.kernel_buffer_with_stride_in(batch, buffer, offset, stride, index),
|
||||
S::ConcurrentDispatchThreadgroups {
|
||||
threadgroups,
|
||||
threads_per_threadgroup,
|
||||
} => self.dispatch_threadgroups_in(batch, threadgroups, threads_per_threadgroup),
|
||||
S::ConcurrentDispatchThreads {
|
||||
threads,
|
||||
threads_per_threadgroup,
|
||||
} => self.dispatch_threads_in(batch, threads, threads_per_threadgroup),
|
||||
S::SetBarrier => self.barrier_in(batch, true),
|
||||
S::ClearBarrier => self.barrier_in(batch, false),
|
||||
S::SetThreadgroupMemoryLength { length, index } => {
|
||||
self.set_threadgroup_memory_length(length, index)
|
||||
}
|
||||
S::SetStageInRegion(region) => self.set_stage_in_region(region),
|
||||
S::SetImageblockSize { width, height } => self.set_imageblock_size(width, height),
|
||||
S::Reset => self.reset(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,13 @@
|
||||
//! set costs a store whatever the buffer's size, and the table keeps one entry a state, however
|
||||
//! many commands name it. An entry goes with the last command that names it, so the table holds
|
||||
//! no state none of the commands names. A recovery's carry carries each entry once
|
||||
//! ([`entries_mut`](SetStates::entries_mut)).
|
||||
//! ([`entries_mut`](SetStates::entries_mut)). Each command's key is also kept where a setter
|
||||
//! reads it without the lock ([`SetKeys`]).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Range;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
/// What tells two states the CPU set apart: the kind, the ID and the serial of the state's hold
|
||||
/// of it (`IdStamp`), which no other state's hold of any ID shares.
|
||||
@@ -25,6 +28,62 @@ pub(super) trait Keyed {
|
||||
fn key(&self) -> StateKey;
|
||||
}
|
||||
|
||||
/// The key of the state each command names, as [`SetStates`] holds it, readable without the
|
||||
/// buffer's lock: two words a command, the state's ID (0 for none) and its serial above its kind,
|
||||
/// stored under the lock as a set or a clear changes the command's state, none until a state is
|
||||
/// set. A setter of the state a command names already finds it here and writes its ID again
|
||||
/// without the lock, the table unchanged. A command's two words are stored one after the other:
|
||||
/// a read of them while another thread sets the same command is the program's race, as two
|
||||
/// threads encoding one command are on Metal.
|
||||
pub(super) struct SetKeys {
|
||||
size: u32,
|
||||
words: OnceLock<Box<[AtomicU64]>>,
|
||||
}
|
||||
|
||||
impl SetKeys {
|
||||
fn new(size: u32) -> SetKeys {
|
||||
SetKeys {
|
||||
size,
|
||||
words: OnceLock::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether command `index` (below the size) names the state of key `key`.
|
||||
pub(super) fn names(&self, index: u32, key: StateKey) -> bool {
|
||||
let Some(words) = self.words.get() else {
|
||||
return false;
|
||||
};
|
||||
let at = 2 * index as usize;
|
||||
words[at].load(Ordering::Acquire) == key.id
|
||||
&& words[at + 1].load(Ordering::Acquire) == serial_and_kind(key)
|
||||
}
|
||||
|
||||
/// Command `index` (below the size) names the state of key `key`, or none.
|
||||
fn store(&self, index: u32, key: Option<StateKey>) {
|
||||
let words = self.words.get_or_init(|| {
|
||||
(0..2 * self.size as usize)
|
||||
.map(|_| AtomicU64::new(0))
|
||||
.collect()
|
||||
});
|
||||
let at = 2 * index as usize;
|
||||
let (id, serial) = key.map_or((0, 0), |key| (key.id, serial_and_kind(key)));
|
||||
words[at].store(id, Ordering::Release);
|
||||
words[at + 1].store(serial, Ordering::Release);
|
||||
}
|
||||
|
||||
/// No command names a state.
|
||||
fn clear_all(&self) {
|
||||
for word in self.words.get().into_iter().flatten() {
|
||||
word.store(0, Ordering::Release);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `key`'s serial above its kind, in one word.
|
||||
fn serial_and_kind(key: StateKey) -> u64 {
|
||||
key.serial << 1 | u64::from(key.compute)
|
||||
}
|
||||
|
||||
/// A distinct state, and how many commands name it.
|
||||
struct Entry<S> {
|
||||
state: S,
|
||||
@@ -47,11 +106,18 @@ pub(super) struct SetStates<S> {
|
||||
/// The place of the entry set last, looked at first: a buffer's commands mostly name one
|
||||
/// state in turn.
|
||||
last: Option<(StateKey, u32)>,
|
||||
/// Each command's key, for the setters' look without the lock.
|
||||
keys: Arc<SetKeys>,
|
||||
}
|
||||
|
||||
impl<S: Keyed> SetStates<S> {
|
||||
/// The table of a buffer of `size` commands: none set.
|
||||
pub(super) fn new(size: u32) -> SetStates<S> {
|
||||
SetStates::empty(size, Arc::new(SetKeys::new(size)))
|
||||
}
|
||||
|
||||
/// The table of a buffer of `size` commands, none set, its keys in `keys`.
|
||||
fn empty(size: u32, keys: Arc<SetKeys>) -> SetStates<S> {
|
||||
SetStates {
|
||||
size,
|
||||
slots: Vec::new(),
|
||||
@@ -59,9 +125,15 @@ impl<S: Keyed> SetStates<S> {
|
||||
free: Vec::new(),
|
||||
places: HashMap::new(),
|
||||
last: None,
|
||||
keys,
|
||||
}
|
||||
}
|
||||
|
||||
/// Each command's key, readable without the lock ([`SetKeys`]).
|
||||
pub(super) fn keys(&self) -> Arc<SetKeys> {
|
||||
Arc::clone(&self.keys)
|
||||
}
|
||||
|
||||
/// The state the CPU set on command `index`.
|
||||
pub(super) fn get(&self, index: u32) -> Option<&S> {
|
||||
let slot = *self.slots.get(index as usize)?;
|
||||
@@ -95,6 +167,9 @@ impl<S: Keyed> SetStates<S> {
|
||||
}
|
||||
let slot = place + 1;
|
||||
let before = std::mem::replace(&mut self.slots[index as usize], slot);
|
||||
// Stored again where the command named the state already: the keys may have been
|
||||
// forgotten since (`forget_keys`).
|
||||
self.keys.store(index, Some(key));
|
||||
if before == slot {
|
||||
return;
|
||||
}
|
||||
@@ -108,13 +183,24 @@ impl<S: Keyed> SetStates<S> {
|
||||
pub(super) fn clear(&mut self, index: u32) {
|
||||
if let Some(slot) = self.slots.get_mut(index as usize) {
|
||||
let before = std::mem::replace(slot, 0);
|
||||
if before != 0 {
|
||||
self.keys.store(index, None);
|
||||
}
|
||||
self.release(before);
|
||||
}
|
||||
}
|
||||
|
||||
/// The keys read without the lock name no state until a set stores each command's again,
|
||||
/// the table unchanged: a recovery's carry forgets them, so that each command's next set of
|
||||
/// its state is checked again, under the lock, against the generation it was carried to.
|
||||
pub(super) fn forget_keys(&self) {
|
||||
self.keys.clear_all();
|
||||
}
|
||||
|
||||
/// No command names a state from now on.
|
||||
pub(super) fn clear_all(&mut self) {
|
||||
*self = SetStates::new(self.size);
|
||||
self.keys.clear_all();
|
||||
*self = SetStates::empty(self.size, Arc::clone(&self.keys));
|
||||
}
|
||||
|
||||
/// Each distinct state a command names, once.
|
||||
@@ -195,11 +281,14 @@ mod tests {
|
||||
|
||||
/// One entry a distinct state, made once while a command names it, shared by the commands
|
||||
/// that name it, gone with the last of them and made again after; a reset command names
|
||||
/// none; the range skips commands that name none.
|
||||
/// none; the range skips commands that name none. The keys read without the lock follow
|
||||
/// every set and clear, kind included, and come back with a set after they were forgotten.
|
||||
#[test]
|
||||
fn a_state_is_kept_once_while_a_command_names_it() {
|
||||
let mut table = SetStates::new(6);
|
||||
let keys = table.keys();
|
||||
assert!(table.get(0).is_none());
|
||||
assert!(!keys.names(0, key(7)), "none before a set");
|
||||
assert_eq!(table.in_range(0..6).count(), 0);
|
||||
let mut made = 0;
|
||||
let mut set = |table: &mut SetStates<Made>, index, id| {
|
||||
@@ -216,6 +305,13 @@ mod tests {
|
||||
assert_eq!(table.get(0), Some(&Made(key(7), 1)));
|
||||
assert_eq!(table.get(1), Some(&Made(key(9), 2)));
|
||||
assert_eq!(table.get(5), None);
|
||||
assert!(keys.names(0, key(7)) && keys.names(1, key(9)));
|
||||
assert!(!keys.names(1, key(7)) && !keys.names(5, key(7)));
|
||||
let compute = StateKey {
|
||||
compute: true,
|
||||
..key(7)
|
||||
};
|
||||
assert!(!keys.names(0, compute), "the kind tells keys apart");
|
||||
let ids: Vec<u64> = table.in_range(0..6).map(|state| state.0.id).collect();
|
||||
assert_eq!(ids, [7, 9, 7, 7, 9]);
|
||||
assert_eq!(table.entries_mut().count(), 2);
|
||||
@@ -223,6 +319,7 @@ mod tests {
|
||||
for index in [0, 2] {
|
||||
table.clear(index);
|
||||
}
|
||||
assert!(!keys.names(0, key(7)) && keys.names(3, key(7)));
|
||||
assert_eq!(table.entries_mut().count(), 2);
|
||||
set(&mut table, 3, 9);
|
||||
assert_eq!(table.entries_mut().count(), 1);
|
||||
@@ -237,5 +334,14 @@ mod tests {
|
||||
table.clear_all();
|
||||
assert_eq!(table.in_range(0..6).count(), 0);
|
||||
assert_eq!(table.entries_mut().count(), 0);
|
||||
assert!(!keys.names(0, key(7)), "the same keys, cleared");
|
||||
set(&mut table, 2, 9);
|
||||
assert!(keys.names(2, key(9)));
|
||||
// Forgotten, then stored again by a set of the state the command names already.
|
||||
table.forget_keys();
|
||||
assert!(!keys.names(2, key(9)));
|
||||
set(&mut table, 2, 9);
|
||||
assert!(keys.names(2, key(9)));
|
||||
assert_eq!(table.entries_mut().count(), 1);
|
||||
}
|
||||
}
|
||||
@@ -532,8 +532,8 @@ pub(super) struct StepChunk {
|
||||
pub(super) copy: StepCopy,
|
||||
}
|
||||
|
||||
/// The chunks the CPU wrote a record of without the buffer's lock (a buffer slot's setter,
|
||||
/// `IndirectCommandBuffer::edit_unlocked`), noted for the next look at the kept recordings to
|
||||
/// The chunks the CPU wrote a record of without the buffer's lock (a setter's write, in
|
||||
/// `indirect_command_buffer`'s `Batch`), noted for the next look at the kept recordings to
|
||||
/// forget ([`KeptChunks::settle`]): a flag a chunk, and one that some flag is set. A write notes
|
||||
/// its chunk after it wrote, and the note is published (`Release`) before the write is counted
|
||||
/// (`IndirectCommandBuffer::cpu_writes`), so a settle after a read of the count that counts the
|
||||
|
||||
@@ -343,8 +343,9 @@ pub use host_ram::{HostRam, HostRamUse};
|
||||
pub use indirect_command_buffer::{
|
||||
EncodedComputeCommand, EncodedRenderCommand, IndirectBufferBinding, IndirectCommand,
|
||||
IndirectCommandBuffer, IndirectCommandBufferDescriptor, IndirectCommandBufferProblem,
|
||||
IndirectCommandCheck, IndirectCommandCheckNeeds, IndirectComputeCommand, IndirectDispatch,
|
||||
IndirectDraw, IndirectRenderCommand, NIL_PATCH_BUFFER_ADDRESS,
|
||||
IndirectCommandCheck, IndirectCommandCheckNeeds, IndirectComputeCommand, IndirectComputeSet,
|
||||
IndirectDispatch, IndirectDraw, IndirectRenderCommand, IndirectRenderSet,
|
||||
NIL_PATCH_BUFFER_ADDRESS,
|
||||
};
|
||||
pub use interop::{SemaphoreProblem, VkEventSignal, VkEventWait, VkHostMemory};
|
||||
pub use library::{Function, FunctionDescriptor, Library};
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
//! `icb_slots_cost` loop through the runtime alone;
|
||||
//! - **compute slot**: `indirect_compute_command_at(i)` of a buffer of dispatches, a compute
|
||||
//! pipeline state, two kernel buffers (one at `(i % 16) * 16`) and a dispatch of threadgroups;
|
||||
//! - **set_each**: each slot's setters in one `set_each` call;
|
||||
//! - **set_render_command**, **set_compute_command**: each slot's setters in one call of the
|
||||
//! buffer's, with no command's handle;
|
||||
//! - **three fields**: `indirect_render_command_at(i)`, a vertex buffer at `(i % 8) * 256`, a
|
||||
//! fragment buffer at `(i % 4) * 64` and a draw of primitives, a consumer's loop;
|
||||
//! - **draw only**: the command and its draw;
|
||||
@@ -24,7 +27,7 @@ use super::blit_holds::{device, Scratch};
|
||||
use super::indirect_command_buffer_device::{compute_state, render_state, EXAMPLES};
|
||||
use crate::{
|
||||
DrawPrimitiveType, Error, IndirectCommandBuffer, IndirectCommandBufferDescriptor,
|
||||
ResourceOptions, Size,
|
||||
IndirectComputeSet, IndirectRenderSet, ResourceOptions, Size,
|
||||
};
|
||||
use metal2vulkan::bind::indirect_commands::COMMAND_BYTES;
|
||||
use metal2vulkan::metal::IndirectCommandType;
|
||||
@@ -111,6 +114,46 @@ fn icb_encode_costs() {
|
||||
command.draw_primitives(triangle, 0, 3, 1, 0).unwrap();
|
||||
}),
|
||||
);
|
||||
let render_sets = |i: u64| {
|
||||
[
|
||||
IndirectRenderSet::SetRenderPipelineState(&render),
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&vertex),
|
||||
offset: (i % 16) * 16,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&fragment),
|
||||
offset: 0,
|
||||
index: 1,
|
||||
},
|
||||
IndirectRenderSet::SetFragmentBuffer {
|
||||
buffer: Some(&vertex),
|
||||
offset: 256,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::DrawPrimitives {
|
||||
primitive_type: triangle,
|
||||
vertex_start: 0,
|
||||
vertex_count: 3,
|
||||
instance_count: 1,
|
||||
base_instance: 0,
|
||||
},
|
||||
]
|
||||
};
|
||||
print(
|
||||
&format!("{size} commands, full slot, set_each"),
|
||||
per_command(size, |i| {
|
||||
let command = icb.indirect_render_command_at(i).unwrap();
|
||||
command.set_each(render_sets(i)).unwrap();
|
||||
}),
|
||||
);
|
||||
print(
|
||||
&format!("{size} commands, full slot, set_render_command"),
|
||||
per_command(size, |i| {
|
||||
icb.set_render_command(i, render_sets(i)).unwrap();
|
||||
}),
|
||||
);
|
||||
let dispatches: IndirectCommandBuffer = device
|
||||
.new_indirect_command_buffer(&compute_descriptor, size, shared)
|
||||
.unwrap();
|
||||
@@ -128,6 +171,38 @@ fn icb_encode_costs() {
|
||||
.unwrap();
|
||||
}),
|
||||
);
|
||||
let compute_sets = |i: u64| {
|
||||
[
|
||||
IndirectComputeSet::SetComputePipelineState(&compute),
|
||||
IndirectComputeSet::SetKernelBuffer {
|
||||
buffer: Some(&vertex),
|
||||
offset: (i % 16) * 16,
|
||||
index: 0,
|
||||
},
|
||||
IndirectComputeSet::SetKernelBuffer {
|
||||
buffer: Some(&fragment),
|
||||
offset: 0,
|
||||
index: 1,
|
||||
},
|
||||
IndirectComputeSet::ConcurrentDispatchThreadgroups {
|
||||
threadgroups: group,
|
||||
threads_per_threadgroup: group,
|
||||
},
|
||||
]
|
||||
};
|
||||
print(
|
||||
&format!("{size} commands, compute slot, set_each"),
|
||||
per_command(size, |i| {
|
||||
let command = dispatches.indirect_compute_command_at(i).unwrap();
|
||||
command.set_each(compute_sets(i)).unwrap();
|
||||
}),
|
||||
);
|
||||
print(
|
||||
&format!("{size} commands, compute slot, set_compute_command"),
|
||||
per_command(size, |i| {
|
||||
dispatches.set_compute_command(i, compute_sets(i)).unwrap();
|
||||
}),
|
||||
);
|
||||
print(
|
||||
&format!("{size} commands, three fields"),
|
||||
per_command(size, |i| {
|
||||
|
||||
@@ -18,9 +18,10 @@ use crate::error::{internal, invalid};
|
||||
use crate::write_routes::GpuWriter;
|
||||
use crate::written_commands::Named;
|
||||
use crate::{
|
||||
Buffer, ComputePipelineState, Device, DrawProblem, Error, IndirectCommandBuffer,
|
||||
IndirectCommandBufferDescriptor, IndirectCommandBufferProblem, PipelineOptions, Problem,
|
||||
Region, RenderPipelineState, ResourceOptions, RuntimeGap, Size,
|
||||
Buffer, ComputePipelineState, Device, DrawPrimitiveType, DrawProblem, Error, GpuAddress,
|
||||
IndirectBufferBinding, IndirectCommandBuffer, IndirectCommandBufferDescriptor,
|
||||
IndirectCommandBufferProblem, IndirectComputeSet, IndirectDraw, IndirectRenderSet,
|
||||
PipelineOptions, Problem, Region, RenderPipelineState, ResourceOptions, RuntimeGap, Size,
|
||||
};
|
||||
use metal2vulkan::bind::indirect_commands::{
|
||||
Action, BufferBinding, BufferStage, CommandRecord, RecordField, RecordView,
|
||||
@@ -741,3 +742,474 @@ fn device_of_another(scratch: &Scratch) -> Device {
|
||||
std::fs::create_dir_all(&cache).unwrap();
|
||||
device(&cache)
|
||||
}
|
||||
|
||||
/// `set_each`, and `set_render_command` and `set_compute_command` with no command's handle, set a
|
||||
/// command as its setters one call at a time do: the same records and the same CPU writes
|
||||
/// counted, a render and a compute buffer alike; the first refused stops the rest, answered with
|
||||
/// its place and the setter's error, those before it made and those after it not taken. The
|
||||
/// buffer's calls answer the command's own refusals (an index past the size, a compute command of
|
||||
/// a render buffer) at place 0.
|
||||
#[test]
|
||||
fn set_each_sets_as_the_setters_one_at_a_time() {
|
||||
let scratch = Scratch::new("icb-set-each");
|
||||
let device = device(&scratch.0);
|
||||
let state = render_state(&device, true);
|
||||
let unsupported = render_state(&device, false);
|
||||
let shared = ResourceOptions::shared();
|
||||
let (a, b) = (
|
||||
device.new_buffer(4096, shared).unwrap(),
|
||||
device.new_buffer(4096, shared).unwrap(),
|
||||
);
|
||||
let mut descriptor = IndirectCommandBufferDescriptor::new();
|
||||
descriptor.command_types = IndirectCommandType::DRAW;
|
||||
descriptor.max_vertex_buffer_bind_count = 2;
|
||||
descriptor.max_fragment_buffer_bind_count = 1;
|
||||
let made = || {
|
||||
device
|
||||
.new_indirect_command_buffer(&descriptor, u64::from(COMMANDS), shared)
|
||||
.unwrap()
|
||||
};
|
||||
let (one_by_one, each, whole) = (made(), made(), made());
|
||||
let triangle = DrawPrimitiveType::from_raw(3).unwrap();
|
||||
for index in 0..u64::from(COMMANDS) {
|
||||
let c = one_by_one.indirect_render_command_at(index).unwrap();
|
||||
c.set_render_pipeline_state(&state).unwrap();
|
||||
c.set_vertex_buffer(Some(&a), index * 16, 0).unwrap();
|
||||
c.set_vertex_buffer(Some(&b), 0, 1).unwrap();
|
||||
c.set_fragment_buffer(Some(&a), 256, 0).unwrap();
|
||||
c.draw_primitives(triangle, 0, 3, 1, index).unwrap();
|
||||
let sets = [
|
||||
IndirectRenderSet::SetRenderPipelineState(&state),
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&a),
|
||||
offset: index * 16,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&b),
|
||||
offset: 0,
|
||||
index: 1,
|
||||
},
|
||||
IndirectRenderSet::SetFragmentBuffer {
|
||||
buffer: Some(&a),
|
||||
offset: 256,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::DrawPrimitives {
|
||||
primitive_type: triangle,
|
||||
vertex_start: 0,
|
||||
vertex_count: 3,
|
||||
instance_count: 1,
|
||||
base_instance: index,
|
||||
},
|
||||
];
|
||||
let c = each.indirect_render_command_at(index).unwrap();
|
||||
assert_eq!(c.set_each(sets), Ok(()), "command {index}");
|
||||
assert_eq!(whole.set_render_command(index, sets), Ok(()));
|
||||
}
|
||||
assert!(storage(&one_by_one) == storage(&each), "the records");
|
||||
assert!(
|
||||
storage(&one_by_one) == storage(&whole),
|
||||
"the buffer's records"
|
||||
);
|
||||
assert_eq!(
|
||||
one_by_one.cpu_writes(),
|
||||
each.cpu_writes(),
|
||||
"the writes counted"
|
||||
);
|
||||
assert_eq!(one_by_one.cpu_writes(), whole.cpu_writes());
|
||||
let named = |icb: &IndirectCommandBuffer| {
|
||||
(0..u64::from(COMMANDS))
|
||||
.map(|index| {
|
||||
let c = icb.indirect_render_command_at(index).unwrap();
|
||||
c.pipeline_state().unwrap().map(|s| s.gpu_resource_id())
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
assert_eq!(named(&one_by_one), named(&each), "the states set");
|
||||
assert_eq!(named(&one_by_one), named(&whole));
|
||||
|
||||
// The command's own refusals, at place 0 before any setter, none set.
|
||||
let before = (storage(&whole), whole.cpu_writes());
|
||||
let past = u64::from(COMMANDS);
|
||||
let refused = whole.indirect_render_command_at(past).err().unwrap();
|
||||
let draw = [IndirectRenderSet::SetBarrier];
|
||||
assert_eq!(whole.set_render_command(past, draw), Err((0, refused)));
|
||||
let refused = problem(
|
||||
"set_compute_command",
|
||||
IndirectCommandBufferProblem::CommandKind,
|
||||
);
|
||||
assert_eq!(whole.set_compute_command(0, []), Err((0, refused)));
|
||||
assert!(
|
||||
(storage(&whole), whole.cpu_writes()) == before,
|
||||
"nothing set"
|
||||
);
|
||||
|
||||
// A refusal mid-way: the buffer before it set, the draw after it not taken.
|
||||
let fresh = made();
|
||||
let c = fresh.indirect_render_command_at(0).unwrap();
|
||||
let before = fresh.cpu_writes();
|
||||
let sets = [
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&a),
|
||||
offset: 32,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::SetRenderPipelineState(&unsupported),
|
||||
IndirectRenderSet::DrawPrimitives {
|
||||
primitive_type: triangle,
|
||||
vertex_start: 0,
|
||||
vertex_count: 3,
|
||||
instance_count: 1,
|
||||
base_instance: 0,
|
||||
},
|
||||
];
|
||||
let refused = problem(
|
||||
"set_render_pipeline_state",
|
||||
IndirectCommandBufferProblem::PipelineWithoutSupport,
|
||||
);
|
||||
assert_eq!(c.set_each(sets), Err((1, refused)));
|
||||
let set = c.vertex_buffer(0).unwrap().map(|binding| binding.address);
|
||||
assert_eq!(
|
||||
set,
|
||||
Some(GpuAddress(a.gpu_address().0 + 32)),
|
||||
"the buffer before"
|
||||
);
|
||||
assert_eq!(c.draw().unwrap(), None, "the draw after");
|
||||
assert_eq!(
|
||||
c.pipeline_state().unwrap().map(|s| s.gpu_resource_id()),
|
||||
None
|
||||
);
|
||||
assert_eq!(fresh.cpu_writes(), before + 1, "the one write made");
|
||||
|
||||
// A compute command, and a refusal first: nothing made.
|
||||
let kernel = compute_state(&device, EXAMPLES, "scale_and_offset", true);
|
||||
let plain = compute_state(&device, EXAMPLES, "scale_and_offset", false);
|
||||
let mut descriptor = IndirectCommandBufferDescriptor::new();
|
||||
descriptor.command_types = IndirectCommandType::CONCURRENT_DISPATCH;
|
||||
descriptor.max_kernel_buffer_bind_count = 2;
|
||||
let made = || {
|
||||
device
|
||||
.new_indirect_command_buffer(&descriptor, 2, shared)
|
||||
.unwrap()
|
||||
};
|
||||
let (one_by_one, each, whole) = (made(), made(), made());
|
||||
let (groups, threads) = (Size::new(4, 1, 1), Size::new(64, 1, 1));
|
||||
let c = one_by_one.indirect_compute_command_at(1).unwrap();
|
||||
c.set_compute_pipeline_state(&kernel).unwrap();
|
||||
c.set_kernel_buffer(Some(&a), 48, 0).unwrap();
|
||||
c.set_kernel_buffer(Some(&b), 0, 1).unwrap();
|
||||
c.concurrent_dispatch_threadgroups(groups, threads).unwrap();
|
||||
let c = each.indirect_compute_command_at(1).unwrap();
|
||||
let sets = [
|
||||
IndirectComputeSet::SetComputePipelineState(&kernel),
|
||||
IndirectComputeSet::SetKernelBuffer {
|
||||
buffer: Some(&a),
|
||||
offset: 48,
|
||||
index: 0,
|
||||
},
|
||||
IndirectComputeSet::SetKernelBuffer {
|
||||
buffer: Some(&b),
|
||||
offset: 0,
|
||||
index: 1,
|
||||
},
|
||||
IndirectComputeSet::ConcurrentDispatchThreadgroups {
|
||||
threadgroups: groups,
|
||||
threads_per_threadgroup: threads,
|
||||
},
|
||||
];
|
||||
assert_eq!(c.set_each(sets), Ok(()));
|
||||
assert_eq!(whole.set_compute_command(1, sets), Ok(()));
|
||||
assert!(
|
||||
storage(&one_by_one) == storage(&each),
|
||||
"the compute records"
|
||||
);
|
||||
assert!(storage(&one_by_one) == storage(&whole));
|
||||
assert_eq!(one_by_one.cpu_writes(), each.cpu_writes());
|
||||
assert_eq!(one_by_one.cpu_writes(), whole.cpu_writes());
|
||||
let refused = whole.indirect_compute_command_at(2).err().unwrap();
|
||||
assert_eq!(whole.set_compute_command(2, sets), Err((0, refused)));
|
||||
let c = each.indirect_compute_command_at(0).unwrap();
|
||||
let before = (storage(&each), each.cpu_writes());
|
||||
let sets = [
|
||||
IndirectComputeSet::SetComputePipelineState(&plain),
|
||||
IndirectComputeSet::SetKernelBuffer {
|
||||
buffer: Some(&a),
|
||||
offset: 0,
|
||||
index: 0,
|
||||
},
|
||||
];
|
||||
let refused = problem(
|
||||
"set_compute_pipeline_state",
|
||||
IndirectCommandBufferProblem::PipelineWithoutSupport,
|
||||
);
|
||||
assert_eq!(c.set_each(sets), Err((0, refused)));
|
||||
assert!(
|
||||
(storage(&each), each.cpu_writes()) == before,
|
||||
"nothing made"
|
||||
);
|
||||
}
|
||||
|
||||
/// Setters on two threads at once: each thread's commands read back as it set them, the writes
|
||||
/// all counted, where the threads set different commands of one buffer (one by its commands'
|
||||
/// setters, the other by `set_render_command`); and where one thread sets
|
||||
/// a command's pipeline state over and over while the other sets its buffers, each reads back its
|
||||
/// own field as it set it after every set, and the command reads back the last state set, its
|
||||
/// record naming that state's ID and identifier, and the last buffers set: no field one thread
|
||||
/// wrote is lost to the other's write.
|
||||
#[test]
|
||||
fn setters_on_two_threads_keep_each_other_s_fields() {
|
||||
const SETS: u64 = 2000;
|
||||
let scratch = Scratch::new("icb-two-threads");
|
||||
let device = device(&scratch.0);
|
||||
let states = [render_state(&device, true), render_state(&device, true)];
|
||||
assert_ne!(states[0].gpu_resource_id(), states[1].gpu_resource_id());
|
||||
let shared = ResourceOptions::shared();
|
||||
let (a, b) = (
|
||||
device.new_buffer(1 << 20, shared).unwrap(),
|
||||
device.new_buffer(1 << 20, shared).unwrap(),
|
||||
);
|
||||
let mut descriptor = IndirectCommandBufferDescriptor::new();
|
||||
descriptor.command_types = IndirectCommandType::DRAW;
|
||||
descriptor.max_vertex_buffer_bind_count = 2;
|
||||
descriptor.max_fragment_buffer_bind_count = 1;
|
||||
let size = 64;
|
||||
let icb = device
|
||||
.new_indirect_command_buffer(&descriptor, size, shared)
|
||||
.unwrap();
|
||||
let triangle = DrawPrimitiveType::from_raw(3).unwrap();
|
||||
let before = icb.cpu_writes();
|
||||
// Different commands: thread `t` sets the commands `index % 2 == t`, each over and over,
|
||||
// the last round's values its own.
|
||||
let slot = |t: usize, index: u64, round: u64| {
|
||||
if t == 1 {
|
||||
let sets = [
|
||||
IndirectRenderSet::SetRenderPipelineState(&states[t]),
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&a),
|
||||
offset: (index + round) * 16,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&b),
|
||||
offset: index * 32,
|
||||
index: 1,
|
||||
},
|
||||
IndirectRenderSet::SetFragmentBuffer {
|
||||
buffer: Some(&b),
|
||||
offset: round * 16,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::DrawPrimitives {
|
||||
primitive_type: triangle,
|
||||
vertex_start: index,
|
||||
vertex_count: 3,
|
||||
instance_count: 1,
|
||||
base_instance: round,
|
||||
},
|
||||
];
|
||||
return icb.set_render_command(index, sets).unwrap();
|
||||
}
|
||||
let c = icb.indirect_render_command_at(index).unwrap();
|
||||
c.set_render_pipeline_state(&states[t]).unwrap();
|
||||
c.set_vertex_buffer(Some(&a), (index + round) * 16, 0)
|
||||
.unwrap();
|
||||
c.set_vertex_buffer(Some(&b), index * 32, 1).unwrap();
|
||||
c.set_fragment_buffer(Some(&b), round * 16, 0).unwrap();
|
||||
c.draw_primitives(triangle, index, 3, 1, round).unwrap();
|
||||
};
|
||||
let rounds = SETS / size;
|
||||
std::thread::scope(|scope| {
|
||||
for t in 0..2 {
|
||||
let slot = &slot;
|
||||
scope.spawn(move || {
|
||||
for round in 0..rounds {
|
||||
for index in (t as u64..size).step_by(2) {
|
||||
slot(t, index, round);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
let last = rounds - 1;
|
||||
for index in 0..size {
|
||||
let c = icb.indirect_render_command_at(index).unwrap();
|
||||
let t = (index % 2) as usize;
|
||||
let named = c.pipeline_state().unwrap().map(|s| s.gpu_resource_id());
|
||||
assert_eq!(named, Some(states[t].gpu_resource_id()), "command {index}");
|
||||
let at = |buffer: &Buffer, offset: u64| Some(GpuAddress(buffer.gpu_address().0 + offset));
|
||||
let address = |binding: Option<IndirectBufferBinding>| binding.map(|b| b.address);
|
||||
assert_eq!(
|
||||
address(c.vertex_buffer(0).unwrap()),
|
||||
at(&a, (index + last) * 16)
|
||||
);
|
||||
assert_eq!(address(c.vertex_buffer(1).unwrap()), at(&b, index * 32));
|
||||
assert_eq!(address(c.fragment_buffer(0).unwrap()), at(&b, last * 16));
|
||||
let drawn = c.draw().unwrap();
|
||||
let expected = IndirectDraw::Primitives {
|
||||
primitive_type: triangle,
|
||||
vertex_start: index,
|
||||
vertex_count: 3,
|
||||
instance_count: 1,
|
||||
base_instance: last,
|
||||
};
|
||||
assert_eq!(drawn, Some(expected), "command {index}");
|
||||
}
|
||||
assert_eq!(
|
||||
icb.cpu_writes() - before,
|
||||
5 * rounds * size,
|
||||
"every write counted"
|
||||
);
|
||||
|
||||
// One command: its pipeline state on one thread, its buffers on the other, each thread
|
||||
// reading back its own field after every set, which the other's writes must leave as set.
|
||||
let c = icb.indirect_render_command_at(7).unwrap();
|
||||
std::thread::scope(|scope| {
|
||||
scope.spawn(|| {
|
||||
for set in 0..SETS {
|
||||
let state = &states[(set % 2) as usize];
|
||||
c.set_render_pipeline_state(state).unwrap();
|
||||
let id = c.pipeline_id().unwrap();
|
||||
assert_eq!(id, Some(state.gpu_resource_id()), "set {set}: the state");
|
||||
}
|
||||
});
|
||||
scope.spawn(|| {
|
||||
for set in 0..SETS {
|
||||
c.set_vertex_buffer(Some(&b), set * 16, 0).unwrap();
|
||||
c.set_fragment_buffer(Some(&a), set * 32, 0).unwrap();
|
||||
let address = c.vertex_buffer(0).unwrap().map(|b| b.address);
|
||||
let expected = GpuAddress(b.gpu_address().0 + set * 16);
|
||||
assert_eq!(address, Some(expected), "set {set}: the vertex buffer");
|
||||
}
|
||||
});
|
||||
});
|
||||
let state = &states[((SETS - 1) % 2) as usize];
|
||||
let named = c.pipeline_state().unwrap().map(|s| s.gpu_resource_id());
|
||||
assert_eq!(named, Some(state.gpu_resource_id()), "the last state set");
|
||||
assert_eq!(c.pipeline_id().unwrap(), Some(state.gpu_resource_id()));
|
||||
assert_eq!(
|
||||
c.pipeline_unique_identifier().unwrap(),
|
||||
Some(state.unique_identifier()),
|
||||
"the record names the state set"
|
||||
);
|
||||
let address = c.vertex_buffer(0).unwrap().map(|b| b.address);
|
||||
assert_eq!(
|
||||
address,
|
||||
Some(GpuAddress(b.gpu_address().0 + (SETS - 1) * 16))
|
||||
);
|
||||
let address = c.fragment_buffer(0).unwrap().map(|b| b.address);
|
||||
assert_eq!(
|
||||
address,
|
||||
Some(GpuAddress(a.gpu_address().0 + (SETS - 1) * 32))
|
||||
);
|
||||
}
|
||||
|
||||
/// A setter's write takes the buffer's lock only where it sets a pipeline state the command does
|
||||
/// not name yet or adds to what the records may hold, on a buffer the GPU may not have written: a
|
||||
/// buffer slot, a draw or a barrier the CPU's edits added already, a barrier cleared, and the
|
||||
/// state the command names already go without it, counted apart (`writes_apart`), a call of
|
||||
/// `set_render_command` counting its writes so once; on a buffer the GPU may write, every write
|
||||
/// takes it.
|
||||
#[test]
|
||||
fn setters_take_the_lock_only_to_set_a_state_or_add_to_the_records() {
|
||||
let scratch = Scratch::new("icb-unlocked-writes");
|
||||
let device = device(&scratch.0);
|
||||
let state = render_state(&device, true);
|
||||
let shared = ResourceOptions::shared();
|
||||
let buffer = device.new_buffer(4096, shared).unwrap();
|
||||
let mut descriptor = IndirectCommandBufferDescriptor::new();
|
||||
descriptor.command_types = IndirectCommandType::DRAW;
|
||||
descriptor.max_vertex_buffer_bind_count = 1;
|
||||
let icb = device
|
||||
.new_indirect_command_buffer(&descriptor, u64::from(COMMANDS), shared)
|
||||
.unwrap();
|
||||
let c: Vec<_> = (0..u64::from(COMMANDS))
|
||||
.map(|index| icb.indirect_render_command_at(index).unwrap())
|
||||
.collect();
|
||||
let (triangle, point) = (PrimitiveType::Triangle, PrimitiveType::Point);
|
||||
let mut at = icb.writes_apart();
|
||||
// A call's writes, and how many went under the lock and how many without it.
|
||||
let mut went = |what: &str, call: Result<(), Error>, locked: u64, unlocked: u64| {
|
||||
call.unwrap();
|
||||
let now = icb.writes_apart();
|
||||
assert_eq!(now, (at.0 + locked, at.1 + unlocked), "{what}");
|
||||
at = now;
|
||||
};
|
||||
went("a state", c[0].set_render_pipeline_state(&state), 1, 0);
|
||||
went(
|
||||
"a buffer",
|
||||
c[0].set_vertex_buffer(Some(&buffer), 0, 0),
|
||||
0,
|
||||
1,
|
||||
);
|
||||
went(
|
||||
"a first draw",
|
||||
c[0].draw_primitives(triangle, 0, 3, 1, 0),
|
||||
1,
|
||||
0,
|
||||
);
|
||||
went(
|
||||
"the draw again",
|
||||
c[1].draw_primitives(triangle, 0, 3, 1, 0),
|
||||
0,
|
||||
1,
|
||||
);
|
||||
went(
|
||||
"another type",
|
||||
c[1].draw_primitives(point, 0, 3, 1, 0),
|
||||
1,
|
||||
0,
|
||||
);
|
||||
went("a first barrier", c[1].set_barrier(), 1, 0);
|
||||
went("a barrier again", c[2].set_barrier(), 0, 1);
|
||||
went("a barrier cleared", c[2].clear_barrier(), 0, 1);
|
||||
let other = render_state(&device, true);
|
||||
let (one, other) = (&state, &other);
|
||||
let states = [
|
||||
("the state, another command", one, 1, 0),
|
||||
("a state named already", one, 0, 1),
|
||||
("another state", other, 1, 0),
|
||||
("that state again", other, 0, 1),
|
||||
];
|
||||
for (what, state, locked, unlocked) in states {
|
||||
went(
|
||||
what,
|
||||
c[1].set_render_pipeline_state(state),
|
||||
locked,
|
||||
unlocked,
|
||||
);
|
||||
}
|
||||
let sets = [
|
||||
IndirectRenderSet::SetVertexBuffer {
|
||||
buffer: Some(&buffer),
|
||||
offset: 64,
|
||||
index: 0,
|
||||
},
|
||||
IndirectRenderSet::DrawPrimitives {
|
||||
primitive_type: DrawPrimitiveType::from_raw(3).unwrap(),
|
||||
vertex_start: 0,
|
||||
vertex_count: 3,
|
||||
instance_count: 1,
|
||||
base_instance: 0,
|
||||
},
|
||||
];
|
||||
let batch = icb.set_render_command(3, sets).map_err(|(_, error)| error);
|
||||
went("a batch", batch, 0, 2);
|
||||
icb.written_by_gpu(GpuWriter::Reset);
|
||||
went(
|
||||
"GPU-written, a draw",
|
||||
c[3].draw_primitives(triangle, 0, 3, 1, 0),
|
||||
1,
|
||||
0,
|
||||
);
|
||||
went(
|
||||
"GPU-written, a buffer",
|
||||
c[3].set_vertex_buffer(Some(&buffer), 0, 0),
|
||||
1,
|
||||
0,
|
||||
);
|
||||
let named = c[1].set_render_pipeline_state(other);
|
||||
went("GPU-written, a state named", named, 1, 0);
|
||||
let named = c[1].pipeline_state().unwrap().map(|s| s.gpu_resource_id());
|
||||
assert_eq!(named, Some(other.gpu_resource_id()), "the state set last");
|
||||
}
|
||||
Vendored
+1
-1
@@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 518;
|
||||
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
|
||||
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
|
||||
/// keeps no history.
|
||||
pub const RUNTIME_VERSION: u32 = 2241;
|
||||
pub const RUNTIME_VERSION: u32 = 2242;
|
||||
|
||||
/// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex,
|
||||
/// of the manifest, the build script, and exactly the files the crate roots' module tree compiles
|
||||
|
||||
@@ -580,6 +580,13 @@ pub enum Action {
|
||||
}
|
||||
|
||||
impl Action {
|
||||
/// What a record holding the action, and no barrier, holds of what a command may write
|
||||
/// ([`CommandRecord::writes`] of such a record): its operation, and a draw's primitive type
|
||||
/// (every type for a private one, past Metal's five).
|
||||
pub fn writes(&self) -> crate::pipeline::CommandWrites {
|
||||
writes_of(self, false)
|
||||
}
|
||||
|
||||
/// Whether the action's arguments take the stage-in region's words
|
||||
/// (`layout::DRAW_ARGUMENT_WORDS`): an indexed draw's, a patch draw's, an indexed patch
|
||||
/// draw's or a mesh draw's. A render command sets no stage-in region.
|
||||
|
||||
@@ -1330,8 +1330,10 @@ enum metal2vulkan-runtime::InPlaceRefusal #[derive(Clone, Copy, Debug, PartialEq
|
||||
enum metal2vulkan-runtime::InPlaceRowEnds #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum InPlaceRowEnds
|
||||
enum metal2vulkan-runtime::IndirectCommand #[derive(Clone, Debug)] #[non_exhaustive] pub enum IndirectCommand
|
||||
enum metal2vulkan-runtime::IndirectCommandBufferProblem #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum IndirectCommandBufferProblem
|
||||
enum metal2vulkan-runtime::IndirectComputeSet #[derive(Clone, Copy, Debug)] pub enum IndirectComputeSet<'a>
|
||||
enum metal2vulkan-runtime::IndirectDispatch #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum IndirectDispatch
|
||||
enum metal2vulkan-runtime::IndirectDraw #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum IndirectDraw
|
||||
enum metal2vulkan-runtime::IndirectRenderSet #[derive(Clone, Copy, Debug)] pub enum IndirectRenderSet<'a>
|
||||
enum metal2vulkan-runtime::IndirectRule #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum IndirectRule
|
||||
enum metal2vulkan-runtime::InstanceApiVersion #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum InstanceApiVersion
|
||||
enum metal2vulkan-runtime::LayerSettingValue #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum LayerSettingValue
|
||||
@@ -8748,8 +8750,10 @@ method metal2vulkan-runtime::IndirectCommandBuffer::may_name_encoding_states pub
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::reset_with_range pub fn reset_with_range(&self, range: Range<u64>) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::resource_index pub fn resource_index(&self) -> u64
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::resource_options pub fn resource_options(&self) -> ResourceOptions
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::set_compute_command pub fn set_compute_command<'a>(&self, index: u64, sets: impl IntoIterator<Item = IndirectComputeSet<'a>>) -> Result<(), (usize, Error)>
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::set_label pub fn set_label(&self, label: &str)
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::set_purgeable_state pub fn set_purgeable_state(&self, state: PurgeableState) -> Result<PurgeableState, Error>
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::set_render_command pub fn set_render_command<'a>(&self, index: u64, sets: impl IntoIterator<Item = IndirectRenderSet<'a>>) -> Result<(), (usize, Error)>
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::size pub fn size(&self) -> u64
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::storage_mode pub fn storage_mode(&self) -> StorageMode
|
||||
method metal2vulkan-runtime::IndirectCommandBuffer::unique_identifier pub fn unique_identifier(&self) -> u64
|
||||
@@ -8769,6 +8773,7 @@ method metal2vulkan-runtime::IndirectComputeCommand::pipeline_unique_identifier
|
||||
method metal2vulkan-runtime::IndirectComputeCommand::reset pub fn reset(&self) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectComputeCommand::set_barrier pub fn set_barrier(&self) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectComputeCommand::set_compute_pipeline_state pub fn set_compute_pipeline_state(&self, state: &ComputePipelineState) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectComputeCommand::set_each pub fn set_each<'a>(&self, sets: impl IntoIterator<Item = IndirectComputeSet<'a>>) -> Result<(), (usize, Error)>
|
||||
method metal2vulkan-runtime::IndirectComputeCommand::set_imageblock_size pub fn set_imageblock_size(&self, width: u64, height: u64) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectComputeCommand::set_kernel_buffer pub fn set_kernel_buffer(&self, buffer: Option<&Buffer>, offset: u64, index: u32) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectComputeCommand::set_kernel_buffer_with_stride pub fn set_kernel_buffer_with_stride(&self, buffer: Option<&Buffer>, offset: u64, stride: u64, index: u32) -> Result<(), Error>
|
||||
@@ -8800,6 +8805,7 @@ method metal2vulkan-runtime::IndirectRenderCommand::set_cull_mode pub fn set_cul
|
||||
method metal2vulkan-runtime::IndirectRenderCommand::set_depth_bias pub fn set_depth_bias(&self, _depth_bias: f32, _slope_scale: f32, _clamp: f32) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectRenderCommand::set_depth_clip_mode pub fn set_depth_clip_mode(&self, _mode: DepthClipMode) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectRenderCommand::set_depth_stencil_state pub fn set_depth_stencil_state(&self, state: Option<&DepthStencilState>) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectRenderCommand::set_each pub fn set_each<'a>(&self, sets: impl IntoIterator<Item = IndirectRenderSet<'a>>) -> Result<(), (usize, Error)>
|
||||
method metal2vulkan-runtime::IndirectRenderCommand::set_fragment_buffer pub fn set_fragment_buffer(&self, buffer: Option<&Buffer>, offset: u64, index: u32) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectRenderCommand::set_front_facing_winding pub fn set_front_facing_winding(&self, _winding: Winding) -> Result<(), Error>
|
||||
method metal2vulkan-runtime::IndirectRenderCommand::set_mesh_buffer pub fn set_mesh_buffer(&self, buffer: Option<&Buffer>, offset: u64, index: u32) -> Result<(), Error>
|
||||
@@ -9575,6 +9581,7 @@ method metal2vulkan::bind::YCbCrRefreshModule::shape pub fn shape(firsts: [u32;
|
||||
method metal2vulkan::bind::YCbCrSampleModule::push pub fn push(size: [u32; 2], extent: [u32; 2]) -> [u8; Self::PUSH_BYTES as usize]
|
||||
method metal2vulkan::bind::YCbCrWriteModule::groups pub fn groups(planes: &YCbCrPlanes) -> [u32; 2]
|
||||
method metal2vulkan::bind::YCbCrWriteModule::shape pub fn shape(planes: &YCbCrPlanes, all: bool) -> [u8; Self::SHAPE_WORDS as usize * 4]
|
||||
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<BufferBinding>; BINDING_COUNT]
|
||||
method metal2vulkan::bind::indirect_commands::Bindings::buffers_mut pub fn buffers_mut(&mut self, stage: BufferStage) -> &mut [Option<BufferBinding>; BINDING_COUNT]
|
||||
method metal2vulkan::bind::indirect_commands::BufferBinding::buffer_alignment pub fn buffer_alignment(&self) -> u64
|
||||
@@ -12574,6 +12581,17 @@ variant metal2vulkan-runtime::IndirectCommandBufferProblem::PipelineKind Pipelin
|
||||
variant metal2vulkan-runtime::IndirectCommandBufferProblem::PipelineWithoutSupport PipelineWithoutSupport
|
||||
variant metal2vulkan-runtime::IndirectCommandBufferProblem::Range Range { location: u64, length: u64, size: u64 }
|
||||
variant metal2vulkan-runtime::IndirectCommandBufferProblem::RenderState RenderState
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::ClearBarrier ClearBarrier
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::ConcurrentDispatchThreadgroups ConcurrentDispatchThreadgroups { threadgroups: Size, threads_per_threadgroup: Size }
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::ConcurrentDispatchThreads ConcurrentDispatchThreads { threads: Size, threads_per_threadgroup: Size }
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::Reset Reset
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::SetBarrier SetBarrier
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::SetComputePipelineState SetComputePipelineState(&'a ComputePipelineState)
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::SetImageblockSize SetImageblockSize { width: u64, height: u64 }
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::SetKernelBuffer SetKernelBuffer { buffer: Option<&'a Buffer>, offset: u64, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::SetKernelBufferWithStride SetKernelBufferWithStride { buffer: Option<&'a Buffer>, offset: u64, stride: u64, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::SetStageInRegion SetStageInRegion(Region)
|
||||
variant metal2vulkan-runtime::IndirectComputeSet::SetThreadgroupMemoryLength SetThreadgroupMemoryLength { length: u32, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectDispatch::Threadgroups Threadgroups { threadgroups_per_grid: Size, threads_per_threadgroup: Size }
|
||||
variant metal2vulkan-runtime::IndirectDispatch::Threads Threads { threads_per_grid: Size, threads_per_threadgroup: Size }
|
||||
variant metal2vulkan-runtime::IndirectDraw::IndexedPatches IndexedPatches { control_points: u64, patch_start: u64, patch_count: u64, patch_index_buffer: Option<GpuAddress>, control_point_index_buffer: Option<GpuAddress>, instance_count: u64, base_instance: u64, factor_buffer: GpuAddress, factor_instance_stride: u64 }
|
||||
@@ -12582,6 +12600,28 @@ variant metal2vulkan-runtime::IndirectDraw::MeshThreadgroups MeshThreadgroups {
|
||||
variant metal2vulkan-runtime::IndirectDraw::MeshThreads MeshThreads { threads_per_grid: Size, threads_per_object_threadgroup: Size, threads_per_mesh_threadgroup: Size }
|
||||
variant metal2vulkan-runtime::IndirectDraw::Patches Patches { control_points: u64, patch_start: u64, patch_count: u64, patch_index_buffer: Option<GpuAddress>, instance_count: u64, base_instance: u64, factor_buffer: GpuAddress, factor_instance_stride: u64 }
|
||||
variant metal2vulkan-runtime::IndirectDraw::Primitives Primitives { primitive_type: DrawPrimitiveType, vertex_start: u64, vertex_count: u64, instance_count: u64, base_instance: u64 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::ClearBarrier ClearBarrier
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::DrawIndexedPatches DrawIndexedPatches { number_of_patch_control_points: u64, patch_start: u64, patch_count: u64, patch_index_buffer: Option<&'a Buffer>, patch_index_buffer_offset: u64, control_point_index_buffer: Option<&'a Buffer>, control_point_index_buffer_offset: u64, instance_count: u64, base_instance: u64, tessellation_factor_buffer: &'a Buffer, tessellation_factor_buffer_offset: u64, tessellation_factor_buffer_instance_stride: u64 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::DrawIndexedPrimitives DrawIndexedPrimitives { primitive_type: DrawPrimitiveType, index_count: u64, index_type: IndexType, index_buffer: &'a Buffer, index_buffer_offset: u64, instance_count: u64, base_vertex: i64, base_instance: u64 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::DrawMeshThreadgroups DrawMeshThreadgroups { threadgroups_per_grid: Size, threads_per_object_threadgroup: Size, threads_per_mesh_threadgroup: Size }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::DrawMeshThreads DrawMeshThreads { threads_per_grid: Size, threads_per_object_threadgroup: Size, threads_per_mesh_threadgroup: Size }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::DrawPatches DrawPatches { number_of_patch_control_points: u64, patch_start: u64, patch_count: u64, patch_index_buffer: Option<&'a Buffer>, patch_index_buffer_offset: u64, instance_count: u64, base_instance: u64, tessellation_factor_buffer: &'a Buffer, tessellation_factor_buffer_offset: u64, tessellation_factor_buffer_instance_stride: u64 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::DrawPrimitives DrawPrimitives { primitive_type: DrawPrimitiveType, vertex_start: u64, vertex_count: u64, instance_count: u64, base_instance: u64 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::Reset Reset
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetBarrier SetBarrier
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetCullMode SetCullMode(CullMode)
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetDepthBias SetDepthBias { depth_bias: f32, slope_scale: f32, clamp: f32 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetDepthClipMode SetDepthClipMode(DepthClipMode)
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetDepthStencilState SetDepthStencilState(Option<&'a DepthStencilState>)
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetFragmentBuffer SetFragmentBuffer { buffer: Option<&'a Buffer>, offset: u64, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetFrontFacingWinding SetFrontFacingWinding(Winding)
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetMeshBuffer SetMeshBuffer { buffer: Option<&'a Buffer>, offset: u64, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetObjectBuffer SetObjectBuffer { buffer: Option<&'a Buffer>, offset: u64, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetObjectThreadgroupMemoryLength SetObjectThreadgroupMemoryLength { length: u32, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetRenderPipelineState SetRenderPipelineState(&'a RenderPipelineState)
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetTriangleFillMode SetTriangleFillMode(TriangleFillMode)
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetVertexBuffer SetVertexBuffer { buffer: Option<&'a Buffer>, offset: u64, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectRenderSet::SetVertexBufferWithStride SetVertexBufferWithStride { buffer: Option<&'a Buffer>, offset: u64, stride: u64, index: u32 }
|
||||
variant metal2vulkan-runtime::IndirectRule::CommandRenderStates CommandRenderStates
|
||||
variant metal2vulkan-runtime::IndirectRule::FamilyRow FamilyRow
|
||||
variant metal2vulkan-runtime::IndirectRule::MemorylessReadPastPass MemorylessReadPastPass
|
||||
|
||||
|
Can't render this file because it is too large.
|
+15
@@ -5054,6 +5054,21 @@ each item named states the rule in full.
|
||||
|
||||
**Indirect command buffers**
|
||||
|
||||
- **A command's setters in one call** (`IndirectRenderCommand::set_each`,
|
||||
`IndirectComputeCommand::set_each`, no Metal counterpart): an `IndirectRenderSet` or
|
||||
`IndirectComputeSet` names one setter call, its fields the setter's arguments, and each does
|
||||
what that setter does, refusals included. The first refused stops the rest and answers its place
|
||||
among them with the setter's error; the calls before it stay made and those after it are not
|
||||
taken, as one setter call at a time would leave the command.
|
||||
`IndirectCommandBuffer::set_render_command` and `set_compute_command` (no Metal counterpart:
|
||||
`indirectRenderCommandAtIndex:` or `indirectComputeCommandAtIndex:`, then the setters) take the
|
||||
command's index with the sets, with no command handle; the refusals of the index (past the
|
||||
size) and of the kind (a compute command of a render buffer) answer at place 0, before any
|
||||
setter. A setter's write that adds nothing to what the records may hold, on a buffer the GPU
|
||||
may not have written, takes no lock: a buffer slot, a draw, dispatch or barrier the CPU's
|
||||
writes added already, and a pipeline state the command names already, which is not held
|
||||
either. Each command's first set of a state, and every set after a device recovery carried
|
||||
the buffer, takes the lock and checks the state.
|
||||
- **A command's read-back answers Metal's private getters**: `command_type`, the buffer addresses
|
||||
and attribute strides, as Metal's `get*` getters answer them. `IndirectComputeCommand` and
|
||||
`IndirectRenderCommand` read one field of their record alone (`command_type`, `has_barrier`,
|
||||
|
||||
+12
-12
@@ -370,7 +370,7 @@ Columns:
|
||||
| `Mipmap` | A `generate_mipmaps` Metal stops | every device (a public call's own check of its arguments) | `delegated`: MipmapProblem, section 9 | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs (mipmaps)` | `-` |
|
||||
| `BufferTexture` | A texture over a buffer plain Metal itself refuses | every device (a public call's own check of its arguments) | `delegated`: BufferTextureProblem, section 9 | 3: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error, 2 sites)`, `crates/metal2vulkan-runtime/src/capabilities.rs (linear_alignment_rule)` | `-` |
|
||||
| `RenderPass` | A render pass descriptor, or a render encoder's late store action, Metal stops | every device (a public call's own check of its arguments) | `delegated`: RenderPassProblem, section 9 | 15: `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs (check_descriptor)`, `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs (of)` (+8) | `-` |
|
||||
| `Draw` | A draw, or render encoder state, Metal stops | every device (a public call's own check of its arguments) | `delegated`: DrawProblem, section 9 | 3: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_patches)`, `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives)` (+1) | `-` |
|
||||
| `Draw` | A draw, or render encoder state, Metal stops | every device (a public call's own check of its arguments) | `delegated`: DrawProblem, section 9 | 3: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_patches)`, `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives_in)` (+1) | `-` |
|
||||
| `PointSizeTopology` | `new_render_pipeline_state` | every device (a public call's own check of its arguments) | `metal-measured`: an M3 Max and an M4: Metal's pipeline creation answers an error, with and without API validation | 1: `crates/metal2vulkan-runtime/src/pipeline/render.rs (create_checked)` | `-` |
|
||||
| `IndirectScaledTessellation` | `new_render_pipeline_state` | every device (a public call's own check of its arguments) | `metal-measured`: an M3 Max, macOS 27.0.1: plain Metal ends its process, the API validation layer off | 1: `crates/metal2vulkan-runtime/src/pipeline/render.rs (create_reflecting)` | `-` |
|
||||
| `CompiledKernel` | `new_compute_pipeline_state` | every device (a public call's own check of its arguments) | `ours`: this crate's already-compiled stage: Metal's descriptor takes a function | 1: `crates/metal2vulkan-runtime/src/pipeline/mod.rs (of_kernel)` | `-` |
|
||||
@@ -515,7 +515,7 @@ Columns:
|
||||
| `DrawProblem::ViewMappings` | `set_vertex_amplification_count` | every device (a public call's own check of its arguments) | `ours`: this crate's slice of view mappings: Metal's call takes a pointer, and reading the count would pass the memory the caller handed over | 1: `crates/metal2vulkan-runtime/src/amplification.rs (new)` | `-` |
|
||||
| `DrawProblem::PatchIndexBufferRange` | A direct patch draw's patch indices run past its patch index buffer | every device (a public call's own check of its arguments) | `metal-takes`: an M4: plain Metal reads past the patch index buffer rather than refusing, probe case `pib_short`: undefined | 2: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_patches)`, `crates/metal2vulkan-runtime/src/render.rs (check_patch_indices)` | `-` |
|
||||
| `DrawProblem::ControlPointIndexBufferRange` | A direct indexed patch draw's control-point indices run past its control-point index buffer | every device (a public call's own check of its arguments) | `metal-takes`: an M4: plain Metal reads past the control-point index buffer rather than refusing, probe cases `cpi_short` and `cpi_start1_count2`: undefined | 1: `crates/metal2vulkan-runtime/src/render.rs (check_control_point_indices)` | `-` |
|
||||
| `DrawProblem::IndexBufferRange` | An indirect render command's indexed draw whose `count` indices from `offset` (rounded down to a multiple of the index size, as Metal reads it)... | every device (a public call's own check of its arguments) | `metal-takes`: an Apple M3 Max, macOS 27.0.1, probe `refusals_without_a_named_device` shape `idxc-past`, four fresh processes with one reading: plain Metal completes an indirect indexed draw of 12 indices from byte 480 of a 512-byte index buffer, with no error, and its vertex function is given the eight indices inside the buffer and then the four words that follow it in the heap, each of which holds its own word number -- so the fetch read the following memory by name, where the same draw made directly on the encoder was given index 0 at those four positions, `idxv-past` | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives)` | `-` |
|
||||
| `DrawProblem::IndexBufferRange` | An indirect render command's indexed draw whose `count` indices from `offset` (rounded down to a multiple of the index size, as Metal reads it)... | every device (a public call's own check of its arguments) | `metal-takes`: an Apple M3 Max, macOS 27.0.1, probe `refusals_without_a_named_device` shape `idxc-past`, four fresh processes with one reading: plain Metal completes an indirect indexed draw of 12 indices from byte 480 of a 512-byte index buffer, with no error, and its vertex function is given the eight indices inside the buffer and then the four words that follow it in the heap, each of which holds its own word number -- so the fetch read the following memory by name, where the same draw made directly on the encoder was given index 0 at those four positions, `idxv-past` | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives_in)` | `-` |
|
||||
| `RenderStateProblem::Count` | A count of viewports outside 1 to 16, or of no scissor rectangle (more than 16 scissor rectangles are taken, as plain Metal takes them) | every device (a public call's own check of its arguments) | `unknown`: plain Metal's answer for a viewport count outside 1 to 16, and for no scissor rectangle, is unmeasured; the more than 16 scissor rectangles it takes are not refused | 2: `crates/metal2vulkan-runtime/src/render_state.rs (check_count)`, `crates/metal2vulkan-runtime/src/render_state.rs (scissor_rects)` | `-` |
|
||||
| `RenderStateProblem::ViewportNotFinite` | A viewport field that is NaN or infinite, but for a NaN origin x, which draws nothing, as plain Metal's | every device (a public call's own check of its arguments) | `unknown`: plain Metal's answer for a viewport field that is NaN or infinite is measured only for a NaN origin x, which draws nothing and is not refused | 1: `crates/metal2vulkan-runtime/src/render_state.rs (set_viewports)` | `-` |
|
||||
| `VisibilityProblem::NoBuffer` | The pass has no visibility result buffer | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal's process ends, SIGSEGV, at `setVisibilityResultMode:offset:` in a pass with no visibility result buffer | 1: `crates/metal2vulkan-runtime/src/visibility.rs (check_mode)` | `-` |
|
||||
@@ -534,13 +534,13 @@ Columns:
|
||||
| `FunctionTableProblem::StageWithoutFunction` | A render pipeline state's `function_handle` or `new_visible_function_table` for `stage`, which is not one stage | every device (a public call's own check of its arguments) | `metal-measured`: an M4, macOS 27.0.1: plain Metal answers the handle nil and the table of more than one stage nil, and faults on a table of no stage | 1: `crates/metal2vulkan-runtime/src/function_table.rs (not_one_stage)` | `-` |
|
||||
| `IndirectCommandBufferProblem::NoCommandTypes` | A call on a buffer of no command types that plain Metal's process does not survive | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, build 26A434, the validation layer off, one shape per process, three processes a shape, each beside the same call on a buffer of the matching command type, `probes/icb_refusals_that_metal_takes.m`. Plain Metal ends the process — SIGBUS, SIGSEGV in some processes of the same shape — at `setRenderPipelineState:`, `setVertexBuffer:offset:atIndex:`, `drawPrimitives:`, `drawIndexedPrimitives:`, `setComputePipelineState:`, `concurrentDispatchThreadgroups:`, `concurrentDispatchThreads:`, a compute command's `reset`, and `resetWithRange:` of a non-empty range, where the buffer of the matching type takes each. It **takes**, and the runtime takes with it, `indirectRenderCommandAtIndex:` and `indirectComputeCommandAtIndex:` — an object, not nil — a render command's `reset`, `setFragmentBuffer:`, `setBarrier` and `clearBarrier`, `setKernelBuffer:` plain and with an attribute stride, `setThreadgroupMemoryLength:atIndex:`, `setStageInRegion:`, `setImageblockWidth:height:`, `resetWithRange:` of an empty range, the execution in a pass which paints nothing, `optimizeIndirectCommandBuffer:`, the blit copy in either direction, and the argument-buffer encoding, whose word is the buffer's own place among the device's indirect command buffers, assigned in creation order and decided by no command type: two buffers encoded side by side take two different IDs whichever types they hold, and the earlier reading that a buffer of no types encodes a `Draw` buffer's bytes held only because each shape made one buffer in its own process. The runtime takes both of those calls: the encoding writes that ID, and the copy beside a buffer of a disagreeing type completes and moves nothing, which is what Metal moves in the one direction a public call can read. The read-back is a runtime extension and has no Metal call to measure | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_command_types)` | `-` |
|
||||
| `IndirectCommandBufferProblem::Range` | A range of commands not inside the buffer | every device (a public call's own check of its arguments) | `unknown`: plain Metal's answer for a reset or read-back range that is not inside the buffer is unmeasured | 2: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (command_range)`, `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (inside)` | `-` |
|
||||
| `IndirectCommandBufferProblem::InheritedPipelineState` | A pipeline state set on a command of a buffer that inherits it (this ends Metal's process) | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal ends the process, SIGBUS, at `setRenderPipelineState:` on a command of a buffer whose `inheritPipelineState` is set, where the same setter on a buffer that does not inherit it runs the draw | 2: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_compute_pipeline_state)`, `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_render_pipeline_state)` | `-` |
|
||||
| `IndirectCommandBufferProblem::PipelineWithoutSupport` | A pipeline state made without `supportIndirectCommandBuffers`, set on a command | every device (a public call's own check of its arguments) | `metal-takes`: an Apple M3 Max, macOS 27.0.1, build 26A434, the validation layer off, one shape per process, three processes a shape, `probes/icb_refusals_that_metal_takes.m`. The two kinds do not answer alike. `setComputePipelineState:` with a state made without the flag ends the process, SIGSEGV, where the same call with the flag set dispatches and the kernel's marker words read back: that arm is a refusal of Metal's own. `setRenderPipelineState:` and `drawPrimitives:` both return, and the command buffer then fails at execution with status 5 and `Caused GPU Address Fault Error 0000000b:kIOGPUCommandBufferCallbackErrorPageFault`, leaving the target at its clear value, where the same pipeline with the flag set paints; a plainly valid command buffer submitted after the fault completes and paints, so the fault does not poison the queue. That arm stands on undefined behaviour — a GPU address fault is not an answer — and so reaches past Metal, and the refusal is kept there deliberately: a typed `Invalid` at the setter is the useful answer where Metal's own is a page fault at execution | 3: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_compute_pipeline_state)`, `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_render_pipeline_state, 2 sites)` | `-` |
|
||||
| `IndirectCommandBufferProblem::InheritedPipelineState` | A pipeline state set on a command of a buffer that inherits it (this ends Metal's process) | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal ends the process, SIGBUS, at `setRenderPipelineState:` on a command of a buffer whose `inheritPipelineState` is set, where the same setter on a buffer that does not inherit it runs the draw | 2: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (pipeline_in, 2 sites)` | `-` |
|
||||
| `IndirectCommandBufferProblem::PipelineWithoutSupport` | A pipeline state made without `supportIndirectCommandBuffers`, set on a command | every device (a public call's own check of its arguments) | `metal-takes`: an Apple M3 Max, macOS 27.0.1, build 26A434, the validation layer off, one shape per process, three processes a shape, `probes/icb_refusals_that_metal_takes.m`. The two kinds do not answer alike. `setComputePipelineState:` with a state made without the flag ends the process, SIGSEGV, where the same call with the flag set dispatches and the kernel's marker words read back: that arm is a refusal of Metal's own. `setRenderPipelineState:` and `drawPrimitives:` both return, and the command buffer then fails at execution with status 5 and `Caused GPU Address Fault Error 0000000b:kIOGPUCommandBufferCallbackErrorPageFault`, leaving the target at its clear value, where the same pipeline with the flag set paints; a plainly valid command buffer submitted after the fault completes and paints, so the fault does not poison the queue. That arm stands on undefined behaviour — a GPU address fault is not an answer — and so reaches past Metal, and the refusal is kept there deliberately: a typed `Invalid` at the setter is the useful answer where Metal's own is a page fault at execution | 3: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (pipeline_in, 3 sites)` | `-` |
|
||||
| `IndirectCommandBufferProblem::CommandType` | A draw of a kind (`DRAW_PATCHES`, `DRAW_INDEXED_PATCHES`, a mesh kind, or `DRAW` and `DRAW_INDEXED` on a buffer of mesh draws, a probe) whose... | every device (a public call's own check of its arguments) | `metal-takes`: an Apple M3 Max, macOS 27.0.1, build 26A434, the validation layer off, one shape per process, `probes/icb_refusals_that_metal_takes.m`. Plain Metal ends the process, SIGBUS, at a patch draw on a buffer of `DRAW` alone, at a mesh pipeline's `setRenderPipelineState:` on such a buffer, and at a draw of primitives on a buffer of `DRAW_MESH_THREADGROUPS` alone, three processes each | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_draw)` | `-` |
|
||||
| `IndirectCommandBufferProblem::CommandKind` | A compute command of a buffer whose commands are render ones, or a setter plain Metal does not ignore on a render command of a buffer whose... | every device (a public call's own check of its arguments) | `metal-measured`: an M3 Max, macOS 27.0.1: plain Metal's process ends — SIGBUS, SIGBUS and SIGSEGV — at `indirectComputeCommandAtIndex:` on a buffer of draws and at a render command's setters and reset on one of dispatches, the API validation layer off | 7: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_draw)`, `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_getter)` (+5) | `-` |
|
||||
| `IndirectCommandBufferProblem::CommandKind` | A compute command of a buffer whose commands are render ones, or a setter plain Metal does not ignore on a render command of a buffer whose... | every device (a public call's own check of its arguments) | `metal-measured`: an M3 Max, macOS 27.0.1: plain Metal's process ends — SIGBUS, SIGBUS and SIGSEGV — at `indirectComputeCommandAtIndex:` on a buffer of draws and at a render command's setters and reset on one of dispatches, the API validation layer off | 8: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (buffer_in)`, `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_draw)` (+6) | `-` |
|
||||
| `IndirectCommandBufferProblem::RenderState` | A render state set on a render command (`set_depth_stencil_state`, `set_depth_bias`, `set_depth_clip_mode`, `set_cull_mode`,... | every device (a public call's own check of its arguments) | `metal-measured`: an M4, macOS 27.0.1: plain Metal raises `APINotSupported` at each setter and its process ends, whether the buffer inherits the state or not | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (render_state)` | `-` |
|
||||
| `IndirectCommandBufferProblem::ObjectThreadgroupMemory` | An object threadgroup length set on a render command of a buffer whose command types hold no mesh draw (`set_object_threadgroup_memory_length`) | every device (a public call's own check of its arguments) | `metal-measured`: an M4: Metal's process ends at `set_object_threadgroup_memory_length` on a buffer of no mesh draw, with and without its validation | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_object_threadgroup_memory_length)` | `-` |
|
||||
| `IndirectCommandBufferProblem::PipelineKind` | A render pipeline state set on a command of a buffer whose command types hold no draw of its kind (`set_render_pipeline_state`) | every device (a public call's own check of its arguments) | `metal-measured`: an M4: Metal's process ends in `set_render_pipeline_state` on a buffer of no draw of the state's kind, with and without its validation | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_render_pipeline_state)` | `-` |
|
||||
| `IndirectCommandBufferProblem::PipelineKind` | A render pipeline state set on a command of a buffer whose command types hold no draw of its kind (`set_render_pipeline_state`) | every device (a public call's own check of its arguments) | `metal-measured`: an M4: Metal's process ends in `set_render_pipeline_state` on a buffer of no draw of the state's kind, with and without its validation | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (pipeline_in)` | `-` |
|
||||
| `RateMapProblem::ScreenSize` | A screen width or height past 32768 | every device (a public call's own check of its arguments) | `unknown`: plain Metal's answer for a screen side past 32768 is unmeasured; the side of 0 its validation stops is compiled by plain Metal and is not refused | 1: `crates/metal2vulkan-runtime/src/rate_map.rs (validate)` | `-` |
|
||||
| `RateMapProblem::LayerCount` | A layer count past 2 ("layerCount (3) must be >0 and <=2") | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal's process ends, SIGBUS, at `newRasterizationRateMapWithDescriptor:` of 3 and of 4 layers, where 1 and 2 make the map | 2: `crates/metal2vulkan-runtime/src/rate_map.rs (reset)`, `crates/metal2vulkan-runtime/src/rate_map.rs (validate)` | `-` |
|
||||
| `RateMapProblem::NoLayers` | A coordinate map of a map of no layers, which ends Metal's process | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal's process ends, SIGSEGV, at a coordinate map of a map of no layers, which it makes | 2: `crates/metal2vulkan-runtime/src/rate_map.rs (map_physical_to_screen_coordinates)`, `crates/metal2vulkan-runtime/src/rate_map.rs (map_screen_to_physical_coordinates)` | `-` |
|
||||
@@ -861,7 +861,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `invalid::Mipmap`: `crates/metal2vulkan-runtime/src/blit_texture.rs (mipmaps)`
|
||||
- `invalid::BufferTexture`: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error, 2 sites)`; `crates/metal2vulkan-runtime/src/capabilities.rs (linear_alignment_rule)`
|
||||
- `invalid::RenderPass`: `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs (check_descriptor)`; `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs (of)`; `crates/metal2vulkan-runtime/src/render.rs (store_problem)`; `crates/metal2vulkan-runtime/src/render/late_resolve.rs (problem)`; `crates/metal2vulkan-runtime/src/render_pass.rs (2 sites)`; `crates/metal2vulkan-runtime/src/render_pass.rs (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs (depth_stencil, 2 sites)`; `crates/metal2vulkan-runtime/src/render_pass.rs (layout, 4 sites)`; `crates/metal2vulkan-runtime/src/resolve.rs (problem)`; `crates/metal2vulkan-runtime/src/sample_positions.rs (problem)`
|
||||
- `invalid::Draw`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_patches)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives)`; `crates/metal2vulkan-runtime/src/render.rs (draw_problem)`
|
||||
- `invalid::Draw`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_patches)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives_in)`; `crates/metal2vulkan-runtime/src/render.rs (draw_problem)`
|
||||
- `invalid::PointSizeTopology`: `crates/metal2vulkan-runtime/src/pipeline/render.rs (create_checked)`
|
||||
- `invalid::IndirectScaledTessellation`: `crates/metal2vulkan-runtime/src/pipeline/render.rs (create_reflecting)`
|
||||
- `invalid::CompiledKernel`: `crates/metal2vulkan-runtime/src/pipeline/mod.rs (of_kernel)`
|
||||
@@ -984,7 +984,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `subproblem::DrawProblem::ViewMappings`: `crates/metal2vulkan-runtime/src/amplification.rs (new)`
|
||||
- `subproblem::DrawProblem::PatchIndexBufferRange`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_patches)`; `crates/metal2vulkan-runtime/src/render.rs (check_patch_indices)`
|
||||
- `subproblem::DrawProblem::ControlPointIndexBufferRange`: `crates/metal2vulkan-runtime/src/render.rs (check_control_point_indices)`
|
||||
- `subproblem::DrawProblem::IndexBufferRange`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives)`
|
||||
- `subproblem::DrawProblem::IndexBufferRange`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (draw_indexed_primitives_in)`
|
||||
- `subproblem::RenderStateProblem::Count`: `crates/metal2vulkan-runtime/src/render_state.rs (check_count)`; `crates/metal2vulkan-runtime/src/render_state.rs (scissor_rects)`
|
||||
- `subproblem::RenderStateProblem::ViewportNotFinite`: `crates/metal2vulkan-runtime/src/render_state.rs (set_viewports)`
|
||||
- `subproblem::VisibilityProblem::NoBuffer`: `crates/metal2vulkan-runtime/src/visibility.rs (check_mode)`
|
||||
@@ -1003,13 +1003,13 @@ Each refusal's sites, with the function that builds it.
|
||||
- `subproblem::FunctionTableProblem::StageWithoutFunction`: `crates/metal2vulkan-runtime/src/function_table.rs (not_one_stage)`
|
||||
- `subproblem::IndirectCommandBufferProblem::NoCommandTypes`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_command_types)`
|
||||
- `subproblem::IndirectCommandBufferProblem::Range`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (command_range)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (inside)`
|
||||
- `subproblem::IndirectCommandBufferProblem::InheritedPipelineState`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_render_pipeline_state)`
|
||||
- `subproblem::IndirectCommandBufferProblem::PipelineWithoutSupport`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_compute_pipeline_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_render_pipeline_state, 2 sites)`
|
||||
- `subproblem::IndirectCommandBufferProblem::InheritedPipelineState`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (pipeline_in, 2 sites)`
|
||||
- `subproblem::IndirectCommandBufferProblem::PipelineWithoutSupport`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (pipeline_in, 3 sites)`
|
||||
- `subproblem::IndirectCommandBufferProblem::CommandType`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_draw)`
|
||||
- `subproblem::IndirectCommandBufferProblem::CommandKind`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_draw)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_getter)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_kind)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (edit)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (reset)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_buffer)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_object_threadgroup_memory_length)`
|
||||
- `subproblem::IndirectCommandBufferProblem::CommandKind`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (buffer_in)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_draw)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_getter)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (check_kind)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (edit_in)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (pipeline_in)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (reset)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_object_threadgroup_memory_length)`
|
||||
- `subproblem::IndirectCommandBufferProblem::RenderState`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (render_state)`
|
||||
- `subproblem::IndirectCommandBufferProblem::ObjectThreadgroupMemory`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_object_threadgroup_memory_length)`
|
||||
- `subproblem::IndirectCommandBufferProblem::PipelineKind`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (set_render_pipeline_state)`
|
||||
- `subproblem::IndirectCommandBufferProblem::PipelineKind`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (pipeline_in)`
|
||||
- `subproblem::RateMapProblem::ScreenSize`: `crates/metal2vulkan-runtime/src/rate_map.rs (validate)`
|
||||
- `subproblem::RateMapProblem::LayerCount`: `crates/metal2vulkan-runtime/src/rate_map.rs (reset)`; `crates/metal2vulkan-runtime/src/rate_map.rs (validate)`
|
||||
- `subproblem::RateMapProblem::NoLayers`: `crates/metal2vulkan-runtime/src/rate_map.rs (map_physical_to_screen_coordinates)`; `crates/metal2vulkan-runtime/src/rate_map.rs (map_screen_to_physical_coordinates)`
|
||||
|
||||
Reference in new issue
Block a user