Emulated meshes go: a device without VK_EXT_mesh_shader refuses mesh and object functions
The planner's ruling: a mesh render pipeline is native or refused. With VK_EXT_mesh_shader and
meshShader (taskShader for an object function), the stages are task and mesh shaders, as before.
The emulation was a second form for devices without them: the object and mesh functions ran as
compute entries, which wrote each threadgroup's vertices and primitives as records into a
per-draw buffer or the command buffer's records pool, and a synthesized vertex stage drew those
records. The runtime never takes that path. Now a mesh or object function on such a device is
refused at lowering (Unsupported{MeshShading}, needing VK_EXT_mesh_shader and the stage's feature
where the profile lacks them), and so is its pipeline. The command line compiles no mesh pipeline
and answers FALLBACK for a mesh or object function on every device, as before.
Removed:
- lowering: lower/mesh/work.rs (the work buffer layout), lower::mesh::emulates, the emulated
compute entries and their wrappers, the record stores, Layout/layout/records/emulated_payload,
the RECORDS/WORK/OBJECT_* slots; MeshPlan's emulated and payload_words. Also dispatch.rs's
WrapperGroups and the wrapper_groups field, emit's GLCompute arm for meshes,
stage_io::flat_primitive_inputs, and the requirement trace's record writes. The payload is
always TaskPayloadWorkgroupEXT (memory::arena::declare_payload). lower::mesh::mesh_stages states
the native test that folds_object_grids reads. The mesh builtins are a const.
- pipeline: MeshRecords, RecordField, RecordValue; GraphicsState::mesh_records and mesh_corners;
StageInterface's mesh_records, mesh_corners and emulated_payload (vk_stage loses its COMPUTE
arm); the synthesized vertex stage (link::mesh keeps the payload check) and link's record
slots and push-range hull; SyntheticBinding::MeshRecords and MeshWork;
RuntimeFact::MeshLastFirst; VariantKey::mesh_last_first. Varyings hold mesh outputs to
maxMeshOutputComponents only. The link contract's compute-entry records check goes, and
compile/api's mesh_info reads the task and mesh limits only.
- binder: bind/mesh_scan (mesh_scan_module, mesh_object_arguments_module, MeshScanModule; its
div_ceil and for_range move to mesh_arguments, their one other reader), MeshDispatch,
MeshGroups, MeshRecordsRegion, DrawCommands::mesh_dispatch, MeshTemplate::records and
RecordsTemplate, GroupStage::Compute (GroupLimits.total is a plain u32), the emulated mesh
stage flags, BindState and BindShape's mesh_last_first, WriteSource::MeshRecords and MeshWork,
and DrawReplayRule::DispatchesFirst. Status: StatusBits::MESH_RECORDS_OVERFLOW,
StatusReport::mesh_records_overflow, MeshRecordsFault, and the words MeshRecordsCursor and
MeshFault{Draw,Objects,Groups}. The buffer keeps its 32 bytes, with SeqCstFences at word 7:
words 3 to 6 are not written, and bit 5 is unreported.
- runtime: the synthesized-stage test no longer reads mesh_records; the SynthesizedStages doc
loses "mesh records".
- tests: engine_mesh's emulated tests (the compute entries, the records pipeline and its object
draws, the last-first variant) are replaced by two refusal tests, one per function and one per
pipeline. The tests that also ran the emulating profiles run the profiles with the extension.
engine_mesh_barriers loses its interpreter run of the emulated object entries; the
round-trip, link and module-sweep fixtures and api_surface lose the rows.
- validation: build.rs's runtime inputs lose lower/mesh/work.rs; a companion test's comment.
The 15 authored mesh and object cases stay untouched. The authored compile census is
re-blessed on development.
Docs: API.md's mesh section states the refusal and loses the emulation's paragraphs, and two
lists lose "an emulated object or mesh function". Varyings docs lose a stale emulated
post-tessellation mention. docs/REFUSALS.md and api_signatures are regenerated. README and the
command's help name no mesh pipeline and need no change.
SEMANTICS_VERSION 2221 is in this commit (placeholder; main renumbers): what the translator emits
for a mesh or object function on a device without the extension changes (a refusal), and the
mesh draws' plans change. ARTIFACT_FORMAT_VERSION 565: the codec loses MeshRecords,
RecordField, RecordValue, StageInterface's three fields, GraphicsState's two, two
SyntheticBinding variants and RuntimeFact::MeshLastFirst. RUNTIME_VERSION stays at this series'
2543. The runtime pin is updated.
Consumer check (consumer-uses.sh, consumer development 12b87d3d6b, 70 refs):
MeshDispatch: 0 hits (code); link-order lists only.
MeshGroups, MeshRecordsRegion, mesh_scan_module, mesh_object_arguments_module, MeshScanModule,
MeshRecordsFault, mesh_dispatch, MESH_RECORDS_OVERFLOW, MeshRecordsCursor, MeshFaultDraw,
MeshFaultObjects, MeshFaultGroups, DispatchesFirst, mesh_last_first, MeshRecords, RecordValue,
mesh_records, mesh_corners, emulated_payload, MeshWork, MeshLastFirst, POOL_WORDS, DRAW_OFFSET,
DISPATCH_OFFSET: 0 hits (code).
mesh_records_overflow: 0 hits on development. It is used on consumer lane branches
(steelbrain/quiesce and others), but only as the name of a local function in
reims-vgpu-vulkan/src/gpu/command.rs, which answers the old runtime's
CommandBufferError::MeshRecordsOverflow. It does not read this field.
Verified: nothing yet (a check job is owed).
This commit is contained in:
1 parent
905ae8b57d
commit
f7279104ae
52 files changed
+357
-4929
No files matched your search
@@ -1327,7 +1327,7 @@ pub enum RenderPipelineKind {
|
||||
/// function that is not post-tessellation is ignored, as Metal ignores it.
|
||||
Tessellation,
|
||||
/// Stages the translator synthesizes beside the functions' but a tessellation's: geometry
|
||||
/// stages, lines drawn as bands of triangles, a rate map's fan-out, or mesh records.
|
||||
/// stages, lines drawn as bands of triangles, or a rate map's fan-out.
|
||||
SynthesizedStages,
|
||||
/// A fragment function that reaches the render pass's imageblock.
|
||||
Imageblock,
|
||||
|
||||
@@ -663,7 +663,6 @@ fn unbuilt(pipeline: &RenderPipeline, enabled: &EnabledCaps) -> Option<RenderPip
|
||||
};
|
||||
let synthesized = g.line_band.is_some()
|
||||
|| g.region_fan_out.is_some()
|
||||
|| g.mesh_records.is_some()
|
||||
|| (pipeline.stages.iter()).any(|stage| !stages.contains(&stage.stage));
|
||||
let unenabled = !(requirements.features).is_subset(&enabled.features)
|
||||
|| !(requirements.extensions).is_subset(&enabled.extensions);
|
||||
|
||||
@@ -122,8 +122,7 @@ fn main() {
|
||||
// `metal2vulkan-air/src/canon` formats), root tables, handles and the threadgroup regions'
|
||||
// alignment (`src/memory`), the dispatch-region encoding (`src/lower/dispatch.rs`, and the
|
||||
// used-parameter walk it reads, `src/lower/users.rs`), the shader-side stencil's shadow format
|
||||
// and state word (`src/lower/fragment/stencil.rs`), an
|
||||
// emulated mesh draw's work buffer layout (`src/lower/mesh/work.rs`), a patch's factor bytes
|
||||
// and state word (`src/lower/fragment/stencil.rs`), a patch's factor bytes
|
||||
// (`src/lower/tessellation/factors.rs`),
|
||||
// the sRGB steps the ASTC and PVRTC decoders read (`src/lower/arith/srgb.rs`), the sRGB
|
||||
// encode the YCbCr write takes from `air.pack`'s lowering (`src/lower/arith/pack.rs`), the blend color an
|
||||
@@ -168,7 +167,6 @@ fn main() {
|
||||
"metal2vulkan/src/lower/arith/extended_range/blend_color.rs",
|
||||
"metal2vulkan/src/lower/arith/pack.rs",
|
||||
"metal2vulkan/src/lower/arith/srgb.rs",
|
||||
"metal2vulkan/src/lower/mesh/work.rs",
|
||||
"metal2vulkan/src/lower/tessellation/factors.rs",
|
||||
"metal2vulkan/src/memory/arena.rs",
|
||||
"metal2vulkan/src/memory/handles.rs",
|
||||
|
||||
@@ -1 +1 @@
|
||||
d52d999780f8aa1837847ec3c62eb56540e766bbedf58d989c60d53a95f94e52
|
||||
8e8b7862a25effbb1f60354e4b30d1e4eab06e81b6922f9d83c85ee89e8e9c23
|
||||
@@ -988,8 +988,7 @@ fn generated_companions_link_with_their_cases_in_the_engine() {
|
||||
let linked = device
|
||||
.compile_mesh_pipeline(&descriptor, &metal2vulkan::Budget::standard())
|
||||
.unwrap();
|
||||
// The object, mesh and fragment stages (with the mesh emulation's, where the device has no
|
||||
// mesh shaders).
|
||||
// The object, mesh and fragment stages.
|
||||
assert!(linked.stages.len() >= 3, "{}", linked.stages.len());
|
||||
|
||||
// The payload object under the mesh function that reads its payload, and that mesh
|
||||
|
||||
@@ -129,10 +129,7 @@
|
||||
//! - **Rotated weights**. A draw of triangles drawn with Metal's last vertex first
|
||||
//! (`BindShape::rotated_weights`) of a pipeline whose fragment function reads
|
||||
//! `[[barycentric_coord]]` runs the variant that takes Metal's weights back from the drawn
|
||||
//! triangle's (`VariantKey::rotated_weights`, `LoweringInputs::rotated_weights`). A mesh draw
|
||||
//! drawn from each primitive's last index first (`BindShape::mesh_last_first`) of an emulated
|
||||
//! mesh function's pipeline of lines or triangles runs the variant whose synthesized vertex
|
||||
//! stage reads its corners so (`VariantKey::mesh_last_first`).
|
||||
//! triangle's (`VariantKey::rotated_weights`, `LoweringInputs::rotated_weights`).
|
||||
//! - **Tested storage writes**. A fragment function that stores a color through the interlocked
|
||||
//! storage form and declares no early tests only because it discards
|
||||
//! (`RuntimeFact::TestedStorageWrites`), in a pipeline with a depth or stencil attachment, stores
|
||||
@@ -272,29 +269,6 @@
|
||||
//! offset where the mesh function chooses its slice, is not implemented: the mesh function does
|
||||
//! not add it. A mesh pipeline draws with an amplification count of 1 (its
|
||||
//! `maxVertexAmplificationCount`).
|
||||
//!
|
||||
//! An emulated mesh pipeline (`GraphicsState::mesh_records`) is different in these ways:
|
||||
//! - Its object and mesh functions are `COMPUTE` stages, the object function's first, and
|
||||
//! their threadgroups are held to the compute limits, as is the object function's grid.
|
||||
//! - Each draw's compute work is `DrawCommands::mesh_dispatch` (`MeshDispatch` states the
|
||||
//! consumer contract), over a work buffer of the draw's own. A direct draw of `G` mesh
|
||||
//! threadgroups without an object function is the host's: its dispatch is `G` folded into
|
||||
//! rows of `maxComputeWorkGroupCount[0]`, its records hold `G · group_words` words (at
|
||||
//! least 16 bytes; past `maxStorageBufferRange` refused, naming it), and its draw is a
|
||||
//! `Draw` of `G · NP · k` vertices. A direct draw with an object function, and an indirect
|
||||
//! draw without one, are scanned on the GPU (`MeshScanModule`): the mesh dispatch and the
|
||||
//! draw are indirect from the work buffer, and the records lie in the command buffer's
|
||||
//! records pool, where a draw that does not fit draws nothing and fails the command buffer
|
||||
//! (`StatusReport::mesh_records_overflow`). Neither asks for its arguments on the CPU.
|
||||
//! - An indirect draw of a pipeline with an object function, whose object threadgroups only the
|
||||
//! GPU knows, runs an object arguments pass first (`mesh_object_arguments_module`,
|
||||
//! `MeshDispatch::object_arguments`): it reads Metal's arguments, reserves the object
|
||||
//! threadgroups' slots and offsets in the records pool (`lower::mesh::work::SLOTS`), and
|
||||
//! writes the object dispatch, which reads its counts from the work buffer; then the scan as
|
||||
//! above. Every threadgroup of a grid whose threads per grid wrap runs, reporting the wrapped
|
||||
//! grid as Metal's (`lower::dispatch`'s object grid). A grid Metal's GPU discards, one past the
|
||||
//! compute limits, and one whose slots the pool cannot hold draw nothing and say so in the
|
||||
//! command buffer's `ExecutionStatus`.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -321,9 +295,8 @@ use crate::bind::plan::slots::{
|
||||
use crate::bind::plan::{
|
||||
AccessClass, BindingPlan, BoundKind, ByteRange, DescriptorWrite, FactorTemplate, FieldLocation,
|
||||
GraphicsTemplate, GroupLimits, GroupStage, MeshTemplate, PlannedVertexBuffer,
|
||||
PushFieldPlacement, PushTemplate, RecordsTemplate, ResourceUse, ShaderTestsTemplate,
|
||||
ShadowTemplate, StageTemplate, StrideRules, UseTarget, VertexBufferBind, ViewSetup,
|
||||
WriteSource,
|
||||
PushFieldPlacement, PushTemplate, ResourceUse, ShaderTestsTemplate, ShadowTemplate,
|
||||
StageTemplate, StrideRules, UseTarget, VertexBufferBind, ViewSetup, WriteSource,
|
||||
};
|
||||
use crate::bind::resident::{stage_root_table, table_entries};
|
||||
use crate::bind::state::{
|
||||
@@ -508,10 +481,6 @@ pub struct DrawCommands {
|
||||
/// (`SpecKey::ObjectLocalSize`, `ObjectFlatLocalSize`, `ObjectMultiRegion`). The consumer creates the draw's
|
||||
/// `VkPipeline` with it. `None` for every other draw, whose pipeline takes the plan's.
|
||||
pub specialization: Option<SpecializationKey>,
|
||||
/// A mesh draw of an emulated mesh function's pipeline (`GraphicsState::mesh_records`): the
|
||||
/// compute dispatch that runs its mesh threadgroups before `draw` draws their primitives
|
||||
/// ([`MeshDispatch`] states the consumer contract). `None` for every other draw.
|
||||
pub mesh_dispatch: Option<MeshDispatch>,
|
||||
/// An indirect mesh draw on a device with `VK_EXT_mesh_shader`, whose first stage's group
|
||||
/// counts `vkCmdDrawMeshTasksIndirectEXT` requires within the device's limits: the form of the
|
||||
/// arguments pass the consumer records before the draw ([`MeshArguments`], which it makes with
|
||||
@@ -574,130 +543,10 @@ impl Default for DrawCommands {
|
||||
discards_command_buffer: false,
|
||||
amplifications: Vec::new(),
|
||||
specialization: None,
|
||||
mesh_dispatch: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The compute work of a mesh draw whose mesh function is emulated: its object threadgroups, where
|
||||
/// the pipeline has an object function, set the mesh grids they launch; its mesh threadgroups write
|
||||
/// their vertices and primitives to records, from which the pipeline's synthesized vertex stage
|
||||
/// draws them.
|
||||
///
|
||||
/// The draw's **work buffer** (`SyntheticBinding::MeshWork`) is the region of
|
||||
/// [`work_bytes`](Self::work_bytes) that every step of the draw binds whole: its first words are
|
||||
/// [`work`](Self::work), the rest zero. Its header holds the draw's object threadgroups and its
|
||||
/// mesh threadgroups, where its records begin, the mesh dispatch's arguments
|
||||
/// ([`DISPATCH_OFFSET`](Self::DISPATCH_OFFSET)) and the draw's ([`DRAW_OFFSET`](Self::DRAW_OFFSET));
|
||||
/// then each object threadgroup's slot (the grid it set and its payload) and each one's first
|
||||
/// mesh threadgroup.
|
||||
///
|
||||
/// The consumer, outside the render pass instance the draw records into, and after every command
|
||||
/// of the pass that writes what the object or mesh function reads or reads what they write:
|
||||
///
|
||||
/// - makes the work buffer and the records ([`records`](Self::records)), and writes them to the
|
||||
/// plan's `WriteSource::MeshWork` and `WriteSource::MeshRecords` bindings of the draw's set 0;
|
||||
/// for records in the command buffer's pool it writes the pool's words at word
|
||||
/// [`POOL_WORDS`](Self::POOL_WORDS) of the work buffer, and, for any draw, its number for the
|
||||
/// draw at word [`DRAW_ID`](Self::DRAW_ID), which a records fault reports
|
||||
/// (`StatusReport::mesh_records_overflow`);
|
||||
/// - creates a compute pipeline of each of the pipeline's `COMPUTE` modules (the object
|
||||
/// function's first, where it has one), under the pipeline's layout and the draw's
|
||||
/// `DrawCommands::specialization`;
|
||||
/// - for an indirect draw with an object function ([`object_arguments`](Self::object_arguments)),
|
||||
/// dispatches [`mesh_object_arguments_module`](crate::bind::mesh_object_arguments_module) (one
|
||||
/// workgroup) under the scan's bindings first: it reads Metal's arguments, reserves the draw's
|
||||
/// slots and offsets in the records pool, and writes the object dispatch's
|
||||
/// `VkDispatchIndirectCommand` in the work buffer;
|
||||
/// - with an object function, binds its pipeline and the draw's sets at the compute bind point,
|
||||
/// records the push writes whose stages are `COMPUTE`, and `vkCmdDispatch` of
|
||||
/// [`object_groups`](Self::object_groups), or, for an indirect draw, `vkCmdDispatchIndirect`
|
||||
/// from the work buffer where the object arguments pass wrote it;
|
||||
/// - for [`MeshGroups::Scanned`], dispatches [`MeshScanModule`](crate::bind::MeshScanModule)
|
||||
/// (one workgroup) over the work buffer, the command buffer's `ExecutionStatus` buffer, the
|
||||
/// arguments the variant names and the records;
|
||||
/// - binds the mesh function's pipeline and the draw's sets, records the push writes whose
|
||||
/// stages are `COMPUTE`, and dispatches its threadgroups: `vkCmdDispatch` of
|
||||
/// [`MeshGroups::Direct`]'s counts (nothing where one is 0), or `vkCmdDispatchIndirect` from
|
||||
/// the work buffer at [`DISPATCH_OFFSET`](Self::DISPATCH_OFFSET);
|
||||
/// - between the steps, orders each one's writes before the next one's reads (a barrier from
|
||||
/// compute shader writes to compute shader and indirect command reads), and after the last,
|
||||
/// before the draw's vertex stage and indirect command reads; then records `DrawCommands::draw`
|
||||
/// in the render pass instance as any draw, its indirect buffer (`DrawIndirect`, for
|
||||
/// [`MeshGroups::Scanned`]) the work buffer.
|
||||
///
|
||||
/// The object and mesh functions' resource uses are compute-stage uses (`ResourceUse`'s
|
||||
/// stages).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct MeshDispatch {
|
||||
/// The work buffer's first words; its other words are zero.
|
||||
pub work: Vec<u32>,
|
||||
/// The work buffer's bytes, at least 16.
|
||||
pub work_bytes: u64,
|
||||
/// The object function's threadgroups, the object dispatch's group counts; `None` for a
|
||||
/// pipeline without an object function, and for an indirect draw with one.
|
||||
pub object_groups: Option<[u32; 3]>,
|
||||
/// An indirect draw with an object function: the range of the Metal indirect buffer its
|
||||
/// object arguments pass binds at `MeshScanModule::ARGUMENTS_BINDING`, from the arguments'
|
||||
/// offset aligned down to `minStorageBufferOffsetAlignment` through their 12 bytes (the work
|
||||
/// buffer's `OBJECT_ARGUMENTS` word names where they begin). `None` for any other draw.
|
||||
pub object_arguments: Option<BufferRange>,
|
||||
/// The mesh threadgroups.
|
||||
pub mesh: MeshGroups,
|
||||
/// The records.
|
||||
pub records: MeshRecordsRegion,
|
||||
}
|
||||
|
||||
impl MeshDispatch {
|
||||
/// The work buffer's word where the consumer writes its records pool's words, for
|
||||
/// [`MeshRecordsRegion::Pool`].
|
||||
pub const POOL_WORDS: usize = crate::lower::mesh::work::POOL_WORDS as usize;
|
||||
/// The work buffer's word where the consumer writes its number for the draw.
|
||||
pub const DRAW_ID: usize = crate::lower::mesh::work::DRAW_ID as usize;
|
||||
/// The byte of the work buffer where the mesh dispatch's `VkDispatchIndirectCommand` lies.
|
||||
pub const DISPATCH_OFFSET: u64 = 4 * crate::lower::mesh::work::DISPATCH as u64;
|
||||
/// The byte of the work buffer where the draw's `VkDrawIndirectCommand` lies.
|
||||
pub const DRAW_OFFSET: u64 = 4 * crate::lower::mesh::work::DRAW as u64;
|
||||
}
|
||||
|
||||
/// Where an emulated mesh draw's mesh threadgroups come from ([`MeshDispatch`]).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum MeshGroups {
|
||||
/// The host knows them (a direct draw without an object function): the dispatch's group
|
||||
/// counts, the draw's threadgroups folded into rows of `maxComputeWorkGroupCount[0]`. The
|
||||
/// work buffer is complete, and the draw is a `Draw`.
|
||||
Direct([u32; 3]),
|
||||
/// The scan writes them (a draw with an object function, or an indirect draw): the mesh
|
||||
/// dispatch is indirect, and the draw a `DrawIndirect`, both from the work buffer.
|
||||
Scanned {
|
||||
/// The range of the Metal indirect buffer the scan binds at
|
||||
/// `MeshScanModule::ARGUMENTS_BINDING`, for an indirect draw: from the arguments' offset
|
||||
/// aligned down to `minStorageBufferOffsetAlignment` through their 12 bytes. `None` for
|
||||
/// any other draw, whose scan reads no argument (any 4 bytes bind there).
|
||||
arguments: Option<BufferRange>,
|
||||
},
|
||||
}
|
||||
|
||||
/// The records of an emulated mesh draw ([`MeshDispatch`]), which its mesh dispatch and its draw
|
||||
/// bind whole.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum MeshRecordsRegion {
|
||||
/// A region of the draw's own of this many bytes (at least 16), for
|
||||
/// [`MeshGroups::Direct`].
|
||||
Exact(u64),
|
||||
/// The command buffer's records pool, for [`MeshGroups::Scanned`]: storage of the
|
||||
/// consumer's size (its budget for the command buffer's emulated mesh draws, within
|
||||
/// `maxStorageBufferRange`), which the scans reserve from front to back
|
||||
/// (`StatusWord::MeshRecordsCursor`). Its words need no initial value.
|
||||
Pool,
|
||||
}
|
||||
|
||||
/// How a direct indexed draw treats its index positions past the index buffer: the positions whose
|
||||
/// bytes do not lie wholly before where Metal's fetch stops reading it
|
||||
/// ([`IndexBufferRef::fetch_end`], the length rounded up to 4 bytes). Metal's API validation
|
||||
@@ -742,38 +591,29 @@ impl RenderPipeline {
|
||||
/// a Metal function, with its Vulkan stage: a tessellation pipeline's (`tessellated`) synthesized
|
||||
/// vertex and control stages run none, and its post-tessellation vertex function is its
|
||||
/// evaluation stage; a mesh render pipeline's object and mesh functions are its task and mesh
|
||||
/// stages, and an emulated pipeline's (`emulated`) are its compute stages, the object function's
|
||||
/// first where it has one, and its synthesized vertex stage runs none; the geometry stages link
|
||||
/// stages; the geometry stages link
|
||||
/// generates (`link::geometry`: barycentric weights read as varyings, a selected slice or
|
||||
/// viewport) run none and bind nothing, nor do a band variant's (`banded`) control and evaluation
|
||||
/// stages (`link::band`).
|
||||
fn metal_stages(
|
||||
stages: impl ExactSizeIterator<Item = vk::ShaderStage>,
|
||||
(tessellated, banded): (bool, bool),
|
||||
emulated: bool,
|
||||
) -> Result<Vec<(Stage, vk::ShaderStage)>, BindError> {
|
||||
let stages: Vec<vk::ShaderStage> = stages.collect();
|
||||
let mut out = Vec::with_capacity(stages.len());
|
||||
for (i, &s) in stages.iter().enumerate() {
|
||||
let compute = s == vk::ShaderStage::COMPUTE && emulated;
|
||||
let object_first = compute && stages.get(i + 1) == Some(&vk::ShaderStage::COMPUTE);
|
||||
for s in stages {
|
||||
let stage = if s == vk::ShaderStage::FRAGMENT {
|
||||
Stage::Fragment
|
||||
} else if object_first {
|
||||
Stage::Object
|
||||
} else if s == vk::ShaderStage::MESH_EXT || compute {
|
||||
} else if s == vk::ShaderStage::MESH_EXT {
|
||||
Stage::Mesh
|
||||
} else if s == vk::ShaderStage::TASK_EXT {
|
||||
Stage::Object
|
||||
} else if s == vk::ShaderStage::VERTEX && emulated {
|
||||
continue;
|
||||
} else if s == vk::ShaderStage::VERTEX && !tessellated
|
||||
|| s == vk::ShaderStage::TESSELLATION_EVALUATION && tessellated
|
||||
{
|
||||
Stage::Vertex
|
||||
} else if tessellated
|
||||
&& (s == vk::ShaderStage::VERTEX || s == vk::ShaderStage::TESSELLATION_CONTROL)
|
||||
|| s == vk::ShaderStage::GEOMETRY && !emulated
|
||||
|| s == vk::ShaderStage::GEOMETRY
|
||||
|| banded
|
||||
&& (s == vk::ShaderStage::TESSELLATION_CONTROL
|
||||
|| s == vk::ShaderStage::TESSELLATION_EVALUATION)
|
||||
@@ -789,15 +629,10 @@ fn metal_stages(
|
||||
|
||||
/// Whether a module of mesh render pipeline `p` other than its object function's declares
|
||||
/// threadgroup memory arguments (`SpecKey::TgLength`): a mesh function's, whose lengths no encoder
|
||||
/// setter sets. The object module is the task stage, or, `emulated`, the first of the two compute
|
||||
/// stages, as [`metal_stages`] names them.
|
||||
fn other_stage_lengths(p: &RenderPipeline, emulated: bool) -> bool {
|
||||
p.stages.iter().enumerate().any(|(i, m)| {
|
||||
let object = m.stage == vk::ShaderStage::TASK_EXT
|
||||
|| emulated
|
||||
&& m.stage == vk::ShaderStage::COMPUTE
|
||||
&& p.stages.get(i + 1).map(|n| n.stage) == Some(vk::ShaderStage::COMPUTE);
|
||||
!object
|
||||
/// setter sets. The object module is the task stage, as [`metal_stages`] names it.
|
||||
fn other_stage_lengths(p: &RenderPipeline) -> bool {
|
||||
p.stages.iter().any(|m| {
|
||||
m.stage != vk::ShaderStage::TASK_EXT
|
||||
&& m.specialization
|
||||
.constants
|
||||
.iter()
|
||||
@@ -832,15 +667,6 @@ fn tessellated_pipeline_stage(stage: Stage) -> vk::PipelineStageFlags2 {
|
||||
}
|
||||
}
|
||||
|
||||
/// [`pipeline_stage`] of an emulated mesh function's pipeline, whose object and mesh functions
|
||||
/// run in the draw's compute dispatches.
|
||||
fn emulated_mesh_pipeline_stage(stage: Stage) -> vk::PipelineStageFlags2 {
|
||||
match stage {
|
||||
Stage::Object | Stage::Mesh => vk::PipelineStageFlags2::COMPUTE_SHADER,
|
||||
other => pipeline_stage(other),
|
||||
}
|
||||
}
|
||||
|
||||
/// How a plan draws the shape's vertex amplification.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
enum Route {
|
||||
@@ -934,7 +760,6 @@ fn stores(a: crate::pipeline::graphics::ColorAttachmentState) -> bool {
|
||||
|
||||
fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<BindingPlan, BindError> {
|
||||
check_slots(shape)?;
|
||||
let records = p.graphics.mesh_records.as_ref();
|
||||
let tessellation = p.graphics.tessellation.is_some();
|
||||
let modules = metal_stages(
|
||||
p.stages.iter().map(|m| m.stage),
|
||||
@@ -942,7 +767,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
p.graphics.tessellation.is_some(),
|
||||
p.graphics.line_band.is_some(),
|
||||
),
|
||||
records.is_some(),
|
||||
)?;
|
||||
let stages: Vec<Stage> = modules.iter().map(|(stage, _)| *stage).collect();
|
||||
// A mesh render pipeline (`Device::compile_mesh_pipeline`) is drawn by mesh draws.
|
||||
@@ -1245,7 +1069,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
&& p.graphics.tessellation.is_none()
|
||||
&& shadow.is_none()
|
||||
&& tile_memory.is_none()
|
||||
&& records.is_none()
|
||||
&& !mesh
|
||||
&& interlocked_colors.is_empty()
|
||||
&& extended_shadows.is_empty()
|
||||
@@ -1296,18 +1119,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
.dependencies
|
||||
.iter()
|
||||
.any(|d| d.fact == RuntimeFact::RotatedWeights);
|
||||
// A mesh draw drawn from each primitive's last index first: the variant whose emulated
|
||||
// mesh pipeline's synthesized vertex stage reads its corners so. A pipeline of points, or
|
||||
// one whose mesh function is not emulated, has no order to change.
|
||||
let mesh_last_first = shape.mesh_last_first
|
||||
&& p.graphics
|
||||
.mesh_records
|
||||
.as_ref()
|
||||
.is_some_and(|r| r.corners > 1);
|
||||
let compiled_last_first = p
|
||||
.dependencies
|
||||
.iter()
|
||||
.any(|d| d.fact == RuntimeFact::MeshLastFirst);
|
||||
// A draw of lines, or of triangles' edges, as bands: the variant whose synthesized
|
||||
// tessellation stages draw them so, which its graphics state states.
|
||||
let line_band = shape.line_band;
|
||||
@@ -1451,15 +1262,9 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
.iter()
|
||||
.any(|d| matches!(d.fact, RuntimeFact::ShaderStencilTest { .. }));
|
||||
// A mesh entry's `Layer` at or past `maxMeshOutputLayers` is undefined: a pass of more layers
|
||||
// than that, which a mesh function choosing its slice could render into, is past the device. An
|
||||
// emulated mesh function's slice is its synthesized vertex stage's `Layer`, as a vertex
|
||||
// function's is.
|
||||
// than that, which a mesh function choosing its slice could render into, is past the device.
|
||||
let mesh_layers = limits.mesh.max_mesh_output_layers;
|
||||
if mesh
|
||||
&& records.is_none()
|
||||
&& vertex_layer.is_some()
|
||||
&& shape.render_target_array_length > mesh_layers
|
||||
{
|
||||
if mesh && vertex_layer.is_some() && shape.render_target_array_length > mesh_layers {
|
||||
return Err(BindError::Unsupported(Unsupported::needs(
|
||||
Feature::MeshShading,
|
||||
Capability::Limit {
|
||||
@@ -1476,12 +1281,10 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
.find(|(s, _)| *s == stage)
|
||||
.map_or_else(|| vk_stage(stage), |(_, m)| *m)
|
||||
};
|
||||
let stage_flags: fn(Stage) -> vk::PipelineStageFlags2 =
|
||||
match (&p.graphics.tessellation, records) {
|
||||
(Some(_), _) => tessellated_pipeline_stage,
|
||||
(None, Some(_)) => emulated_mesh_pipeline_stage,
|
||||
(None, None) => pipeline_stage,
|
||||
};
|
||||
let stage_flags: fn(Stage) -> vk::PipelineStageFlags2 = match &p.graphics.tessellation {
|
||||
Some(_) => tessellated_pipeline_stage,
|
||||
None => pipeline_stage,
|
||||
};
|
||||
let bindings = bindings(&p.layout);
|
||||
let stage_shape = |s: Stage| shape.stages.get(&s);
|
||||
|
||||
@@ -1883,9 +1686,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
control_point_index_binding = Some((set.set, b.binding));
|
||||
WriteSource::ControlPointIndices
|
||||
}
|
||||
// An emulated mesh function's records and work buffer, each draw's own.
|
||||
SyntheticBinding::MeshRecords if records.is_some() => WriteSource::MeshRecords,
|
||||
SyntheticBinding::MeshWork if records.is_some() => WriteSource::MeshWork,
|
||||
SyntheticBinding::HandleTable => {
|
||||
planner(&mut heap)?.table(stage, set.set, b.binding)?
|
||||
}
|
||||
@@ -2134,7 +1934,7 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
} => Some((static_bytes, payload)),
|
||||
_ => None,
|
||||
});
|
||||
if mesh && other_stage_lengths(p, records.is_some()) {
|
||||
if mesh && other_stage_lengths(p) {
|
||||
// A mesh function's arguments, whose lengths no Metal setter sets.
|
||||
return Err(not_implemented(Feature::MeshShading));
|
||||
}
|
||||
@@ -2211,32 +2011,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
fixed.iter().find(|(key, _)| *key == k).map(|(_, v)| *v)
|
||||
});
|
||||
let m = &limits.mesh;
|
||||
// An emulated mesh function's threadgroups are the draw's compute dispatch's.
|
||||
let mesh_limits = match records {
|
||||
Some(_) => GroupLimits {
|
||||
size: limits.max_compute_work_group_size,
|
||||
invocations: limits.max_compute_work_group_invocations,
|
||||
count: limits.max_compute_work_group_count,
|
||||
total: None,
|
||||
stage: GroupStage::Compute,
|
||||
},
|
||||
None => GroupLimits {
|
||||
size: m.max_mesh_work_group_size,
|
||||
invocations: m.max_mesh_work_group_invocations,
|
||||
count: m.max_mesh_work_group_count,
|
||||
total: Some(m.max_mesh_work_group_total_count),
|
||||
stage: GroupStage::Mesh,
|
||||
},
|
||||
};
|
||||
let records = records.map(|r| RecordsTemplate {
|
||||
group_words: r.group_words(),
|
||||
group_vertices: r.primitives.saturating_mul(r.corners),
|
||||
max_range: limits.max_storage_buffer_range,
|
||||
slot_words: r.slot_words,
|
||||
row: limits.max_compute_work_group_count[0],
|
||||
rows: limits.max_compute_work_group_count[1],
|
||||
alignment: limits.min_storage_buffer_offset_alignment,
|
||||
});
|
||||
let mesh = mesh.then(|| MeshTemplate {
|
||||
multiples: p
|
||||
.dependencies
|
||||
@@ -2248,23 +2022,19 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
.collect(),
|
||||
spec: layout,
|
||||
fixed,
|
||||
mesh: mesh_limits,
|
||||
// An emulated object function's threadgroups are a compute dispatch.
|
||||
object: stages.contains(&Stage::Object).then_some(match records {
|
||||
Some(_) => GroupLimits {
|
||||
size: limits.max_compute_work_group_size,
|
||||
invocations: limits.max_compute_work_group_invocations,
|
||||
count: limits.max_compute_work_group_count,
|
||||
total: None,
|
||||
stage: GroupStage::Compute,
|
||||
},
|
||||
None => GroupLimits {
|
||||
size: m.max_task_work_group_size,
|
||||
invocations: m.max_task_work_group_invocations,
|
||||
count: m.max_task_work_group_count,
|
||||
total: Some(m.max_task_work_group_total_count),
|
||||
stage: GroupStage::Task,
|
||||
},
|
||||
mesh: GroupLimits {
|
||||
size: m.max_mesh_work_group_size,
|
||||
invocations: m.max_mesh_work_group_invocations,
|
||||
count: m.max_mesh_work_group_count,
|
||||
total: m.max_mesh_work_group_total_count,
|
||||
stage: GroupStage::Mesh,
|
||||
},
|
||||
object: stages.contains(&Stage::Object).then_some(GroupLimits {
|
||||
size: m.max_task_work_group_size,
|
||||
invocations: m.max_task_work_group_invocations,
|
||||
count: m.max_task_work_group_count,
|
||||
total: m.max_task_work_group_total_count,
|
||||
stage: GroupStage::Task,
|
||||
}),
|
||||
folded: p
|
||||
.dependencies
|
||||
@@ -2274,7 +2044,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
.dependencies
|
||||
.iter()
|
||||
.any(|d| d.fact == RuntimeFact::PartialObjectThreadgroups),
|
||||
records,
|
||||
});
|
||||
|
||||
// Uses: bound buffer slots, vertex buffers, textures, attachments, used resources.
|
||||
@@ -2418,7 +2187,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
.retain(|slot| !variant.snapshot_textures.contains_key(slot));
|
||||
variant.depth_clamp_range = depth_clamp_range;
|
||||
variant.rotated_weights = rotated_weights;
|
||||
variant.mesh_last_first = mesh_last_first;
|
||||
variant.line_band = line_band;
|
||||
variant.read_only_tests = read_only_tests;
|
||||
variant.shader_tests = shader_tests;
|
||||
@@ -2460,7 +2228,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|
||||
|| other_colors
|
||||
|| compiled_range != depth_clamp_range
|
||||
|| compiled_rotated != rotated_weights
|
||||
|| compiled_last_first != mesh_last_first
|
||||
|| compiled_band != line_band
|
||||
|| compiled_tests != read_only_tests
|
||||
|| compiled_shader_tests != shader_tests
|
||||
@@ -2900,8 +2667,6 @@ struct MeshDraw {
|
||||
/// The object stage's region, of a pipeline with an object function.
|
||||
object_region: Option<[u8; 32]>,
|
||||
mesh_region: [u8; 32],
|
||||
/// An emulated mesh function's dispatch.
|
||||
dispatch: Option<MeshDispatch>,
|
||||
/// A direct draw's fold of its object grid, of a folded object function
|
||||
/// (`DrawCommands::object_fold`).
|
||||
fold: Option<ObjectFold>,
|
||||
@@ -2934,13 +2699,12 @@ fn mesh_limit(limit: VkLimit, required: u64, available: u32) -> BindError {
|
||||
}
|
||||
|
||||
/// The limits that name a stage's threadgroup and grid: the task stage's for an object
|
||||
/// function, the mesh stage's for a mesh function, and the compute stage's for an emulated mesh
|
||||
/// function, whose grid has no total limit.
|
||||
/// function and the mesh stage's for a mesh function.
|
||||
struct GroupLimitNames {
|
||||
size: fn(u8) -> VkLimit,
|
||||
invocations: VkLimit,
|
||||
count: fn(u8) -> VkLimit,
|
||||
total: Option<VkLimit>,
|
||||
total: VkLimit,
|
||||
}
|
||||
|
||||
impl GroupLimitNames {
|
||||
@@ -2950,19 +2714,13 @@ impl GroupLimitNames {
|
||||
size: VkLimit::MaxTaskWorkGroupSize,
|
||||
invocations: VkLimit::MaxTaskWorkGroupInvocations,
|
||||
count: VkLimit::MaxTaskWorkGroupCount,
|
||||
total: Some(VkLimit::MaxTaskWorkGroupTotalCount),
|
||||
total: VkLimit::MaxTaskWorkGroupTotalCount,
|
||||
},
|
||||
GroupStage::Mesh => GroupLimitNames {
|
||||
size: VkLimit::MaxMeshWorkGroupSize,
|
||||
invocations: VkLimit::MaxMeshWorkGroupInvocations,
|
||||
count: VkLimit::MaxMeshWorkGroupCount,
|
||||
total: Some(VkLimit::MaxMeshWorkGroupTotalCount),
|
||||
},
|
||||
GroupStage::Compute => GroupLimitNames {
|
||||
size: VkLimit::MaxComputeWorkGroupSize,
|
||||
invocations: VkLimit::MaxComputeWorkGroupInvocations,
|
||||
count: VkLimit::MaxComputeWorkGroupCount,
|
||||
total: None,
|
||||
total: VkLimit::MaxMeshWorkGroupTotalCount,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -3015,10 +2773,8 @@ fn check_grid(limits: &GroupLimits, g: [u32; 3]) -> Result<(), BindError> {
|
||||
));
|
||||
}
|
||||
let total: u64 = g.iter().map(|&x| u64::from(x)).product();
|
||||
if let (Some(available), Some(limit)) = (limits.total, names.total) {
|
||||
if total > u64::from(available) {
|
||||
return Err(mesh_limit(limit, total, available));
|
||||
}
|
||||
if total > u64::from(limits.total) {
|
||||
return Err(mesh_limit(names.total, total, limits.total));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -3163,24 +2919,13 @@ fn mesh_draw(
|
||||
if let Some(o) = &t.object {
|
||||
check_group(o, lo, flat(&object_keys), &t.multiples)?;
|
||||
}
|
||||
// An emulated mesh function's threadgroups are folded into rows, so its direct grid is
|
||||
// held to no axis limit.
|
||||
match (groups, t.object.as_ref(), &t.records) {
|
||||
(Some(_), Some(_), _) if folded => {}
|
||||
(Some(g), Some(o), _) => check_grid(o, g)?,
|
||||
(Some(g), None, None) => check_grid(&t.mesh, g)?,
|
||||
(Some(_), None, Some(_)) | (None, _, _) => {}
|
||||
match (groups, t.object.as_ref()) {
|
||||
(Some(_), Some(_)) if folded => {}
|
||||
(Some(g), Some(o)) => check_grid(o, g)?,
|
||||
(Some(g), None) => check_grid(&t.mesh, g)?,
|
||||
(None, _) => {}
|
||||
}
|
||||
}
|
||||
// An emulated mesh function's threadgroups are a compute dispatch, and their primitives a
|
||||
// draw of `NP · k` vertices each.
|
||||
let (command, dispatch) = match &t.records {
|
||||
None => (command, None),
|
||||
Some(r) => {
|
||||
let (command, dispatch) = emulated_draw(r, t.object.is_some(), draw, groups, launches)?;
|
||||
(command, Some(dispatch))
|
||||
}
|
||||
};
|
||||
let object = t.object.is_some();
|
||||
// A folded object function reads every grid builtin from its region record, and an unfolded
|
||||
// one whose wrapped grid leaves a partial threadgroup from its region (`MultiRegion` 1).
|
||||
@@ -3195,7 +2940,7 @@ fn mesh_draw(
|
||||
(true, Some(g), Some(o)) => {
|
||||
let task = MeshGridLimits {
|
||||
axes: o.count,
|
||||
total: o.total.unwrap_or(u32::MAX),
|
||||
total: o.total,
|
||||
};
|
||||
let g = if launches { g } else { [0; 3] };
|
||||
let fold = match asked.filter(|_| launches) {
|
||||
@@ -3268,198 +3013,11 @@ fn mesh_draw(
|
||||
specialization,
|
||||
object_region,
|
||||
mesh_region,
|
||||
dispatch,
|
||||
fold,
|
||||
discards,
|
||||
})
|
||||
}
|
||||
|
||||
/// The draw and the compute work of an emulated mesh draw `draw` under `r` ([`MeshDispatch`]),
|
||||
/// of a pipeline with an object function where `object`: `groups` are the first stage's
|
||||
/// threadgroups of a direct draw (`None` for an indirect one), `lo` the threads of an object
|
||||
/// threadgroup, and a draw that `launches` nothing runs nothing and draws nothing.
|
||||
///
|
||||
/// - A direct draw without an object function is the host's: `G` mesh threadgroups (refused as
|
||||
/// a group count where they pass a `u32`), their records exactly (`maxStorageBufferRange`,
|
||||
/// else `Unsupported{MeshShading}` naming it with the records' bytes), folded into rows of
|
||||
/// `maxComputeWorkGroupCount[0]` (the rows within `maxComputeWorkGroupCount[1]`, else
|
||||
/// refused naming it), and a draw of `G · NP · k` vertices (refused as a group count past a
|
||||
/// `u32`).
|
||||
/// - A direct draw with an object function dispatches its object threadgroups (`O`, whose
|
||||
/// work buffer must be bindable whole, else refused naming `maxStorageBufferRange` with its
|
||||
/// bytes), and an indirect draw without one reads Metal's arguments in the scan: both are
|
||||
/// scanned, their records in the command buffer's pool.
|
||||
/// - An indirect draw with an object function, of object threadgroups of `lo` threads, runs the
|
||||
/// object arguments pass first (`MeshDispatch::object_arguments`), which reads Metal's
|
||||
/// arguments, reserves the slots and offsets of its object threadgroups in the pool, and writes
|
||||
/// the object dispatch, which reads its counts from the work buffer; then the scan, as above.
|
||||
fn emulated_draw(
|
||||
r: &RecordsTemplate,
|
||||
object: bool,
|
||||
draw: &DrawCall,
|
||||
groups: Option<[u32; 3]>,
|
||||
launches: bool,
|
||||
) -> Result<(vk::DrawCommand, MeshDispatch), BindError> {
|
||||
use crate::lower::mesh::work;
|
||||
let group_vertices = r.group_vertices;
|
||||
let over_range = |bytes: u64| mesh_limit(VkLimit::MaxStorageBufferRange, bytes, r.max_range);
|
||||
let count_past = || {
|
||||
BindError::Unsupported(Unsupported::not_representable(Feature::GroupCount {
|
||||
axis: None,
|
||||
}))
|
||||
};
|
||||
let header = |objects: u32| {
|
||||
let mut w = vec![0u32; work::HEADER as usize];
|
||||
w[work::OBJECT_GROUPS as usize] = objects;
|
||||
w[work::SLOT_WORDS as usize] = r.slot_words;
|
||||
// Within a `u32`: link sizes a threadgroup's records so (`lower::mesh::layout`).
|
||||
w[work::GROUP_WORDS as usize] = r.group_words as u32;
|
||||
w[work::GROUP_VERTICES as usize] = group_vertices;
|
||||
w[work::ROW as usize] = r.row.max(1);
|
||||
w
|
||||
};
|
||||
let work_bytes = |objects: u64| -> Result<u64, BindError> {
|
||||
let bytes = work::words(objects, r.slot_words).saturating_mul(4);
|
||||
if bytes > u64::from(r.max_range) {
|
||||
return Err(over_range(bytes));
|
||||
}
|
||||
Ok(bytes)
|
||||
};
|
||||
// The range of Metal's arguments at `offset` a pass binds, from the offset aligned down to
|
||||
// `minStorageBufferOffsetAlignment`, and the arguments' byte in it.
|
||||
let arguments_range = |offset: u64| {
|
||||
let a = r.alignment.max(4);
|
||||
let start = offset - offset % a;
|
||||
let residual = offset - start;
|
||||
let range = BufferRange {
|
||||
offset: start,
|
||||
range: residual + 12,
|
||||
};
|
||||
(range, residual)
|
||||
};
|
||||
let scanned = |objects: u32, object_groups, arguments| -> Result<_, BindError> {
|
||||
let command = vk::DrawCommand::DrawIndirect {
|
||||
offset: MeshDispatch::DRAW_OFFSET,
|
||||
draw_count: 1,
|
||||
stride: 16,
|
||||
};
|
||||
let dispatch = MeshDispatch {
|
||||
work: header(objects),
|
||||
work_bytes: work_bytes(u64::from(objects))?,
|
||||
object_groups,
|
||||
object_arguments: None,
|
||||
mesh: MeshGroups::Scanned { arguments },
|
||||
records: MeshRecordsRegion::Pool,
|
||||
};
|
||||
Ok((command, dispatch))
|
||||
};
|
||||
match (object, groups.filter(|_| launches)) {
|
||||
// The host's draw of `G` mesh threadgroups.
|
||||
(false, Some(g)) => {
|
||||
let total: u64 = g.iter().map(|&x| u64::from(x)).product();
|
||||
let t = u32::try_from(total).map_err(|_| count_past())?;
|
||||
let bytes = total
|
||||
.saturating_mul(r.group_words)
|
||||
.saturating_mul(4)
|
||||
.max(MIN_RECORDS_BYTES);
|
||||
if bytes > u64::from(r.max_range) {
|
||||
return Err(over_range(bytes));
|
||||
}
|
||||
let vertices = t.checked_mul(group_vertices).ok_or_else(count_past)?;
|
||||
let row = r.row.max(1);
|
||||
let rows = t.div_ceil(row);
|
||||
if rows > r.rows {
|
||||
return Err(mesh_limit(
|
||||
VkLimit::MaxComputeWorkGroupCount(1),
|
||||
u64::from(rows),
|
||||
r.rows,
|
||||
));
|
||||
}
|
||||
let folded = [t.min(row), rows, 1];
|
||||
let mut w = header(1);
|
||||
w[work::MESH_GROUPS as usize] = t;
|
||||
w[work::DISPATCH as usize..][..3].copy_from_slice(&folded);
|
||||
w[work::DRAW as usize..][..4].copy_from_slice(&[vertices, 1, 0, 0]);
|
||||
// Slot 0: the grid, then a zero payload; then the offsets 0 and `T`.
|
||||
w.extend(g);
|
||||
w.extend(std::iter::repeat_n(
|
||||
0,
|
||||
r.slot_words.saturating_sub(3) as usize,
|
||||
));
|
||||
w.extend([0, t]);
|
||||
let command = vk::DrawCommand::Draw {
|
||||
vertex_count: vertices,
|
||||
instance_count: 1,
|
||||
first_vertex: 0,
|
||||
first_instance: 0,
|
||||
};
|
||||
let dispatch = MeshDispatch {
|
||||
work: w,
|
||||
work_bytes: work_bytes(1)?,
|
||||
object_groups: None,
|
||||
object_arguments: None,
|
||||
mesh: MeshGroups::Direct(folded),
|
||||
records: MeshRecordsRegion::Exact(bytes),
|
||||
};
|
||||
Ok((command, dispatch))
|
||||
}
|
||||
// The object threadgroups set the mesh grids: scanned.
|
||||
(true, Some(g)) => {
|
||||
let objects: u64 = g.iter().map(|&x| u64::from(x)).product();
|
||||
let objects = u32::try_from(objects).map_err(|_| count_past())?;
|
||||
scanned(objects, Some(g), None)
|
||||
}
|
||||
// Metal's arguments are the mesh grid: scanned from them.
|
||||
(false, None) if launches => {
|
||||
let DrawCall::MeshThreadgroupsIndirect { indirect, .. } = *draw else {
|
||||
return Err(internal(format!("an indirect mesh draw of {draw:?}")));
|
||||
};
|
||||
let (range, residual) = arguments_range(indirect.offset);
|
||||
let mut out = scanned(1, None, Some(range))?;
|
||||
let word = u32::try_from(residual / 4 + 1).map_err(|_| count_past())?;
|
||||
out.1.work[work::ARGUMENTS as usize] = word;
|
||||
Ok(out)
|
||||
}
|
||||
// Metal's arguments are the object grid: the object arguments pass reads them, reserves
|
||||
// the slots in the pool and writes the object dispatch; then the scan.
|
||||
(true, None) if launches => {
|
||||
let DrawCall::MeshThreadgroupsIndirect { indirect, .. } = *draw else {
|
||||
return Err(internal(format!("an indirect mesh draw of {draw:?}")));
|
||||
};
|
||||
let range = arguments_range(indirect.offset);
|
||||
let mut out = scanned(0, None, None)?;
|
||||
let word = u32::try_from(range.1 / 4 + 1).map_err(|_| count_past())?;
|
||||
out.1.work[work::OBJECT_ARGUMENTS as usize] = word;
|
||||
out.1.object_arguments = Some(range.0);
|
||||
Ok(out)
|
||||
}
|
||||
// A draw that launches nothing: no step runs, and nothing is drawn.
|
||||
(_, _) => {
|
||||
let command = vk::DrawCommand::Draw {
|
||||
vertex_count: 0,
|
||||
instance_count: 1,
|
||||
first_vertex: 0,
|
||||
first_instance: 0,
|
||||
};
|
||||
let mut w = header(1);
|
||||
w.extend(std::iter::repeat_n(0, r.slot_words as usize + 2));
|
||||
let dispatch = MeshDispatch {
|
||||
work: w,
|
||||
work_bytes: work_bytes(1)?,
|
||||
object_groups: None,
|
||||
object_arguments: None,
|
||||
mesh: MeshGroups::Direct([0; 3]),
|
||||
records: MeshRecordsRegion::Exact(MIN_RECORDS_BYTES),
|
||||
};
|
||||
Ok((command, dispatch))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The fewest bytes of an emulated mesh function's records: a draw of no threadgroup still binds
|
||||
/// them (the smallest binding).
|
||||
const MIN_RECORDS_BYTES: u64 = 16;
|
||||
|
||||
/// What a patch draw of `p` instantiates ([`FactorTemplate`]), from the layout's factor, patch
|
||||
/// index and control-point index bindings and the device's `(minStorageBufferOffsetAlignment,
|
||||
/// maxStorageBufferRange)`: `None` for a pipeline that draws no patches. The control stage binds
|
||||
@@ -4042,7 +3600,6 @@ fn instantiate(
|
||||
index_bounds_pass,
|
||||
amplifications: amplifications_out,
|
||||
specialization: specialization_out,
|
||||
mesh_dispatch: mesh_dispatch_out,
|
||||
mesh_arguments: mesh_arguments_out,
|
||||
object_fold: object_fold_out,
|
||||
discards_command_buffer: discards_out,
|
||||
@@ -4367,10 +3924,7 @@ fn instantiate(
|
||||
};
|
||||
let index_unbounded = indirect_indices_unbounded(t.robust_index_fetch, draw);
|
||||
let amplifications = amplification_writes(t)?;
|
||||
let (mesh_dispatch, specialization) = match mesh {
|
||||
Some(m) => (m.dispatch, Some(m.specialization)),
|
||||
None => (None, None),
|
||||
};
|
||||
let specialization = mesh.map(|m| m.specialization);
|
||||
// The de-indexed form reads its indices in the vertex stage, by address, and binds no index
|
||||
// buffer.
|
||||
uses.clear();
|
||||
@@ -4378,12 +3932,8 @@ fn instantiate(
|
||||
Some(indices) => uses.push(indices),
|
||||
None => draw_uses(uses, draw, overrun, t.tessellation.as_ref()),
|
||||
}
|
||||
// An indirect mesh draw's arguments pass, or an emulated one's scan or object arguments pass,
|
||||
// reads Metal's 12 bytes in the compute stage.
|
||||
let scanned = mesh_dispatch.as_ref().is_some_and(|d| {
|
||||
matches!(d.mesh, MeshGroups::Scanned { arguments: Some(_) }) || d.object_arguments.is_some()
|
||||
});
|
||||
if scanned || mesh_arguments.is_some() {
|
||||
// An indirect mesh draw's arguments pass reads Metal's 12 bytes in the compute stage.
|
||||
if mesh_arguments.is_some() {
|
||||
uses.push(ResourceUse {
|
||||
resource: UseTarget::Indirect,
|
||||
access: AccessSet::READ,
|
||||
@@ -4400,7 +3950,6 @@ fn instantiate(
|
||||
*draw_command = command;
|
||||
*overrun_out = overrun;
|
||||
*amplifications_out = amplifications;
|
||||
*mesh_dispatch_out = mesh_dispatch;
|
||||
*specialization_out = specialization;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1501,13 +1501,12 @@ fn mesh_template(flat: bool, multiples: Vec<u32>) -> GraphicsTemplate {
|
||||
size: [256; 3],
|
||||
invocations: 256,
|
||||
count: [65535; 3],
|
||||
total: Some(1 << 22),
|
||||
total: 1 << 22,
|
||||
stage: GroupStage::Mesh,
|
||||
},
|
||||
object: None,
|
||||
folded: false,
|
||||
partial_groups: false,
|
||||
records: None,
|
||||
}),
|
||||
shader_tests: None,
|
||||
deindexed: None,
|
||||
@@ -1566,7 +1565,7 @@ fn object_template() -> GraphicsTemplate {
|
||||
size: [128; 3],
|
||||
invocations: 128,
|
||||
count: [65535; 3],
|
||||
total: Some(1 << 22),
|
||||
total: 1 << 22,
|
||||
stage: crate::bind::plan::GroupStage::Task,
|
||||
});
|
||||
t
|
||||
|
||||
@@ -94,7 +94,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind::instantiate::{BufferRange, IndirectRef};
|
||||
use crate::bind::mesh_scan::{div_ceil, for_range};
|
||||
use crate::bind::replay::checked_mul;
|
||||
use crate::bind::status::{StatusBits, StatusWord};
|
||||
use crate::budget::{Budget, Meter};
|
||||
@@ -104,7 +103,7 @@ use crate::error::{Error, InternalError, InternalKind};
|
||||
use crate::pipeline::sym::{
|
||||
PushField, ResourceKind, ResourceSlot, SlotClass, SlotRef, Stage, Symbol, SyntheticBinding,
|
||||
};
|
||||
use crate::spirv::builder::constructs::{ArmEnd, ArmFn};
|
||||
use crate::spirv::builder::constructs::{ArmEnd, ArmFn, LoopFn, LoopSpec};
|
||||
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{GlobalId, TypeId, Value};
|
||||
@@ -501,6 +500,43 @@ fn u32_value(f: &mut FunctionBuilder<'_>, v: u32) -> BResult<Value> {
|
||||
f.module().const_value(c)
|
||||
}
|
||||
|
||||
/// `a / b` rounded up (`b` not 0), without wrapping.
|
||||
fn div_ceil(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult<Value> {
|
||||
let q = f.binary(BinOp::UDiv, a, b)?;
|
||||
let r = f.binary(BinOp::UMod, a, b)?;
|
||||
let zero = u32_value(f, 0)?;
|
||||
let one = u32_value(f, 1)?;
|
||||
let partial = f.binary(BinOp::INotEqual, r, zero)?;
|
||||
let extra = f.select(partial, one, zero)?;
|
||||
f.binary(BinOp::IAdd, q, extra)
|
||||
}
|
||||
|
||||
/// Run `each(f, i)` for `i` from `lo` below `hi`.
|
||||
fn for_range<'a>(
|
||||
f: &mut FunctionBuilder<'_>,
|
||||
u32_: TypeId,
|
||||
(lo, hi): (Value, Value),
|
||||
each: impl FnOnce(&mut FunctionBuilder<'_>, Value) -> BResult<()> + 'a,
|
||||
) -> BResult<()> {
|
||||
let var = f.local_var(u32_, None)?;
|
||||
let counter = f.var_ptr(var)?;
|
||||
f.store(counter, lo, MemAccess::default())?;
|
||||
let body: LoopFn<'a, ()> = Box::new(move |f, _, lc| {
|
||||
let i = f.load(counter, MemAccess::default())?;
|
||||
let done = f.binary(BinOp::UGreaterThanEqual, i, hi)?;
|
||||
let exit: ArmFn<'_, ()> = Box::new(move |f, _| {
|
||||
lc.break_(f)?;
|
||||
Ok(ArmEnd::Exits)
|
||||
});
|
||||
f.if_(&mut (), done, exit, None)?;
|
||||
let one = u32_value(f, 1)?;
|
||||
let next = f.binary(BinOp::IAdd, i, one)?;
|
||||
f.store(counter, next, MemAccess::default())?;
|
||||
each(f, i)
|
||||
});
|
||||
f.loop_(&mut (), LoopSpec::default(), body)
|
||||
}
|
||||
|
||||
/// Whether `v`'s product is at most `total`, without overflow and without a division: a zero
|
||||
/// count's product is 0, and otherwise the product is within where neither multiplication's high
|
||||
/// word is set and its low word is at most `total` (`checked_mul`, as `bind::replay`'s).
|
||||
|
||||
@@ -1,749 +0,0 @@
|
||||
//! The mesh scan of an emulated mesh draw whose mesh threadgroups only the GPU knows: a draw of a
|
||||
//! pipeline with an object function, whose object threadgroups each set the mesh grid they launch,
|
||||
//! and an indirect draw, whose mesh grid is Metal's indirect arguments.
|
||||
//!
|
||||
//! One workgroup of [`MeshScanModule::LOCAL_SIZE`] invocations reads the draw's work buffer
|
||||
//! (`SyntheticBinding::MeshWork`, [`MeshDispatch::work`](crate::bind::MeshDispatch::work)): the
|
||||
//! grid each of its `O` object threadgroups set (slot 0's, of an indirect draw, from Metal's
|
||||
//! arguments, held to Metal's limits on a mesh grid as an object function's grid is), and
|
||||
//! writes, after the slots:
|
||||
//!
|
||||
//! - each object threadgroup's first mesh threadgroup, in object threadgroup order, and `T`, the
|
||||
//! draw's mesh threadgroups (the offsets the mesh function's wrapper bisects);
|
||||
//! - in the header, `T`, where the draw's records begin in the command buffer's records pool
|
||||
//! (`RECORDS_BASE`), the mesh dispatch's `VkDispatchIndirectCommand` (`T` folded into rows of
|
||||
//! the header's `ROW` workgroups) and the draw's `VkDrawIndirectCommand` (`T · NP · k`
|
||||
//! vertices).
|
||||
//!
|
||||
//! The draw's records are reserved from the records pool's cursor
|
||||
//! ([`StatusWord::MeshRecordsCursor`], 0 before the command buffer's first scan): `T` mesh
|
||||
//! threadgroups' words. A draw whose records the rest of the pool cannot hold, or whose vertices
|
||||
//! pass a `u32`, runs and draws nothing; the scan sets [`StatusBits::MESH_RECORDS_OVERFLOW`] and,
|
||||
//! where it is the command buffer's first records fault, the consumer's number for the draw, its object threadgroups and the mesh threadgroups it needed
|
||||
//! (saturated) in the fault words, which
|
||||
//! [`ExecutionStatus::decode`](crate::bind::ExecutionStatus::decode) reports. Nothing is drawn
|
||||
//! short silently.
|
||||
//!
|
||||
//! **Bindings** (set 0, storage buffers): [`MeshScanModule::WORK_BINDING`] (the draw's work
|
||||
//! buffer, whole), `STATUS_BINDING` (the command buffer's `ExecutionStatus` buffer) and
|
||||
//! `ARGUMENTS_BINDING` (for an indirect draw, the Metal indirect buffer's range from the
|
||||
//! arguments' offset aligned down to `minStorageBufferOffsetAlignment`; for any other draw any 4
|
||||
//! bytes, which nothing reads). Every read of the arguments is contained.
|
||||
//!
|
||||
//! **Synchronization** (consumer): the object dispatch's writes, the arguments' writes and the
|
||||
//! upload of the work buffer → `SHADER_READ` in `COMPUTE_SHADER` before the scan; scans one
|
||||
//! after another (each reads and writes the pool's cursor); the scan's writes →
|
||||
//! `INDIRECT_COMMAND_READ` in `DRAW_INDIRECT` and `SHADER_READ` in `COMPUTE_SHADER` before the
|
||||
//! mesh dispatch, and in `VERTEX_SHADER` before the draw.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind::index_bounds::finished;
|
||||
use crate::bind::mesh_arguments::{
|
||||
METAL_MESH_GRID_AXIS, METAL_MESH_GRID_TOTAL, METAL_OBJECT_GRID_TOTAL,
|
||||
};
|
||||
use crate::bind::replay::checked_mul;
|
||||
use crate::bind::status::{StatusBits, StatusWord};
|
||||
use crate::device::requirements::Requirements;
|
||||
use crate::device::Device;
|
||||
use crate::error::Error;
|
||||
use crate::lower::mesh::work;
|
||||
use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage, Symbol, SyntheticBinding};
|
||||
use crate::spirv::builder::constructs::{ArmEnd, ArmFn, LoopFn, LoopSpec};
|
||||
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{GlobalId, TypeId, Value};
|
||||
use crate::spirv::ir::{
|
||||
natural_layout, AtomicOp, BinOp, ConstBits, Constant, ExecMode, ExecModel, GlslOp, IoDir,
|
||||
LayoutRule, MemAccess, MemoryOrder, Scope, Semantics, StorageClass, Type, TypedModule, UnOp,
|
||||
};
|
||||
|
||||
/// The crate-owned mesh scan module of one device, validated like any output.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct MeshScanModule {
|
||||
/// SPIR-V 1.5 words, entry point `main`, bindings numbered as below in set 0.
|
||||
pub spirv: Arc<[u32]>,
|
||||
/// What the module needs from the device (within every Vulkan 1.2 device).
|
||||
pub requirements: Requirements,
|
||||
}
|
||||
|
||||
impl MeshScanModule {
|
||||
/// Descriptor set of every binding.
|
||||
pub const SET: u32 = 0;
|
||||
/// The draw's work buffer, a storage buffer.
|
||||
pub const WORK_BINDING: u32 = 0;
|
||||
/// The command buffer's `ExecutionStatus` buffer, a storage buffer.
|
||||
pub const STATUS_BINDING: u32 = 1;
|
||||
/// The Metal indirect buffer, a storage buffer.
|
||||
pub const ARGUMENTS_BINDING: u32 = 2;
|
||||
/// The draw's records, a storage buffer: the command buffer's records pool, where an indirect
|
||||
/// draw with an object function keeps its slots and offsets (`MeshDispatch::object_arguments`).
|
||||
pub const RECORDS_BINDING: u32 = 3;
|
||||
/// Invocations of the one workgroup, along x.
|
||||
pub const LOCAL_SIZE: u32 = 64;
|
||||
}
|
||||
|
||||
/// The work buffer's binding symbol in the typed module.
|
||||
pub const WORK: ResourceSlot = ResourceSlot {
|
||||
stage: Stage::Kernel,
|
||||
kind: ResourceKind::Buffer,
|
||||
index: 0,
|
||||
};
|
||||
/// The arguments' binding symbol ([`MeshScanModule::ARGUMENTS_BINDING`]).
|
||||
pub const ARGUMENTS: ResourceSlot = ResourceSlot {
|
||||
stage: Stage::Kernel,
|
||||
kind: ResourceKind::Buffer,
|
||||
index: 1,
|
||||
};
|
||||
/// The records' binding symbol ([`MeshScanModule::RECORDS_BINDING`]).
|
||||
pub const RECORDS: ResourceSlot = ResourceSlot {
|
||||
stage: Stage::Kernel,
|
||||
kind: ResourceKind::Buffer,
|
||||
index: 2,
|
||||
};
|
||||
/// The status buffer's binding symbol ([`MeshScanModule::STATUS_BINDING`]).
|
||||
pub const STATUS: ResourceSlot = ResourceSlot {
|
||||
stage: Stage::Kernel,
|
||||
kind: ResourceKind::Synthetic(SyntheticBinding::ExecutionStatus),
|
||||
index: 0,
|
||||
};
|
||||
|
||||
/// A `Block { u32 words[]; }` storage buffer bound at `sym`.
|
||||
pub(crate) fn words_buffer(
|
||||
b: &mut ModuleBuilder,
|
||||
sym: ResourceSlot,
|
||||
u32_: TypeId,
|
||||
) -> BResult<GlobalId> {
|
||||
let rta = b.ty(Type::RuntimeArray {
|
||||
elem: u32_,
|
||||
stride: Some(4),
|
||||
})?;
|
||||
let layout = natural_layout(b.types(), LayoutRule::Std430, true, &[rta])?;
|
||||
let block = b.ty(Type::Struct {
|
||||
members: [rta].into(),
|
||||
layout: Some(layout),
|
||||
})?;
|
||||
b.resource(sym, StorageClass::StorageBuffer, block)
|
||||
}
|
||||
|
||||
pub(crate) fn k(f: &mut FunctionBuilder<'_>, v: u32) -> BResult<Value> {
|
||||
let c = f.u32_const(v)?;
|
||||
f.module().const_value(c)
|
||||
}
|
||||
|
||||
/// The pointer to word `index` of `buffer`'s runtime array.
|
||||
pub(crate) fn word_ptr(f: &mut FunctionBuilder<'_>, buffer: Value, index: Value) -> BResult<Value> {
|
||||
let zero = k(f, 0)?;
|
||||
f.access_chain(buffer, &[zero, index])
|
||||
}
|
||||
|
||||
pub(crate) fn load(f: &mut FunctionBuilder<'_>, buffer: Value, index: Value) -> BResult<Value> {
|
||||
let p = word_ptr(f, buffer, index)?;
|
||||
f.load(p, MemAccess::default())
|
||||
}
|
||||
|
||||
pub(crate) fn load_at(f: &mut FunctionBuilder<'_>, buffer: Value, index: u32) -> BResult<Value> {
|
||||
let i = k(f, index)?;
|
||||
load(f, buffer, i)
|
||||
}
|
||||
|
||||
pub(crate) fn store(
|
||||
f: &mut FunctionBuilder<'_>,
|
||||
buffer: Value,
|
||||
index: Value,
|
||||
v: Value,
|
||||
) -> BResult<()> {
|
||||
let p = word_ptr(f, buffer, index)?;
|
||||
f.store(p, v, MemAccess::default())
|
||||
}
|
||||
|
||||
pub(crate) fn store_at(
|
||||
f: &mut FunctionBuilder<'_>,
|
||||
buffer: Value,
|
||||
index: u32,
|
||||
v: Value,
|
||||
) -> BResult<()> {
|
||||
let i = k(f, index)?;
|
||||
store(f, buffer, i, v)
|
||||
}
|
||||
|
||||
/// Word `index` of `buffer` where it lies inside the buffer's bound range, else 0 (contained).
|
||||
fn contained(f: &mut FunctionBuilder<'_>, buffer: Value, index: Value) -> BResult<Value> {
|
||||
let zero = k(f, 0)?;
|
||||
let len = f.array_length(buffer, 0)?;
|
||||
let inside = f.binary(BinOp::ULessThan, index, len)?;
|
||||
let safe = f.select(inside, index, zero)?;
|
||||
let loaded = load(f, buffer, safe)?;
|
||||
f.select(inside, loaded, zero)
|
||||
}
|
||||
|
||||
/// `a + b`, or `u32::MAX` where it wraps.
|
||||
pub(crate) fn saturating_add(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult<Value> {
|
||||
let sum = f.binary(BinOp::IAdd, a, b)?;
|
||||
let wrapped = f.binary(BinOp::ULessThan, sum, a)?;
|
||||
let max = k(f, u32::MAX)?;
|
||||
f.select(wrapped, max, sum)
|
||||
}
|
||||
|
||||
/// `a / b` rounded up (`b` not 0), without wrapping.
|
||||
pub(crate) fn div_ceil(f: &mut FunctionBuilder<'_>, a: Value, b: Value) -> BResult<Value> {
|
||||
let q = f.binary(BinOp::UDiv, a, b)?;
|
||||
let r = f.binary(BinOp::UMod, a, b)?;
|
||||
let zero = k(f, 0)?;
|
||||
let one = k(f, 1)?;
|
||||
let partial = f.binary(BinOp::INotEqual, r, zero)?;
|
||||
let extra = f.select(partial, one, zero)?;
|
||||
f.binary(BinOp::IAdd, q, extra)
|
||||
}
|
||||
|
||||
/// The threadgroups of grid `g`: `x · y · z` where the grid lies within Metal's limits on a mesh
|
||||
/// grid ([`METAL_MESH_GRID_AXIS`] along each axis, [`METAL_MESH_GRID_TOTAL`] in all, as an
|
||||
/// emulated object function holds the grid it sets), else 0. The product compared wraps only
|
||||
/// where an earlier test fails.
|
||||
fn bounded_groups(f: &mut FunctionBuilder<'_>, [x, y, z]: [Value; 3]) -> BResult<Value> {
|
||||
let one = k(f, 1)?;
|
||||
let total = k(f, METAL_MESH_GRID_TOTAL)?;
|
||||
let ny = f.glsl(GlslOp::UMax, &[y, one])?;
|
||||
let room = f.binary(BinOp::UDiv, total, ny)?;
|
||||
let mut all = f.binary(BinOp::ULessThanEqual, x, room)?;
|
||||
let xy = f.binary(BinOp::IMul, x, y)?;
|
||||
let nz = f.glsl(GlslOp::UMax, &[z, one])?;
|
||||
let room = f.binary(BinOp::UDiv, total, nz)?;
|
||||
let c = f.binary(BinOp::ULessThanEqual, xy, room)?;
|
||||
all = f.binary(BinOp::LogicalAnd, all, c)?;
|
||||
let axis = k(f, METAL_MESH_GRID_AXIS)?;
|
||||
for v in [x, y, z] {
|
||||
let c = f.binary(BinOp::ULessThanEqual, v, axis)?;
|
||||
all = f.binary(BinOp::LogicalAnd, all, c)?;
|
||||
}
|
||||
let xyz = f.binary(BinOp::IMul, xy, z)?;
|
||||
let zero = k(f, 0)?;
|
||||
f.select(all, xyz, zero)
|
||||
}
|
||||
|
||||
/// Run `each(f, i)` for `i` from `lo` below `hi`.
|
||||
pub(crate) fn for_range<'a>(
|
||||
f: &mut FunctionBuilder<'_>,
|
||||
u32_: TypeId,
|
||||
(lo, hi): (Value, Value),
|
||||
each: impl FnOnce(&mut FunctionBuilder<'_>, Value) -> BResult<()> + 'a,
|
||||
) -> BResult<()> {
|
||||
let var = f.local_var(u32_, None)?;
|
||||
let counter = f.var_ptr(var)?;
|
||||
f.store(counter, lo, MemAccess::default())?;
|
||||
let body: LoopFn<'a, ()> = Box::new(move |f, _, lc| {
|
||||
let i = f.load(counter, MemAccess::default())?;
|
||||
let done = f.binary(BinOp::UGreaterThanEqual, i, hi)?;
|
||||
let exit: ArmFn<'_, ()> = Box::new(move |f, _| {
|
||||
lc.break_(f)?;
|
||||
Ok(ArmEnd::Exits)
|
||||
});
|
||||
f.if_(&mut (), done, exit, None)?;
|
||||
let one = k(f, 1)?;
|
||||
let next = f.binary(BinOp::IAdd, i, one)?;
|
||||
f.store(counter, next, MemAccess::default())?;
|
||||
each(f, i)
|
||||
});
|
||||
f.loop_(&mut (), LoopSpec::default(), body)
|
||||
}
|
||||
|
||||
/// Where the draw's slots and offsets begin (`work::SLOTS`): whether in the records, and the word
|
||||
/// of their first in the buffer that holds them.
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct Slots {
|
||||
work: Value,
|
||||
records: Value,
|
||||
pooled: Value,
|
||||
start: Value,
|
||||
}
|
||||
|
||||
impl Slots {
|
||||
pub(crate) fn of(f: &mut FunctionBuilder<'_>, work: Value, records: Value) -> BResult<Slots> {
|
||||
let word = load_at(f, work, work::SLOTS)?;
|
||||
let zero = k(f, 0)?;
|
||||
let one = k(f, 1)?;
|
||||
let pooled = f.binary(BinOp::INotEqual, word, zero)?;
|
||||
let in_pool = f.binary(BinOp::ISub, word, one)?;
|
||||
let header = k(f, work::HEADER)?;
|
||||
let start = f.select(pooled, in_pool, header)?;
|
||||
Ok(Slots {
|
||||
work,
|
||||
records,
|
||||
pooled,
|
||||
start,
|
||||
})
|
||||
}
|
||||
|
||||
/// Word `at` of the slots and offsets (from their first).
|
||||
pub(crate) fn load(self, f: &mut FunctionBuilder<'_>, at: Value) -> BResult<Value> {
|
||||
let zero = k(f, 0)?;
|
||||
let at = f.binary(BinOp::IAdd, self.start, at)?;
|
||||
let in_work = f.select(self.pooled, zero, at)?;
|
||||
let in_pool = f.select(self.pooled, at, zero)?;
|
||||
let from_work = load(f, self.work, in_work)?;
|
||||
let from_pool = load(f, self.records, in_pool)?;
|
||||
f.select(self.pooled, from_pool, from_work)
|
||||
}
|
||||
|
||||
/// Store `v` at word `at` of the slots and offsets (from their first).
|
||||
pub(crate) fn store(self, f: &mut FunctionBuilder<'_>, at: Value, v: Value) -> BResult<()> {
|
||||
let at = f.binary(BinOp::IAdd, self.start, at)?;
|
||||
let (records, work) = (self.records, self.work);
|
||||
let pool: ArmFn<'_, ()> = Box::new(move |f, _| {
|
||||
store(f, records, at, v)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
let local: ArmFn<'_, ()> = Box::new(move |f, _| {
|
||||
store(f, work, at, v)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
f.if_(&mut (), self.pooled, pool, Some(local))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Run `then(f)` where `c` holds.
|
||||
pub(crate) fn when<'a>(
|
||||
f: &mut FunctionBuilder<'_>,
|
||||
c: Value,
|
||||
then: impl FnOnce(&mut FunctionBuilder<'_>) -> BResult<()> + 'a,
|
||||
) -> BResult<()> {
|
||||
let arm: ArmFn<'a, ()> = Box::new(move |f, _| {
|
||||
then(f)?;
|
||||
Ok(ArmEnd::FallThrough(Vec::new()))
|
||||
});
|
||||
f.if_(&mut (), c, arm, None)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The workgroup barrier over the partial sums.
|
||||
pub(crate) fn barrier(f: &mut FunctionBuilder<'_>) -> BResult<()> {
|
||||
let sem = Semantics {
|
||||
order: MemoryOrder::AcquireRelease,
|
||||
workgroup_memory: true,
|
||||
..Semantics::RELAXED
|
||||
};
|
||||
f.control_barrier(Scope::Workgroup, Scope::Workgroup, sem)
|
||||
}
|
||||
|
||||
/// The scan as a typed module, before serialization: the module [`mesh_scan_module`] serializes,
|
||||
/// which the CPU interpreter runs. Its bindings are the symbols [`WORK`], [`ARGUMENTS`] and
|
||||
/// [`STATUS`].
|
||||
pub fn scan_typed_module() -> BResult<TypedModule> {
|
||||
let mut b = ModuleBuilder::new();
|
||||
let u32_ = b.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: false,
|
||||
})?;
|
||||
let lanes = b.constant(Constant::Scalar {
|
||||
ty: u32_,
|
||||
bits: ConstBits(u64::from(MeshScanModule::LOCAL_SIZE)),
|
||||
})?;
|
||||
let partial_ty = b.ty(Type::Array {
|
||||
elem: u32_,
|
||||
len: lanes,
|
||||
stride: None,
|
||||
})?;
|
||||
let partial = b.plain_global(StorageClass::Workgroup, partial_ty, None)?;
|
||||
let total_var = b.plain_global(StorageClass::Workgroup, u32_, None)?;
|
||||
let work = words_buffer(&mut b, WORK, u32_)?;
|
||||
let arguments = words_buffer(&mut b, ARGUMENTS, u32_)?;
|
||||
let status = words_buffer(&mut b, STATUS, u32_)?;
|
||||
let records = words_buffer(&mut b, RECORDS, u32_)?;
|
||||
let invocation = b.builtin(
|
||||
crate::spv::BuiltIn::LocalInvocationIndex,
|
||||
IoDir::Input,
|
||||
u32_,
|
||||
)?;
|
||||
let void = b.ty(Type::Void)?;
|
||||
let mut f = b.function(void)?;
|
||||
let work = f.module().global_value(work)?;
|
||||
let arguments = f.module().global_value(arguments)?;
|
||||
let status = f.module().global_value(status)?;
|
||||
let records = f.module().global_value(records)?;
|
||||
let partial = f.module().global_value(partial)?;
|
||||
let total_var = f.module().global_value(total_var)?;
|
||||
let invocation = f.module().global_value(invocation)?;
|
||||
let lin = f.load(invocation, MemAccess::default())?;
|
||||
let zero = k(&mut f, 0)?;
|
||||
let one = k(&mut f, 1)?;
|
||||
let first = f.binary(BinOp::IEqual, lin, zero)?;
|
||||
|
||||
let objects = load_at(&mut f, work, work::OBJECT_GROUPS)?;
|
||||
let slot_words = load_at(&mut f, work, work::SLOT_WORDS)?;
|
||||
let group_words = load_at(&mut f, work, work::GROUP_WORDS)?;
|
||||
let group_vertices = load_at(&mut f, work, work::GROUP_VERTICES)?;
|
||||
let pool_words = load_at(&mut f, work, work::POOL_WORDS)?;
|
||||
let draw_id = load_at(&mut f, work, work::DRAW_ID)?;
|
||||
let row = load_at(&mut f, work, work::ROW)?;
|
||||
let argument_word = load_at(&mut f, work, work::ARGUMENTS)?;
|
||||
let slots = Slots::of(&mut f, work, records)?;
|
||||
|
||||
// An indirect draw's grid (slot 0, `O = 1`): Metal's arguments, read by every invocation.
|
||||
let indirect = f.binary(BinOp::INotEqual, argument_word, zero)?;
|
||||
let at = f.binary(BinOp::ISub, argument_word, one)?;
|
||||
let mut grid = Vec::with_capacity(3);
|
||||
for i in 0..3 {
|
||||
let i = k(&mut f, i)?;
|
||||
let w = f.binary(BinOp::IAdd, at, i)?;
|
||||
let w = f.select(indirect, w, zero)?;
|
||||
let v = contained(&mut f, arguments, w)?;
|
||||
grid.push(f.select(indirect, v, zero)?);
|
||||
}
|
||||
let argued = bounded_groups(&mut f, [grid[0], grid[1], grid[2]])?;
|
||||
let held = f.binary(BinOp::INotEqual, argued, zero)?;
|
||||
let write_grid = f.binary(BinOp::LogicalAnd, indirect, first)?;
|
||||
when(&mut f, write_grid, move |f| {
|
||||
let zero = k(f, 0)?;
|
||||
for (i, v) in grid.into_iter().enumerate() {
|
||||
let v = f.select(held, v, zero)?;
|
||||
let at = k(f, work::HEADER + i as u32)?;
|
||||
store(f, work, at, v)?;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
// The mesh threadgroups object threadgroup `o` launches.
|
||||
let groups = move |f: &mut FunctionBuilder<'_>, o: Value| -> BResult<Value> {
|
||||
let slot = f.binary(BinOp::IMul, o, slot_words)?;
|
||||
let mut g = [slot; 3];
|
||||
for (i, v) in g.iter_mut().enumerate() {
|
||||
let off = k(f, i as u32)?;
|
||||
let w = f.binary(BinOp::IAdd, slot, off)?;
|
||||
*v = slots.load(f, w)?;
|
||||
}
|
||||
let set = bounded_groups(f, g)?;
|
||||
f.select(indirect, argued, set)
|
||||
};
|
||||
|
||||
// Each invocation's run of object threadgroups: `[lin · c, lin · c + c)` within `O`.
|
||||
let lanes = k(&mut f, MeshScanModule::LOCAL_SIZE)?;
|
||||
let chunk = div_ceil(&mut f, objects, lanes)?;
|
||||
let start = f.binary(BinOp::IMul, lin, chunk)?;
|
||||
let lo = f.glsl(GlslOp::UMin, &[start, objects])?;
|
||||
let end = f.binary(BinOp::IAdd, lo, chunk)?;
|
||||
let hi = f.glsl(GlslOp::UMin, &[end, objects])?;
|
||||
let sum_var = f.local_var(u32_, None)?;
|
||||
let sum = f.var_ptr(sum_var)?;
|
||||
f.store(sum, zero, MemAccess::default())?;
|
||||
for_range(&mut f, u32_, (lo, hi), move |f, o| {
|
||||
let n = groups(f, o)?;
|
||||
let s = f.load(sum, MemAccess::default())?;
|
||||
let s = saturating_add(f, s, n)?;
|
||||
f.store(sum, s, MemAccess::default())
|
||||
})?;
|
||||
let mine = f.load(sum, MemAccess::default())?;
|
||||
let own = f.access_chain(partial, &[lin])?;
|
||||
f.store(own, mine, MemAccess::default())?;
|
||||
barrier(&mut f)?;
|
||||
// The first invocation turns the sums into each run's first mesh threadgroup.
|
||||
when(&mut f, first, move |f| {
|
||||
let zero = k(f, 0)?;
|
||||
let lanes = k(f, MeshScanModule::LOCAL_SIZE)?;
|
||||
f.store(sum, zero, MemAccess::default())?;
|
||||
for_range(f, u32_, (zero, lanes), move |f, t| {
|
||||
let p = f.access_chain(partial, &[t])?;
|
||||
let part = f.load(p, MemAccess::default())?;
|
||||
let running = f.load(sum, MemAccess::default())?;
|
||||
f.store(p, running, MemAccess::default())?;
|
||||
let next = saturating_add(f, running, part)?;
|
||||
f.store(sum, next, MemAccess::default())
|
||||
})?;
|
||||
let total = f.load(sum, MemAccess::default())?;
|
||||
f.store(total_var, total, MemAccess::default())
|
||||
})?;
|
||||
barrier(&mut f)?;
|
||||
// The offsets of the run's object threadgroups.
|
||||
let offsets = f.binary(BinOp::IMul, objects, slot_words)?;
|
||||
let own = f.access_chain(partial, &[lin])?;
|
||||
let base = f.load(own, MemAccess::default())?;
|
||||
f.store(sum, base, MemAccess::default())?;
|
||||
for_range(&mut f, u32_, (lo, hi), move |f, o| {
|
||||
let running = f.load(sum, MemAccess::default())?;
|
||||
let at = f.binary(BinOp::IAdd, offsets, o)?;
|
||||
slots.store(f, at, running)?;
|
||||
let n = groups(f, o)?;
|
||||
let next = saturating_add(f, running, n)?;
|
||||
f.store(sum, next, MemAccess::default())
|
||||
})?;
|
||||
// The first invocation reserves the records and writes the dispatch and the draw.
|
||||
when(&mut f, first, move |f| {
|
||||
let zero = k(f, 0)?;
|
||||
let one = k(f, 1)?;
|
||||
let total = f.load(total_var, MemAccess::default())?;
|
||||
let at = f.binary(BinOp::IAdd, offsets, objects)?;
|
||||
slots.store(f, at, total)?;
|
||||
let cursor_at = k(f, StatusWord::MeshRecordsCursor.index())?;
|
||||
let cursor_ptr = word_ptr(f, status, cursor_at)?;
|
||||
let cursor = f.load(cursor_ptr, MemAccess::default())?;
|
||||
let used = f.glsl(GlslOp::UMin, &[cursor, pool_words])?;
|
||||
let room = f.binary(BinOp::ISub, pool_words, used)?;
|
||||
let gw = f.glsl(GlslOp::UMax, &[group_words, one])?;
|
||||
let fit = f.binary(BinOp::UDiv, room, gw)?;
|
||||
let fits = f.binary(BinOp::ULessThanEqual, total, fit)?;
|
||||
// The draw's vertices fit a `u32` where the product's high word is 0
|
||||
// (`replay::checked_mul`, whose docs say why).
|
||||
let gv = f.glsl(GlslOp::UMax, &[group_vertices, one])?;
|
||||
let (_, past) = checked_mul(f, total, gv, zero)?;
|
||||
let drawable = f.unary(UnOp::LogicalNot, past)?;
|
||||
let ok = f.binary(BinOp::LogicalAnd, fits, drawable)?;
|
||||
let t = f.select(ok, total, zero)?;
|
||||
let words = f.binary(BinOp::IMul, t, group_words)?;
|
||||
let next = f.binary(BinOp::IAdd, used, words)?;
|
||||
let cursor_after = f.select(ok, next, cursor)?;
|
||||
f.store(cursor_ptr, cursor_after, MemAccess::default())?;
|
||||
let records_base = f.select(ok, used, zero)?;
|
||||
let row = f.glsl(GlslOp::UMax, &[row, one])?;
|
||||
let x = f.glsl(GlslOp::UMin, &[t, row])?;
|
||||
let y = div_ceil(f, t, row)?;
|
||||
let vertices = f.binary(BinOp::IMul, t, group_vertices)?;
|
||||
for (at, v) in [
|
||||
(work::MESH_GROUPS, t),
|
||||
(work::RECORDS_BASE, records_base),
|
||||
(work::DISPATCH, x),
|
||||
(work::DISPATCH + 1, y),
|
||||
(work::DISPATCH + 2, one),
|
||||
(work::DRAW, vertices),
|
||||
(work::DRAW + 1, one),
|
||||
(work::DRAW + 2, zero),
|
||||
(work::DRAW + 3, zero),
|
||||
] {
|
||||
store_at(f, work, at, v)?;
|
||||
}
|
||||
// A draw the pool cannot hold, or whose vertices pass a `u32`, draws nothing and says
|
||||
// so; the command buffer's first such draw is named.
|
||||
let over = f.unary(UnOp::LogicalNot, ok)?;
|
||||
when(f, over, move |f| {
|
||||
let zero = k(f, 0)?;
|
||||
let word = k(f, StatusWord::Status.index())?;
|
||||
let bit = k(f, StatusBits::MESH_RECORDS_OVERFLOW.0)?;
|
||||
let p = word_ptr(f, status, word)?;
|
||||
let old = f.atomic(AtomicOp::Or, p, Scope::Device, Semantics::RELAXED, bit)?;
|
||||
let had = f.binary(BinOp::BitwiseAnd, old, bit)?;
|
||||
let new = f.binary(BinOp::IEqual, had, zero)?;
|
||||
when(f, new, move |f| {
|
||||
for (w, v) in [
|
||||
(StatusWord::MeshFaultDraw, draw_id),
|
||||
(StatusWord::MeshFaultObjects, objects),
|
||||
(StatusWord::MeshFaultGroups, total),
|
||||
] {
|
||||
store_at(f, status, w.index(), v)?;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
})
|
||||
})?;
|
||||
f.ret(None)?;
|
||||
let id = f.finish()?;
|
||||
b.entry(
|
||||
ExecModel::GLCompute,
|
||||
id,
|
||||
vec![ExecMode::LocalSize {
|
||||
x: MeshScanModule::LOCAL_SIZE,
|
||||
y: 1,
|
||||
z: 1,
|
||||
}],
|
||||
)?;
|
||||
b.finalize()
|
||||
}
|
||||
|
||||
/// The object arguments pass as a typed module, before serialization: the module
|
||||
/// [`mesh_object_arguments_module`] serializes for a device of `compute`
|
||||
/// (`maxComputeWorkGroupCount`), which the CPU interpreter runs. One invocation reads Metal's
|
||||
/// arguments, the object grid, at the header's `OBJECT_ARGUMENTS` word (the module docs), and:
|
||||
///
|
||||
/// - a grid with a zero count runs nothing;
|
||||
/// - one of more threadgroups than [`METAL_OBJECT_GRID_TOTAL`], which Metal's GPU discards, runs
|
||||
/// nothing and sets [`StatusBits::MESH_GRID_DISCARDED`];
|
||||
/// - one with a count past `compute` on its axis runs nothing and sets
|
||||
/// [`StatusBits::MESH_GRID_PAST_LIMITS`] (a grid whose threads per grid wrap along an axis runs:
|
||||
/// the object function reports the wrapped grid, `lower::dispatch`'s object grid);
|
||||
/// - else it reserves `O · S + O + 1` words of the records pool from its cursor for the slots and
|
||||
/// offsets, and writes `O` (`OBJECT_GROUPS`), their first word plus 1 (`SLOTS`) and the object
|
||||
/// dispatch (`OBJECT_DISPATCH`, the grid); where the rest of the pool cannot hold them it runs
|
||||
/// nothing and sets [`StatusBits::MESH_RECORDS_OVERFLOW`], naming the draw and its object
|
||||
/// threadgroups (and no mesh threadgroup) where it is the command buffer's first records fault.
|
||||
///
|
||||
/// A grid that runs nothing writes 0 for `O`, `SLOTS` and the dispatch. Its bindings are the
|
||||
/// scan's.
|
||||
pub fn object_arguments_typed_module(compute: [u32; 3]) -> BResult<TypedModule> {
|
||||
let mut b = ModuleBuilder::new();
|
||||
let u32_ = b.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: false,
|
||||
})?;
|
||||
let work = words_buffer(&mut b, WORK, u32_)?;
|
||||
let arguments = words_buffer(&mut b, ARGUMENTS, u32_)?;
|
||||
let status = words_buffer(&mut b, STATUS, u32_)?;
|
||||
// The records are bound for the scan's layout; this pass only reserves from their cursor.
|
||||
words_buffer(&mut b, RECORDS, u32_)?;
|
||||
let void = b.ty(Type::Void)?;
|
||||
let mut f = b.function(void)?;
|
||||
let work = f.module().global_value(work)?;
|
||||
let arguments = f.module().global_value(arguments)?;
|
||||
let status = f.module().global_value(status)?;
|
||||
let zero = k(&mut f, 0)?;
|
||||
let one = k(&mut f, 1)?;
|
||||
let argument_word = load_at(&mut f, work, work::OBJECT_ARGUMENTS)?;
|
||||
let at = f.binary(BinOp::ISub, argument_word, one)?;
|
||||
let mut grid = [zero; 3];
|
||||
let mut any_zero = boolean(&mut f, false)?;
|
||||
let mut past = boolean(&mut f, false)?;
|
||||
for (i, g) in grid.iter_mut().enumerate() {
|
||||
let off = k(&mut f, i as u32)?;
|
||||
let w = f.binary(BinOp::IAdd, at, off)?;
|
||||
*g = contained(&mut f, arguments, w)?;
|
||||
let z = f.binary(BinOp::IEqual, *g, zero)?;
|
||||
any_zero = f.binary(BinOp::LogicalOr, any_zero, z)?;
|
||||
let limit = k(&mut f, compute[i])?;
|
||||
let over = f.binary(BinOp::UGreaterThan, *g, limit)?;
|
||||
past = f.binary(BinOp::LogicalOr, past, over)?;
|
||||
}
|
||||
let some = f.unary(UnOp::LogicalNot, any_zero)?;
|
||||
let (xy, wraps_xy) = checked_mul(&mut f, grid[0], grid[1], zero)?;
|
||||
let (n, wraps_n) = checked_mul(&mut f, xy, grid[2], zero)?;
|
||||
let mut many = f.binary(BinOp::LogicalOr, wraps_xy, wraps_n)?;
|
||||
let most = k(&mut f, METAL_OBJECT_GRID_TOTAL)?;
|
||||
let over = f.binary(BinOp::UGreaterThan, n, most)?;
|
||||
many = f.binary(BinOp::LogicalOr, many, over)?;
|
||||
let discarded = f.binary(BinOp::LogicalAnd, some, many)?;
|
||||
let kept = f.unary(UnOp::LogicalNot, many)?;
|
||||
let past = f.binary(BinOp::LogicalAnd, past, kept)?;
|
||||
let past = f.binary(BinOp::LogicalAnd, past, some)?;
|
||||
// The slots and offsets: `n · S + n + 1` words, held below 2^29 · 2^17 by the grid's bound
|
||||
// and the slot's (a payload of at most 16 KiB); counted without wrapping all the same.
|
||||
let slot_words = load_at(&mut f, work, work::SLOT_WORDS)?;
|
||||
let pool_words = load_at(&mut f, work, work::POOL_WORDS)?;
|
||||
let draw_id = load_at(&mut f, work, work::DRAW_ID)?;
|
||||
let (slots, wraps_slots) = checked_mul(&mut f, n, slot_words, zero)?;
|
||||
let offsets = f.binary(BinOp::IAdd, n, one)?;
|
||||
let words = saturating_add(&mut f, slots, offsets)?;
|
||||
let cursor_at = k(&mut f, StatusWord::MeshRecordsCursor.index())?;
|
||||
let cursor_ptr = word_ptr(&mut f, status, cursor_at)?;
|
||||
let cursor = f.load(cursor_ptr, MemAccess::default())?;
|
||||
let used = f.glsl(GlslOp::UMin, &[cursor, pool_words])?;
|
||||
let room = f.binary(BinOp::ISub, pool_words, used)?;
|
||||
let fits = f.binary(BinOp::ULessThanEqual, words, room)?;
|
||||
let wraps_slots = f.unary(UnOp::LogicalNot, wraps_slots)?;
|
||||
let fits = f.binary(BinOp::LogicalAnd, fits, wraps_slots)?;
|
||||
let launched = f.binary(BinOp::LogicalOr, discarded, past)?;
|
||||
let launched = f.unary(UnOp::LogicalNot, launched)?;
|
||||
let launched = f.binary(BinOp::LogicalAnd, launched, some)?;
|
||||
let runs = f.binary(BinOp::LogicalAnd, launched, fits)?;
|
||||
let short = f.unary(UnOp::LogicalNot, fits)?;
|
||||
let overflow = f.binary(BinOp::LogicalAnd, launched, short)?;
|
||||
let next = f.binary(BinOp::IAdd, used, words)?;
|
||||
let cursor_after = f.select(runs, next, cursor)?;
|
||||
f.store(cursor_ptr, cursor_after, MemAccess::default())?;
|
||||
let first_word = f.binary(BinOp::IAdd, used, one)?;
|
||||
let objects = f.select(runs, n, zero)?;
|
||||
let slots_word = f.select(runs, first_word, zero)?;
|
||||
store_at(&mut f, work, work::OBJECT_GROUPS, objects)?;
|
||||
store_at(&mut f, work, work::SLOTS, slots_word)?;
|
||||
for (i, g) in grid.into_iter().enumerate() {
|
||||
let v = f.select(runs, g, zero)?;
|
||||
store_at(&mut f, work, work::OBJECT_DISPATCH + i as u32, v)?;
|
||||
}
|
||||
// What runs nothing says why: Metal's discard, the device's limits, or the pool.
|
||||
let discard_bit = k(&mut f, StatusBits::MESH_GRID_DISCARDED.0)?;
|
||||
let past_bit = k(&mut f, StatusBits::MESH_GRID_PAST_LIMITS.0)?;
|
||||
let discard_bit = f.select(discarded, discard_bit, zero)?;
|
||||
let past_bit = f.select(past, past_bit, zero)?;
|
||||
let bits = f.binary(BinOp::BitwiseOr, discard_bit, past_bit)?;
|
||||
let set = f.binary(BinOp::INotEqual, bits, zero)?;
|
||||
when(&mut f, set, move |f| {
|
||||
let word = k(f, StatusWord::Status.index())?;
|
||||
let p = word_ptr(f, status, word)?;
|
||||
f.atomic(AtomicOp::Or, p, Scope::Device, Semantics::RELAXED, bits)?;
|
||||
Ok(())
|
||||
})?;
|
||||
when(&mut f, overflow, move |f| {
|
||||
let zero = k(f, 0)?;
|
||||
let word = k(f, StatusWord::Status.index())?;
|
||||
let bit = k(f, StatusBits::MESH_RECORDS_OVERFLOW.0)?;
|
||||
let p = word_ptr(f, status, word)?;
|
||||
let old = f.atomic(AtomicOp::Or, p, Scope::Device, Semantics::RELAXED, bit)?;
|
||||
let had = f.binary(BinOp::BitwiseAnd, old, bit)?;
|
||||
let new = f.binary(BinOp::IEqual, had, zero)?;
|
||||
when(f, new, move |f| {
|
||||
let zero = k(f, 0)?;
|
||||
for (w, v) in [
|
||||
(StatusWord::MeshFaultDraw, draw_id),
|
||||
(StatusWord::MeshFaultObjects, n),
|
||||
(StatusWord::MeshFaultGroups, zero),
|
||||
] {
|
||||
store_at(f, status, w.index(), v)?;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
})?;
|
||||
f.ret(None)?;
|
||||
let id = f.finish()?;
|
||||
b.entry(
|
||||
ExecModel::GLCompute,
|
||||
id,
|
||||
vec![ExecMode::LocalSize { x: 1, y: 1, z: 1 }],
|
||||
)?;
|
||||
b.finalize()
|
||||
}
|
||||
|
||||
/// The `bool` constant `v`.
|
||||
fn boolean(f: &mut FunctionBuilder<'_>, v: bool) -> BResult<Value> {
|
||||
let ty = f.module().ty(Type::Bool)?;
|
||||
let c = f.module().constant(Constant::Scalar {
|
||||
ty,
|
||||
bits: ConstBits(u64::from(v)),
|
||||
})?;
|
||||
f.module().const_value(c)
|
||||
}
|
||||
|
||||
/// The fixed binding numbers of the scan's symbols.
|
||||
fn binding_of(sym: &Symbol) -> Option<u32> {
|
||||
match sym {
|
||||
Symbol::DescriptorSet(_) => Some(MeshScanModule::SET),
|
||||
Symbol::Binding(s) if *s == WORK => Some(MeshScanModule::WORK_BINDING),
|
||||
Symbol::Binding(s) if *s == ARGUMENTS => Some(MeshScanModule::ARGUMENTS_BINDING),
|
||||
Symbol::Binding(s) if *s == STATUS => Some(MeshScanModule::STATUS_BINDING),
|
||||
Symbol::Binding(s) if *s == RECORDS => Some(MeshScanModule::RECORDS_BINDING),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The object arguments pass of `device`, which an emulated indirect draw with an object function
|
||||
/// dispatches (one workgroup of one invocation) before its object dispatch, under the scan's
|
||||
/// bindings (`MeshDispatch::object_arguments`): it reads Metal's arguments, reserves the object
|
||||
/// threadgroups' slots in the records pool, and writes the object dispatch, or runs nothing and
|
||||
/// sets the status bit that says why (`MESH_GRID_DISCARDED`, `MESH_GRID_PAST_LIMITS` past the
|
||||
/// device's `maxComputeWorkGroupCount`, `MESH_RECORDS_OVERFLOW`). Built with the typed builder,
|
||||
/// verified, serialized, and numbered with the fixed bindings of [`MeshScanModule`].
|
||||
pub fn mesh_object_arguments_module(device: &Device) -> Result<MeshScanModule, Error> {
|
||||
let compute = device
|
||||
.profile()
|
||||
.fields()
|
||||
.limits
|
||||
.max_compute_work_group_count;
|
||||
let (spirv, requirements) = finished(
|
||||
device,
|
||||
object_arguments_typed_module(compute)?,
|
||||
binding_of,
|
||||
"the mesh object arguments pass",
|
||||
)?;
|
||||
Ok(MeshScanModule {
|
||||
spirv,
|
||||
requirements,
|
||||
})
|
||||
}
|
||||
|
||||
/// The mesh scan module of `device`: built with the typed builder, verified, serialized, and
|
||||
/// numbered with the fixed bindings of [`MeshScanModule`].
|
||||
pub fn mesh_scan_module(device: &Device) -> Result<MeshScanModule, Error> {
|
||||
let (spirv, requirements) =
|
||||
finished(device, scan_typed_module()?, binding_of, "the mesh scan")?;
|
||||
Ok(MeshScanModule {
|
||||
spirv,
|
||||
requirements,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -1,565 +0,0 @@
|
||||
//! The mesh scan: valid on every committed profile (L3, `G-val`), and, on the CPU interpreter,
|
||||
//! each object threadgroup's first mesh threadgroup, the draw's `T`, its reservation in the
|
||||
//! records pool, its dispatch folded into rows and its draw; an indirect draw's grid from Metal's
|
||||
//! arguments, held to Metal's limit; and a draw the pool cannot hold draws nothing, sets
|
||||
//! `MESH_RECORDS_OVERFLOW` and names itself, the first such draw only. Slots in the records pool
|
||||
//! (`work::SLOTS`) scan as slots in the work buffer do. The object arguments pass: valid on every
|
||||
//! committed profile, and on the interpreter it reserves an indirect draw's slots and writes its
|
||||
//! object dispatch, or runs nothing and says why.
|
||||
|
||||
use super::*;
|
||||
use crate::bind::status::{ExecutionStatus, MeshRecordsFault, StatusReport};
|
||||
use crate::spirv::interp::{run, Buffer, Config, Order, Resources};
|
||||
use crate::spirv::testing::{assert_valid, committed_profiles};
|
||||
|
||||
fn words(bytes: &[u8]) -> Vec<u32> {
|
||||
bytes
|
||||
.as_chunks::<4>()
|
||||
.0
|
||||
.iter()
|
||||
.map(|c| u32::from_le_bytes(*c))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn bytes(words: &[u32]) -> Vec<u8> {
|
||||
words.iter().flat_map(|w| w.to_le_bytes()).collect()
|
||||
}
|
||||
|
||||
/// A draw's work buffer before the scan: `grids` of the object threadgroups, slots of
|
||||
/// `slot_words`, the records of `group_words` words and `group_vertices` vertices per mesh
|
||||
/// threadgroup, a pool of `pool_words`, draw number 7, rows of `row`, and Metal's arguments at
|
||||
/// word `arguments - 1` where it is not 0; the slots and offsets at word `pooled` of the pool
|
||||
/// where it is `Some`, else after the header.
|
||||
struct Draw {
|
||||
grids: Vec<[u32; 3]>,
|
||||
slot_words: u32,
|
||||
group_words: u32,
|
||||
group_vertices: u32,
|
||||
pool_words: u32,
|
||||
row: u32,
|
||||
arguments: u32,
|
||||
pooled: Option<u32>,
|
||||
}
|
||||
|
||||
impl Draw {
|
||||
fn of(grids: &[[u32; 3]]) -> Draw {
|
||||
Draw {
|
||||
grids: grids.to_vec(),
|
||||
slot_words: 6,
|
||||
group_words: 10,
|
||||
group_vertices: 3,
|
||||
pool_words: 1000,
|
||||
row: 4,
|
||||
arguments: 0,
|
||||
pooled: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The slots and the offsets before the scan.
|
||||
fn slots(&self) -> Vec<u32> {
|
||||
let mut w = Vec::new();
|
||||
for g in &self.grids {
|
||||
let mut slot = vec![0xAAAA_AAAA; self.slot_words as usize];
|
||||
slot[..3].copy_from_slice(g);
|
||||
slot[3] = 0;
|
||||
w.extend(slot);
|
||||
}
|
||||
// The offsets, which the scan writes.
|
||||
w.extend(std::iter::repeat_n(0xEEEE_EEEE, self.grids.len() + 1));
|
||||
w
|
||||
}
|
||||
|
||||
/// The pool's words before the scan: `len` words, the slots at `pooled`.
|
||||
fn pool(&self, len: usize) -> Vec<u32> {
|
||||
let mut w = vec![0x5555_5555; len];
|
||||
if let Some(at) = self.pooled {
|
||||
let slots = self.slots();
|
||||
w[at as usize..][..slots.len()].copy_from_slice(&slots);
|
||||
}
|
||||
w
|
||||
}
|
||||
|
||||
fn words(&self) -> Vec<u32> {
|
||||
let o = self.grids.len() as u32;
|
||||
let mut w = vec![0u32; work::HEADER as usize];
|
||||
w[work::OBJECT_GROUPS as usize] = o;
|
||||
w[work::SLOT_WORDS as usize] = self.slot_words;
|
||||
w[work::GROUP_WORDS as usize] = self.group_words;
|
||||
w[work::GROUP_VERTICES as usize] = self.group_vertices;
|
||||
w[work::POOL_WORDS as usize] = self.pool_words;
|
||||
w[work::DRAW_ID as usize] = 7;
|
||||
w[work::ROW as usize] = self.row;
|
||||
w[work::ARGUMENTS as usize] = self.arguments;
|
||||
match self.pooled {
|
||||
Some(at) => {
|
||||
w[work::SLOTS as usize] = at + 1;
|
||||
w.push(0xEEEE_EEEE);
|
||||
}
|
||||
None => w.extend(self.slots()),
|
||||
}
|
||||
w
|
||||
}
|
||||
}
|
||||
|
||||
/// What a scan left: the work words, the status report, the pool's cursor, and the pool.
|
||||
struct Scanned {
|
||||
work: Vec<u32>,
|
||||
report: StatusReport,
|
||||
cursor: u32,
|
||||
pool: Vec<u32>,
|
||||
}
|
||||
|
||||
/// The pool's words in the tests.
|
||||
const POOL: usize = 4096;
|
||||
|
||||
/// Run the scan of `draw` over `arguments` (bound whole) with the pool's cursor at `cursor` and
|
||||
/// the status bits `bits`, in both invocation orders.
|
||||
fn scan(draw: &Draw, arguments: &[u32], cursor: u32, bits: u32) -> Scanned {
|
||||
let module = scan_typed_module().expect("scan");
|
||||
let mut status = [0u32; 8];
|
||||
status[StatusWord::Status.index() as usize] = bits;
|
||||
status[StatusWord::MeshRecordsCursor.index() as usize] = cursor;
|
||||
let mut ran = Vec::new();
|
||||
for order in [Order::Forward, Order::Reverse] {
|
||||
let res = Resources {
|
||||
buffers: vec![
|
||||
Buffer {
|
||||
slot: Some(WORK),
|
||||
address: None,
|
||||
bytes: bytes(&draw.words()),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(ARGUMENTS),
|
||||
address: None,
|
||||
bytes: bytes(arguments),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(STATUS),
|
||||
address: None,
|
||||
bytes: bytes(&status),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(RECORDS),
|
||||
address: None,
|
||||
bytes: bytes(&draw.pool(POOL)),
|
||||
},
|
||||
],
|
||||
push: Vec::new(),
|
||||
spec: Default::default(),
|
||||
};
|
||||
let cfg = Config {
|
||||
order,
|
||||
..Config::default()
|
||||
};
|
||||
ran.push(run(&module, &cfg, res).expect("scan run").buffers);
|
||||
}
|
||||
assert_eq!(ran[0], ran[1], "order independent");
|
||||
let after = &ran[0];
|
||||
let status_bytes: [u8; 32] = after[2].as_slice().try_into().expect("status");
|
||||
let status = words(&after[2]);
|
||||
Scanned {
|
||||
work: words(&after[0]),
|
||||
report: ExecutionStatus::decode(&status_bytes),
|
||||
cursor: status[StatusWord::MeshRecordsCursor.index() as usize],
|
||||
pool: words(&after[3]),
|
||||
}
|
||||
}
|
||||
|
||||
/// The offsets after `draw`'s slots, where they lie.
|
||||
fn offsets(draw: &Draw, s: &Scanned) -> Vec<u32> {
|
||||
let slots = draw.grids.len() * draw.slot_words as usize;
|
||||
match draw.pooled {
|
||||
Some(at) => s.pool[at as usize + slots..][..draw.grids.len() + 1].to_vec(),
|
||||
None => s.work[work::HEADER as usize + slots..].to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
fn header(work: &[u32], at: u32, n: usize) -> Vec<u32> {
|
||||
work[at as usize..at as usize + n].to_vec()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_scan_is_valid_on_every_committed_profile() {
|
||||
for (_, p) in committed_profiles().expect("profiles") {
|
||||
assert_valid(scan_typed_module().expect("scan"), &p);
|
||||
}
|
||||
}
|
||||
|
||||
/// Each object threadgroup's first mesh threadgroup in object order, and `T`; the records
|
||||
/// reserved after the cursor; `T` folded into rows of `ROW`; `T · NP · k` vertices. A grid with
|
||||
/// an axis of 0 launches none, and one past Metal's limits none (65,536 along an axis, or 2^20 in
|
||||
/// all: the object function holds it so; the scan holds it again).
|
||||
#[test]
|
||||
fn the_scan_places_each_object_threadgroups_mesh_threadgroups() {
|
||||
let draw = Draw::of(&[
|
||||
[2, 1, 1],
|
||||
[0, 5, 1],
|
||||
[3, 2, 1],
|
||||
[1, 1, 1],
|
||||
[1 << 20, 2, 1],
|
||||
[1, 65536, 1],
|
||||
[1024, 1024, 1],
|
||||
]);
|
||||
let s = scan(&draw, &[0], 40, 0);
|
||||
assert_eq!(offsets(&draw, &s), vec![0, 2, 2, 8, 9, 9, 9, 9]);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 9);
|
||||
assert_eq!(s.work[work::RECORDS_BASE as usize], 40);
|
||||
assert_eq!(s.cursor, 40 + 9 * 10);
|
||||
assert_eq!(header(&s.work, work::DISPATCH, 3), vec![4, 3, 1]);
|
||||
assert_eq!(header(&s.work, work::DRAW, 4), vec![27, 1, 0, 0]);
|
||||
assert_eq!(s.report, StatusReport::default());
|
||||
// The slots are the object function's: the scan leaves them.
|
||||
assert_eq!(&s.work[work::HEADER as usize..][..3], &[2, 1, 1]);
|
||||
}
|
||||
|
||||
/// More object threadgroups than invocations: every run of them is placed after the runs
|
||||
/// before.
|
||||
#[test]
|
||||
fn the_scan_places_runs_of_many_object_threadgroups() {
|
||||
let grids: Vec<[u32; 3]> = (0..200u32).map(|i| [i % 3, 1, 1]).collect();
|
||||
let mut draw = Draw::of(&grids);
|
||||
draw.pool_words = 100_000;
|
||||
draw.row = 65535;
|
||||
let s = scan(&draw, &[0], 0, 0);
|
||||
let mut want = Vec::new();
|
||||
let mut running = 0;
|
||||
for g in &grids {
|
||||
want.push(running);
|
||||
running += g[0];
|
||||
}
|
||||
want.push(running);
|
||||
assert_eq!(offsets(&draw, &s), want);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], running);
|
||||
assert_eq!(header(&s.work, work::DISPATCH, 3), vec![running, 1, 1]);
|
||||
}
|
||||
|
||||
/// An indirect draw's grid is Metal's arguments at their word, into slot 0; one past Metal's
|
||||
/// limit launches nothing; arguments past the bound range read 0.
|
||||
#[test]
|
||||
fn an_indirect_scan_reads_metals_arguments() {
|
||||
let mut draw = Draw::of(&[[0, 0, 0]]);
|
||||
draw.arguments = 1 + 2;
|
||||
let s = scan(&draw, &[9, 9, 3, 2, 2], 0, 0);
|
||||
assert_eq!(&s.work[work::HEADER as usize..][..3], &[3, 2, 2]);
|
||||
assert_eq!(offsets(&draw, &s), vec![0, 12]);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 12);
|
||||
assert_eq!(header(&s.work, work::DRAW, 4), vec![36, 1, 0, 0]);
|
||||
for past in [
|
||||
[1 << 20, 2, 1],
|
||||
[65536, 1, 1],
|
||||
[1, 1, 65536],
|
||||
[1024, 1024, 1],
|
||||
] {
|
||||
let s = scan(&draw, &[9, 9, past[0], past[1], past[2]], 0, 0);
|
||||
assert_eq!(
|
||||
&s.work[work::HEADER as usize..][..3],
|
||||
&[0, 0, 0],
|
||||
"{past:?}"
|
||||
);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 0, "{past:?}");
|
||||
assert_eq!(
|
||||
header(&s.work, work::DISPATCH, 3),
|
||||
vec![0, 0, 1],
|
||||
"{past:?}"
|
||||
);
|
||||
}
|
||||
let s = scan(&draw, &[9, 9, 3, 2], 0, 0);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 0);
|
||||
}
|
||||
|
||||
/// A draw whose records the rest of the pool cannot hold draws nothing, keeps the cursor, sets
|
||||
/// the bit and names itself; a later fault leaves the first one's words.
|
||||
#[test]
|
||||
fn a_draw_the_pool_cannot_hold_draws_nothing_and_says_so() {
|
||||
let draw = Draw::of(&[[4, 1, 1], [3, 1, 1]]);
|
||||
let s = scan(&draw, &[0], 940, 0);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 0);
|
||||
assert_eq!(header(&s.work, work::DISPATCH, 3), vec![0, 0, 1]);
|
||||
assert_eq!(header(&s.work, work::DRAW, 4), vec![0, 1, 0, 0]);
|
||||
assert_eq!(s.cursor, 940);
|
||||
assert_eq!(
|
||||
s.report.mesh_records_overflow,
|
||||
Some(MeshRecordsFault {
|
||||
draw: 7,
|
||||
object_threadgroups: 2,
|
||||
mesh_threadgroups: 7,
|
||||
})
|
||||
);
|
||||
// Exactly the room left: drawn.
|
||||
let s = scan(&draw, &[0], 930, 0);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 7);
|
||||
assert_eq!(s.cursor, 1000);
|
||||
assert_eq!(s.report.mesh_records_overflow, None);
|
||||
// A later fault leaves the first one's words (here all zero).
|
||||
let s = scan(&draw, &[0], 940, StatusBits::MESH_RECORDS_OVERFLOW.0);
|
||||
assert_eq!(
|
||||
s.report.mesh_records_overflow,
|
||||
Some(MeshRecordsFault::default())
|
||||
);
|
||||
// Vertices past a `u32` draw nothing either.
|
||||
let mut wide = Draw::of(&[[1023, 1025, 1]]);
|
||||
wide.pool_words = u32::MAX;
|
||||
wide.group_words = 1;
|
||||
wide.group_vertices = 1 << 13;
|
||||
let s = scan(&wide, &[0], 0, 0);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 0);
|
||||
assert_eq!(
|
||||
s.report.mesh_records_overflow.map(|f| f.mesh_threadgroups),
|
||||
Some(1023 * 1025)
|
||||
);
|
||||
}
|
||||
|
||||
/// Slots in the records pool scan as slots in the work buffer do, and the offsets land after
|
||||
/// them there; the work buffer keeps its own words.
|
||||
#[test]
|
||||
fn the_scan_reads_slots_in_the_records_pool() {
|
||||
let grids = [[2, 1, 1], [0, 5, 1], [3, 2, 1], [1, 1, 1], [1, 65536, 1]];
|
||||
let mut draw = Draw::of(&grids);
|
||||
draw.pooled = Some(200);
|
||||
let s = scan(&draw, &[0], 300, 0);
|
||||
assert_eq!(offsets(&draw, &s), vec![0, 2, 2, 8, 9, 9]);
|
||||
assert_eq!(s.work[work::MESH_GROUPS as usize], 9);
|
||||
assert_eq!(s.work[work::RECORDS_BASE as usize], 300);
|
||||
assert_eq!(s.cursor, 300 + 9 * 10);
|
||||
assert_eq!(header(&s.work, work::DISPATCH, 3), vec![4, 3, 1]);
|
||||
assert_eq!(s.report, StatusReport::default());
|
||||
assert_eq!(&s.work[work::HEADER as usize..], &[0xEEEE_EEEE]);
|
||||
assert_eq!(&s.pool[200..][..3], &[2, 1, 1]);
|
||||
// Below the slots, the pool is as it was.
|
||||
assert!(s.pool[..200].iter().all(|&w| w == 0x5555_5555));
|
||||
}
|
||||
|
||||
/// An object arguments pass: Metal's arguments `arguments` at word `at` (0: none), slots of 6
|
||||
/// words, a pool of `pool_words` with its cursor at `cursor`, the status bits `bits`, and the
|
||||
/// device's `compute` limits.
|
||||
struct Arguments {
|
||||
arguments: Vec<u32>,
|
||||
at: u32,
|
||||
pool_words: u32,
|
||||
cursor: u32,
|
||||
bits: u32,
|
||||
compute: [u32; 3],
|
||||
}
|
||||
|
||||
impl Arguments {
|
||||
fn of(grid: [u32; 3]) -> Arguments {
|
||||
let mut arguments = vec![9];
|
||||
arguments.extend(grid);
|
||||
Arguments {
|
||||
arguments,
|
||||
at: 1,
|
||||
pool_words: 1000,
|
||||
cursor: 40,
|
||||
bits: 0,
|
||||
compute: [65535; 3],
|
||||
}
|
||||
}
|
||||
|
||||
/// The work words before the pass.
|
||||
fn work(&self) -> Vec<u32> {
|
||||
let mut w = vec![0xAAAA_AAAA; work::HEADER as usize + 1];
|
||||
w[work::OBJECT_ARGUMENTS as usize] = self.at + 1;
|
||||
w[work::SLOT_WORDS as usize] = 6;
|
||||
w[work::POOL_WORDS as usize] = self.pool_words;
|
||||
w[work::DRAW_ID as usize] = 7;
|
||||
w
|
||||
}
|
||||
|
||||
/// Run the pass; the work words, the status report and the pool's cursor after it.
|
||||
fn run(&self) -> Scanned {
|
||||
let module = object_arguments_typed_module(self.compute).expect("arguments");
|
||||
let mut status = [0u32; 8];
|
||||
status[StatusWord::Status.index() as usize] = self.bits;
|
||||
status[StatusWord::MeshRecordsCursor.index() as usize] = self.cursor;
|
||||
let pool = vec![0x5555_5555; 16];
|
||||
let res = Resources {
|
||||
buffers: vec![
|
||||
Buffer {
|
||||
slot: Some(WORK),
|
||||
address: None,
|
||||
bytes: bytes(&self.work()),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(ARGUMENTS),
|
||||
address: None,
|
||||
bytes: bytes(&self.arguments),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(STATUS),
|
||||
address: None,
|
||||
bytes: bytes(&status),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(RECORDS),
|
||||
address: None,
|
||||
bytes: bytes(&pool),
|
||||
},
|
||||
],
|
||||
push: Vec::new(),
|
||||
spec: Default::default(),
|
||||
};
|
||||
let after = run(&module, &Config::default(), res)
|
||||
.expect("arguments run")
|
||||
.buffers;
|
||||
let status_bytes: [u8; 32] = after[2].as_slice().try_into().expect("status");
|
||||
let status = words(&after[2]);
|
||||
Scanned {
|
||||
work: words(&after[0]),
|
||||
report: ExecutionStatus::decode(&status_bytes),
|
||||
cursor: status[StatusWord::MeshRecordsCursor.index() as usize],
|
||||
pool: words(&after[3]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The words a pass that runs nothing leaves: no object threadgroups, no slots, an empty
|
||||
/// dispatch, and the cursor where it was.
|
||||
fn runs_nothing(a: &Arguments, s: &Scanned) {
|
||||
assert_eq!(s.work[work::OBJECT_GROUPS as usize], 0);
|
||||
assert_eq!(s.work[work::SLOTS as usize], 0);
|
||||
assert_eq!(header(&s.work, work::OBJECT_DISPATCH, 3), vec![0, 0, 0]);
|
||||
assert_eq!(s.cursor, a.cursor);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_object_arguments_pass_is_valid_on_every_committed_profile() {
|
||||
for (_, p) in committed_profiles().expect("profiles") {
|
||||
let compute = p.fields().limits.max_compute_work_group_count;
|
||||
assert_valid(
|
||||
object_arguments_typed_module(compute).expect("arguments"),
|
||||
&p,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A grid that runs: its slots and offsets reserved after the cursor (`n · S + n + 1` words), the
|
||||
/// slots' first word plus 1, and the grid as the object dispatch; the pool is the scan's to write.
|
||||
#[test]
|
||||
fn the_object_arguments_pass_reserves_a_grids_slots() {
|
||||
let a = Arguments::of([3, 2, 2]);
|
||||
let s = a.run();
|
||||
assert_eq!(s.work[work::OBJECT_GROUPS as usize], 12);
|
||||
assert_eq!(s.work[work::SLOTS as usize], 41);
|
||||
assert_eq!(header(&s.work, work::OBJECT_DISPATCH, 3), vec![3, 2, 2]);
|
||||
assert_eq!(s.cursor, 40 + 12 * 6 + 13);
|
||||
assert_eq!(s.report, StatusReport::default());
|
||||
assert!(s.pool.iter().all(|&w| w == 0x5555_5555));
|
||||
// The arguments at another word, and exactly the room left.
|
||||
let mut a = Arguments::of([3, 2, 2]);
|
||||
a.arguments.insert(0, 1);
|
||||
a.at = 2;
|
||||
a.cursor = 1000 - 85;
|
||||
let s = a.run();
|
||||
assert_eq!(s.work[work::OBJECT_GROUPS as usize], 12);
|
||||
assert_eq!(s.cursor, 1000);
|
||||
assert_eq!(s.report, StatusReport::default());
|
||||
}
|
||||
|
||||
/// A grid with an axis of 0 runs nothing and says nothing, however large its other axes; so do
|
||||
/// arguments past the bound range.
|
||||
#[test]
|
||||
fn the_object_arguments_pass_runs_an_empty_grid_silently() {
|
||||
for grid in [[3, 0, 2], [0, 1, 1], [1 << 20, 1 << 20, 0]] {
|
||||
let a = Arguments::of(grid);
|
||||
let s = a.run();
|
||||
runs_nothing(&a, &s);
|
||||
assert_eq!(s.report, StatusReport::default(), "{grid:?}");
|
||||
}
|
||||
let mut a = Arguments::of([3, 2, 2]);
|
||||
a.arguments.pop();
|
||||
let s = a.run();
|
||||
runs_nothing(&a, &s);
|
||||
assert_eq!(s.report, StatusReport::default());
|
||||
}
|
||||
|
||||
/// More than 2^29 threadgroups in all (a wrapping product too): Metal discards the command
|
||||
/// buffer, so the pass runs nothing and sets the discard bit alone; exactly 2^29 runs.
|
||||
#[test]
|
||||
fn the_object_arguments_pass_discards_what_metal_discards() {
|
||||
for grid in [[1 << 15, 1 << 15, 1], [(1 << 29) + 1, 1, 1], [65535; 3]] {
|
||||
let mut a = Arguments::of(grid);
|
||||
a.compute = [u32::MAX; 3];
|
||||
let s = a.run();
|
||||
runs_nothing(&a, &s);
|
||||
assert!(s.report.mesh_grid_discarded, "{grid:?}");
|
||||
assert!(!s.report.mesh_grid_past_limits, "{grid:?}");
|
||||
assert_eq!(s.report.mesh_records_overflow, None, "{grid:?}");
|
||||
}
|
||||
let mut a = Arguments::of([1 << 29, 1, 1]);
|
||||
a.compute = [u32::MAX; 3];
|
||||
a.pool_words = u32::MAX;
|
||||
a.cursor = 0;
|
||||
let s = a.run();
|
||||
assert_eq!(s.work[work::OBJECT_GROUPS as usize], 1 << 29);
|
||||
assert_eq!(s.cursor, (1 << 29) * 7 + 1);
|
||||
assert_eq!(s.report, StatusReport::default());
|
||||
}
|
||||
|
||||
/// An axis past the device's compute limits runs nothing and sets the past-limits bit; a grid
|
||||
/// whose threads per grid wrap runs whole (the object function reports the wrapped grid).
|
||||
#[test]
|
||||
fn the_object_arguments_pass_holds_the_device_limits() {
|
||||
for (grid, compute) in [([65536, 1, 1], [65535; 3]), ([1, 1, 3], [65535, 65535, 2])] {
|
||||
let mut a = Arguments::of(grid);
|
||||
a.compute = compute;
|
||||
let s = a.run();
|
||||
runs_nothing(&a, &s);
|
||||
assert!(s.report.mesh_grid_past_limits, "{grid:?}");
|
||||
assert!(!s.report.mesh_grid_discarded, "{grid:?}");
|
||||
}
|
||||
for grid in [[1 << 22, 1, 1], [1, 1 << 23, 1], [65535, 1, 1]] {
|
||||
let mut a = Arguments::of(grid);
|
||||
a.compute = [u32::MAX; 3];
|
||||
a.pool_words = u32::MAX;
|
||||
let s = a.run();
|
||||
let n = grid.iter().product::<u32>();
|
||||
assert_eq!(s.work[work::OBJECT_GROUPS as usize], n, "{grid:?}");
|
||||
assert_eq!(header(&s.work, work::OBJECT_DISPATCH, 3), grid.to_vec());
|
||||
assert_eq!(s.report, StatusReport::default(), "{grid:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Slots the rest of the pool cannot hold: nothing runs, the cursor stays, and the first such
|
||||
/// draw names itself (no mesh threadgroups yet); a later fault leaves the first one's words.
|
||||
#[test]
|
||||
fn the_object_arguments_pass_says_when_the_pool_is_full() {
|
||||
let mut a = Arguments::of([3, 2, 2]);
|
||||
a.cursor = 1000 - 84;
|
||||
let s = a.run();
|
||||
runs_nothing(&a, &s);
|
||||
assert_eq!(
|
||||
s.report.mesh_records_overflow,
|
||||
Some(MeshRecordsFault {
|
||||
draw: 7,
|
||||
object_threadgroups: 12,
|
||||
mesh_threadgroups: 0,
|
||||
})
|
||||
);
|
||||
// A cursor already past the pool.
|
||||
a.cursor = 5000;
|
||||
let s = a.run();
|
||||
runs_nothing(&a, &s);
|
||||
assert!(s.report.mesh_records_overflow.is_some());
|
||||
a.bits = StatusBits::MESH_RECORDS_OVERFLOW.0;
|
||||
let s = a.run();
|
||||
assert_eq!(
|
||||
s.report.mesh_records_overflow,
|
||||
Some(MeshRecordsFault::default())
|
||||
);
|
||||
}
|
||||
|
||||
/// The pass, the object function's slots and the scan in turn: the scan places the threadgroups
|
||||
/// of the slots the pass reserved, after them in the pool.
|
||||
#[test]
|
||||
fn the_scan_places_the_grids_of_the_slots_the_pass_reserved() {
|
||||
let a = Arguments::of([2, 2, 1]);
|
||||
let s = a.run();
|
||||
let at = s.work[work::SLOTS as usize] - 1;
|
||||
let grids = [[2, 1, 1], [0, 5, 1], [3, 2, 1], [1, 1, 1]];
|
||||
let mut draw = Draw::of(&grids);
|
||||
draw.pooled = Some(at);
|
||||
let scanned = scan(&draw, &[0], s.cursor, 0);
|
||||
assert_eq!(offsets(&draw, &scanned), vec![0, 2, 2, 8, 9]);
|
||||
assert_eq!(scanned.work[work::RECORDS_BASE as usize], s.cursor);
|
||||
assert_eq!(scanned.cursor, s.cursor + 9 * 10);
|
||||
}
|
||||
@@ -105,7 +105,6 @@ pub(crate) mod index_rewrite;
|
||||
pub mod indirect_commands;
|
||||
pub(crate) mod instantiate;
|
||||
pub(crate) mod mesh_arguments;
|
||||
pub(crate) mod mesh_scan;
|
||||
pub(crate) mod neutral;
|
||||
pub(crate) mod plan;
|
||||
pub(crate) mod pvrtc_decode;
|
||||
@@ -142,10 +141,7 @@ pub use depth_stencil_copy::{
|
||||
};
|
||||
pub use dispatch::{Dispatch, DispatchCommands, DispatchRegion, IndirectArgs};
|
||||
pub use etc_decode::{EtcDecode, EtcTexels};
|
||||
pub use graphics::{
|
||||
alpha_test_code, DrawCall, DrawCommands, IndexOverrun, MeshDispatch, MeshGroups,
|
||||
MeshRecordsRegion,
|
||||
};
|
||||
pub use graphics::{alpha_test_code, DrawCall, DrawCommands, IndexOverrun};
|
||||
pub use heap::{
|
||||
handle_entry, handle_entry_flags, heap_classes, heap_element, heap_raw_form, HeapElement,
|
||||
HeapElements, HeapSource, HANDLE_ENTRY_BYTES, HANDLE_TABLE_CAPACITY, NEUTRAL_HEAP_ELEMENT,
|
||||
@@ -169,7 +165,6 @@ pub use mesh_arguments::{
|
||||
MeshArgumentsModule, MeshGridLimits, MeshGridRule, ObjectFold, METAL_MESH_GRID_AXIS,
|
||||
METAL_MESH_GRID_TOTAL, METAL_OBJECT_GRID_TOTAL,
|
||||
};
|
||||
pub use mesh_scan::{mesh_object_arguments_module, mesh_scan_module, MeshScanModule};
|
||||
pub use neutral::NeutralResource;
|
||||
pub use plan::resources::sampler_desc;
|
||||
pub use plan::{
|
||||
@@ -220,9 +215,7 @@ pub use sample_interleave::{
|
||||
pub use sample_planes::{
|
||||
planes_merge_modules, planes_split_module, PlanesCopy, PlanesMergeModules, PlanesSplitModule,
|
||||
};
|
||||
pub use status::{
|
||||
ExecutionStatus, MeshRecordsFault, ReplayFaults, StatusBits, StatusReport, StatusWord,
|
||||
};
|
||||
pub use status::{ExecutionStatus, ReplayFaults, StatusBits, StatusReport, StatusWord};
|
||||
pub use table::{FunctionTableSnapshot, FunctionTableWords};
|
||||
pub use texel_parts::{part_texels, texel_buffer_parts};
|
||||
pub use texel_rows::TexelRows;
|
||||
|
||||
@@ -259,8 +259,7 @@ pub(crate) struct MeshTemplate {
|
||||
/// Every `LocalSizeConstraint{multiple}` of the pipeline: a threadgroup of either stage must
|
||||
/// be whole subgroups of the flattened tier's size.
|
||||
pub multiples: Vec<u32>,
|
||||
/// The mesh stage's limits (`maxMeshWorkGroup*`; an emulated mesh function's are the
|
||||
/// compute stage's, `maxComputeWorkGroup*`).
|
||||
/// The mesh stage's limits (`maxMeshWorkGroup*`).
|
||||
pub mesh: GroupLimits,
|
||||
/// The task stage's limits (`maxTaskWorkGroup*`), of a pipeline with an object function.
|
||||
pub object: Option<GroupLimits>,
|
||||
@@ -274,10 +273,6 @@ pub(crate) struct MeshTemplate {
|
||||
/// draws it, its region flagged `lower::dispatch::NONUNIFORM`.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub partial_groups: bool,
|
||||
/// An emulated mesh function's records: each draw dispatches its mesh threadgroups and
|
||||
/// draws their primitives (`DrawCommands::mesh_dispatch`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub records: Option<RecordsTemplate>,
|
||||
}
|
||||
|
||||
/// A stage's threadgroup and grid limits.
|
||||
@@ -290,8 +285,8 @@ pub(crate) struct GroupLimits {
|
||||
pub invocations: u32,
|
||||
/// `max*WorkGroupCount`.
|
||||
pub count: [u32; 3],
|
||||
/// `max*WorkGroupTotalCount`; `None` for the compute stage, which has none.
|
||||
pub total: Option<u32>,
|
||||
/// `max*WorkGroupTotalCount`.
|
||||
pub total: u32,
|
||||
/// The stage the limits are of, which names them.
|
||||
pub stage: GroupStage,
|
||||
}
|
||||
@@ -304,30 +299,6 @@ pub(crate) enum GroupStage {
|
||||
Task,
|
||||
/// A mesh function's (`MESH_EXT`).
|
||||
Mesh,
|
||||
/// An emulated mesh function's (`COMPUTE`).
|
||||
Compute,
|
||||
}
|
||||
|
||||
/// What a draw of an emulated mesh function's pipeline sizes from its grid
|
||||
/// (`DrawCommands::mesh_dispatch`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub(crate) struct RecordsTemplate {
|
||||
/// The words of one threadgroup's records (`MeshRecords::group_words`).
|
||||
pub group_words: u64,
|
||||
/// The vertices of one threadgroup's primitives in the draw: `NP · k`.
|
||||
pub group_vertices: u32,
|
||||
/// The device's `maxStorageBufferRange`, past which a draw's records or work buffer cannot
|
||||
/// be bound.
|
||||
pub max_range: u32,
|
||||
/// The words of an object threadgroup's slot in the work buffer (`MeshRecords::slot_words`).
|
||||
pub slot_words: u32,
|
||||
/// `maxComputeWorkGroupCount[0]`, the mesh dispatch's rows.
|
||||
pub row: u32,
|
||||
/// `maxComputeWorkGroupCount[1]`, its most rows.
|
||||
pub rows: u32,
|
||||
/// `minStorageBufferOffsetAlignment`, to which the scan's arguments range is aligned.
|
||||
pub alignment: u64,
|
||||
}
|
||||
|
||||
/// What a draw of a pipeline whose fragment function runs the draw's depth test itself
|
||||
@@ -822,15 +793,6 @@ pub enum WriteSource {
|
||||
/// stand when the command runs, which differs only for a CPU write racing the GPU. The
|
||||
/// stage's directory gives each listed id its record's offset, by the same sizes.
|
||||
FunctionTableSnapshot,
|
||||
/// An emulated mesh function's records (`SyntheticBinding::MeshRecords`): the draw's
|
||||
/// `MeshDispatch::records`, a region of its own or the command buffer's records pool, which
|
||||
/// the consumer binds whole for the mesh dispatch and the draw alike
|
||||
/// ([`MeshDispatch`](crate::bind::MeshDispatch)).
|
||||
MeshRecords,
|
||||
/// An emulated mesh draw's work buffer (`SyntheticBinding::MeshWork`, the object and mesh
|
||||
/// stages' alike): the draw's region of `MeshDispatch::work_bytes`, holding
|
||||
/// `MeshDispatch::work`, bound whole ([`MeshDispatch`](crate::bind::MeshDispatch)).
|
||||
MeshWork,
|
||||
/// The command buffer's execution status (`SyntheticBinding::ExecutionStatus`) of a stage on
|
||||
/// a device that does not address buffers: a storage buffer of the
|
||||
/// [`ExecutionStatus`](crate::bind::ExecutionStatus) words, the same buffer every command of
|
||||
|
||||
@@ -56,8 +56,6 @@ pub enum DrawReplayRule {
|
||||
ArgumentsOnCpu,
|
||||
/// The state's draw bounds its indices.
|
||||
IndexBounds,
|
||||
/// The state's draw dispatches before it draws (an emulated mesh draw's dispatch).
|
||||
DispatchesFirst,
|
||||
/// The state's draw is amplified or draws views.
|
||||
Amplified,
|
||||
/// The state's vertex function fetches attributes of a layout whose stride is set per bind
|
||||
@@ -118,9 +116,6 @@ impl fmt::Display for DrawReplayRule {
|
||||
"the inherited state's indirect draw needs its arguments on the CPU"
|
||||
}
|
||||
DrawReplayRule::IndexBounds => "the inherited state's draw bounds its indices",
|
||||
DrawReplayRule::DispatchesFirst => {
|
||||
"the inherited state's draw dispatches before it draws"
|
||||
}
|
||||
DrawReplayRule::Amplified => "the inherited state's draw is amplified or draws views",
|
||||
DrawReplayRule::VertexAttributes => {
|
||||
"the inherited state's vertex function fetches attributes at a stride set per bind"
|
||||
@@ -286,10 +281,6 @@ pub fn draw_replay_draw(
|
||||
DrawReplayRule::ArgumentsOnCpu,
|
||||
),
|
||||
(commands.index_bounds_pass, DrawReplayRule::IndexBounds),
|
||||
(
|
||||
commands.mesh_dispatch.is_some(),
|
||||
DrawReplayRule::DispatchesFirst,
|
||||
),
|
||||
(
|
||||
!commands.amplifications.is_empty() || plan.views != ViewSetup::default(),
|
||||
DrawReplayRule::Amplified,
|
||||
|
||||
@@ -253,14 +253,6 @@ pub struct BindState {
|
||||
/// `VariantKey::rotated_weights`). Part of the shape; `false` for every other draw.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub rotated_weights: bool,
|
||||
/// Whether a mesh draw of an emulated mesh function's pipeline draws each line or triangle
|
||||
/// from its last index first: a draw under Apple's last provoking vertex
|
||||
/// (`setProvokingVertexMode:` 1) on a device that takes flat inputs from the first vertex.
|
||||
/// Its pipeline runs the variant whose synthesized vertex stage reads its corners so
|
||||
/// (`BindShape::mesh_last_first`, `VariantKey::mesh_last_first`). Part of the shape; `false`
|
||||
/// for every other draw.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub mesh_last_first: bool,
|
||||
/// What the draw draws as bands of triangles, where it draws its lines or its triangles'
|
||||
/// edges so, and its band (`PushField::LineBand`): `[sx, sy, h, f]`, the half extent of its
|
||||
/// Vulkan viewport 0 (its height negative, as the viewport is), half the band's width in
|
||||
@@ -646,7 +638,6 @@ impl BindState {
|
||||
kept_imageblock_bytes: self.kept_imageblock_bytes,
|
||||
depth_clamp_range: self.depth_clamp_range.is_some(),
|
||||
rotated_weights: self.rotated_weights,
|
||||
mesh_last_first: self.mesh_last_first,
|
||||
line_band: self.line_band.map(|(primitive, _)| primitive),
|
||||
interlocked_colors: self.interlocked_colors.clone(),
|
||||
fragment_tests: self.fragment_tests,
|
||||
@@ -734,7 +725,6 @@ impl BindState {
|
||||
kept_imageblock_bytes,
|
||||
depth_clamp_range,
|
||||
rotated_weights,
|
||||
mesh_last_first,
|
||||
line_band,
|
||||
interlocked_colors,
|
||||
fragment_tests,
|
||||
@@ -765,7 +755,6 @@ impl BindState {
|
||||
&& self.kept_imageblock_bytes == *kept_imageblock_bytes
|
||||
&& self.depth_clamp_range.is_some() == *depth_clamp_range
|
||||
&& self.rotated_weights == *rotated_weights
|
||||
&& self.mesh_last_first == *mesh_last_first
|
||||
&& self.line_band.map(|(primitive, _)| primitive) == *line_band
|
||||
&& self.interlocked_colors == *interlocked_colors
|
||||
&& self.fragment_tests == *fragment_tests
|
||||
@@ -1731,11 +1720,6 @@ pub struct BindShape {
|
||||
/// (`VariantKey::rotated_weights`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub rotated_weights: bool,
|
||||
/// `BindState.mesh_last_first`: the variant whose emulated mesh pipeline's synthesized
|
||||
/// vertex stage draws each line or triangle from its last index first
|
||||
/// (`VariantKey::mesh_last_first`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub mesh_last_first: bool,
|
||||
/// What `BindState.line_band` draws as bands: the variant that draws its lines, or its
|
||||
/// triangles' edges, so (`VariantKey::line_band`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
//! with [`ExecutionStatus::initial`] before the command buffer's first use and reads it back with
|
||||
//! [`ExecutionStatus::decode`] after the last one (a `SHADER_WRITE -> HOST_READ` barrier first);
|
||||
//! the resident-set miss counter, the device replay's preprocess, the index
|
||||
//! bounds pass, an absent argument's read, the mesh scans, a sample through a
|
||||
//! cubic argument sampler, and a sequentially consistent fence write the words
|
||||
//! named here.
|
||||
//! bounds pass, an absent argument's read, a mesh draw's arguments pass, a sample
|
||||
//! through a cubic argument sampler, and a sequentially consistent fence write the
|
||||
//! words named here. Words 3 to 6 are not written.
|
||||
|
||||
/// The `ExecutionStatus` buffer.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
@@ -15,7 +15,7 @@ pub struct ExecutionStatus;
|
||||
impl ExecutionStatus {
|
||||
/// Size of the buffer in bytes.
|
||||
pub const BYTES: usize = 32;
|
||||
/// Size of the buffer in 32-bit words: [`StatusWord::ALL`].
|
||||
/// Size of the buffer in 32-bit words: up to the last of [`StatusWord::ALL`].
|
||||
pub const WORDS: usize = 8;
|
||||
|
||||
/// The buffer's initial bytes: every word 0.
|
||||
@@ -24,8 +24,8 @@ impl ExecutionStatus {
|
||||
}
|
||||
|
||||
/// What the buffer's bytes report after the command buffer ran. The consumer maps a replay
|
||||
/// fault, an index pool overflow, an absent argument read, a mesh records fault, a mesh
|
||||
/// grid Metal's GPU discards or the device cannot launch, and a cubic argument sampler's sample
|
||||
/// fault, an index pool overflow, an absent argument read, a mesh grid Metal's GPU
|
||||
/// discards or the device cannot launch, and a cubic argument sampler's sample
|
||||
/// to a command-buffer execution error, and treats resident-set misses by its own policy.
|
||||
pub fn decode(bytes: &[u8; ExecutionStatus::BYTES]) -> StatusReport {
|
||||
let word = |w: StatusWord| {
|
||||
@@ -43,13 +43,6 @@ impl ExecutionStatus {
|
||||
cubic_argument_sampler: bits.contains(StatusBits::CUBIC_ARGUMENT_SAMPLER),
|
||||
mesh_grid_discarded: bits.contains(StatusBits::MESH_GRID_DISCARDED),
|
||||
mesh_grid_past_limits: bits.contains(StatusBits::MESH_GRID_PAST_LIMITS),
|
||||
mesh_records_overflow: (bits.contains(StatusBits::MESH_RECORDS_OVERFLOW)).then(|| {
|
||||
MeshRecordsFault {
|
||||
draw: word(StatusWord::MeshFaultDraw),
|
||||
object_threadgroups: word(StatusWord::MeshFaultObjects),
|
||||
mesh_threadgroups: word(StatusWord::MeshFaultGroups),
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,40 +68,18 @@ pub struct StatusReport {
|
||||
/// no value (`RuntimeFact::AbsentArgumentRead`): the read yielded zero, so no result of the
|
||||
/// command buffer is Metal's.
|
||||
pub absent_argument_read: bool,
|
||||
/// A mesh scan found no room in the command buffer's records pool for an emulated mesh
|
||||
/// draw's records, or the draw's vertices passed a `u32` (`bind::MeshScanModule`), or an
|
||||
/// object arguments pass none for an emulated indirect draw's object slots
|
||||
/// (`bind::mesh_object_arguments_module`, no mesh threadgroups yet): such draws drew nothing.
|
||||
/// The command buffer's first one, as the pass saw it.
|
||||
pub mesh_records_overflow: Option<MeshRecordsFault>,
|
||||
/// A function sampled through an argument buffer's sampler whose min or mag filter is
|
||||
/// `Cubic`, whose bicubic filter it does not emulate there
|
||||
/// (`RuntimeFact::CubicArgumentSampler`): no result of the command buffer is then Metal's.
|
||||
pub cubic_argument_sampler: bool,
|
||||
/// An indirect mesh draw's arguments pass (or an emulated one's object arguments pass) met an
|
||||
/// object grid that Metal's GPU discards (`StatusBits::MESH_GRID_DISCARDED`): that draw drew
|
||||
/// An indirect mesh draw's arguments pass met an object grid that Metal's GPU discards (`StatusBits::MESH_GRID_DISCARDED`): that draw drew
|
||||
/// nothing, and the command buffer fails as Metal's does (`MTLCommandBufferErrorInternal`).
|
||||
pub mesh_grid_discarded: bool,
|
||||
/// An indirect mesh draw's arguments pass (or an emulated one's object arguments pass) met a
|
||||
/// grid that Metal draws and the device cannot launch (`StatusBits::MESH_GRID_PAST_LIMITS`):
|
||||
/// An indirect mesh draw's arguments pass met a grid that Metal draws and the device cannot launch (`StatusBits::MESH_GRID_PAST_LIMITS`):
|
||||
/// that draw drew nothing, and the command buffer fails (not Metal's failure).
|
||||
pub mesh_grid_past_limits: bool,
|
||||
}
|
||||
|
||||
/// The first emulated mesh draw of a command buffer that drew nothing because its records did
|
||||
/// not fit (`StatusReport::mesh_records_overflow`).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
pub struct MeshRecordsFault {
|
||||
/// The consumer's number for the draw (the work buffer's `DRAW_ID` word).
|
||||
pub draw: u32,
|
||||
/// The draw's object threadgroups (1 without an object function).
|
||||
pub object_threadgroups: u32,
|
||||
/// The mesh threadgroups the draw's object threadgroups launched, saturated at `u32::MAX`; 0
|
||||
/// where its object slots did not fit, before any launched.
|
||||
pub mesh_threadgroups: u32,
|
||||
}
|
||||
|
||||
/// A word of the `ExecutionStatus` buffer.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
@@ -119,16 +90,6 @@ pub enum StatusWord {
|
||||
ResidentMisses,
|
||||
/// The device replay's fault reasons ([`ReplayFaults`]). Initial 0.
|
||||
ReplayFaults,
|
||||
/// The words of the command buffer's mesh records pool its scans reserved
|
||||
/// (`bind::MeshScanModule`). Initial 0.
|
||||
MeshRecordsCursor,
|
||||
/// The consumer's number for the command buffer's first emulated mesh draw whose records did
|
||||
/// not fit ([`StatusBits::MESH_RECORDS_OVERFLOW`]). Initial 0.
|
||||
MeshFaultDraw,
|
||||
/// That draw's object threadgroups. Initial 0.
|
||||
MeshFaultObjects,
|
||||
/// The mesh threadgroups that draw needed, saturated. Initial 0.
|
||||
MeshFaultGroups,
|
||||
/// The word every sequentially consistent fence of the command buffer increments with an
|
||||
/// acquire-release atomic at the fence's scope (`lower::sync::barrier::seq_cst_order`), so
|
||||
/// that the fences of one command buffer are totally ordered, as Metal's are. Its value means
|
||||
@@ -138,14 +99,10 @@ pub enum StatusWord {
|
||||
|
||||
impl StatusWord {
|
||||
/// Every word, in index order.
|
||||
pub const ALL: [StatusWord; 8] = [
|
||||
pub const ALL: [StatusWord; 4] = [
|
||||
StatusWord::Status,
|
||||
StatusWord::ResidentMisses,
|
||||
StatusWord::ReplayFaults,
|
||||
StatusWord::MeshRecordsCursor,
|
||||
StatusWord::MeshFaultDraw,
|
||||
StatusWord::MeshFaultObjects,
|
||||
StatusWord::MeshFaultGroups,
|
||||
StatusWord::SeqCstFences,
|
||||
];
|
||||
|
||||
@@ -155,10 +112,7 @@ impl StatusWord {
|
||||
StatusWord::Status => 0,
|
||||
StatusWord::ResidentMisses => 1,
|
||||
StatusWord::ReplayFaults => 2,
|
||||
StatusWord::MeshRecordsCursor => 3,
|
||||
StatusWord::MeshFaultDraw => 4,
|
||||
StatusWord::MeshFaultObjects => 5,
|
||||
StatusWord::MeshFaultGroups => 6,
|
||||
// Words 3 to 6 are not written.
|
||||
StatusWord::SeqCstFences => 7,
|
||||
}
|
||||
}
|
||||
@@ -184,12 +138,8 @@ impl StatusBits {
|
||||
/// A function read an argument its pipeline's function constants removed, a read Metal
|
||||
/// gives no value, and took zero for it (`RuntimeFact::AbsentArgumentRead`).
|
||||
pub const ABSENT_ARGUMENT_READ: StatusBits = StatusBits(1 << 4);
|
||||
/// A mesh scan found no room in the command buffer's records pool for an emulated mesh
|
||||
/// draw's records, or the draw's vertices passed a `u32`, or an object arguments pass none for
|
||||
/// an emulated indirect draw's object slots, and the draw drew nothing
|
||||
/// (`bind::MeshScanModule`, `bind::mesh_object_arguments_module`); the fault words name the
|
||||
/// command buffer's first such draw.
|
||||
pub const MESH_RECORDS_OVERFLOW: StatusBits = StatusBits(1 << 5);
|
||||
// Bit 5 (an emulated mesh draw's records fault) is not reported: a device without
|
||||
// `meshShader` refuses the pipeline.
|
||||
/// A function sampled, gathered, or queried through a sampler an argument buffer holds whose
|
||||
/// min or mag filter is `Cubic`, whose bicubic filter it does not emulate there
|
||||
/// (`RuntimeFact::CubicArgumentSampler`): its result is the device's through a nearest
|
||||
@@ -200,15 +150,11 @@ impl StatusBits {
|
||||
/// An indirect mesh draw's arguments pass met a grid that Metal draws and the device cannot
|
||||
/// launch: a mesh grid past the mesh stage's limits, an unfolded object grid past the task
|
||||
/// stage's, or a folded one of more pieces than `MeshArguments::OBJECT_PIECES` (only under task
|
||||
/// limits below Vulkan's required least); or an emulated indirect draw's object arguments pass
|
||||
/// met an object grid past the device's compute limits (`bind::mesh_object_arguments_module`);
|
||||
/// the draw drew nothing
|
||||
/// (`bind::MeshArguments`).
|
||||
/// limits below Vulkan's required least); the draw drew nothing (`bind::MeshArguments`).
|
||||
pub const MESH_GRID_PAST_LIMITS: StatusBits = StatusBits(1 << 9);
|
||||
/// An indirect mesh draw's arguments pass met an object grid of more threadgroups than
|
||||
/// `bind::METAL_OBJECT_GRID_TOTAL`, which Metal's GPU discards (or an emulated draw's object
|
||||
/// arguments pass did); the draw drew nothing (`bind::MeshArguments`,
|
||||
/// `bind::mesh_object_arguments_module`).
|
||||
/// `bind::METAL_OBJECT_GRID_TOTAL`, which Metal's GPU discards; the draw drew nothing
|
||||
/// (`bind::MeshArguments`).
|
||||
pub const MESH_GRID_DISCARDED: StatusBits = StatusBits(1 << 10);
|
||||
/// Every bit in `other` is set in `self`.
|
||||
pub const fn contains(self, other: StatusBits) -> bool {
|
||||
@@ -286,9 +232,13 @@ mod tests {
|
||||
#[test]
|
||||
fn words_are_distinct_and_inside_the_buffer() {
|
||||
for (i, w) in StatusWord::ALL.iter().enumerate() {
|
||||
assert_eq!(w.index() as usize, i, "{w:?}");
|
||||
if let Some(next) = StatusWord::ALL.get(i + 1) {
|
||||
assert!(w.index() < next.index(), "{w:?}");
|
||||
}
|
||||
assert!((w.byte_offset() as usize) + 4 <= ExecutionStatus::BYTES);
|
||||
}
|
||||
let last = StatusWord::ALL[StatusWord::ALL.len() - 1];
|
||||
assert_eq!(last.index() as usize + 1, ExecutionStatus::WORDS);
|
||||
assert_eq!(ExecutionStatus::WORDS * 4, ExecutionStatus::BYTES);
|
||||
}
|
||||
|
||||
@@ -299,8 +249,9 @@ mod tests {
|
||||
StatusBits::REPLAY_FAULT,
|
||||
StatusBits::INDEX_POOL_OVERFLOW,
|
||||
StatusBits::ABSENT_ARGUMENT_READ,
|
||||
StatusBits::MESH_RECORDS_OVERFLOW,
|
||||
StatusBits::CUBIC_ARGUMENT_SAMPLER,
|
||||
StatusBits::MESH_GRID_PAST_LIMITS,
|
||||
StatusBits::MESH_GRID_DISCARDED,
|
||||
];
|
||||
let mut all = 0u32;
|
||||
for b in bits {
|
||||
@@ -358,23 +309,6 @@ mod tests {
|
||||
let c = ExecutionStatus::decode(&cubic);
|
||||
assert!(c.cubic_argument_sampler && !c.absent_argument_read);
|
||||
assert!(r.absent_argument_read && !r.index_pool_overflow);
|
||||
assert_eq!(r.mesh_records_overflow, None);
|
||||
bytes = [0u8; 32];
|
||||
bytes[0..4].copy_from_slice(&StatusBits::MESH_RECORDS_OVERFLOW.0.to_le_bytes());
|
||||
bytes[12..16].copy_from_slice(&40u32.to_le_bytes());
|
||||
bytes[16..20].copy_from_slice(&3u32.to_le_bytes());
|
||||
bytes[20..24].copy_from_slice(&2u32.to_le_bytes());
|
||||
bytes[24..28].copy_from_slice(&u32::MAX.to_le_bytes());
|
||||
let r = ExecutionStatus::decode(&bytes);
|
||||
assert_eq!(
|
||||
r.mesh_records_overflow,
|
||||
Some(MeshRecordsFault {
|
||||
draw: 3,
|
||||
object_threadgroups: 2,
|
||||
mesh_threadgroups: u32::MAX,
|
||||
})
|
||||
);
|
||||
assert!(!r.index_pool_overflow);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+6
-16
@@ -47,10 +47,10 @@ use crate::pipeline::graphics::{
|
||||
};
|
||||
use crate::pipeline::interface::{
|
||||
AccessSet, BufferForm, BufferKind, BufferSlot, CommandWrites, DescriptorView, LevelReads,
|
||||
MeshRecords, NumberedSampler, PatchDomain, PipelineInterface, PlacedField, PushLoc,
|
||||
PushPlacement, RecordField, RecordValue, SampledLevels, SamplerArray, SamplerSlot,
|
||||
SlotInterface, SnapshotRefusal, StageDescriptor, StageInterface, StageSpec, TessellationStage,
|
||||
TextureAccess, TextureSlot, ThreadgroupArgument, Window,
|
||||
NumberedSampler, PatchDomain, PipelineInterface, PlacedField, PushLoc, PushPlacement,
|
||||
SampledLevels, SamplerArray, SamplerSlot, SlotInterface, SnapshotRefusal, StageDescriptor,
|
||||
StageInterface, StageSpec, TessellationStage, TextureAccess, TextureSlot, ThreadgroupArgument,
|
||||
Window,
|
||||
};
|
||||
use crate::pipeline::layout::{
|
||||
BindingSource, DescriptorBinding, DescriptorSetLayout, PipelineLayout, PushConstantRange,
|
||||
@@ -858,8 +858,6 @@ codec_enum! {
|
||||
ControlPointIndices,
|
||||
TileMemory,
|
||||
FunctionTableSnapshot,
|
||||
MeshRecords,
|
||||
MeshWork,
|
||||
DepthStandIn,
|
||||
StencilStandIn,
|
||||
}
|
||||
@@ -1139,9 +1137,7 @@ codec_struct! {
|
||||
CommandWrites { operations, primitive_types, kinds }
|
||||
StageInterface {
|
||||
stage, slots, threadgroup, push, descriptors, spec, needs_pointer_translation,
|
||||
needs_handle_translation, io, tessellation, writes_memory, mesh_records, mesh_corners,
|
||||
emulated_payload,
|
||||
payload, reaches_command_buffers, command_writes, writes_textures,
|
||||
needs_handle_translation, io, tessellation, writes_memory, payload, reaches_command_buffers, command_writes, writes_textures,
|
||||
reads_unbound_resources, writes_unbound_resources, unbound_storage_textures,
|
||||
numbered_samplers, own_pixel_textures, snapshot_textures, snapshot_refusals, level_reads,
|
||||
private_bytes, sampler_arrays,
|
||||
@@ -1154,8 +1150,6 @@ codec_struct! {
|
||||
max_tessellation_factor, partition_mode, factor_format, factor_step_function,
|
||||
output_winding_order, control_point_index_type, factor_scale_enabled,
|
||||
}
|
||||
MeshRecords { vertices, primitives, corners, vertex_words, primitive_words, fields, slot_words }
|
||||
RecordField { value, per_primitive, offset, words, numeric }
|
||||
BufferSlot { access, window, form, kind }
|
||||
TextureSlot { texture_type, sampled_type, depth_compare, access, storage }
|
||||
TextureAccess { sample, read, write }
|
||||
@@ -1197,9 +1191,6 @@ codec_enum! {
|
||||
WritesMemory, Interlock, Coherent, Other,
|
||||
}
|
||||
PatchDomain { Triangle, Quad }
|
||||
RecordValue {
|
||||
Position, PointSize, ClipDistance, Culled, Layer, ViewportIndex, Varying(f0),
|
||||
}
|
||||
Window { Bounded { start, len }, Whole }
|
||||
BufferForm { Descriptor(f0), Psb }
|
||||
BufferKind { Buffer, VisibleFunctionTable, IntersectionFunctionTable }
|
||||
@@ -1292,7 +1283,6 @@ codec_enum! {
|
||||
DroppedColor { color },
|
||||
DepthClampRange,
|
||||
RotatedWeights,
|
||||
MeshLastFirst,
|
||||
ConstantLanes { slot },
|
||||
FunctionTableRange { addressed },
|
||||
TestedStorageWrites { early_tests, early_variant },
|
||||
@@ -1425,7 +1415,7 @@ codec_struct! {
|
||||
rasterization_order_attachment_access, max_vertex_amplification_count, declares_layer,
|
||||
tessellation,
|
||||
fragment_imageblock, sample_shading, vertex_writes_memory, writes_viewport_index,
|
||||
storage_attachments, shadow_stencil, early_fragment_tests, mesh_records, mesh_corners,
|
||||
storage_attachments, shadow_stencil, early_fragment_tests,
|
||||
writes_point_size, flat_fragment_inputs,
|
||||
clip_distances, writes_depth, reads_barycentric_coord, reads_primitive_id,
|
||||
reads_position_depth,
|
||||
|
||||
Vendored
+2
-10
@@ -61,7 +61,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2220;
|
||||
pub const SEMANTICS_VERSION: u32 = 2221;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
@@ -71,7 +71,7 @@ pub const SEMANTICS_VERSION: u32 = 2220;
|
||||
/// re-typed in an encoded type, its `codec` body or its `envelope`. A variant removed while its tag
|
||||
/// stays unused needs no bump: an entry holding it fails to decode, which is a miss. The commit that
|
||||
/// bumps it says what changed; this comment keeps no history.
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 564;
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 565;
|
||||
|
||||
/// The version of what this crate's runtime does with a compiled pipeline: instantiating a binding
|
||||
/// plan (`BindingPlan::instantiate_*`: descriptor ranges, push bytes, root, argument, and handle
|
||||
@@ -357,13 +357,6 @@ pub struct VariantKey {
|
||||
/// it states it.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub rotated_weights: bool,
|
||||
/// The synthesized vertex stage of an emulated mesh function's pipeline draws each line or
|
||||
/// triangle from its last index first (`BindShape::mesh_last_first`): the variant a mesh draw
|
||||
/// under Apple's last provoking vertex runs on a device that takes flat inputs from the
|
||||
/// first (`pipeline::link::mesh`). The plan of a pipeline compiled under it states it
|
||||
/// (`RuntimeFact::MeshLastFirst`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub mesh_last_first: bool,
|
||||
/// The pipeline draws its lines, or its triangles' edges, as bands of triangles through
|
||||
/// synthesized tessellation stages, each patch one primitive of this kind
|
||||
/// (`BindShape::line_band`, `pipeline::link::band`): the variant a draw of lines, or of
|
||||
@@ -613,7 +606,6 @@ impl VariantKey {
|
||||
&& self.kept_imageblock_bytes.is_none()
|
||||
&& !self.depth_clamp_range
|
||||
&& !self.rotated_weights
|
||||
&& !self.mesh_last_first
|
||||
&& self.line_band.is_none()
|
||||
&& self.swizzled_storage.is_empty()
|
||||
&& !self.addressed_function_tables
|
||||
|
||||
@@ -205,7 +205,6 @@ pub fn mechanism(fact: &RuntimeFact, profile: &DeviceProfile) -> Mechanism {
|
||||
RuntimeFact::DepthClampRange => Mechanism::Variant,
|
||||
RuntimeFact::RotatedWeights => Mechanism::Variant,
|
||||
// A separate link of the mesh pipeline's synthesized vertex stage.
|
||||
RuntimeFact::MeshLastFirst => Mechanism::Variant,
|
||||
// The binder's region flags a draw whose last object threadgroup along an axis is partial.
|
||||
RuntimeFact::PartialObjectThreadgroups => Mechanism::RegionSelected,
|
||||
// The binder specializes the lanes from the bound texture's pixel format and swizzle.
|
||||
|
||||
@@ -169,7 +169,6 @@ fn every_fact() -> Vec<RuntimeFact> {
|
||||
device: true,
|
||||
},
|
||||
RuntimeFact::TexelRows { slot },
|
||||
RuntimeFact::MeshLastFirst,
|
||||
RuntimeFact::AbsentArgumentRead {
|
||||
stage: Stage::Fragment,
|
||||
},
|
||||
@@ -387,7 +386,6 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
RuntimeFact::QuadPrimitiveIds => 58,
|
||||
RuntimeFact::RotatedWeights => 82,
|
||||
RuntimeFact::PrivateList => 86,
|
||||
RuntimeFact::MeshLastFirst => 71,
|
||||
RuntimeFact::YCbCrInPlace { .. } => 65,
|
||||
RuntimeFact::PartialObjectThreadgroups => 89,
|
||||
RuntimeFact::RotatedInputBlend { .. } => 90,
|
||||
@@ -404,7 +402,7 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
RuntimeFact::UnitAxes { .. } => 101,
|
||||
RuntimeFact::TexelBufferParts { .. } => 102,
|
||||
RuntimeFact::OpenClLineTexture { .. } => 103,
|
||||
RuntimeFact::AddressAlignment { .. } => 104,
|
||||
RuntimeFact::AddressAlignment { .. } => 71,
|
||||
RuntimeFact::GridTiles => 55,
|
||||
}
|
||||
}
|
||||
@@ -413,7 +411,7 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
let facts = every_fact();
|
||||
let covered: std::collections::BTreeSet<usize> = facts.iter().map(variant).collect();
|
||||
assert_eq!(covered, (0..105).collect(), "every_fact misses a variant");
|
||||
assert_eq!(covered, (0..104).collect(), "every_fact misses a variant");
|
||||
for (stem, _) in super::committed_profiles() {
|
||||
let dev = device(&stem);
|
||||
let p = dev.profile();
|
||||
@@ -498,7 +496,6 @@ fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
| RuntimeFact::DroppedColor { .. }
|
||||
| RuntimeFact::DepthClampRange
|
||||
| RuntimeFact::RotatedWeights
|
||||
| RuntimeFact::MeshLastFirst
|
||||
| RuntimeFact::TestedStorageWrites { .. }
|
||||
| RuntimeFact::MovableStorageWrites { .. }
|
||||
| RuntimeFact::ConstexprSampled { .. }
|
||||
|
||||
@@ -1117,11 +1117,7 @@ pub fn declare(mb: &mut ModuleBuilder, plan: &Plan) -> BResult<LocalDecl> {
|
||||
None => None,
|
||||
},
|
||||
payload: match p.payload {
|
||||
Some(size) => Some(arena::declare_payload(
|
||||
mb,
|
||||
size,
|
||||
plan.families.mesh.emulated,
|
||||
)?),
|
||||
Some(size) => Some(arena::declare_payload(mb, size)?),
|
||||
None => None,
|
||||
},
|
||||
typed,
|
||||
|
||||
@@ -508,10 +508,6 @@ pub struct DispatchPlan {
|
||||
/// threadgroups, so its threadgroup's number adds `DrawIndex · nx · ny · nz`
|
||||
/// ([`KernelDecl::folded`]).
|
||||
pub draw_pieces: bool,
|
||||
/// The kernel's threadgroup position and grid are what its entry wrapper computes, not its
|
||||
/// dispatch's: an emulated mesh function under an object function, whose flat dispatch runs
|
||||
/// every object threadgroup's mesh grid ([`WrapperGroups`]).
|
||||
pub wrapper_groups: bool,
|
||||
/// An unfolded object function: its single-region `threadgroups_per_grid` is Metal's object
|
||||
/// grid's, the threadgroups its threads per grid fill once each axis wraps at 2^32
|
||||
/// (`bind::metal_object_grid`, measured): `⌈(NumWorkgroups · L mod 2^32) / L⌉`, which is
|
||||
@@ -659,10 +655,9 @@ pub fn plan_kernel(cx: &mut SelectCx<'_>, tier: Tier) -> Result<DispatchPlan, Er
|
||||
builtins.insert(b);
|
||||
}
|
||||
}
|
||||
// An object or mesh function's wrapper reads its thread and its threadgroup's threads, an
|
||||
// emulated mesh function's its threadgroup's place in the grid.
|
||||
// An object or mesh function's wrapper reads its thread and its threadgroup's threads.
|
||||
if crate::lower::mesh::wraps(&cx.families.mesh) {
|
||||
for &b in crate::lower::mesh::builtins(&cx.families.mesh) {
|
||||
for b in crate::lower::mesh::BUILTINS {
|
||||
builtins.insert(b);
|
||||
}
|
||||
}
|
||||
@@ -744,7 +739,6 @@ pub fn plan_kernel(cx: &mut SelectCx<'_>, tier: Tier) -> Result<DispatchPlan, Er
|
||||
keys: SpecKey::dispatch_keys(cx.stage),
|
||||
folded_groups,
|
||||
draw_pieces: folded_groups && cx.stage == crate::pipeline::sym::Stage::Object,
|
||||
wrapper_groups: crate::lower::mesh::wrapper_groups(&cx.families.mesh),
|
||||
object_grid: !folded_groups && cx.stage == crate::pipeline::sym::Stage::Object,
|
||||
partial_groups,
|
||||
grid_edge,
|
||||
@@ -1000,9 +994,6 @@ pub struct KernelDecl {
|
||||
subgroup_local: Option<GlobalId>,
|
||||
/// The subgroup size the pipeline pins ([`DispatchPlan::pinned_subgroup_size`]).
|
||||
pinned_subgroup_size: Option<u32>,
|
||||
/// The words the entry wrapper stores the threadgroup's position and grid into
|
||||
/// ([`DispatchPlan::wrapper_groups`]), with the dispatch's own builtins it reads.
|
||||
wrapper: Option<WrapperGroups>,
|
||||
/// An unfolded object function's grid ([`DispatchPlan::object_grid`]).
|
||||
object_grid: bool,
|
||||
/// A function whose threadgroup may be partial ([`DispatchPlan::partial_groups`]).
|
||||
@@ -1012,18 +1003,6 @@ pub struct KernelDecl {
|
||||
grid_edge: bool,
|
||||
}
|
||||
|
||||
/// The threadgroup position and grid of a kernel whose entry wrapper computes them
|
||||
/// ([`DispatchPlan::wrapper_groups`]): two `Private` `uvec3`s that every grid builtin reads in
|
||||
/// place of `WorkgroupId` and `NumWorkgroups`, which the wrapper stores before the body; and the
|
||||
/// dispatch's `WorkgroupId` and `NumWorkgroups`, which only the wrapper reads.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct WrapperGroups {
|
||||
pub position: GlobalId,
|
||||
pub grid: GlobalId,
|
||||
pub workgroup_id: GlobalId,
|
||||
pub num_workgroups: GlobalId,
|
||||
}
|
||||
|
||||
/// Declare the kernel's workgroup size (module scope, before the entry is declared), its
|
||||
/// specialization constants, and its builtin variables. A non-kernel plan declares nothing.
|
||||
pub fn declare(
|
||||
@@ -1316,18 +1295,6 @@ impl KernelDecl {
|
||||
|| (needs.local_pos && deep.is_some());
|
||||
let subgroups = needs.lin && flat && !by_index && !dp.grid_edge;
|
||||
use crate::spv::BuiltIn as B;
|
||||
// A wrapper that computes the threadgroup's position and grid stores them into private
|
||||
// words, which the builtins read; it reads the dispatch's own.
|
||||
let wrapper = if dp.wrapper_groups {
|
||||
Some(WrapperGroups {
|
||||
position: mb.plain_global(StorageClass::Private, uvec3, None)?,
|
||||
grid: mb.plain_global(StorageClass::Private, uvec3, None)?,
|
||||
workgroup_id: mb.builtin(B::WorkgroupId, IoDir::Input, uvec3)?,
|
||||
num_workgroups: mb.builtin(B::NumWorkgroups, IoDir::Input, uvec3)?,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut var = |on: bool, b: crate::spv::BuiltIn, ty: TypeId| -> BResult<Option<GlobalId>> {
|
||||
if on {
|
||||
mb.builtin(b, IoDir::Input, ty).map(Some)
|
||||
@@ -1335,13 +1302,10 @@ impl KernelDecl {
|
||||
Ok(None)
|
||||
}
|
||||
};
|
||||
let (workgroup_id, num_workgroups) = match wrapper {
|
||||
Some(w) => (Some(w.position), Some(w.grid)),
|
||||
None => (
|
||||
var(needs.workgroup_id, B::WorkgroupId, uvec3)?,
|
||||
var(needs.num_workgroups, B::NumWorkgroups, uvec3)?,
|
||||
),
|
||||
};
|
||||
let (workgroup_id, num_workgroups) = (
|
||||
var(needs.workgroup_id, B::WorkgroupId, uvec3)?,
|
||||
var(needs.num_workgroups, B::NumWorkgroups, uvec3)?,
|
||||
);
|
||||
Ok(KernelDecl {
|
||||
form: dp.local_size,
|
||||
tile: dp.tile,
|
||||
@@ -1370,29 +1334,12 @@ impl KernelDecl {
|
||||
)?,
|
||||
subgroup_local: var(subgroups, B::SubgroupLocalInvocationId, u32_)?,
|
||||
pinned_subgroup_size: dp.pinned_subgroup_size,
|
||||
wrapper,
|
||||
object_grid: dp.object_grid,
|
||||
partial_groups: dp.partial_groups,
|
||||
grid_edge: dp.grid_edge,
|
||||
})
|
||||
}
|
||||
|
||||
/// The dispatch's own `WorkgroupId` and `NumWorkgroups`, of a kernel that reads its
|
||||
/// threadgroup's position and the grid's threadgroups (an emulated object function's wrapper:
|
||||
/// its slot's number counts the threadgroups the dispatch runs, not the grid Metal reports).
|
||||
pub fn dispatch_groups(&self, fb: &mut FunctionBuilder<'_>) -> BResult<(SValue, SValue)> {
|
||||
Ok((
|
||||
self.load(fb, self.workgroup_id)?,
|
||||
self.load(fb, self.num_workgroups)?,
|
||||
))
|
||||
}
|
||||
|
||||
/// The words the entry wrapper computes the threadgroup's position and grid into, where it
|
||||
/// does ([`DispatchPlan::wrapper_groups`]).
|
||||
pub fn wrapper_groups(&self) -> Option<WrapperGroups> {
|
||||
self.wrapper
|
||||
}
|
||||
|
||||
fn load(&self, fb: &mut FunctionBuilder<'_>, g: Option<GlobalId>) -> BResult<SValue> {
|
||||
let Some(g) = g else {
|
||||
return Err(dangling_value());
|
||||
|
||||
@@ -35,7 +35,6 @@ fn plan(form: LocalSizeForm, multi_region: bool) -> DispatchPlan {
|
||||
keys: SpecKey::dispatch_keys(Stage::Kernel),
|
||||
folded_groups: false,
|
||||
draw_pieces: false,
|
||||
wrapper_groups: false,
|
||||
object_grid: false,
|
||||
partial_groups: false,
|
||||
grid_edge: false,
|
||||
|
||||
@@ -1568,8 +1568,6 @@ pub fn emit_module(e: &Entry, plan: &Plan, m: &mut Meter) -> Result<Emitted, Err
|
||||
}
|
||||
Stage::Vertex => ExecModel::Vertex,
|
||||
Stage::Fragment => ExecModel::Fragment,
|
||||
// An emulated object or mesh function is a compute entry.
|
||||
Stage::Object | Stage::Mesh if plan.families.mesh.emulated => ExecModel::GLCompute,
|
||||
Stage::Object => ExecModel::TaskEXT,
|
||||
Stage::Mesh => ExecModel::MeshEXT,
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,61 +0,0 @@
|
||||
//! The words of an emulated mesh draw's work buffer (`SyntheticBinding::MeshWork`, `lower::mesh`'s
|
||||
//! module docs), each a `u32`: a header of [`HEADER`] words, then a slot of `S` words per object
|
||||
//! threadgroup (its grid's three counts and a zero, then its payload), then `O + 1` offsets: the
|
||||
//! first mesh threadgroup of each object threadgroup, and `T`. An indirect draw with an object
|
||||
//! function keeps its slots and offsets in its records binding instead, where its object arguments
|
||||
//! pass reserves them (`bind::mesh_scan`, [`SLOTS`]).
|
||||
//!
|
||||
//! The binder, the mesh scan (`bind::mesh_scan`) and the runtime read these words at run time,
|
||||
//! so this file is a runtime input (`validation/build.rs`); the lowering writes them.
|
||||
|
||||
/// `O`: the object threadgroups (1 for a pipeline without an object function).
|
||||
pub const OBJECT_GROUPS: u32 = 0;
|
||||
/// `T`: the mesh threadgroups the draw runs, which its records hold.
|
||||
pub const MESH_GROUPS: u32 = 1;
|
||||
/// The word of the records binding where the draw's records begin.
|
||||
pub const RECORDS_BASE: u32 = 2;
|
||||
/// The mesh dispatch's `VkDispatchIndirectCommand`, three words.
|
||||
pub const DISPATCH: u32 = 3;
|
||||
/// The draw's `VkDrawIndirectCommand`, four words.
|
||||
pub const DRAW: u32 = 6;
|
||||
/// `S`: the words of one slot.
|
||||
pub const SLOT_WORDS: u32 = 10;
|
||||
/// The words of one mesh threadgroup's records (`MeshRecords::group_words`), which the scan
|
||||
/// reserves for each.
|
||||
pub const GROUP_WORDS: u32 = 11;
|
||||
/// The vertices the draw draws for one mesh threadgroup, `NP · k`.
|
||||
pub const GROUP_VERTICES: u32 = 12;
|
||||
/// The words of the records pool the scan reserves the draw's records from.
|
||||
pub const POOL_WORDS: u32 = 13;
|
||||
/// The consumer's number for the draw, which a records fault reports.
|
||||
pub const DRAW_ID: u32 = 14;
|
||||
/// The most workgroups of the mesh dispatch along x (`maxComputeWorkGroupCount[0]`): the
|
||||
/// scan folds `T` into rows of it.
|
||||
pub const ROW: u32 = 15;
|
||||
/// 0 for a draw of host-known object threadgroups; else 1 plus the word of the bound
|
||||
/// arguments range where Metal's indirect arguments (the mesh grid of a pipeline without an
|
||||
/// object function) begin, which the scan reads into slot 0.
|
||||
pub const ARGUMENTS: u32 = 16;
|
||||
/// 0 where the slots and offsets follow the header; else 1 plus the word of the records binding
|
||||
/// (the command buffer's records pool) where they begin: an indirect draw with an object function,
|
||||
/// whose object arguments pass reserves them.
|
||||
pub const SLOTS: u32 = 17;
|
||||
/// The object dispatch's `VkDispatchIndirectCommand`, three words, which the object arguments pass
|
||||
/// writes (an indirect draw with an object function).
|
||||
pub const OBJECT_DISPATCH: u32 = 18;
|
||||
/// 0 for any other draw; else 1 plus the word of the bound arguments range where Metal's indirect
|
||||
/// arguments (the object grid of an indirect draw with an object function) begin, which the
|
||||
/// object arguments pass reads.
|
||||
pub const OBJECT_ARGUMENTS: u32 = 21;
|
||||
/// The header's words.
|
||||
pub const HEADER: u32 = 22;
|
||||
/// The words of a slot before its payload: the grid's three counts and a zero.
|
||||
pub const GRID: u32 = 4;
|
||||
|
||||
/// The words of a work buffer of `objects` slots of `slot_words` words, with its offsets.
|
||||
pub fn words(objects: u64, slot_words: u32) -> u64 {
|
||||
u64::from(HEADER)
|
||||
.saturating_add(objects.saturating_mul(u64::from(slot_words)))
|
||||
.saturating_add(objects)
|
||||
.saturating_add(1)
|
||||
}
|
||||
@@ -470,11 +470,6 @@ pub struct StageIoPlan {
|
||||
/// The render pipeline's private alpha test the fragment function runs at each return
|
||||
/// (`LoweringInputs::alpha_test`).
|
||||
pub alpha_test: Option<AlphaTest>,
|
||||
/// A fragment function's per-primitive inputs (`StageIo::primitive_inputs`) are flat alone,
|
||||
/// not decorated `PerPrimitiveEXT`: its device does not enable `VK_EXT_mesh_shader`, so the
|
||||
/// pipeline's mesh function is emulated, and its synthesized vertex stage writes a
|
||||
/// primitive's values at every corner of it.
|
||||
pub flat_primitive_inputs: bool,
|
||||
/// The second outputs a fragment function writes for attachments held with their channels
|
||||
/// rotated (`LoweringInputs::rotated_factors`), each beside its first output there.
|
||||
pub rotated_seconds: Vec<RotatedSecond>,
|
||||
@@ -2837,11 +2832,8 @@ pub fn declare(
|
||||
.insert(i, mb.plain_global(StorageClass::Private, array, None)?);
|
||||
}
|
||||
let g = mb.io(key.clone(), *dir, ty, *deco)?;
|
||||
// An input of a key the mesh function writes per primitive, flat alone behind an
|
||||
// emulated mesh function.
|
||||
if *dir == IoDir::Input
|
||||
&& !sp.flat_primitive_inputs
|
||||
&& sp.interface.primitive_inputs.binary_search(key).is_ok()
|
||||
// An input of a key the mesh function writes per primitive.
|
||||
if *dir == IoDir::Input && sp.interface.primitive_inputs.binary_search(key).is_ok()
|
||||
{
|
||||
mb.per_primitive(g)?;
|
||||
}
|
||||
|
||||
@@ -1453,13 +1453,11 @@ fn push_var(list: &mut Vec<IoVariable>, v: IoVariable) {
|
||||
/// Whether the fragment function reads the varying `key` per primitive: its mesh render
|
||||
/// pipeline's mesh function writes it per primitive (`LoweringInputs::primitive_varyings`). The
|
||||
/// stage interface lists it (`StageIo::primitive_inputs`), and the declaration decorates it
|
||||
/// `PerPrimitiveEXT`, or, on a device that emulates mesh functions, reads it flat alone
|
||||
/// (`StageIoPlan::flat_primitive_inputs`).
|
||||
/// `PerPrimitiveEXT`.
|
||||
fn read_per_primitive(cx: &mut SelectCx<'_>, key: &VaryingKey) -> bool {
|
||||
if !cx.inputs.primitive_varyings.contains(key) {
|
||||
return false;
|
||||
}
|
||||
cx.families.stage_io.flat_primitive_inputs = crate::lower::mesh::emulates(cx.profile);
|
||||
let keys = &mut cx.families.stage_io.interface.primitive_inputs;
|
||||
if let Err(at) = keys.binary_search(key) {
|
||||
keys.insert(at, key.clone());
|
||||
|
||||
@@ -555,20 +555,13 @@ pub fn payload_bytes(size: u64) -> u64 {
|
||||
}
|
||||
|
||||
/// Declare the payload arena of a payload of `size` bytes: a `TaskPayloadWorkgroupEXT` array of
|
||||
/// [`payload_bytes`], or, for an emulated object or mesh function (`emulated`), a `Workgroup` one
|
||||
/// that its wrapper copies out of or into its slot of the draw's work buffer. Neither has an
|
||||
/// initializer: an object function's payload "is assumed uninitialized at the entry of the object
|
||||
/// function" (the Metal Shading Language Specification's `payload` attribute), and an emulated
|
||||
/// mesh function's wrapper copies its payload in before the function runs.
|
||||
pub fn declare_payload(mb: &mut ModuleBuilder, size: u64, emulated: bool) -> BResult<ArenaDecl> {
|
||||
/// [`payload_bytes`], with no initializer: an object function's payload "is assumed uninitialized
|
||||
/// at the entry of the object function" (the Metal Shading Language Specification's `payload`
|
||||
/// attribute).
|
||||
pub fn declare_payload(mb: &mut ModuleBuilder, size: u64) -> BResult<ArenaDecl> {
|
||||
let bytes = konst(mb, size)?;
|
||||
let words = konst(mb, static_words(size))?;
|
||||
let class = if emulated {
|
||||
StorageClass::Workgroup
|
||||
} else {
|
||||
StorageClass::TaskPayloadWorkgroupEXT
|
||||
};
|
||||
let global = array(mb, class, words, false)?;
|
||||
let global = array(mb, StorageClass::TaskPayloadWorkgroupEXT, words, false)?;
|
||||
Ok(ArenaDecl {
|
||||
arena: Arena::Payload,
|
||||
global,
|
||||
|
||||
@@ -245,7 +245,6 @@ mod serde_round_trips {
|
||||
kept_imageblock_bytes: Some(8),
|
||||
depth_clamp_range: true,
|
||||
rotated_weights: true,
|
||||
mesh_last_first: true,
|
||||
line_band: Some(crate::pipeline::BandPrimitive::Triangles),
|
||||
swizzled_storage: BTreeSet::from([slot(Stage::Kernel, SlotClass::Texture, 6)]),
|
||||
addressed_function_tables: true,
|
||||
@@ -638,41 +637,6 @@ mod serde_round_trips {
|
||||
}),
|
||||
early_fragment_tests: true,
|
||||
writes_sample_mask: true,
|
||||
// An emulated mesh function's records.
|
||||
mesh_records: Some(crate::pipeline::MeshRecords {
|
||||
vertices: 3,
|
||||
primitives: 1,
|
||||
corners: 3,
|
||||
vertex_words: 4,
|
||||
primitive_words: 5,
|
||||
fields: vec![
|
||||
crate::pipeline::RecordField {
|
||||
value: crate::pipeline::RecordValue::Position,
|
||||
per_primitive: false,
|
||||
offset: 0,
|
||||
words: 4,
|
||||
numeric: crate::pipeline::stage_io::IoNumeric::Float,
|
||||
},
|
||||
crate::pipeline::RecordField {
|
||||
value: crate::pipeline::RecordValue::Culled,
|
||||
per_primitive: true,
|
||||
offset: 3,
|
||||
words: 1,
|
||||
numeric: crate::pipeline::stage_io::IoNumeric::Uint,
|
||||
},
|
||||
crate::pipeline::RecordField {
|
||||
value: crate::pipeline::RecordValue::Varying(
|
||||
crate::pipeline::sym::VaryingKey::user(b"c"),
|
||||
),
|
||||
per_primitive: true,
|
||||
offset: 4,
|
||||
words: 1,
|
||||
numeric: crate::pipeline::stage_io::IoNumeric::Sint,
|
||||
},
|
||||
],
|
||||
slot_words: 12,
|
||||
}),
|
||||
mesh_corners: Some(3),
|
||||
writes_point_size: true,
|
||||
flat_fragment_inputs: true,
|
||||
clip_distances: 2,
|
||||
@@ -1052,7 +1016,6 @@ mod bind_serde_round_trips {
|
||||
kept_imageblock_bytes: Some(4),
|
||||
depth_clamp_range: Some([0.25, 0.5]),
|
||||
rotated_weights: true,
|
||||
mesh_last_first: true,
|
||||
line_band: Some((
|
||||
crate::pipeline::BandPrimitive::Triangles,
|
||||
[8.0, -8.0, 1.75, -1.0],
|
||||
@@ -1126,7 +1089,6 @@ mod bind_serde_round_trips {
|
||||
kept_imageblock_bytes: Some(4),
|
||||
depth_clamp_range: true,
|
||||
rotated_weights: true,
|
||||
mesh_last_first: true,
|
||||
line_band: Some(crate::pipeline::BandPrimitive::Lines),
|
||||
interlocked_colors: BTreeSet::from([0, 3]),
|
||||
fragment_tests: crate::bind::FragmentTests::Pass,
|
||||
@@ -1350,23 +1312,6 @@ mod bind_serde_round_trips {
|
||||
}],
|
||||
],
|
||||
specialization: None,
|
||||
// An emulated mesh draw's dispatch.
|
||||
mesh_dispatch: Some(crate::bind::MeshDispatch {
|
||||
work: vec![1, 0, 0, 2],
|
||||
work_bytes: 112,
|
||||
object_groups: Some([2, 1, 1]),
|
||||
object_arguments: Some(crate::bind::BufferRange {
|
||||
offset: 0,
|
||||
range: 12,
|
||||
}),
|
||||
mesh: crate::bind::MeshGroups::Scanned {
|
||||
arguments: Some(crate::bind::BufferRange {
|
||||
offset: 64,
|
||||
range: 16,
|
||||
}),
|
||||
},
|
||||
records: crate::bind::MeshRecordsRegion::Pool,
|
||||
}),
|
||||
});
|
||||
// A mesh draw's commands.
|
||||
round_trip(&vk::DrawCommand::DrawMeshTasks {
|
||||
|
||||
@@ -488,8 +488,7 @@ impl RuntimeDependency {
|
||||
/// maximum other than the function's or the required size's threads, and any of them above
|
||||
/// 1024, [`MeshPipelineProblem`](crate::error::MeshPipelineProblem)), held to this device's
|
||||
/// limit for the stage where that is lower: `maxTaskWorkGroupInvocations` and
|
||||
/// `maxMeshWorkGroupInvocations` with `VK_EXT_mesh_shader`, and `maxComputeWorkGroupInvocations`
|
||||
/// where the device runs both stages as compute work (`lower::mesh::emulates`).
|
||||
/// `maxMeshWorkGroupInvocations`.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
@@ -508,8 +507,7 @@ pub struct MeshPipelineMetalInfo {
|
||||
pub mesh_thread_execution_width: u32,
|
||||
/// `maxTotalThreadgroupsPerMeshGrid`: the descriptor's maximum, else Metal's 2^20 (an object
|
||||
/// function's `[[max_total_threadgroups_per_mesh_grid(n)]]` changes neither), held to the
|
||||
/// device's `maxMeshWorkGroupTotalCount` where it runs mesh functions natively and that is
|
||||
/// lower.
|
||||
/// device's `maxMeshWorkGroupTotalCount` where that is lower.
|
||||
pub max_total_threadgroups_per_mesh_grid: u32,
|
||||
}
|
||||
|
||||
|
||||
@@ -3777,9 +3777,6 @@ fn stage_interface(
|
||||
io: plan.families.stage_io.interface.clone(),
|
||||
tessellation: crate::lower::tessellation::interface(plan),
|
||||
writes_memory,
|
||||
mesh_records: crate::lower::mesh::records(&plan.families.mesh),
|
||||
mesh_corners: (plan.families.mesh.mesh).map(crate::lower::mesh::MeshShape::per_primitive),
|
||||
emulated_payload: crate::lower::mesh::emulated_payload(&plan.families.mesh),
|
||||
payload: plan.families.mesh.payload,
|
||||
reaches_command_buffers,
|
||||
command_writes,
|
||||
|
||||
@@ -54,7 +54,6 @@ use crate::pipeline::descriptor::{
|
||||
use crate::pipeline::facts::RuntimeFact;
|
||||
use crate::pipeline::graphics::{GraphicsState, StorageAttachmentView};
|
||||
use crate::pipeline::link::geometry;
|
||||
use crate::pipeline::link::mesh::synthesized_stage as mesh_vertex_stage;
|
||||
use crate::pipeline::link::tessellation::{note_evaluation_stage, synthesized_stages};
|
||||
use crate::pipeline::link::{link, LinkInputs, Linked, RenderLinkInputs};
|
||||
use crate::pipeline::lower_inputs::LoweringInputs;
|
||||
@@ -551,10 +550,9 @@ impl Device {
|
||||
/// result is a [`RenderPipeline`] whose stages are the object stage (`TASK_EXT`), the mesh
|
||||
/// stage (`MESH_EXT`) and the fragment stage: it has no vertex input and no input assembly (its
|
||||
/// `GraphicsState::topology` is unused), and Metal's draws of it are `drawMeshThreadgroups` and
|
||||
/// `drawMeshThreads`. On a device without `VK_EXT_mesh_shader` the mesh stage is a `COMPUTE`
|
||||
/// module that writes records, followed by a synthesized `VERTEX` stage that draws them as a
|
||||
/// list of the mesh's topology (`GraphicsState::mesh_records`). A `Compiled` stage must have
|
||||
/// been compiled under the same inputs and Metal's call stack depth of 1.
|
||||
/// `drawMeshThreads`. A device without `VK_EXT_mesh_shader` and `meshShader` (and `taskShader`
|
||||
/// for an object function) refuses it (`Unsupported{MeshShading}`). A `Compiled` stage must
|
||||
/// have been compiled under the same inputs and Metal's call stack depth of 1.
|
||||
pub fn compile_mesh_pipeline(
|
||||
&self,
|
||||
d: &MeshPipelineDescriptor,
|
||||
@@ -672,32 +670,7 @@ impl Device {
|
||||
{
|
||||
requirements = p.union_requirements(&requirements, &a.requirements);
|
||||
}
|
||||
// An emulated mesh function's records are drawn by a synthesized vertex stage, which
|
||||
// follows the mesh stage's compute module, the last compute module (an object
|
||||
// function's comes first).
|
||||
let records = linked
|
||||
.graphics
|
||||
.as_ref()
|
||||
.and_then(|g| g.mesh_records.as_ref());
|
||||
let mut mesh_facts = Vec::new();
|
||||
if let Some(records) = records {
|
||||
// Drawn from each primitive's last index first: Apple's last provoking vertex on a
|
||||
// device that takes flat inputs from the first (`VariantKey::mesh_last_first`).
|
||||
let last_first = v.mesh_last_first && records.corners > 1;
|
||||
let (module, r) = mesh_vertex_stage(records, last_first, &linked, p, m)?;
|
||||
if last_first {
|
||||
let fact = RuntimeFact::MeshLastFirst;
|
||||
mesh_facts.push(RuntimeDependency::new(fact, mechanism(&fact, p)));
|
||||
}
|
||||
requirements = p.union_requirements(&requirements, &r);
|
||||
let at = stages
|
||||
.iter()
|
||||
.rposition(|s| s.stage == vk::ShaderStage::COMPUTE)
|
||||
.ok_or_else(|| invariant("an emulated mesh pipeline without its compute stage"))?;
|
||||
stages.insert(at + 1, module);
|
||||
}
|
||||
let mut dependencies = dependencies(&artifacts, self);
|
||||
dependencies.extend(mesh_facts);
|
||||
let dependencies = dependencies(&artifacts, self);
|
||||
let (graphics, requirements) = graphics_requirements(requirements, &linked, &artifacts, p)?;
|
||||
let profile = self.profile_fingerprint();
|
||||
let mesh_info = self.mesh_info(d, object.as_ref(), &mesh);
|
||||
@@ -731,16 +704,11 @@ impl Device {
|
||||
) -> MeshPipelineMetalInfo {
|
||||
let p = self.profile();
|
||||
let limits = &p.fields().limits;
|
||||
// Each stage's threadgroups run in the task and mesh stages, or as compute work.
|
||||
let (object_limit, mesh_limit) = if crate::lower::mesh::emulates(p) {
|
||||
let compute = limits.max_compute_work_group_invocations;
|
||||
(compute, compute)
|
||||
} else {
|
||||
(
|
||||
limits.mesh.max_task_work_group_invocations,
|
||||
limits.mesh.max_mesh_work_group_invocations,
|
||||
)
|
||||
};
|
||||
// Each stage's threadgroups run in the task and mesh stages.
|
||||
let (object_limit, mesh_limit) = (
|
||||
limits.mesh.max_task_work_group_invocations,
|
||||
limits.mesh.max_mesh_work_group_invocations,
|
||||
);
|
||||
// Metal's on a first compile: the least of 1024, the function's own maximum, the
|
||||
// descriptor's (Metal's 0 is none) and the threads of the stage's required size (Metal's
|
||||
// all-zero size is none), within the device's.
|
||||
@@ -763,10 +731,7 @@ impl Device {
|
||||
.max_total_threadgroups_per_mesh_grid
|
||||
.filter(|&n| n > 0)
|
||||
.unwrap_or(METAL_MESH_GRID_THREADGROUPS);
|
||||
let grid = match crate::lower::mesh::emulates(p) {
|
||||
true => grid,
|
||||
false => grid.min(limits.mesh.max_mesh_work_group_total_count),
|
||||
};
|
||||
let grid = grid.min(limits.mesh.max_mesh_work_group_total_count);
|
||||
MeshPipelineMetalInfo {
|
||||
max_total_threads_per_object_threadgroup: object.map_or(0, |o| {
|
||||
threads(
|
||||
@@ -1773,18 +1738,13 @@ fn compute_fields(d: &ComputePipelineDescriptor) -> String {
|
||||
|
||||
/// The pipeline key's fields of variant `v` past its stages' keys: its color group past the first
|
||||
/// (`VariantKey::color_group`), whose variant of a pipeline without a fragment function has no
|
||||
/// stage of its own, its emulated mesh function's synthesized vertex stage, and a band variant's
|
||||
/// synthesized tessellation stages. Empty for every other variant, so a pipeline keeps its key.
|
||||
/// stage of its own, and a band variant's synthesized tessellation stages. Empty for every other variant, so a pipeline keeps its key.
|
||||
fn variant_fields(v: &VariantKey) -> String {
|
||||
let mut fields = String::new();
|
||||
// The group a pipeline without a fragment function keeps in no stage's key.
|
||||
if v.color_group != 0 {
|
||||
fields.push_str(&format!(" color_group {}", v.color_group));
|
||||
}
|
||||
// The synthesized vertex stage of an emulated mesh function's pipeline, in no stage's key.
|
||||
if v.mesh_last_first {
|
||||
fields.push_str(" mesh_last_first");
|
||||
}
|
||||
// The band's synthesized stages, in no stage's key.
|
||||
match v.line_band {
|
||||
None => {}
|
||||
|
||||
@@ -482,10 +482,6 @@ pub enum RuntimeFact {
|
||||
/// weights back from a triangle drawn with Metal's last vertex first. Its plans state the
|
||||
/// variant the shape asks for (`BindShape::rotated_weights`).
|
||||
RotatedWeights,
|
||||
/// The emulated mesh function's pipeline was compiled under `VariantKey::mesh_last_first`:
|
||||
/// its synthesized vertex stage draws each line or triangle from its last index first. Its
|
||||
/// plans state the variant the shape asks for (`BindShape::mesh_last_first`).
|
||||
MeshLastFirst,
|
||||
/// The function reads, samples, gathers, or fetches through a sampler the color texture
|
||||
/// bound to the slot, on a profile whose sparse textures are sparse images (it enables
|
||||
/// `shaderResourceResidency`): where that texture is sparse, a block of it that holds no
|
||||
@@ -956,7 +952,6 @@ impl RuntimeFact {
|
||||
RuntimeFact::DroppedColor { .. } => "DroppedColor",
|
||||
RuntimeFact::DepthClampRange => "DepthClampRange",
|
||||
RuntimeFact::RotatedWeights => "RotatedWeights",
|
||||
RuntimeFact::MeshLastFirst => "MeshLastFirst",
|
||||
RuntimeFact::ConstantLanes { .. } => "ConstantLanes",
|
||||
RuntimeFact::FunctionTableRange { .. } => "FunctionTableRange",
|
||||
RuntimeFact::TestedStorageWrites { .. } => "TestedStorageWrites",
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::error::{
|
||||
Attachment, Capability, Error, Feature, InternalError, InternalKind, Unsupported,
|
||||
};
|
||||
use crate::metal;
|
||||
use crate::pipeline::interface::{MeshRecords, PatchDomain};
|
||||
use crate::pipeline::interface::PatchDomain;
|
||||
use crate::pipeline::sym::SampledType;
|
||||
use crate::vk;
|
||||
|
||||
@@ -153,18 +153,6 @@ pub struct GraphicsState {
|
||||
/// [`Limits::early_fragment_multisample_coverage_after_sample_counting`](crate::device::Limits::early_fragment_multisample_coverage_after_sample_counting)).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub writes_sample_mask: bool,
|
||||
/// A mesh render pipeline on a device without `VK_EXT_mesh_shader`: its mesh function is
|
||||
/// the pipeline's `COMPUTE` module, which writes these records, and a synthesized `VERTEX`
|
||||
/// module draws them as a list of [`MeshRecords::topology`](MeshRecords::topology)
|
||||
/// (the binder's `DrawCommands::mesh_dispatch` states the consumer contract). `None` for
|
||||
/// every other pipeline.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub mesh_records: Option<MeshRecords>,
|
||||
/// A mesh render pipeline's primitive, its mesh function's: its indices, 1 (points), 2
|
||||
/// (lines) or 3 (triangles), whether the device draws the mesh or
|
||||
/// [`mesh_records`](Self::mesh_records) does. `None` for every other pipeline.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub mesh_corners: Option<u32>,
|
||||
/// A render pipeline variant that draws its lines as bands of triangles
|
||||
/// (`VariantKey::line_band`, `pipeline::link::band`): its `topology` is `PATCH_LIST` (never
|
||||
/// dynamic), its stages the vertex stage, the band's synthesized tessellation control and
|
||||
@@ -544,8 +532,6 @@ impl GraphicsState {
|
||||
shadow_stencil: None,
|
||||
early_fragment_tests: false,
|
||||
writes_sample_mask: false,
|
||||
mesh_records: None,
|
||||
mesh_corners: None,
|
||||
line_band: None,
|
||||
region_fan_out: None,
|
||||
writes_point_size: false,
|
||||
|
||||
@@ -355,22 +355,6 @@ pub struct StageInterface {
|
||||
/// Metal's color attachment write.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub writes_memory: bool,
|
||||
/// A mesh function compiled for a device without `VK_EXT_mesh_shader`: the module is a
|
||||
/// `GLCompute` entry that writes its threadgroups' vertices and primitives as these records,
|
||||
/// which the pipeline's synthesized vertex stage draws.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub mesh_records: Option<MeshRecords>,
|
||||
/// A mesh function's primitive: its indices, 1 (points), 2 (lines) or 3 (triangles), on
|
||||
/// every device, whether the device draws the mesh or the function writes records. `None`
|
||||
/// for any other function.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub mesh_corners: Option<u32>,
|
||||
/// An object or mesh function compiled for a device without `VK_EXT_mesh_shader` (a
|
||||
/// `GLCompute` entry): its payload's words (0 without a payload), which its object
|
||||
/// threadgroup's slot of the draw's work buffer holds (`MeshRecords::slot_words`). `None`
|
||||
/// for any other function.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub emulated_payload: Option<u32>,
|
||||
/// An object or mesh function's payload arena's bytes (`memory::arena::payload_bytes` of its
|
||||
/// `[[payload]]` parameter's `air.arg_type_size`, a mesh function's at least
|
||||
/// `LoweringInputs::object_payload`), which its accesses of the payload read and write; `None`
|
||||
@@ -740,101 +724,6 @@ impl SampledLevels {
|
||||
|
||||
impl LevelReads {}
|
||||
|
||||
/// An emulated mesh function's records: what each of its threadgroups writes to the draw's records
|
||||
/// buffer (`SyntheticBinding::MeshRecords`), all of it words.
|
||||
///
|
||||
/// Mesh threadgroup `w`, its number among the draw's mesh threadgroups (object threadgroup by
|
||||
/// object threadgroup, each one's grid x fastest), owns [`MeshRecords::group_words`] words from
|
||||
/// the draw's first word plus `w · group_words()`: its primitive count, then `vertices` vertex
|
||||
/// records of `vertex_words` words each, then `primitives` primitive records of
|
||||
/// `primitive_words` words each, every primitive record beginning with the primitive's
|
||||
/// `corners` indices. Each field sits at its offset in its record, one word per lane. A
|
||||
/// threadgroup zeroes its words before its body runs, so an index, a culled flag, or a render
|
||||
/// target slice or viewport index the function does not write reads 0, as Metal's does.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct MeshRecords {
|
||||
/// The mesh type's `NV`.
|
||||
pub vertices: u32,
|
||||
/// The mesh type's `NP`.
|
||||
pub primitives: u32,
|
||||
/// The indices of one primitive: 1 (points), 2 (lines) or 3 (triangles).
|
||||
pub corners: u32,
|
||||
pub vertex_words: u32,
|
||||
pub primitive_words: u32,
|
||||
/// Every field, in record order: the vertex record's, then the primitive record's.
|
||||
pub fields: Vec<RecordField>,
|
||||
/// The words of an object threadgroup's slot in the draw's work buffer: its grid's three
|
||||
/// counts and a zero, then the larger payload of the pipeline's object and mesh functions
|
||||
/// (in a function's own interface, its own payload).
|
||||
pub slot_words: u32,
|
||||
}
|
||||
|
||||
impl MeshRecords {
|
||||
/// The words of one threadgroup's records: its count, its vertex records and its primitive
|
||||
/// records.
|
||||
pub fn group_words(&self) -> u64 {
|
||||
1 + u64::from(self.vertices) * u64::from(self.vertex_words)
|
||||
+ u64::from(self.primitives) * u64::from(self.primitive_words)
|
||||
}
|
||||
|
||||
/// The word of a threadgroup's records where its primitive records begin.
|
||||
pub fn primitive_base(&self) -> u64 {
|
||||
1 + u64::from(self.vertices) * u64::from(self.vertex_words)
|
||||
}
|
||||
|
||||
/// The Vulkan list topology of the records' primitives.
|
||||
pub fn topology(&self) -> vk::PrimitiveTopology {
|
||||
match self.corners {
|
||||
1 => vk::PrimitiveTopology::POINT_LIST,
|
||||
2 => vk::PrimitiveTopology::LINE_LIST,
|
||||
_ => vk::PrimitiveTopology::TRIANGLE_LIST,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One field of a vertex or primitive record ([`MeshRecords`]).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct RecordField {
|
||||
pub value: RecordValue,
|
||||
/// In the primitive record, else in the vertex record.
|
||||
pub per_primitive: bool,
|
||||
/// Its first word in its record.
|
||||
pub offset: u32,
|
||||
/// Its words: its lanes, or the length of the clip distances.
|
||||
pub words: u32,
|
||||
/// What each word holds: a `float`'s bits, a `uint`, or an `int`'s bits (a `bool` is a
|
||||
/// `uint`, 0 or 1).
|
||||
pub numeric: crate::pipeline::stage_io::IoNumeric,
|
||||
}
|
||||
|
||||
/// What a [`RecordField`] holds.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum RecordValue {
|
||||
/// `[[position]]`.
|
||||
Position,
|
||||
/// `[[point_size]]`.
|
||||
PointSize,
|
||||
/// `[[clip_distance]]`.
|
||||
ClipDistance,
|
||||
/// `[[primitive_culled]]`, 1 where set.
|
||||
Culled,
|
||||
/// The primitive's render target slice (`Layer`): its `[[render_target_array_index]]` where
|
||||
/// that lies below the pass's length, else 0.
|
||||
Layer,
|
||||
/// The primitive's viewport (`ViewportIndex`): its `[[viewport_array_index]]` where that lies
|
||||
/// below the draw's viewport count, else 0.
|
||||
ViewportIndex,
|
||||
/// A user varying: vertex data, primitive data, or a raw index (the link numbers its
|
||||
/// location by key).
|
||||
Varying(crate::pipeline::sym::VaryingKey),
|
||||
}
|
||||
|
||||
/// What a tessellation evaluation module (a post-tessellation vertex function) needs of the
|
||||
/// pipeline's control stage: its patch domain and Metal's control points per patch. It reads the
|
||||
/// patch index and the instance as `uint` patch inputs at
|
||||
@@ -882,13 +771,11 @@ pub enum PatchDomain {
|
||||
|
||||
impl StageInterface {
|
||||
/// The Vulkan stage of the module: the evaluation stage for a post-tessellation vertex
|
||||
/// function, the compute stage for an emulated object or mesh function, else the Metal
|
||||
/// stage's.
|
||||
/// function, else the Metal stage's.
|
||||
pub fn vk_stage(&self) -> vk::ShaderStage {
|
||||
match (self.tessellation, self.emulated_payload) {
|
||||
(Some(_), _) => vk::ShaderStage::TESSELLATION_EVALUATION,
|
||||
(None, Some(_)) => vk::ShaderStage::COMPUTE,
|
||||
(None, None) => crate::device::derive::vk_stage(self.stage),
|
||||
match self.tessellation {
|
||||
Some(_) => vk::ShaderStage::TESSELLATION_EVALUATION,
|
||||
None => crate::device::derive::vk_stage(self.stage),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,7 @@
|
||||
//! record, with the measured properties a conversion relies on in place of a note. A mesh
|
||||
//! render pipeline has an object stage when it has an object function, its mesh stage, and a
|
||||
//! fragment stage exactly when it rasterizes; its `GraphicsState` is a render pipeline's with the
|
||||
//! mesh stage in the vertex stage's place, and it has no vertex input. An emulated mesh
|
||||
//! function's pipeline ([`mesh`]) adds a synthesized vertex stage, which reads the mesh
|
||||
//! function's records binding too (its stage flags are both stages').
|
||||
//! mesh stage in the vertex stage's place, and it has no vertex input.
|
||||
|
||||
pub mod band;
|
||||
pub mod contract;
|
||||
@@ -425,28 +423,18 @@ pub fn link(
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
// A mesh function reads its payload within its object function's. An emulated mesh
|
||||
// function's pipeline draws through a synthesized vertex stage, which reads the records the
|
||||
// mesh stage writes.
|
||||
let records = match inputs {
|
||||
LinkInputs::Mesh(_) => {
|
||||
mesh::payload(&ifaces)?;
|
||||
mesh::records(&ifaces)?
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
// A mesh function reads its payload within its object function's.
|
||||
if let LinkInputs::Mesh(_) = inputs {
|
||||
mesh::payload(&ifaces)?;
|
||||
}
|
||||
let mut table = LinkTable::default();
|
||||
let mut synthesized: Vec<(ResourceSlot, vk::ShaderStageFlags)> = plan
|
||||
let synthesized: Vec<(ResourceSlot, vk::ShaderStageFlags)> = plan
|
||||
.as_ref()
|
||||
.map(tessellation::ControlPlan::slots)
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(|slot| (slot, vk::ShaderStageFlags::TESSELLATION_CONTROL))
|
||||
.collect();
|
||||
if records.is_some() {
|
||||
synthesized.push((mesh::RECORDS_SLOT, vk::ShaderStageFlags::VERTEX));
|
||||
synthesized.push((mesh::WORK_SLOT, vk::ShaderStageFlags::VERTEX));
|
||||
}
|
||||
// A fan-out variant's triangle stage reads the region table, and a probe's writes its flags.
|
||||
if let Some(fan) = geometry.as_ref().and_then(|g| g.fan_out) {
|
||||
let stage = vk::ShaderStageFlags::GEOMETRY;
|
||||
@@ -583,13 +571,7 @@ pub fn link(
|
||||
.ok_or_else(|| missing_stage(Stage::Mesh))?;
|
||||
let vi = VertexInputState::default();
|
||||
let fragment = stages.get(at + 1).copied();
|
||||
let mut gs = render_state(r, ifaces[at], fragment, &vi, None, p)?;
|
||||
gs.mesh_corners = ifaces[at].mesh_corners;
|
||||
// An emulated mesh function's primitives are drawn as a list of their kind.
|
||||
if let Some(records) = records {
|
||||
gs.topology = records.topology();
|
||||
gs.mesh_records = Some(records);
|
||||
}
|
||||
let gs = render_state(r, ifaces[at], fragment, &vi, None, p)?;
|
||||
(vi, Some(gs))
|
||||
}
|
||||
LinkInputs::Standalone | LinkInputs::Compute => (VertexInputState::default(), None),
|
||||
@@ -1009,8 +991,7 @@ struct HeapDecl {
|
||||
|
||||
/// Number every binding symbol densely in set 0 and every heap array in set 1, build the layout,
|
||||
/// and check the pipeline-wide limits. `synthesized` are the storage buffers the pipeline's
|
||||
/// synthesized stages read, with those stages: a tessellation pipeline's control-stage buffers, and
|
||||
/// an emulated mesh function's records, which its vertex stage reads too.
|
||||
/// synthesized stages read, with those stages: a tessellation pipeline's control-stage buffers.
|
||||
fn layout(
|
||||
ifaces: &[&StageInterface],
|
||||
synthesized: &[(ResourceSlot, vk::ShaderStageFlags)],
|
||||
@@ -1020,7 +1001,7 @@ fn layout(
|
||||
let mut decls: BTreeMap<ResourceSlot, (StageDescriptor, vk::ShaderStageFlags)> =
|
||||
BTreeMap::new();
|
||||
// A tessellation pipeline's factor, patch index, and control-point index buffers are the
|
||||
// control stage's; an emulated mesh function's records are its synthesized vertex stage's too.
|
||||
// control stage's.
|
||||
for &(slot, stages) in synthesized {
|
||||
let d = StageDescriptor::new(slot, vk::DescriptorType::STORAGE_BUFFER, 1);
|
||||
decls.insert(d.slot, (d, stages));
|
||||
@@ -1133,25 +1114,11 @@ fn layout(
|
||||
),
|
||||
)));
|
||||
}
|
||||
let stages = i.vk_stage().flags();
|
||||
// An emulated mesh pipeline's object and mesh functions are both compute entries:
|
||||
// Vulkan admits one range per stage, so theirs is the hull of their disjoint windows.
|
||||
match push_constants
|
||||
.iter_mut()
|
||||
.find(|r: &&mut PushConstantRange| r.stages == stages)
|
||||
{
|
||||
Some(r) => {
|
||||
let start = r.offset.min(offset);
|
||||
let end = (r.offset + r.size).max(offset + size);
|
||||
r.offset = start;
|
||||
r.size = end - start;
|
||||
}
|
||||
None => push_constants.push(PushConstantRange {
|
||||
stages,
|
||||
offset,
|
||||
size,
|
||||
}),
|
||||
}
|
||||
push_constants.push(PushConstantRange {
|
||||
stages: i.vk_stage().flags(),
|
||||
offset,
|
||||
size,
|
||||
});
|
||||
}
|
||||
}
|
||||
let mut sets = vec![DescriptorSetLayout {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
//! and data type declare, and every specialization constant its size and default. The module's
|
||||
//! user interface variables must be exactly the ones its stage-IO interface ([`StageIo`]) lists, in
|
||||
//! the listed direction and with the listed type (`StageIo::declared_type`: an extended-range color
|
||||
//! output's is the raw texel's), so link numbers every `Location` key from that one contract; an
|
||||
//! emulated mesh function's outputs are records instead. Nothing here reads a name.
|
||||
//! output's is the raw texel's), so link numbers every `Location` key from that one contract.
|
||||
//! Nothing here reads a name.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -73,23 +73,11 @@ pub fn stage_symbols(m: &TypedModule, io: &StageIo) -> Result<StageSymbols, Erro
|
||||
| GlobalKind::FixedIo { .. } => {}
|
||||
}
|
||||
}
|
||||
// A compute entry's listed outputs are an emulated mesh function's: it writes them to its
|
||||
// records binding and declares no interface variable for them.
|
||||
let records = m.entry().model == ExecModel::GLCompute && !outputs.is_empty();
|
||||
let listed = inputs.len() + if records { 0 } else { outputs.len() };
|
||||
if declared != listed {
|
||||
if declared != inputs.len() + outputs.len() {
|
||||
return Err(invariant(
|
||||
"an interface variable the module does not declare",
|
||||
));
|
||||
}
|
||||
if records
|
||||
&& !out
|
||||
.descriptors
|
||||
.iter()
|
||||
.any(|d| d.slot == crate::lower::mesh::RECORDS_SLOT)
|
||||
{
|
||||
return Err(invariant("a compute entry's outputs without its records"));
|
||||
}
|
||||
for d in m.decls() {
|
||||
if let Decl::Const(c) = d {
|
||||
let def = m.consts().get(*c)?;
|
||||
|
||||
@@ -799,9 +799,6 @@ pub fn graphics_state(
|
||||
early_fragment_tests: fs.is_some_and(|fs| fs.io.early_fragment_tests),
|
||||
writes_sample_mask: fs
|
||||
.is_some_and(|fs| fs.io.builtins.contains(&StageBuiltin::SampleMaskOut)),
|
||||
// An emulated mesh function's pipeline states its records (`link`).
|
||||
mesh_records: None,
|
||||
mesh_corners: None,
|
||||
// A band variant's pipeline states its band (`link`).
|
||||
line_band: None,
|
||||
// A fan-out variant's pipeline states its fan-out (`link`).
|
||||
|
||||
@@ -1,68 +1,8 @@
|
||||
//! The synthesized vertex stage of an emulated mesh function's pipeline.
|
||||
//!
|
||||
//! On a device without `VK_EXT_mesh_shader` a mesh function is a compute entry that writes each
|
||||
//! of its threadgroups' vertices and primitives to the draw's records
|
||||
//! ([`MeshRecords`], `SyntheticBinding::MeshRecords`; `lower::mesh` writes them). The pipeline
|
||||
//! draws them through a vertex stage link adds after the mesh stage ([`vertex_module`]): the
|
||||
//! draw is a non-indexed draw of `T · NP · k` vertices (`T` the draw's mesh threadgroups, `NP`
|
||||
//! the mesh type's primitives, `k` a primitive's indices) as a list of the mesh's topology
|
||||
//! ([`MeshRecords::topology`]), and vertex `v` is corner `c` of slot `s` of threadgroup `g`
|
||||
//! (`v = (g · NP + s) · k + c`), whose records begin at the draw's first word (word
|
||||
//! `RECORDS_BASE` of its work buffer, `SyntheticBinding::MeshWork`) plus `g` threadgroups'
|
||||
//! words. It reads the slot's primitive record and the record of the vertex the corner's index
|
||||
//! names, and writes:
|
||||
//!
|
||||
//! - `Position` from the vertex's position, and `PointSize` (a point mesh's, or a mesh's that
|
||||
//! writes it) from its point size, 1.0 where it writes none;
|
||||
//! - `ClipDistance` from its clip distances, and `Layer` and `ViewportIndex` from the
|
||||
//! primitive's;
|
||||
//! - each user varying from its record, the vertex's or, for primitive data and the raw indices,
|
||||
//! the primitive's at every corner: the fragment function reads those flat
|
||||
//! (`StageIoPlan::flat_primitive_inputs`), so whichever corner provokes, the primitive's value
|
||||
//! is read.
|
||||
//!
|
||||
//! A slot at or past the threadgroup's count, a slot whose primitive is culled, and a slot with
|
||||
//! an index at or past `NV` draw nothing: every corner lies at [`FAR`], wholly outside the clip
|
||||
//! volume, and reads vertex 0's record instead (Vulkan defines no index past the mesh's vertices
|
||||
//! either). Vulkan's primitive order for the draw is the vertices' order: threadgroup by
|
||||
//! threadgroup in their linear order, slot by slot, which is the order Metal draws a mesh draw's
|
||||
//! primitives in.
|
||||
//!
|
||||
//! Under `VariantKey::mesh_last_first` (a draw under Apple's last provoking vertex on a device
|
||||
//! that takes flat inputs from the first) vertex `v` reads corner `(c + k - 1) mod k` instead:
|
||||
//! each primitive is drawn from Metal's last index first, a triangle `(i0, i1, i2)` as
|
||||
//! `(i2, i0, i1)`, which keeps its winding, and a line `(i0, i1)` as `(i1, i0)`, so its flat
|
||||
//! inputs are its last vertex's, as Metal's are at mode 1 (Metal probe: a mesh triangle's flat
|
||||
//! input from its last index).
|
||||
//!
|
||||
//! The records do not hold the primitive id: a fragment function that reads `[[primitive_id]]`
|
||||
//! behind an emulated mesh function is not implemented ([`records`]), since the vertex stage's
|
||||
//! primitives are counted across the draw.
|
||||
//! A mesh render pipeline's link check: its mesh function's payload holds its object function's.
|
||||
|
||||
use crate::budget::Meter;
|
||||
use crate::device::requirements::Requirements;
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::{Error, Feature, InternalError, InternalKind, RuntimeInput, Unsupported};
|
||||
pub use crate::lower::mesh::{RECORDS_SLOT, WORK_SLOT};
|
||||
use crate::pipeline::artifact::{Reconvergence, SpecializationLayout, StageModule, StrategyCensus};
|
||||
use crate::pipeline::interface::{MeshRecords, RecordField, RecordValue, StageInterface};
|
||||
use crate::pipeline::stage_io::{IoNumeric, StageBuiltin};
|
||||
use crate::error::{Error, RuntimeInput};
|
||||
use crate::pipeline::interface::StageInterface;
|
||||
use crate::pipeline::sym::Stage;
|
||||
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{GlobalId, TypeId, Value};
|
||||
use crate::spirv::ir::{
|
||||
natural_layout, BinOp, ConstBits, Constant, ConvOp, ExecModel, IoDecor, IoDir, LayoutRule,
|
||||
MemAccess, StorageClass, Type, TypedModule,
|
||||
};
|
||||
use crate::spirv::serialize::{SymbolTable, ENTRY_NAME};
|
||||
use crate::spv::BuiltIn as B;
|
||||
use crate::vk;
|
||||
|
||||
/// Where a corner that draws nothing lies, in clip coordinates of `w` 1: `x` and `y` this far
|
||||
/// past the clip volume, so every primitive of such corners lies wholly outside it, a point or a
|
||||
/// wide line included.
|
||||
pub const FAR: f32 = 65536.0;
|
||||
|
||||
/// The payload check of the mesh render pipeline of stages `ifaces`: its mesh function's payload
|
||||
/// arena holds at least its object function's (`StageInterface::payload`,
|
||||
@@ -81,318 +21,3 @@ pub fn payload(ifaces: &[&StageInterface]) -> Result<(), Error> {
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
/// The records of the mesh render pipeline of stages `ifaces` whose mesh function is emulated
|
||||
/// (`StageInterface::mesh_records`); `None` where its mesh function is not. A fragment function
|
||||
/// that reads `[[primitive_id]]` behind an emulated mesh function is
|
||||
/// `NotImplemented(MeshShading)` (the module docs).
|
||||
pub fn records(ifaces: &[&StageInterface]) -> Result<Option<MeshRecords>, Error> {
|
||||
let Some(r) = ifaces.iter().find_map(|i| i.mesh_records.as_ref()) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let reads_id = ifaces.iter().any(|i| {
|
||||
i.stage == Stage::Fragment
|
||||
&& (i.io.builtins.contains(&StageBuiltin::PrimitiveId)
|
||||
|| i.io
|
||||
.inputs
|
||||
.iter()
|
||||
.any(|v| v.role == crate::pipeline::stage_io::IoRole::PrimitiveId))
|
||||
});
|
||||
if reads_id {
|
||||
return Err(Unsupported::not_implemented(Feature::MeshShading).into());
|
||||
}
|
||||
// An object threadgroup's slot holds the larger of the object and mesh functions' payloads
|
||||
// (Metal links payloads of different sizes).
|
||||
let payload = ifaces
|
||||
.iter()
|
||||
.filter_map(|i| i.emulated_payload)
|
||||
.max()
|
||||
.unwrap_or(0);
|
||||
let slot_words = crate::lower::mesh::work::GRID
|
||||
.checked_add(payload)
|
||||
.ok_or_else(|| {
|
||||
Error::Internal(InternalError::new(
|
||||
InternalKind::Invariant,
|
||||
"mesh records: a payload past the slot's word range".to_owned(),
|
||||
))
|
||||
})?;
|
||||
Ok(Some(MeshRecords {
|
||||
slot_words,
|
||||
..r.clone()
|
||||
}))
|
||||
}
|
||||
|
||||
/// The synthesized vertex stage of records `r`, each primitive drawn from its last index first
|
||||
/// where `last_first`, as a final module under link table `table`, with its module's
|
||||
/// requirements: verified by the owned verifier, serialized, and relocated, as a compiled
|
||||
/// function's module is.
|
||||
pub fn synthesized_stage(
|
||||
r: &MeshRecords,
|
||||
last_first: bool,
|
||||
table: &impl SymbolTable,
|
||||
p: &DeviceProfile,
|
||||
m: &mut Meter,
|
||||
) -> Result<(StageModule, Requirements), Error> {
|
||||
let module = vertex_module(r, last_first)?;
|
||||
let stats = crate::spirv::verify::verify(&module, p, m)?;
|
||||
let module = crate::spirv::serialize::serialize(module)?;
|
||||
let words = crate::spirv::serialize::relocate(&module, table)?;
|
||||
Ok((
|
||||
StageModule {
|
||||
stage: vk::ShaderStage::VERTEX,
|
||||
entry_point: ENTRY_NAME.to_owned(),
|
||||
spirv: words.into(),
|
||||
specialization: SpecializationLayout::default(),
|
||||
required_subgroup_size: None,
|
||||
stage_flags: vk::PipelineShaderStageCreateFlags::empty(),
|
||||
reconvergence: Reconvergence::Guaranteed,
|
||||
precision_notes: Vec::new(),
|
||||
strategies: StrategyCensus::default(),
|
||||
constant_blob: None,
|
||||
rounded_colors: Vec::new(),
|
||||
specialized_notes: Vec::new(),
|
||||
own_pixel_textures: Vec::new(),
|
||||
snapshot_textures: Vec::new(),
|
||||
snapshot_refusals: Vec::new(),
|
||||
level_reads: Vec::new(),
|
||||
private_bytes: 0,
|
||||
stats,
|
||||
},
|
||||
module.requirements,
|
||||
))
|
||||
}
|
||||
|
||||
fn ku(fb: &mut FunctionBuilder<'_>, v: u32) -> BResult<Value> {
|
||||
let c = fb.u32_const(v)?;
|
||||
fb.module().const_value(c)
|
||||
}
|
||||
|
||||
fn kf(fb: &mut FunctionBuilder<'_>, v: f32) -> BResult<Value> {
|
||||
let ty = fb.module().ty(Type::Float { width: 32 })?;
|
||||
let c = fb.module().constant(Constant::Scalar {
|
||||
ty,
|
||||
bits: ConstBits(u64::from(v.to_bits())),
|
||||
})?;
|
||||
fb.module().const_value(c)
|
||||
}
|
||||
|
||||
/// Word `at` of the records.
|
||||
fn word(fb: &mut FunctionBuilder<'_>, records: GlobalId, at: Value) -> BResult<Value> {
|
||||
let zero = ku(fb, 0)?;
|
||||
let base = fb.module().global_value(records)?;
|
||||
let ptr = fb.access_chain(base, &[zero, at])?;
|
||||
fb.load(ptr, MemAccess::default())
|
||||
}
|
||||
|
||||
/// The scalar type of `numeric`.
|
||||
fn scalar(mb: &mut ModuleBuilder, numeric: IoNumeric) -> BResult<TypeId> {
|
||||
match numeric {
|
||||
IoNumeric::Float => mb.ty(Type::Float { width: 32 }),
|
||||
IoNumeric::Sint => mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: true,
|
||||
}),
|
||||
IoNumeric::Uint => mb.ty(Type::Int {
|
||||
width: 32,
|
||||
signed: false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
/// The lanes of field `f` of the record at word `record`, each of its numeric type.
|
||||
fn lanes(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
records: GlobalId,
|
||||
record: Value,
|
||||
f: &RecordField,
|
||||
) -> BResult<Vec<Value>> {
|
||||
let ty = scalar(fb.module(), f.numeric)?;
|
||||
let mut out = Vec::with_capacity(f.words as usize);
|
||||
for j in 0..f.words {
|
||||
let off = ku(fb, f.offset + j)?;
|
||||
let at = fb.binary(BinOp::IAdd, record, off)?;
|
||||
let w = word(fb, records, at)?;
|
||||
out.push(match f.numeric {
|
||||
IoNumeric::Uint => w,
|
||||
IoNumeric::Float | IoNumeric::Sint => fb.convert(ConvOp::Bitcast, w, ty)?,
|
||||
});
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// What one field becomes: the output it is stored to and that output's type.
|
||||
struct Out<'r> {
|
||||
field: &'r RecordField,
|
||||
global: GlobalId,
|
||||
ty: TypeId,
|
||||
}
|
||||
|
||||
/// The synthesized vertex stage of records `r`, each primitive drawn from its last index first
|
||||
/// where `last_first` (the module docs).
|
||||
pub fn vertex_module(r: &MeshRecords, last_first: bool) -> BResult<TypedModule> {
|
||||
let mut mb = ModuleBuilder::new();
|
||||
let u32_ = scalar(&mut mb, IoNumeric::Uint)?;
|
||||
let f32_ = scalar(&mut mb, IoNumeric::Float)?;
|
||||
let vec4 = mb.ty(Type::Vector { elem: f32_, len: 4 })?;
|
||||
let void = mb.ty(Type::Void)?;
|
||||
let words = mb.ty(Type::RuntimeArray {
|
||||
elem: u32_,
|
||||
stride: Some(4),
|
||||
})?;
|
||||
let layout = natural_layout(mb.types(), LayoutRule::Std430, true, &[words])?;
|
||||
let block = mb.ty(Type::Struct {
|
||||
members: [words].into(),
|
||||
layout: Some(layout),
|
||||
})?;
|
||||
let records = mb.resource(RECORDS_SLOT, StorageClass::StorageBuffer, block)?;
|
||||
let work = mb.resource(WORK_SLOT, StorageClass::StorageBuffer, block)?;
|
||||
let vertex_index = mb.builtin(B::VertexIndex, IoDir::Input, u32_)?;
|
||||
let position = mb.builtin(B::Position, IoDir::Output, vec4)?;
|
||||
let find = |value: RecordValue| r.fields.iter().find(|f| f.value == value);
|
||||
let position_field = find(RecordValue::Position);
|
||||
let culled_field = find(RecordValue::Culled);
|
||||
let size_field = find(RecordValue::PointSize);
|
||||
// A point list needs its point sizes; a mesh that writes them has them in any topology.
|
||||
let point_size = if r.corners == 1 || size_field.is_some() {
|
||||
Some(mb.builtin(B::PointSize, IoDir::Output, f32_)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut outs = Vec::new();
|
||||
for f in &r.fields {
|
||||
let (global, ty) = match &f.value {
|
||||
RecordValue::Position | RecordValue::PointSize | RecordValue::Culled => continue,
|
||||
RecordValue::ClipDistance => {
|
||||
let len = mb.constant(Constant::Scalar {
|
||||
ty: u32_,
|
||||
bits: ConstBits(u64::from(f.words)),
|
||||
})?;
|
||||
let ty = mb.ty(Type::Array {
|
||||
elem: f32_,
|
||||
len,
|
||||
stride: None,
|
||||
})?;
|
||||
(mb.builtin(B::ClipDistance, IoDir::Output, ty)?, ty)
|
||||
}
|
||||
RecordValue::Layer => (mb.builtin(B::Layer, IoDir::Output, u32_)?, u32_),
|
||||
RecordValue::ViewportIndex => {
|
||||
(mb.builtin(B::ViewportIndex, IoDir::Output, u32_)?, u32_)
|
||||
}
|
||||
RecordValue::Varying(key) => {
|
||||
let elem = scalar(&mut mb, f.numeric)?;
|
||||
let ty = match f.words {
|
||||
1 => elem,
|
||||
n => mb.ty(Type::Vector { elem, len: n as u8 })?,
|
||||
};
|
||||
(
|
||||
mb.io(key.clone(), IoDir::Output, ty, IoDecor::default())?,
|
||||
ty,
|
||||
)
|
||||
}
|
||||
};
|
||||
outs.push(Out {
|
||||
field: f,
|
||||
global,
|
||||
ty,
|
||||
});
|
||||
}
|
||||
let mut fb = mb.function(void)?;
|
||||
let p = fb.module().global_value(vertex_index)?;
|
||||
let v = fb.load(p, MemAccess::default())?;
|
||||
// `v = (g · NP + s) · k + c`.
|
||||
let per_group = ku(&mut fb, r.primitives.saturating_mul(r.corners))?;
|
||||
let k = ku(&mut fb, r.corners)?;
|
||||
let g = fb.binary(BinOp::UDiv, v, per_group)?;
|
||||
let rem = fb.binary(BinOp::UMod, v, per_group)?;
|
||||
let slot = fb.binary(BinOp::UDiv, rem, k)?;
|
||||
let mut corner = fb.binary(BinOp::UMod, rem, k)?;
|
||||
// Drawn from the last index first: corner `(c + k - 1) mod k`.
|
||||
if last_first && r.corners > 1 {
|
||||
let back = ku(&mut fb, r.corners - 1)?;
|
||||
let moved = fb.binary(BinOp::IAdd, corner, back)?;
|
||||
corner = fb.binary(BinOp::UMod, moved, k)?;
|
||||
}
|
||||
// The threadgroup's records, from the draw's first word: within a `u32`, since the binder
|
||||
// binds them whole.
|
||||
let at = ku(&mut fb, crate::lower::mesh::work::RECORDS_BASE)?;
|
||||
let base = word(&mut fb, work, at)?;
|
||||
let group_words = ku(&mut fb, r.group_words() as u32)?;
|
||||
let mine = fb.binary(BinOp::IMul, g, group_words)?;
|
||||
let first = fb.binary(BinOp::IAdd, base, mine)?;
|
||||
let count = word(&mut fb, records, first)?;
|
||||
let primitive_base = ku(&mut fb, r.primitive_base() as u32)?;
|
||||
let stride = ku(&mut fb, r.primitive_words)?;
|
||||
let into = fb.binary(BinOp::IMul, slot, stride)?;
|
||||
let primitives = fb.binary(BinOp::IAdd, first, primitive_base)?;
|
||||
let primitive = fb.binary(BinOp::IAdd, primitives, into)?;
|
||||
let at = fb.binary(BinOp::IAdd, primitive, corner)?;
|
||||
let index = word(&mut fb, records, at)?;
|
||||
let below = fb.binary(BinOp::ULessThan, slot, count)?;
|
||||
let nv = ku(&mut fb, r.vertices)?;
|
||||
let named = fb.binary(BinOp::ULessThan, index, nv)?;
|
||||
let mut drawn = fb.binary(BinOp::LogicalAnd, below, named)?;
|
||||
if let Some(f) = culled_field {
|
||||
let off = ku(&mut fb, f.offset)?;
|
||||
let at = fb.binary(BinOp::IAdd, primitive, off)?;
|
||||
let culled = word(&mut fb, records, at)?;
|
||||
let zero = ku(&mut fb, 0)?;
|
||||
let kept = fb.binary(BinOp::IEqual, culled, zero)?;
|
||||
drawn = fb.binary(BinOp::LogicalAnd, drawn, kept)?;
|
||||
}
|
||||
let zero = ku(&mut fb, 0)?;
|
||||
let index = fb.select(drawn, index, zero)?;
|
||||
let one = ku(&mut fb, 1)?;
|
||||
let vertex_stride = ku(&mut fb, r.vertex_words)?;
|
||||
let into = fb.binary(BinOp::IMul, index, vertex_stride)?;
|
||||
let vertices = fb.binary(BinOp::IAdd, first, one)?;
|
||||
let vertex = fb.binary(BinOp::IAdd, vertices, into)?;
|
||||
// The position, or `FAR` where the corner draws nothing.
|
||||
let written = match position_field {
|
||||
Some(f) => lanes(&mut fb, records, vertex, f)?,
|
||||
None => vec![
|
||||
kf(&mut fb, 0.0)?,
|
||||
kf(&mut fb, 0.0)?,
|
||||
kf(&mut fb, 0.0)?,
|
||||
kf(&mut fb, 1.0)?,
|
||||
],
|
||||
};
|
||||
let far = [FAR, FAR, 0.0, 1.0];
|
||||
let mut xyzw = Vec::with_capacity(4);
|
||||
for (lane, away) in written.into_iter().zip(far) {
|
||||
let away = kf(&mut fb, away)?;
|
||||
xyzw.push(fb.select(drawn, lane, away)?);
|
||||
}
|
||||
let value = fb.composite_construct(vec4, &xyzw)?;
|
||||
let p = fb.module().global_value(position)?;
|
||||
fb.store(p, value, MemAccess::default())?;
|
||||
if let Some(g) = point_size {
|
||||
let written = match size_field {
|
||||
Some(f) => lanes(&mut fb, records, vertex, f)?,
|
||||
None => Vec::new(),
|
||||
};
|
||||
let size = match written.first() {
|
||||
Some(&size) => size,
|
||||
None => kf(&mut fb, 1.0)?,
|
||||
};
|
||||
let p = fb.module().global_value(g)?;
|
||||
fb.store(p, size, MemAccess::default())?;
|
||||
}
|
||||
for o in &outs {
|
||||
let record = if o.field.per_primitive {
|
||||
primitive
|
||||
} else {
|
||||
vertex
|
||||
};
|
||||
let parts = lanes(&mut fb, records, record, o.field)?;
|
||||
let value = match parts.as_slice() {
|
||||
[one] if !matches!(o.field.value, RecordValue::ClipDistance) => *one,
|
||||
_ => fb.composite_construct(o.ty, &parts)?,
|
||||
};
|
||||
let p = fb.module().global_value(o.global)?;
|
||||
fb.store(p, value, MemAccess::default())?;
|
||||
}
|
||||
fb.ret(None)?;
|
||||
let f = fb.finish()?;
|
||||
mb.entry(ExecModel::Vertex, f, Vec::new())?;
|
||||
mb.finalize()
|
||||
}
|
||||
@@ -129,9 +129,6 @@ pub(super) fn iface(
|
||||
io: positioned(stage, StageIo::default()),
|
||||
tessellation: None,
|
||||
writes_memory: false,
|
||||
mesh_records: None,
|
||||
mesh_corners: None,
|
||||
emulated_payload: None,
|
||||
payload: None,
|
||||
reaches_command_buffers: false,
|
||||
command_writes: Default::default(),
|
||||
|
||||
@@ -359,7 +359,7 @@ fn a_selected_slice_and_viewport_take_the_stages() {
|
||||
/// `LayeredRendering`: a post-tessellation vertex function and a vertex function's own
|
||||
/// `ViewportIndex` beside a selected slice as not implemented, and a selected viewport drawn as
|
||||
/// multiview without `multiviewGeometryShader` as needing the output instead. A selected slice is
|
||||
/// never drawn as multiview, and an emulated mesh pipeline's indices take no stage.
|
||||
/// never drawn as multiview.
|
||||
#[test]
|
||||
fn what_the_stages_cannot_carry_for_an_index_is_refused() {
|
||||
let p = profile("lavapipe");
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
//! (`LoweringInputs::window_depth_varying`), and one linked with another vertex function is
|
||||
//! `NeedsInput(FramebufferFetch)`.
|
||||
//! The primitive ID (`IoRole::PrimitiveId`) is such a varying, read flat: a fragment function
|
||||
//! compiled for a device that cannot declare a fragment `PrimitiveId`, or for an emulated
|
||||
//! post-tessellation vertex function, reads its `[[primitive_id]]` from it, and its pipeline's
|
||||
//! compiled for a device that cannot declare a fragment `PrimitiveId` reads its
|
||||
//! `[[primitive_id]]` from it, and its pipeline's
|
||||
//! vertex function writes it, compiled under `LoweringInputs::primitive_id_varying`
|
||||
//! (`NeedsInput(PrimitiveId)` otherwise, and for a fragment function that reads Vulkan's
|
||||
//! `PrimitiveId` behind a vertex function that writes the varying). A mesh function writes none,
|
||||
@@ -36,9 +36,7 @@
|
||||
//! every vertex output's, below `maxFragmentInputComponents / 4`, and is never packed. A
|
||||
//! fragment function alone numbers them with its other inputs.
|
||||
//! - **Mesh outputs**, per vertex and per primitive alike, are numbered densely in output order,
|
||||
//! one location each at component 0, within `maxMeshOutputComponents / 4` locations
|
||||
//! (`maxVertexOutputComponents / 4` for an emulated mesh function's, which its pipeline's
|
||||
//! synthesized vertex stage writes). In a mesh render pipeline each fragment input takes the
|
||||
//! one location each at component 0, within `maxMeshOutputComponents / 4` locations. In a mesh render pipeline each fragment input takes the
|
||||
//! number of the mesh output of its key and type (`UnmatchedVarying` without one), below
|
||||
//! `maxFragmentInputComponents / 4`; the raw indices follow the vertex rule above. The fragment
|
||||
//! function reads per primitive exactly the inputs whose keys the mesh function writes per
|
||||
@@ -348,17 +346,13 @@ pub fn assign(stages: &[&FunctionArtifact], p: &DeviceProfile) -> Result<Locatio
|
||||
let mut vertex: Option<&StageIo> = None;
|
||||
let mut fragment: Option<&StageIo> = None;
|
||||
let mut mesh: Option<&StageIo> = None;
|
||||
let mut emulated_mesh = false;
|
||||
for a in stages {
|
||||
let io = &a.interface.io;
|
||||
check_roles(a.interface.stage, io)?;
|
||||
match a.interface.stage {
|
||||
Stage::Vertex => vertex = Some(io),
|
||||
Stage::Fragment => fragment = Some(io),
|
||||
Stage::Mesh => {
|
||||
mesh = Some(io);
|
||||
emulated_mesh = a.interface.mesh_records.is_some();
|
||||
}
|
||||
Stage::Mesh => mesh = Some(io),
|
||||
Stage::Kernel | Stage::Object => {}
|
||||
}
|
||||
}
|
||||
@@ -374,18 +368,13 @@ pub fn assign(stages: &[&FunctionArtifact], p: &DeviceProfile) -> Result<Locatio
|
||||
let mut table = Locations::new();
|
||||
if let Some(m) = mesh {
|
||||
let need = m.outputs.len() as u64;
|
||||
let (limit, available) = match emulated_mesh {
|
||||
true => (
|
||||
VkLimit::MaxVertexOutputComponents,
|
||||
l.max_vertex_output_components,
|
||||
),
|
||||
false => (
|
||||
VkLimit::MaxMeshOutputComponents,
|
||||
l.mesh.max_mesh_output_components,
|
||||
),
|
||||
};
|
||||
let available = l.mesh.max_mesh_output_components;
|
||||
if need.saturating_mul(4) > u64::from(available) {
|
||||
return Err(limit_error(limit, need, available));
|
||||
return Err(limit_error(
|
||||
VkLimit::MaxMeshOutputComponents,
|
||||
need,
|
||||
available,
|
||||
));
|
||||
}
|
||||
for (n, x) in m.outputs.iter().enumerate() {
|
||||
table.insert(x.key.clone(), (n as u32, 0));
|
||||
|
||||
@@ -124,10 +124,9 @@ pub use graphics::{
|
||||
};
|
||||
pub use interface::{
|
||||
AccessSet, AttributeFetch, BufferForm, BufferKind, BufferSlot, CommandWrites, DescriptorView,
|
||||
LevelReads, MeshRecords, NumberedSampler, PatchDomain, PipelineInterface, PlacedField, PushLoc,
|
||||
PushPlacement, RecordField, RecordValue, SampledLevels, SamplerArray, SamplerLevels,
|
||||
SamplerSlot, SlotInterface, SnapshotRefusal, TextureAccess, TextureSlot, ThreadgroupArgument,
|
||||
Window,
|
||||
LevelReads, NumberedSampler, PatchDomain, PipelineInterface, PlacedField, PushLoc,
|
||||
PushPlacement, SampledLevels, SamplerArray, SamplerLevels, SamplerSlot, SlotInterface,
|
||||
SnapshotRefusal, TextureAccess, TextureSlot, ThreadgroupArgument, Window,
|
||||
};
|
||||
pub use layout::{
|
||||
BindingSource, DescriptorBinding, DescriptorSetLayout, PipelineLayout, PushConstantRange,
|
||||
|
||||
@@ -340,17 +340,6 @@ pub enum SyntheticBinding {
|
||||
/// its words ([`FunctionTableSnapshot`](crate::bind::FunctionTableSnapshot)). The stage's
|
||||
/// function-table directory gives each id the word offset of its table's record.
|
||||
FunctionTableSnapshot,
|
||||
/// An emulated mesh function's records (`StageInterface::mesh_records`): a storage buffer of
|
||||
/// words from the draw's first word (`lower::mesh::work::RECORDS_BASE`), each mesh
|
||||
/// threadgroup's zeroed by its own threads before its body runs, which the mesh function's
|
||||
/// compute entry writes and the pipeline's synthesized vertex stage reads. Declared with the
|
||||
/// mesh stage's symbols.
|
||||
MeshRecords,
|
||||
/// An emulated mesh pipeline's work buffer for one draw: its object threadgroups' grids and
|
||||
/// payloads, their offsets in the draw's mesh threadgroups, and where its records begin,
|
||||
/// which its object function writes and its mesh function and synthesized vertex stage read
|
||||
/// (`lower::mesh::work`). Declared with the mesh stage's symbols.
|
||||
MeshWork,
|
||||
/// The stand-in of the render pass's depth attachment a fragment function that runs the
|
||||
/// draw's depth test itself tests and writes (`GraphicsState::shader_tests`): a coherent
|
||||
/// `R32f` storage image holding pixel `(x, y)`'s depth at texel `(x, y)` (its samples as the
|
||||
|
||||
@@ -24,12 +24,6 @@
|
||||
//! The trace also ends at an `OpIAdd` whose one operand is a load of the address member, whatever
|
||||
//! the other: the guest does not hold the address, so no sum of the guest's has such an operand.
|
||||
//!
|
||||
//! An emulated mesh function's records (`Synthetic(MeshRecords)`) are the product's too, traced as
|
||||
//! the status buffer's binding is: they hand the function's outputs to the pipeline's synthesized
|
||||
//! vertex stage, as a mesh function's output variables would. So is an emulated object function's
|
||||
//! slot of its draw's work buffer (`Synthetic(MeshWork)`), which hands its grid and payload to the
|
||||
//! mesh function, as `OpEmitMeshTasksEXT` would.
|
||||
//!
|
||||
//! The shader-side stencil's shadow (`Synthetic(ShadowStencil)`) is the product's too: its writes
|
||||
//! carry Metal's stencil test, which Metal applies per sample whether the function runs per pixel
|
||||
//! or per sample, so they do not make the function run per sample. An image write counts unless its
|
||||
@@ -99,8 +93,7 @@ fn class(m: &TypedModule, ptr: Value) -> BResult<StorageClass> {
|
||||
/// is traced through.
|
||||
#[derive(Default)]
|
||||
struct Status<'m> {
|
||||
/// The variables of the `Synthetic(ExecutionStatus)`, `Synthetic(MeshRecords)` and
|
||||
/// `Synthetic(MeshWork)` bindings.
|
||||
/// The variables of the `Synthetic(ExecutionStatus)` binding.
|
||||
bindings: Vec<Value>,
|
||||
/// The variables of the `Synthetic(ShadowStencil)`, `Synthetic(DepthStandIn)`,
|
||||
/// `Synthetic(StencilStandIn)`, `TileAttachment`, `ExtendedShadow` and `SnapshotTexels`
|
||||
@@ -123,11 +116,7 @@ impl<'m> Status<'m> {
|
||||
GlobalKind::Resource(slot)
|
||||
if matches!(
|
||||
slot.kind,
|
||||
ResourceKind::Synthetic(
|
||||
SyntheticBinding::ExecutionStatus
|
||||
| SyntheticBinding::MeshRecords
|
||||
| SyntheticBinding::MeshWork
|
||||
)
|
||||
ResourceKind::Synthetic(SyntheticBinding::ExecutionStatus)
|
||||
) =>
|
||||
{
|
||||
s.bindings.push(g.value);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3,36 +3,23 @@
|
||||
//! The owned fixture `engine/mesh_partial_barrier` holds three object functions, whose barriers
|
||||
//! stand in uniform control flow and in a loop, after a divergent early return, and under a
|
||||
//! thread-dependent condition, and a mesh function that returns before its barrier. On every
|
||||
//! committed profile, natively or emulated, each object function runs a `drawMeshThreads` partial
|
||||
//! object threadgroup (`RuntimeFact::PartialObjectThreadgroups`) and is walked predicated from its
|
||||
//! threadgroup's threads (`lower::simd::divergent`'s partial object threadgroups), the mesh function
|
||||
//! is walked predicated for its divergent barrier, and no workgroup barrier of a body stands in a
|
||||
//! block the body's own uniformity does not prove uniform (`spirv::testing::barriers`). On the
|
||||
//! emulating profiles, whose object functions are compute entries, each object function runs on
|
||||
//! the CPU interpreter under Vulkan's barrier rule (`BarrierRule::Vulkan`: an invocation that
|
||||
//! returned while others wait at a barrier traps), in both scheduling orders, for draws that leave
|
||||
//! partial threadgroups and for whole ones, giving the reading where the threads that reach a
|
||||
//! barrier synchronize among themselves: Metal's threads alone count themselves and write, the
|
||||
//! invocations past a partial threadgroup's threads writing nothing. No GPU is used.
|
||||
//! committed profile with `VK_EXT_mesh_shader`, each object function runs a `drawMeshThreads`
|
||||
//! partial object threadgroup (`RuntimeFact::PartialObjectThreadgroups`) and is walked predicated
|
||||
//! from its threadgroup's threads (`lower::simd::divergent`'s partial object threadgroups), the mesh
|
||||
//! function is walked predicated for its divergent barrier, and no workgroup barrier of a body
|
||||
//! stands in a block the body's own uniformity does not prove uniform
|
||||
//! (`spirv::testing::barriers`). No GPU is used.
|
||||
//!
|
||||
//! `llvm-as` assembles the fixtures; a missing tool skips visibly.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use super::engine_mesh::{device, emulating_profiles, fixture, mesh_profiles};
|
||||
use super::engine_mesh::{device, fixture, mesh_profiles};
|
||||
use crate::bind::{BindState, DrawCall};
|
||||
use crate::budget::Budget;
|
||||
use crate::library::Library;
|
||||
use crate::lower::mesh::{work, OBJECT_RECORDS_SLOT, OBJECT_WORK_SLOT};
|
||||
use crate::lower::select::Plan;
|
||||
use crate::pipeline::descriptor::{FunctionDescriptor, MeshPipelineDescriptor, StageSource};
|
||||
use crate::pipeline::facts::RuntimeFact;
|
||||
use crate::pipeline::interface::PushLoc;
|
||||
use crate::pipeline::sym::{
|
||||
Axis, PushField, ResourceKind, ResourceSlot, SpecKey, Stage, SyntheticBinding,
|
||||
};
|
||||
use crate::pipeline::sym::Stage;
|
||||
use crate::pipeline::testing::typed_module;
|
||||
use crate::spirv::interp::{run, BarrierRule, Buffer, Config, Order, Resources, SubgroupSize};
|
||||
use crate::spirv::ir::{Inst, TypedModule};
|
||||
use crate::spirv::testing::barriers::workgroup_barriers_of;
|
||||
|
||||
@@ -46,12 +33,6 @@ const OBJECTS: [&str; 3] = [
|
||||
/// The fixture's mesh function with a divergent barrier.
|
||||
const MESH: &str = "mesh_partial_barrier_mesh_early_return";
|
||||
|
||||
/// The words of out a case's buffer starts as, but its count.
|
||||
const POISON: u32 = 0xABAB_ABAB;
|
||||
|
||||
/// The control words: the loop's trip count and the threads that stay past the early return.
|
||||
const CTL: [u32; 4] = [3, 3, 0, 0];
|
||||
|
||||
/// The function the entry of `m` calls: an object or mesh function's body, which its entry wrapper
|
||||
/// calls between its own barriers.
|
||||
fn body(m: &TypedModule) -> crate::spirv::ids::FuncId {
|
||||
@@ -78,11 +59,7 @@ fn object_and_mesh_functions_wait_at_their_barriers_predicated() {
|
||||
let Some(bc) = fixture("mesh_partial_barrier") else {
|
||||
return;
|
||||
};
|
||||
let profiles: Vec<_> = mesh_profiles()
|
||||
.into_iter()
|
||||
.chain(emulating_profiles())
|
||||
.collect();
|
||||
for (stem, p) in &profiles {
|
||||
for (stem, p) in &mesh_profiles() {
|
||||
for entry in OBJECTS.into_iter().chain([MESH]) {
|
||||
let what = format!("{stem} {entry}");
|
||||
let object = entry != MESH;
|
||||
@@ -121,7 +98,7 @@ fn object_and_mesh_functions_wait_at_their_barriers_predicated() {
|
||||
}
|
||||
|
||||
/// An object function whose body waits at a threadgroup barrier draws a `drawMeshThreads` that
|
||||
/// leaves a partial object threadgroup, emulated or not: its pipeline records
|
||||
/// leaves a partial object threadgroup: its pipeline records
|
||||
/// `PartialObjectThreadgroups`, and both whole and partial draws instantiate, a partial one at the
|
||||
/// threadgroups its threads fill, rounded up. `icb_object_threadgroup_object`'s barriers stand
|
||||
/// under its thread 0's condition, the fixture's in uniform control flow.
|
||||
@@ -157,7 +134,7 @@ fn a_partial_object_threadgroup_of_a_body_with_a_barrier_draws() {
|
||||
threads_per_object_group: [4, 1, 1],
|
||||
threads_per_mesh_group: [8, 1, 1],
|
||||
};
|
||||
for (stem, _) in mesh_profiles().into_iter().chain(emulating_profiles()) {
|
||||
for (stem, _) in mesh_profiles() {
|
||||
let dev = device(&stem);
|
||||
for (lib, object, mesh) in pipelines {
|
||||
let what = format!("{stem} {object}");
|
||||
@@ -182,235 +159,15 @@ fn a_partial_object_threadgroup_of_a_body_with_a_barrier_draws() {
|
||||
let cmds = plan
|
||||
.instantiate_draw(&state, &draw([6, 1, 1]))
|
||||
.unwrap_or_else(|e| panic!("{what}: a partial object threadgroup: {e}"));
|
||||
let groups = match (&cmds.mesh_dispatch, &cmds.draw) {
|
||||
(Some(d), _) => d.object_groups,
|
||||
(
|
||||
None,
|
||||
crate::vk::DrawCommand::DrawMeshTasks {
|
||||
group_count_x,
|
||||
group_count_y,
|
||||
group_count_z,
|
||||
},
|
||||
) => Some([*group_count_x, *group_count_y, *group_count_z]),
|
||||
(None, other) => panic!("{what}: {other:?}"),
|
||||
let groups = match &cmds.draw {
|
||||
crate::vk::DrawCommand::DrawMeshTasks {
|
||||
group_count_x,
|
||||
group_count_y,
|
||||
group_count_z,
|
||||
} => [*group_count_x, *group_count_y, *group_count_z],
|
||||
other => panic!("{what}: {other:?}"),
|
||||
};
|
||||
assert_eq!(groups, Some([2, 1, 1]), "{what}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One draw: Metal's threads and its threads per object threadgroup.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Draw {
|
||||
threads: [u32; 2],
|
||||
l: [u32; 2],
|
||||
}
|
||||
|
||||
/// The draws each object function runs: partial threadgroups along x, along both axes, past a
|
||||
/// simdgroup, and whole ones.
|
||||
const DRAWS: [Draw; 5] = [
|
||||
Draw {
|
||||
threads: [6, 1],
|
||||
l: [4, 1],
|
||||
},
|
||||
Draw {
|
||||
threads: [5, 3],
|
||||
l: [4, 2],
|
||||
},
|
||||
Draw {
|
||||
threads: [37, 1],
|
||||
l: [32, 1],
|
||||
},
|
||||
Draw {
|
||||
threads: [2, 1],
|
||||
l: [4, 1],
|
||||
},
|
||||
Draw {
|
||||
threads: [8, 2],
|
||||
l: [4, 2],
|
||||
},
|
||||
];
|
||||
|
||||
/// The words of out after `draw` of object function `entry`, by the reading where the threads
|
||||
/// that reach a barrier synchronize among themselves: every Metal thread counted in word 0, each
|
||||
/// writing its two words at its grid position, the rest of the buffer untouched.
|
||||
fn expected(entry: &str, draw: Draw) -> Vec<u32> {
|
||||
let [tx, ty] = draw.threads;
|
||||
let [lx, ly] = draw.l;
|
||||
let mut out = vec![POISON; 4 + 2 * (tx * ty) as usize];
|
||||
out[0] = tx * ty;
|
||||
for gy in 0..ty.div_ceil(ly) {
|
||||
for gx in 0..tx.div_ceil(lx) {
|
||||
// The threads this threadgroup runs, per axis.
|
||||
let rx = (tx - gx * lx).min(lx);
|
||||
let ry = (ty - gy * ly).min(ly);
|
||||
let n = rx * ry;
|
||||
let stay = CTL[1].min(n);
|
||||
let mut words: Vec<u32> = (0..n).map(|t| t * 3 + 1).collect();
|
||||
let mut acc = vec![0u32; n as usize];
|
||||
for _ in 0..CTL[0] {
|
||||
let next: Vec<u32> = (0..n).map(|t| words[((t + 1) % n) as usize]).collect();
|
||||
for t in 0..n as usize {
|
||||
acc[t] += next[t];
|
||||
words[t] = next[t] + 100;
|
||||
}
|
||||
}
|
||||
for y in 0..ry {
|
||||
for x in 0..rx {
|
||||
let tid = x + rx * y;
|
||||
let (px, py) = (gx * lx + x, gy * ly + y);
|
||||
let at = (4 + 2 * (px + tx * py)) as usize;
|
||||
out[at] = match entry {
|
||||
"mesh_partial_barrier_uniform" => {
|
||||
acc[tid as usize] + words[((tid + 2) % n) as usize]
|
||||
}
|
||||
"mesh_partial_barrier_early_return" if tid >= stay => 0xE000_0000 | tid,
|
||||
"mesh_partial_barrier_early_return" => ((tid + 1) % stay) * 3 + 1,
|
||||
"mesh_partial_barrier_if" if tid < stay => ((tid + 1) % stay) * 5 + 2,
|
||||
"mesh_partial_barrier_if" => 0xE100_0000 | tid,
|
||||
other => panic!("no expectation for {other}"),
|
||||
};
|
||||
out[at + 1] = rx | (ry << 8) | (tid << 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn bytes(w: &[u32]) -> Vec<u8> {
|
||||
w.iter().flat_map(|x| x.to_le_bytes()).collect()
|
||||
}
|
||||
|
||||
fn words(b: &[u8]) -> Vec<u32> {
|
||||
b.as_chunks::<4>()
|
||||
.0
|
||||
.iter()
|
||||
.map(|c| u32::from_le_bytes([c[0], c[1], c[2], c[3]]))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The out buffer after `draw` of the emulated object module `m` (planned as `plan`), every object
|
||||
/// threadgroup its threads fill a workgroup of the whole size, the draw's region flagged
|
||||
/// `lower::dispatch::NONUNIFORM` as the binder flags a `drawMeshThreads`, with `lanes`-wide
|
||||
/// subgroups under Vulkan's barrier rule, identical in both scheduling orders.
|
||||
fn run_draw(plan: &Plan, m: &TypedModule, draw: Draw, lanes: SubgroupSize) -> Vec<u32> {
|
||||
let [tx, ty] = draw.threads;
|
||||
let [lx, ly] = draw.l;
|
||||
let groups = [tx.div_ceil(lx), ty.div_ceil(ly), 1];
|
||||
let mut spec = BTreeMap::new();
|
||||
for (a, v) in [Axis::X, Axis::Y, Axis::Z].into_iter().zip([lx, ly, 1]) {
|
||||
spec.insert(SpecKey::ObjectLocalSize(a), u64::from(v));
|
||||
}
|
||||
spec.insert(SpecKey::ObjectFlatLocalSize, u64::from(lx * ly));
|
||||
spec.insert(SpecKey::ObjectMultiRegion, 1);
|
||||
let mut push = vec![0u8; plan.push.push_range.map_or(0, |(_, end)| end as usize)];
|
||||
// The fields a profile's push window has no room for: every offset word 0.
|
||||
let mut table = vec![0u8; plan.push.argument_table_size.max(4) as usize];
|
||||
for f in &plan.push.fields {
|
||||
match (f.field, f.loc) {
|
||||
(PushField::DispatchRegion, loc) => {
|
||||
let region = crate::lower::dispatch::partial_region_bytes([tx, ty, 1], [lx, ly, 1])
|
||||
.expect("a region");
|
||||
let (words, at) = match loc {
|
||||
PushLoc::Push { offset } => (&mut push, offset as usize),
|
||||
PushLoc::ArgumentTable { offset } => (&mut table, offset as usize),
|
||||
};
|
||||
words[at..at + region.len()].copy_from_slice(®ion);
|
||||
}
|
||||
// Every buffer is bound at offset 0, wherever its offset word is placed.
|
||||
(PushField::SlotBindOffset(_), _) => {}
|
||||
other => panic!("unexpected push field {other:?}"),
|
||||
}
|
||||
}
|
||||
let slot = |index| {
|
||||
Some(ResourceSlot {
|
||||
stage: Stage::Object,
|
||||
kind: ResourceKind::Buffer,
|
||||
index,
|
||||
})
|
||||
};
|
||||
let objects = u64::from(groups[0] * groups[1]);
|
||||
let slot_words = work::GRID + plan.families.mesh.payload_words;
|
||||
let mut header = vec![0u32; work::words(objects, slot_words) as usize];
|
||||
header[work::SLOT_WORDS as usize] = slot_words;
|
||||
header[work::OBJECT_GROUPS as usize] = u32::try_from(objects).expect("a word");
|
||||
let mut out = vec![POISON; 4 + 2 * (tx * ty) as usize];
|
||||
out[0] = 0;
|
||||
let res = Resources {
|
||||
buffers: vec![
|
||||
Buffer {
|
||||
slot: slot(0),
|
||||
address: None,
|
||||
bytes: bytes(&out),
|
||||
},
|
||||
Buffer {
|
||||
slot: slot(1),
|
||||
address: None,
|
||||
bytes: bytes(&CTL),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(OBJECT_WORK_SLOT),
|
||||
address: None,
|
||||
bytes: bytes(&header),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(OBJECT_RECORDS_SLOT),
|
||||
address: None,
|
||||
bytes: bytes(&[0; 4]),
|
||||
},
|
||||
Buffer {
|
||||
slot: Some(ResourceSlot {
|
||||
stage: Stage::Object,
|
||||
kind: ResourceKind::Synthetic(SyntheticBinding::ArgumentTable),
|
||||
index: 0,
|
||||
}),
|
||||
address: None,
|
||||
bytes: table,
|
||||
},
|
||||
],
|
||||
push,
|
||||
spec,
|
||||
};
|
||||
let mut outs = Vec::new();
|
||||
for order in [Order::Forward, Order::Reverse] {
|
||||
let cfg = Config {
|
||||
workgroups: groups,
|
||||
subgroup: lanes,
|
||||
order,
|
||||
barriers: BarrierRule::Vulkan,
|
||||
..Config::default()
|
||||
};
|
||||
let o = run(m, &cfg, res.clone()).unwrap_or_else(|e| panic!("{draw:?} {lanes:?}: {e}"));
|
||||
outs.push(o.buffers);
|
||||
}
|
||||
assert_eq!(
|
||||
outs[0][0], outs[1][0],
|
||||
"{draw:?} {lanes:?}: order independent"
|
||||
);
|
||||
words(&outs[0][0])
|
||||
}
|
||||
|
||||
/// Each object function of the fixture, compiled as a compute entry on every emulating profile,
|
||||
/// runs each of [`DRAWS`] on the interpreter under Vulkan's barrier rule and answers the reading
|
||||
/// where the threads that reach a barrier synchronize among themselves: the invocations past a
|
||||
/// partial threadgroup's threads reach every barrier, count nothing and write nothing.
|
||||
#[test]
|
||||
fn partial_object_threadgroups_wait_at_barriers_as_metal_runs_them() {
|
||||
let Some(bc) = fixture("mesh_partial_barrier") else {
|
||||
return;
|
||||
};
|
||||
for (stem, p) in emulating_profiles() {
|
||||
for entry in OBJECTS {
|
||||
let what = format!("{stem} {entry}");
|
||||
let (plan, m) = typed_module(&bc, entry, &p).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
assert!(plan.families.mesh.emulated, "{what}: a compute entry");
|
||||
for draw in DRAWS {
|
||||
for lanes in [SubgroupSize::W8, SubgroupSize::W32] {
|
||||
let got = run_draw(&plan, &m, draw, lanes);
|
||||
assert_eq!(got, expected(entry, draw), "{what} {draw:?} {lanes:?}");
|
||||
}
|
||||
}
|
||||
assert_eq!(groups, [2, 1, 1], "{what}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,6 @@ fn modules() -> Vec<Build> {
|
||||
plain!(
|
||||
index_bounds_fill_module,
|
||||
index_bounds_plan_module,
|
||||
mesh_object_arguments_module,
|
||||
mesh_scan_module,
|
||||
replay_preprocess_module,
|
||||
ycbcr_write_module,
|
||||
);
|
||||
|
||||
@@ -124,16 +124,6 @@ assoc-const metal2vulkan::bind::MeshArgumentsModule::SCRATCH_BINDING pub const S
|
||||
assoc-const metal2vulkan::bind::MeshArgumentsModule::SET pub const SET: u32
|
||||
assoc-const metal2vulkan::bind::MeshArgumentsModule::SOURCE_BINDING pub const SOURCE_BINDING: u32
|
||||
assoc-const metal2vulkan::bind::MeshArgumentsModule::STATUS_BINDING pub const STATUS_BINDING: u32
|
||||
assoc-const metal2vulkan::bind::MeshDispatch::DISPATCH_OFFSET pub const DISPATCH_OFFSET: u64
|
||||
assoc-const metal2vulkan::bind::MeshDispatch::DRAW_ID pub const DRAW_ID: usize
|
||||
assoc-const metal2vulkan::bind::MeshDispatch::DRAW_OFFSET pub const DRAW_OFFSET: u64
|
||||
assoc-const metal2vulkan::bind::MeshDispatch::POOL_WORDS pub const POOL_WORDS: usize
|
||||
assoc-const metal2vulkan::bind::MeshScanModule::ARGUMENTS_BINDING pub const ARGUMENTS_BINDING: u32
|
||||
assoc-const metal2vulkan::bind::MeshScanModule::LOCAL_SIZE pub const LOCAL_SIZE: u32
|
||||
assoc-const metal2vulkan::bind::MeshScanModule::RECORDS_BINDING pub const RECORDS_BINDING: u32
|
||||
assoc-const metal2vulkan::bind::MeshScanModule::SET pub const SET: u32
|
||||
assoc-const metal2vulkan::bind::MeshScanModule::STATUS_BINDING pub const STATUS_BINDING: u32
|
||||
assoc-const metal2vulkan::bind::MeshScanModule::WORK_BINDING pub const WORK_BINDING: u32
|
||||
assoc-const metal2vulkan::bind::NeutralResource::SINK_BYTES pub const SINK_BYTES: u32
|
||||
assoc-const metal2vulkan::bind::PlanesCopy::ALL pub const ALL: [PlanesCopy; 6]
|
||||
assoc-const metal2vulkan::bind::PlanesMergeModules::PLANES_BINDING pub const PLANES_BINDING: u32
|
||||
@@ -168,10 +158,9 @@ assoc-const metal2vulkan::bind::StatusBits::CUBIC_ARGUMENT_SAMPLER pub const CUB
|
||||
assoc-const metal2vulkan::bind::StatusBits::INDEX_POOL_OVERFLOW pub const INDEX_POOL_OVERFLOW: StatusBits
|
||||
assoc-const metal2vulkan::bind::StatusBits::MESH_GRID_DISCARDED pub const MESH_GRID_DISCARDED: StatusBits
|
||||
assoc-const metal2vulkan::bind::StatusBits::MESH_GRID_PAST_LIMITS pub const MESH_GRID_PAST_LIMITS: StatusBits
|
||||
assoc-const metal2vulkan::bind::StatusBits::MESH_RECORDS_OVERFLOW pub const MESH_RECORDS_OVERFLOW: StatusBits
|
||||
assoc-const metal2vulkan::bind::StatusBits::REPLAY_FAULT pub const REPLAY_FAULT: StatusBits
|
||||
assoc-const metal2vulkan::bind::StatusBits::RESIDENT_MISS pub const RESIDENT_MISS: StatusBits
|
||||
assoc-const metal2vulkan::bind::StatusWord::ALL pub const ALL: [StatusWord; 8]
|
||||
assoc-const metal2vulkan::bind::StatusWord::ALL pub const ALL: [StatusWord; 4]
|
||||
assoc-const metal2vulkan::bind::StencilBit::ALL pub const ALL: [StencilBit; 8]
|
||||
assoc-const metal2vulkan::bind::StencilSplitModule::DESTINATION_BINDING pub const DESTINATION_BINDING: u32
|
||||
assoc-const metal2vulkan::bind::StencilSplitModule::LOCAL_SIZE pub const LOCAL_SIZE: u32
|
||||
@@ -401,16 +390,6 @@ assoc-const-value metal2vulkan::bind::MeshArgumentsModule::SCRATCH_BINDING 1
|
||||
assoc-const-value metal2vulkan::bind::MeshArgumentsModule::SET 0
|
||||
assoc-const-value metal2vulkan::bind::MeshArgumentsModule::SOURCE_BINDING 0
|
||||
assoc-const-value metal2vulkan::bind::MeshArgumentsModule::STATUS_BINDING 2
|
||||
assoc-const-value metal2vulkan::bind::MeshDispatch::DISPATCH_OFFSET 4 * crate::lower::mesh::work::DISPATCH as u64
|
||||
assoc-const-value metal2vulkan::bind::MeshDispatch::DRAW_ID crate::lower::mesh::work::DRAW_ID as usize
|
||||
assoc-const-value metal2vulkan::bind::MeshDispatch::DRAW_OFFSET 4 * crate::lower::mesh::work::DRAW as u64
|
||||
assoc-const-value metal2vulkan::bind::MeshDispatch::POOL_WORDS crate::lower::mesh::work::POOL_WORDS as usize
|
||||
assoc-const-value metal2vulkan::bind::MeshScanModule::ARGUMENTS_BINDING 2
|
||||
assoc-const-value metal2vulkan::bind::MeshScanModule::LOCAL_SIZE 64
|
||||
assoc-const-value metal2vulkan::bind::MeshScanModule::RECORDS_BINDING 3
|
||||
assoc-const-value metal2vulkan::bind::MeshScanModule::SET 0
|
||||
assoc-const-value metal2vulkan::bind::MeshScanModule::STATUS_BINDING 1
|
||||
assoc-const-value metal2vulkan::bind::MeshScanModule::WORK_BINDING 0
|
||||
assoc-const-value metal2vulkan::bind::NeutralResource::SINK_BYTES 64
|
||||
assoc-const-value metal2vulkan::bind::PlanesCopy::ALL [PlanesCopy::R8, PlanesCopy::R16, PlanesCopy::R32, PlanesCopy::Rg32, PlanesCopy::Rgba32, PlanesCopy::Alpha8]
|
||||
assoc-const-value metal2vulkan::bind::PlanesMergeModules::PLANES_BINDING 0
|
||||
@@ -445,10 +424,9 @@ assoc-const-value metal2vulkan::bind::StatusBits::CUBIC_ARGUMENT_SAMPLER StatusB
|
||||
assoc-const-value metal2vulkan::bind::StatusBits::INDEX_POOL_OVERFLOW StatusBits(1 <<3)
|
||||
assoc-const-value metal2vulkan::bind::StatusBits::MESH_GRID_DISCARDED StatusBits(1 <<10)
|
||||
assoc-const-value metal2vulkan::bind::StatusBits::MESH_GRID_PAST_LIMITS StatusBits(1 <<9)
|
||||
assoc-const-value metal2vulkan::bind::StatusBits::MESH_RECORDS_OVERFLOW StatusBits(1 <<5)
|
||||
assoc-const-value metal2vulkan::bind::StatusBits::REPLAY_FAULT StatusBits(1 <<2)
|
||||
assoc-const-value metal2vulkan::bind::StatusBits::RESIDENT_MISS StatusBits(1 <<1)
|
||||
assoc-const-value metal2vulkan::bind::StatusWord::ALL [StatusWord::Status, StatusWord::ResidentMisses, StatusWord::ReplayFaults, StatusWord::MeshRecordsCursor, StatusWord::MeshFaultDraw, StatusWord::MeshFaultObjects, StatusWord::MeshFaultGroups, StatusWord::SeqCstFences]
|
||||
assoc-const-value metal2vulkan::bind::StatusWord::ALL [StatusWord::Status, StatusWord::ResidentMisses, StatusWord::ReplayFaults, StatusWord::SeqCstFences]
|
||||
assoc-const-value metal2vulkan::bind::StencilBit::ALL [StencilBit(0), StencilBit(1), StencilBit(2), StencilBit(3), StencilBit(4), StencilBit(5), StencilBit(6), StencilBit(7)]
|
||||
assoc-const-value metal2vulkan::bind::StencilSplitModule::DESTINATION_BINDING 1
|
||||
assoc-const-value metal2vulkan::bind::StencilSplitModule::LOCAL_SIZE 8
|
||||
@@ -946,8 +924,6 @@ enum metal2vulkan::bind::IndexOverrun #[cfg_attr(feature = "serde", derive(serde
|
||||
enum metal2vulkan::bind::IndirectArgs #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum IndirectArgs
|
||||
enum metal2vulkan::bind::MergePhase #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum MergePhase
|
||||
enum metal2vulkan::bind::MeshArgumentsForm #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum MeshArgumentsForm
|
||||
enum metal2vulkan::bind::MeshGroups #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum MeshGroups
|
||||
enum metal2vulkan::bind::MeshRecordsRegion #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum MeshRecordsRegion
|
||||
enum metal2vulkan::bind::NeutralResource #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum NeutralResource
|
||||
enum metal2vulkan::bind::PlanDiagnostic #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum PlanDiagnostic
|
||||
enum metal2vulkan::bind::PlanesCopy #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum PlanesCopy
|
||||
@@ -1073,7 +1049,6 @@ enum metal2vulkan::pipeline::PrecisionNote #[cfg_attr(feature = "serde", derive(
|
||||
enum metal2vulkan::pipeline::PushField #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum PushField
|
||||
enum metal2vulkan::pipeline::PushLoc #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum PushLoc
|
||||
enum metal2vulkan::pipeline::Reconvergence #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Reconvergence
|
||||
enum metal2vulkan::pipeline::RecordValue #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RecordValue
|
||||
enum metal2vulkan::pipeline::RegionFanOut #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum RegionFanOut
|
||||
enum metal2vulkan::pipeline::ResourceKind #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum ResourceKind
|
||||
enum metal2vulkan::pipeline::RotatedBlendForm #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum RotatedBlendForm
|
||||
@@ -2103,7 +2078,6 @@ field metal2vulkan::bind::BindShape.imageblock_size pub imageblock_size: Imagebl
|
||||
field metal2vulkan::bind::BindShape.interlocked_colors pub interlocked_colors: BTreeSet<u32>
|
||||
field metal2vulkan::bind::BindShape.kept_imageblock_bytes pub kept_imageblock_bytes: Option<u32>
|
||||
field metal2vulkan::bind::BindShape.line_band pub line_band: Option<crate::pipeline::BandPrimitive>
|
||||
field metal2vulkan::bind::BindShape.mesh_last_first pub mesh_last_first: bool
|
||||
field metal2vulkan::bind::BindShape.primitive_id_indices pub primitive_id_indices: Option<metal::IndexType>
|
||||
field metal2vulkan::bind::BindShape.private_list pub private_list: bool
|
||||
field metal2vulkan::bind::BindShape.quad_primitive_ids pub quad_primitive_ids: bool
|
||||
@@ -2136,7 +2110,6 @@ field metal2vulkan::bind::BindState.imageblock_size pub imageblock_size: Imagebl
|
||||
field metal2vulkan::bind::BindState.interlocked_colors pub interlocked_colors: BTreeSet<u32>
|
||||
field metal2vulkan::bind::BindState.kept_imageblock_bytes pub kept_imageblock_bytes: Option<u32>
|
||||
field metal2vulkan::bind::BindState.line_band pub line_band: Option<(crate::pipeline::BandPrimitive, [f32; 4])>
|
||||
field metal2vulkan::bind::BindState.mesh_last_first pub mesh_last_first: bool
|
||||
field metal2vulkan::bind::BindState.primitive_id_indices pub primitive_id_indices: Option<metal::IndexType>
|
||||
field metal2vulkan::bind::BindState.primitive_type pub primitive_type: Option<metal::PrimitiveType>
|
||||
field metal2vulkan::bind::BindState.private_list pub private_list: bool
|
||||
@@ -2232,7 +2205,6 @@ field metal2vulkan::bind::DrawCommands.index_bounds_pass pub index_bounds_pass:
|
||||
field metal2vulkan::bind::DrawCommands.index_overrun pub index_overrun: Option<IndexOverrun>
|
||||
field metal2vulkan::bind::DrawCommands.indirect_needs_arguments pub indirect_needs_arguments: bool
|
||||
field metal2vulkan::bind::DrawCommands.mesh_arguments pub mesh_arguments: Option<MeshArgumentsForm>
|
||||
field metal2vulkan::bind::DrawCommands.mesh_dispatch pub mesh_dispatch: Option<MeshDispatch>
|
||||
field metal2vulkan::bind::DrawCommands.object_fold pub object_fold: Option<crate::bind::ObjectFold>
|
||||
field metal2vulkan::bind::DrawCommands.push_constants pub push_constants: Vec<PushConstantWrite>
|
||||
field metal2vulkan::bind::DrawCommands.push_holes pub push_holes: Vec<PushHole>
|
||||
@@ -2341,21 +2313,10 @@ field metal2vulkan::bind::MeshArguments.source_range pub source_range: BufferRan
|
||||
field metal2vulkan::bind::MeshArgumentsModule.requirements pub requirements: Requirements
|
||||
field metal2vulkan::bind::MeshArgumentsModule.rule pub rule: MeshGridRule
|
||||
field metal2vulkan::bind::MeshArgumentsModule.spirv pub spirv: Arc<[u32]>
|
||||
field metal2vulkan::bind::MeshDispatch.mesh pub mesh: MeshGroups
|
||||
field metal2vulkan::bind::MeshDispatch.object_arguments pub object_arguments: Option<BufferRange>
|
||||
field metal2vulkan::bind::MeshDispatch.object_groups pub object_groups: Option<[u32; 3]>
|
||||
field metal2vulkan::bind::MeshDispatch.records pub records: MeshRecordsRegion
|
||||
field metal2vulkan::bind::MeshDispatch.work pub work: Vec<u32>
|
||||
field metal2vulkan::bind::MeshDispatch.work_bytes pub work_bytes: u64
|
||||
field metal2vulkan::bind::MeshGridLimits.axes pub axes: [u32; 3]
|
||||
field metal2vulkan::bind::MeshGridLimits.total pub total: u32
|
||||
field metal2vulkan::bind::MeshGridRule.device pub device: MeshGridLimits
|
||||
field metal2vulkan::bind::MeshGridRule.metal pub metal: Option<MeshGridLimits>
|
||||
field metal2vulkan::bind::MeshRecordsFault.draw pub draw: u32
|
||||
field metal2vulkan::bind::MeshRecordsFault.mesh_threadgroups pub mesh_threadgroups: u32
|
||||
field metal2vulkan::bind::MeshRecordsFault.object_threadgroups pub object_threadgroups: u32
|
||||
field metal2vulkan::bind::MeshScanModule.requirements pub requirements: Requirements
|
||||
field metal2vulkan::bind::MeshScanModule.spirv pub spirv: Arc<[u32]>
|
||||
field metal2vulkan::bind::MetalInstance.intersection_function_table_offset pub intersection_function_table_offset: u32
|
||||
field metal2vulkan::bind::MetalInstance.mask pub mask: u32
|
||||
field metal2vulkan::bind::MetalInstance.options pub options: u32
|
||||
@@ -2486,7 +2447,6 @@ field metal2vulkan::bind::StatusReport.cubic_argument_sampler pub cubic_argument
|
||||
field metal2vulkan::bind::StatusReport.index_pool_overflow pub index_pool_overflow: bool
|
||||
field metal2vulkan::bind::StatusReport.mesh_grid_discarded pub mesh_grid_discarded: bool
|
||||
field metal2vulkan::bind::StatusReport.mesh_grid_past_limits pub mesh_grid_past_limits: bool
|
||||
field metal2vulkan::bind::StatusReport.mesh_records_overflow pub mesh_records_overflow: Option<MeshRecordsFault>
|
||||
field metal2vulkan::bind::StatusReport.replay_fault pub replay_fault: bool
|
||||
field metal2vulkan::bind::StatusReport.replay_faults pub replay_faults: ReplayFaults
|
||||
field metal2vulkan::bind::StatusReport.resident_miss pub resident_miss: bool
|
||||
@@ -2600,7 +2560,6 @@ field metal2vulkan::cache::VariantKey.interlocked_colors pub interlocked_colors:
|
||||
field metal2vulkan::cache::VariantKey.kept_imageblock_bytes pub kept_imageblock_bytes: Option<u32>
|
||||
field metal2vulkan::cache::VariantKey.line_band pub line_band: Option<crate::pipeline::BandPrimitive>
|
||||
field metal2vulkan::cache::VariantKey.merged_draws pub merged_draws: bool
|
||||
field metal2vulkan::cache::VariantKey.mesh_last_first pub mesh_last_first: bool
|
||||
field metal2vulkan::cache::VariantKey.one_row pub one_row: bool
|
||||
field metal2vulkan::cache::VariantKey.open_cl_lines pub open_cl_lines: BTreeSet<SlotRef>
|
||||
field metal2vulkan::cache::VariantKey.partial_threadgroups pub partial_threadgroups: bool
|
||||
@@ -3106,8 +3065,6 @@ field metal2vulkan::pipeline::GraphicsState.interpolates_at_sample pub interpola
|
||||
field metal2vulkan::pipeline::GraphicsState.line_band pub line_band: Option<LineBandState>
|
||||
field metal2vulkan::pipeline::GraphicsState.logic_op pub logic_op: Option<vk::LogicOp>
|
||||
field metal2vulkan::pipeline::GraphicsState.max_vertex_amplification_count pub max_vertex_amplification_count: u32
|
||||
field metal2vulkan::pipeline::GraphicsState.mesh_corners pub mesh_corners: Option<u32>
|
||||
field metal2vulkan::pipeline::GraphicsState.mesh_records pub mesh_records: Option<MeshRecords>
|
||||
field metal2vulkan::pipeline::GraphicsState.rasterization_order_attachment_access pub rasterization_order_attachment_access: bool
|
||||
field metal2vulkan::pipeline::GraphicsState.rasterization_samples pub rasterization_samples: vk::SampleCountFlags
|
||||
field metal2vulkan::pipeline::GraphicsState.rasterizer_discard pub rasterizer_discard: bool
|
||||
@@ -3256,13 +3213,6 @@ field metal2vulkan::pipeline::MeshPipelineMetalInfo.max_total_threads_per_mesh_t
|
||||
field metal2vulkan::pipeline::MeshPipelineMetalInfo.max_total_threads_per_object_threadgroup pub max_total_threads_per_object_threadgroup: u32
|
||||
field metal2vulkan::pipeline::MeshPipelineMetalInfo.mesh_thread_execution_width pub mesh_thread_execution_width: u32
|
||||
field metal2vulkan::pipeline::MeshPipelineMetalInfo.object_thread_execution_width pub object_thread_execution_width: u32
|
||||
field metal2vulkan::pipeline::MeshRecords.corners pub corners: u32
|
||||
field metal2vulkan::pipeline::MeshRecords.fields pub fields: Vec<RecordField>
|
||||
field metal2vulkan::pipeline::MeshRecords.primitive_words pub primitive_words: u32
|
||||
field metal2vulkan::pipeline::MeshRecords.primitives pub primitives: u32
|
||||
field metal2vulkan::pipeline::MeshRecords.slot_words pub slot_words: u32
|
||||
field metal2vulkan::pipeline::MeshRecords.vertex_words pub vertex_words: u32
|
||||
field metal2vulkan::pipeline::MeshRecords.vertices pub vertices: u32
|
||||
field metal2vulkan::pipeline::ModuleStats.blocks pub blocks: u32
|
||||
field metal2vulkan::pipeline::ModuleStats.constructs pub constructs: u32
|
||||
field metal2vulkan::pipeline::ModuleStats.functions pub functions: u32
|
||||
@@ -3620,8 +3570,6 @@ fn metal2vulkan::bind::instance_record pub fn instance_record(instance: &MetalIn
|
||||
fn metal2vulkan::bind::interleave_merge_modules pub fn interleave_merge_modules(device: &Device, samples: u32) -> Result<InterleaveMergeModules, Error>
|
||||
fn metal2vulkan::bind::interleave_split_module pub fn interleave_split_module(device: &Device, copy: PlanesCopy, samples: u32) -> Result<InterleaveSplitModule, Error>
|
||||
fn metal2vulkan::bind::mesh_arguments_module pub fn mesh_arguments_module(device: &Device, form: MeshArgumentsForm) -> Result<MeshArgumentsModule, Error>
|
||||
fn metal2vulkan::bind::mesh_object_arguments_module pub fn mesh_object_arguments_module(device: &Device) -> Result<MeshScanModule, Error>
|
||||
fn metal2vulkan::bind::mesh_scan_module pub fn mesh_scan_module(device: &Device) -> Result<MeshScanModule, Error>
|
||||
fn metal2vulkan::bind::metal_object_grid pub fn metal_object_grid(groups: [u32; 3], threads: [u32; 3], direct: bool) -> Option<([u32; 3], [u32; 3])>
|
||||
fn metal2vulkan::bind::part_texels pub fn part_texels(limits: &Limits) -> u64
|
||||
fn metal2vulkan::bind::planes_merge_modules pub fn planes_merge_modules(device: &Device, copy: PlanesCopy) -> Result<PlanesMergeModules, Error>
|
||||
@@ -7545,9 +7493,6 @@ method metal2vulkan::pipeline::MeshPipelineDescriptor::reflection pub fn reflect
|
||||
method metal2vulkan::pipeline::MeshPipelineDescriptor::slot_writes pub fn slot_writes(&self, budget: &crate::Budget) -> Result<SlotWrites, Error>
|
||||
method metal2vulkan::pipeline::MeshPipelineDescriptor::stages_using_direct_arguments pub fn stages_using_direct_arguments(&self, budget: &crate::Budget, entries: &StageEntries) -> Result<Vec<DirectArgumentUse>, Error>
|
||||
method metal2vulkan::pipeline::MeshPipelineDescriptor::unwritten_fragment_inputs pub fn unwritten_fragment_inputs(&self, budget: &crate::Budget, entries: &StageEntries) -> Result<Option<UnwrittenFragmentInputs>, Error>
|
||||
method metal2vulkan::pipeline::MeshRecords::group_words pub fn group_words(&self) -> u64
|
||||
method metal2vulkan::pipeline::MeshRecords::primitive_base pub fn primitive_base(&self) -> u64
|
||||
method metal2vulkan::pipeline::MeshRecords::topology pub fn topology(&self) -> vk::PrimitiveTopology
|
||||
method metal2vulkan::pipeline::PrecisionNote::of_float_operator pub fn of_float_operator(op: AirBin, width: FloatWidth, fmf: FastMath, p: &DeviceProfile, math: EntryMath) -> Option<BTreeSet<PrecisionNote>>
|
||||
method metal2vulkan::pipeline::PrecisionNote::of_math_call pub fn of_math_call(call: Math, fmf: FastMath, p: &DeviceProfile, math: EntryMath) -> Option<BTreeSet<PrecisionNote>>
|
||||
method metal2vulkan::pipeline::PrivateRenderState::new pub const fn new() -> PrivateRenderState
|
||||
@@ -7977,11 +7922,8 @@ struct metal2vulkan::bind::InterleaveSplitModule #[derive(Clone, Debug, PartialE
|
||||
struct metal2vulkan::bind::MergedLayout #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MergedLayout
|
||||
struct metal2vulkan::bind::MeshArguments #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MeshArguments
|
||||
struct metal2vulkan::bind::MeshArgumentsModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct MeshArgumentsModule
|
||||
struct metal2vulkan::bind::MeshDispatch #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MeshDispatch
|
||||
struct metal2vulkan::bind::MeshGridLimits #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MeshGridLimits
|
||||
struct metal2vulkan::bind::MeshGridRule #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MeshGridRule
|
||||
struct metal2vulkan::bind::MeshRecordsFault #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MeshRecordsFault
|
||||
struct metal2vulkan::bind::MeshScanModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct MeshScanModule
|
||||
struct metal2vulkan::bind::MetalInstance #[derive(Clone, Copy, Debug, PartialEq)] #[non_exhaustive] pub struct MetalInstance
|
||||
struct metal2vulkan::bind::ObjectFold #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct ObjectFold
|
||||
struct metal2vulkan::bind::PlanesMergeModules #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct PlanesMergeModules
|
||||
@@ -8145,7 +8087,6 @@ struct metal2vulkan::pipeline::LinkedSource #[derive(Clone, Copy, Debug)] pub st
|
||||
struct metal2vulkan::pipeline::LoweringInputs #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct LoweringInputs
|
||||
struct metal2vulkan::pipeline::MeshPipelineDescriptor #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct MeshPipelineDescriptor
|
||||
struct metal2vulkan::pipeline::MeshPipelineMetalInfo #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MeshPipelineMetalInfo
|
||||
struct metal2vulkan::pipeline::MeshRecords #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct MeshRecords
|
||||
struct metal2vulkan::pipeline::ModuleStats #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct ModuleStats
|
||||
struct metal2vulkan::pipeline::PipelineInterface #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct PipelineInterface
|
||||
struct metal2vulkan::pipeline::PipelineLayout #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct PipelineLayout
|
||||
@@ -9875,7 +9816,6 @@ variant metal2vulkan::bind::DrawCall::Primitives Primitives { vertex_start: u32,
|
||||
variant metal2vulkan::bind::DrawReplayRule::Amplified Amplified
|
||||
variant metal2vulkan::bind::DrawReplayRule::ArgumentsOnCpu ArgumentsOnCpu
|
||||
variant metal2vulkan::bind::DrawReplayRule::CommandTypes CommandTypes
|
||||
variant metal2vulkan::bind::DrawReplayRule::DispatchesFirst DispatchesFirst
|
||||
variant metal2vulkan::bind::DrawReplayRule::FragmentImageblock FragmentImageblock
|
||||
variant metal2vulkan::bind::DrawReplayRule::FragmentWritesMemory FragmentWritesMemory
|
||||
variant metal2vulkan::bind::DrawReplayRule::IndexBounds IndexBounds
|
||||
@@ -9935,10 +9875,6 @@ variant metal2vulkan::bind::MergePhase::Starts Starts
|
||||
variant metal2vulkan::bind::MeshArgumentsForm::FoldedObject FoldedObject
|
||||
variant metal2vulkan::bind::MeshArgumentsForm::Mesh Mesh
|
||||
variant metal2vulkan::bind::MeshArgumentsForm::Object Object
|
||||
variant metal2vulkan::bind::MeshGroups::Direct Direct([u32; 3])
|
||||
variant metal2vulkan::bind::MeshGroups::Scanned Scanned { arguments: Option<BufferRange> }
|
||||
variant metal2vulkan::bind::MeshRecordsRegion::Exact Exact(u64)
|
||||
variant metal2vulkan::bind::MeshRecordsRegion::Pool Pool
|
||||
variant metal2vulkan::bind::NeutralResource::Image Image { view_type: vk::ImageViewType, sampled_type: SampledType, depth_compare: bool, samples: u32, storage_format: Option<vk::Format> }
|
||||
variant metal2vulkan::bind::NeutralResource::Sampler Sampler { compare: bool }
|
||||
variant metal2vulkan::bind::NeutralResource::Sink Sink { min_bytes: u32 }
|
||||
@@ -10022,10 +9958,6 @@ variant metal2vulkan::bind::RewriteSource::IndirectVertices IndirectVertices { a
|
||||
variant metal2vulkan::bind::SamplerSource::Immutable Immutable
|
||||
variant metal2vulkan::bind::SamplerSource::Neutral Neutral(NeutralResource)
|
||||
variant metal2vulkan::bind::SamplerSource::Slot Slot { slot: SlotRef, compare: bool, integer: bool, opaque_black: OpaqueBlackBorder }
|
||||
variant metal2vulkan::bind::StatusWord::MeshFaultDraw MeshFaultDraw
|
||||
variant metal2vulkan::bind::StatusWord::MeshFaultGroups MeshFaultGroups
|
||||
variant metal2vulkan::bind::StatusWord::MeshFaultObjects MeshFaultObjects
|
||||
variant metal2vulkan::bind::StatusWord::MeshRecordsCursor MeshRecordsCursor
|
||||
variant metal2vulkan::bind::StatusWord::ReplayFaults ReplayFaults
|
||||
variant metal2vulkan::bind::StatusWord::ResidentMisses ResidentMisses
|
||||
variant metal2vulkan::bind::StatusWord::SeqCstFences SeqCstFences
|
||||
@@ -10071,8 +10003,6 @@ variant metal2vulkan::bind::WriteSource::HandleTable HandleTable { stage: Stage,
|
||||
variant metal2vulkan::bind::WriteSource::HeapEntry HeapEntry { class: HandleClass, element: u32, source: HeapSource, view: ImageViewDesc }
|
||||
variant metal2vulkan::bind::WriteSource::Imageblock Imageblock
|
||||
variant metal2vulkan::bind::WriteSource::InlineBytes InlineBytes { slot: SlotRef }
|
||||
variant metal2vulkan::bind::WriteSource::MeshRecords MeshRecords
|
||||
variant metal2vulkan::bind::WriteSource::MeshWork MeshWork
|
||||
variant metal2vulkan::bind::WriteSource::Neutral Neutral(NeutralResource)
|
||||
variant metal2vulkan::bind::WriteSource::PatchIndices PatchIndices { min_bytes: u32 }
|
||||
variant metal2vulkan::bind::WriteSource::RateMapFlags RateMapFlags
|
||||
@@ -11373,13 +11303,6 @@ variant metal2vulkan::pipeline::PushLoc::ArgumentTable ArgumentTable { offset: u
|
||||
variant metal2vulkan::pipeline::PushLoc::Push Push { offset: u32 }
|
||||
variant metal2vulkan::pipeline::Reconvergence::Guaranteed Guaranteed
|
||||
variant metal2vulkan::pipeline::Reconvergence::ImplementationDefined ImplementationDefined
|
||||
variant metal2vulkan::pipeline::RecordValue::ClipDistance ClipDistance
|
||||
variant metal2vulkan::pipeline::RecordValue::Culled Culled
|
||||
variant metal2vulkan::pipeline::RecordValue::Layer Layer
|
||||
variant metal2vulkan::pipeline::RecordValue::PointSize PointSize
|
||||
variant metal2vulkan::pipeline::RecordValue::Position Position
|
||||
variant metal2vulkan::pipeline::RecordValue::Varying Varying(crate::pipeline::sym::VaryingKey)
|
||||
variant metal2vulkan::pipeline::RecordValue::ViewportIndex ViewportIndex
|
||||
variant metal2vulkan::pipeline::RegionFanOut::Draw Draw
|
||||
variant metal2vulkan::pipeline::RegionFanOut::DrawFew DrawFew
|
||||
variant metal2vulkan::pipeline::RegionFanOut::Probe Probe
|
||||
@@ -11447,7 +11370,6 @@ variant metal2vulkan::pipeline::RuntimeFact::InterlockedFramebufferFetch Interlo
|
||||
variant metal2vulkan::pipeline::RuntimeFact::LocalSizeConstraint LocalSizeConstraint { multiple: u32 }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::LocalSizeLimits LocalSizeLimits
|
||||
variant metal2vulkan::pipeline::RuntimeFact::MergedDraws MergedDraws
|
||||
variant metal2vulkan::pipeline::RuntimeFact::MeshLastFirst MeshLastFirst
|
||||
variant metal2vulkan::pipeline::RuntimeFact::MovableStorageWrites MovableStorageWrites { early_variant: bool }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::ObjectThreadgroupArena ObjectThreadgroupArena { static_bytes: u32, payload: Option<u32> }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::OneRow OneRow
|
||||
@@ -11619,8 +11541,6 @@ variant metal2vulkan::pipeline::SyntheticBinding::FunctionTableDirectory Functio
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::FunctionTableSnapshot FunctionTableSnapshot
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::HandleTable HandleTable
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::Imageblock Imageblock
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::MeshRecords MeshRecords
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::MeshWork MeshWork
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::PatchIndices PatchIndices
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::RateMapFlags RateMapFlags
|
||||
variant metal2vulkan::pipeline::SyntheticBinding::RateMapRegions RateMapRegions
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -380,15 +380,12 @@ surface! {
|
||||
struct CommandWrites E;
|
||||
enum DescriptorView N;
|
||||
struct LevelReads N;
|
||||
struct MeshRecords N;
|
||||
enum NumberedSampler N;
|
||||
enum PatchDomain N;
|
||||
struct PipelineInterface N;
|
||||
struct PlacedField N;
|
||||
enum PushLoc N;
|
||||
struct PushPlacement N;
|
||||
struct RecordField N;
|
||||
enum RecordValue N;
|
||||
struct SampledLevels N;
|
||||
struct SamplerArray N;
|
||||
struct SamplerLevels N;
|
||||
@@ -468,9 +465,6 @@ surface! {
|
||||
struct DrawCommands N;
|
||||
fn alpha_test_code;
|
||||
enum IndexOverrun N;
|
||||
struct MeshDispatch N;
|
||||
enum MeshGroups N;
|
||||
enum MeshRecordsRegion N;
|
||||
fn heap_classes;
|
||||
struct HeapElements O;
|
||||
enum HeapSource E;
|
||||
@@ -547,7 +541,6 @@ surface! {
|
||||
struct TileThreadgroupArgument N;
|
||||
enum FragmentTests N;
|
||||
struct ExecutionStatus E;
|
||||
struct MeshRecordsFault N;
|
||||
struct StatusBits E;
|
||||
struct StatusReport N;
|
||||
enum StatusWord N;
|
||||
@@ -626,9 +619,6 @@ surface! {
|
||||
enum EtcDecode N;
|
||||
enum EtcTexels N;
|
||||
enum ChromaDecode N;
|
||||
fn mesh_scan_module;
|
||||
fn mesh_object_arguments_module;
|
||||
struct MeshScanModule N;
|
||||
fn mesh_arguments_module;
|
||||
fn fold_object_grid;
|
||||
fn metal_object_grid;
|
||||
|
||||
+9
-20
@@ -594,8 +594,8 @@ through buffer arguments it reads at any index.
|
||||
threadgroup memory on a profile without it is `Unsupported` with
|
||||
`Feature::ZeroedThreadgroupMemory`. The translator's own `Workgroup` words have none: an
|
||||
emulated SIMD group's exchange scratch and vote word, an object function's mesh grid, a mesh
|
||||
function's primitive count and staged indices, an emulated object or mesh function's payload,
|
||||
and those of the binder's own scan, shadow-merge and index-rewrite kernels. Each is written
|
||||
function's primitive count and staged indices, and those of the binder's own shadow-merge and
|
||||
index-rewrite kernels. Each is written
|
||||
before any read of it, and an object function's payload "is assumed uninitialized at the entry
|
||||
of the object function" (the Metal Shading Language Specification, the `payload` attribute). Metal's documents give
|
||||
threadgroup memory no first contents: `MTLComputeCommandEncoder.h`'s
|
||||
@@ -874,7 +874,7 @@ Where Metal's rules differ from Vulkan's, the pipeline gives Metal's answer:
|
||||
function that selects its slice is refused needing either feature (its pass of one layer still
|
||||
runs), and so is one that selects its viewport on a device with `multiViewport`; one whose index
|
||||
differs among a primitive's vertices is refused needing `geometryShader`. The stages cannot serve
|
||||
a post-tessellation vertex function or an emulated mesh function, nor sit beside a vertex function
|
||||
a post-tessellation vertex function, nor sit beside a vertex function
|
||||
that writes the builtins itself (a device with the outputs but without
|
||||
`fragmentShaderBarycentric`): those are refused as not implemented. A fragment function that reads
|
||||
an index no stage writes, on a device that can declare neither builtin, reads 0, Metal's value
|
||||
@@ -972,16 +972,16 @@ the feature), and a fragment `[[primitive_id]]` behind it is `NotImplemented(Tes
|
||||
|
||||
`Device::compile_mesh_pipeline` compiles a `MeshPipelineDescriptor` (an optional object function,
|
||||
a mesh function and a fragment function), and `compile_mesh_variant` its variants. Its plan draws
|
||||
mesh draws only (`DrawCall::MeshThreadgroups`, `MeshThreads` and their indirect forms). With
|
||||
`VK_EXT_mesh_shader` the stages are task and mesh shaders. Without it (MoltenVK, older ANV) the
|
||||
pipeline is an exact emulation: the object and mesh functions run as compute stages that write the
|
||||
mesh's vertices and primitives as records into buffers, and a synthesized vertex stage draws those
|
||||
records; the plan says which dispatches and draw to record.
|
||||
mesh draws only (`DrawCall::MeshThreadgroups`, `MeshThreads` and their indirect forms). The
|
||||
stages are task and mesh shaders, which need `VK_EXT_mesh_shader` with `meshShader` (and
|
||||
`taskShader` for an object function). A device without them (MoltenVK, older ANV) refuses the
|
||||
pipeline and each of its object and mesh functions (`Unsupported{MeshShading}`, naming what it
|
||||
lacks).
|
||||
|
||||
A grid Metal draws nothing for (an axis past `bind::METAL_MESH_GRID_AXIS`, or more than
|
||||
`bind::METAL_MESH_GRID_TOTAL` threadgroups, measured on the M3 Max) draws nothing in every form:
|
||||
a direct draw's command is zeroed, an object function's wrapper launches nothing for such a grid,
|
||||
and an indirect draw reads its counts on the GPU. With the extension, an indirect draw's
|
||||
and an indirect draw reads its counts on the GPU. An indirect draw's
|
||||
`DrawCommands::mesh_arguments` is a pass to record before the render pass
|
||||
(`bind::mesh_arguments_module`, one invocation): it writes the draw's counts into the consumer's
|
||||
scratch (`MeshArguments::scratch_bytes`), which the draw reads in place of Metal's arguments.
|
||||
@@ -1011,17 +1011,6 @@ through `StatusBits::MESH_GRID_PAST_LIMITS`, or a fold of more pieces than
|
||||
A direct object grid past the task limits of a device that does not fold is refused naming the
|
||||
limit.
|
||||
|
||||
Without the extension, an indirect draw with an object function first dispatches an object
|
||||
arguments pass (`MeshDispatch::object_arguments`, `bind::mesh_object_arguments_module`, one
|
||||
invocation over the scan's bindings): it reads Metal's arguments, reserves the object threadgroups'
|
||||
slots in the command buffer's records pool, and writes the object function's
|
||||
`VkDispatchIndirectCommand` into the work buffer. A grid
|
||||
Metal's GPU discards sets `StatusBits::MESH_GRID_DISCARDED`; one past the device's compute limits
|
||||
sets `MESH_GRID_PAST_LIMITS`; slots the rest of the pool cannot hold set `MESH_RECORDS_OVERFLOW`.
|
||||
Each draws nothing. A grid whose threads per grid wrap along an axis runs every threadgroup, and
|
||||
the object function reports the wrapped grid as Metal's: an unfolded object function's
|
||||
`threadgroups_per_grid` is the threadgroups its wrapped threads fill.
|
||||
|
||||
### Tile pipelines
|
||||
|
||||
`Device::compile_tile_pipeline` compiles a `TileRenderPipelineDescriptor` (the tile function and the
|
||||
|
||||
+4
-4
@@ -131,7 +131,7 @@ Columns:
|
||||
| `VertexStepRate` | A vertex buffer layout stepped per instance at a rate above 1, on a profile that fetches every attribute in fixed function (the identity domains,... | devices without a capability the site computes (`needs`) | `device` | 1: `crates/metal2vulkan/src/metal/vertex.rs (divided)` | `app`: instanced vertex layouts stepped at a rate above 1 |
|
||||
| `VertexInputLayout` | A vertex attribute whose layout fixed-function input cannot fetch, on a profile that fetches every attribute in fixed function (the identity... | devices without a capability the site computes (`limit`); every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/pipeline/link/vertex.rs (resolve, 4 sites)` | `rare`: vertex offsets or strides off their format's alignment, or past a device's limits |
|
||||
| `Tessellation` | Tessellation | devices without VkFeature::TessellationShader; devices without VkLimit::MaxTessellationGenerationLevel; every device (not implemented) | `ours` | 13: `crates/metal2vulkan-air/src/canon/mod.rs (post_check, 2 sites)`, `crates/metal2vulkan/src/lower/stage_io/fetch.rs (select)` (+8) | `rare`: tessellation |
|
||||
| `MeshShading` | | devices short of a device limit the site names; devices without VkLimit::MaxMeshOutputLayers; devices without VkLimit::MaxTaskPayloadSize; devices without a capability the site computes (`missing`); every device (not implemented) | `ours` | 7: `crates/metal2vulkan/src/bind/graphics.rs (mesh_limit)`, `crates/metal2vulkan/src/bind/graphics.rs (plan)` (+4) | `rare`: mesh pipelines |
|
||||
| `MeshShading` | | devices short of a device limit the site names; devices without VkLimit::MaxMeshOutputLayers; devices without VkLimit::MaxTaskPayloadSize; devices without a capability the site computes (`missing`); every device (not implemented) | `ours` | 6: `crates/metal2vulkan/src/bind/graphics.rs (mesh_limit)`, `crates/metal2vulkan/src/bind/graphics.rs (plan)` (+3) | `rare`: mesh pipelines |
|
||||
| `TileShading` | | devices without VkLimit::MaxStorageBufferRange; every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/bind/plan/compute.rs (tile_memory)`, `crates/metal2vulkan/src/lower/access/tile.rs (not_implemented)` (+2) | `rare`: tile shaders (Apple GPU families) |
|
||||
| `Imageblocks` | An imageblock outside the forms implemented | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`missing`); every device (not implemented) | `ours` | 8: `crates/metal2vulkan/src/lower/access/imageblock.rs (imageblocks)`, `crates/metal2vulkan/src/lower/access/mod.rs (select_param)` (+6) | `rare`: imageblocks (Apple GPU families) |
|
||||
| `RayTracing` | | devices without a capability the site computes (`missing`); every device (no Vulkan mechanism); every device (not implemented) | `ours` | 12: `crates/metal2vulkan/src/bind/acceleration.rs (instance_record, 2 sites)`, `crates/metal2vulkan/src/lower/raytracing/mod.rs (instance_count)` (+5) | `rare`: ray tracing (out of scope by ruling) |
|
||||
@@ -153,7 +153,7 @@ Columns:
|
||||
| `StageStoresAndAtomics` | Buffer or image stores or atomics in a vertex or fragment function without the stage's store feature (`vertexPipelineStoresAndAtomics`,... | devices without VkFeature::FragmentStoresAndAtomics | `device` | 1: `crates/metal2vulkan/src/lower/access/tile_memory.rs (written)` | `app`: stores or atomics in vertex or fragment functions on a device without the feature |
|
||||
| `FunctionConstantArgument` | An observed read of a pointer entry argument that a function-constant predicate removes, other than an absent buffer (which reads as null) or an... | every device (not implemented) | `ours` | 1: `crates/metal2vulkan-air/src/canon/interface.rs (absent_values)` | `rare`: a function-constant-removed argument read |
|
||||
| `SamplerBicubicFilter` | A use of Metal's bicubic filter that no Metal reading establishes | every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/bind/heap.rs (new)`, `crates/metal2vulkan/src/bind/plan/resources.rs (bicubic_texels)` (+3) | `system`: bicubic filtering forms Metal does not establish; macOS 26.6.2 makes a runtime sampler with MTLSamplerMinMagFilterCubic (the consumer's boots), whose mip-filtered form is refused |
|
||||
| `GroupCount` | A dispatch whose threadgroup count on `axis` exceeds `maxComputeWorkGroupCount` by more than the binder splits into regions (`None` | every device (no Vulkan mechanism) | `device` | 6: `crates/metal2vulkan/src/bind/dispatch.rs (2 sites)`, `crates/metal2vulkan/src/bind/dispatch.rs (product)` (+3) | `rare`: more threadgroups than a device dispatches, past the binder's split |
|
||||
| `GroupCount` | A dispatch whose threadgroup count on `axis` exceeds `maxComputeWorkGroupCount` by more than the binder splits into regions (`None` | every device (no Vulkan mechanism) | `device` | 5: `crates/metal2vulkan/src/bind/dispatch.rs (2 sites)`, `crates/metal2vulkan/src/bind/dispatch.rs (product)` (+2) | `rare`: more threadgroups than a device dispatches, past the binder's split |
|
||||
| `IntersectionFunctionTable` | A ray intersection through intersection functions | every device (no Vulkan mechanism); every device (not implemented) | `ours` | 9: `crates/metal2vulkan/src/bind/acceleration.rs (geometry_table_offset, 3 sites)`, `crates/metal2vulkan/src/lower/raytracing/mod.rs (intersect, 2 sites)` (+4) | `rare`: ray tracing (out of scope by ruling) |
|
||||
| `IndependentBlending` | Color attachments whose write masks or blend states differ, as Metal sets them per attachment, on a device without `independentBlend`, where no... | devices without VkFeature::IndependentBlend | `device` | 1: `crates/metal2vulkan/src/pipeline/link/graphics.rs (uniform_blend)` | `rare`: per-attachment blending on a device without independentBlend |
|
||||
| `RasterSampleCount` | A `rasterSampleCount` outside the device's framebuffer sample counts for the pipeline's attachments (`framebuffer*SampleCounts`), and, for a color... | devices without a capability the site computes | `device` | 1: `crates/metal2vulkan/src/pipeline/graphics.rs (sample_count_properties)` | `app`: a sample count a device lacks for the attachments |
|
||||
@@ -470,7 +470,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::VertexStepRate`: `crates/metal2vulkan/src/metal/vertex.rs (divided)`
|
||||
- `feature::VertexInputLayout`: `crates/metal2vulkan/src/pipeline/link/vertex.rs (resolve, 4 sites)`
|
||||
- `feature::Tessellation`: `crates/metal2vulkan-air/src/canon/mod.rs (post_check, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs (select)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (param)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (primitive_id_output)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs (not_implemented)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs (plan_entry, 2 sites)`; `crates/metal2vulkan/src/metal/vertex.rs (fetch_as)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs (check_fragment)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs (control_plan, 2 sites)`
|
||||
- `feature::MeshShading`: `crates/metal2vulkan/src/bind/graphics.rs (mesh_limit)`; `crates/metal2vulkan/src/bind/graphics.rs (plan)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (check_payload)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_entry, 2 sites)`; `crates/metal2vulkan/src/memory/plan.rs (reprs)`; `crates/metal2vulkan/src/pipeline/link/mesh.rs (records)`
|
||||
- `feature::MeshShading`: `crates/metal2vulkan/src/bind/graphics.rs (mesh_limit)`; `crates/metal2vulkan/src/bind/graphics.rs (plan)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (check_payload)`; `crates/metal2vulkan/src/lower/mesh/mod.rs (plan_entry, 2 sites)`; `crates/metal2vulkan/src/memory/plan.rs (reprs)`
|
||||
- `feature::TileShading`: `crates/metal2vulkan/src/bind/plan/compute.rs (tile_memory)`; `crates/metal2vulkan/src/lower/access/tile.rs (not_implemented)`; `crates/metal2vulkan/src/lower/sync/barrier.rs (tile_shading)`; `crates/metal2vulkan/src/pipeline/compile/api.rs (tile_pipeline)`
|
||||
- `feature::Imageblocks`: `crates/metal2vulkan/src/lower/access/imageblock.rs (imageblocks)`; `crates/metal2vulkan/src/lower/access/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (reach)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs (require)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/slice.rs (imageblocks)`; `crates/metal2vulkan/src/pipeline/link/imageblock.rs (fragment_imageblock)`
|
||||
- `feature::RayTracing`: `crates/metal2vulkan/src/bind/acceleration.rs (instance_record, 2 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (instance_count)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (intersect, 5 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (primitive_data_read)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (select_param)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (slot_of)`; `crates/metal2vulkan/src/lower/select.rs (route_air)`
|
||||
@@ -492,7 +492,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::StageStoresAndAtomics`: `crates/metal2vulkan/src/lower/access/tile_memory.rs (written)`
|
||||
- `feature::FunctionConstantArgument`: `crates/metal2vulkan-air/src/canon/interface.rs (absent_values)`
|
||||
- `feature::SamplerBicubicFilter`: `crates/metal2vulkan/src/bind/heap.rs (new)`; `crates/metal2vulkan/src/bind/plan/resources.rs (bicubic_texels)`; `crates/metal2vulkan/src/bind/plan/slots.rs (cubic_variant)`; `crates/metal2vulkan/src/lower/sampler/bicubic.rs (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs (bicubic_refused)`
|
||||
- `feature::GroupCount`: `crates/metal2vulkan/src/bind/dispatch.rs (2 sites)`; `crates/metal2vulkan/src/bind/dispatch.rs (product)`; `crates/metal2vulkan/src/bind/dispatch.rs (regions)`; `crates/metal2vulkan/src/bind/graphics.rs (emulated_draw)`; `crates/metal2vulkan/src/bind/graphics.rs (mesh_draw)`
|
||||
- `feature::GroupCount`: `crates/metal2vulkan/src/bind/dispatch.rs (2 sites)`; `crates/metal2vulkan/src/bind/dispatch.rs (product)`; `crates/metal2vulkan/src/bind/dispatch.rs (regions)`; `crates/metal2vulkan/src/bind/graphics.rs (mesh_draw)`
|
||||
- `feature::IntersectionFunctionTable`: `crates/metal2vulkan/src/bind/acceleration.rs (geometry_table_offset, 3 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (intersect, 2 sites)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (null_table)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (select_table)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs (table_of)`; `crates/metal2vulkan/src/lower/select.rs (route_air)`
|
||||
- `feature::IndependentBlending`: `crates/metal2vulkan/src/pipeline/link/graphics.rs (uniform_blend)`
|
||||
- `feature::RasterSampleCount`: `crates/metal2vulkan/src/pipeline/graphics.rs (sample_count_properties)`
|
||||
|
||||
Reference in new issue
Block a user