After the profiles layer moved onto the runtime route, kernel rows went through the runtime, and the
layered cases moved too, nothing called validation's own Vulkan executor. This deletes it:
candidate/platform's compute, render (and its multisampled half), plan_resources, buffers and
multisample modules, the own-context device's clamped-layer, extended-dynamic-state, restriction
and environment machinery, the engine's compile_case / compile_render(_case) / compute_request
plumbing, the bind refusal and status verdict it read, the synthetic guest addresses, the attempt's
creation ceiling, and coverage's module census of its own compiles. corpus-pipeline's Vulkan
context for its render rows, and the runtime probe's, stay.
A render case the runtime route does not draw (a depth/stencil attachment of both aspects, a patch
draw through a patch or control-point index buffer, an out-of-bounds target other than an attribute
buffer) is refused not_supported{executor_not_implemented} before it runs, as run_prepared already
did once the gates were gone. The comments and docs/VALIDATION.md that compared with the own
context now say what the runtime route does.
Test-only items move beside their tests: Mechanism's label into the out-of-bounds tests,
Containment::of_compile, its label, Declared and ExecutionClass::of_description into the tier
table. The linked-functions integration test compiles through kernel_request, as the census does.
Deleted tests and what covers their Metal claim:
- a_kernel_runs_with_its_linked_visible_functions: a_kernel_runs_through_the_runtime_with_its_
linked_visible_functions (engine_compute.rs), kept.
- a_draw_restarts_exactly_its_strips_within_its_class: the conformance case
primitive_type_crossings compares strip restart with Metal.
- a_combined_depth_stencil_format_moves_both_aspects_together, a_draw_covers_the_whole_target,
a_guarded_buffer_counts_each_changed_guard_byte, a_target_is_bound_for_its_fetch_form,
every_state_a_render_pipeline_makes_dynamic_is_recorded,
multisample_initializers_are_vulkan_legal_for_each_component_class,
addressed_allocations_take_metal_addresses, the_status_starts_zero_and_stops_non_evidence,
the_clamped_layer_warning_fails_no_row_of_a_clamped_store_alone,
a_context_has_the_extended_dynamic_states_where_the_product_reads_them,
a_store_runs_through_the_binder_under_the_validation_layer,
a_tessellation_pipeline_census_is_its_functions: the deleted executor's own mechanics, no Metal
answer of their own.
metal2vulkan-validation is not published, so no consumer can reach a deleted item:
git grep -n -E 'metal2vulkan[-_]validation' development -- '*.rs' '*.toml' in the consumer's
checkout at a11528a7e2: 0 hits.
Verified: cargo check of the validation crate, all targets and features, plain, --cfg m2v_gpu and
--cfg m2v_cpu_icd, clean (m3-max-67506, on the probe branch's identical diff); the dead-code pass
against the base finds only items whose users are macOS-only or tests the binder's deletion takes.
The compile job and the suites follow on this commit.
(cherry picked from commit 5808aaa769e3f44b1bd76dea486b2b150b15e92b)
267 lines
13 KiB
Rust
267 lines
13 KiB
Rust
//! The census of compiled and executed modules: what a module records of the product's
|
|
//! selections, and what a candidate run records of the modules it executed and where.
|
|
//!
|
|
//! A module's census ([`ModuleCensus`]) is its stage, the subgroup requirement its simd tier states
|
|
//! ([`SubgroupShape`]), its `StrategyCensus` names, its precision notes, and the containment
|
|
//! encodings it compiled under ([`Containment`]). The containment encoding is taken from what the
|
|
//! module compiled for, never from its census names, which do not all show it. The census names
|
|
//! an access that reaches buffer memory by device address apart from one through a descriptor view
|
|
//! (`.psb`, `.psb_and_view`: the product's `access::BufferReach`), and a side that may be an arena
|
|
//! (`.arena`, `access::SideReach`), with a memory intrinsic's destination and source named apart
|
|
//! (`.to_<side>`, `.from_<side>`): so the name and the module's encoding together say which check
|
|
//! each access took.
|
|
//!
|
|
//! A run's census ([`ExecutedCensus`]) is the class of the device it ran on ([`ExecutionClass`]:
|
|
//! a CPU ICD, or a GPU's driver, [`HostClass`]), the product build that compiled its modules, and
|
|
//! their censuses. The tier table compiles each committed profile twice where it states a
|
|
//! robustness feature ([`Leg`]): as stated, which selects the robust image encodings where it
|
|
//! states image robustness, and with every robustness feature removed ([`robustness_off`]), which
|
|
//! selects the in-shader ones. Buffers are checked in the shader on both legs.
|
|
|
|
use crate::candidate::engine::artifact::ExecutedArtifact;
|
|
use crate::case::Stage;
|
|
use crate::observation_contract::ComparisonClass;
|
|
use metal2vulkan::device::DeviceDescription;
|
|
use metal2vulkan::device::VkFeature;
|
|
use metal2vulkan::pipeline::PrecisionNote;
|
|
use metal2vulkan::vk;
|
|
use serde::{Deserialize, Serialize};
|
|
use std::collections::BTreeSet;
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|
|
#[cfg(test)]
|
|
pub(crate) mod tier_table;
|
|
|
|
/// What a module asks of the device's subgroups: the requirement its simd tier states, carried by
|
|
/// `StageModule::required_subgroup_size` and `REQUIRE_FULL_SUBGROUPS`.
|
|
#[derive(
|
|
Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
|
|
)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct SubgroupShape {
|
|
/// `requiredSubgroupSize`, when the tier pins one.
|
|
pub required_size: Option<u32>,
|
|
/// Full subgroups are required.
|
|
pub full_subgroups: bool,
|
|
}
|
|
|
|
/// The robustness features a tier-table profile's robustness-off leg removes
|
|
/// ([`Leg::RobustnessOff`]): image robustness, which drops the in-shader clamp and guard of images
|
|
/// (`robust_image_access`). The translator names no buffer robustness: the shader checks every
|
|
/// descriptor view.
|
|
pub const ROBUSTNESS_FEATURES: [VkFeature; 2] =
|
|
[VkFeature::RobustImageAccess, VkFeature::RobustImageAccess2];
|
|
|
|
/// How buffers reached through descriptor views (and texel buffers) are contained: the shader
|
|
/// checks every one, on every profile. Its out-of-bounds targets' mechanism
|
|
/// (`executor_contract::out_of_bounds`) states each access's check, where this module-wide label
|
|
/// says what the descriptor views take.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum BufferEncoding {
|
|
/// The module declares no buffer (no variable in the `StorageBuffer` or `Uniform` storage
|
|
/// class, no texel buffer), so no buffer encoding applies to it, whatever its profile's.
|
|
Unused,
|
|
/// Checked in the shader.
|
|
Checked,
|
|
/// Left to robust descriptors, the shader emitting no check: a stored row may state it; no
|
|
/// compile does.
|
|
Robust,
|
|
}
|
|
|
|
/// How image reads and writes are contained (`DeviceProfile::device_reads_texels` and
|
|
/// `device_drops_texel_writes`, which the product's texture family reads). A texel buffer is no
|
|
/// image here: buffer robustness, not image robustness, contains it, so it counts toward
|
|
/// [`BufferEncoding`] alone.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ImageEncoding {
|
|
/// The module declares no image type (`OpTypeImage`) but a texel buffer's, so it accesses no
|
|
/// image and no image encoding applies to it, whatever its profile's.
|
|
Unused,
|
|
/// Reads clamped and writes guarded in the shader: no image robustness is enabled.
|
|
Checked,
|
|
/// `robustImageAccess` without the second level: writes are left to the device, which discards
|
|
/// them out of bounds; reads are clamped in the shader, since the device's out-of-bounds texel
|
|
/// is not Metal's.
|
|
RobustWrites,
|
|
/// `robustImageAccess2` is enabled: reads and writes are left to the device, no clamp, no
|
|
/// guard.
|
|
Robust,
|
|
}
|
|
|
|
/// The containment encodings a module compiled under: the leaf encodings of its descriptor
|
|
/// accesses. They are those of the profile it compiled for, which every lowering that reads them
|
|
/// reads (the access targets' checks, `lower::texture::slot`).
|
|
///
|
|
/// Census names do not all show the encoding they compiled under, so the report keys its rows by
|
|
/// this, taken from the compile, not by the names. An access by device address (a `BufferForm::Psb`
|
|
/// slot or a wide pointer) or to an arena is checked in the shader whatever the profile; the census
|
|
/// names it apart from a descriptor access of the same strategy, so the name, not the module, says
|
|
/// which accesses these encodings apply to.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
#[serde(from = "ContainmentRecord")]
|
|
pub struct Containment {
|
|
pub buffers: BufferEncoding,
|
|
pub images: ImageEncoding,
|
|
}
|
|
|
|
/// A stored [`Containment`]. Rows of executor v34 also state `device_addresses`, the module-level
|
|
/// device-address part, which naming each device-address access in the census superseded: it is
|
|
/// read and dropped. Such a row is not current (`ENGINE_EXECUTOR_ABI` v37), so it is evidence
|
|
/// for no row whatever it states.
|
|
#[derive(Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
struct ContainmentRecord {
|
|
buffers: BufferEncoding,
|
|
images: ImageEncoding,
|
|
#[serde(default, rename = "device_addresses")]
|
|
_device_addresses: Option<bool>,
|
|
}
|
|
|
|
impl From<ContainmentRecord> for Containment {
|
|
fn from(record: ContainmentRecord) -> Containment {
|
|
Containment {
|
|
buffers: record.buffers,
|
|
images: record.images,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// The census of one compiled or executed stage module.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ModuleCensus {
|
|
pub stage: Stage,
|
|
/// The module's subgroup shape, where the executor compiled it itself: `None` for a run
|
|
/// through the runtime, which keeps its modules to itself.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub subgroup: Option<SubgroupShape>,
|
|
/// `StrategyCensus` names. A run through the runtime, which keeps the translator's census of
|
|
/// its modules to itself, records only the float sums and products the case's AIR calls,
|
|
/// under the names the translator's census gives them
|
|
/// (`check::interface::float_reductions`): what its comparison class is derived from.
|
|
pub strategies: BTreeSet<String>,
|
|
/// The module's precision notes: with `strategies`, what its observations' comparison class
|
|
/// is derived from. An executed module's are its notes under the specialization it ran with and
|
|
/// the values its plan pushed (`StageModule::precision_notes_bound`), a compiled one's every
|
|
/// note it records.
|
|
pub precision: BTreeSet<PrecisionNote>,
|
|
/// The containment encodings it compiled under. A row recorded before executors recorded them
|
|
/// (executor ABI v33 and earlier) has none, and is evidence for no row.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub containment: Option<Containment>,
|
|
}
|
|
|
|
/// A Vulkan driver (`VkDriverId`): the host class of a GPU (NVIDIA proprietary, RADV, ANV, ...).
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
#[serde(transparent)]
|
|
pub struct HostClass(pub vk::DriverId);
|
|
|
|
impl std::fmt::Debug for HostClass {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{:?}", self.0)
|
|
}
|
|
}
|
|
|
|
/// Where a module runs.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ExecutionClass {
|
|
/// A CPU Vulkan implementation (`VK_PHYSICAL_DEVICE_TYPE_CPU`: lavapipe, SwiftShader).
|
|
CpuIcd,
|
|
/// A GPU of one host class.
|
|
Host(HostClass),
|
|
}
|
|
|
|
/// The census of what one candidate run executed, and where (the evidence side).
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ExecutedCensus {
|
|
/// `None` when the opened device's description names neither a CPU type nor a driver.
|
|
pub device: Option<ExecutionClass>,
|
|
/// The product build that compiled the modules (`TRANSLATOR_FINGERPRINT`): the one currency
|
|
/// rule (`index::candidate_staleness`) holds a row whose census names another product stale, so
|
|
/// evidence is current only for the build that recorded it.
|
|
pub product: String,
|
|
/// The committed capability profile `VK_LAYER_KHRONOS_profiles` restricted the device to,
|
|
/// if any (`--profiles-layer P`). `device` is then the device that executed.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub restricted_to: Option<String>,
|
|
pub modules: Vec<ModuleCensus>,
|
|
/// How the run contained each out-of-bounds target of its case, and what escaped: the facts the
|
|
/// candidate's verdict on such a case reads (`executor_contract::out_of_bounds::matches`).
|
|
/// `None` for a case that declares no target.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub out_of_bounds: Option<crate::executor_contract::out_of_bounds::OutOfBoundsRun>,
|
|
/// How the run drew its case's rate-mapped render pass: `None` for a case whose pass has no
|
|
/// rate map.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub rate_map_pass: Option<RateMapPassRun>,
|
|
/// What the run executed, by content, and under which product runtime: C3's currency holds a
|
|
/// row of another build current while its artifact is the one the authored compile census
|
|
/// computes for that build. `None` for a run of an executor before ABI v129.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub artifact: Option<ExecutedArtifact>,
|
|
}
|
|
|
|
/// How a candidate drew a rate-mapped render pass: region by region (the option (a), on every
|
|
/// device), into the product's compile of the map, each draw recorded once per region, with the
|
|
/// plan's near-equivalent, which the row's comparison class carries.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct RateMapPassRun {
|
|
/// The screen size: the pass's viewport, in screen coordinates.
|
|
pub screen_size: [u32; 2],
|
|
/// The physical size of the product's compile of the map: the extent the pass draws into.
|
|
pub compiled_physical_size: [u32; 2],
|
|
/// The regions each draw of the pass was recorded in.
|
|
pub regions: u32,
|
|
/// The pass's precision notes: with the modules', what the
|
|
/// row's comparison class is derived from.
|
|
#[serde(default, skip_serializing_if = "BTreeSet::is_empty")]
|
|
pub precision: BTreeSet<PrecisionNote>,
|
|
}
|
|
|
|
impl ExecutedCensus {
|
|
/// The comparison class of an observation of these modules, derived from their notes and
|
|
/// strategies: what a recorded class must equal.
|
|
pub fn comparison_class(&self) -> ComparisonClass {
|
|
ComparisonClass::derive(
|
|
self.modules
|
|
.iter()
|
|
.flat_map(|module| module.precision.iter().copied())
|
|
.chain(
|
|
self.rate_map_pass
|
|
.iter()
|
|
.flat_map(|pass| pass.precision.iter().copied()),
|
|
),
|
|
self.modules
|
|
.iter()
|
|
.flat_map(|module| module.strategies.iter().map(String::as_str)),
|
|
)
|
|
}
|
|
}
|
|
|
|
/// Which robustness a tier-table entry compiles a committed profile under.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum Leg {
|
|
/// The profile as committed, with the robustness features it states: the robust image
|
|
/// encodings where it states them.
|
|
Stated,
|
|
/// The profile without any of [`ROBUSTNESS_FEATURES`]: the in-shader image encodings. A
|
|
/// profile has this leg only when it states one of them.
|
|
RobustnessOff,
|
|
}
|
|
|
|
/// `description` without any robustness feature ([`ROBUSTNESS_FEATURES`]): its robustness-off
|
|
/// leg, or `None` when it states none, so that leg is its stated one.
|
|
pub fn robustness_off(description: &DeviceDescription) -> Option<DeviceDescription> {
|
|
let mut off = description.clone();
|
|
off.features
|
|
.retain(|feature| !ROBUSTNESS_FEATURES.contains(feature));
|
|
(off.features.len() != description.features.len()).then_some(off)
|
|
}
|