Validation enables what the runtime enables, from the runtime's own tables
What: one definition of the enabled set. The runtime gains one public function, `metal2vulkan_runtime::floor::enable_set()`: every feature and extension of the translator's vocabulary that device creation enables on some device (its ENABLED groups' named features and its creation extensions), and `shader_enables` reads the same iteration. Validation's `engine::runtime_enables(description)` keeps of a description what that set holds (plus the features that have no member at the runtime's Vulkan version and the extensions exposing kept features) and `engine::runtime_description(stem)` reads a committed profile at the runtime's version restricted to it. The engine context's list (`engine_list`) is that set; NOT_ENABLED, the old executor's list, `Enables::copy`/`expose` and the unnamed members loop are deleted. The authored-compile census, `corpus-pipeline` and `load_device` compile for `runtime_description`. Why: validation executed, and the census reported, forms the runtime never ships: the ordered framebuffer fetch on lavapipe, ray query and acceleration structures with deferred host operations, float atomic add, OpFmaKHR, buffer robustness and others the runtime's floor tables do not enable. Tests: a runtime test that `enable_set()` equals what `shader_enables` derives on a device with every ENABLED feature and every creation extension; a validation test that no committed profile's context (device and restricted) enables a member or extension outside the set, ray query, acceleration structure and deferred host operations named. docs/VALIDATION.md states the four places where the census's reading differs from the runtime's own answer for a device. ENGINE_EXECUTOR_ABI vulkan-engine-v209 -> v210. Verification: none at this commit; its compile, suite and census jobs follow.
This commit is contained in:
1 parent
591f813569
commit
a2ad41850e
12 files changed
+404
-636
No files matched your search
@@ -790,17 +790,33 @@ pub(crate) const ENABLED: &[&[Feature]] = &[
|
||||
INDIRECT_COMMAND_FEATURES,
|
||||
];
|
||||
|
||||
/// Each feature of a table device creation enables ([`ENABLED`]) that the translator names, with
|
||||
/// its name.
|
||||
fn named_features() -> impl Iterator<Item = (&'static Feature, VkFeature)> {
|
||||
(ENABLED.iter().copied().flatten())
|
||||
.filter_map(|feature| feature.translator.map(|name| (feature, name)))
|
||||
}
|
||||
|
||||
/// Every extension device creation may enable, each where its own rule says.
|
||||
pub(crate) fn creation_extensions() -> impl Iterator<Item = &'static CStr> {
|
||||
(DEVICE_EXTENSIONS.iter())
|
||||
.chain(OPTIONAL_EXTENSIONS)
|
||||
.chain(ATTACHMENT_READ_EXTENSIONS)
|
||||
.chain(BORDER_SWIZZLE_EXTENSIONS)
|
||||
.chain(BARYCENTRIC_EXTENSIONS)
|
||||
.chain(INDIRECT_COMMANDS)
|
||||
.copied()
|
||||
}
|
||||
|
||||
/// What the translator's description of the device states as enabled: each feature of
|
||||
/// `capabilities` device creation enables ([`ENABLED`]) that the translator names, and each
|
||||
/// enabled extension it names.
|
||||
pub(crate) fn shader_enables(capabilities: &Capabilities) -> EnableSet {
|
||||
let mut features = capabilities.features;
|
||||
let mut enables = EnableSet::new();
|
||||
for feature in ENABLED.iter().copied().flatten() {
|
||||
if let Some(name) = feature.translator {
|
||||
if *(feature.field)(&mut features) == vk::TRUE {
|
||||
enables.features.insert(name);
|
||||
}
|
||||
for (feature, name) in named_features() {
|
||||
if *(feature.field)(&mut features) == vk::TRUE {
|
||||
enables.features.insert(name);
|
||||
}
|
||||
}
|
||||
enables.extensions.extend(
|
||||
@@ -812,6 +828,25 @@ pub(crate) fn shader_enables(capabilities: &Capabilities) -> EnableSet {
|
||||
enables
|
||||
}
|
||||
|
||||
/// Every feature and extension of the translator's vocabulary that device creation enables on
|
||||
/// some device: each feature of a table creation enables that the translator names, and each
|
||||
/// extension creation may enable that the translator names. It is the union of what the
|
||||
/// translator's description of any device the runtime makes states as enabled, so a description
|
||||
/// restricted to it states nothing creation never enables; on one device creation enables the part
|
||||
/// of it the device reports, by the floor's rules.
|
||||
///
|
||||
/// Metal has no counterpart.
|
||||
pub fn enable_set() -> EnableSet {
|
||||
let mut enables = EnableSet::new();
|
||||
enables
|
||||
.features
|
||||
.extend(named_features().map(|(_, name)| name));
|
||||
enables
|
||||
.extensions
|
||||
.extend(creation_extensions().filter_map(shader_extension));
|
||||
enables
|
||||
}
|
||||
|
||||
/// The floor's description of a feature the consumer names: its structure, member and field.
|
||||
pub(crate) fn consumer_feature(feature: crate::ConsumerFeature) -> Feature {
|
||||
match feature {
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
use super::floor::{at_the_floor, table};
|
||||
use crate::floor::{
|
||||
decide, shader_enables, shader_extension, vulkan_name, Capabilities, Queried,
|
||||
ATTACHMENT_READ_EXTENSIONS, BARYCENTRIC_EXTENSIONS, BORDER_SWIZZLE_EXTENSIONS,
|
||||
DEVICE_EXTENSIONS, ENABLED, INDIRECT_COMMANDS, OPTIONAL_EXTENSIONS,
|
||||
creation_extensions, decide, enable_set, shader_enables, shader_extension, vulkan_name,
|
||||
Capabilities, Queried, DEVICE_EXTENSIONS, ENABLED, SAMPLERS, SAMPLER_ARRAYS, TEXTURES,
|
||||
};
|
||||
use ash::vk;
|
||||
use metal2vulkan::device::{
|
||||
@@ -33,18 +32,6 @@ fn vocabulary(member: &str) -> Option<VkFeature> {
|
||||
.find(|feature| format!("{feature:?}") == name)
|
||||
}
|
||||
|
||||
/// Every extension device creation may enable.
|
||||
fn creation_extensions() -> BTreeSet<&'static CStr> {
|
||||
(DEVICE_EXTENSIONS.iter())
|
||||
.chain(OPTIONAL_EXTENSIONS)
|
||||
.chain(ATTACHMENT_READ_EXTENSIONS)
|
||||
.chain(BORDER_SWIZZLE_EXTENSIONS)
|
||||
.chain(BARYCENTRIC_EXTENSIONS)
|
||||
.chain(INDIRECT_COMMANDS)
|
||||
.copied()
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The data rows of the README's table headed `header` under its subsection `title`.
|
||||
fn readme_table(title: &str, header: &[&str]) -> Vec<Vec<String>> {
|
||||
let path = crate::tests::crate_dir().join("README.md");
|
||||
@@ -109,10 +96,7 @@ fn every_feature_creation_enables_reaches_the_translator() {
|
||||
for feature in ENABLED.iter().copied().flatten() {
|
||||
*(feature.field)(&mut device.features) = vk::TRUE;
|
||||
}
|
||||
device.extensions = creation_extensions()
|
||||
.into_iter()
|
||||
.map(CStr::to_owned)
|
||||
.collect();
|
||||
device.extensions = creation_extensions().map(CStr::to_owned).collect();
|
||||
let capabilities = decide(&device).unwrap_or_else(|below| panic!("{below}"));
|
||||
let enables = shader_enables(&capabilities);
|
||||
let mut named = 0;
|
||||
@@ -146,6 +130,29 @@ fn every_feature_creation_enables_reaches_the_translator() {
|
||||
);
|
||||
}
|
||||
|
||||
/// The enable set is what the translator's description states as enabled on a device that
|
||||
/// reports every feature of creation's tables, lists every extension creation may enable and has
|
||||
/// the descriptor room of the attachment reads: it holds nothing creation never enables, and
|
||||
/// leaves out nothing creation enables that the translator names.
|
||||
#[test]
|
||||
fn the_enable_set_is_what_creation_enables_on_a_device_with_everything() {
|
||||
let mut device = at_the_floor();
|
||||
for feature in ENABLED.iter().copied().flatten() {
|
||||
*(feature.field)(&mut device.features) = vk::TRUE;
|
||||
}
|
||||
device.extensions = creation_extensions().map(CStr::to_owned).collect();
|
||||
let descriptors = &mut device.vulkan12;
|
||||
descriptors.max_per_stage_descriptor_update_after_bind_sampled_images = 3 * TEXTURES;
|
||||
descriptors.max_descriptor_set_update_after_bind_sampled_images = 3 * TEXTURES;
|
||||
descriptors.max_per_stage_update_after_bind_resources =
|
||||
5 * TEXTURES + device.limits.max_color_attachments;
|
||||
descriptors.max_update_after_bind_descriptors_in_all_pools =
|
||||
5 * TEXTURES + SAMPLER_ARRAYS * SAMPLERS;
|
||||
let capabilities = decide(&device).unwrap_or_else(|below| panic!("{below}"));
|
||||
assert!(capabilities.feedback_loop, "the attachment reads' room");
|
||||
assert_eq!(shader_enables(&capabilities), enable_set());
|
||||
}
|
||||
|
||||
/// Each extension device creation may enable reaches the translator's description where the
|
||||
/// translator names it, as the translator itself reads its name: a profile document that lists it
|
||||
/// alone gives the translator's description that one extension. The exceptions are the README's
|
||||
|
||||
@@ -21,8 +21,10 @@
|
||||
//! (`source::use_source_index`), and parses a whole shard only for a source the index does not
|
||||
//! locate; the report counts both.
|
||||
//! - **The profiles.** The profiles of the expectation file's header, each a committed profile
|
||||
//! as stated, derived under the default policy as every census row is. A device run compiles for the opened device,
|
||||
//! restricted to what the executor enables; this compiles for the committed profile.
|
||||
//! as the runtime's device describes it (`engine::runtime_description`: read at the runtime's
|
||||
//! Vulkan version, restricted to what the runtime enables of it), derived under the default
|
||||
//! policy as every census row is. A device run compiles for the opened device, restricted to
|
||||
//! what the executor enables, which is the same set.
|
||||
//! - **The baseline.** The committed expectation file ([`EXPECTATIONS`] under the corpus root):
|
||||
//! one line per case, its cell on each profile ([`Cell`]): `compiled` or the executor's
|
||||
//! stable refusal label (`NotSupported::outcome`).
|
||||
@@ -136,9 +138,10 @@ pub struct CensusProfile {
|
||||
}
|
||||
|
||||
impl CensusProfile {
|
||||
/// The committed profile `profile`, under the default policy.
|
||||
/// The committed profile `profile` as the runtime's device describes it, under the default
|
||||
/// policy.
|
||||
pub fn load(profile: &ProfileStem) -> Result<CensusProfile, String> {
|
||||
let description = crate::engine::load_description(&profile.stem)?;
|
||||
let description = crate::engine::runtime_description(&profile.stem)?;
|
||||
let device = WorkerDevice::new(description, DevicePolicy::default())
|
||||
.map_err(|error| format!("{}: {error}", profile.label()))?;
|
||||
let key = profile_key(&CensusKey::engine(
|
||||
|
||||
@@ -305,9 +305,10 @@ fn run() -> Result<(), String> {
|
||||
)
|
||||
}
|
||||
|
||||
/// The compile device of an engine sweep of profile `stem`, created under the default policy.
|
||||
/// The compile device of an engine sweep of profile `stem` as the runtime's device describes it
|
||||
/// (`engine::runtime_description`), created under the default policy.
|
||||
fn compile_device(stem: &str) -> Result<WorkerDevice, String> {
|
||||
let description = engine::load_description(stem)?;
|
||||
let description = engine::runtime_description(stem)?;
|
||||
WorkerDevice::new(description, metal2vulkan::device::DevicePolicy::default())
|
||||
.map_err(|error| format!("{stem}: {error}"))
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ pub mod variants;
|
||||
/// how it decides a match. A change no recorded row can observe (a case kind no earlier executor
|
||||
/// ran, or one it refused) needs no bump; its commit says why. The commit that bumps it says what
|
||||
/// changed; this comment keeps no history.
|
||||
pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v209";
|
||||
pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v210";
|
||||
|
||||
/// One kernel case in the terms the binder takes: what this executor supports of an
|
||||
/// [`AuthoredCase`] (buffers, device buffer arrays, argument-buffer buffers and textures,
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::sync::{Mutex, OnceLock};
|
||||
/// (`device_facts::RECORDED_LAYERS`). Every context runs under `VK_LAYER_KHRONOS_validation` with
|
||||
/// core and synchronization validation, and a message sink ([`VulkanContext::take_messages`])
|
||||
/// that fails the row: every engine candidate run and every L4 acceptance run. It enables the
|
||||
/// engine's list on top of the base list ([`enables::engine_list`]).
|
||||
/// engine's list ([`enables::engine_list`]): what the runtime enables of the device.
|
||||
pub(super) use crate::candidate::device_facts::RECORDED_LAYERS;
|
||||
|
||||
/// The validation layer every engine run enables.
|
||||
@@ -1646,9 +1646,9 @@ impl VulkanContext {
|
||||
// SAFETY: `physical` was enumerated from `instance`, created at API `version`, and
|
||||
// `available` is what the device lists, at the version the instance and device share.
|
||||
let supported = unsafe { FeatureChain::query(&instance, physical, &available) };
|
||||
// What the device supports, in the product's vocabulary: the engine's list is the
|
||||
// product's recommendation for it, and the opened description is it restricted to what
|
||||
// was enabled.
|
||||
// What the device supports, in the product's vocabulary: the engine's list is what the
|
||||
// runtime enables of it, and the opened description is it restricted to what was
|
||||
// enabled.
|
||||
// SAFETY: `physical` was enumerated from `instance`, which was created with API
|
||||
// `version`, the version passed here; the query only calls physical-device entry points.
|
||||
let mut description = unsafe { DeviceDescription::query(&instance, physical, version) }
|
||||
@@ -1685,7 +1685,6 @@ impl VulkanContext {
|
||||
}
|
||||
}
|
||||
let mut enables = enables::engine_list(
|
||||
enables::old_engine_list(&supported, &available),
|
||||
description.as_ref().map_err(Clone::clone)?,
|
||||
&supported,
|
||||
&available,
|
||||
|
||||
@@ -11,18 +11,12 @@
|
||||
//! enabled ([`Available::exposing`]), since chaining a structure of an absent extension below its
|
||||
//! core version is invalid usage.
|
||||
//!
|
||||
//! Two lists decide what is enabled:
|
||||
//!
|
||||
//! - [`old_engine_list`]: the old executor's list, unchanged, the base every engine context
|
||||
//! enables (so its opened profile, and its rows, do not move; the pinned chains of
|
||||
//! `tests::every_committed_profiles_context_enables_its_pinned_chain` hold it).
|
||||
//! - [`engine_list`] (engine contexts, on top of the old list): the product's
|
||||
//! `DeviceDescription::recommended_enables` for the device's queried description, less what no
|
||||
//! encoding reads ([`NOT_ENABLED`]), with every robustness feature the description states
|
||||
//! (`coverage::ROBUSTNESS_FEATURES`), so the opened profile compiles the robust containment
|
||||
//! encodings the device states. Extended dynamic state is enabled where
|
||||
//! the device lists it: a render pipeline states it as a requirement, and the render executor
|
||||
//! records its states.
|
||||
//! One list decides what is enabled, [`engine_list`]: what the runtime enables of the device's
|
||||
//! queried description (`engine::runtime_enables`, of the runtime's own set,
|
||||
//! `metal2vulkan_runtime::floor::enable_set`), so a context runs no form the runtime never enables
|
||||
//! (the pinned chains of `tests::every_committed_profiles_context_enables_its_pinned_chain` hold
|
||||
//! it). Extended dynamic state is enabled where the device lists it: a render pipeline states it as
|
||||
//! a requirement, and the render executor records its states.
|
||||
//!
|
||||
//! What a context enabled is read back from the enabled chain, member by member, through the
|
||||
//! one table ([`MEMBERS`]) that also writes it: [`enabled_set`] in the engine's vocabulary
|
||||
@@ -1167,19 +1161,6 @@ members! {
|
||||
PortabilitySubset.portability_subset.point_polygons => Some(F::PointPolygons);
|
||||
}
|
||||
|
||||
/// The engine's vocabulary features [`engine_list`] never enables, each with why. None of
|
||||
/// them is a pipeline requirement, and the product reads none of them. Their extensions stay
|
||||
/// enabled where the product recommends them: an extension enabled without its feature members
|
||||
/// changes nothing the product reads. `extendedDynamicState` is not here: a render pipeline
|
||||
/// requires it where it makes a state dynamic, and the render executor records every such state but
|
||||
/// a per-bind stride. The robustness features are not here either: the product reads them to choose
|
||||
/// the containment encoding, and a context enables every one its description states.
|
||||
pub(super) const NOT_ENABLED: &[(VkFeature, &str)] = &[(
|
||||
F::NullDescriptor,
|
||||
"no encoding reads it; it shares `VK_EXT_robustness2`'s structure with the robust-access \
|
||||
members, which the description decides",
|
||||
)];
|
||||
|
||||
/// One device extension a context can enable, with its name in the engine's vocabulary.
|
||||
struct ExtensionName {
|
||||
name: &'static CStr,
|
||||
@@ -1379,23 +1360,6 @@ impl Enables {
|
||||
}
|
||||
}
|
||||
|
||||
/// Chain `structure` and enable the extension `available` exposes it by (with what that
|
||||
/// extension requires), or none where the context's version has it as core. `false` when
|
||||
/// the device does not expose it.
|
||||
fn expose(&mut self, structure: Structure, available: &Available) -> bool {
|
||||
let Some(extension) = available.exposing(structure) else {
|
||||
return false;
|
||||
};
|
||||
if !structure.is_base() {
|
||||
self.linked.insert(structure);
|
||||
}
|
||||
if let Some(name) = extension {
|
||||
self.extensions.insert(name);
|
||||
self.extensions.extend(structure.requires_at(self.version));
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Chain `structure` when the context's version has it as core or an extension already
|
||||
/// enabled exposes it (with what that extension requires), enabling nothing more. `false`
|
||||
/// when neither does.
|
||||
@@ -1419,13 +1383,6 @@ impl Enables {
|
||||
exposed
|
||||
}
|
||||
|
||||
/// Enable `member` when `supported` has it and the device exposes its structure.
|
||||
fn copy(&mut self, member: &Member, supported: &FeatureChain, available: &Available) {
|
||||
if member.is_set(supported) && self.expose(member.structure, available) {
|
||||
member.set(&mut self.chain);
|
||||
}
|
||||
}
|
||||
|
||||
/// The `ppEnabledExtensionNames` pointers, valid for the `'static` names.
|
||||
pub(super) fn extension_names(&self) -> Vec<*const c_char> {
|
||||
self.extensions.iter().map(|name| name.as_ptr()).collect()
|
||||
@@ -1439,83 +1396,6 @@ fn member_of(feature: VkFeature) -> Option<&'static Member> {
|
||||
.find(|member| member.feature == Some(feature))
|
||||
}
|
||||
|
||||
/// The member of `MEMBERS` that is field `name` of `structure`.
|
||||
fn named_member(structure: Structure, name: &str) -> Option<&'static Member> {
|
||||
MEMBERS
|
||||
.iter()
|
||||
.find(|member| member.structure == structure && member.name == name)
|
||||
}
|
||||
|
||||
/// The old executor's enable list, as it stood before the engine had its own: the members
|
||||
/// every module under test declared (censused over the corpus), plus the portability subset
|
||||
/// (everything a portable implementation says it has), `VK_EXT_shader_stencil_export`, and
|
||||
/// `maintenance5` (which defines an unwritten `PointSize` for the old executor's point draws;
|
||||
/// its extension requires `VK_KHR_dynamic_rendering` on 1.2). Unchanged since: it is the base of
|
||||
/// every engine context's list ([`engine_list`]), so a change here moves every opened
|
||||
/// profile.
|
||||
pub(super) fn old_engine_list(supported: &FeatureChain, available: &Available) -> Enables {
|
||||
let mut enables = Enables::new(available.version);
|
||||
for feature in [
|
||||
F::SamplerAnisotropy,
|
||||
F::SampleRateShading,
|
||||
F::TessellationShader,
|
||||
F::ShaderInt16,
|
||||
F::ShaderInt64,
|
||||
F::ShaderClipDistance,
|
||||
F::ShaderCullDistance,
|
||||
F::ShaderStorageImageExtendedFormats,
|
||||
F::ImageCubeArray,
|
||||
F::GeometryShader,
|
||||
F::FragmentStoresAndAtomics,
|
||||
F::VertexPipelineStoresAndAtomics,
|
||||
F::StorageInputOutput16,
|
||||
F::StorageBuffer16BitAccess,
|
||||
F::UniformAndStorageBuffer16BitAccess,
|
||||
F::StoragePushConstant16,
|
||||
F::StorageBuffer8BitAccess,
|
||||
F::UniformAndStorageBuffer8BitAccess,
|
||||
F::StoragePushConstant8,
|
||||
F::ShaderFloat16,
|
||||
F::ShaderInt8,
|
||||
F::ShaderSubgroupExtendedTypes,
|
||||
F::ShaderOutputViewportIndex,
|
||||
F::ShaderOutputLayer,
|
||||
F::BufferDeviceAddress,
|
||||
F::FragmentShaderPixelInterlock,
|
||||
F::ShaderDemoteToHelperInvocation,
|
||||
F::ShaderBufferFloat32AtomicAdd,
|
||||
F::ShaderSharedFloat32AtomicAdd,
|
||||
F::FragmentShaderBarycentric,
|
||||
] {
|
||||
let member = member_of(feature).expect("every listed feature has a member");
|
||||
enables.copy(member, supported, available);
|
||||
}
|
||||
// The members the engine's vocabulary does not name.
|
||||
for (structure, name) in [
|
||||
(Structure::V11, "variable_pointers"),
|
||||
(Structure::V11, "variable_pointers_storage_buffer"),
|
||||
(Structure::FloatControls2, "shader_float_controls2"),
|
||||
] {
|
||||
let member = named_member(structure, name).expect("every named member is listed");
|
||||
enables.copy(member, supported, available);
|
||||
}
|
||||
let maintenance5 = MEMBERS
|
||||
.iter()
|
||||
.find(|member| member.structure == Structure::Maintenance5)
|
||||
.expect("maintenance5 is listed");
|
||||
enables.copy(maintenance5, supported, available);
|
||||
if enables.expose(Structure::PortabilitySubset, available) {
|
||||
// Ask a portable implementation for exactly what it says it has (only the members:
|
||||
// `unlink` already cleared the query's link).
|
||||
enables.chain.portability_subset = supported.portability_subset;
|
||||
}
|
||||
let stencil_export = c"VK_EXT_shader_stencil_export";
|
||||
if available.has(stencil_export) {
|
||||
enables.extensions.insert(stencil_export);
|
||||
}
|
||||
enables
|
||||
}
|
||||
|
||||
/// What the runtime probe's context enabled beyond the engine's list
|
||||
/// ([`enable_runtime_probe`]).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
@@ -1556,31 +1436,30 @@ pub(super) fn enable_runtime_probe(
|
||||
}
|
||||
}
|
||||
|
||||
/// The engine's enable list: on top of `enables`, the product's
|
||||
/// `DeviceDescription::recommended_enables` for `description` (the device's own queried
|
||||
/// description, at the context's API 1.2, or the profile a restriction reports) under the default
|
||||
/// policy the opened device is derived with, less [`NOT_ENABLED`], with every robustness feature
|
||||
/// ([`ROBUSTNESS_FEATURES`]) the description states. Each recommended extension is enabled by the
|
||||
/// first name the device lists for it, each recommended feature by its member (chaining its
|
||||
/// structure through an enabled extension), and each member no vocabulary names
|
||||
/// (`textureCompressionASTC_HDR` and the rest, by their registry names, `Member::registry`)
|
||||
/// where an enabled extension exposes its structure and the device supports it.
|
||||
/// The engine's enable list: what the runtime enables of `description` (the device's own queried
|
||||
/// description, at the context's API version, or the profile a restriction reports),
|
||||
/// `engine::runtime_enables`, with its robustness features ([`ROBUSTNESS_FEATURES`]) all or none.
|
||||
/// Each of its extensions is enabled by the first name the device lists for it, and each of its
|
||||
/// features by its member (chaining its structure through an enabled extension). Nothing else is
|
||||
/// enabled: no feature or extension outside the runtime's set
|
||||
/// (`metal2vulkan_runtime::floor::enable_set`), and no member the engine's vocabulary does not
|
||||
/// name.
|
||||
///
|
||||
/// A stated robustness feature the feature chain does not report, or whose structure no enabled
|
||||
/// extension exposes, is not an error: no robustness feature is enabled then, and the stated ones
|
||||
/// are [`Enables::unmet_robustness`], so the context opens and every run on it is a typed refusal
|
||||
/// rather than a run of the in-shader encoding. Any other disagreement between
|
||||
/// the product's description and this device's own lists (a recommended extension with no listed
|
||||
/// name, a recommended feature with no member, one the feature chain does not report, or one
|
||||
/// whose structure no enabled extension exposes) is an error: the context is not opened on a list
|
||||
/// that would silently drop it.
|
||||
/// A robustness feature of the set the feature chain does not report, or whose structure no
|
||||
/// enabled extension exposes, is not an error: no robustness feature is enabled then, and the
|
||||
/// stated ones are [`Enables::unmet_robustness`], so the context opens and every run on it is a
|
||||
/// typed refusal rather than a run of the in-shader encoding. Any other disagreement between the
|
||||
/// product's description and this device's own lists (an extension of the set with no listed
|
||||
/// name, a feature with no member, one the feature chain does not report, or one whose structure
|
||||
/// no enabled extension exposes) is an error: the context is not opened on a list that would
|
||||
/// silently drop it.
|
||||
pub(super) fn engine_list(
|
||||
mut enables: Enables,
|
||||
description: &DeviceDescription,
|
||||
supported: &FeatureChain,
|
||||
available: &Available,
|
||||
) -> Result<Enables, String> {
|
||||
let recommended = description.recommended_enables();
|
||||
let mut enables = Enables::new(available.version);
|
||||
let recommended = crate::engine::runtime_enables(description);
|
||||
for &extension in &recommended.extensions {
|
||||
let name = EXTENSIONS
|
||||
.iter()
|
||||
@@ -1592,9 +1471,6 @@ pub(super) fn engine_list(
|
||||
}
|
||||
let mut robustness = Vec::new();
|
||||
for &feature in &recommended.features {
|
||||
if NOT_ENABLED.iter().any(|(excluded, _)| *excluded == feature) {
|
||||
continue;
|
||||
}
|
||||
// Core functionality without a member at the context's version (extended dynamic state
|
||||
// from 1.3): nothing to enable.
|
||||
if !feature.exposure().has_member(enables.version) {
|
||||
@@ -1619,8 +1495,7 @@ pub(super) fn engine_list(
|
||||
}
|
||||
member.set(&mut enables.chain);
|
||||
}
|
||||
// The stated robustness features, all or none: `robustBufferAccess2` without
|
||||
// `robustBufferAccess` is invalid usage, and a context missing any runs nothing anyway.
|
||||
// The stated robustness features, all or none: a context missing any runs nothing anyway.
|
||||
let members = robustness
|
||||
.iter()
|
||||
.map(|&feature| {
|
||||
@@ -1635,12 +1510,6 @@ pub(super) fn engine_list(
|
||||
member.set(&mut enables.chain);
|
||||
}
|
||||
}
|
||||
for member in MEMBERS.iter().filter(|member| member.feature.is_none()) {
|
||||
let extension_structure = !member.structure.extensions().is_empty();
|
||||
if extension_structure && member.is_set(supported) && enables.link(member.structure) {
|
||||
member.set(&mut enables.chain);
|
||||
}
|
||||
}
|
||||
Ok(enables)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,23 +6,6 @@ use metal2vulkan::device::ApiVersion;
|
||||
use metal2vulkan::device::{Device, DevicePolicy};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// A chain that supports every member.
|
||||
fn all_supported() -> FeatureChain {
|
||||
let mut chain = FeatureChain::default();
|
||||
for member in MEMBERS {
|
||||
member.set(&mut chain);
|
||||
}
|
||||
chain
|
||||
}
|
||||
|
||||
/// A device that lists every extension a context can enable.
|
||||
fn every_extension() -> Available {
|
||||
Available::at(
|
||||
ApiVersion::V1_2,
|
||||
EXTENSIONS.iter().map(|extension| extension.name.to_owned()),
|
||||
)
|
||||
}
|
||||
|
||||
/// What a committed profile states that the engine's vocabulary cannot carry, by the names the
|
||||
/// Vulkan registry uses: a `DeviceDescription` holds only the vocabulary, so a member with no
|
||||
/// [`VkFeature`] ([`Member::registry`]) and an extension name with no [`VkExtension`] are read
|
||||
@@ -143,9 +126,31 @@ fn at_1_2(mut description: DeviceDescription) -> DeviceDescription {
|
||||
description
|
||||
}
|
||||
|
||||
/// Whether [`NOT_ENABLED`] names `feature`.
|
||||
fn excluded(feature: VkFeature) -> bool {
|
||||
NOT_ENABLED.iter().any(|(named, _)| *named == feature)
|
||||
/// Every committed profile's context: at API 1.2 as a device context queries it, and at the
|
||||
/// profile's own version as a restricted context opens it. Each is named `<stem> <kind>` and given
|
||||
/// with its enables and what its device supports.
|
||||
fn contexts() -> Vec<(String, Enables, FeatureChain)> {
|
||||
use super::super::profiles::ProfileRestriction;
|
||||
let mut out = Vec::new();
|
||||
for stem in committed_profiles().unwrap() {
|
||||
let restriction = ProfileRestriction::committed(&stem).unwrap();
|
||||
let version = restriction.context_version();
|
||||
let contexts = [
|
||||
(
|
||||
"device",
|
||||
at_1_2(load_description(&stem).unwrap()),
|
||||
ApiVersion::V1_2,
|
||||
),
|
||||
("restricted", restriction.read_at(version), version),
|
||||
];
|
||||
for (kind, description, version) in contexts {
|
||||
let (supported, available) = modelled(&stem, &description, version);
|
||||
let enables = engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem} {kind}: {error}"));
|
||||
out.push((format!("{stem} {kind}"), enables, supported));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The extensions a device described by `description` lists, as a context at `version` sees them:
|
||||
@@ -217,44 +222,82 @@ fn a_member_the_vocabulary_does_not_name_carries_its_registry_name() {
|
||||
/// chain does not report opens no device at all.
|
||||
#[test]
|
||||
fn no_context_enables_a_member_the_device_does_not_report() {
|
||||
use super::super::profiles::ProfileRestriction;
|
||||
let mut checked = 0;
|
||||
for stem in committed_profiles().unwrap() {
|
||||
let restriction = ProfileRestriction::committed(&stem).unwrap();
|
||||
let version = restriction.context_version();
|
||||
for (kind, description, version) in [
|
||||
(
|
||||
"device",
|
||||
at_1_2(load_description(&stem).unwrap()),
|
||||
ApiVersion::V1_2,
|
||||
),
|
||||
("restricted", restriction.read_at(version), version),
|
||||
] {
|
||||
let (supported, available) = modelled(&stem, &description, version);
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem} {kind}: {error}"));
|
||||
for member in MEMBERS {
|
||||
if member.is_set(&enables.chain) {
|
||||
assert!(
|
||||
member.is_set(&supported),
|
||||
"{stem} {kind}: the context enables {:?}.{}, which the device \
|
||||
does not report",
|
||||
member.structure,
|
||||
member.name
|
||||
);
|
||||
checked += 1;
|
||||
}
|
||||
for (name, enables, supported) in contexts() {
|
||||
for member in MEMBERS {
|
||||
if member.is_set(&enables.chain) {
|
||||
assert!(
|
||||
member.is_set(&supported),
|
||||
"{name}: the context enables {:?}.{}, which the device does not report",
|
||||
member.structure,
|
||||
member.name
|
||||
);
|
||||
checked += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(checked > 1000, "{checked} enabled members checked");
|
||||
}
|
||||
|
||||
/// No committed profile's context, at API 1.2 or restricted at its profile's version, enables a
|
||||
/// feature or an extension the runtime never enables (`metal2vulkan_runtime::floor::enable_set`):
|
||||
/// every member it sets is a feature of the runtime's set (or one the runtime's version has as core
|
||||
/// with nothing to enable), none is a member the engine's vocabulary does not name, and every
|
||||
/// extension it enables is one of the set's or one exposing a feature it enables below that
|
||||
/// feature's core version. Ray queries, acceleration structures and deferred host operations,
|
||||
/// which ten profiles list, are among what no context enables.
|
||||
#[test]
|
||||
fn no_context_enables_what_the_runtime_never_enables() {
|
||||
let runtime = metal2vulkan_runtime::floor::enable_set();
|
||||
let version = ApiVersion::from_packed(metal2vulkan_runtime::floor::VERSION);
|
||||
let mut listing_ray_queries = 0;
|
||||
let contexts = contexts();
|
||||
for (name, enables, supported) in &contexts {
|
||||
for member in MEMBERS.iter().filter(|member| enabled(enables, member)) {
|
||||
let feature = member.feature.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"{name}: enables {:?}.{}, which the vocabulary does not name",
|
||||
member.structure, member.name
|
||||
)
|
||||
});
|
||||
assert!(
|
||||
runtime.features.contains(&feature) || !feature.exposure().has_member(version),
|
||||
"{name}: enables {feature:?}, which the runtime never enables"
|
||||
);
|
||||
}
|
||||
let set = enabled_set(enables);
|
||||
for &extension in &enables.extensions {
|
||||
let vocabulary = EXTENSIONS
|
||||
.iter()
|
||||
.find(|named| named.name == extension)
|
||||
.and_then(|named| named.vocabulary)
|
||||
.unwrap_or_else(|| panic!("{name}: enables {extension:?}, outside the vocabulary"));
|
||||
let exposes = (set.features.iter()).any(|feature| {
|
||||
(feature.exposure().extensions_at(enables.version)).contains(&vocabulary)
|
||||
});
|
||||
assert!(
|
||||
runtime.extensions.contains(&vocabulary) || exposes,
|
||||
"{name}: enables {vocabulary:?}, which the runtime never enables"
|
||||
);
|
||||
}
|
||||
for never in [
|
||||
c"VK_KHR_ray_query",
|
||||
c"VK_KHR_acceleration_structure",
|
||||
c"VK_KHR_deferred_host_operations",
|
||||
] {
|
||||
assert!(!enables.extensions.contains(never), "{name}: {never:?}");
|
||||
}
|
||||
if member_of(F::RayQuery).is_some_and(|member| member.is_set(supported)) {
|
||||
listing_ray_queries += 1;
|
||||
}
|
||||
}
|
||||
assert!(contexts.len() >= 30, "{} contexts", contexts.len());
|
||||
assert!(
|
||||
listing_ray_queries > 0,
|
||||
"no context's device has ray queries"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_member_reads_and_writes_its_own_bit() {
|
||||
for (index, member) in MEMBERS.iter().enumerate() {
|
||||
@@ -273,19 +316,13 @@ fn every_member_reads_and_writes_its_own_bit() {
|
||||
}
|
||||
|
||||
/// One member per name in each vocabulary, one name table entry per extension name, and every
|
||||
/// feature of the product's vocabulary is either one the table can enable or one excluded with
|
||||
/// its reason.
|
||||
/// feature of the product's vocabulary is one the table can enable.
|
||||
#[test]
|
||||
fn every_feature_is_enabled_or_excluded_by_name() {
|
||||
fn every_feature_has_one_member_and_every_name_one_entry() {
|
||||
let mut named = BTreeSet::new();
|
||||
for feature in MEMBERS.iter().filter_map(|member| member.feature) {
|
||||
assert!(named.insert(feature), "{feature:?} is listed twice");
|
||||
}
|
||||
let mut excluded = BTreeSet::new();
|
||||
for (feature, reason) in NOT_ENABLED {
|
||||
assert!(excluded.insert(*feature), "{feature:?} is excluded twice");
|
||||
assert!(!reason.is_empty());
|
||||
}
|
||||
let mut fields = BTreeSet::new();
|
||||
for member in MEMBERS {
|
||||
assert!(
|
||||
@@ -306,121 +343,15 @@ fn every_feature_is_enabled_or_excluded_by_name() {
|
||||
}
|
||||
}
|
||||
for feature in VkFeature::ALL {
|
||||
assert!(
|
||||
named.contains(feature) || excluded.contains(feature),
|
||||
"{feature:?} has no member"
|
||||
);
|
||||
assert!(named.contains(feature), "{feature:?} has no member");
|
||||
}
|
||||
}
|
||||
|
||||
/// The old executor's context enables what it enabled before the engine had its own list:
|
||||
/// the base of every engine context, so its opened profile and its rows do not move.
|
||||
#[test]
|
||||
fn the_old_engine_list_is_unchanged() {
|
||||
use VkExtension as X;
|
||||
let enables = old_engine_list(&all_supported(), &every_extension());
|
||||
let set = enabled_set(&enables);
|
||||
assert_eq!(
|
||||
set.features,
|
||||
BTreeSet::from([
|
||||
F::SamplerAnisotropy,
|
||||
F::SampleRateShading,
|
||||
F::TessellationShader,
|
||||
F::ShaderInt16,
|
||||
F::ShaderInt64,
|
||||
F::ShaderClipDistance,
|
||||
F::ShaderCullDistance,
|
||||
F::ShaderStorageImageExtendedFormats,
|
||||
F::ImageCubeArray,
|
||||
F::GeometryShader,
|
||||
F::FragmentStoresAndAtomics,
|
||||
F::VertexPipelineStoresAndAtomics,
|
||||
F::StorageInputOutput16,
|
||||
F::StorageBuffer16BitAccess,
|
||||
F::UniformAndStorageBuffer16BitAccess,
|
||||
F::StoragePushConstant16,
|
||||
F::StorageBuffer8BitAccess,
|
||||
F::UniformAndStorageBuffer8BitAccess,
|
||||
F::StoragePushConstant8,
|
||||
F::ShaderFloat16,
|
||||
F::ShaderInt8,
|
||||
F::ShaderSubgroupExtendedTypes,
|
||||
F::ShaderOutputViewportIndex,
|
||||
F::ShaderOutputLayer,
|
||||
F::BufferDeviceAddress,
|
||||
F::FragmentShaderPixelInterlock,
|
||||
F::ShaderDemoteToHelperInvocation,
|
||||
F::ShaderBufferFloat32AtomicAdd,
|
||||
F::ShaderSharedFloat32AtomicAdd,
|
||||
F::FragmentShaderBarycentric,
|
||||
// The portability subset's structure is chained with what the device supports, as
|
||||
// it always was; the vocabulary names these members, the next three since ARTIFACT 180,
|
||||
// `imageViewFormatSwizzle` since ARTIFACT 203, and `pointPolygons`.
|
||||
F::ConstantAlphaColorBlendFactors,
|
||||
F::VertexAttributeAccessBeyondStride,
|
||||
F::SamplerMipLodBias,
|
||||
F::MutableComparisonSamplers,
|
||||
F::ShaderSampleRateInterpolationFunctions,
|
||||
F::MultisampleArrayImage,
|
||||
F::ImageView2DOn3DImage,
|
||||
F::SeparateStencilMaskRef,
|
||||
F::ImageViewFormatSwizzle,
|
||||
F::PointPolygons,
|
||||
// `maintenance5` is always chained (`old_engine_list`); the vocabulary names it.
|
||||
F::Maintenance5,
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
set.extensions,
|
||||
BTreeSet::from([
|
||||
X::ExtShaderStencilExport,
|
||||
X::ExtFragmentShaderInterlock,
|
||||
X::ExtShaderDemoteToHelperInvocation,
|
||||
X::ExtShaderAtomicFloat,
|
||||
X::KhrFragmentShaderBarycentric,
|
||||
X::KhrMaintenance5,
|
||||
X::KhrDynamicRendering,
|
||||
X::KhrPortabilitySubset,
|
||||
])
|
||||
);
|
||||
// The members the engine's vocabulary does not name, through their structures.
|
||||
assert_eq!(enables.chain.v11.variable_pointers, vk::TRUE);
|
||||
assert_eq!(enables.chain.v11.variable_pointers_storage_buffer, vk::TRUE);
|
||||
assert!(enables.linked.contains(&Structure::FloatControls2));
|
||||
assert_eq!(
|
||||
enables.chain.float_controls2.shader_float_controls2,
|
||||
vk::TRUE
|
||||
);
|
||||
assert_eq!(
|
||||
enables.extensions,
|
||||
BTreeSet::from([
|
||||
c"VK_KHR_portability_subset",
|
||||
c"VK_EXT_shader_stencil_export",
|
||||
c"VK_EXT_fragment_shader_interlock",
|
||||
c"VK_KHR_shader_float_controls2",
|
||||
c"VK_EXT_shader_demote_to_helper_invocation",
|
||||
c"VK_EXT_shader_atomic_float",
|
||||
c"VK_KHR_fragment_shader_barycentric",
|
||||
c"VK_KHR_maintenance5",
|
||||
c"VK_KHR_dynamic_rendering",
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/// A structure is chained, and its members enabled, only through an extension the device lists
|
||||
/// together with what that extension requires; the first listed alternative name is the one
|
||||
/// enabled.
|
||||
#[test]
|
||||
fn a_member_is_enabled_only_through_a_listed_extension() {
|
||||
let supported = all_supported();
|
||||
let bare = Available::at(ApiVersion::V1_2, []);
|
||||
let enables = old_engine_list(&supported, &bare);
|
||||
assert!(enables.linked.is_empty());
|
||||
assert!(enables.extensions.is_empty());
|
||||
assert!(!enabled_set(&enables)
|
||||
.features
|
||||
.contains(&F::FragmentShaderPixelInterlock));
|
||||
|
||||
let unmet = Available::at(
|
||||
ApiVersion::V1_2,
|
||||
[
|
||||
@@ -469,32 +400,23 @@ fn a_member_is_enabled_only_through_a_listed_extension() {
|
||||
}
|
||||
|
||||
/// On every committed profile (as a context's API-1.2 query reads it), the engine's context
|
||||
/// enables exactly the product's recommendation less the excluded features, in the one closed
|
||||
/// set `with_enabled` accepts and `Device::from_queries` derives from, with every robustness feature
|
||||
/// the profile states, so the opened profile compiles the robust encodings it states. The old
|
||||
/// engine's context enables a closed set too.
|
||||
/// enables exactly what the runtime enables of it (`engine::runtime_enables`), in the one closed
|
||||
/// set `with_enabled` accepts and `Device::from_queries` derives from: its opened profile checks
|
||||
/// buffers reached through descriptor views in the shader (the runtime enables no buffer
|
||||
/// robustness) and leaves images to the device where the profile states image robustness. No
|
||||
/// member the vocabulary does not name is enabled (`textureCompressionASTC_HDR` among them).
|
||||
#[test]
|
||||
fn the_new_list_enables_the_recommendation_but_the_excluded() {
|
||||
fn the_list_enables_what_the_runtime_enables_of_the_description() {
|
||||
let stems = committed_profiles().unwrap();
|
||||
assert!(!stems.is_empty());
|
||||
for stem in stems {
|
||||
let description = at_1_2(load_description(&stem).unwrap());
|
||||
let (supported, available) = modelled(&stem, &description, ApiVersion::V1_2);
|
||||
let old = enabled_set(&old_engine_list(&supported, &available));
|
||||
opened_description(description.clone(), &old)
|
||||
.unwrap_or_else(|error| panic!("{stem}: the old list: {error}"));
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
let enables = engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
assert!(enables.unmet_robustness.is_empty(), "{stem}");
|
||||
let set = enabled_set(&enables);
|
||||
let mut expected = description.recommended_enables();
|
||||
expected.features.retain(|&feature| !excluded(feature));
|
||||
assert_eq!(set, expected, "{stem}");
|
||||
assert_eq!(set, crate::engine::runtime_enables(&description), "{stem}");
|
||||
let opened = opened_description(description.clone(), &set)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
let profile = Device::from_queries(opened, DevicePolicy::default())
|
||||
@@ -509,31 +431,25 @@ fn the_new_list_enables_the_recommendation_but_the_excluded() {
|
||||
assert_eq!(
|
||||
robust,
|
||||
(
|
||||
!(states(F::RobustBufferAccess) || states(F::RobustBufferAccess2)),
|
||||
true,
|
||||
states(F::RobustImageAccess) || states(F::RobustImageAccess2)
|
||||
),
|
||||
"{stem}"
|
||||
);
|
||||
// A member no vocabulary names rides along where its structure is chained.
|
||||
if set
|
||||
.extensions
|
||||
.contains(&VkExtension::ExtTextureCompressionAstcHdr)
|
||||
{
|
||||
assert!(enables.linked.contains(&Structure::AstcHdr), "{stem}");
|
||||
assert_eq!(
|
||||
enables.chain.astc_hdr.texture_compression_astc_hdr,
|
||||
vk::TRUE
|
||||
);
|
||||
}
|
||||
assert!(!enables.linked.contains(&Structure::AstcHdr), "{stem}");
|
||||
assert_eq!(
|
||||
enables.chain.astc_hdr.texture_compression_astc_hdr,
|
||||
vk::FALSE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The engine's context enables exactly the robustness features the device's description states,
|
||||
/// through their structures: `robustBufferAccess2` and `robustImageAccess2` through
|
||||
/// `VK_EXT_robustness2`'s, `robustImageAccess` through `VK_EXT_image_robustness`'s; `moltenvk-m3`
|
||||
/// states `robustBufferAccess2` false, so its context enables `robustBufferAccess` alone for
|
||||
/// buffers. A stated feature the device cannot enable is not dropped: no robustness feature is
|
||||
/// enabled then, and the context names it unmet, which refuses every run on it.
|
||||
/// The engine's context enables the robustness features the device's description states that
|
||||
/// the runtime enables (the image ones), through their structures: `robustImageAccess2` through
|
||||
/// `VK_EXT_robustness2`'s, `robustImageAccess` through `VK_EXT_image_robustness`'s, and neither
|
||||
/// buffer feature, with `nullDescriptor` where the device states it. A stated feature the device
|
||||
/// cannot enable is not dropped: no robustness feature is enabled then, and the context names it
|
||||
/// unmet, which refuses every run on it.
|
||||
#[test]
|
||||
fn the_context_enables_the_robustness_the_description_states_or_names_it_unmet() {
|
||||
let enabled_on = |stem: &str, unreported: Option<VkFeature>| {
|
||||
@@ -542,13 +458,8 @@ fn the_context_enables_the_robustness_the_description_states_or_names_it_unmet()
|
||||
if let Some(feature) = unreported {
|
||||
*(member_of(feature).unwrap().write)(&mut supported) = vk::FALSE;
|
||||
}
|
||||
engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"))
|
||||
engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"))
|
||||
};
|
||||
let robustness = |enables: &Enables| {
|
||||
enabled_set(enables)
|
||||
@@ -557,35 +468,25 @@ fn the_context_enables_the_robustness_the_description_states_or_names_it_unmet()
|
||||
.filter(|feature| ROBUSTNESS_FEATURES.contains(feature))
|
||||
.collect::<BTreeSet<_>>()
|
||||
};
|
||||
let images = [F::RobustImageAccess, F::RobustImageAccess2];
|
||||
let lavapipe = enabled_on("lavapipe", None);
|
||||
assert_eq!(robustness(&lavapipe), ROBUSTNESS_FEATURES.into());
|
||||
assert_eq!(robustness(&lavapipe), images.into());
|
||||
assert!(lavapipe.linked.contains(&Structure::Robustness2));
|
||||
assert!(lavapipe.linked.contains(&Structure::ImageRobustness));
|
||||
assert_eq!(lavapipe.chain.core.robust_buffer_access, vk::TRUE);
|
||||
assert_eq!(lavapipe.chain.robustness2.robust_buffer_access2, vk::TRUE);
|
||||
assert_eq!(lavapipe.chain.core.robust_buffer_access, vk::FALSE);
|
||||
assert_eq!(lavapipe.chain.robustness2.robust_buffer_access2, vk::FALSE);
|
||||
assert_eq!(lavapipe.chain.robustness2.robust_image_access2, vk::TRUE);
|
||||
assert_eq!(
|
||||
lavapipe.chain.image_robustness.robust_image_access,
|
||||
vk::TRUE
|
||||
);
|
||||
assert_eq!(lavapipe.chain.robustness2.null_descriptor, vk::FALSE);
|
||||
assert_eq!(lavapipe.chain.robustness2.null_descriptor, vk::TRUE);
|
||||
let moltenvk = enabled_on("moltenvk-m3", None);
|
||||
assert_eq!(
|
||||
robustness(&moltenvk),
|
||||
[
|
||||
F::RobustBufferAccess,
|
||||
F::RobustImageAccess,
|
||||
F::RobustImageAccess2
|
||||
]
|
||||
.into()
|
||||
);
|
||||
assert_eq!(robustness(&moltenvk), images.into());
|
||||
// The runtime floor read at API 1.2: `robustImageAccess` is core from 1.3 and the floor lists
|
||||
// no `VK_EXT_image_robustness`, so only `robustImageAccess2` serves images.
|
||||
let floor = enabled_on("runtime-floor", None);
|
||||
assert_eq!(
|
||||
robustness(&floor),
|
||||
[F::RobustBufferAccess, F::RobustImageAccess2].into()
|
||||
);
|
||||
assert_eq!(robustness(&floor), [F::RobustImageAccess2].into());
|
||||
|
||||
let unmet = enabled_on("lavapipe", Some(F::RobustImageAccess));
|
||||
assert_eq!(unmet.unmet_robustness, [F::RobustImageAccess].into());
|
||||
@@ -594,22 +495,15 @@ fn the_context_enables_the_robustness_the_description_states_or_names_it_unmet()
|
||||
|
||||
/// Where a device lists `VK_EXT_extended_dynamic_state`, the engine's context enables it and
|
||||
/// `extendedDynamicState` through its structure, so the opened profile makes the extended states
|
||||
/// dynamic and a render pipeline's requirement of them is met; the old list enables neither, and a
|
||||
/// device without the extension gets neither.
|
||||
/// dynamic and a render pipeline's requirement of them is met, as the runtime's version has it as
|
||||
/// core; a device without the extension gets neither.
|
||||
#[test]
|
||||
fn the_new_list_enables_extended_dynamic_state_where_the_device_lists_it() {
|
||||
fn the_list_enables_extended_dynamic_state_where_the_device_lists_it() {
|
||||
let lists = |stem: &str| {
|
||||
let description = at_1_2(load_description(stem).unwrap());
|
||||
let (supported, available) = modelled(stem, &description, ApiVersion::V1_2);
|
||||
let old = enabled_set(&old_engine_list(&supported, &available));
|
||||
assert!(!old.features.contains(&F::ExtendedDynamicState), "{stem}");
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
let enables = engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
(description, enables)
|
||||
};
|
||||
for stem in ["lavapipe", "moltenvk-m3"] {
|
||||
@@ -655,17 +549,12 @@ fn the_new_list_enables_extended_dynamic_state_where_the_device_lists_it() {
|
||||
/// vertex pipeline's topology and restart dynamic as the runtime's does; a device without the
|
||||
/// extension gets neither.
|
||||
#[test]
|
||||
fn the_new_list_enables_extended_dynamic_state2_where_the_device_lists_it() {
|
||||
fn the_list_enables_extended_dynamic_state2_where_the_device_lists_it() {
|
||||
let lists = |stem: &str| {
|
||||
let description = at_1_2(load_description(stem).unwrap());
|
||||
let (supported, available) = modelled(stem, &description, ApiVersion::V1_2);
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
let enables = engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
(description, enables)
|
||||
};
|
||||
for stem in ["lavapipe", "moltenvk-m3", "amd-780m-radv"] {
|
||||
@@ -703,40 +592,30 @@ fn the_new_list_enables_extended_dynamic_state2_where_the_device_lists_it() {
|
||||
.contains(&F::ExtendedDynamicState2));
|
||||
}
|
||||
|
||||
/// On every committed profile (as a context's API-1.2 query reads it), the new list (which enables
|
||||
/// the robustness features the description states) is a set the
|
||||
/// device can create: `with_enabled` accepts it, so it keeps
|
||||
/// VUID-VkDeviceCreateInfo-robustBufferAccess-10247: where a profile states
|
||||
/// `robustBufferAccessUpdateAfterBind` false, the list leaves out the buffer update-after-bind
|
||||
/// features, so `robustBufferAccess` can be enabled. The runtime's floor states it false and has
|
||||
/// none of those features; the product's `a_recommendation_keeps_vuid_10247` adds them to it.
|
||||
/// On every committed profile (as a context's API-1.2 query reads it), the list is a set the
|
||||
/// device can create: `with_enabled` accepts it. It enables neither buffer robustness feature (the
|
||||
/// runtime enables none), so VUID-VkDeviceCreateInfo-robustBufferAccess-10247 never applies, and
|
||||
/// the texel buffers' update-after-bind features, which the runtime requires, are enabled wherever
|
||||
/// the profile states them.
|
||||
#[test]
|
||||
fn the_new_list_with_the_stated_robustness_keeps_the_co_enable_rules() {
|
||||
// The features of VUID-VkDeviceCreateInfo-robustBufferAccess-10247 the vocabulary names (its
|
||||
// fourth, `descriptorBindingUniformBufferUpdateAfterBind`, is not in it).
|
||||
const BUFFER_UPDATE_AFTER_BIND: [VkFeature; 3] = [
|
||||
F::DescriptorBindingStorageBufferUpdateAfterBind,
|
||||
F::DescriptorBindingUniformTexelBufferUpdateAfterBind,
|
||||
F::DescriptorBindingStorageTexelBufferUpdateAfterBind,
|
||||
];
|
||||
fn the_list_enables_no_buffer_robustness_and_keeps_the_texel_buffers_update_after_bind() {
|
||||
for stem in committed_profiles().unwrap() {
|
||||
let description = at_1_2(load_description(&stem).unwrap());
|
||||
let (supported, available) = modelled(&stem, &description, ApiVersion::V1_2);
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
let enables = engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
let set = enabled_set(&enables);
|
||||
assert!(set.features.contains(&F::RobustBufferAccess), "{stem}");
|
||||
if !description.robust_buffer_access_update_after_bind {
|
||||
assert!(
|
||||
BUFFER_UPDATE_AFTER_BIND
|
||||
.iter()
|
||||
.all(|feature| !set.features.contains(feature)),
|
||||
"{stem}"
|
||||
for feature in [F::RobustBufferAccess, F::RobustBufferAccess2] {
|
||||
assert!(!set.features.contains(&feature), "{stem}: {feature:?}");
|
||||
}
|
||||
for feature in [
|
||||
F::DescriptorBindingUniformTexelBufferUpdateAfterBind,
|
||||
F::DescriptorBindingStorageTexelBufferUpdateAfterBind,
|
||||
] {
|
||||
assert_eq!(
|
||||
set.features.contains(&feature),
|
||||
description.features.contains(&feature),
|
||||
"{stem}: {feature:?}"
|
||||
);
|
||||
}
|
||||
let opened = opened_description(description.clone(), &set)
|
||||
@@ -754,14 +633,9 @@ fn a_disagreeing_description_is_refused() {
|
||||
let (supported, available) = modelled("lavapipe", &description, ApiVersion::V1_2);
|
||||
let mut unreported = supported;
|
||||
*(member_of(F::ShaderInt64).unwrap().write)(&mut unreported) = vk::FALSE;
|
||||
let error = engine_list(
|
||||
Enables::new(ApiVersion::V1_2),
|
||||
&description,
|
||||
&unreported,
|
||||
&available,
|
||||
)
|
||||
.err()
|
||||
.unwrap();
|
||||
let error = engine_list(&description, &unreported, &available)
|
||||
.err()
|
||||
.unwrap();
|
||||
assert!(error.contains("ShaderInt64"), "{error}");
|
||||
let unlisted = Available::at(
|
||||
ApiVersion::V1_2,
|
||||
@@ -771,69 +645,46 @@ fn a_disagreeing_description_is_refused() {
|
||||
.filter(|named| available.has(named.name))
|
||||
.map(|named| named.name.to_owned()),
|
||||
);
|
||||
let error = engine_list(
|
||||
Enables::new(ApiVersion::V1_2),
|
||||
&description,
|
||||
&supported,
|
||||
&unlisted,
|
||||
)
|
||||
.err()
|
||||
.unwrap();
|
||||
let error = engine_list(&description, &supported, &unlisted)
|
||||
.err()
|
||||
.unwrap();
|
||||
assert!(error.contains("ExtRobustness2"), "{error}");
|
||||
}
|
||||
|
||||
/// The executor's MoltenVK device (the Q1 refusals): the old list dropped subgroup size control and
|
||||
/// the memory model, so the opened kernel stage could not require full subgroups; the engine's
|
||||
/// list enables both, and the opened profile carries them.
|
||||
/// The executor's MoltenVK device (the Q1 refusals): its context enables subgroup size control
|
||||
/// and the memory model, so the opened kernel stage can require full subgroups, and the opened
|
||||
/// profile carries them; it enables no `fragmentShaderSampleInterlock`, which MoltenVK states and
|
||||
/// the runtime never enables.
|
||||
#[test]
|
||||
fn the_moltenvk_context_opens_full_subgroups_and_the_memory_model() {
|
||||
let description = at_1_2(load_description("moltenvk-m3").unwrap());
|
||||
let (supported, available) = modelled("moltenvk-m3", &description, ApiVersion::V1_2);
|
||||
let opened = |set: &EnableSet| {
|
||||
derived_profile(opened_description(description.clone(), set).unwrap()).unwrap()
|
||||
};
|
||||
|
||||
let old = enabled_set(&old_engine_list(&supported, &available));
|
||||
let old_profile = opened(&old);
|
||||
assert!(!old_profile.subgroups().kernel.full_subgroups);
|
||||
assert!(!old_profile
|
||||
.enabled()
|
||||
.features
|
||||
.contains(&F::VulkanMemoryModel));
|
||||
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap();
|
||||
let enables = engine_list(&description, &supported, &available).unwrap();
|
||||
let set = enabled_set(&enables);
|
||||
for feature in [
|
||||
F::SubgroupSizeControl,
|
||||
F::ComputeFullSubgroups,
|
||||
F::VulkanMemoryModel,
|
||||
F::VulkanMemoryModelDeviceScope,
|
||||
F::FragmentShaderSampleInterlock,
|
||||
F::Maintenance8,
|
||||
] {
|
||||
assert!(set.features.contains(&feature), "{feature:?}");
|
||||
}
|
||||
assert!(description.has(F::FragmentShaderSampleInterlock));
|
||||
assert!(!set.features.contains(&F::FragmentShaderSampleInterlock));
|
||||
assert!(set
|
||||
.extensions
|
||||
.contains(&VkExtension::ExtSubgroupSizeControl));
|
||||
assert!(enables.linked.contains(&Structure::SubgroupSizeControl));
|
||||
let profile = opened(&set);
|
||||
let profile = derived_profile(opened_description(description, &set).unwrap()).unwrap();
|
||||
assert!(profile.subgroups().kernel.full_subgroups);
|
||||
assert!(profile.enabled().features.contains(&F::VulkanMemoryModel));
|
||||
}
|
||||
|
||||
/// The opened context enables the product's recommendation less the excluded features on top of
|
||||
/// the base list (lavapipe and MoltenVK both list subgroup size control and have the memory
|
||||
/// model), under the validation layer without a message, and its opened description is
|
||||
/// restricted to exactly what it enabled. It enables the device's stated robustness (both devices
|
||||
/// state
|
||||
/// `robustBufferAccess`) with none unmet, so its opened profile compiles robust descriptor views.
|
||||
/// The opened context enables what the runtime enables of the device (lavapipe and MoltenVK both
|
||||
/// list subgroup size control and have the memory model), under the validation layer without a
|
||||
/// message, and its opened description is restricted to exactly what it enabled. It enables no
|
||||
/// buffer robustness, and none of its stated robustness is unmet.
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
#[test]
|
||||
fn the_opened_contexts_enable_their_lists() {
|
||||
@@ -850,7 +701,7 @@ fn the_opened_contexts_enable_their_lists() {
|
||||
.unwrap();
|
||||
assert!(messages.is_empty(), "{messages:?}");
|
||||
assert_eq!(unmet, BTreeSet::new());
|
||||
assert!(new.features.contains(&F::RobustBufferAccess));
|
||||
assert!(!new.features.contains(&F::RobustBufferAccess));
|
||||
let opened = opened.unwrap();
|
||||
assert_eq!(opened.features, new.features);
|
||||
assert_eq!(opened.extensions, new.extensions);
|
||||
@@ -862,41 +713,38 @@ fn the_opened_contexts_enable_their_lists() {
|
||||
] {
|
||||
assert!(new.features.contains(&feature), "{feature:?}");
|
||||
}
|
||||
for (feature, _) in NOT_ENABLED {
|
||||
assert!(!new.features.contains(feature), "{feature:?}");
|
||||
let runtime = metal2vulkan_runtime::floor::enable_set();
|
||||
let version = ApiVersion::from_packed(metal2vulkan_runtime::floor::VERSION);
|
||||
for feature in &new.features {
|
||||
assert!(
|
||||
runtime.features.contains(feature) || !feature.exposure().has_member(version),
|
||||
"{feature:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the device lists `VK_KHR_shader_fma` (moltenvk-m3), the new list enables it and
|
||||
/// `shaderFmaFloat32`, and the opened description states both, so a module the engine
|
||||
/// translated with `OpFmaKHR`, whose requirements name the feature, is not refused as
|
||||
/// `not_enabled`.
|
||||
/// Where the device lists `VK_KHR_shader_fma` (moltenvk-m3), the context enables neither it nor
|
||||
/// `shaderFmaFloat32` (the runtime never does), and the opened description states neither, so a
|
||||
/// `float` `fma` compiles to the device's `Fma` as on the runtime.
|
||||
#[test]
|
||||
fn an_enabled_shader_fma_is_in_the_opened_description() {
|
||||
fn shader_fma_is_not_enabled_where_the_device_lists_it() {
|
||||
let description = at_1_2(load_description("moltenvk-m3").unwrap());
|
||||
assert!(description.extensions.contains(&VkExtension::KhrShaderFma));
|
||||
let (supported, available) = modelled("moltenvk-m3", &description, ApiVersion::V1_2);
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(enables.chain.shader_fma.shader_fma_float32, vk::TRUE);
|
||||
assert!(enables.extensions.contains(c"VK_KHR_shader_fma"));
|
||||
let enables = engine_list(&description, &supported, &available).unwrap();
|
||||
assert_eq!(enables.chain.shader_fma.shader_fma_float32, vk::FALSE);
|
||||
assert!(!enables.extensions.contains(c"VK_KHR_shader_fma"));
|
||||
let set = enabled_set(&enables);
|
||||
let opened = opened_description(description, &set).unwrap();
|
||||
assert!(opened.features.contains(&F::ShaderFmaFloat32));
|
||||
assert!(opened.extensions.contains(&VkExtension::KhrShaderFma));
|
||||
assert!(!opened.features.contains(&F::ShaderFmaFloat32));
|
||||
assert!(!opened.extensions.contains(&VkExtension::KhrShaderFma));
|
||||
}
|
||||
|
||||
/// An engine context enables `VK_EXT_depth_range_unrestricted` exactly where the device lists
|
||||
/// it, so its copies into a depth aspect keep Metal's `Depth32Float` texels outside
|
||||
/// `[0, 1]` (RADV stores them clamped without it); the opened description then states it, and a
|
||||
/// module reading depth texels compiled for it records no `RestrictedDepthRange`. A device that
|
||||
/// does not list it (moltenvk-m3) is opened without it.
|
||||
/// No engine context enables `VK_EXT_depth_range_unrestricted`, which the runtime never enables,
|
||||
/// whether the device lists it or not: the opened description does not state it, so a module
|
||||
/// writing depth texels compiled for it records `RestrictedDepthRange`, as on the runtime.
|
||||
#[test]
|
||||
fn depth_range_unrestricted_is_enabled_where_the_device_lists_it() {
|
||||
fn depth_range_unrestricted_is_not_enabled_where_the_device_lists_it() {
|
||||
use metal2vulkan::device::VkExtension as X;
|
||||
let name = c"VK_EXT_depth_range_unrestricted";
|
||||
for (stem, listed) in [
|
||||
@@ -913,25 +761,18 @@ fn depth_range_unrestricted_is_enabled_where_the_device_lists_it() {
|
||||
"{stem}"
|
||||
);
|
||||
let (supported, available) = modelled(stem, &description, ApiVersion::V1_2);
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
assert_eq!(enables.extensions.contains(name), listed, "{stem}");
|
||||
let enables = engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
assert!(!enables.extensions.contains(name), "{stem}");
|
||||
let set = enabled_set(&enables);
|
||||
assert_eq!(
|
||||
set.extensions.contains(&X::ExtDepthRangeUnrestricted),
|
||||
listed,
|
||||
assert!(
|
||||
!set.extensions.contains(&X::ExtDepthRangeUnrestricted),
|
||||
"{stem}"
|
||||
);
|
||||
let opened = opened_description(description.clone(), &set)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
assert_eq!(
|
||||
opened.extensions.contains(&X::ExtDepthRangeUnrestricted),
|
||||
listed,
|
||||
assert!(
|
||||
!opened.extensions.contains(&X::ExtDepthRangeUnrestricted),
|
||||
"{stem}"
|
||||
);
|
||||
}
|
||||
@@ -950,9 +791,9 @@ fn every_structure() -> impl Iterator<Item = Structure> {
|
||||
/// A context at Vulkan 1.2, every unrestricted context and every one restricted to a profile of
|
||||
/// that version, exposes, chains, and enables exactly as before contexts had a version. Only the
|
||||
/// base structures are core at 1.2, every extension requirement stands, and
|
||||
/// [`Available::exposing`], [`Enables::expose`] and [`Enables::link`] give what the former rules
|
||||
/// (restated here) give over extension lists this test builds: none, all, each structure's names
|
||||
/// alone, and each with its requirements.
|
||||
/// [`Available::exposing`] and [`Enables::link`] give what the former rules (restated here) give
|
||||
/// over extension lists this test builds: none, all, each structure's names alone, and each with
|
||||
/// its requirements.
|
||||
#[test]
|
||||
fn a_context_at_vulkan_1_2_exposes_and_links_as_before() {
|
||||
fn former_exposing(
|
||||
@@ -974,21 +815,6 @@ fn a_context_at_vulkan_1_2_exposes_and_links_as_before() {
|
||||
}
|
||||
/// `(linked, extensions)` of a former `Enables`.
|
||||
type Former = (BTreeSet<Structure>, BTreeSet<&'static CStr>);
|
||||
fn former_expose(
|
||||
state: &mut Former,
|
||||
structure: Structure,
|
||||
names: &BTreeSet<&'static CStr>,
|
||||
) -> bool {
|
||||
let Some(extension) = former_exposing(names, structure) else {
|
||||
return false;
|
||||
};
|
||||
if let Some(name) = extension {
|
||||
state.0.insert(structure);
|
||||
state.1.insert(name);
|
||||
state.1.extend(structure.requires().iter().copied());
|
||||
}
|
||||
true
|
||||
}
|
||||
fn former_link(state: &mut Former, structure: Structure) -> bool {
|
||||
let alternatives = structure.extensions();
|
||||
if alternatives.is_empty() {
|
||||
@@ -1033,8 +859,6 @@ fn a_context_at_vulkan_1_2_exposes_and_links_as_before() {
|
||||
ApiVersion::V1_2,
|
||||
names.iter().map(|name| (*name).to_owned()),
|
||||
);
|
||||
let mut exposing = Enables::new(ApiVersion::V1_2);
|
||||
let mut former_exposed: Former = Default::default();
|
||||
let mut linking = Enables::new(ApiVersion::V1_2);
|
||||
linking.extensions = names.clone();
|
||||
let mut former_linked: Former = (BTreeSet::new(), names.clone());
|
||||
@@ -1044,22 +868,12 @@ fn a_context_at_vulkan_1_2_exposes_and_links_as_before() {
|
||||
former_exposing(names, structure),
|
||||
"{structure:?} {names:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
exposing.expose(structure, &available),
|
||||
former_expose(&mut former_exposed, structure, names),
|
||||
"{structure:?} {names:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
linking.link(structure),
|
||||
former_link(&mut former_linked, structure),
|
||||
"{structure:?} {names:?}"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
(exposing.linked, exposing.extensions),
|
||||
former_exposed,
|
||||
"{names:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
(linking.linked, linking.extensions),
|
||||
former_linked,
|
||||
@@ -1137,12 +951,12 @@ fn a_structure_is_core_from_the_version_the_product_reads_it_core() {
|
||||
|
||||
/// A context restricted to a committed profile runs at the profile's version
|
||||
/// (`ProfileRestriction::context_version`) and translates for the profile read there. At that
|
||||
/// version its engine list is the product's recommendation less the excluded features, the
|
||||
/// one closed set `with_enabled` accepts and `Device::from_queries` derives from, as at 1.2
|
||||
/// ([`the_new_list_enables_the_recommendation_but_the_excluded`]), and no structure core at the
|
||||
/// version is chained through its extension.
|
||||
/// version its engine list is what the runtime enables of the profile, the one closed set
|
||||
/// `with_enabled` accepts and `Device::from_queries` derives from, as at 1.2
|
||||
/// ([`the_list_enables_what_the_runtime_enables_of_the_description`]), and no structure core at
|
||||
/// the version is chained through its extension.
|
||||
#[test]
|
||||
fn a_restricted_context_enables_the_recommendation_at_its_profiles_version() {
|
||||
fn a_restricted_context_enables_what_the_runtime_enables_at_its_profiles_version() {
|
||||
use super::super::profiles::ProfileRestriction;
|
||||
for stem in committed_profiles().unwrap() {
|
||||
let restriction = ProfileRestriction::committed(&stem).unwrap();
|
||||
@@ -1154,19 +968,12 @@ fn a_restricted_context_enables_the_recommendation_at_its_profiles_version() {
|
||||
);
|
||||
let description = restriction.read_at(version);
|
||||
let (supported, available) = modelled(&stem, &description, version);
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
let enables = engine_list(&description, &supported, &available)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
assert_eq!(enables.version, version, "{stem}");
|
||||
assert!(enables.unmet_robustness.is_empty(), "{stem}");
|
||||
let set = enabled_set(&enables);
|
||||
let mut expected = description.recommended_enables();
|
||||
expected.features.retain(|&feature| !excluded(feature));
|
||||
assert_eq!(set, expected, "{stem}");
|
||||
assert_eq!(set, crate::engine::runtime_enables(&description), "{stem}");
|
||||
let opened = opened_description(description.clone(), &set)
|
||||
.unwrap_or_else(|error| panic!("{stem}: {error}"));
|
||||
Device::from_queries(opened, DevicePolicy::default())
|
||||
@@ -1573,36 +1380,13 @@ fn chain_lines(enables: &Enables) -> Vec<String> {
|
||||
lines
|
||||
}
|
||||
|
||||
/// Every committed profile's context: at API 1.2 as a device context queries it, and at the
|
||||
/// profile's own version as a restricted context opens it. Each is named `<stem> <kind>` and given with its
|
||||
/// Every committed profile's context ([`contexts`]), named `<stem> <kind>`, with its
|
||||
/// [`chain_lines`].
|
||||
fn opened_chains() -> Vec<(String, Vec<String>)> {
|
||||
use super::super::profiles::ProfileRestriction;
|
||||
let mut out = Vec::new();
|
||||
for stem in committed_profiles().unwrap() {
|
||||
let restriction = ProfileRestriction::committed(&stem).unwrap();
|
||||
let version = restriction.context_version();
|
||||
let contexts = [
|
||||
(
|
||||
"device",
|
||||
at_1_2(load_description(&stem).unwrap()),
|
||||
ApiVersion::V1_2,
|
||||
),
|
||||
("restricted", restriction.read_at(version), version),
|
||||
];
|
||||
for (kind, description, version) in contexts {
|
||||
let (supported, available) = modelled(&stem, &description, version);
|
||||
let enables = engine_list(
|
||||
old_engine_list(&supported, &available),
|
||||
&description,
|
||||
&supported,
|
||||
&available,
|
||||
)
|
||||
.unwrap_or_else(|error| panic!("{stem} {kind}: {error}"));
|
||||
out.push((format!("{stem} {kind}"), chain_lines(&enables)));
|
||||
}
|
||||
}
|
||||
out
|
||||
contexts()
|
||||
.into_iter()
|
||||
.map(|(name, enables, _)| (name, chain_lines(&enables)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// One line of [`OPENED_CHAINS`]: a context's name, the SHA-256 of its [`chain_lines`] (each
|
||||
|
||||
@@ -63,7 +63,8 @@ impl SubgroupShape {
|
||||
/// in-shader check of descriptor views (`DeviceProfile::checks_buffers_in_shader`), image
|
||||
/// robustness the in-shader clamp and guard of images (`robust_image_access`). A tier-table
|
||||
/// profile's robustness-off leg removes them ([`Leg::RobustnessOff`]), and the engine executor's
|
||||
/// own context enables exactly the ones its device's description states.
|
||||
/// own context enables the ones its device's description states that the runtime enables on some
|
||||
/// device (the image ones), all or none.
|
||||
pub const ROBUSTNESS_FEATURES: [VkFeature; 4] = [
|
||||
VkFeature::RobustBufferAccess,
|
||||
VkFeature::RobustBufferAccess2,
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
//! error taxonomy, never a second list of reasons.
|
||||
|
||||
use crate::l3::L3Failure;
|
||||
use metal2vulkan::device::{DevicePolicy, DeviceProfile, Requirements};
|
||||
use metal2vulkan::device::{
|
||||
ApiVersion, DeviceDescription, DevicePolicy, DeviceProfile, EnableSet, Requirements,
|
||||
VkExtension,
|
||||
};
|
||||
use metal2vulkan::error::{
|
||||
CanonError, Capability, Error, ErrorClass, Feature, InputError, InputErrorKind, InternalKind,
|
||||
Limit, Location, Needs, RuntimeInput,
|
||||
@@ -20,7 +23,7 @@ use metal2vulkan::pipeline::{CompileReport, EntryDescriptor, EntryRef, LoweringI
|
||||
use metal2vulkan::Budget;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Instant;
|
||||
|
||||
@@ -989,16 +992,62 @@ pub fn load_profile(stem: &str) -> Result<DeviceProfile, String> {
|
||||
Ok(load_device(stem)?.profile().clone())
|
||||
}
|
||||
|
||||
/// The engine's `Device` for committed profile `stem` under the default policy (the runtime's):
|
||||
/// what the public compile API compiles against (its profile is [`load_profile`]'s).
|
||||
/// The engine's `Device` for committed profile `stem` under the default policy (the runtime's),
|
||||
/// made of [`runtime_description`]: what the public compile API compiles against (its profile is
|
||||
/// [`load_profile`]'s).
|
||||
pub fn load_device(stem: &str) -> Result<metal2vulkan::device::Device, String> {
|
||||
metal2vulkan::device::Device::from_queries(load_description(stem)?, DevicePolicy::default())
|
||||
metal2vulkan::device::Device::from_queries(runtime_description(stem)?, DevicePolicy::default())
|
||||
.map_err(|error| format!("{stem}: {error}"))
|
||||
}
|
||||
|
||||
/// The `DeviceDescription` of committed profile `stem`, as the Khronos JSON reader builds it:
|
||||
/// Committed profile `stem` as the runtime's device describes it: read at the runtime's Vulkan
|
||||
/// version (`metal2vulkan_runtime::floor::VERSION`, [`crate::acceptance::read_at`]) and restricted
|
||||
/// to what the runtime enables of it ([`runtime_enables`]). What every census compiles for, and
|
||||
/// what a compile worker rebuilds [`load_device`]'s `Device` from.
|
||||
pub fn load_description(stem: &str) -> Result<metal2vulkan::device::DeviceDescription, String> {
|
||||
pub fn runtime_description(stem: &str) -> Result<DeviceDescription, String> {
|
||||
let read = crate::acceptance::read_at(&load_description(stem)?, runtime_version());
|
||||
let enables = runtime_enables(&read);
|
||||
read.with_enabled(&enables)
|
||||
.map_err(|error| format!("{stem}: the runtime's enables: {error}"))
|
||||
}
|
||||
|
||||
/// The Vulkan version the runtime requires of every device and makes its descriptions at.
|
||||
fn runtime_version() -> ApiVersion {
|
||||
ApiVersion::from_packed(metal2vulkan_runtime::floor::VERSION)
|
||||
}
|
||||
|
||||
/// What the runtime enables of a device `description` states, in the translator's vocabulary:
|
||||
/// `description`'s recommended enables (`DeviceDescription::recommended_enables`) of the features
|
||||
/// the runtime enables on some device (`metal2vulkan_runtime::floor::enable_set`) and of those
|
||||
/// its version has as core with nothing to enable (extended dynamic state), with the set's
|
||||
/// extensions and each extension that exposes one of those features below its core version (a
|
||||
/// context below the runtime's version reaches them so). The one definition of what a validation
|
||||
/// context enables and of what a census compiles for: no feature or extension outside the
|
||||
/// runtime's set.
|
||||
///
|
||||
/// It is the runtime's tables applied to what `description` states, not the runtime's answer for
|
||||
/// one device: where the runtime enables a group all or none (the border swizzle's two features),
|
||||
/// by the device's limits (the attachment feedback loop), or not at all (a device below its floor),
|
||||
/// this keeps each member of the set `description` states.
|
||||
pub fn runtime_enables(description: &DeviceDescription) -> EnableSet {
|
||||
let runtime = metal2vulkan_runtime::floor::enable_set();
|
||||
let api = description.api_version;
|
||||
let mut kept = description.clone();
|
||||
kept.features.retain(|&feature| {
|
||||
runtime.features.contains(&feature) || !feature.exposure().has_member(runtime_version())
|
||||
});
|
||||
let exposing: BTreeSet<VkExtension> = (kept.features.iter())
|
||||
.flat_map(|feature| feature.exposure().extensions_at(api))
|
||||
.copied()
|
||||
.collect();
|
||||
kept.extensions
|
||||
.retain(|extension| runtime.extensions.contains(extension) || exposing.contains(extension));
|
||||
kept.recommended_enables()
|
||||
}
|
||||
|
||||
/// The `DeviceDescription` of committed profile `stem`, as the Khronos JSON reader builds it: what
|
||||
/// the device states, before [`runtime_description`] restricts it.
|
||||
pub fn load_description(stem: &str) -> Result<DeviceDescription, String> {
|
||||
let committed = committed_profiles()?;
|
||||
if !committed.iter().any(|known| known == stem) {
|
||||
return Err(format!(
|
||||
@@ -1009,8 +1058,7 @@ pub fn load_description(stem: &str) -> Result<metal2vulkan::device::DeviceDescri
|
||||
let path = profiles_dir().join(format!("{stem}.json"));
|
||||
let text =
|
||||
std::fs::read_to_string(&path).map_err(|error| format!("{}: {error}", path.display()))?;
|
||||
metal2vulkan::device::DeviceDescription::from_khronos_json(&text, None)
|
||||
.map_err(|error| format!("{stem}: {error}"))
|
||||
DeviceDescription::from_khronos_json(&text, None).map_err(|error| format!("{stem}: {error}"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -3381,6 +3381,7 @@ fn metal2vulkan-air::intrinsics::undecoded_feature pub fn undecoded_feature(name
|
||||
fn metal2vulkan-air::specialize pub fn specialize(d: Decoded, r: &SpecRequest, m: &mut Meter) -> Result<Entry, Error>
|
||||
fn metal2vulkan-air::specialize_dynamic pub fn specialize_dynamic(d: Decoded, r: &SpecRequest, (linked, dynamic): (&[LinkedModule], &DynamicLinks), m: &mut Meter) -> Result<Entry, Error>
|
||||
fn metal2vulkan-air::specialize_linked pub fn specialize_linked(d: Decoded, r: &SpecRequest, linked: &[LinkedModule], m: &mut Meter) -> Result<Entry, Error>
|
||||
fn metal2vulkan-runtime::floor::enable_set pub fn enable_set() -> EnableSet
|
||||
fn metal2vulkan-runtime::host_time pub fn host_time() -> u64
|
||||
fn metal2vulkan-runtime::serve_stage pub fn serve_stage(instance: &Instance, mut options: DeviceOptions, mut from_parent: impl Read, mut to_parent: impl Write) -> io::Result<()>
|
||||
fn metal2vulkan::ash_interop::sampler_create_info pub fn sampler_create_info<'a>(desc: &vk::SamplerDesc, reduction: &'a mut ash::vk::SamplerReductionModeCreateInfo<'static>, border: &'a mut ash::vk::SamplerBorderColorComponentMappingCreateInfoEXT<'static>) -> ash::vk::SamplerCreateInfo<'a>
|
||||
|
||||
|
Can't render this file because it is too large.
|
+21
-1
@@ -381,6 +381,25 @@ worker under the 20-second and 500-MiB ceilings, resumable in bounded batches (`
|
||||
| `bitcode-reader` | The bitcode reader's decode compared with `llvm-dis`, and the intrinsic census |
|
||||
| focused audits (`rasterization-rate-maps`, `sample-rate`, `ulong-textures`, `fragment-varyings`, `linked-functions`, `tile-functions`, `mesh-draws`) | One structural family, selected by current facts, translated in batches |
|
||||
|
||||
The translation, specialization and authored-compile audits, and `corpus-pipeline`, compile for a
|
||||
committed profile as the runtime's device describes it (`engine::runtime_description`): read at
|
||||
the runtime's Vulkan version and restricted to what the runtime enables of it
|
||||
(`engine::runtime_enables`, of `metal2vulkan_runtime::floor::enable_set`). Every Vulkan context
|
||||
the executor opens enables the same set. It is the runtime's tables applied to what the profile
|
||||
states, which differs from the runtime's own answer for a device in four places:
|
||||
|
||||
- The runtime enables the border swizzle's two features together or not at all; a profile that
|
||||
states `borderColorSwizzle` without `borderColorSwizzleFromImage` (the NVIDIA ones) keeps
|
||||
`borderColorSwizzle` here, where the runtime enables neither.
|
||||
- The runtime enables the attachment feedback loop only where the device's descriptor limits hold
|
||||
the attachment reads; this keeps it wherever the profile states it.
|
||||
- A profile below the runtime's floor (`moltenvk-m3`, which states `nullDescriptor` and `logicOp`
|
||||
false) is compiled for the set's intersection with what it states, not for the runtime's answer,
|
||||
which is to refuse the device.
|
||||
- A context at API 1.2 (every context without a profile restriction) reaches the features the
|
||||
runtime's version has as core through their extensions, and has none that only that version
|
||||
brings without an extension.
|
||||
|
||||
```sh
|
||||
cargo run -p metal2vulkan-validation --release --bin corpus-triage -- \
|
||||
--audit authoring-capabilities --limit 100000
|
||||
@@ -450,7 +469,8 @@ cargo run -p metal2vulkan-validation --release --bin corpus-vulkan -- \
|
||||
- **The Vulkan candidate** (`corpus-vulkan`, on Linux) translates the
|
||||
case through the public API in a killable compile worker, executes exactly what the binder plans,
|
||||
and compares the observations with Metal's. Every context runs under the validation layer and
|
||||
enables every robustness feature the device states.
|
||||
enables what the runtime enables of the device: no buffer robustness, and the image robustness
|
||||
the device states.
|
||||
- **Through the runtime.** On Linux, without a profile restriction, every kernel case the engine
|
||||
maps (buffers, device buffer arrays included, bound textures and samplers, argument buffers of
|
||||
buffers, textures and samplers, threadgroup memory, function constants and linked functions,
|
||||
|
||||
Reference in new issue
Block a user