Translator: the DevicePolicy switches, the driver-fact tables and Device::new go; Device::from_queries is the one constructor
Work in progress of the cutover's translator lane: the policy keeps the pointer and handle domains, containment and isolation; the profile is derived from Vulkan queries alone; the measured description set, the per-identity function storage table and the fact pairs of the profile go with docs/FAST-PATHS.md and tests::fast_paths. Not yet compiled.
This commit is contained in:
1 parent
b100185a2d
commit
0b94d919d9
214 files changed
+1035
-12431
No files matched your search
@@ -75,7 +75,7 @@ fn committed_device(stem: &str) -> Result<Device> {
|
||||
"crates/metal2vulkan-validation/profiles/{stem}.json"
|
||||
)))?;
|
||||
let description = DeviceDescription::from_khronos_json(&json, None)?;
|
||||
let device = Device::new(description, DevicePolicy::default())?;
|
||||
let device = Device::from_queries(description, DevicePolicy::default())?;
|
||||
Ok(device)
|
||||
}
|
||||
|
||||
|
||||
@@ -1169,7 +1169,7 @@ fn a_queried_description_derives_a_device() {
|
||||
dev.v11_props.subgroup_supported_stages = avk::ShaderStageFlags::ALL;
|
||||
dev.v11_props.subgroup_supported_operations = avk::SubgroupFeatureFlags::from_raw(0xff);
|
||||
let desc = dev.query().unwrap();
|
||||
Device::new(desc, DevicePolicy::default()).expect("queried description derives");
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("queried description derives");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -17,7 +17,7 @@ fn the_modules_are_valid_on_every_committed_device() {
|
||||
}
|
||||
let text = std::fs::read_to_string(&path).expect("read");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
let profile = device.profile();
|
||||
assert_valid(merge_vertex_typed_module().expect("vertex"), profile);
|
||||
assert_valid(fragment_typed_module().expect("fragment"), profile);
|
||||
|
||||
@@ -171,7 +171,7 @@ fn the_modules_come_numbered_and_refuse_another_count_or_planes() {
|
||||
.join("../metal2vulkan-validation/profiles/lavapipe.json");
|
||||
let text = std::fs::read_to_string(&path).expect("read");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
let format = representatives()[0];
|
||||
for (format, source) in cases(format) {
|
||||
let modules =
|
||||
|
||||
@@ -130,7 +130,7 @@ fn committed_devices() -> Vec<(String, Device)> {
|
||||
.unwrap_or_default();
|
||||
let text = std::fs::read_to_string(&path).expect("read");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
out.push((stem, device));
|
||||
}
|
||||
out.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
@@ -79,7 +79,7 @@ fn the_modules_come_numbered_and_refuse_another_count() {
|
||||
.join("../metal2vulkan-validation/profiles/lavapipe.json");
|
||||
let text = std::fs::read_to_string(&path).expect("read");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
for draw in every_draw(4) {
|
||||
let modules = depth_stencil_resolve_modules(&device, draw, Feature::Format);
|
||||
match modules {
|
||||
|
||||
@@ -36,7 +36,8 @@ fn committed_devices() -> Vec<(String, Device)> {
|
||||
let stem = p.file_stem().unwrap().to_string_lossy().into_owned();
|
||||
let text = std::fs::read_to_string(&p).expect("profile is readable");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("profile parses");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device derives");
|
||||
let device =
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device derives");
|
||||
(stem, device)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -53,7 +53,7 @@ fn devices() -> Vec<(String, Device)> {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
(
|
||||
stem,
|
||||
Device::new(desc, DevicePolicy::default()).expect("device"),
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device"),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -57,7 +57,7 @@ fn devices() -> Vec<(String, Device)> {
|
||||
.into_owned();
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let dev = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
(stem, dev)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -84,7 +84,7 @@ fn committed_devices() -> Vec<(String, Device)> {
|
||||
.unwrap_or_default();
|
||||
let text = std::fs::read_to_string(&path).expect("read");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
out.push((stem, device));
|
||||
}
|
||||
out.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
@@ -106,7 +106,7 @@ fn committed_devices() -> Vec<(String, Device)> {
|
||||
.unwrap_or_default();
|
||||
let text = std::fs::read_to_string(&path).expect("read");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
out.push((stem, device));
|
||||
}
|
||||
out.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// `store_const` compiled on `dev`, with its compute pipeline.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! `Device::new`: the only producer of a `DeviceProfile`.
|
||||
//! `Device::from_queries`: the only producer of a `DeviceProfile`.
|
||||
//!
|
||||
//! The profile is a pure function of the description and the policy. Memory's A/F split is the
|
||||
//! The profile is a pure function of the description's Vulkan queries and the policy: no driver or
|
||||
//! GPU identity decides anything. Memory's A/F split is the
|
||||
//! only field that selects a pointer model; every other field selects leaf encodings or feeds the
|
||||
//! requirement check.
|
||||
|
||||
@@ -8,15 +9,15 @@ use std::collections::BTreeSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::device::description::{
|
||||
AllocationLimits, DeviceDescription, GeneratedCommandsProperties, APPLE_VENDOR_ID,
|
||||
AllocationLimits, DeviceDescription, GeneratedCommandsProperties,
|
||||
};
|
||||
use crate::device::function_storage;
|
||||
use crate::device::metal::MetalDeviceProperties;
|
||||
use crate::device::policy::{ContainmentPolicy, DevicePolicy};
|
||||
use crate::device::profile::{
|
||||
BufferAccess, Containment, CubeGradientRoute, CubeGradients, DescriptorCaps, DeviceProfile,
|
||||
DriverWorkaround, EnabledCaps, FloatFunctions, FormatTable, FragmentCaps, GuestIsolation,
|
||||
HandleDomain, ImageCaps, Independence, LeafCaps, NanEncoding, PointerDomain, ProfileFacts,
|
||||
DriverWorkaround, EnabledCaps, FloatFunctions, FormatTable, FragmentCaps, FunctionStorage,
|
||||
GuestIsolation, HandleDomain, ImageCaps, Independence, LeafCaps, NanEncoding, PointerDomain,
|
||||
ProfileFields, Robustness,
|
||||
};
|
||||
use crate::device::requirements::{
|
||||
@@ -24,7 +25,7 @@ use crate::device::requirements::{
|
||||
VkFeature, VkProperty,
|
||||
};
|
||||
use crate::device::subgroup::{OpBits, StageSubgroup, SubgroupModel, SubgroupSizes};
|
||||
use crate::error::{Capability, DescriptorError, DriverDeviation, Error, Feature, Unsupported};
|
||||
use crate::error::{Capability, DescriptorError, Error, Feature, Unsupported};
|
||||
use crate::pipeline::sym::Stage;
|
||||
use crate::vk;
|
||||
|
||||
@@ -53,7 +54,11 @@ struct DeviceInner {
|
||||
}
|
||||
|
||||
impl Device {
|
||||
/// Derives the device profile from what the consumer enabled and its policy.
|
||||
/// The device its Vulkan queries decide, under `policy`: the profile is a function of what
|
||||
/// the description states the device supports and the consumer enabled, and of the policy.
|
||||
/// The description need not come from a device: one read from a Khronos profiles JSON document
|
||||
/// ([`DeviceDescription::from_khronos_json`]) or built field by field
|
||||
/// ([`DeviceDescription::new`]) makes a device with no `VkDevice` behind it.
|
||||
///
|
||||
/// Refuses a device below Vulkan 1.2 (`Unsupported{VulkanVersion}`), a description that lists
|
||||
/// a feature neither its version nor its listed extensions expose or a feature without the
|
||||
@@ -63,24 +68,8 @@ impl Device {
|
||||
/// (`InvalidDescriptor`), and the identity domains on a device without `bufferDeviceAddress`
|
||||
/// and `shaderInt64` (`Unsupported{IdentityDomains}`).
|
||||
///
|
||||
/// It reads the description's identity: the driver facts keyed on the driver and its GPU
|
||||
/// (`driver_facts`), the workarounds keyed on them, the Function storage measured on a GPU,
|
||||
/// and the workarounds the consumer measured (`DeviceDescription::measured`), for
|
||||
/// `metal2vulkan-runtime` until the cutover deletes them and `new` becomes
|
||||
/// [`Device::from_queries`].
|
||||
pub fn new(desc: DeviceDescription, policy: DevicePolicy) -> Result<Device, Error> {
|
||||
// The driver's measured deviations on its GPU, never its name.
|
||||
let deviations = super::driver_facts::deviations(&desc);
|
||||
Device::with_deviations(desc, policy, deviations)
|
||||
}
|
||||
|
||||
/// The device its Vulkan queries decide, under `policy`: the constructor `metal2vulkan-rt`
|
||||
/// uses. Refuses what [`Device::new`] refuses.
|
||||
///
|
||||
/// No identity decides anything: the description's `driver_id`, `driver_version`,
|
||||
/// `vendor_id`, `device_id` and `device_name`, and its `measured` workarounds, are not read.
|
||||
/// So no driver fact, deviation, workaround or measured value keyed on a driver or a GPU
|
||||
/// applies, and every note one of them could turn off stays on: the rasterizer splits clipped
|
||||
/// `vendor_id`, `device_id` and `device_name` are not read. The rasterizer splits clipped
|
||||
/// coverage and the tessellator orders triangles as the device does
|
||||
/// (`DriverWorkaround::ClippedCoverageNotMetals`, `DriverWorkaround::TessellatorNotMetals`),
|
||||
/// `InterpolateAtOffset` reads from the pixel's center as GLSL.std.450 states, and a thread's
|
||||
@@ -88,53 +77,6 @@ impl Device {
|
||||
/// on every device, whatever its type. Every stage output is 32-bit: a `half` color output
|
||||
/// reaches the device widened to `float`, whatever `storageInputOutput16` says.
|
||||
pub fn from_queries(desc: DeviceDescription, policy: DevicePolicy) -> Result<Device, Error> {
|
||||
Device::derived(desc.without_identity(), policy, |desc, policy| {
|
||||
let fields = ProfileFields {
|
||||
ycbcr_in_place: true,
|
||||
..derive_fields(desc, policy, &BTreeSet::new())
|
||||
};
|
||||
(fields, ProfileFacts::EVERY)
|
||||
})
|
||||
}
|
||||
|
||||
/// [`Device::new`] with `deviation` taken or not, and the driver's other deviations as
|
||||
/// measured: a test's way to take one route alone, which no driver in the table gives.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_deviation(
|
||||
desc: DeviceDescription,
|
||||
policy: DevicePolicy,
|
||||
deviation: DriverDeviation,
|
||||
taken: bool,
|
||||
) -> Result<Device, Error> {
|
||||
let mut deviations = super::driver_facts::deviations(&desc);
|
||||
match taken {
|
||||
true => {
|
||||
deviations.insert(deviation);
|
||||
}
|
||||
false => {
|
||||
deviations.remove(&deviation);
|
||||
}
|
||||
}
|
||||
Device::with_deviations(desc, policy, deviations)
|
||||
}
|
||||
|
||||
fn with_deviations(
|
||||
desc: DeviceDescription,
|
||||
policy: DevicePolicy,
|
||||
deviations: BTreeSet<DriverDeviation>,
|
||||
) -> Result<Device, Error> {
|
||||
Device::derived(desc, policy, |desc, policy| {
|
||||
(derive_fields(desc, policy, &deviations), ProfileFacts::ROWS)
|
||||
})
|
||||
}
|
||||
|
||||
/// The device of `desc` under `policy`, its profile's fields and facts as `fields` derives
|
||||
/// them, once the description and the policy pass their checks.
|
||||
fn derived(
|
||||
desc: DeviceDescription,
|
||||
policy: DevicePolicy,
|
||||
fields: impl FnOnce(&DeviceDescription, &DevicePolicy) -> (ProfileFields, ProfileFacts),
|
||||
) -> Result<Device, Error> {
|
||||
if desc.api_version < ApiVersion::V1_2 {
|
||||
return Err(Unsupported::needs(
|
||||
Feature::VulkanVersion,
|
||||
@@ -153,8 +95,7 @@ impl Device {
|
||||
));
|
||||
}
|
||||
identity_domains(&desc, &policy)?;
|
||||
let (fields, facts) = fields(&desc, &policy);
|
||||
let profile = DeviceProfile::of(fields, facts);
|
||||
let profile = DeviceProfile::of(derive_fields(&desc, &policy));
|
||||
let metal = MetalDeviceProperties::derive(&profile, &desc.allocation);
|
||||
Ok(Device(Arc::new(DeviceInner {
|
||||
fingerprint: profile.fingerprint(),
|
||||
@@ -229,11 +170,7 @@ fn identity_domains(desc: &DeviceDescription, policy: &DevicePolicy) -> Result<(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn derive_fields(
|
||||
desc: &DeviceDescription,
|
||||
policy: &DevicePolicy,
|
||||
deviations: &BTreeSet<DriverDeviation>,
|
||||
) -> ProfileFields {
|
||||
fn derive_fields(desc: &DeviceDescription, policy: &DevicePolicy) -> ProfileFields {
|
||||
let has = |f: VkFeature| desc.has(f);
|
||||
let ext = |e: VkExtension| desc.extensions.contains(&e);
|
||||
let api = desc.api_version;
|
||||
@@ -373,16 +310,14 @@ fn derive_fields(
|
||||
};
|
||||
|
||||
let (vertex_formats, storage_formats, image_formats) = format_tables(desc);
|
||||
let deviates = |d: DriverDeviation| deviations.contains(&d);
|
||||
ProfileFields {
|
||||
buffer_access,
|
||||
pointer_domain: policy.pointer_domain,
|
||||
handle_domain: policy.handle_domain,
|
||||
containment,
|
||||
isolation: policy.isolation,
|
||||
half_chains: policy.half_chains,
|
||||
leaf,
|
||||
subgroup: subgroup_model(desc, deviates(DriverDeviation::MetalVertexSimdgroups)),
|
||||
subgroup: subgroup_model(desc),
|
||||
images,
|
||||
descriptors,
|
||||
fragment,
|
||||
@@ -393,138 +328,39 @@ fn derive_fields(
|
||||
vertex_formats,
|
||||
storage_formats,
|
||||
image_formats,
|
||||
workarounds: workarounds(desc),
|
||||
// Every rasterizer but Apple's hands a clipped primitive's fragments their coverage by the
|
||||
// whole primitive (or by its own pieces), never by Apple's pieces; and every tessellator
|
||||
// but Apple's orders a patch's triangles its own way. No query tells Apple's apart.
|
||||
workarounds: vec![
|
||||
DriverWorkaround::ClippedCoverageNotMetals,
|
||||
DriverWorkaround::TessellatorNotMetals,
|
||||
],
|
||||
api_version: api,
|
||||
// The feature, which both description readers list from 1.3 (core without a member),
|
||||
// so the extended dynamic states a pipeline makes are exactly what it requires.
|
||||
dynamic_vertex_stride: has(VkFeature::ExtendedDynamicState),
|
||||
enabled: enabled_caps(desc, deviations),
|
||||
// The measured deviation; unmeasured, the device's own functions.
|
||||
float_functions: if deviates(DriverDeviation::MetalFloatFunctions) {
|
||||
FloatFunctions::Metal
|
||||
} else {
|
||||
FloatFunctions::Native
|
||||
},
|
||||
// The measured deviation; unmeasured, the device's NaN, noted.
|
||||
nan_encoding: if deviates(DriverDeviation::MetalCanonicalNans) {
|
||||
NanEncoding::MetalCanonical
|
||||
} else {
|
||||
NanEncoding::Native
|
||||
},
|
||||
// The planes of a two-plane YCbCr texture read in place where the GPU reads host memory
|
||||
// with no bus between: an integrated GPU's, a CPU device's.
|
||||
ycbcr_in_place: matches!(
|
||||
desc.device_type,
|
||||
Some(vk::PhysicalDeviceType::INTEGRATED_GPU | vk::PhysicalDeviceType::CPU)
|
||||
),
|
||||
ycbcr_in_place_reads: policy.ycbcr_in_place_reads,
|
||||
// The device's measured value, keyed on its identity as the workarounds are, or the floor.
|
||||
function_storage: function_storage::of(desc),
|
||||
// The measured deviations, one per pipeline kind; unmeasured, Vulkan's rule, the device's
|
||||
// own reading of the gradients handed to it.
|
||||
cube_gradients: {
|
||||
let route = |measured: &[(DriverDeviation, CubeGradientRoute)]| {
|
||||
measured
|
||||
.iter()
|
||||
.find(|(deviation, _)| deviates(*deviation))
|
||||
.map_or(CubeGradientRoute::Vulkan, |&(_, route)| route)
|
||||
};
|
||||
CubeGradients {
|
||||
graphics: route(&[(
|
||||
DriverDeviation::GraphicsCubeGradientTangents,
|
||||
CubeGradientRoute::AppleProjected,
|
||||
)]),
|
||||
compute: route(&[(DriverDeviation::CubeGradientRoute, CubeGradientRoute::Metal)]),
|
||||
}
|
||||
enabled: enabled_caps(desc),
|
||||
float_functions: FloatFunctions::Native,
|
||||
nan_encoding: NanEncoding::Native,
|
||||
// The planes of a two-plane YCbCr texture read in place on every device.
|
||||
ycbcr_in_place: true,
|
||||
// The floor: no Vulkan query states how much a thread holds.
|
||||
function_storage: FunctionStorage::Assumed(function_storage::FLOOR),
|
||||
// Vulkan's rule, the device's own reading of the gradients handed to it.
|
||||
cube_gradients: CubeGradients {
|
||||
graphics: CubeGradientRoute::Vulkan,
|
||||
compute: CubeGradientRoute::Vulkan,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// The driver workarounds of the driver `desc` names (`driver_id`), on its GPU (`vendor_id`, or its
|
||||
/// generation's `device_id`s) where the defect is the GPU's, those of the measured table
|
||||
/// (`driver_facts::DEFECTS`), and those the consumer measured on the device itself
|
||||
/// ([`DeviceDescription::measured`]), in order.
|
||||
fn workarounds(desc: &DeviceDescription) -> Vec<DriverWorkaround> {
|
||||
let mut found = by_identity(desc);
|
||||
// Every rasterizer but Apple's hands a clipped primitive's fragments their coverage by the
|
||||
// whole primitive (or, lavapipe, by its own pieces), never by Apple's pieces; and every
|
||||
// tessellator but Apple's orders a patch's triangles its own way.
|
||||
if !(desc.driver_id == Some(vk::DriverId::MOLTENVK) && desc.vendor_id == APPLE_VENDOR_ID) {
|
||||
found.push(DriverWorkaround::ClippedCoverageNotMetals);
|
||||
found.push(DriverWorkaround::TessellatorNotMetals);
|
||||
}
|
||||
found.extend(super::driver_facts::defects(desc));
|
||||
found.extend(desc.measured.iter().copied());
|
||||
found.sort();
|
||||
found.dedup();
|
||||
found
|
||||
}
|
||||
|
||||
/// The workarounds of [`workarounds`] keyed on the driver's identity alone.
|
||||
fn by_identity(desc: &DeviceDescription) -> Vec<DriverWorkaround> {
|
||||
match desc.driver_id {
|
||||
Some(vk::DriverId::GOOGLE_SWIFTSHADER) => vec![DriverWorkaround::BufferAtomicsUncontained],
|
||||
Some(vk::DriverId::MOLTENVK) if desc.vendor_id == APPLE_VENDOR_ID => vec![
|
||||
DriverWorkaround::EarlyTestsDropMultisampledImageWrites,
|
||||
DriverWorkaround::DiscardDropsSimdgroupStores,
|
||||
],
|
||||
Some(vk::DriverId::MESA_LLVMPIPE) => {
|
||||
vec![DriverWorkaround::ClippedTrianglesSplitPixelFragments]
|
||||
}
|
||||
// A `half` round trip folded on every GPU it drives, and on the 3090's generation a
|
||||
// narrow integer's mask dropped.
|
||||
Some(vk::DriverId::NVIDIA_PROPRIETARY) => {
|
||||
let mut found = vec![DriverWorkaround::HalfConversionPairFolded];
|
||||
if super::NVIDIA_AMPERE_GA10X.contains(&desc.device_id) {
|
||||
found.push(DriverWorkaround::NarrowMaskAfterSignedClamp);
|
||||
}
|
||||
found
|
||||
}
|
||||
// An `f32` operation fused into the conversion of its result to `half`, on every GPU it
|
||||
// drives.
|
||||
Some(vk::DriverId::MESA_RADV) => vec![DriverWorkaround::HalfConversionFusedWithArithmetic],
|
||||
// A register allocator that faults compiling a module past a word bound, products of one
|
||||
// value by zeros of opposite sign kept as one, a stage past 2^20 objects of its
|
||||
// serialized form corrupted, and a compiler whose memory outgrows the stage, on every GPU
|
||||
// it drives.
|
||||
Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA) => vec![
|
||||
DriverWorkaround::RegisterAllocatorOverflowsLargeModules,
|
||||
DriverWorkaround::OppositeZeroProductsMerged,
|
||||
DriverWorkaround::SerializedStageWrapsLargeModules,
|
||||
DriverWorkaround::CompilerMemoryGrowsWithStageSize,
|
||||
],
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The operation classes measured exact in a vertex function on a driver that takes
|
||||
/// `DriverDeviation::MetalVertexSimdgroups`: with the vertex stage forced into the profile,
|
||||
/// MoltenVK 1.4.1 ran `rvc_simd_vertex`'s `simd_sum`, `simd_shuffle`, `simd_shuffle_xor` and
|
||||
/// `simd_ballot` as Metal does (200 of 200 words on the M4 and the M3 Max), and with the votes
|
||||
/// added, `gsm2_vertex_votes_shifts`' `simd_all` and `simd_any` over full and partial simdgroups
|
||||
/// (the four cases matching in both legs on both chips).
|
||||
///
|
||||
/// The clustered class stays out: with it added, MoltenVK 1.4.1 refused `gsm2_quad_ops`' vertex
|
||||
/// functions, whose quad reductions then lowered to it ("Subgroup builtins are not available in
|
||||
/// this type of function", SPIRV-Cross's MSL conversion). They now take the ballot
|
||||
/// and shuffles, so no quad or simdgroup operation of a vertex function on the `Direct` tier needs
|
||||
/// it.
|
||||
const MEASURED_VERTEX_OPS: OpBits = OpBits(
|
||||
OpBits::BASIC.0 | OpBits::VOTE.0 | OpBits::ARITHMETIC.0 | OpBits::BALLOT.0 | OpBits::SHUFFLE.0,
|
||||
);
|
||||
|
||||
/// The subgroup model.
|
||||
///
|
||||
/// A stage is `pinnable` when subgroup size control is enabled and the stage is in
|
||||
/// `requiredSubgroupSizeStages`; its size range is then `[minSubgroupSize, maxSubgroupSize]`.
|
||||
/// Otherwise SPIR-V 1.5 modules run with the API-constant `subgroupSize`, which is the only size
|
||||
/// the stage exposes. `full_subgroups` is compute-only (`computeFullSubgroups`).
|
||||
///
|
||||
/// Where the driver is measured to run a vertex function's subgroup operations as Metal does
|
||||
/// though `subgroupSupportedStages` leaves the vertex stage out (`vertex_simdgroups`,
|
||||
/// `DriverDeviation::MetalVertexSimdgroups`), the vertex stage has subgroups of the device's
|
||||
/// operations that were measured exact there ([`MEASURED_VERTEX_OPS`]).
|
||||
fn subgroup_model(desc: &DeviceDescription, vertex_simdgroups: bool) -> SubgroupModel {
|
||||
fn subgroup_model(desc: &DeviceDescription) -> SubgroupModel {
|
||||
let sg = &desc.subgroup;
|
||||
let control = desc.has(VkFeature::SubgroupSizeControl);
|
||||
let ops = OpBits(sg.supported_operations.as_raw() & OpBits(0xff).0);
|
||||
@@ -534,15 +370,9 @@ fn subgroup_model(desc: &DeviceDescription, vertex_simdgroups: bool) -> Subgroup
|
||||
&& sg.required_size_stages.contains(bit)
|
||||
&& sg.min_size > 0
|
||||
&& sg.max_size >= sg.min_size;
|
||||
let advertised = sg.supported_stages.contains(bit);
|
||||
let measured = !advertised && vertex_simdgroups && stage == Stage::Vertex;
|
||||
StageSubgroup {
|
||||
supported: advertised || measured,
|
||||
ops: if measured {
|
||||
OpBits(ops.0 & MEASURED_VERTEX_OPS.0)
|
||||
} else {
|
||||
ops
|
||||
},
|
||||
supported: sg.supported_stages.contains(bit),
|
||||
ops,
|
||||
api_size: sg.size,
|
||||
sizes: if pinnable {
|
||||
SubgroupSizes {
|
||||
@@ -731,7 +561,7 @@ pub(crate) fn usage_class(usage: FormatUsage) -> UsageClass {
|
||||
}
|
||||
}
|
||||
|
||||
fn enabled_caps(desc: &DeviceDescription, deviations: &BTreeSet<DriverDeviation>) -> EnabledCaps {
|
||||
fn enabled_caps(desc: &DeviceDescription) -> EnabledCaps {
|
||||
let sg = &desc.subgroup;
|
||||
let mut properties = BTreeSet::new();
|
||||
for (stage, bit) in STAGE_BITS {
|
||||
@@ -804,108 +634,10 @@ fn enabled_caps(desc: &DeviceDescription, deviations: &BTreeSet<DriverDeviation>
|
||||
if desc.rgba4_opaque_black_swizzled {
|
||||
properties.insert(VkProperty::Rgba4OpaqueBlackSwizzled);
|
||||
}
|
||||
// Where `InterpolateAtOffset` reads, and the measured deviations.
|
||||
if desc.interpolates_at_offset_centered() {
|
||||
properties.insert(VkProperty::InterpolateAtOffsetCentered);
|
||||
} else {
|
||||
properties.insert(VkProperty::InterpolateAtOffsetFromSevenSixteenths);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::SimdgroupLockstep) {
|
||||
properties.insert(VkProperty::SimdgroupLockstep);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalSampler) {
|
||||
properties.insert(VkProperty::MetalSampler);
|
||||
} else {
|
||||
// Native device sampling, where the device's sampler is not Metal's.
|
||||
properties.insert(VkProperty::DeviceSampling);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalColorWrites) {
|
||||
properties.insert(VkProperty::MetalColorWrites);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalFloatColorNans) {
|
||||
properties.insert(VkProperty::MetalFloatColorNans);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalHalfFma) {
|
||||
properties.insert(VkProperty::MetalHalfFma);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalFloatDenormals) {
|
||||
properties.insert(VkProperty::MetalFloatDenormals);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalCenterVaryings) {
|
||||
properties.insert(VkProperty::MetalCenterVaryings);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalSmallFloatColorWrites) {
|
||||
properties.insert(VkProperty::MetalSmallFloatColorWrites);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalNorm16ColorWrites) {
|
||||
properties.insert(VkProperty::MetalNorm16ColorWrites);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalMinMax) {
|
||||
properties.insert(VkProperty::MetalMinMax);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalHalfArithmetic) {
|
||||
properties.insert(VkProperty::MetalHalfArithmetic);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalHalfStorageWrites) {
|
||||
properties.insert(VkProperty::MetalHalfStorageWrites);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalHalfStorageNans) {
|
||||
properties.insert(VkProperty::MetalHalfStorageNans);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalFragmentSimdgroups) {
|
||||
properties.insert(VkProperty::MetalFragmentSimdgroups);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalVertexSimdgroups) {
|
||||
properties.insert(VkProperty::MetalVertexSimdgroups);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::CenterFragCoordDepth) {
|
||||
properties.insert(VkProperty::CenterFragCoordDepth);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::SampleFragCoordDepth) {
|
||||
properties.insert(VkProperty::SampleFragCoordDepth);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalHalfTexelWrites) {
|
||||
properties.insert(VkProperty::MetalHalfTexelWrites);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalNormStorageWrites) {
|
||||
properties.insert(VkProperty::MetalNormStorageWrites);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalDepth16Stores) {
|
||||
properties.insert(VkProperty::MetalDepth16Stores);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalDepth16BiasedStores) {
|
||||
properties.insert(VkProperty::MetalDepth16BiasedStores);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalInterpolation) {
|
||||
properties.insert(VkProperty::MetalInterpolation);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalFirstVertexIndices) {
|
||||
properties.insert(VkProperty::MetalFirstVertexIndices);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalFullQuads) {
|
||||
properties.insert(VkProperty::MetalFullQuads);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalNormalizedVertexFetch) {
|
||||
properties.insert(VkProperty::MetalNormalizedVertexFetch);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalAlphaCoverage) {
|
||||
properties.insert(VkProperty::MetalAlphaCoverage);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalNanMoves) {
|
||||
properties.insert(VkProperty::MetalNanMoves);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalPackConversions) {
|
||||
properties.insert(VkProperty::MetalPackConversions);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalHalfConversion) {
|
||||
properties.insert(VkProperty::MetalHalfConversion);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalSmallFloatNans) {
|
||||
properties.insert(VkProperty::MetalSmallFloatNans);
|
||||
}
|
||||
if deviations.contains(&DriverDeviation::MetalUnaryDenormals) {
|
||||
properties.insert(VkProperty::MetalUnaryDenormals);
|
||||
}
|
||||
// `InterpolateAtOffset` reads from the pixel's center, as GLSL.std.450 states, and the device
|
||||
// samples natively.
|
||||
properties.insert(VkProperty::InterpolateAtOffsetCentered);
|
||||
properties.insert(VkProperty::DeviceSampling);
|
||||
let l = &desc.limits;
|
||||
let sample_counts: [(vk::SampleCountFlags, fn(u32) -> VkProperty); 6] = [
|
||||
(
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use crate::device::profile::{DriverWorkaround, FloatControls, Limits};
|
||||
use crate::device::profile::{FloatControls, Limits};
|
||||
use crate::device::requirements::{ApiVersion, FormatUsage, VkExtension, VkFeature};
|
||||
use crate::vk;
|
||||
|
||||
@@ -82,15 +82,6 @@ pub struct DeviceDescription {
|
||||
/// `maxBufferLength` and the runtime's heap sizes read them from the `Device`.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub allocation: AllocationLimits,
|
||||
/// The driver workarounds the consumer measured on this device itself, which the profile
|
||||
/// takes beside those its driver's identity names: the cost facts no identity decides,
|
||||
/// [`DriverWorkaround::UniformBufferPerLaneReadsSerialize`] and
|
||||
/// [`DriverWorkaround::ExternalUniformReadsSkipACache`], which the runtime's view check
|
||||
/// measures once per driver and release. A profile field (its workarounds), so its fingerprint
|
||||
/// and every cache key follow it. Empty unless the consumer fills it (`new`, `query` and
|
||||
/// `from_khronos_json` leave it so).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub measured: BTreeSet<DriverWorkaround>,
|
||||
}
|
||||
|
||||
/// A device's allocation sizes, [`DeviceDescription::allocation`]: device facts that size
|
||||
@@ -168,12 +159,9 @@ impl GeneratedCommandsProperties {
|
||||
}
|
||||
}
|
||||
|
||||
/// `VkPhysicalDeviceProperties::vendorID` of Apple's GPUs.
|
||||
pub(crate) const APPLE_VENDOR_ID: u32 = 0x106B;
|
||||
|
||||
impl DeviceDescription {
|
||||
/// A description of a device of `api_version` that enables nothing and reports zero limits.
|
||||
/// Callers fill the public fields; `Device::new` validates the result.
|
||||
/// Callers fill the public fields; `Device::from_queries` validates the result.
|
||||
pub fn new(api_version: ApiVersion) -> DeviceDescription {
|
||||
DeviceDescription {
|
||||
api_version,
|
||||
@@ -195,7 +183,6 @@ impl DeviceDescription {
|
||||
khr_format_feature_flags2: false,
|
||||
generated_commands: None,
|
||||
allocation: AllocationLimits::default(),
|
||||
measured: BTreeSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,34 +204,6 @@ impl DeviceDescription {
|
||||
pub fn has(&self, feature: VkFeature) -> bool {
|
||||
self.features.contains(&feature)
|
||||
}
|
||||
|
||||
/// This description without what names its driver and GPU rather than answers a Vulkan
|
||||
/// query: no `driver_id`, `driver_version`, `vendor_id`, `device_id` or `device_name`, and no
|
||||
/// `measured` workarounds ([`Device::from_queries`](crate::device::Device::from_queries)).
|
||||
pub(crate) fn without_identity(self) -> DeviceDescription {
|
||||
DeviceDescription {
|
||||
driver_id: None,
|
||||
driver_version: 0,
|
||||
vendor_id: 0,
|
||||
device_id: 0,
|
||||
device_name: String::new(),
|
||||
measured: BTreeSet::new(),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether `GLSL.std.450 InterpolateAtOffset` reads at the pixel center plus its offset, as
|
||||
/// GLSL.std.450 states ("An offset of (0, 0) identifies the center of the pixel"): every
|
||||
/// driver but MoltenVK, whose SPIRV-Cross converts the instruction to Metal's
|
||||
/// `interpolate_at_offset(offset + 0.4375)`, which Metal measures from the pixel's upper-left
|
||||
/// corner, so offset 0 reads a sixteenth of a pixel from the center. That conversion is read in
|
||||
/// SPIRV-Cross's source and Metal's reading measured on the Apple M3 Max; no release of
|
||||
/// MoltenVK is measured to read at the center, so none takes it: a device without it has
|
||||
/// `VkProperty::InterpolateAtOffsetFromSevenSixteenths`, where translation moves a Metal
|
||||
/// offset by 7/16 and reads nothing else through the instruction.
|
||||
pub(crate) fn interpolates_at_offset_centered(&self) -> bool {
|
||||
self.driver_id != Some(vk::DriverId::MOLTENVK)
|
||||
}
|
||||
}
|
||||
|
||||
/// Subgroup properties (`VkPhysicalDeviceVulkan11Properties` subgroup members and
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,156 +1,38 @@
|
||||
//! The Function storage a thread holds correctly on each device:
|
||||
//! [`ProfileFields::function_storage`].
|
||||
//! The Function storage a thread holds correctly: [`ProfileFields::function_storage`].
|
||||
//!
|
||||
//! A thread's private memory, its `alloca`s (a recursion's call stack among them) and the constants
|
||||
//! it holds as `Private` variables, is storage a driver backs with scratch memory. No Vulkan
|
||||
//! property states how much of it a thread holds, and past it a driver can answer wrongly or hang
|
||||
//! with no error: the Radeon 780M and the RX 7900 XTX under RADV over 4096 threads at 128 KiB a
|
||||
//! thread, the Iris Xe under ANV at 48 KiB, the RTX 5080 at 48 KiB and the RTX 3090 at 192 KiB
|
||||
//! (both Xid 109). So the amount is measured, per device, by `validation`'s
|
||||
//! `runtime_lane::private_memory` (a private array of that many bytes a thread, every 64-byte line
|
||||
//! written and read back in an order no two threads share, over 1, 64, 4096 and 262144 threads,
|
||||
//! each size cut at 60 s). A device's value is its largest size answered correctly over every
|
||||
//! thread count below its first size that failed; a size cut at 60 s is not measured, never taken
|
||||
//! as correct. The table keys each value on the device's identity, its driver, vendor, and device
|
||||
//! ID, as the driver workarounds are keyed ([`DriverWorkaround`]), and on nothing else; a GPU that
|
||||
//! reports more than one device ID is read by the one it was measured under
|
||||
//! ([`DeviceDescription::canonical_device_id`]).
|
||||
//! with no error: measured, the Radeon 780M and the RX 7900 XTX under RADV over 4096 threads at
|
||||
//! 128 KiB a thread, the Iris Xe under ANV at 48 KiB, the RTX 5080 at 48 KiB and the RTX 3090 at
|
||||
//! 192 KiB (both Xid 109).
|
||||
//!
|
||||
//! A device the table does not name holds [`FLOOR`], 16 KiB a thread: half the least any
|
||||
//! measured device held (32 KiB), and below every size any of them failed at (48 KiB and up).
|
||||
//! Private memory within it is taken as held on every device, and records nothing. Past it, on
|
||||
//! such a device, a vertex or fragment function runs up to [`METAL`], 192 KiB a thread, the most
|
||||
//! a Metal device was measured to hold, and records `PrecisionNote::FunctionStorageAssumed`: past
|
||||
//! the floor, unmeasured, it rests on no measurement, and a driver that holds less can answer
|
||||
//! wrongly or hang the GPU, as the RTX 5080 at 48 KiB and the RTX 3090 at 192 KiB hung when probed.
|
||||
//! A kernel, an object or a mesh function past the floor there is refused, as is any stage past a
|
||||
//! measured device's value and a vertex or fragment function past [`METAL`]: typed
|
||||
//! (`Unsupported{PrivateMemory}`, or `Unsupported{Recursion}` for a stage with a call stack,
|
||||
//! needing `VkLimit::FunctionStorageBytesPerThread`).
|
||||
//! Every device holds [`FLOOR`], 16 KiB a thread: half the least any measured device held
|
||||
//! (32 KiB), and below every size any of them failed at (48 KiB and up). Private memory within it
|
||||
//! is taken as held on every device, and records nothing. Past it a vertex or fragment function
|
||||
//! runs up to [`METAL`], 192 KiB a thread, the most a Metal device was measured to hold, and
|
||||
//! records `PrecisionNote::FunctionStorageAssumed`: past the floor it rests on no measurement, and
|
||||
//! a driver that holds less can answer wrongly or hang the GPU, as the RTX 5080 at 48 KiB and the
|
||||
//! RTX 3090 at 192 KiB hung when probed. A kernel, an object or a mesh function past the floor is
|
||||
//! refused, as is a vertex or fragment function past [`METAL`]: typed (`Unsupported{PrivateMemory}`,
|
||||
//! or `Unsupported{Recursion}` for a stage with a call stack, needing
|
||||
//! `VkLimit::FunctionStorageBytesPerThread`).
|
||||
//!
|
||||
//! [`ProfileFields::function_storage`]: crate::device::profile::ProfileFields::function_storage
|
||||
//! [`DriverWorkaround`]: crate::device::profile::DriverWorkaround
|
||||
|
||||
use crate::device::description::{DeviceDescription, APPLE_VENDOR_ID};
|
||||
use crate::device::profile::FunctionStorage;
|
||||
use crate::pipeline::sym::Stage;
|
||||
use crate::vk;
|
||||
|
||||
/// One measured device: its identity, and the most Function storage a thread held correctly.
|
||||
struct Measured {
|
||||
driver: vk::DriverId,
|
||||
vendor: u32,
|
||||
device: u32,
|
||||
bytes: u64,
|
||||
}
|
||||
|
||||
const KIB: u64 = 1024;
|
||||
|
||||
/// The devices measured, each with the build and the evidence it was measured on.
|
||||
const MEASURED: [Measured; 9] = [
|
||||
// AMD Radeon 780M (RADV PHOENIX), RADV Mesa 26.2.4-arch3.1: 64 and 96 KiB correct over 262144
|
||||
// threads; 128 KiB wrong over 4096. RADV Mesa 26.0.8-1ubuntu0.3 (homelab-um780): 4 to 96 KiB
|
||||
// correct over 262144 threads. Hawk Point's 780M (0x1900) is the same GPU, read as 0x15bf.
|
||||
Measured {
|
||||
driver: vk::DriverId::MESA_RADV,
|
||||
vendor: 0x1002,
|
||||
device: 0x15bf,
|
||||
bytes: 96 * KIB,
|
||||
},
|
||||
// AMD Radeon RX 7900 XTX (RADV NAVI31), RADV Mesa 26.0.8-1ubuntu0.3 (homelab-um780): 4 to 96
|
||||
// KiB correct over 262144 threads; 128 KiB wrong over 4096 (53 to 55 of the 64 threads
|
||||
// checked, in three runs).
|
||||
Measured {
|
||||
driver: vk::DriverId::MESA_RADV,
|
||||
vendor: 0x1002,
|
||||
device: 0x744c,
|
||||
bytes: 96 * KIB,
|
||||
},
|
||||
// Intel Iris Xe Graphics (RPL-P), ANV Mesa 26.2.4-arch3.1: 4 to 32 KiB correct over 262144
|
||||
// threads; 48 KiB wrong over 4096. The Intel venue's two devices derive one translation key, so
|
||||
// each takes the lower of the two values.
|
||||
Measured {
|
||||
driver: vk::DriverId::INTEL_OPEN_SOURCE_MESA,
|
||||
vendor: 0x8086,
|
||||
device: 0xa7a0,
|
||||
bytes: 32 * KIB,
|
||||
},
|
||||
// Intel Graphics (RPL-S, a UHD 770), ANV Mesa 26.2.4-arch3.1: 4 to 256 KiB correct over 262144
|
||||
// threads; 512 KiB refused at its first dispatch (VK_ERROR_UNKNOWN). It takes the RPL-P's lower
|
||||
// 32 KiB, its venue's.
|
||||
Measured {
|
||||
driver: vk::DriverId::INTEL_OPEN_SOURCE_MESA,
|
||||
vendor: 0x8086,
|
||||
device: 0xa780,
|
||||
bytes: 32 * KIB,
|
||||
},
|
||||
// NVIDIA GeForce RTX 5080 Laptop GPU, NVIDIA 615.71.09: 4 to 32 KiB correct over 262144
|
||||
// threads; 48 KiB hung over 4096 threads (no completion within 50 s, Xid 109 CTX SWITCH
|
||||
// TIMEOUT).
|
||||
Measured {
|
||||
driver: vk::DriverId::NVIDIA_PROPRIETARY,
|
||||
vendor: 0x10de,
|
||||
device: 0x2c19,
|
||||
bytes: 32 * KIB,
|
||||
},
|
||||
// NVIDIA GeForce RTX 3090, NVIDIA 615.71.09 (homelab-gem10): 4 to 128 KiB correct over 262144
|
||||
// threads; 192 KiB hung over 4096 threads (no completion within 50 s, Xid 109 CTX SWITCH
|
||||
// TIMEOUT).
|
||||
Measured {
|
||||
driver: vk::DriverId::NVIDIA_PROPRIETARY,
|
||||
vendor: 0x10de,
|
||||
device: 0x2204,
|
||||
bytes: 128 * KIB,
|
||||
},
|
||||
// Apple M4, MoltenVK 1.4.1 under macOS 27.0.1: 64 to 192 KiB correct over 262144 threads; 256
|
||||
// KiB refused at pipeline creation (VK_ERROR_INITIALIZATION_FAILED).
|
||||
Measured {
|
||||
driver: vk::DriverId::MOLTENVK,
|
||||
vendor: APPLE_VENDOR_ID,
|
||||
device: 0x1b00_0209,
|
||||
bytes: 192 * KIB,
|
||||
},
|
||||
// Apple M3 Max, MoltenVK 1.4.1 under macOS 26.7: 4 to 192 KiB correct
|
||||
// over 262144 threads; 256 KiB refused at pipeline creation (VK_ERROR_INITIALIZATION_FAILED).
|
||||
Measured {
|
||||
driver: vk::DriverId::MOLTENVK,
|
||||
vendor: APPLE_VENDOR_ID,
|
||||
device: 0x1a06_0209,
|
||||
bytes: 192 * KIB,
|
||||
},
|
||||
// lavapipe, Mesa 26.0.8-1ubuntu0.3 (LLVM 21.1.8), whose identity (device ID 0) is one on every
|
||||
// CPU, so it takes the lower of its measured values. x86_64 on an i9-13900: 4 to 48 KiB correct
|
||||
// over 262144 threads; 64 KiB not measured (pipeline creation passed 35 s, the size cut at 60
|
||||
// s). arm64 in a Mac mini's Linux VM: 64 KiB correct over 262144 threads; 96 KiB not measured.
|
||||
Measured {
|
||||
driver: vk::DriverId::MESA_LLVMPIPE,
|
||||
vendor: 0x10005,
|
||||
device: 0,
|
||||
bytes: 48 * KIB,
|
||||
},
|
||||
];
|
||||
|
||||
/// The Function storage a device not measured holds, a thread: 16 KiB (the module docs).
|
||||
/// The Function storage every device holds, a thread: 16 KiB (the module docs).
|
||||
pub(crate) const FLOOR: u64 = 16 * KIB;
|
||||
|
||||
/// The most Function storage a thread was measured to hold on Metal: the Apple M3 Max and M4 hold
|
||||
/// 192 KiB and refuse 256 KiB at pipeline creation (their rows in [`MEASURED`]). A vertex or
|
||||
/// fragment function on a device not measured may keep this much, past [`FLOOR`] with
|
||||
/// `PrecisionNote::FunctionStorageAssumed` (the module docs).
|
||||
/// 192 KiB and refuse 256 KiB at pipeline creation. A vertex or fragment function may keep this
|
||||
/// much, past [`FLOOR`] with `PrecisionNote::FunctionStorageAssumed` (the module docs).
|
||||
pub(crate) const METAL: u64 = 192 * KIB;
|
||||
|
||||
/// The Function storage a thread of `desc`'s device holds correctly: the measured value of its
|
||||
/// identity, or [`FLOOR`] for a device not measured.
|
||||
pub(crate) fn of(desc: &DeviceDescription) -> FunctionStorage {
|
||||
let gpu = desc.canonical_device_id();
|
||||
MEASURED
|
||||
.iter()
|
||||
.find(|d| desc.driver_id == Some(d.driver) && desc.vendor_id == d.vendor && gpu == d.device)
|
||||
.map_or(FunctionStorage::Assumed(FLOOR), |d| {
|
||||
FunctionStorage::Measured(d.bytes)
|
||||
})
|
||||
}
|
||||
|
||||
/// The private memory a thread of a `stage` function may keep on a device whose Function storage
|
||||
/// is `storage`: the device's own value, but [`METAL`] for a vertex or fragment function on a
|
||||
/// device not measured, which past [`FLOOR`] rests on no measurement (the module docs).
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
//! GPU generations a measured defect keys on by `deviceID`, where the defect is a generation's
|
||||
//! and not every GPU its driver runs: the device layer's driver workarounds and the runtime's
|
||||
//! driver defects share them. And the GPUs that report more than one `deviceID`, which every table
|
||||
//! keyed on a measured GPU names by one of them ([`DeviceDescription::canonical_device_id`]).
|
||||
|
||||
use crate::device::DeviceDescription;
|
||||
|
||||
/// The `deviceID`s of NVIDIA's Ampere GA10x GPUs: every GA102, GA103, GA104, GA106 and GA107
|
||||
/// entry of pci.ids (version 2026.09.03) under vendor 0x10de, their high-definition audio
|
||||
/// functions left out (114 IDs). 0x2204, the RTX 3090, is the one measured.
|
||||
pub const NVIDIA_AMPERE_GA10X: &[u32] = &[
|
||||
0x2200, 0x2203, 0x2204, 0x2205, 0x2206, 0x2207, 0x2208, 0x220a, 0x220d, 0x2216, 0x222b, 0x222f,
|
||||
0x2230, 0x2231, 0x2232, 0x2233, 0x2235, 0x2236, 0x2237, 0x2238, 0x223f, 0x2414, 0x2420, 0x2438,
|
||||
0x2460, 0x2480, 0x2482, 0x2483, 0x2484, 0x2486, 0x2487, 0x2488, 0x2489, 0x248a, 0x248c, 0x248d,
|
||||
0x248e, 0x249c, 0x249d, 0x249f, 0x24a0, 0x24a4, 0x24ac, 0x24ad, 0x24af, 0x24b0, 0x24b1, 0x24b6,
|
||||
0x24b7, 0x24b8, 0x24b9, 0x24ba, 0x24bb, 0x24bf, 0x24c0, 0x24c7, 0x24c8, 0x24c9, 0x24dc, 0x24dd,
|
||||
0x24df, 0x24e0, 0x24fa, 0x2501, 0x2503, 0x2504, 0x2505, 0x2507, 0x2508, 0x2509, 0x2520, 0x2521,
|
||||
0x2523, 0x252f, 0x2531, 0x2544, 0x2560, 0x2561, 0x2563, 0x2571, 0x2582, 0x2583, 0x2584, 0x25a0,
|
||||
0x25a2, 0x25a3, 0x25a4, 0x25a5, 0x25a6, 0x25a7, 0x25a9, 0x25aa, 0x25ab, 0x25ac, 0x25ad, 0x25af,
|
||||
0x25b0, 0x25b2, 0x25b5, 0x25b6, 0x25b8, 0x25b9, 0x25ba, 0x25bb, 0x25bc, 0x25bd, 0x25e0, 0x25e2,
|
||||
0x25e5, 0x25ec, 0x25ed, 0x25f9, 0x25fa, 0x25fb,
|
||||
];
|
||||
|
||||
/// Each measured GPU that reports more than one `deviceID`, as its `vendorID` and its IDs, the one
|
||||
/// it was measured under first. A table keyed on a measured GPU names it by that first ID, and a
|
||||
/// device that reports any of them takes its rows at the releases they name: the driver facts,
|
||||
/// deviations and defects (`driver_facts`), the Function storage a thread holds
|
||||
/// (`function_storage`) and the runtime's driver defects.
|
||||
const ONE_GPU: &[(u32, &[u32])] = &[
|
||||
// The AMD Radeon 780M (gfx1103): Phoenix's 0x15bf, measured (the committed capture
|
||||
// `amd-780m-radv`), and Hawk Point's 0x1900, whose capture under the same RADV build
|
||||
// (`amd-780m-hawkpoint-radv`) differs from Phoenix's in its `deviceID` alone.
|
||||
(0x1002, &[0x15bf, 0x1900]),
|
||||
];
|
||||
|
||||
impl DeviceDescription {
|
||||
/// The `deviceID` by which the tables keyed on a measured GPU name this device's GPU: the
|
||||
/// driver facts, deviations and defects, the Function storage a thread holds, and the
|
||||
/// runtime's driver defects. It is the description's own
|
||||
/// [`device_id`](DeviceDescription::device_id), but for a GPU that reports more than one
|
||||
/// `deviceID`, the one it was measured under: the Radeon 780M reports 0x15bf (Phoenix) and
|
||||
/// 0x1900 (Hawk Point), and both name it as 0x15bf. The `driverID`, `vendorID` and
|
||||
/// `driverVersion` a measured row names still hold as they are.
|
||||
pub fn canonical_device_id(&self) -> u32 {
|
||||
ONE_GPU
|
||||
.iter()
|
||||
.find(|(vendor, ids)| *vendor == self.vendor_id && ids.contains(&self.device_id))
|
||||
.map_or(self.device_id, |(_, ids)| ids[0])
|
||||
}
|
||||
}
|
||||
@@ -169,10 +169,7 @@ impl MetalDeviceProperties {
|
||||
let threads = l
|
||||
.max_compute_work_group_invocations
|
||||
.min(apple_gpu::MAX_THREADS_PER_THREADGROUP);
|
||||
let per_axis = match profile.deep_threadgroups() {
|
||||
DeepThreadgroups::Axes => l.max_compute_work_group_size.map(|axis| axis.min(threads)),
|
||||
DeepThreadgroups::OneRow => [threads; 3],
|
||||
};
|
||||
let per_axis = [threads; 3];
|
||||
let d = &f.descriptors;
|
||||
let argument_buffers_tier = if f.buffer_access == BufferAccess::Addressed
|
||||
&& d.runtime_descriptor_array
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
//! [`DeviceDescription::with_enabled`] (which refuses a set that breaks one) so that it states
|
||||
//! what is enabled. Translation uses only what the description enables.
|
||||
//!
|
||||
//! [`Device::new`] derives an opaque [`DeviceProfile`] from the description and a
|
||||
//! [`DevicePolicy`], the consumer's product choices (the default, [`DevicePolicy::UNTRUSTED`],
|
||||
//! contains and isolates guest shaders and bounds their loops). It refuses a device below Vulkan
|
||||
//! [`Device::from_queries`] derives an opaque [`DeviceProfile`] from the description's Vulkan
|
||||
//! queries and a [`DevicePolicy`], the consumer's product choices (the default,
|
||||
//! [`DevicePolicy::UNTRUSTED`], contains and isolates guest shaders and bounds their loops); no
|
||||
//! driver or GPU identity decides anything, and no `VkDevice` is needed. It refuses a device below Vulkan
|
||||
//! 1.2 and an inconsistent description or policy. A [`Device`] is cheap to clone, and every
|
||||
//! compile and plan takes one:
|
||||
//!
|
||||
@@ -43,10 +44,8 @@
|
||||
pub(crate) mod check;
|
||||
pub(crate) mod derive;
|
||||
pub(crate) mod description;
|
||||
pub(crate) mod driver_facts;
|
||||
pub(crate) mod enables;
|
||||
pub(crate) mod function_storage;
|
||||
pub(crate) mod gpus;
|
||||
pub(crate) mod khronos;
|
||||
pub(crate) mod mechanism;
|
||||
pub(crate) mod metal;
|
||||
@@ -60,19 +59,11 @@ pub use description::{
|
||||
AllocationLimits, DeviceDescription, FormatProperties, FormatSupport,
|
||||
GeneratedCommandsProperties, SubgroupProperties,
|
||||
};
|
||||
pub use driver_facts::{DriverDiagnostic, DriverFact};
|
||||
pub use enables::{EnableSet, Exposure};
|
||||
// The mechanism derivation: internal; a pipeline states each mechanism in its `dependencies`.
|
||||
pub(crate) use mechanism::mechanism;
|
||||
pub use metal::{MetalDeviceProperties, SimdSupport, StageSimd};
|
||||
pub use policy::{
|
||||
BatchOrderPolicy, CompletionPolicy, ContainmentPolicy, DevicePolicy, DontCareColorPolicy,
|
||||
ExtendedRangeBlitPolicy, HalfChainPolicy, HeapAnswerPolicy, HeapCompressionPolicy,
|
||||
HostPageTexturePolicy, IndirectRecordsPolicy, ManagedCopyInPolicy, PipelineWaitPolicy,
|
||||
QueueSharingPolicy, QueueTurnPolicy, RateMapRegionPolicy, RenderLoweringPolicy,
|
||||
UnsharedIsolationPolicy, UnstoredDontCarePolicy, VertexReachPolicy, WideLinePolicy,
|
||||
YCbCrInPlacePolicy,
|
||||
};
|
||||
pub use policy::{ContainmentPolicy, DevicePolicy};
|
||||
pub(crate) use profile::whole_point_size;
|
||||
pub use profile::{DeviceProfile, SpirvValidation};
|
||||
// The vocabulary the device surface reaches: description and policy inputs, and the requirement
|
||||
@@ -88,8 +79,6 @@ pub use profile::{Containment, DescriptorCaps, FunctionStorage, Robustness};
|
||||
pub use subgroup::{SimdClass, StageSubgroup, SubgroupModel, SubgroupSizes, Tier};
|
||||
// The driver defect a refusal names (`Needs::DriverDefect`).
|
||||
pub use profile::DriverWorkaround;
|
||||
// The GPU generation a driver workaround and a runtime driver defect key on.
|
||||
pub use gpus::NVIDIA_AMPERE_GA10X;
|
||||
pub use requirements::{
|
||||
ApiVersion, FloatControl, FloatWidth, FormatUsage, Requirements, ResolveMode, SpirvCapability,
|
||||
SpirvExtension, StageCreateFlag, SubgroupOp, VkExtension, VkFeature, VkLimit, VkProperty,
|
||||
|
||||
@@ -2,29 +2,9 @@
|
||||
//! decide a `DeviceProfile`.
|
||||
|
||||
use crate::device::profile::{GuestIsolation, HandleDomain, PointerDomain};
|
||||
use std::time::Duration;
|
||||
|
||||
/// Policy inputs of `Device::new`. Every field but `heap_compression`, `heap_answers`,
|
||||
/// `completion`, `batch_order`, `render_lowering`, `host_page_textures`, `pipeline_waits`,
|
||||
/// `pipeline_creation_wait`, `pipeline_commit_wait`, `wide_lines`, `extended_range_blits`,
|
||||
/// `queue_sharing`, `unshared_isolation`, `queue_turns`, `dont_care_colors`,
|
||||
/// `unstored_dont_care_loads`, `vertex_reach`, `rate_map_regions`, `managed_copy_in` and
|
||||
/// `indirect_records` can change emitted code, so the profile carries it (containment as the
|
||||
/// encoding it selects) and its fingerprint covers it; those twenty are the runtime's alone (a
|
||||
/// heap's
|
||||
/// compressed texture's image, what a heap texture's size query answers, when the host sees a
|
||||
/// command buffer complete, how a batch begins after the earlier ones
|
||||
/// of its queue, where a render encoder's calls are lowered, what holds a sampled texture over host
|
||||
/// pages, whether and how long a pipeline the driver is still making is waited for, which lines
|
||||
/// draw a wide line, what a blit through a compressed extended-range texture writes, which
|
||||
/// `VkQueue` a command queue submits to, how much of other queues' work goes ahead of an unshared
|
||||
/// queue's on a `VkQueue` they share, how much of its own work a command queue keeps submitted
|
||||
/// ahead on a `VkQueue` it shares, what a colour attachment stored `DontCare` keeps, what a pass
|
||||
/// reads of an attachment it loads `DontCare` and does not store, which draws fetch a vertex
|
||||
/// layout in the shader where the device's fixed-function input would wrap past 4 GiB, how a
|
||||
/// rate-mapped pass's draws reach its regions, when a `Managed` buffer's GPU copy takes the
|
||||
/// bytes a `didModifyRange:` names, and where an indirect command buffer's records lie on a device
|
||||
/// whose held host-pointer imports cost every submission), and no profile carries them.
|
||||
/// Policy inputs of `Device::from_queries`. Every field can change emitted code, so the profile
|
||||
/// carries it (containment as the encoding it selects) and its fingerprint covers it.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
@@ -38,240 +18,17 @@ pub struct DevicePolicy {
|
||||
pub containment: ContainmentPolicy,
|
||||
/// Whether guest shaders are isolated from each other's resources.
|
||||
pub isolation: GuestIsolation,
|
||||
|
||||
/// Whether a heap's colour texture that Metal keeps losslessly compressed, on a driver whose
|
||||
/// compressed images hide writes through an alias, is the driver's compressed image (the
|
||||
/// default) or one the driver keeps uncompressed in the heap's bytes. The runtime's choice
|
||||
/// alone: no emitted code changes.
|
||||
pub heap_compression: HeapCompressionPolicy,
|
||||
/// Whether a heap texture whose image needs more of the heap than Metal's answer on Apple's
|
||||
/// GPUs answers the device's image (the default) and lies in it, or answers Metal's and is
|
||||
/// held to it by an image that fits or a shadow. The runtime's choice alone: no emitted code
|
||||
/// changes.
|
||||
pub heap_answers: HeapAnswerPolicy,
|
||||
/// Whether command buffers committed on one `VkQueue` that the runtime's scheduler finds ready
|
||||
/// together go to the driver in one kernel submission, each seen complete once the last of
|
||||
/// them completed (the default, on a driver that merges such submissions), or each in a
|
||||
/// submission of its own, seen complete at its own end. The runtime's choice alone: no
|
||||
/// emitted code changes.
|
||||
pub completion: CompletionPolicy,
|
||||
/// Whether a batch of command buffers on one `VkQueue` begins after the batches before it
|
||||
/// there by their ends (the default, on a driver measured to run no two kernel submissions of
|
||||
/// one queue side by side), or by a barrier for each access that depends on theirs. The
|
||||
/// runtime's choice alone: no emitted code changes.
|
||||
pub batch_order: BatchOrderPolicy,
|
||||
/// Whether a render encoder's call is lowered inside the call, which returns every refusal
|
||||
/// (the default), or after it returned, a refusal only the lowering finds failing its command
|
||||
/// buffer. The runtime's choice alone: no emitted code changes.
|
||||
pub render_lowering: RenderLoweringPolicy,
|
||||
/// Whether a texture that only samples or reads, over a no-copy buffer's host pages or over a
|
||||
/// buffer the runtime placed in fresh host pages, is an image aliasing those pages in place
|
||||
/// (the default, where the device's own check shows its first move keeps every byte), or a
|
||||
/// shadow the encoders copy the texels into and back. The runtime's choice alone: no emitted
|
||||
/// code changes.
|
||||
pub host_page_textures: HostPageTexturePolicy,
|
||||
/// Whether a chain of fast-math `half` additions, subtractions and products, on a device
|
||||
/// without `shaderFloat16`, rounds where a value leaves it (the default) or at each operation.
|
||||
/// Changes emitted code: the profile carries it.
|
||||
pub half_chains: HalfChainPolicy,
|
||||
/// Whether a function that reads a two-plane YCbCr texture's planes in place (a uniform
|
||||
/// texel buffer over their codes, on a device whose memory is the host's) samples them by
|
||||
/// Vulkan's Y′CbCr model in the device's arithmetic, as the device's own conversion would
|
||||
/// (the default), or converts and filters every tap as Metal does, exactly. Changes emitted
|
||||
/// code: the profile carries it.
|
||||
pub ycbcr_in_place_reads: YCbCrInPlacePolicy,
|
||||
/// Whether a render or compute state's creation, and a `commit` that records a pass whose
|
||||
/// executions read the CPU's records, wait a bound for a pipeline the driver is still making
|
||||
/// (the default), or until it is made. A committed command buffer waits for its draws' and
|
||||
/// dispatches' pipelines until they are made under either. The bounds are the two fields
|
||||
/// below. The runtime's choice alone: no emitted code changes.
|
||||
pub pipeline_waits: PipelineWaitPolicy,
|
||||
/// Under [`PipelineWaitPolicy::Bounded`], the longest a render or compute state's creation
|
||||
/// waits for the pipelines it hands to the runtime's pool, one deadline for all of them from
|
||||
/// the wait's start: then it returns, the makings going on. 4.5 s by default, so a host call that
|
||||
/// both creates a state and commits a command buffer (a guest's FIFO step may) waits 9 s at
|
||||
/// most for the driver's makings, under a guest's 10 s check of its FIFO. Unread under
|
||||
/// `Exact`. The runtime's alone: no emitted code changes.
|
||||
pub pipeline_creation_wait: Duration,
|
||||
/// Under [`PipelineWaitPolicy::Bounded`], how long after its commit a command buffer's
|
||||
/// `commit` waits for the pipelines of a pass that executes render commands the CPU writes,
|
||||
/// and for those its executions' replay begins itself, leaving the pass to its host step past
|
||||
/// it, which records it once they are made. Every other command's making is waited for until
|
||||
/// made. 4.5 s
|
||||
/// by default (as the creation wait, above). Unread under `Exact`. The runtime's alone: no
|
||||
/// emitted code changes.
|
||||
pub pipeline_commit_wait: Duration,
|
||||
/// Whether a line Apple's `setLineWidth:` widens, at a width the device's own lines draw (which
|
||||
/// no device's are taken to draw as Metal's: strict lines, lines that are not parallelograms, a
|
||||
/// width off the device's granularity or below 1, a driver's parallelograms, whose ends the
|
||||
/// driver places), is the device's own line at that width (the default) or the pipeline's band
|
||||
/// variant, two triangles that cover Metal's parallelogram. The runtime's choice alone: no
|
||||
/// emitted code of a pipeline changes, the band being a variant of its own.
|
||||
pub wide_lines: WideLinePolicy,
|
||||
/// Whether a blit or fill through a `BGRA10_XR` or `BGRA10_XR_sRGB` texture Metal keeps
|
||||
/// losslessly compressed keeps the texels' bytes (the default) or writes Metal's canonical
|
||||
/// encoding of them. The runtime's choice alone: no emitted code changes.
|
||||
pub extended_range_blits: ExtendedRangeBlitPolicy,
|
||||
/// Whether command queues share `VkQueue`s, each moving to a busy one of its family as it
|
||||
/// makes a command buffer while it holds no other uncompleted one (the default, on a device
|
||||
/// whose own check finds its GPU idle when consecutive work comes from another `VkQueue`), or
|
||||
/// each keeps the `VkQueue` it took at its creation. The runtime's choice alone: no emitted
|
||||
/// code changes.
|
||||
pub queue_sharing: QueueSharingPolicy,
|
||||
/// Whether, on a `VkQueue` that a command queue made with `new_command_queue_unshared` shares
|
||||
/// with other command queues (the one graphics queue of RADV, ANV and lavapipe), the runtime
|
||||
/// keeps only about 2 ms of the other queues' expected GPU work submitted ahead there, so the
|
||||
/// unshared queue's command buffers wait behind no deep backlog (the default), or submits
|
||||
/// every ready batch at once. The runtime's choice alone: no emitted code changes.
|
||||
pub unshared_isolation: UnsharedIsolationPolicy,
|
||||
/// Whether command queues that share a `VkQueue` take turns there, each keeping only about
|
||||
/// 2 ms of its own expected GPU work submitted ahead while another submits there, so a
|
||||
/// command buffer of one waits behind no deep backlog of another's (the default), or every
|
||||
/// ready batch is submitted at once, in commit order. The runtime's choice alone: no emitted
|
||||
/// code changes.
|
||||
pub queue_turns: QueueTurnPolicy,
|
||||
/// Whether a colour attachment of a texture's own image that a pass stores `DontCare` is
|
||||
/// stored as the driver stores it (the default) or renders through a backing so that the
|
||||
/// texture keeps the texels it held before the pass, as Apple's GPU leaves them. The runtime's
|
||||
/// choice alone: no emitted code changes.
|
||||
pub dont_care_colors: DontCareColorPolicy,
|
||||
/// Whether an attachment a pass loads `DontCare` and does not store, in a pass whose draws
|
||||
/// reach a tile, is cleared over the render area on a driver measured to run that clear no
|
||||
/// slower than its `DONT_CARE` load and left `DONT_CARE` on every other (the default), or
|
||||
/// cleared on every driver, so the pass's draws read Metal's answer wherever they read it.
|
||||
/// The runtime's choice alone: no emitted code changes.
|
||||
pub unstored_dont_care_loads: UnstoredDontCarePolicy,
|
||||
/// Whether, on a driver whose fixed-function vertex input takes an element's displacement
|
||||
/// modulo `2^32` (`RuntimeDriverDefect::VertexFetchWrapsPast4GiB`), a draw pulls a vertex
|
||||
/// layout in the shader only where its own values may fetch it past `2^32` bytes of its bind
|
||||
/// offset (the default), or also where GPU memory states how far it fetches: an indexed draw
|
||||
/// of 32-bit indices, an indirect draw. The runtime's choice alone: no emitted code of a
|
||||
/// pipeline changes, the pulled layouts being a variant of their own.
|
||||
pub vertex_reach: VertexReachPolicy,
|
||||
/// Whether a rate-mapped pass's triangles that a host step records are drawn once, a
|
||||
/// geometry stage fanning each out to the regions it touches where a probe of the draw found
|
||||
/// it can (the default), or every draw recorded once per region of the map's plan. The
|
||||
/// runtime's choice alone: no emitted code of a pipeline changes, the fan-out and its probe
|
||||
/// being variants of their own.
|
||||
pub rate_map_regions: RateMapRegionPolicy,
|
||||
/// When the GPU copy of a `Managed` buffer on a device without unified memory takes the
|
||||
/// bytes of a range `didModifyRange:` names: copied by the GPU from the host copy as the
|
||||
/// submission runs (the default), or copied on the CPU at the commit as the host copy holds
|
||||
/// them then. The runtime's choice alone: no emitted code changes.
|
||||
pub managed_copy_in: ManagedCopyInPolicy,
|
||||
/// Where an indirect command buffer's records lie on a device that imports host pointers and
|
||||
/// whose own check found a held pointer import costs every submission (RADV, ANV on i915):
|
||||
/// in pooled host-visible memory, as every other buffer of the runtime's own lies there,
|
||||
/// which a recovery of the device loses (the default), or in pages of the runtime's own
|
||||
/// imported by their pointer, which a recovery keeps, as Metal keeps a buffer's records
|
||||
/// across its GPU's restart. Elsewhere the records lie in the runtime's own pages under
|
||||
/// either. The runtime's choice alone: no emitted code changes.
|
||||
pub indirect_records: IndirectRecordsPolicy,
|
||||
}
|
||||
|
||||
impl DevicePolicy {
|
||||
/// The untrusted-guest production policy: containment and isolation on, the driver's
|
||||
/// compressed image of a heap's texture Metal keeps compressed, a heap texture's size query
|
||||
/// the device's image where it needs more than Metal's answer, command buffers ready together
|
||||
/// in one kernel submission, batches of one queue ordered by their ends where the driver runs
|
||||
/// them one after another, and a sampled
|
||||
/// texture over host pages in place where the device's check passed, a pipeline still
|
||||
/// being made waited for a bound (4.5 s at a state's creation, and 4.5 s from a commit), a
|
||||
/// wide line the device's own wherever it draws the width, command queues sharing
|
||||
/// `VkQueue`s where the device's GPU idles between work of different ones, other queues' work
|
||||
/// held to about 2 ms ahead of an unshared queue's on a `VkQueue` they share, each command
|
||||
/// queue's own work held to about 2 ms ahead on a `VkQueue` it shares, a colour stored
|
||||
/// `DontCare` stored as the driver stores it, an attachment loaded `DontCare` and not stored
|
||||
/// cleared where its driver clears it no slower, a vertex layout pulled past a wrapping
|
||||
/// fixed-function input only where the draw's own values reach past 4 GiB, a rate-mapped
|
||||
/// pass's triangles a host step records fanned out to its regions where a probe finds they
|
||||
/// can be, a `Managed` buffer's named range copied in by the GPU from its host copy as the
|
||||
/// submission runs, and an indirect command buffer's records in pooled memory where a held
|
||||
/// host-pointer import costs the device's every submission.
|
||||
/// The untrusted-guest production policy: the default domains (a resident table of pointers
|
||||
/// and a handle table), containment and isolation on.
|
||||
pub const UNTRUSTED: DevicePolicy = DevicePolicy {
|
||||
pointer_domain: PointerDomain::ResidentTable,
|
||||
handle_domain: HandleDomain::Table,
|
||||
containment: ContainmentPolicy::Contained,
|
||||
isolation: GuestIsolation::On,
|
||||
heap_compression: HeapCompressionPolicy::Compressed,
|
||||
heap_answers: HeapAnswerPolicy::Device,
|
||||
completion: CompletionPolicy::Grouped,
|
||||
batch_order: BatchOrderPolicy::Ends,
|
||||
render_lowering: RenderLoweringPolicy::AtCall,
|
||||
host_page_textures: HostPageTexturePolicy::InPlace,
|
||||
half_chains: HalfChainPolicy::AtExits,
|
||||
ycbcr_in_place_reads: YCbCrInPlacePolicy::Model,
|
||||
pipeline_waits: PipelineWaitPolicy::Bounded,
|
||||
pipeline_creation_wait: Duration::from_millis(4500),
|
||||
pipeline_commit_wait: Duration::from_millis(4500),
|
||||
wide_lines: WideLinePolicy::Device,
|
||||
extended_range_blits: ExtendedRangeBlitPolicy::Kept,
|
||||
queue_sharing: QueueSharingPolicy::Adaptive,
|
||||
unshared_isolation: UnsharedIsolationPolicy::Bounded,
|
||||
queue_turns: QueueTurnPolicy::Fair,
|
||||
dont_care_colors: DontCareColorPolicy::Driver,
|
||||
unstored_dont_care_loads: UnstoredDontCarePolicy::Driver,
|
||||
vertex_reach: VertexReachPolicy::Bounded,
|
||||
rate_map_regions: RateMapRegionPolicy::FanOut,
|
||||
managed_copy_in: ManagedCopyInPolicy::AtSubmission,
|
||||
indirect_records: IndirectRecordsPolicy::Untaxed,
|
||||
};
|
||||
|
||||
/// This policy with Metal's answer wherever the choices offer it: a heap's texture whose bytes
|
||||
/// alias the heap's
|
||||
/// as written ([`HeapCompressionPolicy::Uncompressed`]), every heap texture's size query
|
||||
/// Metal's answer wherever the runtime models it ([`HeapAnswerPolicy::Metal`]), each command
|
||||
/// buffer seen complete
|
||||
/// at its own end ([`CompletionPolicy::Exact`]), each batch ordered after the earlier ones of
|
||||
/// its queue by
|
||||
/// the accesses it depends on alone ([`BatchOrderPolicy::Exact`]), each render encoder
|
||||
/// call lowered inside the call, which returns every refusal
|
||||
/// ([`RenderLoweringPolicy::AtCall`]), every texture over host pages a shadow, whose
|
||||
/// copies touch its texels alone ([`HostPageTexturePolicy::Shadow`]), each `half`
|
||||
/// operation rounded on a device without `shaderFloat16` ([`HalfChainPolicy::EachOperation`]),
|
||||
/// every two-plane YCbCr sample of planes read in place Metal's conversion and filter of its
|
||||
/// taps ([`YCbCrInPlacePolicy::Exact`]),
|
||||
/// a render state's predicted pipeline made at its creation, each draw's pipeline waited
|
||||
/// for until it is made ([`PipelineWaitPolicy::Exact`]), every wide line Metal's
|
||||
/// parallelogram where the device's own line differs ([`WideLinePolicy::Exact`]), and every
|
||||
/// blit and fill through a compressed `BGRA10_XR` texture Metal's canonical encoding of its
|
||||
/// texels ([`ExtendedRangeBlitPolicy::Canonical`]), every command queue on the `VkQueue`
|
||||
/// it took at its creation ([`QueueSharingPolicy::PerQueue`]), and every colour attachment of a
|
||||
/// texture's own image stored `DontCare` keeping its earlier texels
|
||||
/// ([`DontCareColorPolicy::Kept`]), every attachment loaded `DontCare` and not stored cleared
|
||||
/// in a pass whose draws reach a tile ([`UnstoredDontCarePolicy::Cleared`]), and every vertex
|
||||
/// layout a draw may fetch past 4 GiB of its bind offset pulled where the device's
|
||||
/// fixed-function input wraps there, wherever the draw's reach is stated
|
||||
/// ([`VertexReachPolicy::Exact`]), every draw of a rate-mapped pass recorded once per
|
||||
/// region ([`RateMapRegionPolicy::Exact`]), every `Managed` buffer's named range taken
|
||||
/// on the CPU at the commit ([`ManagedCopyInPolicy::AtCommit`]), and every indirect command
|
||||
/// buffer's records in the runtime's own pages wherever the device imports host pointers,
|
||||
/// which a recovery keeps ([`IndirectRecordsPolicy::Carried`]). Every other field is kept,
|
||||
/// `unshared_isolation` and `queue_turns` among them: their defaults are the ones nearer
|
||||
/// Metal's, whose queues do not wait for each other's whole command buffers.
|
||||
pub const fn exact_answers(self) -> DevicePolicy {
|
||||
DevicePolicy {
|
||||
heap_compression: HeapCompressionPolicy::Uncompressed,
|
||||
heap_answers: HeapAnswerPolicy::Metal,
|
||||
completion: CompletionPolicy::Exact,
|
||||
batch_order: BatchOrderPolicy::Exact,
|
||||
render_lowering: RenderLoweringPolicy::AtCall,
|
||||
host_page_textures: HostPageTexturePolicy::Shadow,
|
||||
half_chains: HalfChainPolicy::EachOperation,
|
||||
ycbcr_in_place_reads: YCbCrInPlacePolicy::Exact,
|
||||
pipeline_waits: PipelineWaitPolicy::Exact,
|
||||
wide_lines: WideLinePolicy::Exact,
|
||||
extended_range_blits: ExtendedRangeBlitPolicy::Canonical,
|
||||
queue_sharing: QueueSharingPolicy::PerQueue,
|
||||
dont_care_colors: DontCareColorPolicy::Kept,
|
||||
unstored_dont_care_loads: UnstoredDontCarePolicy::Cleared,
|
||||
vertex_reach: VertexReachPolicy::Exact,
|
||||
rate_map_regions: RateMapRegionPolicy::Exact,
|
||||
managed_copy_in: ManagedCopyInPolicy::AtCommit,
|
||||
indirect_records: IndirectRecordsPolicy::Carried,
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DevicePolicy {
|
||||
@@ -282,7 +39,8 @@ impl Default for DevicePolicy {
|
||||
}
|
||||
|
||||
/// The containment choice. The encoding (robustness or in-shader checks) is selected by
|
||||
/// `Device::new` from the enabled robustness features; the policy only says whether to contain.
|
||||
/// `Device::from_queries` from the enabled robustness features; the policy only says whether to
|
||||
/// contain.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
@@ -295,610 +53,3 @@ pub enum ContainmentPolicy {
|
||||
/// it at a field's offset), reach whatever memory the device puts there.
|
||||
UnsafeOff,
|
||||
}
|
||||
|
||||
/// The image of a heap's colour texture that Metal keeps losslessly compressed (with
|
||||
/// `allowGPUOptimizedContents`, no `ShaderWrite`, `PixelFormatView` or `ShaderAtomic` usage, and a
|
||||
/// level 0 of 16 texels or more a side), on a driver whose compressed images may keep their texels
|
||||
/// apart from the memory they are bound to (`DriverFact::CompressedImagesHideAliasedWrites`: ANV
|
||||
/// on Intel's GPUs). Metal's own texture shows no aliased write as written either: an M3 Max read
|
||||
/// opaque magenta (`0xffff00ff`) in every texel of drawn content a buffer's fill over the
|
||||
/// texture's bytes covered, and the fill's bytes where the texture held only a clear. A texture
|
||||
/// Metal keeps uncompressed takes the uncompressed image under either value, and so does every
|
||||
/// texture of a heap over the caller's host pages, whose image is the one over the pages (a linear
|
||||
/// image made for host allocations, else a shadow of the heap's bytes): the choice is made for
|
||||
/// heaps over the device's own memory. The compressed image lies in the heap's bytes only where
|
||||
/// the heap's answer for the texture holds it ([`HeapAnswerPolicy`]). The runtime's choice alone:
|
||||
/// no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum HeapCompressionPolicy {
|
||||
/// The driver's compressed optimal image (the default), its fast clears, compression and
|
||||
/// tiling kept: a write through a buffer or texture over its bytes may leave its texels as
|
||||
/// they were or change them otherwise than Metal's, and its writes may show in those bytes
|
||||
/// compressed. Announced `heap-texture-compressed` where such a texture is made.
|
||||
#[default]
|
||||
Compressed,
|
||||
/// An image the driver keeps uncompressed in the heap's bytes, as for a texture Metal keeps
|
||||
/// uncompressed: host-transfer usage where the device enabled `hostImageCopy`, else a linear
|
||||
/// image, else the optimal one (each announced as such), so a write through a buffer over the
|
||||
/// texture's bytes shows in its texels as written.
|
||||
Uncompressed,
|
||||
}
|
||||
|
||||
/// What `heap_texture_size_and_align` (Metal's `heapTextureSizeAndAlignWithDescriptor:`)
|
||||
/// answers for a texture whose image binds into a heap's memory, where that image needs more
|
||||
/// bytes or a coarser alignment than Metal's answer on Apple's GPUs, which the runtime models.
|
||||
/// Metal's query is the device's own: the Macs answer alignments from 128 bytes (an M3 Max) to
|
||||
/// 4096 (an Intel UHD Graphics 630) and 65536 (an AMD Radeon Pro 5300M), and every driver measured
|
||||
/// off MoltenVK aligns its optimal images coarser than Apple's 128 (1024 bytes on an RTX 5080
|
||||
/// Laptop, 65536 for ANV's compressed images, up to 64 KiB on a Radeon 780M, and on an RX 7900 XTX
|
||||
/// 128 KiB for a depth image and 256 KiB for a 4-sample render target past 128 texels a side).
|
||||
/// The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum HeapAnswerPolicy {
|
||||
/// The larger of Metal's answer and the device's image of the texture's first route (the
|
||||
/// default), for a texture whose image binds into the heap's memory (a multisample one too,
|
||||
/// its samples in the driver's layout), where that image's alignment is at most 256 KiB (the
|
||||
/// alignment of a heap's memory, past which no image binds there) and at most 4 KiB or its
|
||||
/// answer's size, so a heap's padding at most doubles a texture's bytes past a page: the
|
||||
/// texture lies in that image, its compression kept as `HeapCompressionPolicy` says, with no
|
||||
/// image put in its place to fit Metal's answer and no shadow of Metal's tiles. Where that
|
||||
/// image's alignment is coarser, the texture's image that a 4 KiB alignment holds (its
|
||||
/// optimal image of host-transfer usage, else its linear one) lies there in its place, the
|
||||
/// answer that image's. A `Shared` texture's answer also holds the linear image a heap over
|
||||
/// host pages binds there. A texture whose answer Metal measures apart from its image (4:2:2,
|
||||
/// one-plane YCbCr, two-plane extended-range, `X32_Stencil8`, `BlockWritesOnly`), one whose
|
||||
/// image lies in memory of its own and every other texture take Metal's answer as under
|
||||
/// `Metal`. Announced `heap-texture-larger-than-metal` where the answer is past Metal's.
|
||||
#[default]
|
||||
Device,
|
||||
/// Metal's answer wherever the runtime models it: a texture whose image needs more takes an
|
||||
/// image that fits in its place (host-transfer usage, or a linear image), else a shadow of
|
||||
/// the heap's bytes (Metal's tiles where Metal keeps it uncompressed), and the device's own
|
||||
/// answer only where neither holds it.
|
||||
Metal,
|
||||
}
|
||||
|
||||
/// When the host sees a command buffer complete, on a driver that merges a submission signalling
|
||||
/// nothing into the next one in the same `vkQueueSubmit` (Mesa's common queue,
|
||||
/// `vk_queue_submits_merge`: ANV, RADV, lavapipe, NVK, Turnip and the other Mesa drivers of a kernel
|
||||
/// submission), where each kernel submission costs CPU time for every `VkDeviceMemory` of the
|
||||
/// device (ANV on i915 lists each in every execbuffer). Elsewhere every command buffer goes in a
|
||||
/// submission of its own under either value. The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum CompletionPolicy {
|
||||
/// Up to four batches of command buffers on one `VkQueue` that the scheduler finds ready
|
||||
/// together, none of which signals a binary semaphore, takes a fence, moves the caller's
|
||||
/// images or does first work, and none but the first of which waits for anything not seen
|
||||
/// complete, go in one `vkQueueSubmit`, and only the last signals, the queue's timeline and
|
||||
/// every event they signal (the default): one kernel submission for all of them. The commands,
|
||||
/// their barriers and their GPU times are unchanged; each but the last is seen complete (its
|
||||
/// status, handlers and waits) once the last completed, and an event's values they signal are
|
||||
/// reached then, late by the GPU time of the batches after it, never early and in commit
|
||||
/// order. The submission checks of up to three batches right behind a queue's next batch run
|
||||
/// with its own, in commit order, so checked command buffers are found ready together: such a
|
||||
/// check runs before the previous batch's submission rather than after it. Announced
|
||||
/// `grouped-completion` at the first such submission.
|
||||
#[default]
|
||||
Grouped,
|
||||
/// Each batch in a submission of its own that signals its own values, so each command buffer
|
||||
/// is seen complete, and its event signals land, at its own end, as Metal's are; each batch's
|
||||
/// submission checks run once the batch before it was submitted. The runtime's
|
||||
/// `CommandBuffer::set_completion_joins_next` lets a command buffer the program marks group as
|
||||
/// under `Grouped`, the first one behind it not marked going last in its submission.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// How a batch of command buffers on one `VkQueue` (the work the runtime submits for a command
|
||||
/// buffer between its event waits and signals) begins after the earlier batches there. Metal
|
||||
/// orders a command buffer after the earlier ones of its queue only where its work depends on
|
||||
/// theirs, so an independent one may run beside the one before it; it writes its `GPUStartTime`
|
||||
/// as its work begins. The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum BatchOrderPolicy {
|
||||
/// By their ends (the default) on a driver measured to run no two kernel submissions of one
|
||||
/// queue side by side, with or without a barrier between them, where it runs the same work
|
||||
/// recorded in one command buffer side by side (ANV, RADV and NVIDIA's driver): every batch
|
||||
/// ends with a barrier that orders all its commands before every command after it on its
|
||||
/// queue, so a later batch plans no barrier for the accesses of earlier ones, and its first
|
||||
/// encoder's GPU start time is written once the work before it ended, at the bottom of the
|
||||
/// pipe. Each batch then still starts once the one before it ended, as those drivers start it
|
||||
/// anyway. On any other driver, as [`Exact`](Self::Exact).
|
||||
#[default]
|
||||
Ends,
|
||||
/// A barrier at a batch's start for each access that depends on an earlier batch's, as for
|
||||
/// the accesses within a batch, and its first encoder's GPU start time written as it begins,
|
||||
/// at the top of the pipe, where the driver may run it beside the batch before it.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// Where a render encoder's calls are lowered: where each call's commands, descriptors, pipelines
|
||||
/// and resources are worked out and recorded. Metal's encoder checks a call as it is made and
|
||||
/// returns; its GPU work, and any failure found there, comes after. The runtime's choice alone: no
|
||||
/// emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum RenderLoweringPolicy {
|
||||
/// After the call returned: the call makes Metal's checks of its arguments and
|
||||
/// of the encoder's state, copies what it was lent and holds what it names, and returns; the
|
||||
/// encoder lowers it later, in order, before its command buffer's submission (on the
|
||||
/// runtime's lowering thread while the program goes on, the encoder's end too, and the rest
|
||||
/// at what follows the end in the command buffer; `commit` makes its checks and returns, its
|
||||
/// own work run after the end, and later commits behind it). A refusal only
|
||||
/// the lowering finds fails the command buffer
|
||||
/// (`CommandBufferError::CallRefused`, naming the call), which then runs nothing of that
|
||||
/// encoder or of any after it.
|
||||
Worker,
|
||||
/// Inside the call, as each call is made (the default): every refusal, the lowering's too,
|
||||
/// returns from the call itself.
|
||||
#[default]
|
||||
AtCall,
|
||||
}
|
||||
|
||||
/// What holds a texture over host pages: over a no-copy buffer's pages (imported by their pointer
|
||||
/// or as dma-bufs) or over a buffer the runtime placed in fresh host pages it imported. Vulkan
|
||||
/// makes an image bound to imported memory start `UNDEFINED`
|
||||
/// (`VUID-VkImageCreateInfo-pNext-01443`), and lets its layout transitions, the first among them,
|
||||
/// and a render pass's load and store operations read and write every byte bound to it, and a
|
||||
/// linear image's storage writes may reach more than their texels, where Metal keeps every CPU
|
||||
/// write to the bytes no command writes. The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum HostPageTexturePolicy {
|
||||
/// A linear image aliasing the pages (the default), on a device whose own check, run once per
|
||||
/// driver and release, shows that the first move of such an image leaves every byte alone
|
||||
/// while the CPU writes beside it, for a texture that renders, its render passes' load and
|
||||
/// store operations and its moves into the feedback loop layout and back too, and for one a
|
||||
/// shader writes (`ShaderWrite` or `ShaderAtomic`, of texels of 1, 2, 4, 8 or 16 bytes, those
|
||||
/// of 1 or 2 checked apart), a kernel's storage writes of its texels; and where the device
|
||||
/// makes the image (its format and usage linear) and lays it out at the buffer's row pitch.
|
||||
/// Elsewhere the shadow below. A texture made before the check's verdict is known is a shadow
|
||||
/// too.
|
||||
#[default]
|
||||
InPlace,
|
||||
/// A shadow on every device: an image of the runtime's own memory the encoders copy the
|
||||
/// texels into before each use and merge back after each write, whose copies touch the
|
||||
/// texels alone.
|
||||
Shadow,
|
||||
}
|
||||
|
||||
/// How a chain of `half` additions, subtractions and products rounds on a device without
|
||||
/// `shaderFloat16`, where a module computes each in `float` on its operands held widened and
|
||||
/// rounds its result by the device's `OpQuantizeToF16` (`PrecisionNote::NativeHalfQuantize`):
|
||||
/// capability emulation, as the device has no 16-bit arithmetic. A device with `shaderFloat16`
|
||||
/// computes `half` as it does under either value. Changes emitted code: the profile carries it.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum HalfChainPolicy {
|
||||
/// An operation whose flags hold `contract` and `reassoc`, and whose result only such
|
||||
/// operations on `half` read, is held at `float` precision unrounded (the default): the chain
|
||||
/// rounds where a value leaves it, a quantize at each of its exits instead of one per
|
||||
/// operation. A result may differ from the rounded operations' by the roundings the chain
|
||||
/// skips, and a value past `half`'s range inside the chain stays finite. Recorded
|
||||
/// `PrecisionNote::FastMathRewrites`.
|
||||
#[default]
|
||||
AtExits,
|
||||
/// Every operation's result rounded to `half`, as the AIR computes it.
|
||||
EachOperation,
|
||||
}
|
||||
|
||||
/// How a function samples a two-plane YCbCr texture (`YCBCR8_420_2P`, `YCBCR10_420_2P`) whose
|
||||
/// planes it reads in place: a uniform texel buffer over the planes' codes, on a device whose
|
||||
/// memory is the host's (an integrated GPU, a CPU device), where no image of the device's samples
|
||||
/// them (`bind::YCbCrInPlace`). No sampler of the device reads a texel buffer, so the function
|
||||
/// filters and converts the codes itself either way. Changes emitted code: the profile carries
|
||||
/// it.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum YCbCrInPlacePolicy {
|
||||
/// A linear sample by Vulkan's Y′CbCr model, as the device's own sampler Y′CbCr conversion of
|
||||
/// the planes' multi-planar format with a linear chroma filter computes it (the default): the
|
||||
/// luma codes blended bilinearly at the sample's point, the chroma pairs blended bilinearly at
|
||||
/// the same point of the chroma plane (Metal's midpoint siting), then the surface's range and
|
||||
/// matrix (Metal's coefficients) in `float`, each channel clamped into `[0, 1]`, alpha 1:
|
||||
/// eight fetches. Metal converts each of the four taps (its chroma weighted 9/3/3/1 and
|
||||
/// rounded to a code, each channel clamped) and sums their steps of `1/2048`: the answers
|
||||
/// differ by the chroma the taps reconstruct, by those roundings, and where a tap's channel
|
||||
/// leaves `[0, 1]`, recorded `PrecisionNote::HalfSampleFilter` or `FloatSampleFilter` and
|
||||
/// announced `ycbcr-filter-not-exact`. A nearest sample (one tap), a sample through a border
|
||||
/// address mode, one whose texel offset Metal places by a parent's size, and a gather are
|
||||
/// Metal's under either value.
|
||||
#[default]
|
||||
Model,
|
||||
/// Every tap Metal's texel (its luma code, its chroma pairs weighted 9/3/3/1 and rounded to a
|
||||
/// code, the range's and the matrix's fixed-point conversion), and a linear sample Metal's sum
|
||||
/// of the four taps' steps on the grid `2048`, exactly: twenty fetches and four conversions a
|
||||
/// linear sample.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// How long the runtime's calls wait for a `VkPipeline` the driver is still making. Metal makes a
|
||||
/// render state's pipeline inside `newRenderPipelineState`, so no command buffer of Metal's waits
|
||||
/// for a compile, and no draw of a state that was made is dropped. The runtime makes a state's
|
||||
/// pipelines on its pool while the draws that need them go on (a draw's own key, and a state's
|
||||
/// predicted key), so a command buffer committed before one is made waits for it, and completes
|
||||
/// later. A driver's cold compile (MoltenVK on a cold Metal compiler service) can take seconds,
|
||||
/// where a host that creates a state lazily inside a command buffer's encoding would wait inside
|
||||
/// it. The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum PipelineWaitPolicy {
|
||||
/// The default. A render or compute state's creation hands the making of its predicted
|
||||
/// pipeline to the runtime's pool and waits for it [`DevicePolicy::pipeline_creation_wait`] at
|
||||
/// most (4.5 s by default), then returns with it still being made. A committed command buffer
|
||||
/// waits for its draws' and dispatches' pipelines still being made until they are made, under
|
||||
/// either value, on the runtime's scheduler thread, which no program call waits for: it
|
||||
/// completes later, and no command is dropped. A `commit` that records a pass whose
|
||||
/// executions read the CPU's records waits for its pipelines, and for those its executions'
|
||||
/// replay begins itself, until its commit plus [`DevicePolicy::pipeline_commit_wait`] (4.5 s
|
||||
/// by default) at most, and leaves the pass to its host step past it.
|
||||
///
|
||||
/// What one call blocks for, waiting for the driver's makings: a state's creation, its
|
||||
/// creation wait; a `commit`, which records there what it can (a pass whose pipelines are
|
||||
/// made, an execution of render commands the CPU writes, which waits for its pipelines), until
|
||||
/// its own deadline at most (the moment it committed plus its commit wait), whatever earlier
|
||||
/// command buffers wait for (their deadlines are earlier); every other recording runs on the
|
||||
/// runtime's scheduler thread, which no program call waits for. A creation waits on no command buffer's
|
||||
/// deadline and a commit on no creation's, so a host call that creates a state and commits a
|
||||
/// command buffer waits their sum at most: 9 s by default. Made until made, under this value
|
||||
/// too, where the call that makes them waits for them: a draw that records nothing (no
|
||||
/// vertices or instances, or culled whole), a draw in a pass of custom sample positions, and
|
||||
/// one recorded again into another instance of its pass (an extended-range color's `half`
|
||||
/// shadow starting), each in the draw's call or in an execution's replay; a device replay's
|
||||
/// draws (an execution of render commands the GPU may write, recorded on the GPU), in its
|
||||
/// `commit`; and a making that failed, made again by its command's recording.
|
||||
#[default]
|
||||
Bounded,
|
||||
/// A render or compute state's creation makes its predicted pipeline before it returns, as
|
||||
/// Metal compiles there, and a committed command buffer waits for each of its draws' and
|
||||
/// dispatches' pipelines until it is made, an execution replay's among them: no command is
|
||||
/// dropped for its making's time.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// Which lines draw a line Apple's `setLineWidth:` widens (a width other than 1, quantized as Metal
|
||||
/// quantizes it) where the device's own lines draw that width, which no device's are taken to draw
|
||||
/// as Metal's parallelogram: strict lines (rectangles), lines not stated as parallelograms
|
||||
/// (`nonStrictWideLinesUseParallelogram` unset or unknown), a width off the device's
|
||||
/// `lineWidthGranularity` (which rounds it) or below 1 (where Vulkan promises no shape), and a
|
||||
/// driver's parallelograms, whose ends and endpoints' snap are the driver's. Where they cannot draw
|
||||
/// it at all (no `wideLines`, or a width outside `lineWidthRange`), and at width 0, the band draws
|
||||
/// it under either value. The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum WideLinePolicy {
|
||||
/// The device's own line at the width (the default): its rectangle, its Bresenham columns, its
|
||||
/// width rounded to the granularity, or its parallelogram's ends, which can cover pixels
|
||||
/// Metal's parallelogram does not and miss others. Announced `device-wide-lines` at the first
|
||||
/// such draw.
|
||||
#[default]
|
||||
Device,
|
||||
/// The pipeline's band variant (needs `tessellationShader`): each line two triangles over
|
||||
/// Metal's parallelogram. On a device without `tessellationShader`, the device's own line,
|
||||
/// announced as under `Device`.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// What a blit or fill writes through a `BGRA10_XR` or `BGRA10_XR_sRGB` texture Metal keeps
|
||||
/// losslessly compressed (`allowGPUOptimizedContents`, the shorter side of level 0 16 texels or
|
||||
/// more, neither `ShaderWrite` nor `PixelFormatView` usage, one sample, not over a buffer). Metal's
|
||||
/// GPU blit that reads or writes such a texture (a buffer into it, it into a buffer, a texture into
|
||||
/// it or out of it) moves the texels through its compression, which writes their canonical
|
||||
/// encoding: each 16-bit field's low six bits cleared and the alpha code clamped to `[384, 894]`;
|
||||
/// its fill clears the low six bits alone. The texel reads the same value either way: the low six
|
||||
/// bits are not read, and a read clamps the alpha. Measured on an Apple M3 Max under macOS 27.0.1:
|
||||
/// random texels through each direction, both formats, every storage mode, the usages and sizes
|
||||
/// that decide the compression; CPU copies (`replaceRegion`, `getBytes`) keep the bytes on Metal
|
||||
/// too. The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ExtendedRangeBlitPolicy {
|
||||
/// The device's copy, which keeps the bytes it moves (the default): no work past the copy.
|
||||
/// Announced `extended-range-bits-kept` at the first such blit or fill.
|
||||
#[default]
|
||||
Kept,
|
||||
/// Metal's canonical encoding: after a blit writes such a texture's region, or a blit out of
|
||||
/// one writes a buffer's or another texture's, a compute dispatch rewrites the texels it
|
||||
/// wrote (an image's through a scratch buffer, a copy in and out around the dispatch; a
|
||||
/// buffer's or a texture over a buffer's in place); a fill's texel is encoded before it is
|
||||
/// written. A blit out of one into a buffer whose bytes the device cannot bind there (an
|
||||
/// offset or pitch off 4 bytes, a region past `maxStorageBufferRange`), or into a texture over
|
||||
/// a buffer whose rows share bytes, keeps the bytes, announced as under `Kept`.
|
||||
Canonical,
|
||||
}
|
||||
|
||||
/// Which `VkQueue` a command queue submits to. A `VkQueue` runs its submissions in order, so two
|
||||
/// command queues on one wait for each other's whole command buffers, where Metal's queues wait
|
||||
/// for each other only inside one command. NVIDIA's driver (615.71.09 on the RTX 5080 Laptop GPU)
|
||||
/// leaves the GPU idle 56 to 62 us whenever consecutive work comes from another `VkQueue`, which
|
||||
/// held a device of a `VkQueue` per command queue near 30,000 one-draw command buffers a second,
|
||||
/// the GPU idle at the switches 60% of its time. Under either value a command queue takes, as it
|
||||
/// is made, the `VkQueue` the fewest live command queues hold, of those no unshared queue holds,
|
||||
/// in turn among equals, and a queue made with `new_command_queue_unshared` one no command queue
|
||||
/// holds where one is free. Presenting queues, and unshared queues, keep their `VkQueue` under
|
||||
/// either value. The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum QueueSharingPolicy {
|
||||
/// The default, on a device whose own check, run once per driver and release, finds the GPU
|
||||
/// idle when consecutive work comes from another `VkQueue` of one family; elsewhere, and before
|
||||
/// the check answered, as [`PerQueue`](Self::PerQueue). A command queue that makes a command
|
||||
/// buffer while it holds no other uncompleted one takes the busiest `VkQueue` of its family
|
||||
/// whose oldest batch has run under 0.5 ms, else stays. A queue one of whose command buffers
|
||||
/// ran on the GPU for over 2 ms, by its own timestamps, is long from then on: at its next such
|
||||
/// point it takes an idle `VkQueue` no long queue holds and stays there, and no queue moves
|
||||
/// onto a long queue's `VkQueue`. So the first long command buffer of a queue that shared holds
|
||||
/// the command buffers the queues sharing with it committed behind it, once per queue that goes
|
||||
/// long. Announced `queue-sharing` at the first move onto a `VkQueue` with another queue's work
|
||||
/// in flight. A device whose command buffers write no GPU timestamps the host reads (the
|
||||
/// runtime's `gpu_times_from_host`, or a driver whose timestamps wait for every queue's) does
|
||||
/// not share, and the runtime counts it (`WorkCounts::queue_sharing_untimed`).
|
||||
#[default]
|
||||
Adaptive,
|
||||
/// Each command queue on the `VkQueue` it took at its creation for its life: command queues
|
||||
/// share one only while the program keeps more live than the `VkQueue`s the device lends
|
||||
/// them.
|
||||
PerQueue,
|
||||
}
|
||||
|
||||
/// How much of other command queues' work the runtime submits ahead of an unshared queue's
|
||||
/// (`new_command_queue_unshared`, a compositor's) on a `VkQueue` they share. A `VkQueue` runs its
|
||||
/// submissions in order, so a command buffer there waits for everything submitted before it:
|
||||
/// where an application keeps several long command buffers in flight on the one graphics queue of
|
||||
/// RADV, ANV or lavapipe, the compositor's light one waits for all of them, where Metal runs it
|
||||
/// beside them. Where the unshared queue has a `VkQueue` of its own (a device with several, where
|
||||
/// no other command queue shares it), no batch is held under either value. The runtime's choice
|
||||
/// alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum UnsharedIsolationPolicy {
|
||||
/// The default: on a `VkQueue` an unshared queue holds, another command queue's batch is
|
||||
/// submitted only while less than 2 ms of the other queues' expected GPU work is left ahead
|
||||
/// of it there, else held in the runtime's scheduler until enough of it completes, so an
|
||||
/// unshared queue's command buffer goes in behind about one batch of theirs. A batch's
|
||||
/// expected GPU work is its command queue's: the host's view of how long that queue's
|
||||
/// recent batches ran on the `VkQueue`, raised at once by a longer one and halved toward a
|
||||
/// shorter one; while a batch of a command queue with no run seen yet is in flight there, no
|
||||
/// other is submitted until it completes. The next batch is submitted before the one ahead
|
||||
/// ends, so the GPU is not left idle between them where the host's scheduler thread runs in
|
||||
/// time; a batch longer than its command queue's recent ones still holds the unshared queue
|
||||
/// for its whole length, as one command buffer is one submission. The 2 ms holds while an
|
||||
/// unshared queue there committed a command buffer within the last 50 ms; while none has,
|
||||
/// 16 ms does, so a compositor's first command buffer after a quiet stretch waits behind at
|
||||
/// most about 16 ms of the other queues' expected work and one batch, and an application
|
||||
/// that keeps less queued beside a quiet compositor is not held.
|
||||
#[default]
|
||||
Bounded,
|
||||
/// Every ready batch is submitted at once: an unshared queue's command buffer waits behind
|
||||
/// every batch submitted before it on its `VkQueue`.
|
||||
Off,
|
||||
}
|
||||
|
||||
/// Whether command queues that share a `VkQueue` take turns there. A `VkQueue` runs its
|
||||
/// submissions in order, so a command buffer there waits for every batch submitted before it:
|
||||
/// where one command queue commits a burst of command buffers (a long one cut into parts, a
|
||||
/// backlog of frames) on the one graphics queue of RADV, ANV, lavapipe or another driver that
|
||||
/// lends one, a command buffer another queue commits after it waits for the whole burst. Metal's
|
||||
/// GPUs differ there: an Apple M3 Max (macOS 27.0.1) ran a second queue's small command buffer
|
||||
/// among a first queue's burst of 64; an AMD Radeon Pro 5300M (macOS 26.7.1) a blit or render one
|
||||
/// so, a compute one after the burst; an Intel UHD 630 (macOS 26.7.1) after the burst in every
|
||||
/// case. A queue made with
|
||||
/// `new_command_queue_unshared` is never held under either value; `UnsharedIsolationPolicy`
|
||||
/// bounds the other queues' work ahead of it. The runtime's choice alone: no emitted code
|
||||
/// changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum QueueTurnPolicy {
|
||||
/// The default: on a `VkQueue` that two or more command queues hold, a batch of a queue not
|
||||
/// made unshared is submitted only while less than 2 ms of its own queue's expected GPU work
|
||||
/// is in flight there (16 ms while no other command queue submitted there within the last
|
||||
/// 50 ms), else held in the runtime's scheduler until enough of it completes, while a later
|
||||
/// commit of another queue that shares nothing with it goes ahead of it. So another queue's
|
||||
/// command buffer goes in behind about that much of each busy queue's work and one batch of
|
||||
/// it, not its whole backlog. A batch's expected GPU work is its queue's expected run now
|
||||
/// (the host's view of how long its recent batches ran, raised at once by a longer one and
|
||||
/// halved toward a shorter one), so a run longer than the queue's recent ones prices every
|
||||
/// batch of it in flight at once; while a batch of a queue with no run seen yet is in flight
|
||||
/// there, no other batch of that queue is submitted until it completes. A batch already
|
||||
/// submitted runs to its end.
|
||||
#[default]
|
||||
Fair,
|
||||
/// Every ready batch is submitted at once, in commit order: a command buffer waits behind
|
||||
/// every batch submitted before it on its `VkQueue`.
|
||||
CommitOrder,
|
||||
}
|
||||
|
||||
/// What a colour attachment of a texture's own image (not a texture over a buffer's bytes, not
|
||||
/// memoryless, resolving nothing) keeps after a render pass stores it `MTLStoreActionDontCare`.
|
||||
/// Metal's documentation leaves it open (`MTLStoreAction.dontCare`: "You need to assume that GPU
|
||||
/// discarded the texture's contents"); what Apple's GPU leaves is measured: the texels the
|
||||
/// attachment held before the pass, the pass's clear and its draws both gone (the conformance
|
||||
/// case `pass-sequence-color-actions`, an Apple M3 Max under macOS 27.0.1, eight runs alike), or
|
||||
/// the rendered texels where its tiler overflows. Vulkan's `DONT_CARE` leaves the texels
|
||||
/// undefined. On a driver that stores `DONT_CARE` as Metal's own (MoltenVK on Apple's GPUs), a
|
||||
/// pass recorded as one render pass instance is handed to it under either value. The runtime's
|
||||
/// choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum DontCareColorPolicy {
|
||||
/// As the driver stores it (the default): `DONT_CARE` on a driver measured to keep one of
|
||||
/// Metal's two answers (the earlier texels or the rendered ones) or to store as Metal's own,
|
||||
/// else `STORE`, the rendered texels, Metal's answer where its tiler overflows. No work past
|
||||
/// the pass. Announced `dont-care-store` at the first such pass a driver does not store as
|
||||
/// Metal's own.
|
||||
#[default]
|
||||
Driver,
|
||||
/// The texels the attachment held before the pass: the pass renders through a backing its
|
||||
/// command queue keeps, one image of the attachment's shape, into which a `Load` copies the
|
||||
/// texels first, and nothing is copied back. A `Load` pass costs the copy (on an RTX 5080
|
||||
/// Laptop GPU about 19 µs more a pass at 1920x1080 than one stored `Store`, 10 µs at
|
||||
/// 256x256); a `Clear` or `DontCare` load about none. Where a format makes no such image, the
|
||||
/// pass stores as under `Driver`, announced as there.
|
||||
Kept,
|
||||
}
|
||||
|
||||
/// What a render pass's draws read of an attachment (not memoryless) the pass loads
|
||||
/// `MTLLoadActionDontCare` and does not store (`MTLStoreActionDontCare`), in a pass whose draws
|
||||
/// reach a tile. Metal's documentation leaves it open; what Apple's GPU reads is measured: zero for
|
||||
/// a colour and the pass's clear value for depth and stencil, wherever a draw reads it (an Apple
|
||||
/// M3 Max under macOS 27.0.1: a framebuffer fetch and a stencil test, in passes split and whole;
|
||||
/// a depth and a stencil test of separate depth and stencil textures, each aspect apart). Vulkan's
|
||||
/// `DONT_CARE` load leaves the contents undefined. Separate depth and stencil textures render
|
||||
/// through a scratch image of the pass's own, whose load of each such aspect this decides. The
|
||||
/// runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum UnstoredDontCarePolicy {
|
||||
/// Cleared on a driver measured to run the clear no slower than its `DONT_CARE` load
|
||||
/// (`DriverFact::UnstoredClearNoSlower`), Metal's answer there at no cost; `DONT_CARE`
|
||||
/// elsewhere (the default), whose draws read what the driver leaves (on lavapipe, the
|
||||
/// attachment's earlier texels), announced `dont-care-unstored-load` at the first such pass.
|
||||
#[default]
|
||||
Driver,
|
||||
/// Cleared on every driver by the pass's load operation over the render area (or before the
|
||||
/// pass, where its first render pass instance leaves the attachment out), to zero for a colour
|
||||
/// and to the attachment's clear value for depth and stencil: Metal's answer wherever a draw
|
||||
/// reads it. On lavapipe a 3648x2038 pass of an `RG16Float` colour and a
|
||||
/// `Depth32Float_Stencil8` so loaded costs about 3.3 ms more of its CPU's time.
|
||||
Cleared,
|
||||
}
|
||||
|
||||
/// Which draws pull a vertex layout in the shader on a driver whose fixed-function vertex input
|
||||
/// takes an element's displacement (`element · stride`) modulo `2^32`
|
||||
/// (`RuntimeDriverDefect::VertexFetchWrapsPast4GiB`: lavapipe), where Metal takes it in 64 bits:
|
||||
/// an element past `2^32` bytes of the bind offset of a buffer that ends before them reads zero on
|
||||
/// Metal (an Apple M3 Max under macOS 27.0.1, the conformance case
|
||||
/// `vertex-fetch-past-4gib-small-buffer`) and the bytes at its displacement's low 32 bits there.
|
||||
/// The pulled fetch reads the bytes past `2^32` as zero (`lower::stage_io::fetch`), Metal's answer
|
||||
/// wherever the buffer ends before them. On every other driver no draw pulls a layout for its
|
||||
/// reach under either value. The runtime's choice alone: no emitted code of a pipeline changes,
|
||||
/// the pulled layouts being the pulled-vertex-buffer variant (`VariantKey::pulled_vertex_buffers`).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum VertexReachPolicy {
|
||||
/// Pulled where the draw's own values may reach past `2^32` bytes of the bind offset (the
|
||||
/// default): the furthest element a draw without indices fetches (its last vertex), a draw of
|
||||
/// 16-bit indices (`65535` plus its base vertex), and a per-instance layout (its base instance
|
||||
/// plus its last instance over the step rate), times the stride, plus the end of the layout's
|
||||
/// furthest attribute. Such draws are rare, so no other draw pays anything. A layout an
|
||||
/// indexed draw of 32-bit indices fetches per vertex, and one an indirect draw fetches, stays
|
||||
/// in fixed function: an element past `2^32` bytes that its indices or arguments name reads
|
||||
/// its wrapped displacement's bytes. Announced `vertex-fetch-may-wrap` at the first such
|
||||
/// draw.
|
||||
#[default]
|
||||
Bounded,
|
||||
/// Pulled also where GPU memory states the reach: every layout of a nonzero stride that an
|
||||
/// indexed draw of 32-bit indices fetches per vertex, or that an indirect draw fetches, on
|
||||
/// such a driver, so every element reads Metal's bytes. Such a draw runs the pipeline's
|
||||
/// pulled-vertex-buffer variant, one more pipeline beside the fixed-function one where the
|
||||
/// state also draws otherwise, and fetches those layouts in its vertex shader.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// How a rasterization-rate-mapped pass's draws reach the regions of the map's plan. Drawn region
|
||||
/// by region, a draw runs its vertex function once per region (a plan may hold thousands); fanned
|
||||
/// out, once, a geometry stage emitting a copy of each triangle for each region it touches, through
|
||||
/// one viewport over the whole target, clip distances keeping each copy to its region's pixels.
|
||||
/// A copy's window coordinates are the region viewport's computed in the shader, so a pixel
|
||||
/// centre within a rounding error of a triangle's edge may be covered under one value and not
|
||||
/// the other. The runtime's choice alone: no emitted code of a pipeline changes, the fan-out, its
|
||||
/// probe and the region-copy variant being variants of their own (`VariantKey::region_fan_out`).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum RateMapRegionPolicy {
|
||||
/// Fanned out (the default) where a host step records the draw (an execution whose records
|
||||
/// the GPU writes) and the device has the fan-out's features: a probe of the step's draws,
|
||||
/// submitted and waited for first, flags each draw a triangle of which crosses `w = 0` or
|
||||
/// touches more regions than the fan-out's copies, and counts the copies of the others; a
|
||||
/// flagged draw is drawn region by region, the others once each, fanned out. Every other draw
|
||||
/// is drawn region by region: on such a device that also enables `multiViewport`,
|
||||
/// `shaderOutputViewportIndex` and `shaderDrawParameters`, one the fan-out's variant takes
|
||||
/// through its region-copy variant, whose vertex function puts each vertex in its region as a
|
||||
/// fanned-out draw's copy is put, each region through a viewport over the render area and its
|
||||
/// own scissor, so every route of the pass rasterizes a vertex at one position; any other
|
||||
/// through each region's viewport and scissor.
|
||||
#[default]
|
||||
FanOut,
|
||||
/// Every draw region by region, each region's through its own viewport and scissor.
|
||||
Exact,
|
||||
}
|
||||
|
||||
/// When the GPU copy of a `Managed` buffer takes the bytes of a range `didModifyRange:` names, on
|
||||
/// a device without unified memory, where the runtime keeps such a buffer as two copies (a host
|
||||
/// copy, which `contents` maps: the caller's pages of a no-copy buffer, or host memory of the
|
||||
/// runtime's own; and the GPU's own in device-local memory, which every command uses). Either way
|
||||
/// the next commit of a command buffer that may use the buffer takes the range for its own
|
||||
/// submission, which copies it in before any of its commands, and no later commit's range lands
|
||||
/// under it. What differs is when the bytes are read: Metal on an AMD Radeon Pro 5300M (two
|
||||
/// copies, macOS 26.7.1) reads them at the commit, so a CPU write of the range after the commit,
|
||||
/// while the GPU has not reached the command buffer, is not read; on an Intel UHD Graphics 630
|
||||
/// (one copy) it is (the validation lane `device_copies`). The runtime's choice alone: no emitted
|
||||
/// code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ManagedCopyInPolicy {
|
||||
/// The GPU copies the range from the host copy (the import of the caller's pages, or the
|
||||
/// runtime's own host memory) as the submission runs (the default), with no copy on the CPU:
|
||||
/// a CPU write of the range after the commit, before the GPU runs the command buffer, may be
|
||||
/// read, as on the UHD 630. Pages no import maps, which the GPU cannot read, are copied into
|
||||
/// staging memory on the CPU at the commit.
|
||||
#[default]
|
||||
AtSubmission,
|
||||
/// The CPU copies the range into staging memory at the commit, as the host copy holds it
|
||||
/// then, and the submission copies that in: a CPU write after the commit never reaches a
|
||||
/// command buffer committed before it, as on the 5300M. Its cost is a CPU copy of the range's
|
||||
/// bytes at each commit.
|
||||
AtCommit,
|
||||
}
|
||||
|
||||
/// Where an indirect command buffer's records (and the slots past them) lie on a device that
|
||||
/// imports host pointers (`VK_EXT_external_memory_host`) and whose own check found that a held
|
||||
/// pointer import adds to the cost of every submission. There such an import is held for the
|
||||
/// buffer's life and listed in every kernel submission: on RADV every imported memory is on every
|
||||
/// submission's list, amdgpu gets every page of each pointer import (a userptr) again in each, and
|
||||
/// a migration of any of those pages by the kernel's compaction waits for every fence of the
|
||||
/// import, so for all the process's work in flight, while every submission of the process waits
|
||||
/// behind it (a Radeon 780M, Mesa 26.2.6, Linux 7.3.3: windows of 65 to 140 ms in which every
|
||||
/// submission waited or failed with `EAGAIN`, with gameload's ICB records the only pointer
|
||||
/// imports). On every other device the records lie in the runtime's own pages under either value.
|
||||
/// The runtime's choice alone: no emitted code changes.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum IndirectRecordsPolicy {
|
||||
/// In the runtime's own pages imported by their pointer only where a held pointer import
|
||||
/// costs the device's submissions nothing, or its check has not answered (the default); where
|
||||
/// it costs them, in pooled host-visible memory, as the runtime's other buffers lie there. A
|
||||
/// recovery of such a device loses records in pooled memory with the `VkDevice` and writes
|
||||
/// them again as a new buffer's (its header, every command reset), where Metal keeps them;
|
||||
/// its notice counts such buffers (`device-recovered`).
|
||||
#[default]
|
||||
Untaxed,
|
||||
/// In the runtime's own pages imported by their pointer wherever the device imports host
|
||||
/// pointers, whatever a held import costs, so that a recovery keeps the records as the CPU
|
||||
/// and the GPU left them, as Metal does. Its cost, on such a device, is the held import in
|
||||
/// every submission while the buffer lives.
|
||||
Carried,
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `DeviceProfile` and its translation-relevant fields.
|
||||
//!
|
||||
//! `Device::new(desc, policy)` is the only producer of a [`DeviceProfile`]. The profile is the
|
||||
//! `Device::from_queries(desc, policy)` is the only producer of a [`DeviceProfile`]. The profile is the
|
||||
//! normalized projection of a device description plus the policy; lowering selects representations
|
||||
//! from it and nothing else. Derivation lives in `device::derive`, the fingerprint in
|
||||
//! [`DeviceProfile::fingerprint`].
|
||||
@@ -49,13 +49,11 @@ const SPIRV_VAL_RELAXATIONS: [(VkFeature, &str); 5] = [
|
||||
(VkFeature::Maintenance8, "--allow-offset-texture-operand"),
|
||||
];
|
||||
|
||||
/// The normalized, translation-relevant device projection. Opaque; built only by `Device::new`.
|
||||
/// The normalized, translation-relevant device projection. Opaque; built only by
|
||||
/// `Device::from_queries`.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct DeviceProfile {
|
||||
fields: ProfileFields,
|
||||
/// The facts whose form `Device::new` takes from its driver's rows and `Device::from_queries`
|
||||
/// from no identity ([`ProfileFacts`]).
|
||||
facts: ProfileFacts,
|
||||
/// [`DeviceProfile::fingerprint`], derived once here, where the fields are fixed.
|
||||
///
|
||||
/// Deriving it renders every field of the profile -- a format table alone is tens of
|
||||
@@ -69,14 +67,13 @@ pub struct DeviceProfile {
|
||||
}
|
||||
|
||||
impl DeviceProfile {
|
||||
/// The profile of `fields` and `facts`, with its fingerprint derived (the only way to build
|
||||
/// one): the fingerprint is a function of both, so holding them together is what keeps it true
|
||||
/// of them. A test's edit goes through `edit`, which only the crate's tests build.
|
||||
pub(crate) fn of(fields: ProfileFields, facts: ProfileFacts) -> DeviceProfile {
|
||||
let fingerprint = fingerprint_of(&fields, facts);
|
||||
/// The profile of `fields`, with its fingerprint derived (the only way to build one): the
|
||||
/// fingerprint is a function of the fields, so holding them together is what keeps it true of
|
||||
/// them. A test's edit goes through `edit`, which only the crate's tests build.
|
||||
pub(crate) fn of(fields: ProfileFields) -> DeviceProfile {
|
||||
let fingerprint = fingerprint_of(&fields);
|
||||
DeviceProfile {
|
||||
fields,
|
||||
facts,
|
||||
fingerprint,
|
||||
}
|
||||
}
|
||||
@@ -87,86 +84,10 @@ impl DeviceProfile {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn edit<T>(&mut self, change: impl FnOnce(&mut ProfileFields) -> T) -> T {
|
||||
let answer = change(&mut self.fields);
|
||||
self.fingerprint = fingerprint_of(&self.fields, self.facts);
|
||||
self.fingerprint = fingerprint_of(&self.fields);
|
||||
answer
|
||||
}
|
||||
|
||||
/// Which stages the compile holds under a stage bound.
|
||||
pub(crate) fn stage_bound(&self) -> StageBound {
|
||||
self.facts.stage_bound
|
||||
}
|
||||
|
||||
/// Where a `half` rounded through the conversion pair under the float controls is noted.
|
||||
pub(crate) fn half_pair_note(&self) -> HalfPairNote {
|
||||
self.facts.half_pair_note
|
||||
}
|
||||
|
||||
/// Whether a stage of implementation-defined reconvergence records it as a note.
|
||||
pub(crate) fn reconvergence_note(&self) -> ReconvergenceNote {
|
||||
self.facts.reconvergence_note
|
||||
}
|
||||
|
||||
/// Whether a render pipeline that draws into a signed normalized or `RGB9E5Float` attachment
|
||||
/// records Metal's tile store of it as a note.
|
||||
pub(crate) fn snorm_minimum_note(&self) -> SnormMinimumNote {
|
||||
self.facts.snorm_minimum_note
|
||||
}
|
||||
|
||||
/// Which narrow integer results clear the bits above their width.
|
||||
pub(crate) fn narrow_wrap(&self) -> NarrowWrap {
|
||||
self.facts.narrow_wrap
|
||||
}
|
||||
|
||||
/// Whether a `half` color output may be declared with 16-bit `float` lanes.
|
||||
pub(crate) fn half_outputs(&self) -> HalfOutputs {
|
||||
self.facts.half_outputs
|
||||
}
|
||||
|
||||
/// How many bytes of push constants a kernel's push window holds.
|
||||
pub(crate) fn push_window(&self) -> PushWindow {
|
||||
self.facts.push_window
|
||||
}
|
||||
|
||||
/// Which `half` fused multiply-adds take the device's 16-bit `Fma`.
|
||||
pub(crate) fn half_fma(&self) -> HalfFma {
|
||||
self.facts.half_fma
|
||||
}
|
||||
|
||||
/// How a kernel under the identity domains reads its dispatch region's base and threadgroup
|
||||
/// size.
|
||||
pub(crate) fn identity_region(&self) -> IdentityRegion {
|
||||
self.facts.identity_region
|
||||
}
|
||||
|
||||
/// How the partial-threadgroups variant of a kernel that does not observe its threadgroup
|
||||
/// partition runs the threads past its grid.
|
||||
pub(crate) fn oblivious_edge(&self) -> ObliviousEdge {
|
||||
self.facts.oblivious_edge
|
||||
}
|
||||
|
||||
/// How a kernel whose workgroup is its threadgroup runs a threadgroup deeper than the
|
||||
/// device's `maxComputeWorkGroupSize[2]`.
|
||||
pub(crate) fn deep_threadgroups(&self) -> DeepThreadgroups {
|
||||
self.facts.deep_threadgroups
|
||||
}
|
||||
|
||||
/// What a read of an argument the pipeline's function constants removed does beside taking
|
||||
/// zero.
|
||||
pub(crate) fn absent_reads(&self) -> AbsentReads {
|
||||
self.facts.absent_reads
|
||||
}
|
||||
|
||||
/// Whether a threadgroup memory access is contained, and how a kernel's threadgroup arena
|
||||
/// holds its words when every access of it is a whole, aligned `float` word.
|
||||
pub(crate) fn threadgroup_memory(&self) -> ThreadgroupMemory {
|
||||
self.facts.threadgroup_memory
|
||||
}
|
||||
|
||||
/// What a program's threadgroup memory holds before the program writes it.
|
||||
pub(crate) fn threadgroup_start(&self) -> ThreadgroupStart {
|
||||
self.facts.threadgroup_start
|
||||
}
|
||||
|
||||
/// The profile's fields: internal; the profile is opaque to consumers, who compare
|
||||
/// [`DeviceProfile::fingerprint`] and read its facts through the accessors.
|
||||
pub(crate) fn fields(&self) -> &ProfileFields {
|
||||
@@ -305,11 +226,8 @@ impl DeviceProfile {
|
||||
}
|
||||
|
||||
/// Whether a function reads a two-plane YCbCr texture's planes in place where its slot reads
|
||||
/// the texture only so (`bind::YCbCrInPlace`): on every device made by
|
||||
/// [`Device::from_queries`](crate::device::Device::from_queries); by [`Device::new`](crate::device::Device::new),
|
||||
/// on an integrated GPU or a CPU device, which reads host memory with no bus between, and
|
||||
/// elsewhere every such texture's image of converted texels is read. The image holds Metal's texels exactly; the planes read in place are
|
||||
/// sampled as `DevicePolicy::ycbcr_in_place_reads` says. The runtime reads it
|
||||
/// the texture only so (`bind::YCbCrInPlace`): on every device. The planes read in place are
|
||||
/// sampled by Vulkan's Y′CbCr model where the sample allows it. The runtime reads it
|
||||
/// to state a texture's planes (`TextureFacts::ycbcr_in_place`).
|
||||
pub fn reads_ycbcr_planes_in_place(&self) -> bool {
|
||||
self.fields.ycbcr_in_place
|
||||
@@ -561,7 +479,7 @@ pub(crate) fn fingerprints_derived() -> u64 {
|
||||
/// The fingerprint of `fields` ([`DeviceProfile::fingerprint`]): the rendering streams into the
|
||||
/// hash, because a materialized rendering of a profile with a format table is tens of kilobytes
|
||||
/// that no input-scaled ledger charge accounts for.
|
||||
fn fingerprint_of(fields: &ProfileFields, facts: ProfileFacts) -> Hash256 {
|
||||
fn fingerprint_of(fields: &ProfileFields) -> Hash256 {
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::fmt::Write as _;
|
||||
struct Hashing(Sha256);
|
||||
@@ -577,309 +495,9 @@ fn fingerprint_of(fields: &ProfileFields, facts: ProfileFacts) -> Hash256 {
|
||||
// `Hashing` never fails, and `Debug` of these plain-data types only fails when the
|
||||
// writer does.
|
||||
let _ = write!(h, "{:?}", fields);
|
||||
// A profile whose facts are its driver's rows' (`Device::new`'s) renders its fields alone, as
|
||||
// every profile did before those facts were the profile's own; any other renders its facts
|
||||
// after them.
|
||||
if facts != ProfileFacts::ROWS {
|
||||
let _ = write!(h, "{facts:?}");
|
||||
}
|
||||
h.0.finalize().into()
|
||||
}
|
||||
|
||||
/// The facts of a profile whose form `Device::new` takes from its driver's identity rows
|
||||
/// (`device::derive`) and `Device::from_queries`, which reads no identity, takes the same on every
|
||||
/// device: one field each, which the translator reads alone.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct ProfileFacts {
|
||||
/// Which stages the compile holds under a stage bound.
|
||||
pub(crate) stage_bound: StageBound,
|
||||
/// Where a `half` rounded through the conversion pair under the float controls is noted.
|
||||
pub(crate) half_pair_note: HalfPairNote,
|
||||
/// Whether a stage of implementation-defined reconvergence records it as a note.
|
||||
pub(crate) reconvergence_note: ReconvergenceNote,
|
||||
/// Whether a render pipeline that draws into a signed normalized or `RGB9E5Float` attachment
|
||||
/// records Metal's tile store of it as a note.
|
||||
pub(crate) snorm_minimum_note: SnormMinimumNote,
|
||||
/// Which narrow integer results clear the bits above their width.
|
||||
pub(crate) narrow_wrap: NarrowWrap,
|
||||
/// Whether a `half` color output may be declared with 16-bit `float` lanes.
|
||||
pub(crate) half_outputs: HalfOutputs,
|
||||
/// How many bytes of push constants a kernel's push window holds.
|
||||
pub(crate) push_window: PushWindow,
|
||||
/// Which `half` fused multiply-adds take the device's 16-bit `Fma`.
|
||||
pub(crate) half_fma: HalfFma,
|
||||
/// How a kernel under the identity domains reads its dispatch region's base and threadgroup
|
||||
/// size.
|
||||
pub(crate) identity_region: IdentityRegion,
|
||||
/// How the partial-threadgroups variant of a kernel that does not observe its threadgroup
|
||||
/// partition runs the threads past its grid.
|
||||
pub(crate) oblivious_edge: ObliviousEdge,
|
||||
/// How a kernel whose workgroup is its threadgroup runs a deep threadgroup, and the
|
||||
/// threadgroup the device reports it runs.
|
||||
pub(crate) deep_threadgroups: DeepThreadgroups,
|
||||
/// What a read of an argument the pipeline's function constants removed does beside taking
|
||||
/// zero.
|
||||
pub(crate) absent_reads: AbsentReads,
|
||||
/// Whether a threadgroup memory access is contained, and how a kernel's threadgroup arena
|
||||
/// holds its words when every access of it is a whole, aligned `float` word.
|
||||
pub(crate) threadgroup_memory: ThreadgroupMemory,
|
||||
/// What a program's threadgroup memory holds before the program writes it.
|
||||
pub(crate) threadgroup_start: ThreadgroupStart,
|
||||
}
|
||||
|
||||
impl ProfileFacts {
|
||||
/// `Device::new`'s: each fact as its driver's rows decide it.
|
||||
pub(crate) const ROWS: ProfileFacts = ProfileFacts {
|
||||
stage_bound: StageBound::Defects,
|
||||
half_pair_note: HalfPairNote::Fused,
|
||||
reconvergence_note: ReconvergenceNote::Field,
|
||||
snorm_minimum_note: SnormMinimumNote::Announced,
|
||||
narrow_wrap: NarrowWrap::Every,
|
||||
half_outputs: HalfOutputs::Sixteen,
|
||||
push_window: PushWindow::Guaranteed,
|
||||
half_fma: HalfFma::Measured,
|
||||
identity_region: IdentityRegion::Grid,
|
||||
oblivious_edge: ObliviousEdge::Partial,
|
||||
deep_threadgroups: DeepThreadgroups::Axes,
|
||||
absent_reads: AbsentReads::Marked,
|
||||
threadgroup_memory: ThreadgroupMemory::Contained,
|
||||
threadgroup_start: ThreadgroupStart::Unwritten,
|
||||
};
|
||||
|
||||
/// `Device::from_queries`': each fact the same on every device.
|
||||
pub(crate) const EVERY: ProfileFacts = ProfileFacts {
|
||||
stage_bound: StageBound::Every,
|
||||
half_pair_note: HalfPairNote::Every,
|
||||
reconvergence_note: ReconvergenceNote::Noted,
|
||||
snorm_minimum_note: SnormMinimumNote::Noted,
|
||||
narrow_wrap: NarrowWrap::Read,
|
||||
half_outputs: HalfOutputs::Widened,
|
||||
push_window: PushWindow::Floor,
|
||||
half_fma: HalfFma::Native,
|
||||
identity_region: IdentityRegion::Sized,
|
||||
oblivious_edge: ObliviousEdge::Grid,
|
||||
deep_threadgroups: DeepThreadgroups::OneRow,
|
||||
absent_reads: AbsentReads::Nil,
|
||||
threadgroup_memory: ThreadgroupMemory::Native,
|
||||
threadgroup_start: ThreadgroupStart::Zero,
|
||||
};
|
||||
}
|
||||
|
||||
/// Which narrow integer results (an `i8` or `i16` held in a wider container) clear the container's
|
||||
/// bits above their width after an operation that can set them: an add, subtract, multiply or
|
||||
/// shift left not marked `nuw`, a signed divide or remainder, an arithmetic shift right
|
||||
/// (`lower::arith::ops::int_binary`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum NarrowWrap {
|
||||
/// Every such result: `Device::new`'s profile.
|
||||
Every,
|
||||
/// Only a result whose high bits a use reads (`lower::arith::demand`): a use that reads only
|
||||
/// the low bits (another wrapping operation, a truncation, a sign extension) leaves them
|
||||
/// unread. `Device::from_queries`' profile.
|
||||
Read,
|
||||
}
|
||||
|
||||
/// How many bytes of push constants a kernel's push window holds (`lower::push::window`): the
|
||||
/// fields a kernel reads from push constants up to it, the rest from its `ArgumentTable`. Under
|
||||
/// the identity domains, vertex and fragment functions lower on the floor's window alone
|
||||
/// (`lower::select`'s `identity_admits`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum PushWindow {
|
||||
/// 128 bytes, what Vulkan guarantees (`maxPushConstantsSize`): `Device::new`'s profile.
|
||||
Guaranteed,
|
||||
/// 256 bytes, the new runtime's floor for `maxPushConstantsSize`, which every captured device
|
||||
/// reports: a dispatch region and 24 buffer addresses below a stage's tail
|
||||
/// (`lower::push::tail`). `Device::from_queries`' profile.
|
||||
Floor,
|
||||
}
|
||||
|
||||
/// How a kernel under the identity domains reads the base and Metal's threadgroup size `L` of its
|
||||
/// dispatch region (`lower::dispatch`'s `RegionSelect`). Either way the region's grid tells a
|
||||
/// region of a dispatch the host knows from an indirect dispatch, for the grid builtins.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum IdentityRegion {
|
||||
/// The grid selects them too: the region's base and nominal size where it states a grid, else
|
||||
/// 0 and the pipeline's size. The kernel declares no `MultiRegion`: `Device::new`'s profile.
|
||||
Grid,
|
||||
/// The base is the region's on every dispatch, and `L` is its nominal size where `MultiRegion`
|
||||
/// is 1, else the pipeline's, which the driver folds when it specializes: every dispatch the
|
||||
/// consumer launches at its pipeline's own size reads no decode. `Device::from_queries`'
|
||||
/// profile.
|
||||
Sized,
|
||||
}
|
||||
|
||||
/// How the partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) of a kernel that
|
||||
/// does not observe its threadgroup partition runs the threads a ragged grid's last threadgroups
|
||||
/// leave over (`lower::dispatch`'s grid edge). Such a kernel reads only `thread_position_in_grid`
|
||||
/// and `threads_per_grid`, so both forms run the same threads with the same answers.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ObliviousEdge {
|
||||
/// As any kernel's: where the region is flagged `NONUNIFORM`, the threadgroup runs Metal's
|
||||
/// partial threadgroup, its position in the threadgroup `lin` divided over the threads left.
|
||||
/// `Device::new`'s profile.
|
||||
Partial,
|
||||
/// Under the identity domains the variant runs its grid in tiles (`RuntimeFact::GridTiles`):
|
||||
/// each workgroup one power-of-two tile of the grid that its region gives, its positions
|
||||
/// masks and shifts of its local index, and an invocation past the grid returning before the
|
||||
/// body. `Device::from_queries`' profile.
|
||||
Grid,
|
||||
}
|
||||
|
||||
/// What a read of a texture, sampler or threadgroup memory argument the pipeline's function
|
||||
/// constants removed does beside taking zero (`lower::access::absent`). Metal gives such a read
|
||||
/// no value.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum AbsentReads {
|
||||
/// Where the read runs it sets `StatusBits::ABSENT_ARGUMENT_READ` in the command buffer's
|
||||
/// `ExecutionStatus` word, which the consumer reports as a failed execution:
|
||||
/// `Device::new`'s profile.
|
||||
Marked,
|
||||
/// It takes zero and writes no status word, a read's zeros and a query's size of 0 being
|
||||
/// what the nil texture, set 1's element 0, answers too: `Device::from_queries`' profile.
|
||||
Nil,
|
||||
}
|
||||
|
||||
/// Whether an access of threadgroup memory (a threadgroup arena's, `memory::arena`, its atomics,
|
||||
/// memory intrinsics, pointer cells and imageblock, and a typed threadgroup object's) is contained,
|
||||
/// and how a kernel's threadgroup arena holds its words when every access of it is a whole, aligned
|
||||
/// `float` word: a scalar `float`, or a vector of them, at an offset its alignment proves a
|
||||
/// multiple of its bytes, with no atomic, no memory intrinsic and no access of another type
|
||||
/// (`lower::access::local`'s `TgWords`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ThreadgroupMemory {
|
||||
/// Every access contained, as the profile's containment says (`lower::access::local`): a load
|
||||
/// past the arena reads zero and a store past it is dropped, and a typed object's dynamic index
|
||||
/// is clamped to its level. Every arena is a `u32` array whose words each access composes:
|
||||
/// `Device::new`'s profile.
|
||||
Contained,
|
||||
/// No access contained: one past the memory is undefined, as in Metal, and reads or writes
|
||||
/// what the device's access there does. An arena whose every access is a whole, aligned `float`
|
||||
/// word is a `float` array of its own words, each access one typed load or store per lane at
|
||||
/// its word index, with no branch and no bitcast: `Device::from_queries`' profile.
|
||||
Native,
|
||||
}
|
||||
|
||||
/// What a program's threadgroup memory holds before the program writes it: the words of the
|
||||
/// `Workgroup` variables that hold it, a function's threadgroup arena (its declared threadgroup
|
||||
/// variables, its `[[threadgroup(n)]]` arguments and its imageblock, `memory::arena`) and its
|
||||
/// typed threadgroup objects (`lower::access::local`). Metal's documents give threadgroup memory
|
||||
/// no first contents; an Apple GPU reads zero there.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ThreadgroupStart {
|
||||
/// Whatever the device's memory holds: no `Workgroup` variable has an initializer.
|
||||
/// `Device::new`'s profile.
|
||||
Unwritten,
|
||||
/// Zero: each of those variables has a null initializer, which needs
|
||||
/// `shaderZeroInitializeWorkgroupMemory` (a function that uses threadgroup memory on a
|
||||
/// profile without it is refused). The translator's own `Workgroup` words, which it writes
|
||||
/// before any read of them, have none. `Device::from_queries`' profile.
|
||||
Zero,
|
||||
}
|
||||
|
||||
/// How a kernel whose workgroup is its threadgroup (`lower::dispatch::LocalSizeForm::Spec`) runs
|
||||
/// a threadgroup deeper than the device's `maxComputeWorkGroupSize[2]`, and so what the device
|
||||
/// reports as Metal's `maxThreadsPerThreadgroup` (`MetalDeviceProperties`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum DeepThreadgroups {
|
||||
/// As its workgroup, axis for axis, so a device that holds fewer threads along `z` than the
|
||||
/// threadgroup refuses it at its plan (`bind::dispatch`'s local-size checks), and the device
|
||||
/// reports each axis's `maxComputeWorkGroupSize`: `Device::new`'s profile.
|
||||
Axes,
|
||||
/// As one row past [`DEEP_THREADGROUP`](crate::lower::dispatch::DEEP_THREADGROUP) along `z`
|
||||
/// (`SpecKey::DeepThreadgroup`), within every device's sizes, so the device reports
|
||||
/// `maxComputeWorkGroupInvocations` on every axis, as an Apple GPU reports 1024 on each:
|
||||
/// `Device::from_queries`' profile.
|
||||
OneRow,
|
||||
}
|
||||
|
||||
/// Which `half` fused multiply-adds take the device's 16-bit `Fma` (`lower::arith::fma::half_route`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum HalfFma {
|
||||
/// Those on a driver measured to compute it as Metal's `half` `fma`
|
||||
/// (`DriverDeviation::MetalHalfFma`), with no note; elsewhere `OpFmaKHR` on 16 bits where the
|
||||
/// profile has `shaderFmaFloat16` and computes `half` under the 16-bit float controls, else the
|
||||
/// device's `float` `Fma` rounded to `half`, noted `NativeFma`: `Device::new`'s profile.
|
||||
Measured,
|
||||
/// Every one where the profile computes `half` under the 16-bit float controls (it has
|
||||
/// `shaderFloat16`, and the controls that make a 16-bit conversion Metal's), noted `NativeFma`
|
||||
/// as the device's `Fma` is on every route; elsewhere the device's `float` `Fma` rounded to
|
||||
/// `half`, noted the same. `Device::from_queries`' profile, keyed on no identity.
|
||||
Native,
|
||||
}
|
||||
|
||||
/// How a `half` color output (a scalar or vector of AIR's `half`) reaches the device
|
||||
/// (`lower::stage_io`'s `half_variable`, `StageIo::half_outputs`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum HalfOutputs {
|
||||
/// Declared with 16-bit `float` lanes where the profile enables `storageInputOutput16` and
|
||||
/// `shaderFloat16`, so the device receives the `half` as Metal's attachment does; 32-bit, the
|
||||
/// `half` widened, elsewhere: `Device::new`'s profile.
|
||||
Sixteen,
|
||||
/// 32-bit on every device, the `half` widened to `float`, which holds every `half` exactly:
|
||||
/// `storageInputOutput16` is not a query that may choose a second form.
|
||||
/// `Device::from_queries`' profile.
|
||||
Widened,
|
||||
}
|
||||
|
||||
/// Whether a stage whose reconvergence is implementation-defined (`Reconvergence::ImplementationDefined`:
|
||||
/// a tangled instruction on a device without maximal reconvergence) records
|
||||
/// `PrecisionNote::DeviceReconvergence`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ReconvergenceNote {
|
||||
/// No note: the artifact's `reconvergence` field alone says it, which `metal2vulkan-runtime`
|
||||
/// announces as `ImplementationDefinedReconvergence`: `Device::new`'s profile.
|
||||
Field,
|
||||
/// The note, beside the field, a static note of the stage: `Device::from_queries`' profile.
|
||||
Noted,
|
||||
}
|
||||
|
||||
/// Whether a render pipeline that draws into a single-sampled color attachment records Metal's
|
||||
/// tile store as a note: `PrecisionNote::SnormMinimumKept` into a signed normalized format, whose
|
||||
/// minimum code Metal's pass stores as the code above it in each tile a draw reaches, and
|
||||
/// `PrecisionNote::SharedExponentKept` into `RGB9E5Float`, whose unnormalized words Metal's pass
|
||||
/// stores normalized; the device's pass keeps both.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum SnormMinimumNote {
|
||||
/// No note: `metal2vulkan-runtime` announces each at a draw in a pass that loads such an
|
||||
/// attachment, which only its encoder knows: `Device::new`'s profile.
|
||||
Announced,
|
||||
/// The note, a static note of the pipeline: `Device::from_queries`' profile.
|
||||
Noted,
|
||||
}
|
||||
|
||||
/// Where a module records `PrecisionNote::NativeHalfConversion` for a `half` it rounds through the
|
||||
/// device's conversion and its widening under the 16-bit float controls
|
||||
/// (`QuantizeForm::Controlled`), Metal's `half(float)` by the Vulkan spec.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum HalfPairNote {
|
||||
/// Only where the pair narrows the result of `f32` arithmetic on a driver that fuses that
|
||||
/// operation into the narrowing (`DriverWorkaround::HalfConversionFusedWithArithmetic`); a
|
||||
/// driver that folds the pair (`DriverWorkaround::HalfConversionPairFolded`) takes the
|
||||
/// `Converted` form, noted as such: `Device::new`'s profile.
|
||||
Fused,
|
||||
/// Every such module, on every device, a static note of the rounding: a driver's compiler may
|
||||
/// fold the pair into the value it started from or fuse the `f32` operation computing the
|
||||
/// value into the narrowing. `Device::from_queries`' profile, keyed on no identity.
|
||||
Every,
|
||||
}
|
||||
|
||||
/// Which stages a profile's compile holds under a stage bound (`pipeline::compile`'s stage
|
||||
/// bounds): the entry weight past which a module is not handed to the driver, a kernel planned
|
||||
/// again keeping the widest mode's pin where only its emulation passed it, and every other module
|
||||
/// refused.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum StageBound {
|
||||
/// Only where the profile names a stage-size defect of its driver
|
||||
/// (`DriverWorkaround::SerializedStageWrapsLargeModules`,
|
||||
/// `DriverWorkaround::CompilerMemoryGrowsWithStageSize`), refused as that defect
|
||||
/// (`Needs::DriverDefect`): `Device::new`'s profile.
|
||||
Defects,
|
||||
/// Every stage, on every device, at the heaviest entry measured to compile within host-sized
|
||||
/// memory (`pipeline::compile::COMPILED_STAGE_WEIGHT`), refused as `Needs::StageBound`:
|
||||
/// `Device::from_queries`' profile, keyed on no identity.
|
||||
Every,
|
||||
}
|
||||
|
||||
/// Every field of a profile, policy included. The fingerprint hashes all of them.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ProfileFields {
|
||||
@@ -889,8 +507,6 @@ pub struct ProfileFields {
|
||||
pub handle_domain: HandleDomain,
|
||||
pub containment: Containment,
|
||||
pub isolation: GuestIsolation,
|
||||
/// How a fast-math `half` chain rounds without `shaderFloat16` (`DevicePolicy::half_chains`).
|
||||
pub half_chains: crate::device::HalfChainPolicy,
|
||||
pub leaf: LeafCaps,
|
||||
pub subgroup: SubgroupModel,
|
||||
pub images: ImageCaps,
|
||||
@@ -935,9 +551,6 @@ pub struct ProfileFields {
|
||||
/// which its refresh reads across the bus once per encoder where the in-place form would read
|
||||
/// the planes there at every pass. Both forms read Metal's texels exactly.
|
||||
pub ycbcr_in_place: bool,
|
||||
/// How a sample of planes read in place converts and filters them
|
||||
/// (`DevicePolicy::ycbcr_in_place_reads`).
|
||||
pub ycbcr_in_place_reads: crate::device::YCbCrInPlacePolicy,
|
||||
/// The Function storage a thread holds correctly (`device::function_storage`): a stage's
|
||||
/// private memory, its call stacks included, may take this much a thread
|
||||
/// (`VkLimit::FunctionStorageBytesPerThread`), and a vertex or fragment function on a device
|
||||
@@ -1646,9 +1259,7 @@ pub enum DriverWorkaround {
|
||||
/// our bare-Vulkan probes: at `N` = 16 and 8, scalar and three lanes, every such program
|
||||
/// answered sign-extended, while `OpBitFieldUExtract(x, 0, N)` in place of the mask answered
|
||||
/// right; the RTX 5080 (Blackwell) on the same release answered every program right. Derived
|
||||
/// for NVIDIA's driver on the 3090's generation, GA10x
|
||||
/// ([`NVIDIA_AMPERE_GA10X`](crate::device::NVIDIA_AMPERE_GA10X)), which its compiler
|
||||
/// targets alike. Every narrow integer's mask in a 32-bit container is
|
||||
/// for NVIDIA's driver on the 3090's generation, GA10x, which its compiler targets alike. Every narrow integer's mask in a 32-bit container is
|
||||
/// emitted as `OpBitFieldUExtract(x, 0, N)` there (`lower::arith::ops::mask`), which is the
|
||||
/// same bits on every device.
|
||||
NarrowMaskAfterSignedClamp,
|
||||
|
||||
@@ -10,7 +10,6 @@ use crate::error::{DescriptorError, Error};
|
||||
use crate::vk;
|
||||
|
||||
mod description;
|
||||
mod driver_facts;
|
||||
mod enables;
|
||||
mod from_queries;
|
||||
mod host_identity;
|
||||
|
||||
@@ -197,7 +197,8 @@ fn rgba4_opaque_black_swizzled_follows_exposure() {
|
||||
);
|
||||
let d = DeviceDescription::from_khronos_json(&with, None).unwrap();
|
||||
assert!(d.rgba4_opaque_black_swizzled);
|
||||
let dev = crate::device::Device::new(d, crate::device::DevicePolicy::default()).unwrap();
|
||||
let dev =
|
||||
crate::device::Device::from_queries(d, crate::device::DevicePolicy::default()).unwrap();
|
||||
assert!(dev
|
||||
.profile()
|
||||
.fields()
|
||||
@@ -234,7 +235,8 @@ fn the_arm_spelling_of_rasterization_order_access_is_the_ext_one() {
|
||||
.extensions
|
||||
.contains(&VkExtension::ExtRasterizationOrderAttachmentAccess));
|
||||
assert!(d.has(VkFeature::RasterizationOrderColorAttachmentAccess));
|
||||
let dev = crate::device::Device::new(d, crate::device::DevicePolicy::default()).unwrap();
|
||||
let dev =
|
||||
crate::device::Device::from_queries(d, crate::device::DevicePolicy::default()).unwrap();
|
||||
assert!(
|
||||
dev.profile()
|
||||
.fields()
|
||||
@@ -798,10 +800,12 @@ fn required_features_are_cumulative() {
|
||||
#[cfg(feature = "serde")]
|
||||
#[test]
|
||||
fn descriptions_and_policies_round_trip_through_serde() {
|
||||
let policies = [
|
||||
DevicePolicy::default(),
|
||||
DevicePolicy::default().exact_answers(),
|
||||
];
|
||||
let unsafe_off = DevicePolicy {
|
||||
containment: crate::device::ContainmentPolicy::UnsafeOff,
|
||||
isolation: crate::device::profile::GuestIsolation::Off,
|
||||
..DevicePolicy::default()
|
||||
};
|
||||
let policies = [DevicePolicy::default(), unsafe_off];
|
||||
for (stem, text) in committed_profiles() {
|
||||
let description = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let json = serde_json::to_string(&description).unwrap();
|
||||
@@ -811,8 +815,8 @@ fn descriptions_and_policies_round_trip_through_serde() {
|
||||
let policy_json = serde_json::to_string(&policy).unwrap();
|
||||
let decoded_policy: DevicePolicy = serde_json::from_str(&policy_json).unwrap();
|
||||
assert_eq!(decoded_policy, policy, "{stem}");
|
||||
let original = Device::new(description.clone(), policy).unwrap();
|
||||
let rebuilt = Device::new(decoded.clone(), decoded_policy).unwrap();
|
||||
let original = Device::from_queries(description.clone(), policy).unwrap();
|
||||
let rebuilt = Device::from_queries(decoded.clone(), decoded_policy).unwrap();
|
||||
assert_eq!(
|
||||
rebuilt.profile().fingerprint(),
|
||||
original.profile().fingerprint(),
|
||||
|
||||
@@ -1,901 +0,0 @@
|
||||
//! The table of measured driver facts (`device::driver_facts`), keyed on the driver and its GPU
|
||||
//! at every release, and the runtime's facts each committed profile's driver has.
|
||||
|
||||
use crate::device::driver_facts::{among, Measured, MEASURED, NVIDIA_RTX_3090};
|
||||
use crate::device::{DeviceDescription, DriverFact};
|
||||
use crate::vk::DriverId;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::PathBuf;
|
||||
|
||||
const APPLE: u32 = 0x106B;
|
||||
|
||||
/// A driver has a fact at every release: a row of every GPU of the driver holds on any, a row of
|
||||
/// one vendor's GPUs on that vendor's alone, a row of one GPU on that GPU alone, and no row holds
|
||||
/// on another driver or a device that names none.
|
||||
#[test]
|
||||
fn a_fact_holds_on_its_driver_vendor_and_gpu_at_every_release() {
|
||||
let radv = Some(DriverId::MESA_RADV);
|
||||
let every = Measured {
|
||||
fact: 1u8,
|
||||
driver: DriverId::MESA_RADV,
|
||||
vendor: None,
|
||||
device: None,
|
||||
};
|
||||
let amd = Measured {
|
||||
vendor: Some(0x1002),
|
||||
..every
|
||||
};
|
||||
let gpu = Measured {
|
||||
device: Some(0x15bf),
|
||||
..amd
|
||||
};
|
||||
let at = |row: Measured<u8>, driver, identity| !among(&[row], driver, identity).is_empty();
|
||||
assert!(at(every, radv, (0x8086, 0x15bf)));
|
||||
assert!(at(amd, radv, (0x1002, 0x744c)));
|
||||
assert!(!at(amd, radv, (0x8086, 0x744c)));
|
||||
assert!(at(gpu, radv, (0x1002, 0x15bf)));
|
||||
assert!(!at(gpu, radv, (0x1002, 0x744c)));
|
||||
assert!(!at(every, Some(DriverId::MESA_LLVMPIPE), (0x1002, 0x15bf)));
|
||||
assert!(!at(every, None, (0x1002, 0x15bf)));
|
||||
}
|
||||
|
||||
/// The deviations a profile takes, read from the routes it derives, each as
|
||||
/// `DeviceProfile::takes_driver_deviation` answers it too.
|
||||
fn taken(p: &crate::device::DeviceProfile) -> Vec<crate::error::DriverDeviation> {
|
||||
use crate::device::profile::{CubeGradientRoute, FloatFunctions, NanEncoding};
|
||||
use crate::device::requirements::VkProperty;
|
||||
use crate::error::DriverDeviation as D;
|
||||
let f = p.fields();
|
||||
let property = |v| f.enabled.properties.contains(&v);
|
||||
let routes = (f.cube_gradients.graphics, f.cube_gradients.compute);
|
||||
[
|
||||
(
|
||||
D::SimdgroupLockstep,
|
||||
property(VkProperty::SimdgroupLockstep),
|
||||
),
|
||||
(
|
||||
D::MetalFloatFunctions,
|
||||
f.float_functions == FloatFunctions::Metal,
|
||||
),
|
||||
(
|
||||
D::MetalCanonicalNans,
|
||||
f.nan_encoding == NanEncoding::MetalCanonical,
|
||||
),
|
||||
(D::MetalSampler, property(VkProperty::MetalSampler)),
|
||||
(D::CubeGradientRoute, routes.1 == CubeGradientRoute::Metal),
|
||||
(
|
||||
D::GraphicsCubeGradientTangents,
|
||||
routes.0 == CubeGradientRoute::AppleProjected,
|
||||
),
|
||||
(D::MetalColorWrites, property(VkProperty::MetalColorWrites)),
|
||||
(
|
||||
D::MetalFloatColorNans,
|
||||
property(VkProperty::MetalFloatColorNans),
|
||||
),
|
||||
(D::MetalHalfFma, property(VkProperty::MetalHalfFma)),
|
||||
(
|
||||
D::MetalFloatDenormals,
|
||||
property(VkProperty::MetalFloatDenormals),
|
||||
),
|
||||
(
|
||||
D::MetalCenterVaryings,
|
||||
property(VkProperty::MetalCenterVaryings),
|
||||
),
|
||||
(
|
||||
D::MetalSmallFloatColorWrites,
|
||||
property(VkProperty::MetalSmallFloatColorWrites),
|
||||
),
|
||||
(
|
||||
D::MetalNorm16ColorWrites,
|
||||
property(VkProperty::MetalNorm16ColorWrites),
|
||||
),
|
||||
(D::MetalMinMax, property(VkProperty::MetalMinMax)),
|
||||
(
|
||||
D::MetalHalfArithmetic,
|
||||
property(VkProperty::MetalHalfArithmetic),
|
||||
),
|
||||
(
|
||||
D::MetalHalfStorageWrites,
|
||||
property(VkProperty::MetalHalfStorageWrites),
|
||||
),
|
||||
(
|
||||
D::MetalHalfStorageNans,
|
||||
property(VkProperty::MetalHalfStorageNans),
|
||||
),
|
||||
(
|
||||
D::MetalFragmentSimdgroups,
|
||||
property(VkProperty::MetalFragmentSimdgroups),
|
||||
),
|
||||
(
|
||||
D::MetalVertexSimdgroups,
|
||||
property(VkProperty::MetalVertexSimdgroups),
|
||||
),
|
||||
(
|
||||
D::CenterFragCoordDepth,
|
||||
property(VkProperty::CenterFragCoordDepth),
|
||||
),
|
||||
(
|
||||
D::SampleFragCoordDepth,
|
||||
property(VkProperty::SampleFragCoordDepth),
|
||||
),
|
||||
(
|
||||
D::MetalHalfTexelWrites,
|
||||
property(VkProperty::MetalHalfTexelWrites),
|
||||
),
|
||||
(
|
||||
D::MetalNormStorageWrites,
|
||||
property(VkProperty::MetalNormStorageWrites),
|
||||
),
|
||||
(
|
||||
D::MetalDepth16Stores,
|
||||
property(VkProperty::MetalDepth16Stores),
|
||||
),
|
||||
(
|
||||
D::MetalDepth16BiasedStores,
|
||||
property(VkProperty::MetalDepth16BiasedStores),
|
||||
),
|
||||
(
|
||||
D::MetalInterpolation,
|
||||
property(VkProperty::MetalInterpolation),
|
||||
),
|
||||
(
|
||||
D::MetalFirstVertexIndices,
|
||||
property(VkProperty::MetalFirstVertexIndices),
|
||||
),
|
||||
(D::MetalFullQuads, property(VkProperty::MetalFullQuads)),
|
||||
(
|
||||
D::MetalNormalizedVertexFetch,
|
||||
property(VkProperty::MetalNormalizedVertexFetch),
|
||||
),
|
||||
(
|
||||
D::MetalAlphaCoverage,
|
||||
property(VkProperty::MetalAlphaCoverage),
|
||||
),
|
||||
(D::MetalNanMoves, property(VkProperty::MetalNanMoves)),
|
||||
(
|
||||
D::MetalPackConversions,
|
||||
property(VkProperty::MetalPackConversions),
|
||||
),
|
||||
(
|
||||
D::MetalHalfConversion,
|
||||
property(VkProperty::MetalHalfConversion),
|
||||
),
|
||||
(
|
||||
D::MetalSmallFloatNans,
|
||||
property(VkProperty::MetalSmallFloatNans),
|
||||
),
|
||||
(
|
||||
D::MetalUnaryDenormals,
|
||||
property(VkProperty::MetalUnaryDenormals),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.inspect(|&(d, taken)| {
|
||||
// The public answer agrees with the routes (the gate lanes ask it).
|
||||
assert_eq!(p.takes_driver_deviation(d), taken, "{d:?}");
|
||||
})
|
||||
.filter_map(|(d, taken)| taken.then_some(d))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The deviations each committed profile takes are those its driver is measured with on its GPU,
|
||||
/// at every release: every Apple GPU's (MoltenVK's lockstep, `float` functions, canonical NaNs,
|
||||
/// sampler, compute cube route and the rest of the seventeen), with the graphics cube route and the
|
||||
/// per-sample depth of macOS 27's Apple9 identity, that identity's normalized
|
||||
/// storage writes, full quads, normalized vertex fetch, alpha to coverage, moved NaNs, pack conversions, half conversions, small-float NaN stores and unary denormals, and every Apple GPU's 16-bit unorm depth stores, interpolation
|
||||
/// and first-vertex indices; lavapipe's `float` color NaNs, half-float storage writes and
|
||||
/// small-float NaN stores; RADV's
|
||||
/// half-float storage writes on every GPU and its others on the Radeon 780M, ANV's on the Iris Xe
|
||||
/// of RPL-P and the UHD 770 of RPL-S, and NVIDIA's on the RTX 3090 and the RTX 5080 Laptop GPU, as
|
||||
/// measured there; the 8-bit linear filter's bound where measured. Every other committed profile
|
||||
/// takes none. MoltenVK on another
|
||||
/// vendor's GPU takes none, its cube routes unmeasured; another driver on Apple's vendor takes its
|
||||
/// own driver's rows, with Vulkan's cube rule. `InterpolateAtOffsetCentered` follows the driver alone.
|
||||
#[test]
|
||||
fn the_profile_takes_the_deviations_its_driver_is_measured_with() {
|
||||
use crate::device::profile::{CubeGradientRoute, CubeGradients};
|
||||
use crate::device::requirements::VkProperty;
|
||||
use crate::device::{Device, DevicePolicy};
|
||||
use crate::error::DriverDeviation as D;
|
||||
use crate::spirv::testing::is_moltenvk_capture;
|
||||
// The seventeen of every Apple GPU measured, and the M3 Max's graphics cube route.
|
||||
let apple = vec![
|
||||
D::SimdgroupLockstep,
|
||||
D::MetalFloatFunctions,
|
||||
D::MetalCanonicalNans,
|
||||
D::MetalSampler,
|
||||
D::CubeGradientRoute,
|
||||
D::MetalColorWrites,
|
||||
D::MetalHalfFma,
|
||||
D::MetalFloatDenormals,
|
||||
D::MetalCenterVaryings,
|
||||
D::MetalMinMax,
|
||||
D::MetalHalfArithmetic,
|
||||
D::MetalHalfStorageWrites,
|
||||
D::MetalHalfStorageNans,
|
||||
D::MetalFragmentSimdgroups,
|
||||
D::MetalVertexSimdgroups,
|
||||
];
|
||||
// NVIDIA's 615.71.09 on the RTX 3090 and the RTX 5080 Laptop GPU: the color-NaN stores, the
|
||||
// `float` denormals, the half-float storage writes, and the half texel writes' NaN bits.
|
||||
let nvidia_measured = vec![
|
||||
D::MetalFloatColorNans,
|
||||
D::MetalFloatDenormals,
|
||||
D::MetalHalfStorageWrites,
|
||||
D::MetalHalfTexelWrites,
|
||||
];
|
||||
// In `taken`'s order: the graphics route of the identity both chips share under macOS 27
|
||||
// before the color writes, and its per-sample depth last.
|
||||
let mut m4_measured = apple.clone();
|
||||
m4_measured.insert(5, D::GraphicsCubeGradientTangents);
|
||||
m4_measured.push(D::CenterFragCoordDepth);
|
||||
// The M4's identity's normalized storage writes, measured on it alone.
|
||||
m4_measured.push(D::MetalNormStorageWrites);
|
||||
// Every Apple GPU's 16-bit unorm depth, unbiased and biased, its interpolation and its
|
||||
// first-vertex indices, last in `taken`'s order.
|
||||
let mut apple_all = apple.clone();
|
||||
for list in [&mut m4_measured, &mut apple_all] {
|
||||
list.push(D::MetalDepth16Stores);
|
||||
list.push(D::MetalDepth16BiasedStores);
|
||||
list.push(D::MetalInterpolation);
|
||||
list.push(D::MetalFirstVertexIndices);
|
||||
}
|
||||
// macOS 27's full quads, measured on the M4's identity alone, and its normalized vertex
|
||||
// fetch, alpha to coverage, moved NaNs, pack conversions, half conversions, small-float NaN
|
||||
// stores and unary denormals, measured on the M3 Max under it.
|
||||
m4_measured.push(D::MetalFullQuads);
|
||||
m4_measured.push(D::MetalNormalizedVertexFetch);
|
||||
m4_measured.push(D::MetalAlphaCoverage);
|
||||
m4_measured.push(D::MetalNanMoves);
|
||||
m4_measured.push(D::MetalPackConversions);
|
||||
m4_measured.push(D::MetalHalfConversion);
|
||||
m4_measured.push(D::MetalSmallFloatNans);
|
||||
m4_measured.push(D::MetalUnaryDenormals);
|
||||
let all_of = |d: &DeviceDescription| match d.device_id {
|
||||
crate::device::driver_facts::APPLE9 => m4_measured.clone(),
|
||||
_ => apple_all.clone(),
|
||||
};
|
||||
let profile_of = |d: DeviceDescription| {
|
||||
Device::new(d, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
};
|
||||
let centered = |p: &crate::device::DeviceProfile| {
|
||||
p.fields()
|
||||
.enabled
|
||||
.properties
|
||||
.contains(&VkProperty::InterpolateAtOffsetCentered)
|
||||
};
|
||||
let committed = super::committed_profiles();
|
||||
assert!(committed.len() > 10);
|
||||
for (stem, _) in &committed {
|
||||
let d = super::profile(stem);
|
||||
let want_all = all_of(&d);
|
||||
let p = profile_of(d);
|
||||
let moltenvk = is_moltenvk_capture(stem);
|
||||
let want = match (moltenvk, stem.as_str()) {
|
||||
(true, _) => want_all,
|
||||
(false, "nvidia-rtx5080-laptop") => nvidia_measured.clone(),
|
||||
(false, "lavapipe" | "gate-lavapipe" | "gate-lavapipe-x86_64") => {
|
||||
vec![
|
||||
D::MetalFloatColorNans,
|
||||
D::MetalHalfStorageWrites,
|
||||
D::MetalSmallFloatNans,
|
||||
]
|
||||
}
|
||||
// The per-sample `FragCoord.z` last, in `taken`'s order. The 780M under Phoenix's
|
||||
// `deviceID` and Hawk Point's alike.
|
||||
(false, "amd-780m-radv" | "amd-780m-hawkpoint-radv") => vec![
|
||||
D::MetalFloatDenormals,
|
||||
D::MetalSmallFloatColorWrites,
|
||||
D::MetalNorm16ColorWrites,
|
||||
D::MetalHalfStorageWrites,
|
||||
D::SampleFragCoordDepth,
|
||||
D::MetalHalfTexelWrites,
|
||||
D::MetalNormStorageWrites,
|
||||
D::MetalDepth16Stores,
|
||||
],
|
||||
// RADV's driver-wide row alone on the RADV GPUs no other row names.
|
||||
(false, "amd-rdna3-radv" | "amd-rdna2-apu-radv") => vec![D::MetalHalfStorageWrites],
|
||||
(false, "intel-irisxe-rplp-anv") => vec![
|
||||
D::MetalFloatDenormals,
|
||||
D::MetalSmallFloatColorWrites,
|
||||
D::MetalHalfStorageWrites,
|
||||
D::MetalDepth16Stores,
|
||||
],
|
||||
(false, "intel-uhd770-rpls-anv") => vec![
|
||||
D::MetalFloatDenormals,
|
||||
D::MetalSmallFloatColorWrites,
|
||||
D::MetalHalfStorageWrites,
|
||||
D::MetalDepth16Stores,
|
||||
],
|
||||
(false, _) => Vec::new(),
|
||||
};
|
||||
assert_eq!(taken(&p), want, "{stem}");
|
||||
assert_eq!(centered(&p), !moltenvk, "{stem}");
|
||||
}
|
||||
let m3 = super::profile("moltenvk-m3");
|
||||
assert_eq!(
|
||||
(m3.driver_id, m3.vendor_id, m3.device_id),
|
||||
(
|
||||
Some(DriverId::MOLTENVK),
|
||||
APPLE,
|
||||
crate::device::driver_facts::APPLE9
|
||||
)
|
||||
);
|
||||
// macOS 27's graphics cube route is the fixup's projected form, its compute route Metal's.
|
||||
assert_eq!(
|
||||
profile_of(m3.clone()).fields().cube_gradients,
|
||||
CubeGradients {
|
||||
graphics: CubeGradientRoute::AppleProjected,
|
||||
compute: CubeGradientRoute::Metal,
|
||||
}
|
||||
);
|
||||
// Every release of the driver takes the same.
|
||||
for version in [10400, 10401, 10402, 10403] {
|
||||
let mut other = m3.clone();
|
||||
other.driver_version = version;
|
||||
let p = profile_of(other);
|
||||
assert_eq!(taken(&p), m4_measured, "{version}");
|
||||
assert!(!centered(&p), "{version}");
|
||||
}
|
||||
// Another vendor's GPU: none, the cube routes unmeasured and so Vulkan's rule.
|
||||
let vulkan = CubeGradients {
|
||||
graphics: CubeGradientRoute::Vulkan,
|
||||
compute: CubeGradientRoute::Vulkan,
|
||||
};
|
||||
let mut intel = m3.clone();
|
||||
intel.vendor_id = 0x8086;
|
||||
let p = profile_of(intel);
|
||||
assert_eq!(taken(&p), Vec::new());
|
||||
assert_eq!(p.fields().cube_gradients, vulkan);
|
||||
assert!(!centered(&p));
|
||||
// Another driver on Apple's vendor: that driver's rows of every GPU (lavapipe's), with
|
||||
// Vulkan's rule and a centered offset.
|
||||
let mut lavapipe = m3;
|
||||
lavapipe.driver_id = Some(DriverId::MESA_LLVMPIPE);
|
||||
let p = profile_of(lavapipe);
|
||||
assert_eq!(
|
||||
taken(&p),
|
||||
[
|
||||
D::MetalFloatColorNans,
|
||||
D::MetalHalfStorageWrites,
|
||||
D::MetalSmallFloatNans
|
||||
]
|
||||
);
|
||||
assert_eq!(p.fields().cube_gradients, vulkan);
|
||||
assert!(centered(&p));
|
||||
// NVIDIA's color-NaN stores and `float` denormals: per GPU (the 3090 and the 5080 Laptop
|
||||
// GPU, not another RTX 50), at every release; the small float color writes the 3090's alone.
|
||||
use crate::device::driver_facts::NVIDIA_RTX_5080_LAPTOP;
|
||||
let laptop = super::profile("nvidia-rtx5080-laptop");
|
||||
assert_eq!(laptop.device_id, NVIDIA_RTX_5080_LAPTOP);
|
||||
let mut rtx_3090 = laptop.clone();
|
||||
rtx_3090.device_id = NVIDIA_RTX_3090;
|
||||
let mut desktop = laptop.clone();
|
||||
desktop.device_id = 0x2c02;
|
||||
let mut later = laptop.clone();
|
||||
later.driver_version += 1 << 6;
|
||||
let mut rtx_3090_measured = nvidia_measured.clone();
|
||||
rtx_3090_measured.insert(2, D::MetalSmallFloatColorWrites);
|
||||
assert_eq!(taken(&profile_of(rtx_3090)), rtx_3090_measured);
|
||||
assert_eq!(taken(&profile_of(desktop)), Vec::new());
|
||||
assert_eq!(taken(&profile_of(later)), nvidia_measured);
|
||||
}
|
||||
|
||||
const ZERO: DriverFact = DriverFact::RobustIndexFetchReadsZero;
|
||||
const DENORMALS: DriverFact = DriverFact::DepthImageKeepsDenormals;
|
||||
const FRAGDEPTH: DriverFact = DriverFact::FragmentDepthStoresUnchanged;
|
||||
const APART: DriverFact = DriverFact::DepthStencilImagesLieApart;
|
||||
const AVERAGE: DriverFact = DriverFact::ColorResolveAverageIsMetals;
|
||||
const CLEAR: DriverFact = DriverFact::ColorClearIsMetals;
|
||||
const HIDE: DriverFact = DriverFact::CompressedImagesHideAliasedWrites;
|
||||
const HOST: DriverFact = DriverFact::HostTransferImagesKeepTheirBytes;
|
||||
const OPTIMIZED: DriverFact = DriverFact::DepthStencilImagesStayGpuOptimized;
|
||||
const DEPTH16: DriverFact = DriverFact::FragmentDepthKeepsDepth16Codes;
|
||||
const FETCH: DriverFact = DriverFact::SampledFetchRecoversCodes;
|
||||
const SPLIT: DriverFact = DriverFact::InterlockedPassSplitNoSlower;
|
||||
const UNSTORED_CLEAR: DriverFact = DriverFact::UnstoredClearNoSlower;
|
||||
const RESTART: DriverFact = DriverFact::DynamicRestartWarns;
|
||||
const DONT_CARE: DriverFact = DriverFact::DontCareStoreIsMetals;
|
||||
const STAMPS: DriverFact = DriverFact::TimestampsWaitForEveryQueue;
|
||||
const COLOR_BLOCKS: DriverFact = DriverFact::ColorBlockDecodeIsMetals;
|
||||
const CHANNEL_BLOCKS: DriverFact = DriverFact::ChannelBlockDecodeIsMetals;
|
||||
const PLANES: DriverFact = DriverFact::PositionedDepthReadAtStandardPositions;
|
||||
const TESTS_DENORMALS: DriverFact = DriverFact::DepthTestKeepsDenormals;
|
||||
const TESTS_MAGNITUDES: DriverFact = DriverFact::DepthTestComparesMagnitudes;
|
||||
const SPARSE_WAIT: DriverFact = DriverFact::FirstSparseResourceWaitsForQueues;
|
||||
const BC6H: DriverFact = DriverFact::Bc6hBlockDecodeIsMetals;
|
||||
const BC7: DriverFact = DriverFact::Bc7BlockDecodeIsMetals;
|
||||
const SCARCE_POOLS: DriverFact = DriverFact::TimestampPoolsAreCounterSampleBuffers;
|
||||
const ONE_OF_METALS: DriverFact = DriverFact::DontCareStoreIsOneOfMetals;
|
||||
const COPY_BACK: DriverFact = DriverFact::ShadowCopyBackDispatchFaster;
|
||||
const COPY_IN: DriverFact = DriverFact::ShadowCopyInDispatchFaster;
|
||||
const ROWS: DriverFact = DriverFact::RowCopiesDispatchFaster;
|
||||
const MESSENGER: DriverFact = DriverFact::QueueFailuresReportedByMessenger;
|
||||
const STALL: DriverFact = DriverFact::SemaphoreOperationsStallSubmits;
|
||||
const STALL_1024: DriverFact = DriverFact::SignallingSubmitsStallEvery1024;
|
||||
const SAMPLED_HIZ: DriverFact = DriverFact::SampledDepthKeepsHiZ;
|
||||
const MSAA_DEPTH: DriverFact = DriverFact::MultisampledDepthFasterOutOfGeneral;
|
||||
const TILE_STORE: DriverFact = DriverFact::TileStoreIsMetals;
|
||||
const INTERLOCK_ORDER: DriverFact = DriverFact::InterlockOrdersDraws;
|
||||
const INTERLOCK_RACE: DriverFact = DriverFact::InterlockedDrawsRaceUnderLoad;
|
||||
const BLENDLESS: DriverFact = DriverFact::BlendlessColorAttachmentsWarn;
|
||||
const HEAP_COLORS: DriverFact = DriverFact::ColorImagesLieAsMetalHeapTextures;
|
||||
const HEAP_MULTISAMPLE_COLORS: DriverFact =
|
||||
DriverFact::MultisampleColorImagesLieAsMetalHeapTextures;
|
||||
const LINE_TIES: DriverFact = DriverFact::LineTiesAreMetals;
|
||||
const SUBPIXEL_SNAP: DriverFact = DriverFact::SubpixelSnapIsMetals;
|
||||
const CLEARED_DEPTH: DriverFact = DriverFact::ClearedDepthAtStandardPositions;
|
||||
const PLAIN_HOLDS: DriverFact = DriverFact::PlainAllocationsHoldSubmissions;
|
||||
|
||||
/// Each committed profile's driver has the runtime's driver facts its rows name, on its vendor and
|
||||
/// GPU, at its release as at any other.
|
||||
#[test]
|
||||
fn the_committed_profiles_drivers_have_their_facts() {
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles");
|
||||
let mut claims = BTreeMap::new();
|
||||
for path in std::fs::read_dir(&dir).expect("validation/profiles is readable") {
|
||||
let path = path.expect("directory entry").path();
|
||||
if path.extension().is_none_or(|x| x != "json") {
|
||||
continue;
|
||||
}
|
||||
let text = std::fs::read_to_string(&path).expect("profile is readable");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("profile parses");
|
||||
let facts: Vec<_> = desc.driver_facts().into_iter().collect();
|
||||
if !facts.is_empty() {
|
||||
let stem = path.file_stem().unwrap().to_string_lossy().into_owned();
|
||||
claims.insert(stem, facts);
|
||||
}
|
||||
}
|
||||
let expected: BTreeMap<String, Vec<DriverFact>> = [
|
||||
(
|
||||
"amd-780m-hawkpoint-radv",
|
||||
vec![
|
||||
ZERO,
|
||||
FETCH,
|
||||
SPLIT,
|
||||
UNSTORED_CLEAR,
|
||||
COLOR_BLOCKS,
|
||||
BC6H,
|
||||
BC7,
|
||||
ONE_OF_METALS,
|
||||
PLAIN_HOLDS,
|
||||
],
|
||||
),
|
||||
(
|
||||
"amd-780m-radv",
|
||||
vec![
|
||||
ZERO,
|
||||
FETCH,
|
||||
SPLIT,
|
||||
UNSTORED_CLEAR,
|
||||
COLOR_BLOCKS,
|
||||
BC6H,
|
||||
BC7,
|
||||
ONE_OF_METALS,
|
||||
PLAIN_HOLDS,
|
||||
],
|
||||
),
|
||||
("amd-rdna2-apu-radv", vec![ZERO]),
|
||||
("amd-rdna3-radv", vec![ZERO]),
|
||||
(
|
||||
"gate-lavapipe",
|
||||
vec![DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H],
|
||||
),
|
||||
(
|
||||
"gate-lavapipe-x86_64",
|
||||
vec![DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H],
|
||||
),
|
||||
(
|
||||
"intel-arl-anv",
|
||||
vec![HIDE, HOST, SPARSE_WAIT, COPY_BACK, ROWS],
|
||||
),
|
||||
(
|
||||
"intel-irisxe-anv",
|
||||
vec![HIDE, HOST, SPARSE_WAIT, COPY_BACK, ROWS],
|
||||
),
|
||||
(
|
||||
"intel-irisxe-rplp-anv",
|
||||
vec![
|
||||
HIDE,
|
||||
HOST,
|
||||
FETCH,
|
||||
SPLIT,
|
||||
SPARSE_WAIT,
|
||||
BC6H,
|
||||
BC7,
|
||||
ONE_OF_METALS,
|
||||
COPY_BACK,
|
||||
ROWS,
|
||||
SAMPLED_HIZ,
|
||||
MSAA_DEPTH,
|
||||
INTERLOCK_ORDER,
|
||||
],
|
||||
),
|
||||
(
|
||||
"intel-uhd770-rpls-anv",
|
||||
vec![
|
||||
ZERO,
|
||||
HIDE,
|
||||
HOST,
|
||||
FETCH,
|
||||
SPLIT,
|
||||
SPARSE_WAIT,
|
||||
ONE_OF_METALS,
|
||||
COPY_BACK,
|
||||
COPY_IN,
|
||||
ROWS,
|
||||
],
|
||||
),
|
||||
("lavapipe", vec![DENORMALS, FRAGDEPTH, DEPTH16, FETCH, BC6H]),
|
||||
(
|
||||
"moltenvk-m3",
|
||||
vec![
|
||||
DENORMALS,
|
||||
APART,
|
||||
AVERAGE,
|
||||
CLEAR,
|
||||
OPTIMIZED,
|
||||
DEPTH16,
|
||||
FETCH,
|
||||
SPLIT,
|
||||
UNSTORED_CLEAR,
|
||||
RESTART,
|
||||
BLENDLESS,
|
||||
DONT_CARE,
|
||||
STAMPS,
|
||||
COLOR_BLOCKS,
|
||||
CHANNEL_BLOCKS,
|
||||
TESTS_DENORMALS,
|
||||
TESTS_MAGNITUDES,
|
||||
BC6H,
|
||||
BC7,
|
||||
SCARCE_POOLS,
|
||||
MESSENGER,
|
||||
TILE_STORE,
|
||||
INTERLOCK_RACE,
|
||||
HEAP_COLORS,
|
||||
HEAP_MULTISAMPLE_COLORS,
|
||||
LINE_TIES,
|
||||
SUBPIXEL_SNAP,
|
||||
],
|
||||
),
|
||||
("nvidia-pascal-linux", vec![DENORMALS, PLANES]),
|
||||
("nvidia-rtx50-linux", vec![DENORMALS, PLANES]),
|
||||
(
|
||||
"nvidia-rtx5080-laptop",
|
||||
vec![
|
||||
ZERO, DENORMALS, FETCH, SPLIT, PLANES, BC6H, BC7, ROWS, STALL, STALL_1024,
|
||||
],
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(stem, facts)| (stem.to_owned(), facts))
|
||||
.collect();
|
||||
assert_eq!(claims, expected);
|
||||
}
|
||||
|
||||
/// One GPU that reports more than one `deviceID` takes its measured rows under each: the Radeon
|
||||
/// 780M of Hawk Point (0x1900) is Phoenix's (0x15bf), so a RADV description of it has Phoenix's
|
||||
/// driver facts, deviations and defects, and derives Phoenix's profile, its Function storage among
|
||||
/// it, and fingerprint, at every release. A neighbouring `deviceID` (0x1901), or 0x1900 of another
|
||||
/// vendor, is another GPU: it takes only the rows of every GPU of the driver.
|
||||
#[test]
|
||||
fn a_gpu_under_another_of_its_device_ids_takes_its_measured_rows() {
|
||||
use crate::device::driver_facts::{defects, deviations};
|
||||
use crate::device::{Device, DevicePolicy, FunctionStorage};
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles");
|
||||
let text = std::fs::read_to_string(dir.join("amd-780m-radv.json")).expect("amd-780m-radv");
|
||||
let phoenix = DeviceDescription::from_khronos_json(&text, None).expect("profile parses");
|
||||
let profile = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.expect("the device is made")
|
||||
.profile()
|
||||
.clone()
|
||||
};
|
||||
let mut hawk_point = phoenix.clone();
|
||||
hawk_point.device_id = 0x1900;
|
||||
assert_eq!(phoenix.canonical_device_id(), 0x15bf);
|
||||
assert_eq!(hawk_point.canonical_device_id(), 0x15bf);
|
||||
assert!(!hawk_point.driver_facts().is_empty());
|
||||
assert_eq!(hawk_point.driver_facts(), phoenix.driver_facts());
|
||||
assert!(!deviations(&hawk_point).is_empty());
|
||||
assert_eq!(deviations(&hawk_point), deviations(&phoenix));
|
||||
assert_eq!(defects(&hawk_point), defects(&phoenix));
|
||||
assert_eq!(
|
||||
profile(&hawk_point).fields().function_storage,
|
||||
FunctionStorage::Measured(96 * 1024)
|
||||
);
|
||||
assert_eq!(
|
||||
profile(&hawk_point).fingerprint(),
|
||||
profile(&phoenix).fingerprint()
|
||||
);
|
||||
|
||||
let mut later = hawk_point.clone();
|
||||
later.driver_version += 1;
|
||||
assert_eq!(later.driver_facts(), phoenix.driver_facts());
|
||||
assert_eq!(deviations(&later), deviations(&phoenix));
|
||||
|
||||
let mut neighbour = hawk_point.clone();
|
||||
neighbour.device_id = 0x1901;
|
||||
let mut other_vendor = hawk_point.clone();
|
||||
other_vendor.vendor_id = 0x8086;
|
||||
for (desc, device) in [(&neighbour, 0x1901), (&other_vendor, 0x1900)] {
|
||||
assert_eq!(desc.canonical_device_id(), device);
|
||||
assert!(
|
||||
desc.driver_facts().len() < phoenix.driver_facts().len(),
|
||||
"{device:#x}"
|
||||
);
|
||||
}
|
||||
assert!(deviations(&neighbour).len() < deviations(&phoenix).len());
|
||||
assert_eq!(
|
||||
profile(&neighbour).fields().function_storage,
|
||||
FunctionStorage::Assumed(16 * 1024)
|
||||
);
|
||||
}
|
||||
|
||||
/// NVIDIA's driver stalls a submission about once in every thousand semaphore operations on the
|
||||
/// two GPUs measured, the RTX 5080 Laptop GPU and the RTX 3090, which take the fact at every
|
||||
/// release; another GPU of the driver (an RTX 5080 desktop GPU) does not, so it waits for
|
||||
/// completed timelines as every other driver does. No other driver has it.
|
||||
#[test]
|
||||
fn nvidia_s_semaphore_stall_holds_on_the_gpus_measured() {
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles");
|
||||
let read = |stem: &str| {
|
||||
let text = std::fs::read_to_string(dir.join(format!("{stem}.json"))).expect(stem);
|
||||
DeviceDescription::from_khronos_json(&text, None).expect("profile parses")
|
||||
};
|
||||
let laptop = read("nvidia-rtx5080-laptop");
|
||||
assert!(laptop.driver_facts().contains(&STALL));
|
||||
let mut rtx_3090 = laptop.clone();
|
||||
rtx_3090.device_id = NVIDIA_RTX_3090;
|
||||
assert!(rtx_3090.driver_facts().contains(&STALL));
|
||||
let mut desktop = laptop.clone();
|
||||
desktop.device_id = 0x2c02;
|
||||
assert!(!desktop.driver_facts().contains(&STALL));
|
||||
let mut later = laptop.clone();
|
||||
later.driver_version += 1 << 6;
|
||||
assert!(later.driver_facts().contains(&STALL));
|
||||
let drivers: Vec<DriverId> = MEASURED
|
||||
.iter()
|
||||
.filter(|row| row.fact == STALL)
|
||||
.map(|row| row.driver)
|
||||
.collect();
|
||||
assert_eq!(drivers, [DriverId::NVIDIA_PROPRIETARY; 2]);
|
||||
}
|
||||
|
||||
/// NVIDIA's image uses that miss a buffer's write in the same `VkCommandBuffer`: on the GPU
|
||||
/// measured with them, the RTX 3090 (620.70.06), at every release; not on the RTX 5080 Laptop
|
||||
/// GPU, measured without them (615.71.09), nor an RTX 5080 desktop GPU, not measured, nor any
|
||||
/// other driver.
|
||||
#[test]
|
||||
fn nvidia_s_image_uses_missing_buffer_writes_hold_on_the_gpu_measured() {
|
||||
let fact = DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer;
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles");
|
||||
let read = |stem: &str| {
|
||||
let text = std::fs::read_to_string(dir.join(format!("{stem}.json"))).expect(stem);
|
||||
DeviceDescription::from_khronos_json(&text, None).expect("profile parses")
|
||||
};
|
||||
let laptop = read("nvidia-rtx5080-laptop");
|
||||
assert!(!laptop.driver_facts().contains(&fact));
|
||||
let mut rtx_3090 = laptop.clone();
|
||||
rtx_3090.device_id = NVIDIA_RTX_3090;
|
||||
assert!(rtx_3090.driver_facts().contains(&fact));
|
||||
let mut later = rtx_3090.clone();
|
||||
later.driver_version += 1 << 6;
|
||||
assert!(later.driver_facts().contains(&fact));
|
||||
let mut desktop = laptop.clone();
|
||||
desktop.device_id = 0x2c02;
|
||||
assert!(!desktop.driver_facts().contains(&fact));
|
||||
let rows: Vec<_> = MEASURED.iter().filter(|row| row.fact == fact).collect();
|
||||
assert_eq!(rows.len(), 1);
|
||||
assert_eq!(rows[0].driver, DriverId::NVIDIA_PROPRIETARY);
|
||||
assert_eq!(rows[0].device, Some(NVIDIA_RTX_3090));
|
||||
}
|
||||
|
||||
/// NVIDIA's driver stalls in one signalling submission of every 1024 to a queue on the GPU
|
||||
/// measured, the RTX 5080 Laptop GPU, at every release, so the runtime takes that stall while
|
||||
/// idle there; the RTX 3090 and an RTX 5080 desktop GPU, not measured in that form, do not take
|
||||
/// the fact, nor does RADV, measured without it, or any other driver.
|
||||
#[test]
|
||||
fn nvidia_s_every_1024th_signalling_submit_stall_holds_on_the_gpu_measured() {
|
||||
use crate::device::driver_facts::NVIDIA_RTX_5080_LAPTOP;
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles");
|
||||
let read = |stem: &str| {
|
||||
let text = std::fs::read_to_string(dir.join(format!("{stem}.json"))).expect(stem);
|
||||
DeviceDescription::from_khronos_json(&text, None).expect("profile parses")
|
||||
};
|
||||
let laptop = read("nvidia-rtx5080-laptop");
|
||||
assert!(laptop.driver_facts().contains(&STALL_1024));
|
||||
let mut later = laptop.clone();
|
||||
later.driver_version += 1 << 6;
|
||||
assert!(later.driver_facts().contains(&STALL_1024));
|
||||
let mut rtx_3090 = laptop.clone();
|
||||
rtx_3090.device_id = NVIDIA_RTX_3090;
|
||||
assert!(!rtx_3090.driver_facts().contains(&STALL_1024));
|
||||
let mut desktop = laptop.clone();
|
||||
desktop.device_id = 0x2c02;
|
||||
assert!(!desktop.driver_facts().contains(&STALL_1024));
|
||||
for stem in [
|
||||
"amd-rdna3-radv",
|
||||
"moltenvk-m3",
|
||||
"intel-irisxe-rplp-anv",
|
||||
"lavapipe",
|
||||
] {
|
||||
assert!(!read(stem).driver_facts().contains(&STALL_1024), "{stem}");
|
||||
}
|
||||
let rows: Vec<(DriverId, Option<u32>)> = MEASURED
|
||||
.iter()
|
||||
.filter(|row| row.fact == STALL_1024)
|
||||
.map(|row| (row.driver, row.device))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
rows,
|
||||
[(DriverId::NVIDIA_PROPRIETARY, Some(NVIDIA_RTX_5080_LAPTOP))]
|
||||
);
|
||||
}
|
||||
|
||||
/// RADV on a GPU no row names takes RADV's driver-wide fact alone: the Radeon 780M's own
|
||||
/// description presented under a `deviceID` no table names (0x1114) reads zero past a bound index
|
||||
/// range, as RADV does on every GPU, and takes no answer measured on the 780M alone (its block
|
||||
/// decodes, `DONT_CARE` stores, interlocked split, sampled fetch, plain allocations that hold its
|
||||
/// submissions), at another release too. Under
|
||||
/// the RX 7900 XTX's (0x744c) it takes the one answer measured there too, BC1 to BC3's block
|
||||
/// decode, and none of the 780M's others; under the RX 550's (0x699f) the one answer measured
|
||||
/// there, a cleared depth at the standard positions. Whether its submissions merge and whether a
|
||||
/// held pointer import costs its submissions are no facts of the table: the runtime's device
|
||||
/// checks answer them on each device (`submit_check.rs` in the runtime), so a GPU no row names
|
||||
/// takes those paths too.
|
||||
#[test]
|
||||
fn a_radv_gpu_no_row_names_takes_radv_s_driver_wide_fact_alone() {
|
||||
use crate::device::driver_facts::{AMD_RX_550, AMD_RX_7900_XTX};
|
||||
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../metal2vulkan-validation/profiles");
|
||||
let text = std::fs::read_to_string(dir.join("amd-780m-radv.json")).expect("amd-780m-radv");
|
||||
let phoenix = DeviceDescription::from_khronos_json(&text, None).expect("profile parses");
|
||||
let answers = BTreeSet::from([
|
||||
FETCH,
|
||||
SPLIT,
|
||||
UNSTORED_CLEAR,
|
||||
COLOR_BLOCKS,
|
||||
BC6H,
|
||||
BC7,
|
||||
ONE_OF_METALS,
|
||||
PLAIN_HOLDS,
|
||||
]);
|
||||
let measured = BTreeSet::from([DriverFact::RobustIndexFetchReadsZero]);
|
||||
assert_eq!(
|
||||
phoenix.driver_facts(),
|
||||
answers.union(&measured).copied().collect()
|
||||
);
|
||||
let xtx = BTreeSet::from([DriverFact::RobustIndexFetchReadsZero, COLOR_BLOCKS]);
|
||||
let rx550 = BTreeSet::from([DriverFact::RobustIndexFetchReadsZero, CLEARED_DEPTH]);
|
||||
for (device_id, facts) in [
|
||||
(AMD_RX_7900_XTX, &xtx),
|
||||
(AMD_RX_550, &rx550),
|
||||
(0x1114, &measured),
|
||||
] {
|
||||
let mut unlisted = phoenix.clone();
|
||||
unlisted.device_id = device_id;
|
||||
assert_eq!(&unlisted.driver_facts(), facts, "{device_id:#x}");
|
||||
let mut other = unlisted.clone();
|
||||
other.driver_version += 1;
|
||||
assert_eq!(&other.driver_facts(), facts, "{device_id:#x}");
|
||||
}
|
||||
}
|
||||
|
||||
/// MoltenVK's warning of a pipeline whose restart may be disabled (`MVKPipeline.mm` lines 881-893
|
||||
/// at 1.4.1, 883-895 at 1.4.2) is the diagnostic of a pipeline that makes the restart dynamic with
|
||||
/// its topology dynamic or a strip or fan, exactly as the driver reports it; no other pipeline's,
|
||||
/// and no other fact's. It is MoltenVK's on any GPU at every release, and no other driver's.
|
||||
#[test]
|
||||
fn moltenvk_warns_of_a_pipeline_whose_restart_is_dynamic() {
|
||||
use crate::device::DriverDiagnostic;
|
||||
use crate::vk::{DynamicState as D, PrimitiveTopology as T};
|
||||
let warning = DriverDiagnostic {
|
||||
id_name: "mvk-warn",
|
||||
id: 0,
|
||||
text: "VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support disabling primitive restart."
|
||||
.into(),
|
||||
};
|
||||
let both = [D::PRIMITIVE_TOPOLOGY, D::PRIMITIVE_RESTART_ENABLE];
|
||||
let restart = [D::CULL_MODE, D::PRIMITIVE_RESTART_ENABLE];
|
||||
let topology = [D::PRIMITIVE_TOPOLOGY];
|
||||
let cases: [(&[D], T, bool); 10] = [
|
||||
(&both, T::TRIANGLE_LIST, true),
|
||||
(&both, T::LINE_LIST, true),
|
||||
(&both, T::POINT_LIST, true),
|
||||
(&restart, T::TRIANGLE_STRIP, true),
|
||||
(&restart, T::LINE_STRIP, true),
|
||||
(&restart, T::TRIANGLE_FAN, true),
|
||||
(&restart, T::TRIANGLE_LIST, false),
|
||||
(&topology, T::TRIANGLE_STRIP, false),
|
||||
(&[], T::TRIANGLE_STRIP, false),
|
||||
(&[D::CULL_MODE], T::LINE_STRIP, false),
|
||||
];
|
||||
let blendless = [crate::vk::Format::R32_UINT];
|
||||
for (dynamic, top, warns) in cases {
|
||||
assert_eq!(
|
||||
RESTART.pipeline_creation_diagnostics(dynamic, top, &blendless),
|
||||
warns
|
||||
.then(|| warning.clone())
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>(),
|
||||
"{dynamic:?} {top:?}"
|
||||
);
|
||||
for other in [ZERO, DENORMALS, FETCH, SPLIT] {
|
||||
assert!(other
|
||||
.pipeline_creation_diagnostics(dynamic, top, &blendless)
|
||||
.is_empty());
|
||||
}
|
||||
}
|
||||
let rows: Vec<_> = MEASURED
|
||||
.iter()
|
||||
.filter(|row| row.fact == RESTART)
|
||||
.map(|row| (row.driver, row.vendor, row.device))
|
||||
.collect();
|
||||
assert_eq!(rows, [(DriverId::MOLTENVK, None, None)]);
|
||||
let text = std::fs::read_to_string(
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles/moltenvk-m3.json"),
|
||||
)
|
||||
.expect("moltenvk-m3");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("profile parses");
|
||||
for version in [10400, 10401, 10402, 10403] {
|
||||
desc.driver_version = version;
|
||||
assert!(desc.driver_facts().contains(&RESTART), "{version}");
|
||||
}
|
||||
desc.driver_id = Some(DriverId::MESA_LLVMPIPE);
|
||||
assert!(!desc.driver_facts().contains(&RESTART));
|
||||
}
|
||||
|
||||
/// MoltenVK's warning of a color attachment whose format cannot blend (`MVKPipeline.mm`'s
|
||||
/// `addFragmentOutputToPipeline` at 1.4.2), whether the pipeline blends it or not, is one
|
||||
/// diagnostic for each such format, named as the registry names it, exactly as the driver reports
|
||||
/// it; none for a pipeline without such an attachment, and none of another fact. It is measured on
|
||||
/// the M4's identity (the Apple9 family under macOS 27), at every release.
|
||||
#[test]
|
||||
fn moltenvk_warns_of_each_color_attachment_it_cannot_blend() {
|
||||
use crate::device::DriverDiagnostic;
|
||||
use crate::vk::{Format as F, PrimitiveTopology as T};
|
||||
let warning = |name: &str| DriverDiagnostic {
|
||||
id_name: "mvk-warn",
|
||||
id: 0,
|
||||
text: format!(
|
||||
"VK_ERROR_FEATURE_NOT_PRESENT: Blending is enabled for attachment with format {name}, \
|
||||
which does not support it."
|
||||
)
|
||||
.into(),
|
||||
};
|
||||
let blendless = [F::R32_UINT, F::E5B9G9R9_UFLOAT_PACK32];
|
||||
assert_eq!(
|
||||
BLENDLESS.pipeline_creation_diagnostics(&[], T::TRIANGLE_LIST, &blendless),
|
||||
[
|
||||
warning("VK_FORMAT_R32_UINT"),
|
||||
warning("VK_FORMAT_E5B9G9R9_UFLOAT_PACK32")
|
||||
]
|
||||
);
|
||||
// The text MoltenVK 1.4.2 reported for `R32_UINT` on the M3 Max (2026-10-21).
|
||||
assert_eq!(
|
||||
warning("VK_FORMAT_R32_UINT").text,
|
||||
"VK_ERROR_FEATURE_NOT_PRESENT: Blending is enabled for attachment with format \
|
||||
VK_FORMAT_R32_UINT, which does not support it."
|
||||
);
|
||||
assert!(BLENDLESS
|
||||
.pipeline_creation_diagnostics(&[], T::TRIANGLE_STRIP, &[])
|
||||
.is_empty());
|
||||
assert!(RESTART
|
||||
.pipeline_creation_diagnostics(&[], T::TRIANGLE_LIST, &blendless)
|
||||
.is_empty());
|
||||
let text = std::fs::read_to_string(
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles/moltenvk-m3.json"),
|
||||
)
|
||||
.expect("moltenvk-m3");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("profile parses");
|
||||
for version in [10401, 10402, 10403] {
|
||||
desc.driver_version = version;
|
||||
assert!(desc.driver_facts().contains(&BLENDLESS), "{version}");
|
||||
}
|
||||
}
|
||||
@@ -101,10 +101,10 @@ fn recommendations_are_closed_fixed_points_on_every_committed_profile() {
|
||||
.clone()
|
||||
.with_enabled(&rec)
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let dev = Device::new(restricted, DevicePolicy::default())
|
||||
let dev = Device::from_queries(restricted, DevicePolicy::default())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
assert_eq!(dev.required_enables(), rec, "{stem}");
|
||||
let full = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let full = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
assert_eq!(full.required_enables(), rec, "{stem}");
|
||||
assert_eq!(
|
||||
rec.extensions.contains(&VkExtension::KhrPortabilitySubset),
|
||||
@@ -154,9 +154,9 @@ fn recommendations_keep_robust_buffer_access_and_vuid_10247() {
|
||||
assert_eq!(rec.features.contains(f), reported, "{reported}: {f:?}");
|
||||
}
|
||||
let restricted = d.clone().with_enabled(&rec).unwrap();
|
||||
let dev = Device::new(restricted, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(restricted, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(dev.required_enables(), rec, "{reported}");
|
||||
let whole = Device::new(d.clone(), DevicePolicy::default()).unwrap();
|
||||
let whole = Device::from_queries(d.clone(), DevicePolicy::default()).unwrap();
|
||||
assert_eq!(whole.required_enables(), rec, "{reported}");
|
||||
}
|
||||
// Under `UnsafeOff` robust buffer access is not recommended, so neither rule side is lost.
|
||||
@@ -192,13 +192,13 @@ fn the_swiftshader_recommendation_keeps_vuid_10247() {
|
||||
.features
|
||||
.contains(&VkFeature::DescriptorBindingSampledImageUpdateAfterBind));
|
||||
let restricted = desc.clone().with_enabled(&rec).unwrap();
|
||||
let stated = Device::new(restricted.clone(), DevicePolicy::default()).unwrap();
|
||||
let stated = Device::from_queries(restricted.clone(), DevicePolicy::default()).unwrap();
|
||||
assert_eq!(stated.required_enables(), rec);
|
||||
let mut with_buffers = restricted;
|
||||
with_buffers
|
||||
.features
|
||||
.extend(BUFFER_UPDATE_AFTER_BIND.iter().copied());
|
||||
let both = Device::new(with_buffers, DevicePolicy::default()).unwrap();
|
||||
let both = Device::from_queries(with_buffers, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(both.required_enables(), rec);
|
||||
let mut fields = both.profile().fields().clone();
|
||||
assert!(fields.descriptors.update_after_bind_storage_buffer);
|
||||
@@ -304,7 +304,7 @@ fn extended_dynamic_state2_is_enabled_below_1_3_and_implied_from_it() {
|
||||
assert!(rec.extensions.contains(&extension), "{extension:?}");
|
||||
assert!(rec.features.contains(&feature), "{feature:?}");
|
||||
}
|
||||
let dev = Device::new(
|
||||
let dev = Device::from_queries(
|
||||
d.clone().with_enabled(&rec).unwrap(),
|
||||
DevicePolicy::default(),
|
||||
)
|
||||
@@ -383,7 +383,7 @@ fn unsafe_containment_recommends_no_robust_buffer_access() {
|
||||
assert!(!rec.features.contains(&VkFeature::RobustBufferAccess));
|
||||
assert!(!rec.features.contains(&VkFeature::RobustBufferAccess2));
|
||||
let restricted = desc.with_enabled(&rec).unwrap();
|
||||
Device::new(restricted, policy).unwrap();
|
||||
Device::from_queries(restricted, policy).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -486,13 +486,13 @@ fn device_new_refuses_a_feature_without_its_companion() {
|
||||
}
|
||||
let mut d = floor_with(&[VkExtension::ExtRobustness2], &[f]);
|
||||
d.features.remove(&needs);
|
||||
let e = match Device::new(d.clone(), DevicePolicy::default()) {
|
||||
let e = match Device::from_queries(d.clone(), DevicePolicy::default()) {
|
||||
Err(Error::InvalidDescriptor(DescriptorError::DeviceDescription { detail })) => detail,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
assert!(e.contains(vuid), "{e}");
|
||||
d.features.insert(needs);
|
||||
Device::new(d, DevicePolicy::default()).unwrap();
|
||||
Device::from_queries(d, DevicePolicy::default()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,7 +722,7 @@ fn required_enables_follow_version_dependencies_formats_and_flags() {
|
||||
fn device_new_refuses_unexposed_features() {
|
||||
let mut d = profile("vk12-floor");
|
||||
d.features.insert(VkFeature::Maintenance8);
|
||||
let e = match Device::new(d.clone(), DevicePolicy::default()) {
|
||||
let e = match Device::from_queries(d.clone(), DevicePolicy::default()) {
|
||||
Err(Error::InvalidDescriptor(DescriptorError::DeviceDescription { detail })) => detail,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
@@ -731,7 +731,7 @@ fn device_new_refuses_unexposed_features() {
|
||||
"{e}"
|
||||
);
|
||||
d.extensions.insert(VkExtension::KhrMaintenance8);
|
||||
Device::new(d, DevicePolicy::default()).unwrap();
|
||||
Device::from_queries(d, DevicePolicy::default()).unwrap();
|
||||
}
|
||||
|
||||
/// The profile's format tables hold only formats the description exposes: a queried description
|
||||
@@ -772,7 +772,7 @@ fn profile_format_tables_hold_only_exposed_formats() {
|
||||
let entry = d.formats.formats[&vk::Format::R8_UNORM];
|
||||
d.formats.formats.insert(vk::Format::A8_UNORM, entry);
|
||||
let a8 = |d: &DeviceDescription| {
|
||||
Device::new(d.clone(), DevicePolicy::default())
|
||||
Device::from_queries(d.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.supports_format(vk::Format::A8_UNORM, FormatUsage::SampledImage)
|
||||
@@ -807,7 +807,7 @@ fn a_storage_read_without_a_format_is_enabled_by_the_feature_the_version_or_the_
|
||||
let opened = desc.clone().with_enabled(&enabled).unwrap();
|
||||
(
|
||||
enabled,
|
||||
Device::new(opened.clone(), policy).unwrap(),
|
||||
Device::from_queries(opened.clone(), policy).unwrap(),
|
||||
opened,
|
||||
)
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
//! nothing it derives.
|
||||
|
||||
use super::*;
|
||||
use crate::device::description::APPLE_VENDOR_ID;
|
||||
|
||||
/// The identities each committed profile is also read under, each with a device type: MoltenVK
|
||||
/// on an Apple GPU, the NVIDIA driver on a GA10x, RADV, Intel's Mesa driver and none.
|
||||
@@ -11,14 +10,14 @@ fn identities() -> [(Option<vk::DriverId>, u32, u32, vk::PhysicalDeviceType); 5]
|
||||
[
|
||||
(
|
||||
Some(vk::DriverId::MOLTENVK),
|
||||
APPLE_VENDOR_ID,
|
||||
0x106b,
|
||||
0x1_0009,
|
||||
T::INTEGRATED_GPU,
|
||||
),
|
||||
(
|
||||
Some(vk::DriverId::NVIDIA_PROPRIETARY),
|
||||
0x10de,
|
||||
NVIDIA_AMPERE_GA10X[0],
|
||||
0x2204,
|
||||
T::DISCRETE_GPU,
|
||||
),
|
||||
(
|
||||
@@ -39,11 +38,9 @@ fn identities() -> [(Option<vk::DriverId>, u32, u32, vk::PhysicalDeviceType); 5]
|
||||
|
||||
/// On every committed profile, descriptions that differ only in `driver_id`, `vendor_id`,
|
||||
/// `device_id` and the device type give one profile, whose only workarounds are the two every
|
||||
/// device but Apple's takes and which reads YCbCr planes in place; `Device::new` reads the
|
||||
/// identity, so at least one profile differs there.
|
||||
/// device but Apple's takes and which reads YCbCr planes in place.
|
||||
#[test]
|
||||
fn from_queries_derives_one_profile_whatever_the_identity() {
|
||||
let mut new_differs = false;
|
||||
for (stem, _) in committed_profiles() {
|
||||
let desc = profile(&stem);
|
||||
let derived: Vec<Option<DeviceProfile>> = identities()
|
||||
@@ -74,14 +71,7 @@ fn from_queries_derives_one_profile_whatever_the_identity() {
|
||||
"{stem}"
|
||||
);
|
||||
assert!(queried.reads_ycbcr_planes_in_place(), "{stem}");
|
||||
if let Ok(identified) = Device::new(desc, DevicePolicy::default()) {
|
||||
new_differs |= identified.profile() != queried;
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
new_differs,
|
||||
"no committed profile's identity changes Device::new"
|
||||
);
|
||||
}
|
||||
|
||||
/// The owned synthetic kernel of `from_queries_keeps_the_narrow_mask_on_ga10x`: two loaded words'
|
||||
@@ -126,9 +116,7 @@ entry:
|
||||
/// A narrow mask over a signed clamp, to exactly 16 bits' range, of a sum of two values
|
||||
/// sign-extended from 16 bits ([`NARROW_CLAMP`]), on an NVIDIA Ampere GA10x description (the RTX
|
||||
/// 50's capture under the RTX 3090's identity): `Device::from_queries` masks it with
|
||||
/// `OpBitwiseAnd`, as on every device, and emits no `OpBitFieldUExtract`; `Device::new` reads the
|
||||
/// identity and takes `OpBitFieldUExtract` in place of every such mask
|
||||
/// (`DriverWorkaround::NarrowMaskAfterSignedClamp`).
|
||||
/// `OpBitwiseAnd`, as on every device, and emits no `OpBitFieldUExtract`.
|
||||
#[test]
|
||||
fn from_queries_keeps_the_narrow_mask_on_ga10x() {
|
||||
use crate::budget::SPIRV_WORDS;
|
||||
@@ -148,7 +136,6 @@ fn from_queries_keeps_the_narrow_mask_on_ga10x() {
|
||||
desc.driver_id = Some(vk::DriverId::NVIDIA_PROPRIETARY);
|
||||
desc.vendor_id = 0x10de;
|
||||
desc.device_id = 0x2204;
|
||||
assert!(NVIDIA_AMPERE_GA10X.contains(&desc.device_id));
|
||||
// The unsigned extracts and the ANDs of the kernel compiled on `p`.
|
||||
let counts = |p: &DeviceProfile| {
|
||||
let entry = EntryRef::Name("narrow_clamp");
|
||||
@@ -172,15 +159,8 @@ fn from_queries_keeps_the_narrow_mask_on_ga10x() {
|
||||
.count();
|
||||
(extracts, ands)
|
||||
};
|
||||
let queried = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let queried = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
let (extracts, ands) = counts(queried.profile());
|
||||
assert_eq!(extracts, 0, "from_queries: an extract");
|
||||
assert!(ands > 0, "from_queries: no mask");
|
||||
let identified = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
assert!(identified
|
||||
.profile()
|
||||
.workarounds()
|
||||
.contains(&DriverWorkaround::NarrowMaskAfterSignedClamp));
|
||||
let (extracts, _) = counts(identified.profile());
|
||||
assert!(extracts > 0, "Device::new: no extract");
|
||||
}
|
||||
@@ -9,14 +9,14 @@ use crate::device::requirements::{Requirements, StageCreateFlag, VkLimit, VkProp
|
||||
use crate::error::{Capability, Feature, Needs};
|
||||
|
||||
pub(crate) fn device(stem: &str) -> Device {
|
||||
Device::new(profile(stem), DevicePolicy::default()).expect("committed profile derives")
|
||||
Device::from_queries(profile(stem), DevicePolicy::default()).expect("committed profile derives")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_committed_profile_derives() {
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default())
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default())
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let f = dev.profile().fields();
|
||||
assert_eq!(f.api_version, desc.api_version, "{stem}");
|
||||
@@ -27,7 +27,7 @@ fn every_committed_profile_derives() {
|
||||
f.containment
|
||||
);
|
||||
// Deterministic.
|
||||
let again = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let again = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(dev.profile(), again.profile(), "{stem}");
|
||||
assert_eq!(dev.profile().fingerprint(), again.profile().fingerprint());
|
||||
// A profile satisfies the requirements of everything it enabled.
|
||||
@@ -65,7 +65,7 @@ fn occlusion_query_precise_follows_each_source() {
|
||||
stated,
|
||||
"{stem}"
|
||||
);
|
||||
let dev = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
let enabled = &dev.profile().fields().enabled.features;
|
||||
assert_eq!(
|
||||
enabled.contains(&VkFeature::OcclusionQueryPrecise),
|
||||
@@ -98,7 +98,7 @@ fn depth_bias_control_follows_each_source() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let has_extension = desc.extensions.contains(&VkExtension::ExtDepthBiasControl);
|
||||
assert_eq!(has_extension, stated.is_some(), "{stem}");
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let enabled = &dev.profile().fields().enabled;
|
||||
for (member, feature) in features {
|
||||
let want = stated
|
||||
@@ -239,12 +239,12 @@ fn vertex_layer_and_viewport_outputs_follow_the_features_not_the_extension() {
|
||||
assert!(desc
|
||||
.extensions
|
||||
.contains(&VkExtension::ExtShaderViewportIndexLayer));
|
||||
let full = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let full = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let f = full.profile().fields();
|
||||
assert!(f.fragment.output_layer && f.fragment.output_viewport_index);
|
||||
assert!(desc.features.remove(&VkFeature::ShaderOutputLayer));
|
||||
assert!(desc.features.remove(&VkFeature::ShaderOutputViewportIndex));
|
||||
let lacking = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let lacking = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
let f = lacking.profile().fields();
|
||||
assert!(!f.fragment.output_layer);
|
||||
assert!(!f.fragment.output_viewport_index);
|
||||
@@ -284,7 +284,7 @@ fn robustness2_selects_the_rba2_encoding() {
|
||||
fn below_1_2_and_contradictory_policies_are_refused() {
|
||||
let mut desc = profile("vk12-floor");
|
||||
desc.api_version = ApiVersion { major: 1, minor: 1 };
|
||||
match Device::new(desc, DevicePolicy::default()) {
|
||||
match Device::from_queries(desc, DevicePolicy::default()) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
assert_eq!(u.feature, Feature::VulkanVersion);
|
||||
assert_eq!(
|
||||
@@ -299,13 +299,13 @@ fn below_1_2_and_contradictory_policies_are_refused() {
|
||||
..DevicePolicy::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
Device::new(profile("vk12-floor"), unsafe_on),
|
||||
Device::from_queries(profile("vk12-floor"), unsafe_on),
|
||||
Err(Error::InvalidDescriptor(
|
||||
DescriptorError::DeviceDescription { .. }
|
||||
))
|
||||
));
|
||||
unsafe_on.isolation = GuestIsolation::Off;
|
||||
let dev = Device::new(profile("vk12-floor"), unsafe_on).unwrap();
|
||||
let dev = Device::from_queries(profile("vk12-floor"), unsafe_on).unwrap();
|
||||
assert_eq!(dev.profile().fields().containment, Containment::UnsafeOff);
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ fn the_identity_domains_come_as_a_pair_on_a_device_with_addresses() {
|
||||
] {
|
||||
assert!(
|
||||
matches!(
|
||||
Device::new(profile("lavapipe"), half),
|
||||
Device::from_queries(profile("lavapipe"), half),
|
||||
Err(Error::InvalidDescriptor(
|
||||
DescriptorError::DeviceDescription { .. }
|
||||
))
|
||||
@@ -340,7 +340,7 @@ fn the_identity_domains_come_as_a_pair_on_a_device_with_addresses() {
|
||||
);
|
||||
}
|
||||
// roadmap-2022 has device addresses but not shaderInt64.
|
||||
match Device::new(profile("roadmap-2022"), identity) {
|
||||
match Device::from_queries(profile("roadmap-2022"), identity) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
assert_eq!(u.feature, Feature::IdentityDomains);
|
||||
let both = [VkFeature::BufferDeviceAddress, VkFeature::ShaderInt64];
|
||||
@@ -356,7 +356,7 @@ fn fingerprint_covers_every_policy_field() {
|
||||
let desc = profile("lavapipe");
|
||||
let base = DevicePolicy::default();
|
||||
let fp = |p: DevicePolicy| {
|
||||
Device::new(desc.clone(), p)
|
||||
Device::from_queries(desc.clone(), p)
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fingerprint()
|
||||
@@ -384,13 +384,19 @@ fn fingerprint_covers_every_policy_field() {
|
||||
let mut fewer = desc.clone();
|
||||
fewer.features.remove(&VkFeature::ShaderInt8);
|
||||
assert_ne!(
|
||||
Device::new(fewer, base).unwrap().profile().fingerprint(),
|
||||
Device::from_queries(fewer, base)
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fingerprint(),
|
||||
reference
|
||||
);
|
||||
let mut limits = desc;
|
||||
limits.limits.max_texel_offset += 1;
|
||||
assert_ne!(
|
||||
Device::new(limits, base).unwrap().profile().fingerprint(),
|
||||
Device::from_queries(limits, base)
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fingerprint(),
|
||||
reference
|
||||
);
|
||||
}
|
||||
@@ -465,7 +471,7 @@ fn allocation_sizes_are_no_profile_field() {
|
||||
] {
|
||||
let mut other = desc.clone();
|
||||
other.allocation = AllocationLimits::new(memory, buffer);
|
||||
let dev = Device::new(other, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(other, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(dev.profile(), base.profile(), "{stem}");
|
||||
assert_eq!(
|
||||
dev.profile().fingerprint(),
|
||||
@@ -649,14 +655,14 @@ fn storage_without_format_follows_each_format() {
|
||||
U::StorageTexelBufferReadWithoutFormat,
|
||||
U::StorageTexelBufferWriteWithoutFormat,
|
||||
];
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
assert_eq!(usages(&dev, vk::Format::R32_UINT), all);
|
||||
assert_eq!(usages(&dev, vk::Format::B8G8R8A8_UNORM), []);
|
||||
let mut write_only = desc.clone();
|
||||
write_only
|
||||
.features
|
||||
.remove(&VkFeature::ShaderStorageImageReadWithoutFormat);
|
||||
let dev = Device::new(write_only, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(write_only, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(
|
||||
usages(&dev, vk::Format::R32_UINT),
|
||||
[
|
||||
@@ -669,7 +675,7 @@ fn storage_without_format_follows_each_format() {
|
||||
// extension at 1.2 reports them as Vulkan 1.3 does.
|
||||
desc.khr_format_feature_flags2 = true;
|
||||
assert!(desc.has_format_feature_flags2());
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
assert_eq!(
|
||||
usages(&dev, vk::Format::R32_UINT),
|
||||
[
|
||||
@@ -685,7 +691,7 @@ fn storage_without_format_follows_each_format() {
|
||||
F::STORAGE_READ_WITHOUT_FORMAT,
|
||||
),
|
||||
);
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
assert_eq!(
|
||||
usages(&dev, vk::Format::B8G8R8A8_UNORM),
|
||||
[
|
||||
@@ -696,7 +702,7 @@ fn storage_without_format_follows_each_format() {
|
||||
// The implication needs the feature.
|
||||
desc.features
|
||||
.remove(&VkFeature::ShaderStorageImageReadWithoutFormat);
|
||||
let dev = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(
|
||||
usages(&dev, vk::Format::R32_UINT),
|
||||
[U::StorageImageWriteWithoutFormat]
|
||||
@@ -715,188 +721,6 @@ fn storage_without_format_follows_each_format() {
|
||||
assert_eq!(usages(&device("lavapipe"), vk::Format::R32_UINT), all);
|
||||
}
|
||||
|
||||
/// A MoltenVK driver on an Apple GPU carries
|
||||
/// `DriverWorkaround::EarlyTestsDropMultisampledImageWrites` and
|
||||
/// `DriverWorkaround::DiscardDropsSimdgroupStores` (the defects are the GPU's, which MoltenVK
|
||||
/// reaches), keyed on the driver and the vendor and on nothing else: MoltenVK on another vendor's
|
||||
/// GPU, and another driver on an Apple vendor ID, do not. (MoltenVK 1.4.1's
|
||||
/// `BothBarycentricFormsRejected`, `CompositeInsertsWrittenInPlace`, `LoadsForwardedIntoLoops` and
|
||||
/// `LocalizedLoadsForwardedPastAtomicsAndCalls`, and `FunctionsInlinedAtEveryCall`, are its
|
||||
/// SPIRV-Cross's, on every vendor; its `MemoryWritingFragmentsRunPerSample`, is measured on Apple's
|
||||
/// GPUs.)
|
||||
#[test]
|
||||
fn moltenvk_on_apple_carries_the_early_tests_image_write_defect() {
|
||||
use crate::device::profile::DriverWorkaround as W;
|
||||
let workarounds = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.clone()
|
||||
};
|
||||
let mut desc = profile("moltenvk-m3");
|
||||
assert_eq!(desc.driver_id, Some(vk::DriverId::MOLTENVK));
|
||||
assert_eq!(desc.vendor_id, 0x106B);
|
||||
assert_eq!(
|
||||
workarounds(&desc),
|
||||
[
|
||||
W::EarlyTestsDropMultisampledImageWrites,
|
||||
W::BothBarycentricFormsRejected,
|
||||
W::MemoryWritingFragmentsRunPerSample,
|
||||
W::CompositeInsertsWrittenInPlace,
|
||||
W::FunctionsInlinedAtEveryCall,
|
||||
W::LoadsForwardedIntoLoops,
|
||||
W::LocalizedLoadsForwardedPastAtomicsAndCalls,
|
||||
W::DiscardDropsSimdgroupStores
|
||||
]
|
||||
);
|
||||
desc.vendor_id = 0x1002;
|
||||
assert_eq!(
|
||||
workarounds(&desc),
|
||||
[
|
||||
W::BothBarycentricFormsRejected,
|
||||
W::CompositeInsertsWrittenInPlace,
|
||||
W::FunctionsInlinedAtEveryCall,
|
||||
W::LoadsForwardedIntoLoops,
|
||||
W::LocalizedLoadsForwardedPastAtomicsAndCalls,
|
||||
W::ClippedCoverageNotMetals,
|
||||
W::TessellatorNotMetals
|
||||
]
|
||||
);
|
||||
desc.vendor_id = 0x106B;
|
||||
desc.driver_id = Some(vk::DriverId::MESA_RADV);
|
||||
// Every rasterizer but Apple's hands a clipped primitive's fragments other coverage than
|
||||
// Metal's pieces, and every tessellator but Apple's orders a patch's triangles its own way;
|
||||
// RADV's own interpolation facts and its fused half conversion hold on any vendor.
|
||||
assert_eq!(
|
||||
workarounds(&desc),
|
||||
[
|
||||
W::HalfConversionFusedWithArithmetic,
|
||||
W::InterpolationNeedsTheWholeQuad,
|
||||
W::PerspectiveReadsExtrapolated,
|
||||
W::ClippedCoverageNotMetals,
|
||||
W::TessellatorNotMetals
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::BothBarycentricFormsRejected`,
|
||||
/// `DriverWorkaround::CompositeInsertsWrittenInPlace`, `DriverWorkaround::LoadsForwardedIntoLoops`,
|
||||
/// `DriverWorkaround::LocalizedLoadsForwardedPastAtomicsAndCalls` and
|
||||
/// `DriverWorkaround::FunctionsInlinedAtEveryCall`, its SPIRV-Cross's, are keyed on MoltenVK by
|
||||
/// the measured table (`driver_facts::DEFECTS`): carried at every release, and not by another
|
||||
/// driver.
|
||||
#[test]
|
||||
fn moltenvk_carries_its_spirv_cross_defects_at_every_release() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
for defect in [
|
||||
DriverWorkaround::BothBarycentricFormsRejected,
|
||||
DriverWorkaround::CompositeInsertsWrittenInPlace,
|
||||
DriverWorkaround::FunctionsInlinedAtEveryCall,
|
||||
DriverWorkaround::LoadsForwardedIntoLoops,
|
||||
DriverWorkaround::LocalizedLoadsForwardedPastAtomicsAndCalls,
|
||||
] {
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&defect)
|
||||
};
|
||||
{
|
||||
let stem = "moltenvk-m3";
|
||||
let mut desc = profile(stem);
|
||||
assert!(carries(&desc), "{stem} {defect:?}");
|
||||
for version in [10400, 10500] {
|
||||
desc.driver_version = version;
|
||||
assert!(carries(&desc), "{stem} {version} {defect:?}");
|
||||
}
|
||||
desc.driver_id = Some(vk::DriverId::MESA_LLVMPIPE);
|
||||
assert!(!carries(&desc), "{stem} under lavapipe {defect:?}");
|
||||
}
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let moltenvk = desc.driver_id == Some(vk::DriverId::MOLTENVK);
|
||||
assert_eq!(carries(&desc), moltenvk, "{stem} {defect:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::MemoryWritingFragmentsRunPerSample` is keyed on MoltenVK and Apple's vendor
|
||||
/// ID by the measured table (`driver_facts::DEFECTS`): carried at every release, and not on another
|
||||
/// vendor's GPU, nor by another driver.
|
||||
#[test]
|
||||
fn moltenvk_on_apple_carries_the_per_sample_writer_defect_at_every_release() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let defect = DriverWorkaround::MemoryWritingFragmentsRunPerSample;
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&defect)
|
||||
};
|
||||
{
|
||||
let stem = "moltenvk-m3";
|
||||
let mut desc = profile(stem);
|
||||
assert!(carries(&desc), "{stem}");
|
||||
for version in [10400, 10500] {
|
||||
desc.driver_version = version;
|
||||
assert!(carries(&desc), "{stem} {version}");
|
||||
}
|
||||
desc.vendor_id = 0x1002;
|
||||
assert!(!carries(&desc), "{stem} on another vendor");
|
||||
desc.vendor_id = 0x106B;
|
||||
desc.driver_id = Some(vk::DriverId::MESA_LLVMPIPE);
|
||||
assert!(!carries(&desc), "{stem} under lavapipe");
|
||||
}
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let apple_moltenvk =
|
||||
desc.driver_id == Some(vk::DriverId::MOLTENVK) && desc.vendor_id == 0x106B;
|
||||
assert_eq!(carries(&desc), apple_moltenvk, "{stem}");
|
||||
}
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::InterpolationNeedsTheWholeQuad` and
|
||||
/// `DriverWorkaround::PerspectiveReadsExtrapolated` are keyed on RADV by the measured table
|
||||
/// (`driver_facts::DEFECTS`): each carried at every release, whatever the vendor ID (the rows name
|
||||
/// none), and not by another driver.
|
||||
#[test]
|
||||
fn radv_carries_its_interpolation_facts_at_every_release() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
for fact in [
|
||||
DriverWorkaround::InterpolationNeedsTheWholeQuad,
|
||||
DriverWorkaround::PerspectiveReadsExtrapolated,
|
||||
] {
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&fact)
|
||||
};
|
||||
let mut desc = profile("amd-780m-radv");
|
||||
assert_eq!(desc.driver_id, Some(vk::DriverId::MESA_RADV));
|
||||
assert!(carries(&desc), "{fact:?}");
|
||||
desc.driver_version += 1;
|
||||
assert!(carries(&desc), "{fact:?} at another release");
|
||||
desc.vendor_id = 0x8086;
|
||||
assert!(carries(&desc), "{fact:?} on another vendor's ID");
|
||||
desc.driver_id = Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA);
|
||||
assert!(!carries(&desc), "{fact:?} under ANV");
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let radv = desc.driver_id == Some(vk::DriverId::MESA_RADV);
|
||||
assert_eq!(carries(&desc), radv, "{fact:?} on {stem}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The profile holds the upper bound of the device's `pointSizeRange` in whole pixels, rounded
|
||||
/// down, so a description's two-decimal JSON (2047.94, 8191.88) and the device's own `f32`
|
||||
/// (2047.9375, 8191.875) hold the same; 0 for a range that is not above zero.
|
||||
@@ -933,233 +757,12 @@ fn the_profile_holds_the_largest_whole_point_size() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Every driver carries `DriverWorkaround::ClippedCoverageNotMetals` and
|
||||
/// `DriverWorkaround::TessellatorNotMetals` but MoltenVK on an Apple GPU, which draws through Metal
|
||||
/// and splits a clipped primitive and orders a patch's triangles as Metal does: MoltenVK on another
|
||||
/// vendor's GPU carries them, and so does every other driver on an Apple vendor ID.
|
||||
#[test]
|
||||
fn every_rasterizer_and_tessellator_but_apples_answer_their_own_way() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
for answer in [
|
||||
DriverWorkaround::ClippedCoverageNotMetals,
|
||||
DriverWorkaround::TessellatorNotMetals,
|
||||
] {
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&answer)
|
||||
};
|
||||
for stem in [
|
||||
"nvidia-rtx5080-laptop",
|
||||
"amd-rdna3-radv",
|
||||
"intel-irisxe-rplp-anv",
|
||||
"lavapipe",
|
||||
"swiftshader",
|
||||
] {
|
||||
assert!(carries(&profile(stem)), "{answer:?} {stem}");
|
||||
}
|
||||
let mut desc = profile("moltenvk-m3");
|
||||
assert!(!carries(&desc), "{answer:?}: MoltenVK on an Apple GPU");
|
||||
desc.vendor_id = 0x1002;
|
||||
assert!(
|
||||
carries(&desc),
|
||||
"{answer:?}: MoltenVK on another vendor's GPU"
|
||||
);
|
||||
desc.vendor_id = 0x106B;
|
||||
desc.driver_id = Some(vk::DriverId::MESA_RADV);
|
||||
assert!(
|
||||
carries(&desc),
|
||||
"{answer:?}: another driver on an Apple vendor ID"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Lavapipe carries `DriverWorkaround::ClippedTrianglesSplitPixelFragments` (the defect is the
|
||||
/// driver's rasterizer, so whatever vendor ID it reports), keyed on the driver alone: the same
|
||||
/// description under another driver does not.
|
||||
#[test]
|
||||
fn lavapipe_carries_the_split_pixel_fragments_defect() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let defect = DriverWorkaround::ClippedTrianglesSplitPixelFragments;
|
||||
let workarounds = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.clone()
|
||||
};
|
||||
// The committed lavapipe's release (Mesa 26.2.3) also carries the mesh index defect, kept
|
||||
// past the release measured with it (`lavapipe_carries_the_mesh_index_defect_from_its_
|
||||
// measured_release`).
|
||||
// And, as every rasterizer and tessellator but Apple's, `ClippedCoverageNotMetals` and
|
||||
// `TessellatorNotMetals`.
|
||||
let both = [
|
||||
defect,
|
||||
DriverWorkaround::MeshIndexComponentStoresMisplaced,
|
||||
DriverWorkaround::ClippedCoverageNotMetals,
|
||||
DriverWorkaround::TessellatorNotMetals,
|
||||
];
|
||||
let mut desc = profile("lavapipe");
|
||||
assert_eq!(desc.driver_id, Some(vk::DriverId::MESA_LLVMPIPE));
|
||||
assert_eq!(workarounds(&desc), both);
|
||||
desc.vendor_id = 0x1002;
|
||||
assert_eq!(workarounds(&desc), both);
|
||||
desc.driver_id = Some(vk::DriverId::MESA_RADV);
|
||||
assert!(!workarounds(&desc).contains(&defect));
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::MeshIndexComponentStoresMisplaced` is keyed on lavapipe by the measured
|
||||
/// table (`driver_facts::DEFECTS`): carried at every release, whatever the vendor ID (the row
|
||||
/// names none), and not by another driver.
|
||||
#[test]
|
||||
fn lavapipe_carries_the_mesh_index_defect_at_every_release() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let defect = DriverWorkaround::MeshIndexComponentStoresMisplaced;
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&defect)
|
||||
};
|
||||
let mut desc = profile("gate-lavapipe-x86_64");
|
||||
assert_eq!(desc.driver_id, Some(vk::DriverId::MESA_LLVMPIPE));
|
||||
assert!(carries(&desc));
|
||||
desc.driver_version += 1;
|
||||
assert!(carries(&desc), "at another release");
|
||||
desc.vendor_id = 0x8086;
|
||||
assert!(carries(&desc), "on another vendor's ID");
|
||||
desc.driver_id = Some(vk::DriverId::MESA_RADV);
|
||||
assert!(!carries(&desc), "under RADV");
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let lavapipe = desc.driver_id == Some(vk::DriverId::MESA_LLVMPIPE);
|
||||
assert_eq!(carries(&desc), lavapipe, "{stem}");
|
||||
}
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::NarrowMaskAfterSignedClamp` is keyed on NVIDIA's driver on Ampere's GA10x
|
||||
/// GPUs and on nothing else. No committed profile describes one, so none carries it, and each
|
||||
/// translates as before. The RTX 5080 laptop GPU's description under the RTX 3090's device ID
|
||||
/// (0x2204, the GPU measured) and under another GA10x ID (the RTX 3070, 0x2484) carries it; under
|
||||
/// its own ID (Blackwell, measured right), or with the 3090's ID under another driver, it does not.
|
||||
#[test]
|
||||
fn only_nvidia_on_ampere_ga10x_carries_the_narrow_mask_defect() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let defect = DriverWorkaround::NarrowMaskAfterSignedClamp;
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&defect)
|
||||
};
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
assert!(!carries(&desc), "{stem}");
|
||||
}
|
||||
let mut desc = profile("nvidia-rtx5080-laptop");
|
||||
assert_eq!(desc.driver_id, Some(vk::DriverId::NVIDIA_PROPRIETARY));
|
||||
assert!(!crate::device::NVIDIA_AMPERE_GA10X.contains(&desc.device_id));
|
||||
for ampere in [0x2204, 0x2484] {
|
||||
desc.device_id = ampere;
|
||||
assert!(carries(&desc), "{ampere:#x}");
|
||||
}
|
||||
desc.driver_id = Some(vk::DriverId::MESA_NVK);
|
||||
assert!(!carries(&desc));
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::HalfConversionPairFolded` is keyed on NVIDIA's driver whatever its GPU and on
|
||||
/// nothing else: every committed NVIDIA profile carries it (the RTX 3090's generation and the RTX
|
||||
/// 50 series alike) and no other committed profile does; the RTX 5080 laptop GPU's description
|
||||
/// under Mesa's NVK does not. Where it is carried, a profile whose float controls would make the
|
||||
/// conversion Metal's rounds an `f32` to `half` in another form (`narrow::quantize_form` is
|
||||
/// `Converted`, not `Controlled`) and computes under those controls all the same
|
||||
/// (`narrow::half_controls`).
|
||||
#[test]
|
||||
fn nvidia_carries_the_folded_half_conversion_pair() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let defect = DriverWorkaround::HalfConversionPairFolded;
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&defect)
|
||||
};
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let nvidia = desc.driver_id == Some(vk::DriverId::NVIDIA_PROPRIETARY);
|
||||
assert_eq!(carries(&desc), nvidia, "{stem}");
|
||||
}
|
||||
let mut desc = profile("nvidia-rtx5080-laptop");
|
||||
let p = Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.clone();
|
||||
let half = p.fields().float_controls.f16;
|
||||
assert!(half.rounding_rte && half.denorm_preserve && half.signed_zero_inf_nan_preserve);
|
||||
assert_eq!(
|
||||
crate::lower::arith::narrow::quantize_form(&p),
|
||||
crate::spirv::builder::QuantizeForm::Converted
|
||||
);
|
||||
assert!(crate::lower::arith::narrow::half_controls(&p));
|
||||
desc.device_id = 0x2204;
|
||||
assert!(carries(&desc));
|
||||
desc.driver_id = Some(vk::DriverId::MESA_NVK);
|
||||
assert!(!carries(&desc));
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::HalfConversionFusedWithArithmetic` is keyed on RADV whatever its GPU and on
|
||||
/// nothing else: every committed RADV profile carries it (the Radeon 780M, 680M and RX 7800 XT)
|
||||
/// and no other committed profile does; the 780M's description under another driver does not.
|
||||
/// Such a profile keeps the conversion under the float controls (`QuantizeForm::Controlled`).
|
||||
#[test]
|
||||
fn radv_carries_the_fused_half_conversion() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let defect = DriverWorkaround::HalfConversionFusedWithArithmetic;
|
||||
let profile_of = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.clone()
|
||||
};
|
||||
let mut radv = 0;
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let on_radv = desc.driver_id == Some(vk::DriverId::MESA_RADV);
|
||||
let p = profile_of(&desc);
|
||||
assert_eq!(p.workarounds().contains(&defect), on_radv, "{stem}");
|
||||
if on_radv {
|
||||
radv += 1;
|
||||
assert_eq!(
|
||||
crate::lower::arith::narrow::quantize_form(&p),
|
||||
crate::spirv::builder::QuantizeForm::Controlled,
|
||||
"{stem}"
|
||||
);
|
||||
}
|
||||
}
|
||||
assert!(radv >= 3, "{radv} RADV profiles");
|
||||
let mut desc = profile("amd-780m-radv");
|
||||
assert!(profile_of(&desc).workarounds().contains(&defect));
|
||||
desc.driver_id = Some(vk::DriverId::AMD_OPEN_SOURCE);
|
||||
assert!(!profile_of(&desc).workarounds().contains(&defect));
|
||||
}
|
||||
|
||||
/// Through `Device::from_queries`, a profile's `half` rounding follows its queries alone: every
|
||||
/// committed profile with `shaderFloat16` and the 16-bit float controls (`narrow::half_controls`)
|
||||
/// rounds an `f32` to `half` through the controlled conversion (`narrow::quantize_form` is
|
||||
/// `Controlled`), NVIDIA's included, and names neither half row.
|
||||
/// `Controlled`), NVIDIA's included.
|
||||
#[test]
|
||||
fn from_queries_half_rounding_follows_the_queries_alone() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
use crate::lower::arith::narrow::{half_controls, quantize_form};
|
||||
use crate::spirv::builder::QuantizeForm;
|
||||
let mut controlled = Vec::new();
|
||||
@@ -1167,12 +770,6 @@ fn from_queries_half_rounding_follows_the_queries_alone() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
let p = device.profile();
|
||||
for row in [
|
||||
DriverWorkaround::HalfConversionPairFolded,
|
||||
DriverWorkaround::HalfConversionFusedWithArithmetic,
|
||||
] {
|
||||
assert!(!p.workarounds().contains(&row), "{stem}: {row:?}");
|
||||
}
|
||||
if half_controls(p) {
|
||||
assert_eq!(quantize_form(p), QuantizeForm::Controlled, "{stem}");
|
||||
controlled.push(stem);
|
||||
@@ -1189,331 +786,3 @@ fn from_queries_half_rounding_follows_the_queries_alone() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::RegisterAllocatorOverflowsLargeModules`,
|
||||
/// `DriverWorkaround::SerializedStageWrapsLargeModules` and
|
||||
/// `DriverWorkaround::CompilerMemoryGrowsWithStageSize` are keyed on ANV, whatever its GPU and
|
||||
/// release; every committed ANV profile carries them, and no other profile does. The Iris Xe's
|
||||
/// description under RADV or NVIDIA's driver loses them.
|
||||
#[test]
|
||||
fn large_module_defects_are_keyed_on_anv() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let profile_of = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.clone()
|
||||
};
|
||||
for fact in [
|
||||
DriverWorkaround::RegisterAllocatorOverflowsLargeModules,
|
||||
DriverWorkaround::SerializedStageWrapsLargeModules,
|
||||
DriverWorkaround::CompilerMemoryGrowsWithStageSize,
|
||||
] {
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let anv = desc.driver_id == Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA);
|
||||
let p = profile_of(&desc);
|
||||
assert_eq!(p.workarounds().contains(&fact), anv, "{fact:?} on {stem}");
|
||||
}
|
||||
let mut desc = profile("intel-irisxe-rplp-anv");
|
||||
assert!(profile_of(&desc).workarounds().contains(&fact));
|
||||
for other in [vk::DriverId::MESA_RADV, vk::DriverId::NVIDIA_PROPRIETARY] {
|
||||
desc.driver_id = Some(other);
|
||||
let p = profile_of(&desc);
|
||||
assert!(!p.workarounds().contains(&fact), "{fact:?} under {other:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The stage bound, two notes, the narrow wrap, the push window, the `half` fused multiply-add, the
|
||||
/// absent read and the threadgroup memory's start are facts of the profile, on every committed profile: `Device::new` bounds a stage only where
|
||||
/// its driver's identity names a stage-size defect (`StageBound::Defects`), notes the controlled
|
||||
/// `half` pair only where its driver fuses arithmetic into the narrowing (`HalfPairNote::Fused`),
|
||||
/// records implementation-defined reconvergence as the stage's field alone
|
||||
/// (`ReconvergenceNote::Field`), masks every narrow result (`NarrowWrap::Every`), pushes 128 bytes
|
||||
/// to a kernel (`PushWindow::Guaranteed`) and takes the 16-bit `Fma` only where its driver is
|
||||
/// measured (`HalfFma::Measured`), marks an absent argument's read (`AbsentReads::Marked`) and
|
||||
/// initializes no threadgroup memory (`ThreadgroupStart::Unwritten`); `Device::from_queries`
|
||||
/// bounds every stage, notes every pair, notes the reconvergence, masks only the narrow results a
|
||||
/// use reads, pushes 256 bytes, takes the 16-bit `Fma` under the 16-bit float controls, reads an
|
||||
/// absent argument as zero alone and zeroes threadgroup memory until the program writes it
|
||||
/// (`Every`, `Every`, `Noted`, `Read`, `Floor`, `Native`, `Nil`, `Zero`). The facts key the
|
||||
/// fingerprint: a profile of the same fields with another fact is another profile, the `half`
|
||||
/// fused multiply-add's and the threadgroup memory's start included.
|
||||
#[test]
|
||||
fn the_profiles_facts_follow_its_constructor() {
|
||||
use crate::device::profile::{
|
||||
AbsentReads, DeviceProfile, HalfFma, HalfPairNote, NarrowWrap, ProfileFacts, PushWindow,
|
||||
ReconvergenceNote, StageBound, ThreadgroupStart,
|
||||
};
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let old = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let queries = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(old.profile().stage_bound(), StageBound::Defects, "{stem}");
|
||||
assert_eq!(queries.profile().stage_bound(), StageBound::Every, "{stem}");
|
||||
let notes = (
|
||||
old.profile().half_pair_note(),
|
||||
queries.profile().half_pair_note(),
|
||||
);
|
||||
assert_eq!(notes, (HalfPairNote::Fused, HalfPairNote::Every), "{stem}");
|
||||
let notes = (
|
||||
old.profile().reconvergence_note(),
|
||||
queries.profile().reconvergence_note(),
|
||||
);
|
||||
let want = (ReconvergenceNote::Field, ReconvergenceNote::Noted);
|
||||
assert_eq!(notes, want, "{stem}");
|
||||
let wraps = (old.profile().narrow_wrap(), queries.profile().narrow_wrap());
|
||||
assert_eq!(wraps, (NarrowWrap::Every, NarrowWrap::Read), "{stem}");
|
||||
let windows = (old.profile().push_window(), queries.profile().push_window());
|
||||
assert_eq!(
|
||||
windows,
|
||||
(PushWindow::Guaranteed, PushWindow::Floor),
|
||||
"{stem}"
|
||||
);
|
||||
let fmas = (old.profile().half_fma(), queries.profile().half_fma());
|
||||
assert_eq!(fmas, (HalfFma::Measured, HalfFma::Native), "{stem}");
|
||||
let reads = (
|
||||
old.profile().absent_reads(),
|
||||
queries.profile().absent_reads(),
|
||||
);
|
||||
assert_eq!(reads, (AbsentReads::Marked, AbsentReads::Nil), "{stem}");
|
||||
let starts = (
|
||||
old.profile().threadgroup_start(),
|
||||
queries.profile().threadgroup_start(),
|
||||
);
|
||||
let want = (ThreadgroupStart::Unwritten, ThreadgroupStart::Zero);
|
||||
assert_eq!(starts, want, "{stem}");
|
||||
let fields = queries.profile().fields().clone();
|
||||
for facts in [
|
||||
ProfileFacts {
|
||||
stage_bound: StageBound::Defects,
|
||||
..ProfileFacts::EVERY
|
||||
},
|
||||
ProfileFacts {
|
||||
half_fma: HalfFma::Measured,
|
||||
..ProfileFacts::EVERY
|
||||
},
|
||||
ProfileFacts {
|
||||
threadgroup_start: ThreadgroupStart::Unwritten,
|
||||
..ProfileFacts::EVERY
|
||||
},
|
||||
] {
|
||||
let other = DeviceProfile::of(fields.clone(), facts);
|
||||
assert_ne!(
|
||||
other.fingerprint(),
|
||||
queries.profile().fingerprint(),
|
||||
"{stem}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The two view facts (`DriverWorkaround::UniformBufferPerLaneReadsSerialize` and
|
||||
/// `DriverWorkaround::ExternalUniformReadsSkipACache`) come from the description's measured set
|
||||
/// alone: no committed profile carries either by its identity, the GPUs they were first measured
|
||||
/// on included (the RTX 5080 Laptop GPU's and the Iris Xe's captures, the RTX 3090's and the
|
||||
/// RTX 2080's IDs), and any description that measured one carries it, its fingerprint another.
|
||||
#[test]
|
||||
fn view_facts_come_from_the_measured_set_alone() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let facts = [
|
||||
DriverWorkaround::UniformBufferPerLaneReadsSerialize,
|
||||
DriverWorkaround::ExternalUniformReadsSkipACache,
|
||||
];
|
||||
let device =
|
||||
|desc: &DeviceDescription| Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let carried = |desc: &DeviceDescription| {
|
||||
let device = device(desc);
|
||||
facts.map(|fact| device.profile().workarounds().contains(&fact))
|
||||
};
|
||||
let mut nvidia = profile("nvidia-rtx5080-laptop");
|
||||
let mut identities = vec![nvidia.clone(), profile("intel-irisxe-rplp-anv")];
|
||||
for id in [0x2204, 0x1e87] {
|
||||
nvidia.device_id = id;
|
||||
identities.push(nvidia.clone());
|
||||
}
|
||||
let committed = committed_profiles()
|
||||
.into_iter()
|
||||
.map(|(_, text)| DeviceDescription::from_khronos_json(&text, None).unwrap());
|
||||
for desc in identities.into_iter().chain(committed) {
|
||||
assert_eq!(carried(&desc), [false, false], "{}", desc.device_name);
|
||||
let unmeasured = device(&desc).profile_fingerprint();
|
||||
let mut fingerprints = vec![unmeasured];
|
||||
for (at, fact) in facts.into_iter().enumerate() {
|
||||
let mut measured = desc.clone();
|
||||
measured.measured.insert(fact);
|
||||
let mut expected = [false, false];
|
||||
expected[at] = true;
|
||||
assert_eq!(
|
||||
carried(&measured),
|
||||
expected,
|
||||
"{}: {fact:?}",
|
||||
desc.device_name
|
||||
);
|
||||
fingerprints.push(device(&measured).profile_fingerprint());
|
||||
}
|
||||
let mut both = desc.clone();
|
||||
both.measured.extend(facts);
|
||||
assert_eq!(carried(&both), [true, true]);
|
||||
fingerprints.push(device(&both).profile_fingerprint());
|
||||
let distinct: std::collections::BTreeSet<_> = fingerprints.iter().collect();
|
||||
assert_eq!(
|
||||
distinct.len(),
|
||||
4,
|
||||
"{}: each verdict its own fingerprint",
|
||||
desc.device_name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::OppositeZeroProductsMerged` is keyed on ANV, whatever its GPU and release:
|
||||
/// every committed ANV profile carries it, no other profile does, and the Iris Xe's description
|
||||
/// under RADV or NVIDIA's driver loses it (`tests::engine_zero_factors` checks the products of the
|
||||
/// profiles that carry it).
|
||||
#[test]
|
||||
fn opposite_zero_products_merged_is_keyed_on_anv() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let fact = DriverWorkaround::OppositeZeroProductsMerged;
|
||||
let profile_of = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.clone()
|
||||
};
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let anv = desc.driver_id == Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA);
|
||||
let p = profile_of(&desc);
|
||||
assert_eq!(p.workarounds().contains(&fact), anv, "{stem}");
|
||||
}
|
||||
let mut desc = profile("intel-irisxe-rplp-anv");
|
||||
assert!(profile_of(&desc).workarounds().contains(&fact));
|
||||
for other in [vk::DriverId::MESA_RADV, vk::DriverId::NVIDIA_PROPRIETARY] {
|
||||
desc.driver_id = Some(other);
|
||||
let p = profile_of(&desc);
|
||||
assert!(!p.workarounds().contains(&fact), "{other:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The Function storage a thread holds is the measured value of the device's identity, and on every
|
||||
/// committed profile of a device not measured the assumed floor, 16 KiB. It is keyed on the driver,
|
||||
/// the vendor, and the device ID together: the Radeon 780M's description under the RX 7900 XTX's
|
||||
/// device ID (a measured RADV GPU of no committed capture) takes the XTX's value, and under another
|
||||
/// device ID (an unmeasured RADV GPU, Navi 21's 0x73bf) or another driver is assumed. The Intel
|
||||
/// venue's two devices take one value, so they keep one translation key.
|
||||
#[test]
|
||||
fn function_storage_is_the_measured_value_of_the_device() {
|
||||
use crate::device::profile::FunctionStorage::{Assumed, Measured};
|
||||
let kib = 1024;
|
||||
let measured = [
|
||||
("amd-780m-hawkpoint-radv", 96 * kib),
|
||||
("amd-780m-radv", 96 * kib),
|
||||
("intel-irisxe-rplp-anv", 32 * kib),
|
||||
("intel-uhd770-rpls-anv", 32 * kib),
|
||||
("nvidia-rtx5080-laptop", 32 * kib),
|
||||
("moltenvk-m3", 192 * kib),
|
||||
("gate-lavapipe", 48 * kib),
|
||||
("gate-lavapipe-x86_64", 48 * kib),
|
||||
("lavapipe", 48 * kib),
|
||||
];
|
||||
let storage = |desc: DeviceDescription| {
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.function_storage
|
||||
};
|
||||
for (stem, _) in committed_profiles() {
|
||||
let want = measured
|
||||
.iter()
|
||||
.find(|(m, _)| *m == stem)
|
||||
.map_or(Assumed(16 * kib), |&(_, b)| Measured(b));
|
||||
assert_eq!(storage(profile(&stem)), want, "{stem}");
|
||||
}
|
||||
let mut desc = profile("amd-780m-radv");
|
||||
desc.device_id = 0x744c;
|
||||
assert_eq!(storage(desc.clone()), Measured(96 * kib));
|
||||
desc.device_id = 0x73bf;
|
||||
assert_eq!(storage(desc.clone()), Assumed(16 * kib));
|
||||
desc.device_id = 0x15bf;
|
||||
desc.driver_id = Some(vk::DriverId::AMD_OPEN_SOURCE);
|
||||
assert_eq!(storage(desc), Assumed(16 * kib));
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::VertexGroupingNotApples` is keyed on ANV, for every GPU it runs at every
|
||||
/// release: every committed ANV profile carries it, and another driver does not.
|
||||
#[test]
|
||||
fn anv_carries_the_vertex_grouping_at_every_release() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let fact = DriverWorkaround::VertexGroupingNotApples;
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&fact)
|
||||
};
|
||||
let mut desc = profile("intel-irisxe-rplp-anv");
|
||||
assert_eq!(desc.driver_id, Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA));
|
||||
assert!(carries(&desc));
|
||||
desc.device_id = 0x56a0;
|
||||
assert!(carries(&desc), "on another Intel GPU");
|
||||
desc.driver_version += 1;
|
||||
assert!(carries(&desc), "at another release");
|
||||
desc.driver_id = Some(vk::DriverId::MESA_RADV);
|
||||
assert!(!carries(&desc), "under RADV");
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let anv = desc.driver_id == Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA);
|
||||
assert_eq!(carries(&desc), anv, "{stem}");
|
||||
}
|
||||
assert!(carries(&profile("intel-uhd770-rpls-anv")));
|
||||
assert!(carries(&profile("intel-arl-anv")));
|
||||
assert!(carries(&profile("intel-irisxe-anv")));
|
||||
}
|
||||
|
||||
/// `DriverWorkaround::DontInlineKeepsCalls`, a cost fact, is keyed on the GPUs measured with it:
|
||||
/// NVIDIA's driver on the RTX 3090 and on the RTX 5080 Laptop GPU (`scripts/making-bench`), at
|
||||
/// every release. Another GPU of the vendor (the desktop RTX 50's committed profile, Pascal's),
|
||||
/// another vendor's ID, or another driver (NVK, Mesa's, MoltenVK) does not carry it.
|
||||
#[test]
|
||||
fn nvidia_keeps_dont_inline_calls_on_its_measured_gpu() {
|
||||
use crate::device::profile::DriverWorkaround;
|
||||
let fact = DriverWorkaround::DontInlineKeepsCalls;
|
||||
let carries = |desc: &DeviceDescription| {
|
||||
Device::new(desc.clone(), DevicePolicy::default())
|
||||
.unwrap()
|
||||
.profile()
|
||||
.fields()
|
||||
.workarounds
|
||||
.contains(&fact)
|
||||
};
|
||||
let mut desc = profile("nvidia-rtx5080-laptop");
|
||||
assert_eq!(desc.driver_id, Some(vk::DriverId::NVIDIA_PROPRIETARY));
|
||||
assert!(
|
||||
carries(&desc),
|
||||
"on the RTX 5080 Laptop GPU, where it was measured"
|
||||
);
|
||||
desc.device_id = crate::device::driver_facts::NVIDIA_RTX_3090;
|
||||
assert!(carries(&desc), "on the RTX 3090, where it was measured");
|
||||
desc.driver_version += 1 << 6;
|
||||
assert!(carries(&desc), "at another release");
|
||||
desc.vendor_id = 0x1002;
|
||||
assert!(!carries(&desc), "on another vendor's ID");
|
||||
desc.vendor_id = 0x10de;
|
||||
desc.driver_id = Some(vk::DriverId::MESA_NVK);
|
||||
assert!(!carries(&desc), "under NVK");
|
||||
for (stem, text) in committed_profiles() {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
assert_eq!(
|
||||
carries(&desc),
|
||||
stem == "nvidia-rtx5080-laptop",
|
||||
"{stem}: the RTX 5080 Laptop GPU's is the one committed profile of a measured GPU"
|
||||
);
|
||||
}
|
||||
assert!(!carries(&profile("nvidia-pascal-linux")));
|
||||
assert!(!carries(&profile("amd-780m-radv")));
|
||||
assert!(!carries(&profile("moltenvk-m3")));
|
||||
}
|
||||
@@ -146,7 +146,7 @@ fn render_features_follow_each_source() {
|
||||
for (stem, text) in committed_profiles() {
|
||||
let json: Value = serde_json::from_str(&text).unwrap();
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let enabled = &dev.profile().fields().enabled;
|
||||
for (structure, member, feature, extension) in FEATURES {
|
||||
let exposed = extension.is_none_or(|e| desc.extensions.contains(&e));
|
||||
@@ -217,7 +217,7 @@ fn render_properties_and_limits_follow_each_source() {
|
||||
for (stem, text) in committed_profiles() {
|
||||
let json: Value = serde_json::from_str(&text).unwrap();
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let properties = &dev.profile().fields().enabled.properties;
|
||||
let depth = stated_flags(&json, "supportedDepthResolveModes");
|
||||
let stencil = stated_flags(&json, "supportedStencilResolveModes");
|
||||
@@ -300,7 +300,7 @@ fn each_stated_color_attachment_sample_count_derives_its_property() {
|
||||
for (stem, text) in committed_profiles() {
|
||||
let json: Value = serde_json::from_str(&text).unwrap();
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let derived: BTreeSet<(vk::Format, u32)> = dev
|
||||
.profile()
|
||||
.fields()
|
||||
@@ -380,7 +380,7 @@ fn the_provoking_vertex_mode_per_pipeline_follows_each_source() {
|
||||
for (stem, text) in committed_profiles() {
|
||||
let json: Value = serde_json::from_str(&text).unwrap();
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).unwrap();
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let properties = &dev.profile().fields().enabled.properties;
|
||||
let exposed = desc.extensions.contains(&VkExtension::ExtProvokingVertex);
|
||||
let stated = stated_true(
|
||||
|
||||
@@ -597,7 +597,7 @@ fn metal_properties_report_d3_d4_values() {
|
||||
formatless
|
||||
.features
|
||||
.insert(VkFeature::ShaderStorageImageWriteWithoutFormat);
|
||||
let formatless = Device::new(formatless, DevicePolicy::default()).unwrap();
|
||||
let formatless = Device::from_queries(formatless, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(
|
||||
formatless.metal_properties().read_write_texture_tier,
|
||||
ReadWriteTextureTier::Tier1
|
||||
|
||||
@@ -543,14 +543,11 @@ pub enum Needs {
|
||||
/// change. A device without the defect runs the input.
|
||||
RuntimeDriverDefect(RuntimeDriverDefect),
|
||||
/// The stage, as this device's plan writes it, is heavier than the translator hands any
|
||||
/// driver of a device [`Device::from_queries`](crate::device::Device::from_queries) made: its
|
||||
/// entry weight passes the heaviest stage measured to compile within host-sized memory
|
||||
/// driver: its entry weight passes the heaviest stage measured to compile within host-sized memory
|
||||
/// ([`Unsupported::symbol`] names the weight and the bound). The weight is the plan's, so a
|
||||
/// device whose plan writes the stage lighter translates it: one that keeps its widest
|
||||
/// simdgroup mode pinned where this one emulates simdgroups. A gap of the translator rather
|
||||
/// than of the device: no such device is handed a stage past the bound. A device
|
||||
/// [`Device::new`](crate::device::Device::new) made bounds a stage only where its driver is
|
||||
/// measured to need it ([`Needs::DriverDefect`]).
|
||||
/// than of the device: no device is handed a stage past the bound.
|
||||
StageBound,
|
||||
/// A device that claims this Metal GPU family (`MTLGPUFamily`'s raw value, 1010 for Apple10),
|
||||
/// which the device does not: Metal itself refuses the input on a device without the family,
|
||||
|
||||
@@ -103,25 +103,11 @@ pub fn select(cx: &mut SelectCx<'_>, at: InstId, inst: &Inst) -> Result<Option<A
|
||||
Ok(Some(AbsentRead { result, marks }))
|
||||
}
|
||||
|
||||
/// What an absent read needs, stated for the stage, and whether it marks the status: on a profile
|
||||
/// whose absent reads mark it (`AbsentReads::Marked`), the `ExecutionStatus` buffer
|
||||
/// ([`state_status`]) and the stage's stores and atomics, a device without them refusing the read
|
||||
/// as `FunctionConstantArgument`, naming what it needs; on one whose absent reads read as nil
|
||||
/// (`AbsentReads::Nil`), nothing, and the read does not mark. The texture and sampler families'
|
||||
/// arms on the absent handle need the same.
|
||||
pub fn require(cx: &mut SelectCx<'_>) -> Result<bool, Error> {
|
||||
if cx.profile.absent_reads() == AbsentReads::Nil {
|
||||
return Ok(false);
|
||||
}
|
||||
if let Some(StatusShort::Stores(f)) = status_short(cx) {
|
||||
return Err(
|
||||
Unsupported::needs(Feature::FunctionConstantArgument, Capability::Feature(f)).into(),
|
||||
);
|
||||
}
|
||||
state_status(cx, StatusBinding::Required);
|
||||
cx.facts
|
||||
.insert(RuntimeFact::AbsentArgumentRead { stage: cx.stage });
|
||||
Ok(true)
|
||||
/// What an absent read needs, stated for the stage, and whether it marks the status: nothing, and
|
||||
/// it does not mark, an absent read reading as nil. The texture and sampler families' arms on the
|
||||
/// absent handle need the same.
|
||||
pub fn require(_cx: &mut SelectCx<'_>) -> Result<bool, Error> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
/// What the stage lacks to write the command buffer's `ExecutionStatus` words. Each refusal
|
||||
|
||||
@@ -103,7 +103,7 @@ use crate::air::ir::{
|
||||
IntPredicate, Type, TypeId, Value, ValueId,
|
||||
};
|
||||
use crate::budget::{tree_bytes, Meter, PRIVATE_ARENA_BYTES};
|
||||
use crate::device::profile::{Containment, GuestIsolation, ThreadgroupMemory, ThreadgroupStart};
|
||||
use crate::device::profile::{Containment, GuestIsolation};
|
||||
use crate::device::requirements::VkFeature;
|
||||
use crate::error::{Capability, Error, Feature, Limit, LowerFamily, Unsupported};
|
||||
use crate::lower::emit::EmitCx;
|
||||
@@ -464,7 +464,7 @@ pub struct LocalPlan {
|
||||
pub positions: BTreeMap<Home, u32>,
|
||||
/// Whether the threadgroup arena's array and every typed threadgroup object are declared with
|
||||
/// a null initializer, so the function's threadgroup memory reads zero until it writes it
|
||||
/// (`ThreadgroupStart::Zero`, [`zero_threadgroup`]).
|
||||
/// ([`zero_threadgroup`]).
|
||||
pub zeroed: bool,
|
||||
}
|
||||
|
||||
@@ -636,14 +636,10 @@ fn count_and_init(
|
||||
Ok((count, init))
|
||||
}
|
||||
|
||||
/// Where the profile's threadgroup memory starts at zero (`ThreadgroupStart::Zero`), record that
|
||||
/// the function's threadgroup memory, a `Workgroup` variable, is declared with a null initializer:
|
||||
/// `Unsupported{ZeroedThreadgroupMemory}` on a profile without
|
||||
/// Record that the function's threadgroup memory, a `Workgroup` variable, is declared with a null
|
||||
/// initializer, so it starts at zero: `Unsupported{ZeroedThreadgroupMemory}` on a profile without
|
||||
/// `shaderZeroInitializeWorkgroupMemory`, which Vulkan requires of any initializer there.
|
||||
fn zero_threadgroup(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
if cx.profile.threadgroup_start() != ThreadgroupStart::Zero {
|
||||
return Ok(());
|
||||
}
|
||||
let feature = VkFeature::ShaderZeroInitializeWorkgroupMemory;
|
||||
if !cx.profile.fields().enabled.features.contains(&feature) {
|
||||
return Err(Unsupported::needs(
|
||||
@@ -710,9 +706,7 @@ pub(super) fn use_arena(cx: &mut SelectCx<'_>, arena: Arena) -> Result<(), Error
|
||||
// function's.
|
||||
shape.tile = (fragment || super::tile::is_tile(cx)) && !shape.regions.is_empty();
|
||||
// Only a kernel's own workgroup arena may be of `float` words.
|
||||
let floats = cx.stage == Stage::Kernel
|
||||
&& !super::tile::is_tile(cx)
|
||||
&& cx.profile.threadgroup_memory() == ThreadgroupMemory::Native;
|
||||
let floats = cx.stage == Stage::Kernel && !super::tile::is_tile(cx);
|
||||
if !floats {
|
||||
shape.words = TgWords::Composed;
|
||||
}
|
||||
@@ -1195,12 +1189,9 @@ pub(crate) fn access(
|
||||
}
|
||||
|
||||
/// Whether an access of `arena` is contained (the module docs): unless the profile's containment
|
||||
/// is `UnsafeOff`, or the arena is threadgroup memory on a profile that contains none
|
||||
/// (`ThreadgroupMemory::Native`).
|
||||
/// is `UnsafeOff`, or the arena is threadgroup memory, which no profile contains.
|
||||
pub(crate) fn contained(cx: &SelectCx<'_>, arena: Arena) -> bool {
|
||||
cx.profile.fields().containment != Containment::UnsafeOff
|
||||
&& !(arena == Arena::Threadgroup
|
||||
&& cx.profile.threadgroup_memory() == ThreadgroupMemory::Native)
|
||||
cx.profile.fields().containment != Containment::UnsafeOff && arena != Arena::Threadgroup
|
||||
}
|
||||
|
||||
/// A pointer's offset shape while reading its definitions: `Empty` is a join's identity.
|
||||
@@ -2064,7 +2055,7 @@ pub(super) fn emit_access_at(
|
||||
|
||||
/// Load or store (`stored`) `a`'s leaf, whole `float` words, at byte offset `off` of an arena of
|
||||
/// `float` words (`ArenaDecl::floats`, the module docs): lane `j` of `lanes` at word
|
||||
/// `off / 4 + j`, one typed access each, uncontained (`ThreadgroupMemory::Native`).
|
||||
/// `off / 4 + j`, one typed access each, uncontained.
|
||||
fn float_words(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
|
||||
@@ -124,7 +124,7 @@ use std::collections::{BTreeMap, BTreeSet};
|
||||
use crate::air::abi::{AbiInt, ParamBinding, ParamRole};
|
||||
use crate::air::ir::{AddrSpace, CastOp, Const, Inst, InstId, InstKind, Type, Value, ValueId};
|
||||
use crate::budget::Meter;
|
||||
use crate::device::profile::{BufferAccess, Containment, DriverWorkaround, Limits, PushWindow};
|
||||
use crate::device::profile::{BufferAccess, Containment, DriverWorkaround, Limits};
|
||||
use crate::device::requirements::VkLimit;
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::{Capability, Error, Feature, LowerFamily, Unsupported};
|
||||
@@ -1222,9 +1222,8 @@ struct Census {
|
||||
/// Under the identity domains a device-address slot reads its own address
|
||||
/// ([`address_field`]), not the root table.
|
||||
identity: bool,
|
||||
/// The profile's push window and the stage's push base, which decide where the fields
|
||||
/// spill.
|
||||
window: (PushWindow, u32),
|
||||
/// The stage's push base, which decides where the fields spill.
|
||||
push_base: u32,
|
||||
}
|
||||
|
||||
impl Census {
|
||||
@@ -1232,7 +1231,7 @@ impl Census {
|
||||
/// pointer reads the root table.
|
||||
fn new(
|
||||
push: &BTreeSet<PushField>,
|
||||
(dynamic, identity, window): (bool, bool, (PushWindow, u32)),
|
||||
(dynamic, identity, push_base): (bool, bool, u32),
|
||||
forms: impl Iterator<Item = (SlotRef, SlotLowering)>,
|
||||
m: &mut Meter,
|
||||
) -> Result<Census, Error> {
|
||||
@@ -1242,7 +1241,7 @@ impl Census {
|
||||
texel: 0,
|
||||
fields: push.clone(),
|
||||
identity,
|
||||
window,
|
||||
push_base,
|
||||
};
|
||||
let mut psb = dynamic;
|
||||
for (slot, l) in forms {
|
||||
@@ -1278,7 +1277,7 @@ impl Census {
|
||||
// Under the identity domains the spilled fields are a parameter block at a pushed
|
||||
// address, no descriptor.
|
||||
uniform_buffers: u32::from(
|
||||
!self.identity && table::spills(stage, self.window.0, self.window.1, &self.fields),
|
||||
!self.identity && table::spills(stage, self.push_base, &self.fields),
|
||||
)
|
||||
.saturating_add(self.uniform),
|
||||
storage_buffers: self.storage,
|
||||
@@ -1484,7 +1483,7 @@ fn place_slots(cx: &mut SelectCx<'_>, m: &mut Meter) -> Result<Vec<Option<SlotCh
|
||||
(
|
||||
cx.families.access.dynamic.used,
|
||||
identity(p),
|
||||
(p.push_window(), cx.inputs.push_base),
|
||||
cx.inputs.push_base,
|
||||
),
|
||||
forms,
|
||||
m,
|
||||
@@ -1717,8 +1716,7 @@ fn place_slots(cx: &mut SelectCx<'_>, m: &mut Meter) -> Result<Vec<Option<SlotCh
|
||||
}
|
||||
let counts = census.counts(stage);
|
||||
cx.descriptors = cx.descriptors.plus(&counts);
|
||||
cx.families.access.argument_table =
|
||||
table::spills(stage, p.push_window(), cx.inputs.push_base, &cx.push);
|
||||
cx.families.access.argument_table = table::spills(stage, cx.inputs.push_base, &cx.push);
|
||||
// Under the identity domains a function whose fields spill, of any stage, reads them from a
|
||||
// parameter block whose address its window holds first: a render pipeline's stages too, in
|
||||
// their shares of the floor's one range (`push::VERTEX_FLOOR_END`).
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::device::profile::PushWindow;
|
||||
use crate::lower::push::{self, FieldShape};
|
||||
use crate::pipeline::interface::{PushLoc, PushPlacement};
|
||||
use crate::pipeline::sym::{PushField, ResourceKind, ResourceSlot, Stage, SyntheticBinding};
|
||||
@@ -37,10 +36,9 @@ pub struct Table {
|
||||
pub fields: Vec<PushField>,
|
||||
}
|
||||
|
||||
/// Whether `stage`'s placement of `fields` in push window `w` spills into the `ArgumentTable`
|
||||
/// (`push::spills`).
|
||||
pub fn spills(stage: Stage, w: PushWindow, base: u32, fields: &BTreeSet<PushField>) -> bool {
|
||||
push::spills(stage, w, base, fields)
|
||||
/// Whether `stage`'s placement of `fields` spills into the `ArgumentTable` (`push::spills`).
|
||||
pub fn spills(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> bool {
|
||||
push::spills(stage, base, fields)
|
||||
}
|
||||
|
||||
/// The binding symbol of `stage`'s `ArgumentTable`.
|
||||
|
||||
@@ -11,39 +11,21 @@
|
||||
//! - [`Route::Native`]: the device's `GLSL.std.450 Fma`, within Vulkan's precision rather than
|
||||
//! rounded once (`PrecisionNote::NativeFma`).
|
||||
//!
|
||||
//! Where the driver is measured to compute `GLSL.std.450 Fma` on 16-bit floats as Metal's own
|
||||
//! `half` `fma` (`DriverDeviation::MetalHalfFma`: MoltenVK on Apple's GPUs) and the profile has
|
||||
//! `shaderFloat16`, a `half` one takes [`Route::F16`]: its operands, each a `half` held in a
|
||||
//! `float`, convert to 16 bits exactly, the device's `Fma` rounds the exact sum once as Metal
|
||||
//! does, and its result widens exactly; the module then requires `VkProperty::MetalHalfFma`.
|
||||
//!
|
||||
//! Where the profile has `shaderFmaFloat16` and computes under the 16-bit float controls
|
||||
//! ([`narrow::half_controls`]), a `half` one takes
|
||||
//! [`Route::F16Khr`]: its operands convert to 16 bits exactly, `OpFmaKHR` on them rounds the exact
|
||||
//! sum once, and its result widens exactly. Vulkan's precision table lists `OpFmaKHR` as "Correctly
|
||||
//! rounded", "according to IEEE 754 roundTiesToEven" under `RoundingModeRTE`, with denormals kept
|
||||
//! under `DenormPreserve` and zero signs under `SignedZeroInfNanPreserve`, which the entry then
|
||||
//! declares (`narrow::computes_in_16_bits`): Metal's `half` `fma`, with no fact. A NaN's bits are
|
||||
//! the device's, as the controlled rounding's are. Every other `half` one takes [`Route::Native`]: the device's `float` `Fma`
|
||||
//! of the operands held in `float`, whose product is exact there, rounded to `half`.
|
||||
//!
|
||||
//! Those three are `Device::new`'s (`HalfFma::Measured`). On a profile `Device::from_queries`
|
||||
//! built (`HalfFma::Native`), which reads no driver identity, a `half` one takes
|
||||
//! [`Route::F16Native`] where the profile computes `half` under the 16-bit float controls
|
||||
//! A `half` one takes [`Route::F16Native`] where the profile computes `half` under the 16-bit
|
||||
//! float controls
|
||||
//! ([`narrow::half_controls`]): the device's `Fma` on 16-bit floats between the same exact
|
||||
//! conversions, which the module's 16-bit holding then removes (`spirv::half_hold`), so the
|
||||
//! operands and the result stay 16-bit floats. Its precision is Vulkan's for `Fma`, inherited from
|
||||
//! an `OpFMul` followed by an `OpFAdd`, each correctly rounded to `half` under the controls'
|
||||
//! `RoundingModeRTE`, where Metal's rounds once: noted `PrecisionNote::NativeFma`, as
|
||||
//! [`Route::Native`] is. `OpFmaKHR` is not taken there: `shaderFmaFloat16` is not a query that may
|
||||
//! choose a second form. Every other `half` one on that profile takes [`Route::Native`].
|
||||
//! choose a second form. Every other `half` one takes [`Route::Native`]: the device's `float`
|
||||
//! `Fma` of the operands held in `float`, whose product is exact there, rounded to `half`.
|
||||
//!
|
||||
//! An extended-range blend computes its own correctly rounded multiply-adds ([`half_sum`],
|
||||
//! [`float_fma_exact`]): the blend the device cannot do, in plain arithmetic.
|
||||
|
||||
use crate::device::profile::HalfFma;
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::DriverDeviation;
|
||||
use crate::lower::arith::legal::{FloatFmt, Form, Held};
|
||||
use crate::lower::arith::narrow::{self, u32_form};
|
||||
use crate::lower::arith::ops::{fsplat, splat, ty};
|
||||
@@ -57,15 +39,9 @@ use crate::spirv::ir::{BinOp, Contraction, ConvOp, GlslOp, Type};
|
||||
pub enum Route {
|
||||
/// `OpFmaKHR` on `float`.
|
||||
Khr,
|
||||
/// A `half` fused multiply-add by the device's `Fma` on 16-bit floats, Metal's own
|
||||
/// ([`half_route`]).
|
||||
F16,
|
||||
/// A `half` fused multiply-add by `OpFmaKHR` on 16-bit floats under the 16-bit float
|
||||
/// controls, correctly rounded by the Vulkan spec ([`half_route`]).
|
||||
F16Khr,
|
||||
/// A `half` fused multiply-add by the device's `Fma` on 16-bit floats under the 16-bit float
|
||||
/// controls, on `Device::from_queries`' profile: within Vulkan's precision rather than rounded
|
||||
/// once (`PrecisionNote::NativeFma`) ([`half_route`]).
|
||||
/// controls: within Vulkan's precision rather than rounded once (`PrecisionNote::NativeFma`)
|
||||
/// ([`half_route`]).
|
||||
F16Native,
|
||||
/// The device's `GLSL.std.450 Fma` on the `float` lanes (a `half`'s held in `float`, its
|
||||
/// result rounded to `half`), within Vulkan's precision rather than rounded once
|
||||
@@ -84,10 +60,6 @@ impl Route {
|
||||
/// The census names of the fused multiply-add strategies (one per [`Route`]).
|
||||
pub const KHR: &str = "arith.fma.khr";
|
||||
/// See [`KHR`].
|
||||
pub const F16: &str = "arith.fma.f16";
|
||||
/// See [`KHR`].
|
||||
pub const F16_KHR: &str = "arith.fma.f16.khr";
|
||||
/// See [`KHR`].
|
||||
pub const F16_NATIVE: &str = "arith.fma.f16.native";
|
||||
/// See [`KHR`].
|
||||
pub const NATIVE: &str = "arith.fma.native";
|
||||
@@ -102,24 +74,13 @@ pub fn float_route(p: &DeviceProfile) -> Route {
|
||||
}
|
||||
}
|
||||
|
||||
/// The `half` route profile `p` offers. On `Device::new`'s profile (`HalfFma::Measured`):
|
||||
/// [`Route::F16`] where the driver is measured to compute a 16-bit `Fma` as Metal's own `half`
|
||||
/// `fma` (`DriverDeviation::MetalHalfFma`) and `shaderFloat16` is enabled, else [`Route::F16Khr`]
|
||||
/// where `shaderFmaFloat16` is and the profile computes under the 16-bit float controls
|
||||
/// (`narrow::half_controls`). On `Device::from_queries`' (`HalfFma::Native`): [`Route::F16Native`]
|
||||
/// where the profile computes under those controls. Elsewhere the device's `float` `Fma` rounded
|
||||
/// to `half` ([`Route::Native`]).
|
||||
/// The `half` route profile `p` offers: [`Route::F16Native`] where the profile computes under the
|
||||
/// 16-bit float controls (`narrow::half_controls`), else the device's `float` `Fma` rounded to
|
||||
/// `half` ([`Route::Native`]).
|
||||
pub fn half_route(p: &DeviceProfile) -> Route {
|
||||
let leaf = &p.fields().leaf;
|
||||
match p.half_fma() {
|
||||
HalfFma::Measured
|
||||
if p.takes_driver_deviation(DriverDeviation::MetalHalfFma) && leaf.float16 =>
|
||||
{
|
||||
Route::F16
|
||||
}
|
||||
HalfFma::Measured if leaf.fma16 && narrow::half_controls(p) => Route::F16Khr,
|
||||
HalfFma::Native if narrow::half_controls(p) => Route::F16Native,
|
||||
HalfFma::Measured | HalfFma::Native => Route::Native,
|
||||
match narrow::half_controls(p) {
|
||||
true => Route::F16Native,
|
||||
false => Route::Native,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,20 +124,17 @@ impl Fma {
|
||||
pub fn name(self) -> &'static str {
|
||||
match self.route {
|
||||
Route::Khr => KHR,
|
||||
Route::F16 => F16,
|
||||
Route::F16Khr => F16_KHR,
|
||||
Route::F16Native => F16_NATIVE,
|
||||
Route::Native => NATIVE,
|
||||
}
|
||||
}
|
||||
|
||||
/// An upper estimate of the SPIR-V words per use: the instruction; on [`Route::F16`],
|
||||
/// [`Route::F16Khr`] and [`Route::F16Native`] the three conversions, the instruction and the
|
||||
/// widening.
|
||||
/// An upper estimate of the SPIR-V words per use: the instruction; on [`Route::F16Native`] the
|
||||
/// three conversions, the instruction and the widening.
|
||||
pub fn words(self) -> u32 {
|
||||
match self.route {
|
||||
Route::Khr => 16,
|
||||
Route::F16 | Route::F16Khr | Route::F16Native => 32,
|
||||
Route::F16Native => 32,
|
||||
// The instruction, and a `half` result's rounding.
|
||||
Route::Native => 64,
|
||||
}
|
||||
@@ -190,10 +148,7 @@ pub fn emit(fb: &mut FunctionBuilder<'_>, fma: Fma, args: &[Value]) -> BResult<V
|
||||
};
|
||||
match (fma.route, fma.form.float_fmt()) {
|
||||
(Route::Khr, Some(FloatFmt::F32)) => fb.fma(a, b, c),
|
||||
(Route::F16 | Route::F16Native, Some(FloatFmt::Half)) => {
|
||||
f16(fb, fma.form.lanes, [a, b, c], false)
|
||||
}
|
||||
(Route::F16Khr, Some(FloatFmt::Half)) => f16(fb, fma.form.lanes, [a, b, c], true),
|
||||
(Route::F16Native, Some(FloatFmt::Half)) => f16(fb, fma.form.lanes, [a, b, c]),
|
||||
// The device's `Fma`; on `half` operands held in `float` the product is exact, so only
|
||||
// the sum's rounding and the rounding to `half` differ from Metal's one rounding.
|
||||
(Route::Native, Some(FloatFmt::F32)) => fb.glsl(GlslOp::Fma, &[a, b, c]),
|
||||
@@ -206,18 +161,10 @@ pub fn emit(fb: &mut FunctionBuilder<'_>, fma: Fma, args: &[Value]) -> BResult<V
|
||||
}
|
||||
|
||||
/// The `half` fused multiply-add of `a`, `b`, `c` (`half` values held in `float` lanes of
|
||||
/// `lanes` lanes) by the device's `Fma` on 16-bit floats ([`Route::F16`], [`Route::F16Native`]),
|
||||
/// or by `OpFmaKHR` on them where `khr` ([`Route::F16Khr`]): each operand converted to 16 bits,
|
||||
/// exactly since it is a `half`, the instruction, and its result widened, exactly. The device
|
||||
/// rounds the exact sum once, as Metal's `half` `fma` does: measured where the profile takes
|
||||
/// `DriverDeviation::MetalHalfFma`, by the Vulkan spec for `OpFmaKHR` under the 16-bit float
|
||||
/// controls; on [`Route::F16Native`], within Vulkan's precision for `Fma`, noted.
|
||||
fn f16(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
lanes: u8,
|
||||
[a, b, c]: [Value; 3],
|
||||
khr: bool,
|
||||
) -> BResult<Value> {
|
||||
/// `lanes` lanes) by the device's `Fma` on 16-bit floats ([`Route::F16Native`]): each operand
|
||||
/// converted to 16 bits, exactly since it is a `half`, the instruction, and its result widened,
|
||||
/// exactly, within Vulkan's precision for `Fma`, noted.
|
||||
fn f16(fb: &mut FunctionBuilder<'_>, lanes: u8, [a, b, c]: [Value; 3]) -> BResult<Value> {
|
||||
let lanes_of = |fb: &mut FunctionBuilder<'_>, width: u8| -> BResult<_> {
|
||||
let e = fb.module().ty(Type::Float { width })?;
|
||||
match lanes {
|
||||
@@ -228,11 +175,7 @@ fn f16(
|
||||
let (h, w) = (lanes_of(fb, 16)?, lanes_of(fb, 32)?);
|
||||
let narrow = |fb: &mut FunctionBuilder<'_>, x: Value| fb.convert(ConvOp::FConvert, x, h);
|
||||
let (a, b, c) = (narrow(fb, a)?, narrow(fb, b)?, narrow(fb, c)?);
|
||||
let r = if khr {
|
||||
fb.fma(a, b, c)?
|
||||
} else {
|
||||
fb.glsl(GlslOp::Fma, &[a, b, c])?
|
||||
};
|
||||
let r = fb.glsl(GlslOp::Fma, &[a, b, c])?;
|
||||
fb.convert(ConvOp::FConvert, r, w)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! `half` arithmetic held at `float` precision between its roundings on a device without
|
||||
//! `shaderFloat16`: the fast form of that capability's emulation (`DevicePolicy::half_chains`).
|
||||
//! `shaderFloat16`: the fast form of that capability's emulation.
|
||||
//!
|
||||
//! Without `shaderFloat16` a module computes a `half` `+ - *` in `float` on its operands held
|
||||
//! widened and rounds the result by the device's `OpQuantizeToF16` ([`super::narrow::round`],
|
||||
//! `PrecisionNote::NativeHalfQuantize`). Under `HalfChainPolicy::AtExits` (the default) [`plan`]
|
||||
//! `PrecisionNote::NativeHalfQuantize`). [`plan`]
|
||||
//! marks each addition, subtraction and product on `half` whose flags hold `contract` and
|
||||
//! `reassoc` and whose result is read, and only by such operations: selection computes it in
|
||||
//! `float` and leaves it unrounded ([`super::ArithPlan::held_at_float`]). A chain of them rounds
|
||||
@@ -14,26 +14,21 @@
|
||||
//! `PrecisionNote::FastMathRewrites`, which records the difference: the roundings the chain skips,
|
||||
//! and a value inside it past `half`'s range staying finite.
|
||||
//!
|
||||
//! Under `HalfChainPolicy::EachOperation`, and on a device with `shaderFloat16` under either value,
|
||||
//! nothing is marked.
|
||||
//! On a device with `shaderFloat16` nothing is marked.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::air::ir::{BinOp as AirBin, FastMath, InstId, InstKind, Type, Value};
|
||||
use crate::budget::Meter;
|
||||
use crate::device::HalfChainPolicy;
|
||||
use crate::error::Error;
|
||||
use crate::lower::select::SelectCx;
|
||||
use crate::spirv::builder::QuantizeForm;
|
||||
|
||||
/// The `half` additions, subtractions and products of `cx`'s body held at `float` precision: on a
|
||||
/// profile without `shaderFloat16` under `HalfChainPolicy::AtExits`, each whose flags hold
|
||||
/// profile without `shaderFloat16`, each whose flags hold
|
||||
/// `contract` and `reassoc` and whose every use is such an operation; none elsewhere.
|
||||
pub fn plan(cx: &SelectCx<'_>, m: &mut Meter) -> Result<BTreeSet<InstId>, Error> {
|
||||
let fields = cx.profile.fields();
|
||||
if fields.half_chains != HalfChainPolicy::AtExits
|
||||
|| super::narrow::quantize_form(cx.profile) != QuantizeForm::Device
|
||||
{
|
||||
if super::narrow::quantize_form(cx.profile) != QuantizeForm::Device {
|
||||
return Ok(BTreeSet::new());
|
||||
}
|
||||
let n = cx.body.insts.len();
|
||||
|
||||
@@ -735,9 +735,6 @@ pub struct ArithPlan {
|
||||
/// padded or bfloat form ([`ArithPlan::converts`]) by the device's arithmetic
|
||||
/// ([`extended_range`]): [`finish`] then records `PrecisionNote::DevicePackConversion`.
|
||||
pub extended_range: bool,
|
||||
/// Whether a `half` fused multiply-add takes the device's 16-bit `Fma` ([`fma::Route::F16`]),
|
||||
/// recorded at selection: the module then requires `VkProperty::MetalHalfFma`.
|
||||
pub f16_fma: bool,
|
||||
/// Whether a `float` operation leaves its `f32` denormals to the device because the device
|
||||
/// reads them as Metal does ([`denormal::device_flushes`]), recorded at selection: the module
|
||||
/// then requires `VkProperty::MetalFloatDenormals`, or, where its entry declares the 16-bit
|
||||
@@ -808,11 +805,9 @@ impl ArithPlan {
|
||||
self.extended_range = true;
|
||||
}
|
||||
|
||||
/// Record fused multiply-add `fma`, selected: the device's 16-bit `Fma` measured to be Metal's
|
||||
/// ([`ArithPlan::f16_fma`]), or the device's `Fma`, on `float` or on 16-bit floats
|
||||
/// ([`ArithPlan::native_fma`]).
|
||||
/// Record fused multiply-add `fma`, selected: the device's `Fma`, on `float` or on 16-bit
|
||||
/// floats ([`ArithPlan::native_fma`]).
|
||||
pub fn take_fma(&mut self, fma: fma::Fma) {
|
||||
self.f16_fma |= fma.route == fma::Route::F16;
|
||||
self.native_fma |= matches!(fma.route, fma::Route::Native | fma::Route::F16Native);
|
||||
}
|
||||
}
|
||||
@@ -2422,7 +2417,7 @@ fn native_fma(fma: fma::Fma) -> OpNotes {
|
||||
fma::Route::Native | fma::Route::F16Native => {
|
||||
OpNotes::everywhere(BTreeSet::from([PrecisionNote::NativeFma]))
|
||||
}
|
||||
fma::Route::Khr | fma::Route::F16 | fma::Route::F16Khr => OpNotes::default(),
|
||||
fma::Route::Khr => OpNotes::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,15 +77,13 @@
|
||||
//! as Metal's object grid is (measured: an indirect draw runs every threadgroup and reports the
|
||||
//! grid its wrapped threads fill); it is `NumWorkgroups` wherever no axis wraps.
|
||||
//!
|
||||
//! Under the identity domains ([`DispatchPlan::identity_region`]) every dispatch states its region,
|
||||
//! Under the identity domains ([`DispatchPlan::identity`]) every dispatch states its region,
|
||||
//! and the region's grid selects the grid builtins' form: a dispatch the host knows
|
||||
//! (`dispatchThreads`, `dispatchThreadgroups`, and each piece of a split of either) states Metal's
|
||||
//! `threads_per_grid` in `region[1].xyz`, so the pieces of a split read Metal's whole grid; an
|
||||
//! indirect dispatch states `region[1].xyz = 0` and takes the single-region form, its grid
|
||||
//! `NumWorkgroups · L`, which needs its workgroup size to be Metal's threadgroup size. So one
|
||||
//! pipeline runs every dispatch of a threadgroup size. The base and `L` take one of two forms
|
||||
//! (`IdentityRegion`). On `Device::new`'s profile the grid selects them too, and the kernel
|
||||
//! declares no `MultiRegion`. On `Device::from_queries`' the base is `region[0].xyz` on every
|
||||
//! pipeline runs every dispatch of a threadgroup size. The base is `region[0].xyz` on every
|
||||
//! dispatch (0 for one that is not split and for an indirect one), and `MultiRegion` says only
|
||||
//! whether `L` is the region's nominal size (1, a region whose threadgroup size is not its
|
||||
//! pipeline's, as the binder's edge regions are) or the pipeline's `(sx, sy, sz)` (0, the
|
||||
@@ -187,7 +185,6 @@
|
||||
|
||||
use crate::air::abi::{Builtin, ParamBinding, ParamRole};
|
||||
use crate::air::ir::{ArgIdx, Value};
|
||||
use crate::device::profile::{DeepThreadgroups, IdentityRegion, ObliviousEdge};
|
||||
use crate::device::subgroup::{self, SimdClass, Tier};
|
||||
use crate::error::{Error, Feature, LowerFamily, Unsupported};
|
||||
use crate::lower::arith;
|
||||
@@ -463,15 +460,10 @@ pub struct PlannedParam {
|
||||
enum RegionSelect {
|
||||
/// The `MultiRegion` specialization constant.
|
||||
Spec(ConstId),
|
||||
/// Under the identity domains on `Device::new`'s profile (`IdentityRegion::Grid`), the
|
||||
/// region's grid: `region[1].xyz` is Metal's `threads_per_grid` for every dispatch the host
|
||||
/// knows, and all 0 for an indirect one. So one pipeline runs both, with no constant to
|
||||
/// specialize.
|
||||
Grid,
|
||||
/// Under the identity domains on `Device::from_queries`' profile (`IdentityRegion::Sized`):
|
||||
/// the region's grid as [`RegionSelect::Grid`], but the base is the region's on every
|
||||
/// dispatch, and the `MultiRegion` constant says only whether `L` is the region's nominal
|
||||
/// size.
|
||||
/// Under the identity domains, the region's grid: `region[1].xyz` is Metal's
|
||||
/// `threads_per_grid` for every dispatch the host knows, and all 0 for an indirect one, so one
|
||||
/// pipeline runs both. The base is the region's on every dispatch, and the `MultiRegion`
|
||||
/// constant says only whether `L` is the region's nominal size.
|
||||
Sized(ConstId),
|
||||
}
|
||||
|
||||
@@ -541,9 +533,8 @@ pub struct DispatchPlan {
|
||||
/// grid tiles).
|
||||
pub grid_edge: bool,
|
||||
/// Under the identity domains a kernel tells a region from an indirect dispatch by the
|
||||
/// region's grid, and reads its base and `L` as the profile's form says
|
||||
/// ([`RegionSelect::Grid`], [`RegionSelect::Sized`]). `None` outside them.
|
||||
pub identity_region: Option<IdentityRegion>,
|
||||
/// region's grid, and reads its base and `L` as [`RegionSelect::Sized`] says.
|
||||
pub identity: bool,
|
||||
/// The subgroup size the pipeline pins in a flattened tier
|
||||
/// (`SubgroupRequirement::size`): `lin` multiplies the subgroup index by it as a constant and
|
||||
/// never reads `SubgroupSize`. `None` outside the flattened tiers and where the stage pins no
|
||||
@@ -612,15 +603,12 @@ fn reads_region(b: KernelBuiltin, tile_sized: bool) -> bool {
|
||||
|
||||
/// Whether a kernel's partial-threadgroups variant runs its grid in tiles
|
||||
/// ([`DispatchPlan::grid_edge`]): a kernel that does not observe its threadgroup partition
|
||||
/// (`pipeline::compile::partition`, decided from its AIR) on a profile whose [`ObliviousEdge`] is
|
||||
/// `Grid`, under the identity domains, whose regions state their base on every dispatch
|
||||
/// ([`IdentityRegion::Sized`]).
|
||||
/// (`pipeline::compile::partition`, decided from its AIR) under the identity domains, whose
|
||||
/// regions state their base on every dispatch ([`RegionSelect::Sized`]).
|
||||
fn grid_edge(cx: &SelectCx<'_>) -> bool {
|
||||
use crate::pipeline::compile::partition::{partition, Partition};
|
||||
cx.stage == crate::pipeline::sym::Stage::Kernel
|
||||
&& cx.profile.oblivious_edge() == ObliviousEdge::Grid
|
||||
&& crate::lower::access::identity(cx.profile)
|
||||
&& cx.profile.identity_region() == IdentityRegion::Sized
|
||||
&& partition(cx.entry) == Partition::Oblivious
|
||||
}
|
||||
|
||||
@@ -746,7 +734,6 @@ pub fn plan_kernel(cx: &mut SelectCx<'_>, tier: Tier) -> Result<DispatchPlan, Er
|
||||
}
|
||||
let deep = local_size == LocalSizeForm::Spec
|
||||
&& cx.stage == crate::pipeline::sym::Stage::Kernel
|
||||
&& cx.profile.deep_threadgroups() == DeepThreadgroups::OneRow
|
||||
&& !cx.families.barrier.compute_derivatives;
|
||||
Ok(DispatchPlan {
|
||||
local_size,
|
||||
@@ -764,8 +751,7 @@ pub fn plan_kernel(cx: &mut SelectCx<'_>, tier: Tier) -> Result<DispatchPlan, Er
|
||||
object_grid: !folded_groups && cx.stage == crate::pipeline::sym::Stage::Object,
|
||||
partial_groups,
|
||||
grid_edge,
|
||||
identity_region: crate::lower::access::identity(cx.profile)
|
||||
.then(|| cx.profile.identity_region()),
|
||||
identity: crate::lower::access::identity(cx.profile),
|
||||
pinned_subgroup_size,
|
||||
deep,
|
||||
})
|
||||
@@ -1307,19 +1293,18 @@ impl KernelDecl {
|
||||
mb.workgroup_size(sn, one, one)?;
|
||||
}
|
||||
}
|
||||
let multi_region = match (dp.multi_region, dp.identity_region) {
|
||||
let multi_region = match (dp.multi_region, dp.identity) {
|
||||
(false, _) => None,
|
||||
(true, Some(IdentityRegion::Grid)) => Some(RegionSelect::Grid),
|
||||
(true, form) => {
|
||||
(true, identity) => {
|
||||
let b = mb.ty(Type::Bool)?;
|
||||
let mr = mb.spec(
|
||||
keys.multi_region,
|
||||
b,
|
||||
ConstBits(u64::from(defaults.multi_region)),
|
||||
)?;
|
||||
Some(match form {
|
||||
Some(_) => RegionSelect::Sized(mr),
|
||||
None => RegionSelect::Spec(mr),
|
||||
Some(match identity {
|
||||
true => RegionSelect::Sized(mr),
|
||||
false => RegionSelect::Spec(mr),
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -1906,7 +1891,7 @@ impl KernelDecl {
|
||||
}
|
||||
let nominal = fb.composite_construct(self.uvec3, &axes)?;
|
||||
match sel {
|
||||
RegionSelect::Spec(_) | RegionSelect::Grid => {
|
||||
RegionSelect::Spec(_) => {
|
||||
let mr = self.selected(fb, sel, region)?;
|
||||
let zero = self.splat(fb, 0)?;
|
||||
let base = fb.select(mr, base, zero)?;
|
||||
@@ -1946,7 +1931,7 @@ impl KernelDecl {
|
||||
) -> BResult<SValue> {
|
||||
match sel {
|
||||
RegionSelect::Spec(mr) => fb.module().const_value(mr),
|
||||
RegionSelect::Grid | RegionSelect::Sized(_) => {
|
||||
RegionSelect::Sized(_) => {
|
||||
let r = region(fb)?;
|
||||
let r1 = fb.composite_extract(r, &[1])?;
|
||||
let [x, y, z] = [0, 1, 2].map(|i| fb.composite_extract(r1, &[i]));
|
||||
|
||||
@@ -16,7 +16,7 @@ fn profile(stem: &str, features: &[VkFeature]) -> DeviceProfile {
|
||||
for f in features {
|
||||
desc.features.remove(f);
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
@@ -31,7 +31,7 @@ fn profile_with(stem: &str, features: &[VkFeature], flags2: bool) -> DeviceProfi
|
||||
for f in features {
|
||||
desc.features.remove(f);
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -15,7 +15,7 @@ fn profile(stem: &str, features: &[VkFeature]) -> DeviceProfile {
|
||||
for f in features {
|
||||
desc.features.remove(f);
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
//! Push placement: the complete algorithm. Families only contribute fields.
|
||||
//!
|
||||
//! Each stage has a push window: vertex `[0, 64)`, fragment `[64, 128)`, compute `[0, 128)`.
|
||||
//! Vulkan guarantees `maxPushConstantsSize ≥ 128`, so those windows depend neither on the other
|
||||
//! stage nor on the device. On a profile whose push window is the runtime's floor
|
||||
//! (`PushWindow::Floor`, `Device::from_queries`'), which requires `maxPushConstantsSize ≥ 256`, a
|
||||
//! compute window is `[0, 256)` (a dispatch region and 24 buffer addresses below its tail), and a render
|
||||
//! Each stage has a push window on the runtime's floor, which requires
|
||||
//! `maxPushConstantsSize ≥ 256`: a compute window is `[0, 256)` (a dispatch region and 24 buffer
|
||||
//! addresses below its tail), and a render
|
||||
//! pipeline's two stages share one range `[0, 256)`, dense by link: the vertex function's fields
|
||||
//! from 0, the fragment function's from its `LoweringInputs::push_base`, the vertex function's push
|
||||
//! end, so only the fields the pair places take space (a four-byte field the fragment function
|
||||
@@ -43,26 +41,16 @@
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::device::profile::PushWindow;
|
||||
use crate::pipeline::interface::{PlacedField, PushLoc, PushPlacement};
|
||||
use crate::pipeline::sym::{PushField, Stage};
|
||||
|
||||
/// The byte range `[start, end)` of `stage`'s push window on a profile whose push window is `w`;
|
||||
/// `base` is a fragment function's `LoweringInputs::push_base`, which only the floor reads.
|
||||
pub const fn window(stage: Stage, w: PushWindow, base: u32) -> (u32, u32) {
|
||||
/// The byte range `[start, end)` of `stage`'s push window; `base` is a fragment function's
|
||||
/// `LoweringInputs::push_base`.
|
||||
pub const fn window(stage: Stage, base: u32) -> (u32, u32) {
|
||||
match stage {
|
||||
Stage::Vertex => match w {
|
||||
PushWindow::Guaranteed => (0, 64),
|
||||
PushWindow::Floor => (0, VERTEX_FLOOR_END),
|
||||
},
|
||||
Stage::Fragment => match w {
|
||||
PushWindow::Guaranteed => (64, 128),
|
||||
PushWindow::Floor => (base, FLOOR_BYTES),
|
||||
},
|
||||
Stage::Kernel => match w {
|
||||
PushWindow::Guaranteed => (0, 128),
|
||||
PushWindow::Floor => (0, FLOOR_BYTES),
|
||||
},
|
||||
Stage::Vertex => (0, VERTEX_FLOOR_END),
|
||||
Stage::Fragment => (base, FLOOR_BYTES),
|
||||
Stage::Kernel => (0, FLOOR_BYTES),
|
||||
// A mesh render pipeline's object, mesh and fragment functions share the 128 bytes: the
|
||||
// fragment function keeps its window, and the vertex function's is split.
|
||||
Stage::Object => (0, 32),
|
||||
@@ -70,7 +58,7 @@ pub const fn window(stage: Stage, w: PushWindow, base: u32) -> (u32, u32) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The push bytes of the runtime's floor (`PushWindow::Floor`): its `maxPushConstantsSize`.
|
||||
/// The push bytes of the runtime's floor: its `maxPushConstantsSize`.
|
||||
pub const FLOOR_BYTES: u32 = 256;
|
||||
|
||||
/// The end of a vertex function's window on the floor: the floor's end less one address, so the
|
||||
@@ -232,22 +220,11 @@ fn align_up(v: u32, a: u32) -> u32 {
|
||||
v.div_ceil(a).saturating_mul(a)
|
||||
}
|
||||
|
||||
/// Place `fields` for `stage` in its push window on a profile whose push window is `w`, from a
|
||||
/// fragment function's `base` there ([`window`]): on the floor with its tail ([`tail`]).
|
||||
pub fn place(
|
||||
stage: Stage,
|
||||
w: PushWindow,
|
||||
base: u32,
|
||||
fields: &BTreeSet<PushField>,
|
||||
) -> PushPlacement {
|
||||
let (start, end) = window(stage, w, base);
|
||||
let (pushed, offsets, word, push_end) = match w {
|
||||
PushWindow::Guaranteed => {
|
||||
let (n, offsets, push_end) = dense(start, end, fields);
|
||||
(n, offsets, None, push_end)
|
||||
}
|
||||
PushWindow::Floor => floor(start, end, fields),
|
||||
};
|
||||
/// Place `fields` for `stage` in its push window, from a fragment function's `base` there
|
||||
/// ([`window`]), with its tail ([`tail`]).
|
||||
pub fn place(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
let (start, end) = window(stage, base);
|
||||
let (pushed, offsets, word, push_end) = floor(start, end, fields);
|
||||
let mut table = 0u32;
|
||||
let mut placed = Vec::with_capacity(fields.len());
|
||||
// `BTreeSet` iterates in the derived `Ord`: exactly the kind order, then slot order.
|
||||
@@ -364,20 +341,16 @@ fn tail_layout(start: u32, end: u32, pushed: &[PushField]) -> Option<(Vec<u32>,
|
||||
/// gives it a size. That is the first field with a size that does not fit, so the fields are read
|
||||
/// only up to it, at most the window's worth plus one, however many there are; a step that asks
|
||||
/// once per slot it moves (`access::finish_slots`) then costs no walk of every slot's field.
|
||||
pub fn spills(stage: Stage, w: PushWindow, base: u32, fields: &BTreeSet<PushField>) -> bool {
|
||||
let (start, end) = window(stage, w, base);
|
||||
let pushed = match w {
|
||||
PushWindow::Guaranteed => dense(start, end, fields).0,
|
||||
PushWindow::Floor => floor(start, end, fields).0,
|
||||
};
|
||||
pub fn spills(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> bool {
|
||||
let (start, end) = window(stage, base);
|
||||
let pushed = floor(start, end, fields).0;
|
||||
// Every shape has a size, so any field past the pushed ones gives the table one.
|
||||
pushed < fields.len()
|
||||
}
|
||||
|
||||
/// The tail of `placement` ([`place`] on the floor): its tail word (`PushField::TailWord`), or
|
||||
/// its highest pushed field, where it lies at least [`HOLE_BYTES`] above every other pushed
|
||||
/// field's end. A placement packed in the guaranteed window has none: no alignment there leaves
|
||||
/// 24 bytes.
|
||||
/// field's end.
|
||||
pub fn tail(placement: &PushPlacement) -> Option<PushField> {
|
||||
let pushed = || {
|
||||
(placement.fields.iter()).filter_map(|f| match f.loc {
|
||||
@@ -401,12 +374,11 @@ pub fn tail(placement: &PushPlacement) -> Option<PushField> {
|
||||
(at >= below(skip)? + HOLE_BYTES).then_some(field)
|
||||
}
|
||||
|
||||
/// The floor's bound on `placement`, a stage's on a profile whose push window is `w`: on the
|
||||
/// floor a stage that pushes more than one field, or one of more than two words, ends with its
|
||||
/// tail ([`tail`]), a field of a tail kind or the tail word, of one or two words; its push range
|
||||
/// ends with its highest pushed byte, by the floor's end; off the floor no stage pushes the tail
|
||||
/// word. `Err` names the placement that passes it.
|
||||
pub fn check_floor(w: PushWindow, placement: &PushPlacement) -> Result<(), String> {
|
||||
/// The floor's bound on `placement`, a stage's: a stage that pushes more than one field, or one
|
||||
/// of more than two words, ends with its tail ([`tail`]), a field of a tail kind or the tail word,
|
||||
/// of one or two words; its push range ends with its highest pushed byte, by the floor's end.
|
||||
/// `Err` names the placement that passes it.
|
||||
pub fn check_floor(placement: &PushPlacement) -> Result<(), String> {
|
||||
let pushed: Vec<(PushField, u32, u32)> = (placement.fields.iter())
|
||||
.filter_map(|f| match f.loc {
|
||||
PushLoc::Push { offset } => Some((f.field, offset, f.size)),
|
||||
@@ -420,20 +392,13 @@ pub fn check_floor(w: PushWindow, placement: &PushPlacement) -> Result<(), Strin
|
||||
.map(|&(_, offset, size)| offset + size)
|
||||
.chain(word)
|
||||
.max();
|
||||
let ok = match w {
|
||||
PushWindow::Guaranteed => word.is_none(),
|
||||
PushWindow::Floor => {
|
||||
let single =
|
||||
word.is_none() && matches!(pushed.as_slice(), [(_, _, size)] if *size <= 8);
|
||||
let tailed = tail(placement).is_some_and(|t| {
|
||||
(tail_kind(t) || t == PushField::TailWord) && shape(t).size() <= 8
|
||||
});
|
||||
let range = placement.push_range.map(|(offset, size)| offset + size);
|
||||
(pushed.is_empty() || single || tailed)
|
||||
&& range == top
|
||||
&& top.is_none_or(|t| t <= FLOOR_BYTES)
|
||||
}
|
||||
};
|
||||
let single = word.is_none() && matches!(pushed.as_slice(), [(_, _, size)] if *size <= 8);
|
||||
let tailed = tail(placement)
|
||||
.is_some_and(|t| (tail_kind(t) || t == PushField::TailWord) && shape(t).size() <= 8);
|
||||
let range = placement.push_range.map(|(offset, size)| offset + size);
|
||||
let ok = (pushed.is_empty() || single || tailed)
|
||||
&& range == top
|
||||
&& top.is_none_or(|t| t <= FLOOR_BYTES);
|
||||
match ok {
|
||||
true => Ok(()),
|
||||
false => Err(format!(
|
||||
@@ -514,32 +479,19 @@ mod tests {
|
||||
/// ([`tail`]) lies above every other pushed field and the floor's bound holds
|
||||
/// ([`check_floor`]); the guaranteed window has no tail.
|
||||
fn check(stage: Stage, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
check_in(stage, PushWindow::Guaranteed, fields)
|
||||
check_at(stage, 0, fields)
|
||||
}
|
||||
|
||||
/// [`check`] on a profile whose push window is `w`.
|
||||
fn check_in(stage: Stage, w: PushWindow, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
check_at(stage, w, 0, fields)
|
||||
}
|
||||
|
||||
/// [`check_in`] from a fragment function's push `base`.
|
||||
fn check_at(
|
||||
stage: Stage,
|
||||
w: PushWindow,
|
||||
base: u32,
|
||||
fields: &BTreeSet<PushField>,
|
||||
) -> PushPlacement {
|
||||
let p = place(stage, w, base, fields);
|
||||
assert_eq!(spills(stage, w, base, fields), p.argument_table_size > 0);
|
||||
let (start, end) = window(stage, w, base);
|
||||
/// [`check`] from a fragment function's push `base`.
|
||||
fn check_at(stage: Stage, base: u32, fields: &BTreeSet<PushField>) -> PushPlacement {
|
||||
let p = place(stage, base, fields);
|
||||
assert_eq!(spills(stage, base, fields), p.argument_table_size > 0);
|
||||
let (start, end) = window(stage, base);
|
||||
assert_eq!(p.stage, stage);
|
||||
let order: Vec<PushField> = p.fields.iter().map(|f| f.field).collect();
|
||||
assert_eq!(order, fields.iter().copied().collect::<Vec<_>>());
|
||||
assert_eq!(check_floor(w, &p), Ok(()));
|
||||
assert_eq!(check_floor(&p), Ok(()));
|
||||
let top = tail(&p);
|
||||
if w == PushWindow::Guaranteed {
|
||||
assert_eq!(top, None);
|
||||
}
|
||||
let (mut push_end, mut table_end, mut spilled) = (start, 0u32, false);
|
||||
let mut tail_end = p.tail_word.map(|at| (at, at + 4));
|
||||
for f in &p.fields {
|
||||
@@ -592,74 +544,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_bind_offset_opens_the_stage_window() {
|
||||
for (stage, base) in [
|
||||
(Stage::Vertex, 0),
|
||||
(Stage::Fragment, 64),
|
||||
(Stage::Kernel, 0),
|
||||
] {
|
||||
let fields = [PushField::SlotBindOffset(slot(stage, 0))].into();
|
||||
let p = check(stage, &fields);
|
||||
assert_eq!(p.fields[0].loc, PushLoc::Push { offset: base });
|
||||
assert_eq!(p.push_range, Some((base, 4)));
|
||||
}
|
||||
}
|
||||
|
||||
/// Fields arrive in any order and are placed in kind order, each aligned: a `u32` residual,
|
||||
/// then an 8-aligned guest base after 4 bytes of padding.
|
||||
#[test]
|
||||
fn fields_are_placed_in_kind_order_with_alignment() {
|
||||
let s = slot(Stage::Kernel, 3);
|
||||
let fields = [
|
||||
PushField::SlotGuestBase(s),
|
||||
PushField::VertexBufferStride(0),
|
||||
PushField::SlotBindOffset(s),
|
||||
PushField::DispatchRegion,
|
||||
]
|
||||
.into();
|
||||
let p = check(Stage::Kernel, &fields);
|
||||
let locs: Vec<(PushField, PushLoc)> = p.fields.iter().map(|f| (f.field, f.loc)).collect();
|
||||
assert_eq!(
|
||||
locs,
|
||||
vec![
|
||||
(PushField::DispatchRegion, PushLoc::Push { offset: 0 }),
|
||||
(PushField::SlotBindOffset(s), PushLoc::Push { offset: 32 }),
|
||||
(PushField::SlotGuestBase(s), PushLoc::Push { offset: 40 }),
|
||||
(
|
||||
PushField::VertexBufferStride(0),
|
||||
PushLoc::Push { offset: 48 }
|
||||
),
|
||||
]
|
||||
);
|
||||
assert_eq!(p.push_range, Some((0, 52)));
|
||||
}
|
||||
|
||||
/// 31 residuals fill 124 bytes of the compute window; the first guest base would end past
|
||||
/// 128, so it and every later field go to the `ArgumentTable`.
|
||||
#[test]
|
||||
fn the_first_field_that_does_not_fit_spills_it_and_the_rest() {
|
||||
let mut fields = BTreeSet::new();
|
||||
for i in 0..31 {
|
||||
fields.insert(PushField::SlotBindOffset(slot(Stage::Kernel, i)));
|
||||
fields.insert(PushField::SlotGuestBase(slot(Stage::Kernel, i)));
|
||||
}
|
||||
let p = check(Stage::Kernel, &fields);
|
||||
let pushed = p
|
||||
.fields
|
||||
.iter()
|
||||
.filter(|f| matches!(f.loc, PushLoc::Push { .. }))
|
||||
.count();
|
||||
assert_eq!(pushed, 31);
|
||||
assert_eq!(p.push_range, Some((0, 124)));
|
||||
assert_eq!(p.argument_table_size, 31 * 8 + 8);
|
||||
assert_eq!(
|
||||
p.fields[31].loc,
|
||||
PushLoc::ArgumentTable { offset: 0 },
|
||||
"the first spilled field starts the table"
|
||||
);
|
||||
}
|
||||
|
||||
/// A kernel's dispatch region and its buffers' addresses: 12 addresses fill the guaranteed
|
||||
/// window. On the floor the addresses hold no tail kind, so the tail word ends the push, 24
|
||||
/// bytes above them: 24 addresses end at 224 and the word at 252, and a 25th spills; with a
|
||||
@@ -680,18 +564,7 @@ mod tests {
|
||||
.filter(|f| matches!(f.loc, PushLoc::Push { .. }))
|
||||
.count()
|
||||
};
|
||||
let guaranteed = check_in(Stage::Kernel, PushWindow::Guaranteed, &fields(12));
|
||||
assert_eq!(
|
||||
(guaranteed.push_range, guaranteed.argument_table_size),
|
||||
(Some((0, 128)), 0)
|
||||
);
|
||||
assert!(spills(
|
||||
Stage::Kernel,
|
||||
PushWindow::Guaranteed,
|
||||
0,
|
||||
&fields(13)
|
||||
));
|
||||
let floor = check_in(Stage::Kernel, PushWindow::Floor, &fields(24));
|
||||
let floor = check(Stage::Kernel, &fields(24));
|
||||
assert_eq!(
|
||||
(floor.push_range, floor.argument_table_size),
|
||||
(Some((0, 252)), 0)
|
||||
@@ -701,22 +574,16 @@ mod tests {
|
||||
(tail(&floor), floor.tail_word),
|
||||
(Some(PushField::TailWord), Some(248))
|
||||
);
|
||||
assert!(spills(Stage::Kernel, PushWindow::Floor, 0, &fields(25)));
|
||||
assert!(spills(Stage::Kernel, 0, &fields(25)));
|
||||
let mut spilled = fields(25);
|
||||
spilled.insert(PushField::ArgumentTableAddress);
|
||||
let p = check_in(Stage::Kernel, PushWindow::Floor, &spilled);
|
||||
let p = check(Stage::Kernel, &spilled);
|
||||
assert_eq!((p.push_range, p.argument_table_size), (Some((0, 252)), 32));
|
||||
assert_eq!(
|
||||
(pushed(&p), p.tail_word),
|
||||
(24, Some(248)),
|
||||
"the address, the region and 22 buffer addresses"
|
||||
);
|
||||
for stage in [Stage::Object, Stage::Mesh] {
|
||||
assert_eq!(
|
||||
window(stage, PushWindow::Floor, 0),
|
||||
window(stage, PushWindow::Guaranteed, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The floor's tail: a kernel's highest field of a tail kind moves 24 bytes above its other
|
||||
@@ -740,9 +607,7 @@ mod tests {
|
||||
PushField::SlotBounds(a),
|
||||
]
|
||||
.into();
|
||||
let packed = check_in(Stage::Kernel, PushWindow::Guaranteed, &fields);
|
||||
assert_eq!(packed.push_range, Some((0, 64)));
|
||||
let p = check_in(Stage::Kernel, PushWindow::Floor, &fields);
|
||||
let p = check(Stage::Kernel, &fields);
|
||||
assert_eq!(tail(&p), Some(PushField::SlotBounds(a)));
|
||||
assert_eq!(at(&p, PushField::ZeroAddress), PushLoc::Push { offset: 48 });
|
||||
assert_eq!(
|
||||
@@ -760,7 +625,7 @@ mod tests {
|
||||
assert_eq!(p.tail_word, None);
|
||||
// A second slot's bounds: the higher one is the tail, the first stays packed.
|
||||
fields.insert(PushField::SlotBounds(b));
|
||||
let p = check_in(Stage::Kernel, PushWindow::Floor, &fields);
|
||||
let p = check(Stage::Kernel, &fields);
|
||||
assert_eq!(tail(&p), Some(PushField::SlotBounds(b)));
|
||||
assert_eq!(
|
||||
at(&p, PushField::SlotBounds(a)),
|
||||
@@ -772,24 +637,14 @@ mod tests {
|
||||
);
|
||||
assert_eq!(p.push_range, Some((0, 96)));
|
||||
// A region alone: the tail word, 24 bytes above it.
|
||||
let region = check_in(
|
||||
Stage::Kernel,
|
||||
PushWindow::Floor,
|
||||
&[PushField::DispatchRegion].into(),
|
||||
);
|
||||
let region = check_in(Stage::Kernel, &[PushField::DispatchRegion].into());
|
||||
assert_eq!(tail(®ion), Some(PushField::TailWord));
|
||||
assert_eq!(region.tail_word, Some(56));
|
||||
assert_eq!(region.push_range, Some((0, 60)));
|
||||
// One address alone: no tail.
|
||||
let one = check_in(
|
||||
Stage::Kernel,
|
||||
PushWindow::Floor,
|
||||
&[PushField::SlotGuestBase(a)].into(),
|
||||
);
|
||||
let one = check_in(Stage::Kernel, &[PushField::SlotGuestBase(a)].into());
|
||||
assert_eq!((tail(&one), one.push_range), (None, Some((0, 8))));
|
||||
assert!(check_in(Stage::Kernel, PushWindow::Floor, &BTreeSet::new())
|
||||
.fields
|
||||
.is_empty());
|
||||
assert!(check(Stage::Kernel, &BTreeSet::new()).fields.is_empty());
|
||||
}
|
||||
|
||||
/// The floor's bound, which `select` checks on every placement: a stage that pushes more than
|
||||
@@ -805,15 +660,12 @@ mod tests {
|
||||
PushField::SlotBounds(a),
|
||||
]
|
||||
.into();
|
||||
let p = place(Stage::Kernel, PushWindow::Floor, 0, &fields);
|
||||
assert_eq!(check_floor(PushWindow::Floor, &p), Ok(()));
|
||||
let packed = place(Stage::Kernel, PushWindow::Guaranteed, 0, &fields);
|
||||
assert_eq!(check_floor(PushWindow::Guaranteed, &packed), Ok(()));
|
||||
assert!(check_floor(PushWindow::Floor, &packed).is_err(), "no hole");
|
||||
let p = place(Stage::Kernel, 0, &fields);
|
||||
assert_eq!(check_floor(&p), Ok(()));
|
||||
let mut short = p.clone();
|
||||
short.push_range = Some((0, 80));
|
||||
assert!(
|
||||
check_floor(PushWindow::Floor, &short).is_err(),
|
||||
check_floor(&short).is_err(),
|
||||
"a range that does not end with the tail"
|
||||
);
|
||||
let mut moved = p.clone();
|
||||
@@ -823,28 +675,16 @@ mod tests {
|
||||
}
|
||||
}
|
||||
moved.push_range = Some((0, 64));
|
||||
assert!(
|
||||
check_floor(PushWindow::Floor, &moved).is_err(),
|
||||
"a hole of 16"
|
||||
);
|
||||
let region = place(
|
||||
Stage::Kernel,
|
||||
PushWindow::Floor,
|
||||
0,
|
||||
&[PushField::DispatchRegion].into(),
|
||||
);
|
||||
assert_eq!(check_floor(PushWindow::Floor, ®ion), Ok(()));
|
||||
assert!(check_floor(PushWindow::Guaranteed, ®ion).is_err());
|
||||
assert!(check_floor(&moved).is_err(), "a hole of 16");
|
||||
let region = place(Stage::Kernel, 0, &[PushField::DispatchRegion].into());
|
||||
assert_eq!(check_floor(®ion), Ok(()));
|
||||
let mut bare = region.clone();
|
||||
bare.tail_word = None;
|
||||
bare.push_range = Some((0, 32));
|
||||
assert!(
|
||||
check_floor(PushWindow::Floor, &bare).is_err(),
|
||||
"a long field alone"
|
||||
);
|
||||
assert!(check_floor(&bare).is_err(), "a long field alone");
|
||||
let mut past = region;
|
||||
past.push_range = Some((0, 260));
|
||||
assert!(check_floor(PushWindow::Floor, &past).is_err());
|
||||
assert!(check_floor(&past).is_err());
|
||||
}
|
||||
|
||||
/// The windows a pipeline of each kind pushes, pinned: on the guaranteed window the fixed
|
||||
@@ -854,21 +694,9 @@ mod tests {
|
||||
#[test]
|
||||
fn each_kind_pushes_its_own_window() {
|
||||
for base in [0, 8, 40, 248] {
|
||||
assert_eq!(window(Stage::Vertex, PushWindow::Guaranteed, base), (0, 64));
|
||||
assert_eq!(
|
||||
window(Stage::Fragment, PushWindow::Guaranteed, base),
|
||||
(64, 128)
|
||||
);
|
||||
assert_eq!(
|
||||
window(Stage::Kernel, PushWindow::Guaranteed, base),
|
||||
(0, 128)
|
||||
);
|
||||
assert_eq!(window(Stage::Kernel, PushWindow::Floor, base), (0, 256));
|
||||
assert_eq!(window(Stage::Vertex, PushWindow::Floor, base), (0, 248));
|
||||
assert_eq!(
|
||||
window(Stage::Fragment, PushWindow::Floor, base),
|
||||
(base, 256)
|
||||
);
|
||||
assert_eq!(window(Stage::Kernel, base), (0, 256));
|
||||
assert_eq!(window(Stage::Vertex, base), (0, 248));
|
||||
assert_eq!(window(Stage::Fragment, base), (base, 256));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,28 +711,23 @@ mod tests {
|
||||
let vertex: BTreeSet<PushField> = (0..3)
|
||||
.map(|i| PushField::SlotGuestBase(slot(Stage::Vertex, i)))
|
||||
.collect();
|
||||
let v = check_at(Stage::Vertex, PushWindow::Floor, 0, &vertex);
|
||||
let v = check_at(Stage::Vertex, 0, &vertex);
|
||||
assert_eq!(v.push_range, Some((0, 52)), "the tail word at 48");
|
||||
let fragment = |n: u32| -> BTreeSet<PushField> {
|
||||
(0..n)
|
||||
.map(|i| PushField::SlotGuestBase(slot(Stage::Fragment, i)))
|
||||
.collect()
|
||||
};
|
||||
let f = check_at(Stage::Fragment, PushWindow::Floor, 52, &fragment(2));
|
||||
let f = check_at(Stage::Fragment, 52, &fragment(2));
|
||||
assert_eq!(
|
||||
f.push_range,
|
||||
Some((52, 48)),
|
||||
"two addresses from 56, the word at 96"
|
||||
);
|
||||
let full = check_at(Stage::Fragment, PushWindow::Floor, 24, &fragment(25));
|
||||
let full = check_at(Stage::Fragment, 24, &fragment(25));
|
||||
assert_eq!(full.push_range, Some((24, 228)), "to the word at 248");
|
||||
assert_eq!(full.argument_table_size, 0);
|
||||
assert!(spills(
|
||||
Stage::Fragment,
|
||||
PushWindow::Floor,
|
||||
24,
|
||||
&fragment(26)
|
||||
));
|
||||
assert!(spills(Stage::Fragment, 24, &fragment(26)));
|
||||
// A vertex function's window ends at 248: 27 addresses end at 216 below the word at 240,
|
||||
// and a 28th spills.
|
||||
let wide = |n: u32| -> BTreeSet<PushField> {
|
||||
@@ -912,15 +735,15 @@ mod tests {
|
||||
.map(|i| PushField::SlotGuestBase(slot(Stage::Vertex, i)))
|
||||
.collect()
|
||||
};
|
||||
let v = check_at(Stage::Vertex, PushWindow::Floor, 0, &wide(27));
|
||||
let v = check_at(Stage::Vertex, 0, &wide(27));
|
||||
assert_eq!((v.push_range, v.argument_table_size), (Some((0, 244)), 0));
|
||||
assert!(spills(Stage::Vertex, PushWindow::Floor, 0, &wide(28)));
|
||||
assert!(spills(Stage::Vertex, 0, &wide(28)));
|
||||
// The fragment function from the fullest vertex function's end, 244, pushes its block's
|
||||
// address, 8-aligned, at 248, alone, and spills the rest; from 248 the same.
|
||||
let mut spilled = fragment(2);
|
||||
spilled.insert(PushField::ArgumentTableAddress);
|
||||
for (base, range) in [(248, (248, 8)), (244, (244, 12))] {
|
||||
let f = check_at(Stage::Fragment, PushWindow::Floor, base, &spilled);
|
||||
let f = check_at(Stage::Fragment, base, &spilled);
|
||||
assert_eq!((f.push_range, f.argument_table_size), (Some(range), 16));
|
||||
assert_eq!(
|
||||
(f.fields[0].field, f.fields[0].loc),
|
||||
@@ -933,21 +756,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// The vertex window holds 16 residuals; the 17th spills even though a later, smaller field
|
||||
/// would still fit nowhere else: placement is a prefix of the order.
|
||||
#[test]
|
||||
fn the_vertex_window_holds_sixty_four_bytes() {
|
||||
let mut fields: BTreeSet<PushField> = (0..17)
|
||||
.map(|i| PushField::SlotBindOffset(slot(Stage::Vertex, i)))
|
||||
.collect();
|
||||
fields.insert(PushField::VertexBufferStride(0));
|
||||
let p = check(Stage::Vertex, &fields);
|
||||
assert_eq!(p.push_range, Some((0, 64)));
|
||||
assert_eq!(p.fields[16].loc, PushLoc::ArgumentTable { offset: 0 });
|
||||
assert_eq!(p.fields[17].loc, PushLoc::ArgumentTable { offset: 4 });
|
||||
assert_eq!(p.argument_table_size, 16);
|
||||
}
|
||||
|
||||
/// A synthetic sweep over field sets built from every kind: the invariants hold for each.
|
||||
#[test]
|
||||
fn placement_invariants_hold_over_synthetic_field_sets() {
|
||||
@@ -970,11 +778,7 @@ mod tests {
|
||||
]
|
||||
};
|
||||
let mut state = 0x2545_f491_4f6c_dd1du64;
|
||||
let windows = [PushWindow::Guaranteed, PushWindow::Floor];
|
||||
for (stage, w) in [Stage::Vertex, Stage::Fragment, Stage::Kernel]
|
||||
.into_iter()
|
||||
.flat_map(|stage| windows.map(|w| (stage, w)))
|
||||
{
|
||||
for stage in [Stage::Vertex, Stage::Fragment, Stage::Kernel] {
|
||||
for _ in 0..200 {
|
||||
let mut fields = BTreeSet::new();
|
||||
state ^= state << 13;
|
||||
@@ -985,7 +789,7 @@ mod tests {
|
||||
let pick = ((state >> (i % 50)) % 10) as usize;
|
||||
fields.insert(kinds(stage, i % 31)[pick]);
|
||||
}
|
||||
check_in(stage, w, &fields);
|
||||
check(stage, &fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1033,7 +837,7 @@ mod tests {
|
||||
later.insert(PushField::SlotGuestBase(slot(i)));
|
||||
later.insert(PushField::VertexBufferStride(i));
|
||||
}
|
||||
let (start, end) = window(stage, PushWindow::Guaranteed, 0);
|
||||
let (start, end) = window(stage, 0);
|
||||
let firsts = [
|
||||
None,
|
||||
Some(PushField::RootTableAddress),
|
||||
@@ -1045,7 +849,7 @@ mod tests {
|
||||
let mut fields = rest;
|
||||
fields.insert(PushField::ExecutionStatusAddress);
|
||||
fields.extend(first);
|
||||
let placement = place(stage, PushWindow::Guaranteed, 0, &fields);
|
||||
let placement = place(stage, 0, &fields);
|
||||
let status = placement
|
||||
.fields
|
||||
.iter()
|
||||
@@ -1083,7 +887,7 @@ mod tests {
|
||||
later.insert(PushField::SlotGuestBase(slot(Stage::Vertex, i)));
|
||||
later.insert(PushField::VertexBufferStride(i));
|
||||
}
|
||||
let (start, end) = window(Stage::Vertex, PushWindow::Guaranteed, 0);
|
||||
let (start, end) = window(Stage::Vertex, 0);
|
||||
for (root, status) in [(false, false), (true, false), (false, true), (true, true)] {
|
||||
let mut fields = later.clone();
|
||||
fields.insert(PushField::CaptureIndexAddress);
|
||||
|
||||
@@ -127,7 +127,7 @@ declare { <4 x float>, i8 } @air.sample_texture_2d_grad.v4f32(ptr addrspace(1),
|
||||
fn p(stem: &str) -> DeviceProfile {
|
||||
let mut desc = crate::pipeline::testing::description(stem).expect(stem);
|
||||
desc.features.remove(&VkFeature::SamplerAnisotropy);
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect(stem)
|
||||
.profile()
|
||||
.clone()
|
||||
@@ -344,7 +344,7 @@ fn a_bound_anisotropic_sampler_asks_for_the_variant() {
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
assert!(desc.features.remove(&VkFeature::SamplerAnisotropy));
|
||||
let dev = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
let pipeline = |inputs: &LoweringInputs| {
|
||||
let function = Library::from_air(&bc)
|
||||
.and_then(|lib| lib.function("k"))
|
||||
@@ -574,7 +574,10 @@ fn anisotropy_of(stem: &str, policy: DevicePolicy, withheld: bool) -> DeviceProf
|
||||
"{stem}"
|
||||
);
|
||||
}
|
||||
Device::new(desc, policy).expect(stem).profile().clone()
|
||||
Device::from_queries(desc, policy)
|
||||
.expect(stem)
|
||||
.profile()
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// Without `samplerAnisotropy` every Vulkan sampler is isotropic, so Metal's anisotropic filter is
|
||||
@@ -689,31 +692,13 @@ declare {{ <4 x float>, i8 }} @air.sample_texture_cube_grad.v4f32(ptr addrspace(
|
||||
)
|
||||
}
|
||||
|
||||
/// `moltenvk-m3` whose kernel cube-gradient route its description does not state (a MoltenVK
|
||||
/// release no measurement covers).
|
||||
fn unmeasured_moltenvk() -> DeviceProfile {
|
||||
let desc = crate::pipeline::testing::description("moltenvk-m3").expect("moltenvk-m3");
|
||||
let route = crate::error::DriverDeviation::CubeGradientRoute;
|
||||
crate::device::Device::with_deviation(
|
||||
desc,
|
||||
crate::device::DevicePolicy::default(),
|
||||
route,
|
||||
false,
|
||||
)
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// A cube's explicit gradients through a constexpr sampler of `maxAnisotropy` 8 under a linear
|
||||
/// mip filter take Metal's footprint in the shader on every device without `samplerAnisotropy`:
|
||||
/// Metal's level and taps (no gradient sample, the level count queried, tap 0 and the loop's tap
|
||||
/// of one explicit level each, `AnisotropicFilter` recorded and `CubeGradientFootprint` not).
|
||||
/// Through an isotropic sampler a device without the feature keeps its own gradient sample, at the
|
||||
/// footprint the cube's form hands it. On a measured route (`moltenvk-m3`, whose kernels hand
|
||||
/// Metal's own gradients) the device's gradient sample stays, unrecorded; on MoltenVK where its
|
||||
/// kernel route is not measured it stays too, Vulkan's rule's form, recorded as
|
||||
/// `CubeGradientFootprint`.
|
||||
/// footprint the cube's form hands it. On `moltenvk-m3`, whose sampler is anisotropic, the device's
|
||||
/// gradient sample stays, Vulkan's rule's form, recorded as `CubeGradientFootprint`.
|
||||
#[test]
|
||||
fn a_cubes_explicit_gradients_take_metals_level_and_taps() {
|
||||
const GRAD: u32 = 0x4;
|
||||
@@ -727,10 +712,7 @@ fn a_cubes_explicit_gradients_take_metals_level_and_taps() {
|
||||
};
|
||||
let explicit = if taps { WRITTEN_TAPS as usize } else { 2 };
|
||||
let mut shader = Vec::new();
|
||||
let mut device = vec![
|
||||
("moltenvk-m3", full("moltenvk-m3")),
|
||||
("unmeasured MoltenVK", unmeasured_moltenvk()),
|
||||
];
|
||||
let mut device = vec![("moltenvk-m3", full("moltenvk-m3"))];
|
||||
for stem in ["lavapipe", "amd-rdna3-radv", "intel-irisxe-anv"] {
|
||||
match taps {
|
||||
true => shader.push((stem, p(stem))),
|
||||
@@ -767,20 +749,13 @@ fn a_cubes_explicit_gradients_take_metals_level_and_taps() {
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
// Metal's own sampler on a measured route takes Metal's own gradients; on an
|
||||
// unmeasured one, Vulkan's rule's form, the device's reading.
|
||||
match stem {
|
||||
"moltenvk-m3" => assert!(
|
||||
!a.precision.contains(&PrecisionNote::CubeGradientFootprint),
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
),
|
||||
"unmeasured MoltenVK" => assert!(
|
||||
// Vulkan's rule's form, the device's reading.
|
||||
if stem == "moltenvk-m3" {
|
||||
assert!(
|
||||
a.precision.contains(&PrecisionNote::CubeGradientFootprint),
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
),
|
||||
_ => {}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1535,9 +1535,7 @@ fn in_place_sample(
|
||||
.ok_or_else(|| cx.invariant("a sampling call without a coordinate"))?;
|
||||
// The model takes a linear sample that addresses no border and whose offset no parent's size
|
||||
// places: a constexpr sampler's state decides now, a runtime sampler's word as it runs.
|
||||
let model = cx.profile.fields().ycbcr_in_place_reads
|
||||
== crate::device::YCbCrInPlacePolicy::Model
|
||||
&& gather.is_none()
|
||||
let model = gather.is_none()
|
||||
&& !offset_base
|
||||
&& match &state {
|
||||
State::Constant {
|
||||
|
||||
@@ -47,7 +47,7 @@ use crate::air::ir::{
|
||||
use crate::air::Entry;
|
||||
use crate::budget::{tree_bytes, Growth, Meter};
|
||||
use crate::device::function_storage;
|
||||
use crate::device::profile::{Limits, NarrowWrap, PushWindow};
|
||||
use crate::device::profile::Limits;
|
||||
use crate::device::requirements::{VkFeature, VkLimit};
|
||||
use crate::device::subgroup::{self, SimdClass, SubgroupRequirement, Tier};
|
||||
use crate::device::DeviceProfile;
|
||||
@@ -1610,11 +1610,8 @@ fn select_body(
|
||||
}
|
||||
}
|
||||
}
|
||||
// The narrow results whose bits above their width no use reads, unmasked on a profile that
|
||||
// masks only the read ones.
|
||||
if cx.profile.narrow_wrap() == NarrowWrap::Read {
|
||||
arith::demand::drop_unread_wraps(body, values, &mut strategy, m)?;
|
||||
}
|
||||
// The narrow results whose bits above their width no use reads, unmasked.
|
||||
arith::demand::drop_unread_wraps(body, values, &mut strategy, m)?;
|
||||
phis.sort();
|
||||
Ok(BodySelection {
|
||||
strategy,
|
||||
@@ -1680,16 +1677,11 @@ fn finish(
|
||||
}
|
||||
|
||||
stage_io::finish_merged(&mut cx)?;
|
||||
let placement = push::place(
|
||||
stage,
|
||||
cx.profile.push_window(),
|
||||
cx.inputs.push_base,
|
||||
&cx.push,
|
||||
);
|
||||
let placement = push::place(stage, cx.inputs.push_base, &cx.push);
|
||||
access::accept_placement(&cx, &placement)?;
|
||||
// On the floor every stage that pushes more than one short field ends with its tail, a hole
|
||||
// above the others, so every load a driver widens from them stays inside its upload.
|
||||
push::check_floor(cx.profile.push_window(), &placement)
|
||||
push::check_floor(&placement)
|
||||
.map_err(|detail| Error::Internal(InternalError::new(InternalKind::Invariant, detail)))?;
|
||||
|
||||
// A kernel compiled for dispatches with a partial simdgroup emulates its simdgroups whatever
|
||||
@@ -1924,11 +1916,10 @@ fn identity_unsourced(f: &RuntimeFact) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
/// Under the identity domains on profile `p`, the plans lowered so far: a kernel, or on the floor's
|
||||
/// push window (`PushWindow::Floor`, `Device::from_queries`' profile) a vertex or fragment
|
||||
/// function, that reaches memory only through its buffer slots' device addresses, the device
|
||||
/// addresses it loads or makes from integers (`access::dynamic`, no root table), its textures'
|
||||
/// and runtime samplers' resource IDs and its constexpr samplers' pushed indices, with no
|
||||
/// Under the identity domains on profile `p`, the plans lowered so far: a kernel, a vertex or a
|
||||
/// fragment function that reaches memory only through its buffer slots' device addresses, the
|
||||
/// device addresses it loads or makes from integers (`access::dynamic`, no root table), its
|
||||
/// textures' and runtime samplers' resource IDs and its constexpr samplers' pushed indices, with no
|
||||
/// descriptor and no state of a bound texture or sampler but its resource ID's
|
||||
/// (`SlotPlan::identity_lowered`, [`identity_unsourced`]). The values it reads of the encoder are
|
||||
/// pushed: the dispatch's region, a storage texture's integer channel widths, the compute
|
||||
@@ -1963,7 +1954,7 @@ pub(crate) const BICUBIC_LINE_FORM: &str = "a bicubic filter of a 1D texture";
|
||||
fn identity_refusal(plan: &Plan, p: &DeviceProfile) -> Option<String> {
|
||||
let stage = match plan.stage {
|
||||
Stage::Kernel => true,
|
||||
Stage::Vertex | Stage::Fragment => p.push_window() == PushWindow::Floor,
|
||||
Stage::Vertex | Stage::Fragment => true,
|
||||
_ => false,
|
||||
};
|
||||
if !stage {
|
||||
|
||||
@@ -3413,7 +3413,7 @@ fn output(cx: &mut SelectCx<'_>, o: &OutputBinding, ty: AirTypeId) -> Result<Lin
|
||||
index: (index == 1).then_some(1),
|
||||
..IoDecor::default()
|
||||
};
|
||||
let half = declared == io && half_variable(cx, attachment, f);
|
||||
let half = false;
|
||||
let sp = &mut cx.families.stage_io;
|
||||
let object = declare(sp, key.clone(), IoDir::Output, declared, deco, half)?;
|
||||
if half {
|
||||
@@ -3720,26 +3720,6 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Whether a color output of form `f` to `attachment`, through a variable of its own type, is
|
||||
/// declared with 16-bit `float` lanes (`StageIo::half_outputs`): a `half` output on a profile that
|
||||
/// enables `storageInputOutput16` and `shaderFloat16` under `HalfOutputs::Sixteen` (`Device::new`'s
|
||||
/// profile; `Device::from_queries`' widens every one), so the device receives the `half` the
|
||||
/// function returns as a `half`, as Metal's attachment does, and blends and converts it as its own
|
||||
/// `half` output. Its value is a `half`, also where the attachment's write rounds a lane
|
||||
/// (`color_write::plan`: a `half` lane rounds only to a float format of no more precision and the
|
||||
/// same exponent range), so the conversion that stores it is exact. Not to an attachment held with
|
||||
/// its channels rotated, whose output may be premultiplied in `float` (`rotated_blend_form`).
|
||||
fn half_variable(cx: &SelectCx<'_>, attachment: u32, f: Form) -> bool {
|
||||
use crate::device::profile::HalfOutputs;
|
||||
use crate::device::requirements::VkFeature;
|
||||
let fields = cx.profile.fields();
|
||||
f.float_fmt() == Some(FloatFmt::Half)
|
||||
&& cx.profile.half_outputs() == HalfOutputs::Sixteen
|
||||
&& (fields.enabled.features).contains(&VkFeature::StorageInputOutput16)
|
||||
&& fields.leaf.float16
|
||||
&& !cx.inputs.rotated_colors.contains(&attachment)
|
||||
}
|
||||
|
||||
/// Whether AIR type `ty` of entry `e` is `half` or a vector of it: a `half` color output
|
||||
/// (`PrecisionNote::HalfOutputPrecision`, or `HalfOutputFastMathBlend` under fast math).
|
||||
fn half_color(e: &crate::air::Entry, ty: AirTypeId) -> bool {
|
||||
|
||||
@@ -235,13 +235,13 @@ fn run(
|
||||
let description =
|
||||
DeviceDescription::from_khronos_json(json, args.profile_name.as_deref())
|
||||
.map_err(|e| Failure::detailed("profile not read", e.to_string()))?;
|
||||
Device::new(description, DevicePolicy::default())
|
||||
Device::from_queries(description, DevicePolicy::default())
|
||||
.map_err(|e| Failure::detailed("profile refused", e.to_string()))?
|
||||
}
|
||||
DeviceFile::Device(json) => {
|
||||
let device = ReproDevice::from_json(json)
|
||||
.map_err(|e| Failure::detailed("device not read", e))?;
|
||||
Device::new(device.description, device.policy)
|
||||
Device::from_queries(device.description, device.policy)
|
||||
.map_err(|e| Failure::detailed("device refused", e.to_string()))?
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,7 +21,8 @@ pub(crate) fn committed_devices() -> Vec<(String, Device)> {
|
||||
committed_descriptions()
|
||||
.into_iter()
|
||||
.map(|(stem, desc)| {
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device derives");
|
||||
let device =
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device derives");
|
||||
(stem, device)
|
||||
})
|
||||
.collect()
|
||||
@@ -48,7 +49,7 @@ fn floor_with(formats: &[(vk::Format, vk::FormatFeatureFlags)]) -> DeviceDescrip
|
||||
}
|
||||
|
||||
fn device(desc: DeviceDescription) -> Device {
|
||||
Device::new(desc, DevicePolicy::default()).expect("device derives")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device derives")
|
||||
}
|
||||
|
||||
fn usages(list: &[FormatUsage]) -> BTreeSet<FormatUsage> {
|
||||
|
||||
@@ -1221,7 +1221,6 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::device::requirements::VkExtension;
|
||||
use crate::device::{Device, DevicePolicy};
|
||||
use crate::error::DriverDeviation;
|
||||
use crate::metal::format::tests::committed_descriptions;
|
||||
use crate::metal::format::FormatEmulation;
|
||||
use crate::metal::SamplerReductionMode;
|
||||
@@ -1376,7 +1375,7 @@ mod tests {
|
||||
desc.features.remove(f);
|
||||
}
|
||||
desc.limits.max_sampler_anisotropy_bits = 16f32.to_bits();
|
||||
Device::new(desc, DevicePolicy::default()).unwrap()
|
||||
Device::from_queries(desc, DevicePolicy::default()).unwrap()
|
||||
}
|
||||
|
||||
/// What a plan reads of a bound sampler's shape to check its separate textures' views
|
||||
@@ -1470,7 +1469,7 @@ mod tests {
|
||||
];
|
||||
let (mut checked, mut past_limit, mut withheld) = (0, 0, 0);
|
||||
for (stem, description) in committed_descriptions() {
|
||||
let dev = Device::new(description, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(description, DevicePolicy::default()).unwrap();
|
||||
let p = dev.profile();
|
||||
let limit = f32::from_bits(p.fields().limits.max_sampler_lod_bias_bits);
|
||||
if p.fields()
|
||||
@@ -1550,7 +1549,7 @@ mod tests {
|
||||
.unwrap()
|
||||
.1;
|
||||
floor.limits.max_sampler_lod_bias_bits = 15.5f32.to_bits();
|
||||
let floor = Device::new(floor, DevicePolicy::default()).unwrap();
|
||||
let floor = Device::from_queries(floor, DevicePolicy::default()).unwrap();
|
||||
let p = floor.profile();
|
||||
assert!(!(p.fields().enabled).portability_withholds(VkFeature::SamplerMipLodBias));
|
||||
let exact = |b: f32| match device_lod_bias(b, p) {
|
||||
@@ -1575,7 +1574,12 @@ mod tests {
|
||||
assert_eq!(device_lod_bias(-f32::NAN, p).bias().to_bits(), 0);
|
||||
let (stem, mvk) = committed_descriptions()
|
||||
.into_iter()
|
||||
.map(|(stem, d)| (stem, Device::new(d, DevicePolicy::default()).unwrap()))
|
||||
.map(|(stem, d)| {
|
||||
(
|
||||
stem,
|
||||
Device::from_queries(d, DevicePolicy::default()).unwrap(),
|
||||
)
|
||||
})
|
||||
.find(|(_, dev)| {
|
||||
(dev.profile().fields().enabled).portability_withholds(VkFeature::SamplerMipLodBias)
|
||||
})
|
||||
@@ -1601,7 +1605,7 @@ mod tests {
|
||||
fn the_device_lod_bias_carries_its_note_where_it_is_not_the_bias() {
|
||||
let note = Some(PrecisionNote::CappedLodBias);
|
||||
for (stem, d) in committed_descriptions() {
|
||||
let dev = Device::new(d, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(d, DevicePolicy::default()).unwrap();
|
||||
let p = dev.profile();
|
||||
let withheld = (p.fields().enabled).portability_withholds(VkFeature::SamplerMipLodBias);
|
||||
let limit = f32::from_bits(p.fields().limits.max_sampler_lod_bias_bits).max(0.0);
|
||||
@@ -1694,71 +1698,6 @@ mod tests {
|
||||
/// agree is clamped to `[0, 0]` whatever its clamps, where that sampler reads Metal's
|
||||
/// `NotMipmapped`; one whose filters differ, an isotropic one, and every sampler off Metal's
|
||||
/// sampler keep the clamp that chooses Metal's filter.
|
||||
#[test]
|
||||
fn metals_own_anisotropic_sampler_reads_not_mipmapped_at_level_zero() {
|
||||
use SamplerMinMagFilter::{Linear, Nearest};
|
||||
let with = |metal_sampler: bool| {
|
||||
let (_, mut desc) = committed_descriptions()
|
||||
.into_iter()
|
||||
.find(|(s, _)| s == "vk12-floor")
|
||||
.unwrap();
|
||||
desc.features.insert(VkFeature::SamplerAnisotropy);
|
||||
desc.limits.max_sampler_anisotropy_bits = 16f32.to_bits();
|
||||
Device::with_deviation(
|
||||
desc,
|
||||
DevicePolicy::default(),
|
||||
DriverDeviation::MetalSampler,
|
||||
metal_sampler,
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
for (metal_sampler, min, mag, anisotropy, lo, hi, lods) in [
|
||||
(true, Linear, Linear, 8, 0.0, f32::MAX, (0.0, 0.0)),
|
||||
(true, Nearest, Nearest, 16, 0.0, f32::MAX, (0.0, 0.0)),
|
||||
(true, Linear, Linear, 2, 1.0, f32::MAX, (0.0, 0.0)),
|
||||
(true, Linear, Linear, 8, 0.125, 2.0, (0.0, 0.0)),
|
||||
(
|
||||
true,
|
||||
Linear,
|
||||
Nearest,
|
||||
8,
|
||||
0.0,
|
||||
f32::MAX,
|
||||
(0.0, NOT_MIPMAPPED_MAX_LOD),
|
||||
),
|
||||
(
|
||||
true,
|
||||
Linear,
|
||||
Linear,
|
||||
1,
|
||||
0.0,
|
||||
f32::MAX,
|
||||
(0.0, NOT_MIPMAPPED_MAX_LOD),
|
||||
),
|
||||
(
|
||||
false,
|
||||
Linear,
|
||||
Linear,
|
||||
8,
|
||||
0.0,
|
||||
f32::MAX,
|
||||
(0.0, NOT_MIPMAPPED_MAX_LOD),
|
||||
),
|
||||
] {
|
||||
let dev = with(metal_sampler);
|
||||
let mut d = metal_default();
|
||||
d.min_filter = min;
|
||||
d.mag_filter = mag;
|
||||
d.max_anisotropy = anisotropy;
|
||||
d.lod_min_clamp = lo;
|
||||
d.lod_max_clamp = hi;
|
||||
let s = vk_sampler(&d, SamplerUse::default(), dev.profile()).unwrap();
|
||||
let what = format!("{min:?} {mag:?} {anisotropy} [{lo}, {hi}], {metal_sampler}");
|
||||
assert_eq!(s.mipmap_mode, vk::SamplerMipmapMode::NEAREST, "{what}");
|
||||
assert_eq!((s.min_lod, s.max_lod), lods, "{what}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filters_lods_and_compare() {
|
||||
let dev = device(&[], &[]);
|
||||
@@ -1807,11 +1746,11 @@ mod tests {
|
||||
let mvk = committed("moltenvk-m3");
|
||||
assert!(mvk.extensions.contains(&VkExtension::KhrPortabilitySubset));
|
||||
assert!(mvk.features.contains(&mutable));
|
||||
let dev = Device::new(mvk.clone(), DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(mvk.clone(), DevicePolicy::default()).unwrap();
|
||||
assert!(vk_sampler(&d, compare, dev.profile()).is_ok());
|
||||
let mut withheld = mvk;
|
||||
withheld.features.remove(&mutable);
|
||||
let dev = Device::new(withheld, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(withheld, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(
|
||||
vk_sampler(&d, compare, dev.profile()),
|
||||
Err(Unsupported::needs(Feature::SamplerCompare, Capability::Feature(mutable)).into())
|
||||
@@ -1819,7 +1758,7 @@ mod tests {
|
||||
assert!(vk_sampler(&d, SamplerUse::default(), dev.profile()).is_ok());
|
||||
let lavapipe = committed("lavapipe");
|
||||
assert!(!lavapipe.features.contains(&mutable));
|
||||
let dev = Device::new(lavapipe, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(lavapipe, DevicePolicy::default()).unwrap();
|
||||
assert!(vk_sampler(&d, compare, dev.profile()).is_ok());
|
||||
}
|
||||
|
||||
@@ -1855,23 +1794,14 @@ mod tests {
|
||||
#[test]
|
||||
fn a_nearest_filter_is_handed_its_anisotropy() {
|
||||
use SamplerMinMagFilter::{Linear, Nearest};
|
||||
let with = |metal_sampler: bool| {
|
||||
let (_, mut desc) = committed_descriptions()
|
||||
.into_iter()
|
||||
.find(|(s, _)| s == "vk12-floor")
|
||||
.unwrap();
|
||||
desc.features.insert(VkFeature::SamplerAnisotropy);
|
||||
desc.limits.max_sampler_anisotropy_bits = 16f32.to_bits();
|
||||
Device::with_deviation(
|
||||
desc,
|
||||
DevicePolicy::default(),
|
||||
DriverDeviation::MetalSampler,
|
||||
metal_sampler,
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
for metal_sampler in [false, true] {
|
||||
let dev = with(metal_sampler);
|
||||
let (_, mut desc) = committed_descriptions()
|
||||
.into_iter()
|
||||
.find(|(s, _)| s == "vk12-floor")
|
||||
.unwrap();
|
||||
desc.features.insert(VkFeature::SamplerAnisotropy);
|
||||
desc.limits.max_sampler_anisotropy_bits = 16f32.to_bits();
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
{
|
||||
for (min, mag) in [
|
||||
(Linear, Linear),
|
||||
(Nearest, Nearest),
|
||||
@@ -1883,11 +1813,7 @@ mod tests {
|
||||
d.mag_filter = mag;
|
||||
d.max_anisotropy = 5;
|
||||
let s = vk_sampler(&d, SamplerUse::default(), dev.profile()).unwrap();
|
||||
assert_eq!(
|
||||
s.max_anisotropy,
|
||||
Some(8.0),
|
||||
"{min:?} {mag:?}, Metal's sampler {metal_sampler}"
|
||||
);
|
||||
assert_eq!(s.max_anisotropy, Some(8.0), "{min:?} {mag:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2060,35 +1986,28 @@ mod tests {
|
||||
}
|
||||
|
||||
/// An opaque-black border through a non-identity view mapping, the texture's swizzle composed
|
||||
/// on the format's, needs the device to swizzle borders, or Metal's sampler; a view whose
|
||||
/// border texel is not Metal's (`A8Unorm` through `A8_UNORM`) refuses, or names the direct
|
||||
/// format where its view would read Metal's; other borders, identity mappings, and samplers
|
||||
/// on the format's, needs the device to swizzle borders; a view whose
|
||||
/// border texel is not Metal's (`A8Unorm` through `A8_UNORM`) refuses; other borders, identity mappings, and samplers
|
||||
/// without a border axis need nothing.
|
||||
#[test]
|
||||
fn border_swizzle_follows_the_view_mapping() {
|
||||
use vk::ComponentSwizzle as S;
|
||||
let plain = device(&[], &[]);
|
||||
let with = |swizzle: bool, metal_sampler: bool| {
|
||||
let swizzling = {
|
||||
let (_, mut desc) = committed_descriptions()
|
||||
.into_iter()
|
||||
.find(|(s, _)| s == "vk12-floor")
|
||||
.unwrap();
|
||||
if swizzle {
|
||||
desc.extensions.extend([
|
||||
VkExtension::ExtBorderColorSwizzle,
|
||||
VkExtension::ExtCustomBorderColor,
|
||||
]);
|
||||
desc.features.extend([
|
||||
VkFeature::BorderColorSwizzle,
|
||||
VkFeature::BorderColorSwizzleFromImage,
|
||||
]);
|
||||
}
|
||||
let policy = DevicePolicy::default();
|
||||
Device::with_deviation(desc, policy, DriverDeviation::MetalSampler, metal_sampler)
|
||||
.unwrap()
|
||||
desc.extensions.extend([
|
||||
VkExtension::ExtBorderColorSwizzle,
|
||||
VkExtension::ExtCustomBorderColor,
|
||||
]);
|
||||
desc.features.extend([
|
||||
VkFeature::BorderColorSwizzle,
|
||||
VkFeature::BorderColorSwizzleFromImage,
|
||||
]);
|
||||
Device::from_queries(desc, DevicePolicy::default()).unwrap()
|
||||
};
|
||||
let swizzling = with(true, false);
|
||||
let metal = with(false, true);
|
||||
let mapping = |format, components, emulation| FormatMapping {
|
||||
format,
|
||||
components,
|
||||
@@ -2154,7 +2073,7 @@ mod tests {
|
||||
TextureSwizzle::Green,
|
||||
TextureSwizzle::Blue,
|
||||
);
|
||||
for dev in [&plain, &swizzling, &metal] {
|
||||
for dev in [&plain, &swizzling] {
|
||||
assert_eq!(check(&black, rgba, &direct, own, dev), Ok(()));
|
||||
for d in [&white, &zero, &unused] {
|
||||
for s in [own, argb] {
|
||||
@@ -2165,19 +2084,17 @@ mod tests {
|
||||
}
|
||||
}
|
||||
// `A8_UNORM` reads an opaque-black border's alpha as 1, Metal's `A8Unorm` as the color's
|
||||
// red, 0; only Metal's sampler reads it so.
|
||||
// red, 0.
|
||||
for dev in [&plain, &swizzling] {
|
||||
assert_eq!(
|
||||
check(&black, alpha, &a8_unorm, own, dev),
|
||||
Err(Unsupported::not_implemented(Feature::SamplerBorderColor).into())
|
||||
);
|
||||
}
|
||||
assert_eq!(check(&black, alpha, &a8_unorm, own, &metal), Ok(()));
|
||||
// `R8_UNORM`'s `(0, 0, 0, R)` reads the border's red as alpha, Metal's texel, where the
|
||||
// device swizzles borders.
|
||||
assert_eq!(check(&black, alpha, &a8, own, &plain), features());
|
||||
assert_eq!(check(&black, alpha, &a8, own, &swizzling), Ok(()));
|
||||
assert_eq!(check(&black, alpha, &a8, own, &metal), Ok(()));
|
||||
// The texture's swizzle is composed on the format's mapping.
|
||||
for m in [&direct, &twin] {
|
||||
for s in [own, argb] {
|
||||
@@ -2187,7 +2104,6 @@ mod tests {
|
||||
};
|
||||
assert_eq!(check(&black, rgba, m, s, &plain), expected, "{m:?} {s:?}");
|
||||
assert_eq!(check(&black, rgba, m, s, &swizzling), Ok(()));
|
||||
assert_eq!(check(&black, rgba, m, s, &metal), Ok(()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2260,7 +2176,7 @@ mod tests {
|
||||
]);
|
||||
}
|
||||
desc.rgba4_opaque_black_swizzled = rgba4;
|
||||
Device::new(desc, DevicePolicy::default()).unwrap()
|
||||
Device::from_queries(desc, DevicePolicy::default()).unwrap()
|
||||
};
|
||||
let direct = FormatMapping {
|
||||
format: vk::Format::R4G4B4A4_UNORM_PACK16,
|
||||
@@ -2330,13 +2246,13 @@ mod tests {
|
||||
/// A runtime sampler made per view: through a mapping other than the identity, with
|
||||
/// `borderColorSwizzle` and without `borderColorSwizzleFromImage`, the device reads an
|
||||
/// opaque-black border as Metal's texel when the sampler carries the view's mapping
|
||||
/// (`Mapped`); one the binder cannot make per view needs `FromImage` there. Both features, or
|
||||
/// Metal's sampler, read the stated border through any view; without `borderColorSwizzle`
|
||||
/// (`Mapped`); one the binder cannot make per view needs `FromImage` there. Both features read
|
||||
/// the stated border through any view; without `borderColorSwizzle`
|
||||
/// the mapping is refused for it alone.
|
||||
#[test]
|
||||
fn opaque_black_maps_the_sampler_where_the_view_cannot() {
|
||||
use vk::ComponentSwizzle as S;
|
||||
let with = |features: &[VkFeature], metal_sampler: bool| {
|
||||
let with = |features: &[VkFeature]| {
|
||||
let (_, mut desc) = committed_descriptions()
|
||||
.into_iter()
|
||||
.find(|(s, _)| s == "vk12-floor")
|
||||
@@ -2348,20 +2264,14 @@ mod tests {
|
||||
]);
|
||||
desc.features.extend(features.iter().copied());
|
||||
}
|
||||
let policy = DevicePolicy::default();
|
||||
Device::with_deviation(desc, policy, DriverDeviation::MetalSampler, metal_sampler)
|
||||
.unwrap()
|
||||
Device::from_queries(desc, DevicePolicy::default()).unwrap()
|
||||
};
|
||||
let plain = with(&[], false);
|
||||
let swizzle_only = with(&[VkFeature::BorderColorSwizzle], false);
|
||||
let both = with(
|
||||
&[
|
||||
VkFeature::BorderColorSwizzle,
|
||||
VkFeature::BorderColorSwizzleFromImage,
|
||||
],
|
||||
false,
|
||||
);
|
||||
let metal = with(&[], true);
|
||||
let plain = with(&[]);
|
||||
let swizzle_only = with(&[VkFeature::BorderColorSwizzle]);
|
||||
let both = with(&[
|
||||
VkFeature::BorderColorSwizzle,
|
||||
VkFeature::BorderColorSwizzleFromImage,
|
||||
]);
|
||||
let direct = FormatMapping {
|
||||
format: vk::Format::R8G8B8A8_UNORM,
|
||||
components: vk::ComponentMapping::IDENTITY,
|
||||
@@ -2394,7 +2304,7 @@ mod tests {
|
||||
)
|
||||
.into()
|
||||
};
|
||||
for dev in [&plain, &swizzle_only, &both, &metal] {
|
||||
for dev in [&plain, &swizzle_only, &both] {
|
||||
let p = dev.profile();
|
||||
assert_eq!(
|
||||
opaque_black_border(rgba, &direct, own, p),
|
||||
@@ -2402,7 +2312,8 @@ mod tests {
|
||||
);
|
||||
assert_eq!(check_border_view(true, rgba, &direct, own, p), Ok(()));
|
||||
}
|
||||
for dev in [&both, &metal] {
|
||||
{
|
||||
let dev = &both;
|
||||
for (m, s) in [(&direct, argb), (&twin, own), (&twin, argb)] {
|
||||
let p = dev.profile();
|
||||
assert_eq!(
|
||||
@@ -2776,7 +2687,7 @@ mod tests {
|
||||
let mut desc = desc;
|
||||
desc.features.insert(VkFeature::SamplerAnisotropy);
|
||||
desc.limits.max_sampler_anisotropy_bits = 16f32.to_bits();
|
||||
let dev = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
{
|
||||
let use_ = SamplerUse::new(false, false);
|
||||
let (linear, nearest) = device_anisotropy_by_filters(use_, dev.profile());
|
||||
|
||||
@@ -509,7 +509,7 @@ mod tests {
|
||||
} else {
|
||||
desc.features.remove(&VkFeature::DualSrcBlend);
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default()).unwrap()
|
||||
Device::from_queries(desc, DevicePolicy::default()).unwrap()
|
||||
}
|
||||
|
||||
/// Every concrete factor maps, the names agree, and only `Source1*` needs `dualSrcBlend`.
|
||||
@@ -629,7 +629,7 @@ mod tests {
|
||||
.into_iter()
|
||||
.find(|(s, _)| s == name)
|
||||
.unwrap();
|
||||
Device::new(desc, DevicePolicy::default()).unwrap()
|
||||
Device::from_queries(desc, DevicePolicy::default()).unwrap()
|
||||
}
|
||||
|
||||
/// The encoder's fill mode, depth clip mode, and depth bias clamp map where the device has
|
||||
|
||||
@@ -531,7 +531,7 @@ mod tests {
|
||||
);
|
||||
desc.features
|
||||
.remove(&VkFeature::VertexAttributeInstanceRateDivisor);
|
||||
let plain = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let plain = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
desc.features
|
||||
.insert(VkFeature::VertexAttributeInstanceRateDivisor);
|
||||
// Listed with the extension that exposes it below Vulkan 1.4.
|
||||
@@ -540,9 +540,9 @@ mod tests {
|
||||
desc.limits.max_vertex_attrib_divisor = 4;
|
||||
// No nonzero first instance with a divisor (VUID-vkCmdDraw-pNext-09461): pulled.
|
||||
desc.limits.supports_non_zero_first_instance = false;
|
||||
let zero_first = Device::new(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
let zero_first = Device::from_queries(desc.clone(), DevicePolicy::default()).unwrap();
|
||||
desc.limits.supports_non_zero_first_instance = true;
|
||||
let divisor = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let divisor = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
use VertexStepFunction as S;
|
||||
let fetch = |dev: &Device, f, s, r| attribute_fetch(f, s, r, dev.profile());
|
||||
let fixed = |rate, divisor| {
|
||||
@@ -620,7 +620,7 @@ mod tests {
|
||||
},
|
||||
);
|
||||
}
|
||||
let dev = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
assert!(dev.profile().supports_format(
|
||||
vk::Format::E5B9G9R9_UFLOAT_PACK32,
|
||||
FormatUsage::VertexBuffer
|
||||
@@ -662,9 +662,9 @@ mod tests {
|
||||
isolation: GuestIsolation::Off,
|
||||
..DevicePolicy::UNTRUSTED
|
||||
};
|
||||
let checked = Device::new(bare.clone(), DevicePolicy::default()).unwrap();
|
||||
let off = Device::new(bare, unsafe_off).unwrap();
|
||||
let robust = Device::new(robust, DevicePolicy::default()).unwrap();
|
||||
let checked = Device::from_queries(bare.clone(), DevicePolicy::default()).unwrap();
|
||||
let off = Device::from_queries(bare, unsafe_off).unwrap();
|
||||
let robust = Device::from_queries(robust, DevicePolicy::default()).unwrap();
|
||||
assert_eq!(contain::encoding(checked.profile()), Check::InShader);
|
||||
assert_eq!(contain::encoding(robust.profile()), Check::None);
|
||||
assert_eq!(contain::encoding(off.profile()), Check::None);
|
||||
@@ -704,7 +704,7 @@ mod tests {
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let dev = Device::new(desc, DevicePolicy::default()).unwrap();
|
||||
let dev = Device::from_queries(desc, DevicePolicy::default()).unwrap();
|
||||
for v in [
|
||||
VertexFormat::Float,
|
||||
VertexFormat::Float2,
|
||||
|
||||
@@ -814,8 +814,7 @@ pub enum PrecisionNote {
|
||||
/// (`NoContraction`). The AIR's value is any of the rewrites those flags allow, and Metal's
|
||||
/// compiler takes its own grouping and fusion, so the roundings may differ: by any amount
|
||||
/// relative to the result where a sum of mixed signs is grouped otherwise, or a multiply-add
|
||||
/// fused on one side alone. On a device without `shaderFloat16`, under
|
||||
/// `HalfChainPolicy::AtExits` (the default), a chain of such `half` additions, subtractions and
|
||||
/// fused on one side alone. On a device without `shaderFloat16` a chain of such `half` additions, subtractions and
|
||||
/// products is held at `float` precision between the roundings where its values leave it
|
||||
/// (`lower::arith::half_chain`): the result may differ from the rounded operations' by the
|
||||
/// roundings skipped, and a value inside the chain past `half`'s range stays finite. On
|
||||
@@ -1134,7 +1133,7 @@ pub enum PrecisionNote {
|
||||
///
|
||||
/// On every device, a linear sample of a two-plane YCbCr texture whose planes the function
|
||||
/// reads in place (`lower::sampler::in_place`) by Vulkan's Y′CbCr model of the codes
|
||||
/// (`YCbCrInPlacePolicy::Model`, the default; `Exact` takes Metal's filter) records it too,
|
||||
/// records it too,
|
||||
/// under the slot's bound converted 4:2:0 format and, through a runtime sampler slot, the bound
|
||||
/// word's linear filter that addresses no border, announced as `ycbcr-filter-not-exact`. The
|
||||
/// `float` result's counterpart is [`PrecisionNote::FloatSampleFilter`]. Validation derives no
|
||||
|
||||
@@ -213,12 +213,7 @@ impl<'a> From<&'a MeshPipelineDescriptor> for FragmentPass<'a> {
|
||||
logic_operation: None,
|
||||
depth_compare_clamp_mask: 0,
|
||||
color_group: None,
|
||||
push_base: crate::lower::push::window(
|
||||
crate::pipeline::sym::Stage::Mesh,
|
||||
crate::device::profile::PushWindow::Floor,
|
||||
0,
|
||||
)
|
||||
.1,
|
||||
push_base: crate::lower::push::window(crate::pipeline::sym::Stage::Mesh, 0).1,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2721,10 +2716,8 @@ pub(crate) fn fragment_inputs(
|
||||
out.logic_operation = d.logic_operation;
|
||||
out.depth_compare_clamp_mask = d.depth_compare_clamp_mask;
|
||||
out.texture_write_rounding = d.texture_write_rounding_mode;
|
||||
// Only the floor's one render range moves the fragment function's fields.
|
||||
if p.push_window() == crate::device::profile::PushWindow::Floor {
|
||||
out.push_base = d.push_base;
|
||||
}
|
||||
// The floor's one render range moves the fragment function's fields.
|
||||
out.push_base = d.push_base;
|
||||
out
|
||||
}
|
||||
|
||||
@@ -3354,28 +3347,11 @@ fn lower_bounded<K>(
|
||||
let native_widening = widens && !controls && !measured_widening;
|
||||
// A `half` rounded through the conversion and its widening under the float controls: Metal's
|
||||
// `half(float)` by the Vulkan spec, but a driver's compiler may fold the pair into the value it
|
||||
// started from (NVIDIA's) or fuse the `float` operation computing the value into the narrowing
|
||||
// and round its exact result once (RADV's). On a profile that notes every such pair
|
||||
// (`HalfPairNote::Every`), the module records the native note on every device, a static note
|
||||
// of the rounding; on one that notes it as its driver's rows say (`HalfPairNote::Fused`), only
|
||||
// a `half` rounded from `float` arithmetic on a driver that fuses the operation into the
|
||||
// narrowing (`DriverWorkaround::HalfConversionFusedWithArithmetic`) records it.
|
||||
// started from or fuse the `float` operation computing the value into the narrowing and round
|
||||
// its exact result once. The module records the native note on every device, a static note of
|
||||
// the rounding.
|
||||
let controlled = quantize == crate::spirv::builder::QuantizeForm::Controlled;
|
||||
let controlled_pair = match p.half_pair_note() {
|
||||
crate::device::profile::HalfPairNote::Every => {
|
||||
Some(controlled && crate::lower::arith::narrow::rounds_by_conversion(&module, m)?)
|
||||
}
|
||||
crate::device::profile::HalfPairNote::Fused => None,
|
||||
};
|
||||
let fused =
|
||||
match controlled_pair {
|
||||
Some(pair) => pair,
|
||||
None => controlled
|
||||
&& p.workarounds().contains(
|
||||
&crate::device::profile::DriverWorkaround::HalfConversionFusedWithArithmetic,
|
||||
)
|
||||
&& crate::lower::arith::narrow::rounds_arithmetic(&module, m)?,
|
||||
};
|
||||
let fused = controlled && crate::lower::arith::narrow::rounds_by_conversion(&module, m)?;
|
||||
// Its NaN's bits, and those of a `half` held widened that a widening to `float` or a `half`
|
||||
// `fabs` moves: Metal's where the device's widening and narrowing are measured to answer
|
||||
// them (`DriverDeviation::MetalNanMoves`) and the module moves its `half` values only as
|
||||
@@ -3499,12 +3475,6 @@ fn lower_bounded<K>(
|
||||
false => VkProperty::MetalSampler,
|
||||
});
|
||||
}
|
||||
// A `half` fused multiply-add left to the device's 16-bit `Fma` because it is Metal's.
|
||||
if plan.families.arith.f16_fma {
|
||||
requirements
|
||||
.properties
|
||||
.insert(crate::device::requirements::VkProperty::MetalHalfFma);
|
||||
}
|
||||
// A NaN's bits left to the device's widening, narrowing, negation or magnitude because they
|
||||
// are Metal's.
|
||||
if plan.families.arith.nan_moves || moved_nans || (held_moves && !unfolded) {
|
||||
@@ -3646,11 +3616,9 @@ fn lower_bounded<K>(
|
||||
}
|
||||
}
|
||||
// Implementation-defined where a tangled instruction runs without maximal reconvergence
|
||||
// (`lower::simd` chooses the entry's reconvergence mode), which the stage's note records on a
|
||||
// profile that notes it (`ReconvergenceNote::Noted`).
|
||||
// (`lower::simd` chooses the entry's reconvergence mode), which the stage's note records.
|
||||
let reconvergence = crate::lower::simd::reconvergence(&plan);
|
||||
if reconvergence == Reconvergence::ImplementationDefined
|
||||
&& p.reconvergence_note() == crate::device::profile::ReconvergenceNote::Noted
|
||||
&& !precision.contains(&PrecisionNote::DeviceReconvergence)
|
||||
{
|
||||
precision.push(PrecisionNote::DeviceReconvergence);
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
//! The stage bounds: a module kept under the sizes its driver's compiler takes intact
|
||||
//! (`DriverWorkaround::SerializedStageWrapsLargeModules`) and in host-sized memory
|
||||
//! (`DriverWorkaround::CompilerMemoryGrowsWithStageSize`), where `Device::new`'s profile names
|
||||
//! those defects; and on a profile `Device::from_queries` built, every module kept under the
|
||||
//! compiled bound on every device (`device::profile::StageBound`).
|
||||
//! The stage bound: every module kept under the compiled bound, on every device.
|
||||
//!
|
||||
//! Mesa's common pipeline runtime (`vk_pipeline.c`), which ANV's pipelines go through, writes each
|
||||
//! stage after the driver's preprocessing into a precompiled shader (`nir_serialize`) and reads it
|
||||
//! back (`nir_deserialize`) before compiling it, on every pipeline it makes, cached or not. The
|
||||
//! serialized form names a value by a 20-bit index, and the bound (`MAX_OBJECT_IDS`, 2^20 objects:
|
||||
//! values, blocks, variables) is held only by an assertion a release build leaves out: past it the
|
||||
//! indices wrap, the reader takes other objects for them, and the driver faults inside
|
||||
//! `vkCreateComputePipelines` (Mesa 26.2.6, ANV on the Iris Xe). Below that bound, the driver's
|
||||
//! compiler takes memory that grows faster than the stage, in the process that creates the
|
||||
//! pipeline, so one creation past the largest stage measured to compile may take the host's
|
||||
//! memory.
|
||||
//! A driver's compiler takes memory that grows faster than the stage, in the process that creates
|
||||
//! the pipeline, so one creation past the largest stage measured to compile may take the host's
|
||||
//! memory. No Vulkan query states how large a stage a device's compiler takes, so every stage, on
|
||||
//! every device, is held under the compiled bound, the heaviest stage measured to compile on the
|
||||
//! slowest compiler measured, one form for every device.
|
||||
//!
|
||||
//! On a profile with either defect, a module whose entry weighs more than its bound
|
||||
//! (`spirv::roll::entry_weight`: the entry's instructions with each call counted as its callee's
|
||||
//! body, as the driver inlines every call) after the repeated regions are rolled is past it:
|
||||
//! A module whose entry weighs more than the bound (`spirv::roll::entry_weight`: the entry's
|
||||
//! instructions with each call counted as its callee's body, as the driver inlines every call)
|
||||
//! after the repeated regions are rolled is past it:
|
||||
//!
|
||||
//! - a kernel that took the `Emulated` simdgroup tier only in place of the `Direct` tier's pin to
|
||||
//! the device's widest mode (`lower::simd::widest_pin`) is planned again keeping the pin
|
||||
@@ -26,27 +17,9 @@
|
||||
//! specialized, ordered and analyzed once, so the kernel is charged what any compile of it is
|
||||
//! charged, whichever path reached it (`super::Analyzed`);
|
||||
//! - every other module past it, a kernel planned again that still is among them, is refused
|
||||
//! (`Unsupported`, `Feature::StageSize`, `Needs::DriverDefect`, naming the serialized stage's
|
||||
//! defect past its bound and the compiler's memory below it, and as its symbol the module's
|
||||
//! entry weight and the bound it passed): Metal compiles it, so the refusal is the device's
|
||||
//! gap, recorded in `docs/FAST-PATHS.md`'s known gaps.
|
||||
//!
|
||||
//! **Every device.** A profile `Device::from_queries` built reads no driver identity, so it names
|
||||
//! no defect: it holds every stage, on every device, under the compiled bound, the heaviest stage
|
||||
//! measured to compile on the slowest compiler measured, one form for every device. A kernel past
|
||||
//! it is planned again keeping the widest mode's pin as above, and every other module past it is
|
||||
//! refused as `Needs::StageBound`, with the same symbol: a device whose compiler would take a
|
||||
//! heavier stage is refused it all the same, a known gap of `metal2vulkan-rt`.
|
||||
//!
|
||||
//! **The serialized bound.** The driver's object count is not the module's: it counts the stage
|
||||
//! after its own inlining and optimization. Measured on ANV, Mesa 26.2.6, on the Iris Xe of RPL-P
|
||||
//! (the count each serialized stage holds, read where the driver reads it back), over 22 compute
|
||||
//! stages: the heaviest, of entry weight 1,603,989, held 1,096,128 objects, 0.683 per instruction
|
||||
//! of its weight, and faulted the driver; the other 21 held 0.14 to 0.99 objects per instruction
|
||||
//! of a count of the entry's instructions that ran 1.9 to 2.7% below the entry weight on the five
|
||||
//! modules both counted. [`SERIALIZED_STAGE_WEIGHT`] is three quarters of 2^20: a stage at the
|
||||
//! bound stays under the driver's 2^20 objects at up to 4/3 objects per instruction, a third above
|
||||
//! the largest ratio measured.
|
||||
//! (`Unsupported`, `Feature::StageSize`, `Needs::StageBound`, naming as its symbol the module's
|
||||
//! entry weight and the bound it passed): a device whose compiler would take a heavier stage is
|
||||
//! refused it all the same, a known gap of `metal2vulkan-rt`.
|
||||
//!
|
||||
//! **The compiled bound.** [`COMPILED_STAGE_WEIGHT`] is the heaviest entry measured to compile
|
||||
//! within host-sized memory: on ANV, Mesa 26.2.6, on the Iris Xe of RPL-P, compute modules created
|
||||
@@ -58,87 +31,40 @@
|
||||
|
||||
use super::{analyze_one, Planned, Request};
|
||||
use crate::budget::Meter;
|
||||
use crate::device::profile::{DriverWorkaround, StageBound};
|
||||
use crate::device::DeviceProfile;
|
||||
use crate::error::{DiagName, Error, Feature, Needs, Unsupported};
|
||||
use crate::lower::emit::Emitted;
|
||||
use crate::lower::simd::WidestPin;
|
||||
|
||||
/// The heaviest entry ([`crate::spirv::roll::entry_weight`]) a profile with
|
||||
/// `DriverWorkaround::SerializedStageWrapsLargeModules` is handed (the module docs' serialized
|
||||
/// bound).
|
||||
pub(crate) const SERIALIZED_STAGE_WEIGHT: u64 = 3 << 18;
|
||||
|
||||
/// The heaviest entry ([`crate::spirv::roll::entry_weight`]) a profile with
|
||||
/// `DriverWorkaround::CompilerMemoryGrowsWithStageSize`, or one whose every stage is bounded
|
||||
/// (`StageBound::Every`), is handed: the largest measured to compile (the module docs' compiled
|
||||
/// bound).
|
||||
/// The heaviest entry ([`crate::spirv::roll::entry_weight`]) every stage is handed: the largest
|
||||
/// measured to compile (the module docs' compiled bound).
|
||||
pub(crate) const COMPILED_STAGE_WEIGHT: u64 = 99_109;
|
||||
|
||||
/// The entry weights past which a profile with each defect, or one whose every stage is bounded, is
|
||||
/// not handed a module: the measured ones in production ([`StageBounds::MEASURED`]), others in a
|
||||
/// test, so it reaches each bound with a small module.
|
||||
/// The entry weight past which no module is handed to the device: the measured one in production
|
||||
/// ([`StageBounds::MEASURED`]), another in a test, so it reaches the bound with a small module.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct StageBounds {
|
||||
/// `DriverWorkaround::SerializedStageWrapsLargeModules`' bound.
|
||||
pub(crate) serialized: u64,
|
||||
/// `DriverWorkaround::CompilerMemoryGrowsWithStageSize`'s bound, and every stage's on a
|
||||
/// profile whose every stage is bounded.
|
||||
/// Every stage's bound.
|
||||
pub(crate) compiled: u64,
|
||||
}
|
||||
|
||||
impl StageBounds {
|
||||
/// The bounds measured on the defects' drivers (the module docs).
|
||||
/// The bound measured (the module docs).
|
||||
pub(crate) const MEASURED: StageBounds = StageBounds {
|
||||
serialized: SERIALIZED_STAGE_WEIGHT,
|
||||
compiled: COMPILED_STAGE_WEIGHT,
|
||||
};
|
||||
|
||||
/// `p`'s bounds, each with what a module past it is refused as: on a profile whose every
|
||||
/// stage is bounded, the compiled bound alone; else its defects', the serialized stage's
|
||||
/// first, so a module past both is refused for the one that faults the driver.
|
||||
fn of(self, p: &DeviceProfile) -> Vec<(Past, u64)> {
|
||||
if p.stage_bound() == StageBound::Every {
|
||||
return vec![(Past::Every, self.compiled)];
|
||||
}
|
||||
[
|
||||
(
|
||||
DriverWorkaround::SerializedStageWrapsLargeModules,
|
||||
self.serialized,
|
||||
),
|
||||
(
|
||||
DriverWorkaround::CompilerMemoryGrowsWithStageSize,
|
||||
self.compiled,
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.filter(|(defect, _)| p.workarounds().contains(defect))
|
||||
.map(|(defect, bound)| (Past::Defect(defect), bound))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// What a module past a bound is refused as.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Past {
|
||||
/// The driver's stage-size defect (`Needs::DriverDefect`).
|
||||
Defect(DriverWorkaround),
|
||||
/// The bound every stage is held under (`Needs::StageBound`).
|
||||
Every,
|
||||
}
|
||||
|
||||
/// `r`'s function planned and emitted with its repeated regions rolled, under the plan's word
|
||||
/// estimate `word_cap` and, on a profile with a stage bound's defect or whose every stage is
|
||||
/// bounded, under `bounds` (the module docs): planned again keeping the widest mode's pin where
|
||||
/// only that pin's emulation passed one, else refused as the first bound the module passes, naming
|
||||
/// the module's entry weight and that bound ([`past_bound`]).
|
||||
/// estimate `word_cap` and under `bounds` (the module docs): planned again keeping the widest
|
||||
/// mode's pin where only that pin's emulation passed the bound, else refused, naming the module's
|
||||
/// entry weight and the bound ([`past_bound`]).
|
||||
pub(super) fn emit(
|
||||
r: &Request<'_>,
|
||||
p: &DeviceProfile,
|
||||
(word_cap, bounds): (u64, StageBounds),
|
||||
m: &mut Meter,
|
||||
) -> Result<(Planned, Emitted), Error> {
|
||||
let bounded = bounds.of(p);
|
||||
let analyzed = analyze_one(r, p, m)?;
|
||||
let mut widest = WidestPin::Weighed;
|
||||
loop {
|
||||
@@ -157,21 +83,12 @@ pub(super) fn emit(
|
||||
m.weighted(crate::pipeline::compile::weights::HOIST, |m| {
|
||||
crate::spirv::hoist::hoist_uniform_loads(&mut emitted.module, p.containment(), m)
|
||||
})?;
|
||||
let past = match bounded.is_empty() {
|
||||
true => None,
|
||||
false => {
|
||||
let weight = crate::spirv::roll::entry_weight(&emitted.module, m)?;
|
||||
bounded
|
||||
.iter()
|
||||
.find(|&&(_, cap)| weight > cap)
|
||||
.map(|&(past, cap)| (past, weight, cap))
|
||||
}
|
||||
};
|
||||
let Some((past, weight, bound)) = past else {
|
||||
let weight = crate::spirv::roll::entry_weight(&emitted.module, m)?;
|
||||
if weight <= bounds.compiled {
|
||||
return Ok((analyzed.planned(plan, kernel), emitted));
|
||||
};
|
||||
}
|
||||
if widest == WidestPin::Kept || !plan.families.simd.widest_pin {
|
||||
return Err(refused(past, weight, bound));
|
||||
return Err(refused(weight, bounds.compiled));
|
||||
}
|
||||
// The emulated plan and module go, and with them what they hold of the ledger.
|
||||
drop((plan, emitted));
|
||||
@@ -181,20 +98,14 @@ pub(super) fn emit(
|
||||
}
|
||||
}
|
||||
|
||||
/// The refusal of a module of entry weight `weight` past `bound`, as `past` says.
|
||||
fn refused(past: Past, weight: u64, bound: u64) -> Error {
|
||||
let named = past_bound(weight, bound);
|
||||
match past {
|
||||
Past::Defect(defect) => Unsupported::driver_defect(Feature::StageSize, defect)
|
||||
.naming(named)
|
||||
.into(),
|
||||
Past::Every => Error::Unsupported(Unsupported {
|
||||
feature: Feature::StageSize,
|
||||
needs: Needs::StageBound,
|
||||
location: None,
|
||||
symbol: Some(named),
|
||||
}),
|
||||
}
|
||||
/// The refusal of a module of entry weight `weight` past `bound`.
|
||||
fn refused(weight: u64, bound: u64) -> Error {
|
||||
Error::Unsupported(Unsupported {
|
||||
feature: Feature::StageSize,
|
||||
needs: Needs::StageBound,
|
||||
location: None,
|
||||
symbol: Some(past_bound(weight, bound)),
|
||||
})
|
||||
}
|
||||
|
||||
/// What a stage's refusal names as its symbol: the module's entry weight and the bound it passed.
|
||||
|
||||
@@ -63,7 +63,7 @@ fn fixture(stem: &str) -> Option<Vec<u8>> {
|
||||
|
||||
/// Committed profile `stem` as a device with the default policy.
|
||||
fn device(stem: &str) -> Device {
|
||||
Device::new(description(stem), DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(description(stem), DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// Committed profile `stem` as the Khronos reader describes it.
|
||||
@@ -1642,7 +1642,7 @@ fn a_render_pipeline_requires_extended_dynamic_state_exactly_when_it_makes_one_d
|
||||
)));
|
||||
d.rasterization_enabled = false;
|
||||
let compile = |desc: &DeviceDescription| {
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let pipe = dev
|
||||
.compile_render_pipeline(&d, &Budget::standard())
|
||||
.expect("render pipeline");
|
||||
@@ -1738,7 +1738,7 @@ fn a_vertex_pipeline_makes_its_input_assembly_dynamic_exactly_with_both_extended
|
||||
)));
|
||||
d.rasterization_enabled = false;
|
||||
let compile = |desc: &DeviceDescription| {
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
dev.compile_render_pipeline(&d, &Budget::standard())
|
||||
.expect("render pipeline")
|
||||
};
|
||||
@@ -1850,7 +1850,7 @@ fn a_framebuffer_fetch_pipeline_is_ordered_exactly_where_the_device_orders_it()
|
||||
c.destination_rgb_blend_factor = metal::BlendFactor::One;
|
||||
}
|
||||
let compile = |desc: &DeviceDescription, policy: DevicePolicy, d: &RenderPipelineDescriptor| {
|
||||
let dev = Device::new(desc.clone(), policy).expect("device");
|
||||
let dev = Device::from_queries(desc.clone(), policy).expect("device");
|
||||
let pipe = dev.compile_render_pipeline(d, &Budget::standard())?;
|
||||
for s in &pipe.stages {
|
||||
l3(&s.spirv, &pipe.requirements, &dev);
|
||||
@@ -2222,7 +2222,7 @@ fn a_multisampled_framebuffer_fetch_reads_each_samples_own_color() {
|
||||
d
|
||||
};
|
||||
let compile = |desc: &DeviceDescription, d: &RenderPipelineDescriptor| {
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let pipe = dev.compile_render_pipeline(d, &Budget::standard())?;
|
||||
for s in &pipe.stages {
|
||||
l3(&s.spirv, &pipe.requirements, &dev);
|
||||
@@ -2452,7 +2452,7 @@ fn a_render_pipeline_requires_the_blend_features_its_attachments_need() {
|
||||
};
|
||||
let compile = |stem: &str, d: &RenderPipelineDescriptor| {
|
||||
let desc = description(stem);
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let pipe = dev.compile_render_pipeline(d, &Budget::standard())?;
|
||||
let enables = desc
|
||||
.required_enables(&pipe.requirements)
|
||||
@@ -2876,7 +2876,7 @@ fn a_render_pipeline_requires_the_portability_features_it_uses() {
|
||||
};
|
||||
// Every pipeline that compiles requires only what its device enabled.
|
||||
let compile = |desc: &DeviceDescription, d: &RenderPipelineDescriptor| {
|
||||
let dev = Device::new(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
let dev = Device::from_queries(desc.clone(), DevicePolicy::default()).expect("device");
|
||||
dev.compile_render_pipeline(d, &Budget::standard())
|
||||
.map(|p| {
|
||||
assert_eq!(dev.profile().check(&p.requirements), Ok(()));
|
||||
@@ -2964,7 +2964,8 @@ fn a_render_pipeline_requires_its_framebuffer_sample_counts() {
|
||||
),
|
||||
] {
|
||||
d.raster_sample_count = count;
|
||||
let dev = Device::new(description("lavapipe"), DevicePolicy::default()).expect("device");
|
||||
let dev =
|
||||
Device::from_queries(description("lavapipe"), DevicePolicy::default()).expect("device");
|
||||
let pipe = dev
|
||||
.compile_render_pipeline(&d, &Budget::standard())
|
||||
.expect("lavapipe");
|
||||
@@ -3043,7 +3044,7 @@ fn the_interface_states_why_a_slot_takes_no_snapshot() {
|
||||
(d.features).remove(&VkFeature::ShaderDemoteToHelperInvocation),
|
||||
"the 780M's profile demotes"
|
||||
);
|
||||
let ends = Device::new(d, DevicePolicy::default()).expect("device");
|
||||
let ends = Device::from_queries(d, DevicePolicy::default()).expect("device");
|
||||
for (name, dev, refusals) in [
|
||||
("demote", &demotes, Vec::new()),
|
||||
("no demote", &ends, vec![(0, SnapshotRefusal::Branch)]),
|
||||
@@ -3149,10 +3150,7 @@ fn a_snapshot_variant_reads_its_texture_in_the_copy_alone() {
|
||||
inputs
|
||||
};
|
||||
let mut interlocked = 0;
|
||||
let policies = [
|
||||
("default", DevicePolicy::default()),
|
||||
("exact", DevicePolicy::default().exact_answers()),
|
||||
];
|
||||
let policies = [("default", DevicePolicy::default())];
|
||||
for (stem, name, policy) in [
|
||||
"intel-irisxe-anv",
|
||||
"nvidia-rtx5080-laptop",
|
||||
|
||||
@@ -24,7 +24,7 @@ fn profile_with_level(stem: &str, level: u32) -> DeviceProfile {
|
||||
);
|
||||
assert_ne!(edited, text, "{stem} states the level");
|
||||
let desc = DeviceDescription::from_khronos_json(&edited, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -121,12 +121,7 @@ pub(super) fn iface(
|
||||
stage,
|
||||
slots: BTreeMap::new(),
|
||||
threadgroup: Vec::new(),
|
||||
push: crate::lower::push::place(
|
||||
stage,
|
||||
crate::device::profile::PushWindow::Guaranteed,
|
||||
0,
|
||||
&BTreeSet::new(),
|
||||
),
|
||||
push: crate::lower::push::place(stage, 0, &BTreeSet::new()),
|
||||
descriptors,
|
||||
spec,
|
||||
needs_pointer_translation: false,
|
||||
@@ -605,16 +600,10 @@ fn push_ranges_are_the_stage_windows() {
|
||||
})
|
||||
};
|
||||
let mut vs = iface(Stage::Vertex, Vec::new(), Vec::new());
|
||||
vs.push = crate::lower::push::place(
|
||||
Stage::Vertex,
|
||||
crate::device::profile::PushWindow::Guaranteed,
|
||||
0,
|
||||
&BTreeSet::from([sb(Stage::Vertex)]),
|
||||
);
|
||||
vs.push = crate::lower::push::place(Stage::Vertex, 0, &BTreeSet::from([sb(Stage::Vertex)]));
|
||||
let mut fs = iface(Stage::Fragment, Vec::new(), Vec::new());
|
||||
fs.push = crate::lower::push::place(
|
||||
Stage::Fragment,
|
||||
crate::device::profile::PushWindow::Guaranteed,
|
||||
0,
|
||||
&BTreeSet::from([PushField::RootTableAddress, sb(Stage::Fragment)]),
|
||||
);
|
||||
|
||||
@@ -389,12 +389,7 @@ fn a_regions_variant_draws_its_vertex_function_s_copies() {
|
||||
let regions = fanned(RegionFanOut::RegionCopies);
|
||||
not_implemented(link(&[&v, &f], ®ions, &p).unwrap_err());
|
||||
let fields = BTreeSet::from([PushField::RegionBox]);
|
||||
v.interface.push = crate::lower::push::place(
|
||||
Stage::Vertex,
|
||||
crate::device::profile::PushWindow::Guaranteed,
|
||||
0,
|
||||
&fields,
|
||||
);
|
||||
v.interface.push = crate::lower::push::place(Stage::Vertex, 0, &fields);
|
||||
let offset = match v.interface.push.fields.as_slice() {
|
||||
[placed] => match placed.loc {
|
||||
crate::pipeline::interface::PushLoc::Push { offset } => offset,
|
||||
|
||||
@@ -2529,7 +2529,7 @@ fn multisampled_fragment_invocations_follow_metals_measured_rules() {
|
||||
)
|
||||
.expect("description");
|
||||
edit(&mut d);
|
||||
crate::device::Device::new(d, DevicePolicy::default())
|
||||
crate::device::Device::from_queries(d, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -948,7 +948,7 @@ pub struct LoweringInputs {
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub unit_axes: u8,
|
||||
/// Where a fragment function's push fields start on `Device::from_queries`' profile
|
||||
/// (`PushWindow::Floor`), whose render pipeline pushes one range `[0, 256)` for both stages:
|
||||
///, whose render pipeline pushes one range `[0, 256)` for both stages:
|
||||
/// its vertex function's fields first, from 0, then the fragment function's from this offset,
|
||||
/// the vertex function's push end
|
||||
/// ([`CompiledFunction::fragment_push_base`](crate::library::CompiledFunction::fragment_push_base)).
|
||||
|
||||
@@ -649,9 +649,8 @@ pub(crate) fn note_tile_store(
|
||||
p: &DeviceProfile,
|
||||
modules: &mut [StageModule],
|
||||
) {
|
||||
use crate::device::profile::SnormMinimumNote;
|
||||
use PixelFormat as P;
|
||||
if p.snorm_minimum_note() != SnormMinimumNote::Noted || d.raster_sample_count > 1 {
|
||||
if d.raster_sample_count > 1 {
|
||||
return;
|
||||
}
|
||||
let formats = || d.color_attachments.iter().flatten().map(|a| a.pixel_format);
|
||||
|
||||
@@ -395,7 +395,7 @@ fn a_second_output_needs_dual_source_blending() {
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
assert!(desc.features.remove(&VkFeature::DualSrcBlend));
|
||||
let p = Device::new(desc, DevicePolicy::default())
|
||||
let p = Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
|
||||
@@ -1105,7 +1105,7 @@ pub enum PushField {
|
||||
/// The function states `RuntimeFact::FramebufferFetch` for the color, and its fetches are
|
||||
/// ordered after earlier draws only by the consumer's barriers, not after an overlapping
|
||||
/// earlier fragment of the same draw (`PrecisionNote::UnorderedFetchWithinDraw`). Ordered
|
||||
/// before the slot addresses, so on the floor (`PushWindow::Floor`) a fragment function that
|
||||
/// before the slot addresses, so on the floor a fragment function that
|
||||
/// pushes no parameter block's address places it in the four bytes a vertex function's push
|
||||
/// end may leave below the fragment function's first eight-byte field.
|
||||
FetchedColor { color: u32, texels: SampledType },
|
||||
@@ -1315,7 +1315,7 @@ pub enum PushField {
|
||||
/// returns where both words are all ones (`lower::push::emit_tail_guard`), which the consumer
|
||||
/// never pushes.
|
||||
SlotBounds(SlotRef),
|
||||
/// On `Device::from_queries`' profile (`PushWindow::Floor`), the zero word (`u32`) a stage
|
||||
/// On `Device::from_queries`' profile, the zero word (`u32`) a stage
|
||||
/// whose pushed fields include no tail kind (`lower::push::tail_kind`) pushes as its tail,
|
||||
/// `lower::push::HOLE_BYTES` above them, and returns where it is non-zero: the consumer pushes
|
||||
/// it zero with the stage's other fields, so the branch is never taken. No placement lists it
|
||||
|
||||
@@ -104,7 +104,8 @@ pub fn description_at_1_2(stem: &str, flags2: bool) -> Result<DeviceDescription,
|
||||
|
||||
/// Committed profile `stem` (`validation/profiles/<stem>.json`) derived under `policy`.
|
||||
pub fn profile(stem: &str, policy: DevicePolicy) -> Result<DeviceProfile, String> {
|
||||
let dev = Device::new(description(stem)?, policy).map_err(|e| format!("{stem}: {e}"))?;
|
||||
let dev =
|
||||
Device::from_queries(description(stem)?, policy).map_err(|e| format!("{stem}: {e}"))?;
|
||||
Ok(dev.profile().clone())
|
||||
}
|
||||
|
||||
@@ -117,7 +118,7 @@ pub fn profile_with_storage_buffers(
|
||||
) -> Result<DeviceProfile, String> {
|
||||
let mut desc = description(stem)?;
|
||||
desc.limits.max_per_stage_descriptor_storage_buffers = storage;
|
||||
let dev = Device::new(desc, policy).map_err(|e| format!("{stem}: {e}"))?;
|
||||
let dev = Device::from_queries(desc, policy).map_err(|e| format!("{stem}: {e}"))?;
|
||||
Ok(dev.profile().clone())
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ pub fn formatless_floor(policy: DevicePolicy) -> Result<DeviceProfile, String> {
|
||||
VkFeature::ShaderStorageImageReadWithoutFormat,
|
||||
VkFeature::ShaderStorageImageWriteWithoutFormat,
|
||||
]);
|
||||
let dev = Device::new(desc, policy).map_err(|e| format!("{FORMATLESS_FLOOR}: {e}"))?;
|
||||
let dev = Device::from_queries(desc, policy).map_err(|e| format!("{FORMATLESS_FLOOR}: {e}"))?;
|
||||
Ok(dev.profile().clone())
|
||||
}
|
||||
|
||||
@@ -160,12 +161,6 @@ pub fn device_nan_bits(a: &FunctionArtifact) -> bool {
|
||||
.contains(&crate::device::requirements::VkProperty::MetalNanMoves)
|
||||
}
|
||||
|
||||
/// The default policy with Metal's answers wherever a choice still offers them
|
||||
/// ([`DevicePolicy::exact_answers`]).
|
||||
pub fn exact_maths() -> DevicePolicy {
|
||||
DevicePolicy::default().exact_answers()
|
||||
}
|
||||
|
||||
/// A fresh per-attempt meter with the standard caps and no deadline.
|
||||
pub fn meter() -> Meter {
|
||||
Meter::new(&Budget::default())
|
||||
|
||||
@@ -273,7 +273,7 @@ fn a_rasterizing_void_vertex_function_is_refused_at_its_link() {
|
||||
.join("../metal2vulkan-validation/profiles/lavapipe.json");
|
||||
let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let description = DeviceDescription::from_khronos_json(&text, None).expect("profile");
|
||||
let device = Device::new(description, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(description, DevicePolicy::default()).expect("device");
|
||||
let refused = Err(Error::InvalidDescriptor(
|
||||
DescriptorError::RasterizedVoidVertex,
|
||||
));
|
||||
@@ -656,7 +656,7 @@ fn a_dropped_unwritten_fragment_input_is_absent_from_the_compiled_fragment() {
|
||||
let description = DeviceDescription::from_khronos_json(&text, None).expect(stem);
|
||||
(
|
||||
stem,
|
||||
Device::new(description, DevicePolicy::default()).expect(stem),
|
||||
Device::from_queries(description, DevicePolicy::default()).expect(stem),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
@@ -725,7 +725,7 @@ fn tessellated_and_mesh_pipelines_answer_an_unwritten_fragment_input_as_a_vertex
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let description = DeviceDescription::from_khronos_json(&text, None).expect(stem);
|
||||
let device = Device::new(description, DevicePolicy::default()).expect(stem);
|
||||
let device = Device::from_queries(description, DevicePolicy::default()).expect(stem);
|
||||
let budget = Budget::standard();
|
||||
for attached in [true, false] {
|
||||
let named = attached.then(|| (vec!["color".to_string()], None));
|
||||
@@ -795,7 +795,7 @@ fn one_creation_specializes_each_stage_once() {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let description = DeviceDescription::from_khronos_json(&text, None).expect(stem);
|
||||
let device = Device::new(description, DevicePolicy::default()).expect(stem);
|
||||
let device = Device::from_queries(description, DevicePolicy::default()).expect(stem);
|
||||
let budget = Budget::standard();
|
||||
let mut descriptor = RenderPipelineDescriptor::new(source(&library, "varying_vertex"));
|
||||
descriptor.fragment = Some(source(&library, "depth_writing_fragment"));
|
||||
|
||||
@@ -1020,7 +1020,7 @@ fn case_lines(case: &Case, budget: &Budget) -> Result<Vec<String>, Error> {
|
||||
|
||||
/// The compile layer's device of the lavapipe profile.
|
||||
fn lavapipe() -> crate::device::Device {
|
||||
crate::device::Device::new(
|
||||
crate::device::Device::from_queries(
|
||||
crate::device::DeviceDescription::from_khronos_json(
|
||||
&std::fs::read_to_string(
|
||||
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
|
||||
@@ -231,8 +231,7 @@ pub fn committed_profiles() -> Result<Vec<(String, DeviceProfile)>, String> {
|
||||
committed_profiles_under(DevicePolicy::default())
|
||||
}
|
||||
|
||||
/// [`committed_profiles`] under `policy` (the tests of Metal's NaN and `half` rounding take
|
||||
/// [`crate::pipeline::testing::exact_maths`]).
|
||||
/// [`committed_profiles`] under `policy`.
|
||||
pub fn committed_profiles_with(
|
||||
policy: DevicePolicy,
|
||||
) -> Result<Vec<(String, DeviceProfile)>, String> {
|
||||
@@ -251,7 +250,7 @@ fn committed_profiles_under(policy: DevicePolicy) -> Result<Vec<(String, DeviceP
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for (stem, desc) in committed_descriptions()? {
|
||||
let dev = Device::new(desc.clone(), policy).map_err(|e| format!("{stem}: {e}"))?;
|
||||
let dev = Device::from_queries(desc.clone(), policy).map_err(|e| format!("{stem}: {e}"))?;
|
||||
out.push((stem.clone(), dev.profile().clone()));
|
||||
}
|
||||
lock().push((policy, out.clone()));
|
||||
|
||||
@@ -271,7 +271,7 @@ fn written(bc: &[u8]) -> (u64, u64, u64) {
|
||||
.join("../metal2vulkan-validation/profiles/lavapipe.json");
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let device = Device::new(desc, DevicePolicy::default()).expect("device");
|
||||
let device = Device::from_queries(desc, DevicePolicy::default()).expect("device");
|
||||
let f = Library::from_air(bc)
|
||||
.expect("library")
|
||||
.function("blob")
|
||||
|
||||
@@ -23,7 +23,7 @@ fn device() -> Device {
|
||||
.join("../metal2vulkan-validation/profiles/moltenvk-m3.json");
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// A library of the extern functions `tint` and `shift`, over one module.
|
||||
|
||||
@@ -86,7 +86,7 @@ fn profile_with(stem: &str, robust: bool, standard_layout: bool) -> DeviceProfil
|
||||
desc.features
|
||||
.remove(&VkFeature::UniformBufferStandardLayout);
|
||||
}
|
||||
Device::new(desc, policy())
|
||||
Device::from_queries(desc, policy())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
@@ -349,28 +349,6 @@ fn a_uniform_view_read_at_its_bind_offset_drops_the_residual() {
|
||||
/// Xe RPL-P under ANV, where the row was measured.
|
||||
const AT_BIND_PROFILE: &str = "intel-irisxe-rplp-anv";
|
||||
|
||||
/// A committed profile, its description measuring `DriverWorkaround::ExternalUniformReadsSkipACache`
|
||||
/// where `measured` (the fact comes from that set alone), with `uniformBufferStandardLayout` or
|
||||
/// without.
|
||||
fn texel_profile(stem: &str, measured: bool, standard_layout: bool) -> DeviceProfile {
|
||||
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles")
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
if !standard_layout {
|
||||
desc.features
|
||||
.remove(&VkFeature::UniformBufferStandardLayout);
|
||||
}
|
||||
if measured {
|
||||
(desc.measured).insert(DriverWorkaround::ExternalUniformReadsSkipACache);
|
||||
}
|
||||
Device::new(desc, policy())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// A kernel reading byte `i` of a `constant` window of 6 bytes, `i` the first word of its
|
||||
/// `device` buffer 2 (an indexed read: no constant offset), into word 0 of buffer 1.
|
||||
const INDEXED_BYTE: &str = r#"define void @indexed_byte_load(ptr addrspace(2) noundef "air-buffer-no-alias" %0, ptr addrspace(1) noundef "air-buffer-no-alias" %1, ptr addrspace(1) noundef "air-buffer-no-alias" %2) {
|
||||
@@ -409,120 +387,6 @@ fn texel_buffer(index: u32, bytes: &[u8]) -> Image {
|
||||
image
|
||||
}
|
||||
|
||||
/// On a profile whose description measured `DriverWorkaround::ExternalUniformReadsSkipACache`, a
|
||||
/// `constant` slot of a short window with an indexed read reads through a uniform texel buffer:
|
||||
/// its form is `DescriptorView::UniformTexel`, the slot's one variable is a `UniformConstant`
|
||||
/// sampled image of `Dim` `Buffer` (no `Uniform` block), the module passes L3, and the read takes
|
||||
/// the last byte at the residual pushed, at residuals 0, 4, 16 and 256, with
|
||||
/// `uniformBufferStandardLayout` and without. A slot read at a constant offset alone
|
||||
/// (`buffer_end_byte_load_constant`) keeps its uniform buffer there, and the same profile with
|
||||
/// nothing measured (the Iris Xe's own identity included) keeps the uniform buffer for both.
|
||||
#[test]
|
||||
fn a_short_constant_window_reads_through_a_uniform_texel_buffer() {
|
||||
use crate::spirv::interp::run_with_images;
|
||||
use crate::spirv::ir::{Dim, ImageType, ImageUsage};
|
||||
let entry = "indexed_byte_load";
|
||||
let Some(bc) = assemble_text(entry, INDEXED_BYTE) else {
|
||||
return;
|
||||
};
|
||||
let Some(constant) = assemble_file("buffer_end_byte_load_constant") else {
|
||||
return;
|
||||
};
|
||||
let data = [9u8, 8, 7, 6, 5, 0xC3];
|
||||
let form_of = |bc: &[u8], entry: &str, p: &DeviceProfile, what: &str| {
|
||||
let a = compile(bc, entry, p).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
link_and_validate(&a, p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
match a.interface.slots.get(&sref(0)) {
|
||||
Some(SlotInterface::Buffer(b)) => b.form,
|
||||
other => panic!("{what}: {other:?}"),
|
||||
}
|
||||
};
|
||||
for standard in [true, false] {
|
||||
let what = format!("standard={standard}");
|
||||
let p = texel_profile("intel-irisxe-rplp-anv", true, standard);
|
||||
assert!(
|
||||
p.workarounds()
|
||||
.contains(&DriverWorkaround::ExternalUniformReadsSkipACache),
|
||||
"{what}"
|
||||
);
|
||||
assert_eq!(
|
||||
form_of(&bc, entry, &p, &what),
|
||||
BufferForm::Descriptor(DescriptorView::UniformTexel),
|
||||
"{what}"
|
||||
);
|
||||
let plain = match standard {
|
||||
true => DescriptorView::UniformWords,
|
||||
false => DescriptorView::UniformVec4,
|
||||
};
|
||||
let constant_entry = "buffer_end_byte_load_constant";
|
||||
assert_eq!(
|
||||
form_of(&constant, constant_entry, &p, &what),
|
||||
BufferForm::Descriptor(plain),
|
||||
"{what}: a constant offset alone"
|
||||
);
|
||||
let (plan, m) = typed_module(&bc, entry, &p).expect("module");
|
||||
let slot: Vec<_> = (m.globals().iter())
|
||||
.filter(|g| g.kind == GlobalKind::Resource(kslot(0)))
|
||||
.collect();
|
||||
assert_eq!(slot.len(), 1, "{what}: the slot's variables");
|
||||
assert_eq!(slot[0].class, StorageClass::UniformConstant, "{what}");
|
||||
assert!(
|
||||
matches!(
|
||||
m.types().get(slot[0].pointee),
|
||||
Ok(Type::Image(ImageType {
|
||||
dim: Dim::Buffer,
|
||||
usage: ImageUsage::Sampled,
|
||||
..
|
||||
}))
|
||||
),
|
||||
"{what}: {:?}",
|
||||
m.types().get(slot[0].pointee)
|
||||
);
|
||||
for r in [0u32, 4, 16, 256] {
|
||||
let mut bytes = bound(0, r, &data, 0x44).bytes;
|
||||
bytes.resize(bytes.len().max(512), 0x44);
|
||||
let res = Resources {
|
||||
buffers: vec![bound(1, 0, &[0; 4], 0), bound(2, 0, &5u32.to_le_bytes(), 0)],
|
||||
push: push_bytes(&plan, &[(0, r)]),
|
||||
spec: Default::default(),
|
||||
};
|
||||
let (out, _) =
|
||||
run_with_images(&m, &Config::default(), res, vec![texel_buffer(0, &bytes)])
|
||||
.unwrap_or_else(|e| panic!("{what} r={r}: {e:?}"));
|
||||
assert_eq!(out.buffers[0][..4], [0xC3, 0, 0, 0], "{what} r={r}");
|
||||
}
|
||||
}
|
||||
let p = texel_profile("intel-irisxe-rplp-anv", false, true);
|
||||
assert_eq!(
|
||||
form_of(&bc, entry, &p, "unmeasured"),
|
||||
BufferForm::Descriptor(DescriptorView::UniformWords)
|
||||
);
|
||||
}
|
||||
|
||||
/// A uniform view takes the texel form for a `Bounded` window of at most
|
||||
/// `views::TEXEL_WINDOW_BYTES` alone, on a profile whose description measured
|
||||
/// `DriverWorkaround::ExternalUniformReadsSkipACache`: 4096 bytes is one, 4097 keeps its uniform
|
||||
/// buffer, as does every window on lavapipe's profile, which measured nothing.
|
||||
#[test]
|
||||
fn only_a_window_within_the_bound_takes_the_texel_form() {
|
||||
use crate::lower::access::texel_view;
|
||||
use crate::memory::views::{ViewKind, TEXEL_WINDOW_BYTES};
|
||||
let iris = texel_profile("intel-irisxe-rplp-anv", true, true);
|
||||
let lavapipe = profile_with("lavapipe", true, true);
|
||||
let window = |len| Window::Bounded { start: 0, len };
|
||||
assert!(matches!(
|
||||
texel_view(&iris, window(TEXEL_WINDOW_BYTES)),
|
||||
Some(ViewKind::UniformTexel { vecs: 257 })
|
||||
));
|
||||
assert!(matches!(
|
||||
texel_view(&iris, window(1)),
|
||||
Some(ViewKind::UniformTexel { vecs: 1 })
|
||||
));
|
||||
assert_eq!(texel_view(&iris, window(TEXEL_WINDOW_BYTES + 1)), None);
|
||||
assert_eq!(texel_view(&iris, Window::Whole), None);
|
||||
assert_eq!(texel_view(&lavapipe, window(16)), None);
|
||||
}
|
||||
|
||||
/// Whether a function of `m` reads push member `field` with the specialization constant of `key`
|
||||
/// at `value`: whether a value the member's word reaches is read by an instruction other than one
|
||||
/// that computes its own result from its operands alone (`spirv::dead::removable`, a result the
|
||||
@@ -1878,7 +1742,7 @@ fn the_highest_storage_slots_fall_back_to_device_addresses() {
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
desc.limits.max_per_stage_descriptor_storage_buffers = 2;
|
||||
let p = Device::new(desc, policy())
|
||||
let p = Device::from_queries(desc, policy())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
@@ -1925,7 +1789,7 @@ fn the_highest_storage_slots_fall_back_to_device_addresses() {
|
||||
let mut written = profile_desc(stem);
|
||||
written.limits.max_per_stage_descriptor_storage_buffers = 0;
|
||||
for desc in [strict, written] {
|
||||
let p = Device::new(desc, policy())
|
||||
let p = Device::from_queries(desc, policy())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
@@ -1977,7 +1841,7 @@ fn a_looping_kernel_reserves_no_status_binding_in_the_fallback() {
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
desc.limits.max_per_stage_descriptor_storage_buffers = 2;
|
||||
let p = Device::new(desc, policy())
|
||||
let p = Device::from_queries(desc, policy())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
@@ -2236,7 +2100,7 @@ fn profile_without(stem: &str, features: &[VkFeature]) -> DeviceProfile {
|
||||
for f in features {
|
||||
desc.features.remove(f);
|
||||
}
|
||||
Device::new(desc, policy())
|
||||
Device::from_queries(desc, policy())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -103,7 +103,7 @@ fn wave64() -> DeviceProfile {
|
||||
let narrowed = text.replace("\"minSubgroupSize\": 32", "\"minSubgroupSize\": 64");
|
||||
assert_ne!(narrowed, text, "the description names minSubgroupSize");
|
||||
let desc = DeviceDescription::from_khronos_json(&narrowed, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -53,7 +53,7 @@ fn a_pipeline_covering_by_alpha_notes_the_device_s_coverage() {
|
||||
"intel-irisxe-anv",
|
||||
"nvidia-rtx5080-laptop",
|
||||
] {
|
||||
let dev = Device::new(
|
||||
let dev = Device::from_queries(
|
||||
description(stem).expect("committed description"),
|
||||
DevicePolicy::default(),
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ fn description(stem: &str) -> DeviceDescription {
|
||||
}
|
||||
|
||||
fn device(stem: &str) -> Device {
|
||||
Device::new(description(stem), DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(description(stem), DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// `moltenvk-m3` with `features` removed from its description.
|
||||
@@ -99,7 +99,7 @@ fn moltenvk_without(features: &[F]) -> Device {
|
||||
for f in features {
|
||||
assert!(desc.features.remove(f), "moltenvk-m3 has {f:?}");
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// Link `a` alone, relocate it, and run L3; the specialization constants link declared.
|
||||
@@ -881,7 +881,7 @@ fn a_profile_without_shader_output_layer_draws_or_refuses_every_amplification()
|
||||
let mut lavapipe = description("lavapipe");
|
||||
assert!(lavapipe.features.remove(&F::ShaderOutputLayer));
|
||||
assert!(lavapipe.features.contains(&F::GeometryShader));
|
||||
let lavapipe = Device::new(lavapipe, DevicePolicy::default()).expect("device");
|
||||
let lavapipe = Device::from_queries(lavapipe, DevicePolicy::default()).expect("device");
|
||||
for (stem, dev, geometry) in [
|
||||
(lunarg, device(lunarg), false),
|
||||
("lavapipe without shaderOutputLayer", lavapipe, true),
|
||||
|
||||
@@ -235,7 +235,7 @@ pub(super) fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// The pipeline of kernel `entry` with the four functions linked, through the public API.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//! an integer where it needs one. `llvm-as` assembles the generated module; without it the test
|
||||
//! skips visibly.
|
||||
//!
|
||||
//! Every profile here takes Metal's `half` rounding and NaN (`exact_maths`), whose answers these
|
||||
//! Every profile here takes Metal's `half` rounding and NaN (the default policy), whose answers these
|
||||
//! tests check; the maths functions are the device's on every device but MoltenVK
|
||||
//! (`engine_native_maths`).
|
||||
|
||||
@@ -30,8 +30,7 @@ use crate::pipeline::artifact::PrecisionNote;
|
||||
use crate::pipeline::compile::{plan_bitcode, EntryRef};
|
||||
use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage};
|
||||
use crate::pipeline::testing::{
|
||||
compile, description, exact_maths, link_and_validate, llvm_assemble, meter, profile,
|
||||
AssembleError, Scratch,
|
||||
compile, description, link_and_validate, llvm_assemble, meter, profile, AssembleError, Scratch,
|
||||
};
|
||||
use crate::spirv::interp::{run, Buffer, Config, Resources};
|
||||
|
||||
@@ -1140,7 +1139,7 @@ fn arith_kernels_validate_and_compute_on_every_profile() {
|
||||
let (mut met, mut refused) = (Vec::new(), Vec::new());
|
||||
let mut computed = 0;
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let missing = kk.needs.iter().copied().find(|n| !has(&p, *n));
|
||||
@@ -1272,7 +1271,7 @@ fn wide_divisions_share_one_routine_per_form() {
|
||||
.expect("description");
|
||||
desc.driver_id = Some(crate::vk::DriverId::MOLTENVK);
|
||||
desc.driver_version = 10401;
|
||||
let converted = Device::new(desc, exact_maths())
|
||||
let converted = Device::from_queries(desc, crate::device::DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
@@ -1283,7 +1282,7 @@ fn wide_divisions_share_one_routine_per_form() {
|
||||
let cases = [
|
||||
(
|
||||
"vk12-floor",
|
||||
profile("vk12-floor", exact_maths()).expect("profile"),
|
||||
profile("vk12-floor", crate::device::DevicePolicy::default()).expect("profile"),
|
||||
3,
|
||||
5,
|
||||
0,
|
||||
@@ -1291,7 +1290,7 @@ fn wide_divisions_share_one_routine_per_form() {
|
||||
("vk12-floor under MoltenVK 1.4.1", converted, 3, 5, 0x2),
|
||||
(
|
||||
"amd-rdna3-radv",
|
||||
profile("amd-rdna3-radv", exact_maths()).expect("profile"),
|
||||
profile("amd-rdna3-radv", crate::device::DevicePolicy::default()).expect("profile"),
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
@@ -1359,7 +1358,7 @@ fn fused_multiply_adds_take_the_profiles_route() {
|
||||
("lavapipe", 0, true),
|
||||
("vk12-floor", 0, true),
|
||||
] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -1481,8 +1480,8 @@ fn a_half_fused_multiply_add_is_the_devices_16_bit_fma_on_from_queries() {
|
||||
] {
|
||||
let what = format!("fma_half_rounds_once on {stem} (from_queries)");
|
||||
let desc = description(stem).expect("description");
|
||||
let device =
|
||||
Device::from_queries(desc, exact_maths()).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
let device = Device::from_queries(desc, crate::device::DevicePolicy::default())
|
||||
.unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
let p = device.profile();
|
||||
let controls = half_controls(p);
|
||||
let route = if controls {
|
||||
@@ -1659,7 +1658,8 @@ fn dot_is_the_devices_op_dot_on_every_profile() {
|
||||
"vk12-floor",
|
||||
"lunarg-desktop-baseline-2023",
|
||||
] {
|
||||
for policy in [exact_maths(), DevicePolicy::default()] {
|
||||
{
|
||||
let policy = DevicePolicy::default();
|
||||
let p = profile(stem, policy).expect("profile");
|
||||
let metal = p.fields().float_functions == FloatFunctions::Metal;
|
||||
for kk in &ks {
|
||||
@@ -1723,7 +1723,7 @@ fn fast_fmod_is_metals_composition() {
|
||||
("lavapipe", 0, 1),
|
||||
("vk12-floor", 0, 1),
|
||||
] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let kk = &ks[0];
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -1777,7 +1777,7 @@ fn an_ordered_not_equal_is_the_negated_unordered_equal() {
|
||||
return;
|
||||
};
|
||||
for stem in ["moltenvk-m3", "lavapipe", "vk12-floor"] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let kk = &ks[0];
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -1843,7 +1843,7 @@ fn an_arcp_division_is_the_devices_quotient() {
|
||||
return;
|
||||
};
|
||||
for stem in ["moltenvk-m3", "lavapipe", "vk12-floor"] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -1928,9 +1928,9 @@ fn a_fast_division_leaves_its_nans_to_the_device() {
|
||||
let Some(bitcode) = assemble("fast-divide-specials", &module(&ks)) else {
|
||||
return;
|
||||
};
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &[], &|_, fact, _| !fact);
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &[], &|_| true);
|
||||
for stem in every_profile() {
|
||||
let p = profile(&stem, exact_maths()).expect("profile");
|
||||
let p = profile(&stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let device_nans =
|
||||
p.takes_driver_deviation(crate::error::DriverDeviation::MetalCanonicalNans);
|
||||
for kk in &ks {
|
||||
@@ -2031,7 +2031,7 @@ fn a_division_without_arcp_is_the_devices_quotient() {
|
||||
return;
|
||||
};
|
||||
for stem in ["moltenvk-m3", "lavapipe", "vk12-floor"] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let device_nans =
|
||||
p.takes_driver_deviation(crate::error::DriverDeviation::MetalCanonicalNans);
|
||||
for kk in &ks {
|
||||
@@ -2112,7 +2112,7 @@ fn fast_sincos_is_the_devices_sine_and_cosine() {
|
||||
return;
|
||||
};
|
||||
for stem in ["moltenvk-m3", "lavapipe", "vk12-floor"] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -2178,7 +2178,7 @@ fn device_float_environment_notes_follow_the_operations() {
|
||||
return;
|
||||
};
|
||||
for (stem, column) in [("moltenvk-m3", 0), ("lavapipe", 1)] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for (kk, (m3, lp)) in ks.iter().zip(¬es) {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -2233,7 +2233,7 @@ fn a_float_remainder_is_the_devices_without_every_flag() {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -2286,7 +2286,7 @@ fn unlowered_arithmetic_refuses_as_not_implemented() {
|
||||
let Some(bitcode) = assemble("refusals", &text) else {
|
||||
return;
|
||||
};
|
||||
let p = profile("moltenvk-m3", exact_maths()).expect("profile");
|
||||
let p = profile("moltenvk-m3", crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &cases {
|
||||
match compile(&bitcode, kk.name, &p) {
|
||||
Err(Error::Unsupported(u)) => {
|
||||
@@ -2393,7 +2393,7 @@ fn float_ops_without_contract_and_reassoc_are_no_contraction() {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -2492,7 +2492,7 @@ fn arithmetic_the_air_lets_a_compiler_rewrite_notes_fast_math_rewrites() {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for (i, kk) in ks.iter().enumerate() {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -2556,7 +2556,9 @@ fn narrow_float_module_growth_is_bounded() {
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{} on {stem}: L3: {e}", kk.name));
|
||||
a.module.words.len()
|
||||
};
|
||||
let words = ks.each_ref().map(|kk| words_on(exact_maths(), kk));
|
||||
let words = ks
|
||||
.each_ref()
|
||||
.map(|kk| words_on(crate::device::DevicePolicy::default(), kk));
|
||||
eprintln!(
|
||||
"half and bfloat growth on {stem}: float {} words, half {} ({:+}), bfloat {} ({:+})",
|
||||
words[0],
|
||||
@@ -2628,7 +2630,7 @@ fn half_rounding_follows_the_operation() {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -2764,7 +2766,7 @@ fn a_measured_half_sum_requires_the_arithmetic_fact_alone() {
|
||||
};
|
||||
let mut converting = 0;
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let converted = crate::lower::arith::narrow::quantize_form(&p)
|
||||
== crate::spirv::builder::QuantizeForm::Converted;
|
||||
let ha = p.takes_driver_deviation(crate::error::DriverDeviation::MetalHalfArithmetic)
|
||||
@@ -2853,7 +2855,7 @@ fn a_half_rounding_without_float16_is_the_quantize_alone() {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for (kk, &(_, _, quantizes)) in ks.iter().zip(&cases) {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -3034,7 +3036,7 @@ fn float_ops_without_fast_flags_preserve_signed_zero_inf_nan() {
|
||||
};
|
||||
let (mut declared, mut noted) = (0, 0);
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let supported = p.fields().float_controls.f32.signed_zero_inf_nan_preserve;
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
@@ -3147,7 +3149,7 @@ fn a_convert_tells_a_nan_by_its_bits_where_the_entry_may_assume_none() {
|
||||
};
|
||||
let mut bits = 0;
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -3167,29 +3169,10 @@ fn a_convert_tells_a_nan_by_its_bits_where_the_entry_may_assume_none() {
|
||||
assert!(bits >= PROFILES.len(), "{bits} by bits");
|
||||
}
|
||||
|
||||
/// The profile of committed profile `stem` with its driver's `MetalFloatFunctions` deviation
|
||||
/// taken or not as `metal` says, and nothing else changed.
|
||||
fn with_float_functions(stem: &str, metal: bool) -> DeviceProfile {
|
||||
use crate::device::{Device, DeviceDescription};
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles")
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let deviation = crate::error::DriverDeviation::MetalFloatFunctions;
|
||||
Device::with_deviation(desc, exact_maths(), deviation, metal)
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// An `arcp` division is the device's `OpFDiv(x, y)` itself on every profile, which MoltenVK hands
|
||||
/// Metal's compiler as the AIR's own fast `x / y` (Metal's compiler does not treat `x * (1.0 / y)`
|
||||
/// the same way: case 24c263bb's `(a * 255) / a` was 255 on Metal and 254 as `x` times the
|
||||
/// device's `OpFDiv(1, y)`). Where the device's `float` division is Metal's (its driver's
|
||||
/// deviation `MetalFloatFunctions`) and Metal compiles the entry with fast math (it declares no
|
||||
/// `SignedZeroInfNanPreserve`), the quotient is Metal's own and records no note; elsewhere it
|
||||
/// records `DeviceArithmetic`. The interpreter's `OpFDiv` is correctly rounded: `RN(1e10 / 3)` is
|
||||
/// device's `OpFDiv(1, y)`). The quotient records `DeviceArithmetic`. The interpreter's `OpFDiv` is correctly rounded: `RN(1e10 / 3)` is
|
||||
/// `0x4f46aea1`.
|
||||
#[test]
|
||||
fn a_fast_division_is_the_device_s_quotient() {
|
||||
@@ -3226,10 +3209,10 @@ fn a_fast_division_is_the_device_s_quotient() {
|
||||
let Some(bitcode) = assemble("fast-quotient", &module(&ks)) else {
|
||||
return;
|
||||
};
|
||||
let p = profile("moltenvk-m3", crate::device::DevicePolicy::default()).expect("profile");
|
||||
for (kk, fast_math) in ks.iter().zip(fast_math) {
|
||||
for metal in [true, false] {
|
||||
let p = with_float_functions("moltenvk-m3", metal);
|
||||
let what = format!("{} with the fact {metal}", kk.name);
|
||||
{
|
||||
let what = kk.name.to_string();
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
let (_, words) =
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
@@ -3238,11 +3221,8 @@ fn a_fast_division_is_the_device_s_quotient() {
|
||||
!fast_math,
|
||||
"{what}: SignedZeroInfNanPreserve"
|
||||
);
|
||||
// Metal's own quotient in a fast entry records no note; the device's elsewhere does.
|
||||
let device = metal && fast_math;
|
||||
assert_eq!(
|
||||
assert!(
|
||||
a.precision.contains(&PrecisionNote::DeviceArithmetic),
|
||||
!device,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
@@ -3268,33 +3248,6 @@ fn ob(name: &str, b: u32) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
/// Committed profile `stem` with its driver's `MetalCanonicalNans` deviation taken or not as
|
||||
/// `fact` says.
|
||||
fn profile_with_canonical_nans(stem: &str, fact: bool) -> DeviceProfile {
|
||||
profile_with_fact(
|
||||
stem,
|
||||
crate::error::DriverDeviation::MetalCanonicalNans,
|
||||
fact,
|
||||
)
|
||||
}
|
||||
|
||||
/// Committed profile `stem` with its driver's deviation `deviation` taken or not as `fact` says.
|
||||
fn profile_with_fact(
|
||||
stem: &str,
|
||||
deviation: crate::error::DriverDeviation,
|
||||
fact: bool,
|
||||
) -> DeviceProfile {
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles")
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::with_deviation(desc, exact_maths(), deviation, fact)
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// The bits tests' `OpUGreaterThan` in the entry point's own function of module `words` (one
|
||||
/// entry point): a module-scope routine tests by the bits in entries of every float mode, and
|
||||
/// compares integers so (a precise division's).
|
||||
@@ -3354,33 +3307,27 @@ fn stores_nan(bits: u32, half: bool) -> bool {
|
||||
}
|
||||
|
||||
/// Kernels `ks` of `bitcode` (each storing a NaN's bits, `half` ones zero-extended where `half`)
|
||||
/// on `lavapipe` and `moltenvk-m3`, each with its driver's deviation `MetalCanonicalNans` taken
|
||||
/// and not: the module selects no NaN, so it is the same word for word on both sides of the fact;
|
||||
/// it records `PrecisionNote::NativeNanEncoding` exactly where `noted(kernel, fact, moves)` or it
|
||||
/// reads a `half` from its bits by the device's widening or encodes one by its narrowing
|
||||
/// (`narrow::widens_bits`, `narrow::encodes_bits`: both profiles have `shaderFloat16`) on a profile
|
||||
/// whose moves of a NaN are not measured (`moves`, `DriverDeviation::MetalNanMoves`: the M3 Max's
|
||||
/// identity on MoltenVK), and never `DeviceNanEncoding`; it requires `VkProperty::MetalNanMoves`
|
||||
/// exactly where `moves` and it reads or encodes a `half` so, or `noted` drops the note for the
|
||||
/// moves; and the interpreter's answer is the kernel's `want`, or a NaN, its bits the device's,
|
||||
/// where it has none, but for the kernels `unread` names, whose device instruction the interpreter
|
||||
/// does not evaluate.
|
||||
/// on `lavapipe` and `moltenvk-m3`: the module selects no NaN; it records
|
||||
/// `PrecisionNote::NativeNanEncoding` exactly where `noted(kernel)` or it reads a `half` from its
|
||||
/// bits by the device's widening or encodes one by its narrowing (`narrow::widens_bits`,
|
||||
/// `narrow::encodes_bits`: both profiles have `shaderFloat16`), and never `DeviceNanEncoding`; and
|
||||
/// the interpreter's answer is the kernel's `want`, or a NaN, its bits the device's, where it has
|
||||
/// none, but for the kernels `unread` names, whose device instruction the interpreter does not
|
||||
/// evaluate.
|
||||
fn nans_are_the_device_s(
|
||||
bitcode: &[u8],
|
||||
ks: &[Kernel],
|
||||
half: bool,
|
||||
unread: &[&str],
|
||||
noted: &dyn Fn(&str, bool, bool) -> bool,
|
||||
noted: &dyn Fn(&str) -> bool,
|
||||
) {
|
||||
for stem in ["lavapipe", "moltenvk-m3"] {
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in ks {
|
||||
let mut emitted = Vec::new();
|
||||
for fact in [false, true] {
|
||||
let p = profile_with_canonical_nans(stem, fact);
|
||||
let what = format!("{} on {stem}, MetalCanonicalNans {fact}", kk.name);
|
||||
{
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
let (_, words) =
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
let (_, m) = crate::pipeline::testing::typed_module(bitcode, kk.name, &p)
|
||||
.unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
let widens = crate::lower::arith::narrow::widens_bits(&m, &mut meter())
|
||||
@@ -3388,21 +3335,12 @@ fn nans_are_the_device_s(
|
||||
Ok(w || crate::lower::arith::narrow::encodes_bits(&m, &mut meter())?)
|
||||
})
|
||||
.unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
let moves = p.takes_driver_deviation(crate::error::DriverDeviation::MetalNanMoves);
|
||||
assert_eq!(
|
||||
a.precision.contains(&PrecisionNote::NativeNanEncoding),
|
||||
noted(kk.name, fact, moves) || (widens && !moves),
|
||||
noted(kk.name) || widens,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
let moved = noted(kk.name, fact, false) && !noted(kk.name, fact, true);
|
||||
assert_eq!(
|
||||
a.requirements
|
||||
.properties
|
||||
.contains(&crate::device::requirements::VkProperty::MetalNanMoves),
|
||||
moves && (widens || moved),
|
||||
"{what}"
|
||||
);
|
||||
assert!(
|
||||
!a.precision.contains(&PrecisionNote::DeviceNanEncoding),
|
||||
"{what}: {:?}",
|
||||
@@ -3415,13 +3353,7 @@ fn nans_are_the_device_s(
|
||||
None => assert!(stores_nan(got, half), "{what}: {got:#x}"),
|
||||
}
|
||||
}
|
||||
emitted.push(words);
|
||||
}
|
||||
assert!(
|
||||
emitted[0] == emitted[1],
|
||||
"{} on {stem}: the module changes with the fact",
|
||||
kk.name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3451,37 +3383,19 @@ fn a_float_nan_is_the_device_s_on_every_profile() {
|
||||
let Some(bitcode) = assemble("nan-fact", &module(&ks)) else {
|
||||
return;
|
||||
};
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &[], &|name, fact, _| {
|
||||
name == "nan_round" || !fact
|
||||
});
|
||||
// The committed profiles state the fact for the measured device only.
|
||||
for (stem, fact) in [("moltenvk-m3", true), ("lavapipe", false)] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
assert_eq!(
|
||||
p.fingerprint(),
|
||||
profile_with_canonical_nans(stem, fact).fingerprint(),
|
||||
"{stem}"
|
||||
);
|
||||
}
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &[], &|_| true);
|
||||
}
|
||||
|
||||
// ---- Metal's float denormals ----
|
||||
|
||||
/// Metal reads an `f32` denormal operand of `+ - *`, a comparison, `sqrt`, `floor`, `ceil` and
|
||||
/// `ldexp` as the zero of its sign and flushes a denormal result. The module leaves the reading to
|
||||
/// the device: where the profile takes its driver's measured deviation `MetalFloatDenormals` it
|
||||
/// requires the fact for `+ - *`, the comparison, `sqrt` and `ldexp` (whose denormal operand and
|
||||
/// result are the device's products, `math::ldexp_bits`), which then read them as Metal does;
|
||||
/// elsewhere they are the device's, noted `DeviceDenormals` (`sqrt`, the device's maths function,
|
||||
/// off Metal's own functions notes them beside its precision on either). `floor` and `ceil` are
|
||||
/// the device's whatever the fact: noted, but on a profile that takes the unary deviation
|
||||
/// `MetalUnaryDenormals` (moltenvk-m3), which requires its property instead and reads them as the
|
||||
/// zero of their sign as Metal does. Flipping the fact changes the requirement and the note, never
|
||||
/// the module. The interpreter keeps denormals as
|
||||
/// the device: each is the device's, noted `DeviceDenormals` (`ldexp`'s denormal operand and
|
||||
/// result are the device's products, `math::ldexp_bits`). The interpreter keeps denormals as
|
||||
/// lavapipe does. The operands are bits (volatile private words), so each kernel's float
|
||||
/// operation is its only one.
|
||||
#[test]
|
||||
fn float_denormals_are_the_devices_and_noted_off_the_device_fact() {
|
||||
fn float_denormals_are_the_devices_and_noted() {
|
||||
// The kernel's float `%r` from `body`, Metal's word, and the word of a device that keeps
|
||||
// denormals (the interpreter, where the module leaves them to the device).
|
||||
let float = |name: &'static str, body: String, metal: u32| Kernel {
|
||||
@@ -3604,74 +3518,21 @@ fn float_denormals_are_the_devices_and_noted_off_the_device_fact() {
|
||||
let Some(bitcode) = assemble("denormal-fact", &text) else {
|
||||
return;
|
||||
};
|
||||
let deviation = crate::error::DriverDeviation::MetalFloatDenormals;
|
||||
for stem in ["moltenvk-m3", "lavapipe"] {
|
||||
let mut emitted: Vec<Vec<Vec<u32>>> = Vec::new();
|
||||
for fact in [true, false] {
|
||||
let p = profile_with_fact(stem, deviation, fact);
|
||||
let mut per = Vec::new();
|
||||
for (kk, device) in ks.iter().zip(&devices) {
|
||||
let what = format!("{} on {stem}, MetalFloatDenormals {fact}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
let (_, words) =
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
let never = matches!(kk.name, "den_floor" | "den_ceil");
|
||||
// Floor and ceiling follow the unary deviation alone.
|
||||
let unary =
|
||||
p.takes_driver_deviation(crate::error::DriverDeviation::MetalUnaryDenormals);
|
||||
// The device's `Sqrt`, a maths function off Metal's own functions, records its
|
||||
// denormals with its precision.
|
||||
let function = kk.name == "den_sqrt"
|
||||
&& p.fields().float_functions != crate::device::profile::FloatFunctions::Metal;
|
||||
assert_eq!(
|
||||
a.requirements
|
||||
.properties
|
||||
.contains(&crate::device::requirements::VkProperty::MetalFloatDenormals),
|
||||
fact && !never,
|
||||
"{what}"
|
||||
);
|
||||
if never {
|
||||
assert_eq!(
|
||||
a.requirements.properties.contains(
|
||||
&crate::device::requirements::VkProperty::MetalUnaryDenormals
|
||||
),
|
||||
unary,
|
||||
"{what}"
|
||||
);
|
||||
}
|
||||
let noted = match never {
|
||||
true => !unary,
|
||||
false => function || !fact,
|
||||
};
|
||||
assert_eq!(
|
||||
a.precision.contains(&PrecisionNote::DeviceDenormals),
|
||||
noted,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
let got = interpret(&bitcode, kk.name, &p);
|
||||
assert_eq!(got, *device, "{what}: {got:#x} != {device:#x}");
|
||||
per.push(words);
|
||||
}
|
||||
emitted.push(per);
|
||||
}
|
||||
for (i, kk) in ks.iter().enumerate() {
|
||||
assert_eq!(
|
||||
emitted[0][i], emitted[1][i],
|
||||
"{} on {stem}: the module with and without the fact",
|
||||
kk.name
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for (kk, device) in ks.iter().zip(&devices) {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
assert!(
|
||||
a.precision.contains(&PrecisionNote::DeviceDenormals),
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
let got = interpret(&bitcode, kk.name, &p);
|
||||
assert_eq!(got, *device, "{what}: {got:#x} != {device:#x}");
|
||||
}
|
||||
}
|
||||
// The committed profiles state the fact for the measured device only.
|
||||
for (stem, fact) in [("moltenvk-m3", true), ("lavapipe", false)] {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
assert_eq!(
|
||||
p.fingerprint(),
|
||||
profile_with_fact(stem, deviation, fact).fingerprint(),
|
||||
"{stem}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// `air.sincos` answers the NaN its `sin` and `cos` answer as calls of their own, since Metal's
|
||||
@@ -3702,7 +3563,7 @@ fn sincos_answers_the_device_s_nan() {
|
||||
return;
|
||||
};
|
||||
let unread = ["sincos_nan_sine", "sincos_nan_cosine"];
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &unread, &|_, fact, _| !fact);
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &unread, &|_| true);
|
||||
}
|
||||
|
||||
/// A NaN test (Metal's saturating conversion's) is `OpIsNan` only in an entry that declares
|
||||
@@ -3769,7 +3630,7 @@ fn a_nan_test_no_float_mode_folds() {
|
||||
};
|
||||
let (mut bits_tested, mut is_nan_tested) = (0, 0);
|
||||
for stem in PROFILES.into_iter().chain(["lavapipe"]) {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -3820,7 +3681,7 @@ fn a_nan_test_no_float_mode_folds() {
|
||||
Err(AssembleError::Rejected(e)) => panic!("llvm-as rejected {entry}: {e}"),
|
||||
};
|
||||
for stem in PROFILES.into_iter().chain(["lavapipe"]) {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let what = format!("{entry} on {stem}");
|
||||
let a = compile(&bitcode, entry, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
let (_, words) =
|
||||
@@ -3910,7 +3771,7 @@ fn half_nans_answer_the_device_s_nan() {
|
||||
let Some(bitcode) = assemble("nan-half", &text) else {
|
||||
return;
|
||||
};
|
||||
nans_are_the_device_s(&bitcode, &ks, true, &[], &|_, fact, _| !fact);
|
||||
nans_are_the_device_s(&bitcode, &ks, true, &[], &|_| true);
|
||||
}
|
||||
|
||||
/// Class C: Metal widens a `half` NaN to the canonical `float` NaN `0x7FC00000`, sign and payload
|
||||
@@ -3951,7 +3812,7 @@ fn a_widened_half_nan_keeps_its_payload_on_every_profile() {
|
||||
let Some(bitcode) = assemble("nan-widen", &text) else {
|
||||
return;
|
||||
};
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &[], &|_, _, moves| !moves);
|
||||
nans_are_the_device_s(&bitcode, &ks, false, &[], &|_| true);
|
||||
}
|
||||
|
||||
/// Class D: Metal's `half` `fneg` and `fabs` answer the canonical `half` NaN `0x7E00`, with or
|
||||
@@ -3997,9 +3858,7 @@ fn half_sign_operations_keep_a_nan_s_payload_on_every_profile() {
|
||||
let Some(bitcode) = assemble("nan-half-sign", &text) else {
|
||||
return;
|
||||
};
|
||||
nans_are_the_device_s(&bitcode, &ks, true, &[], &|name, _, moves| {
|
||||
name != "half_kept" && !(moves && name.starts_with("half_fabs"))
|
||||
});
|
||||
nans_are_the_device_s(&bitcode, &ks, true, &[], &|name| name != "half_kept");
|
||||
}
|
||||
|
||||
/// A `half` read from its bits by the device's widening and moved through the registers to a
|
||||
@@ -4303,101 +4162,6 @@ fn pack_conversions_are_metals_where_measured() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A `half` rounded from a `float` the function holds, by an AIR `fptrunc` of a sum, a product, a
|
||||
/// quotient or a fused multiply-add, records no `NativeHalfConversion` on a profile that takes
|
||||
/// `DriverDeviation::MetalHalfConversion` (`moltenvk-m3`), and the module requires
|
||||
/// `VkProperty::MetalHalfConversion`; without the deviation (the same profile with it dropped) each
|
||||
/// records the note and requires nothing. A `half` function the lowering computes in `float` and
|
||||
/// rounds through the conversion keeps the note there, as on every profile: Metal computes it
|
||||
/// otherwise.
|
||||
#[test]
|
||||
fn half_conversions_are_metals_where_measured() {
|
||||
use crate::device::requirements::VkProperty;
|
||||
use crate::error::DriverDeviation;
|
||||
let halves = |x: &str| {
|
||||
format!(
|
||||
" %h = fptrunc float {x} to half\n %hb = bitcast half %h to i16\n %r = zext i16 %hb to i32\n"
|
||||
)
|
||||
};
|
||||
let two = format!("{}{}", of("a", 0.3), of("b", 1.7));
|
||||
// (name, body, whether the rounding converts a `float` the function holds alone).
|
||||
let cases = [
|
||||
("conv_sum", format!("{two} %s = fadd float %a, %b\n{}", halves("%s")), true),
|
||||
("conv_product", format!("{two} %s = fmul float %a, %b\n{}", halves("%s")), true),
|
||||
("conv_quotient", format!("{two} %s = fdiv float %a, %b\n{}", halves("%s")), true),
|
||||
(
|
||||
"conv_fma",
|
||||
format!(
|
||||
"{two} %s = call float @air.fma.f32(float %a, float %b, float %a)\n{}",
|
||||
halves("%s")
|
||||
),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"half_tanh",
|
||||
format!(
|
||||
"{} %g = fptrunc float %a to half\n %t = call half @air.tanh.f16(half %g)\n %tb = bitcast half %t to i16\n %r = zext i16 %tb to i32\n",
|
||||
of("a", 0.3)
|
||||
),
|
||||
false,
|
||||
),
|
||||
];
|
||||
let ks: Vec<Kernel> = cases
|
||||
.iter()
|
||||
.map(|(name, body, _)| Kernel {
|
||||
want: None,
|
||||
..k(name, body.clone(), 0)
|
||||
})
|
||||
.collect();
|
||||
let text = module(&ks).replace(
|
||||
DECLS,
|
||||
&format!(
|
||||
"{DECLS}declare float @air.fma.f32(float, float, float)\ndeclare half @air.tanh.f16(half)\n"
|
||||
),
|
||||
);
|
||||
let Some(bitcode) = assemble("half-conversions", &text) else {
|
||||
return;
|
||||
};
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles/moltenvk-m3.json");
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
for taken in [true, false] {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let p = Device::with_deviation(
|
||||
desc,
|
||||
DevicePolicy::default(),
|
||||
DriverDeviation::MetalHalfConversion,
|
||||
taken,
|
||||
)
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
assert_eq!(
|
||||
p.takes_driver_deviation(DriverDeviation::MetalHalfConversion),
|
||||
taken
|
||||
);
|
||||
for ((name, _, measured), kk) in cases.iter().zip(&ks) {
|
||||
let what = format!("{name}, the deviation taken: {taken}");
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
let exempt = taken && *measured;
|
||||
assert_eq!(
|
||||
a.precision.contains(&PrecisionNote::NativeHalfConversion),
|
||||
!exempt,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
assert_eq!(
|
||||
a.requirements
|
||||
.properties
|
||||
.contains(&VkProperty::MetalHalfConversion),
|
||||
exempt,
|
||||
"{what}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Class E: Metal's `float` `fneg` and `fabs` (`air.fabs`, `air.fast_fabs`, and `llvm.fabs`, which
|
||||
/// takes `air.fabs`'s answer) flip or clear the sign bit alone, with and without fast-math flags: a
|
||||
/// NaN keeps its payload, signaling or not, and a denormal stays. The lowering is the device's
|
||||
@@ -4480,7 +4244,7 @@ fn float_sign_operations_are_the_devices_on_every_profile() {
|
||||
})
|
||||
};
|
||||
for stem in PROFILES.iter().copied().chain(["lavapipe"]) {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -4683,7 +4447,7 @@ fn float_min_max_are_the_device_s_on_every_profile() {
|
||||
})
|
||||
};
|
||||
for stem in PROFILES.iter().copied().chain(["lavapipe"]) {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -4785,7 +4549,7 @@ fn half_fmod_is_its_float_remainder_on_every_profile() {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES.iter().copied().chain(["lavapipe"]) {
|
||||
let p = profile(stem, exact_maths()).expect("profile");
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
let a = compile(&bitcode, kk.name, &p).unwrap_or_else(|e| panic!("{what}: {e:?}"));
|
||||
@@ -4881,7 +4645,7 @@ fn mix_is_the_devices_fmix_on_every_profile() {
|
||||
.copied()
|
||||
.chain(["lavapipe", "amd-rdna3-radv"])
|
||||
{
|
||||
let p = profile_with_canonical_nans(stem, false);
|
||||
let p = profile(stem, crate::device::DevicePolicy::default()).expect("profile");
|
||||
let metal = p.fields().float_functions == FloatFunctions::Metal;
|
||||
for kk in &ks {
|
||||
let what = format!("{} on {stem}", kk.name);
|
||||
@@ -4968,10 +4732,5 @@ fn half_functions_answer_the_device_s_nan() {
|
||||
let Some(bitcode) = assemble("nan-half-functions", &text) else {
|
||||
return;
|
||||
};
|
||||
nans_are_the_device_s(&bitcode, &ks, true, &["half_asin"], &|name, fact, _| {
|
||||
name.starts_with("half_round")
|
||||
|| name.starts_with("half_fract")
|
||||
|| name == "half_asin"
|
||||
|| !fact
|
||||
});
|
||||
nans_are_the_device_s(&bitcode, &ks, true, &["half_asin"], &|_| true);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ fn unrobust(stem: &str) -> DeviceProfile {
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
desc.features.remove(&VkFeature::RobustBufferAccess);
|
||||
desc.features.remove(&VkFeature::RobustBufferAccess2);
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -503,7 +503,7 @@ fn an_anisotropic_sampler_takes_the_axis_gradients() {
|
||||
.features
|
||||
.remove(&crate::device::requirements::VkFeature::SamplerAnisotropy));
|
||||
}
|
||||
crate::device::Device::new(desc, DevicePolicy::default())
|
||||
crate::device::Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect(stem)
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -101,7 +101,7 @@ pub(super) fn device(stem: &str, tweak: impl FnOnce(&mut DeviceDescription)) ->
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
tweak(&mut desc);
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
fn no_robustness(desc: &mut DeviceDescription) {
|
||||
|
||||
@@ -40,7 +40,7 @@ fn profiles() -> [(&'static str, DeviceProfile); 2] {
|
||||
if !int64 {
|
||||
assert!(desc.features.remove(&VkFeature::ShaderInt64));
|
||||
}
|
||||
let p = Device::new(desc, DevicePolicy::default())
|
||||
let p = Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
|
||||
@@ -46,7 +46,7 @@ fn profile_with(stem: &str, robust: bool) -> DeviceProfile {
|
||||
desc.features.remove(&VkFeature::RobustBufferAccess);
|
||||
desc.features.remove(&VkFeature::RobustBufferAccess2);
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -44,11 +44,12 @@ fn narrowed(stem: &str) -> Device {
|
||||
let mut desc = description(stem).expect("profile");
|
||||
desc.limits.max_color_attachments = 4;
|
||||
desc.limits.max_fragment_output_attachments = 4;
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
fn device(stem: &str) -> Device {
|
||||
Device::new(description(stem).expect("profile"), DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(description(stem).expect("profile"), DevicePolicy::default())
|
||||
.expect("device")
|
||||
}
|
||||
|
||||
/// A different format at each color index, so an attachment's place in a group shows.
|
||||
|
||||
@@ -108,7 +108,7 @@ fn profile(stem: &str, int64: bool) -> DeviceProfile {
|
||||
if !int64 {
|
||||
assert!(desc.features.remove(&VkFeature::ShaderInt64), "{stem}");
|
||||
}
|
||||
let p = Device::new(desc, DevicePolicy::default())
|
||||
let p = Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
|
||||
@@ -80,7 +80,7 @@ fn variant(stem: &str, unrobust: bool, no_int64: bool) -> DeviceProfile {
|
||||
if no_int64 {
|
||||
desc.features.remove(&VkFeature::ShaderInt64);
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default())
|
||||
Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
|
||||
@@ -112,7 +112,7 @@ fn description(stem: &str) -> DeviceDescription {
|
||||
}
|
||||
|
||||
fn device(stem: &str) -> Device {
|
||||
Device::new(description(stem), DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(description(stem), DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// The refusal of a memory writer on a driver that runs it once per covered sample where that
|
||||
|
||||
@@ -450,7 +450,7 @@ fn devices() -> Vec<(String, Device)> {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
out.push((
|
||||
stem,
|
||||
Device::new(desc, DevicePolicy::default()).expect("device"),
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device"),
|
||||
));
|
||||
}
|
||||
out.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
@@ -57,7 +57,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("../metal2vulkan-validation/profiles/{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// Function `name` of `library` specialized with `dfk_reads` = `live` and `dfk_weight` one where
|
||||
|
||||
@@ -59,7 +59,7 @@ fn device_without(stem: &str, features: &[VkFeature]) -> Device {
|
||||
for f in features {
|
||||
assert!(desc.features.remove(f), "{stem} has {f:?}");
|
||||
}
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// The devices of the raster order tests, each with whether it has the pixel interlock.
|
||||
@@ -173,7 +173,7 @@ fn a_raster_order_group_on_an_input_dead_after_specialization_takes_no_interlock
|
||||
}
|
||||
cases.push((name.to_owned(), dev, interlock, "dfr_output", vec![0]));
|
||||
}
|
||||
let floor = Device::new(
|
||||
let floor = Device::from_queries(
|
||||
description("vk12-floor").expect("profile"),
|
||||
DevicePolicy::default(),
|
||||
)
|
||||
|
||||
@@ -106,7 +106,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let description = DeviceDescription::from_khronos_json(&text, None).expect(stem);
|
||||
Device::new(description, DevicePolicy::default()).expect(stem)
|
||||
Device::from_queries(description, DevicePolicy::default()).expect(stem)
|
||||
}
|
||||
|
||||
/// The `Location` of every user variable of storage class `class` in `words` (built-ins carry no
|
||||
|
||||
@@ -152,7 +152,7 @@ fn devices_with(tweak: impl Fn(&mut DeviceDescription)) -> Vec<(String, Device)>
|
||||
tweak(&mut desc);
|
||||
(
|
||||
stem,
|
||||
Device::new(desc, DevicePolicy::default()).expect("device"),
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device"),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
@@ -1437,7 +1437,7 @@ fn gate_lavapipe(tweak: impl Fn(&mut Option<GeneratedCommandsProperties>)) -> De
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
tweak(&mut desc.generated_commands);
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// The limit `set` changes on a description that states the facts.
|
||||
|
||||
@@ -244,7 +244,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// A draw of patches from base instance 7 writes `[patch_start, 7]` into the evaluation stage's
|
||||
|
||||
@@ -218,7 +218,7 @@ fn device() -> Device {
|
||||
.join("../metal2vulkan-validation/profiles/moltenvk-m3.json");
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
fn stage(lib: &Library, libraries: DynamicLibraries) -> FunctionDescriptor {
|
||||
|
||||
@@ -69,7 +69,10 @@ fn profile(stem: &str, robust: bool, policy: DevicePolicy) -> DeviceProfile {
|
||||
desc.features.remove(&VkFeature::RobustBufferAccess);
|
||||
desc.features.remove(&VkFeature::RobustBufferAccess2);
|
||||
}
|
||||
Device::new(desc, policy).expect("device").profile().clone()
|
||||
Device::from_queries(desc, policy)
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// Profile-A profiles in both descriptor encodings (the device-address check is emitted in both:
|
||||
|
||||
@@ -805,7 +805,7 @@ fn devices() -> Vec<(String, Device)> {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
out.push((
|
||||
stem,
|
||||
Device::new(desc, DevicePolicy::default()).expect("device"),
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device"),
|
||||
));
|
||||
}
|
||||
out.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
@@ -1102,15 +1102,11 @@ fn ycbcr_write_slots_store_each_texel_s_bits_and_mark() {
|
||||
}
|
||||
|
||||
/// A `half` read of a slot bound in an extended-range form decodes the texel's codes and rounds
|
||||
/// the decoded `f32` through the device's conversion (`narrow::round_texel`). On `moltenvk-m3`,
|
||||
/// which takes `DriverDeviation::MetalHalfConversion`, the module records no
|
||||
/// `NativeHalfConversion` for it and requires `VkProperty::MetalHalfConversion`; it records
|
||||
/// `DevicePackConversion`, which states the decoded `half` against Metal's. Without the deviation
|
||||
/// (the same profile with it dropped) it records the note and requires nothing.
|
||||
/// the decoded `f32` through the device's conversion (`narrow::round_texel`). On `moltenvk-m3` the
|
||||
/// module records `NativeHalfConversion` for it and `DevicePackConversion`, which states the
|
||||
/// decoded `half` against Metal's.
|
||||
#[test]
|
||||
fn decoded_half_texels_round_by_the_measured_conversion() {
|
||||
use crate::device::requirements::VkProperty;
|
||||
use crate::error::DriverDeviation;
|
||||
fn decoded_half_texels_round_by_the_device_s_conversion() {
|
||||
use crate::pipeline::artifact::PrecisionNote;
|
||||
let Some(bc) = assemble("decoded-halves", &kernel(Source::Read, true, 0)) else {
|
||||
return;
|
||||
@@ -1118,20 +1114,15 @@ fn decoded_half_texels_round_by_the_measured_conversion() {
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles/moltenvk-m3.json");
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let p = Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
for form in FORMS {
|
||||
let i = inputs(form, Source::Read);
|
||||
for taken in [true, false] {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let p = Device::with_deviation(
|
||||
desc,
|
||||
DevicePolicy::default(),
|
||||
DriverDeviation::MetalHalfConversion,
|
||||
taken,
|
||||
)
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
let what = format!("{form:?}, the deviation taken: {taken}");
|
||||
{
|
||||
let what = format!("{form:?}");
|
||||
let a = compile_bitcode(
|
||||
&bc,
|
||||
EntryRef::Name("k"),
|
||||
@@ -1143,9 +1134,8 @@ fn decoded_half_texels_round_by_the_measured_conversion() {
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
assert_eq!(
|
||||
assert!(
|
||||
a.precision.contains(&PrecisionNote::NativeHalfConversion),
|
||||
!taken,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
@@ -1154,13 +1144,6 @@ fn decoded_half_texels_round_by_the_measured_conversion() {
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
assert_eq!(
|
||||
a.requirements
|
||||
.properties
|
||||
.contains(&VkProperty::MetalHalfConversion),
|
||||
taken,
|
||||
"{what}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// The fixture's library; `None` (skipped) without `llvm-as`.
|
||||
|
||||
@@ -910,65 +910,49 @@ fn a_heap_half_write_s_nan_note_follows_the_families_its_command_can_name() {
|
||||
/// A `half` read, nearest sample or gather of a texture an argument buffer holds rounds its texel
|
||||
/// through the device's conversion of the texel's `f32` value (`narrow::round_texel`): the
|
||||
/// fetched texel's, merged with the decode routine's texel of a form a heap reads. On
|
||||
/// `moltenvk-m3`, which takes `DriverDeviation::MetalHalfConversion`, the module records no
|
||||
/// `NativeHalfConversion` for it and requires `VkProperty::MetalHalfConversion`, and it records
|
||||
/// `HalfTexelConversion`, which states a heap element's `half` against Metal's; without the
|
||||
/// deviation (the same profile with it dropped) it records the note and requires nothing. A
|
||||
/// linear sample's filter sum is computed by the device's arithmetic and rounded by
|
||||
/// `narrow::round`, which keeps the note on both.
|
||||
/// `moltenvk-m3` the module records `NativeHalfConversion` for it and `HalfTexelConversion`, which
|
||||
/// states a heap element's `half` against Metal's. A linear sample's filter sum is computed by the
|
||||
/// device's arithmetic and rounded by `narrow::round`, which records the note too.
|
||||
#[test]
|
||||
fn heap_half_texels_round_by_the_measured_conversion() {
|
||||
use crate::device::requirements::VkProperty;
|
||||
use crate::error::DriverDeviation;
|
||||
fn heap_half_texels_round_by_the_device_s_conversion() {
|
||||
use crate::pipeline::PrecisionNote;
|
||||
let consts = FunctionConstantValues::defaults();
|
||||
let entry = EntryRef::Name("k");
|
||||
let inputs = LowerInputs::new();
|
||||
// (what, the kernel, whether every rounding is a texel's).
|
||||
let cases = [
|
||||
("read", kernel(Use::Half), true),
|
||||
("read", kernel(Use::Half)),
|
||||
(
|
||||
"nearest sample",
|
||||
sampling_kernel(Sampling::HalfSample(words(false, false))),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"gather",
|
||||
sampling_kernel(Sampling::HalfGather(words(false, false))),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"linear sample",
|
||||
sampling_kernel(Sampling::HalfSample(words(true, false))),
|
||||
false,
|
||||
),
|
||||
];
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../metal2vulkan-validation/profiles/moltenvk-m3.json");
|
||||
let text = std::fs::read_to_string(&path).expect("profile");
|
||||
for (name, source, texels) in &cases {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let p = Device::from_queries(desc, DevicePolicy::default())
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
for (name, source) in &cases {
|
||||
let Some(bc) = assemble("heap_half", source) else {
|
||||
return;
|
||||
};
|
||||
for taken in [true, false] {
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
let p = Device::with_deviation(
|
||||
desc,
|
||||
DevicePolicy::default(),
|
||||
DriverDeviation::MetalHalfConversion,
|
||||
taken,
|
||||
)
|
||||
.expect("device")
|
||||
.profile()
|
||||
.clone();
|
||||
let what = format!("{name}, the deviation taken: {taken}");
|
||||
{
|
||||
let what = name.to_string();
|
||||
let a = compile_bitcode(&bc, entry, &consts, &p, &inputs, &mut meter(), SPIRV_WORDS)
|
||||
.unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
let exempt = taken && *texels;
|
||||
assert_eq!(
|
||||
assert!(
|
||||
a.precision.contains(&PrecisionNote::NativeHalfConversion),
|
||||
!exempt,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
@@ -977,13 +961,6 @@ fn heap_half_texels_round_by_the_measured_conversion() {
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
assert_eq!(
|
||||
a.requirements
|
||||
.properties
|
||||
.contains(&VkProperty::MetalHalfConversion),
|
||||
exempt,
|
||||
"{what}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,20 +23,17 @@
|
||||
//! (`0x3C01`). Where a profile takes the device's 16-bit arithmetic, each operation reads its
|
||||
//! operands as 16-bit floats with no conversion between them: a 16-bit float widened and narrowed
|
||||
//! back is that float (`FunctionBuilder::convert`), and a narrowed constant is a 16-bit constant.
|
||||
//! Without `shaderFloat16` the `fast` chain is held at `float` precision under
|
||||
//! `HalfChainPolicy::AtExits` (`lower::arith::half_chain`), and rounded at each operation under
|
||||
//! `HalfChainPolicy::EachOperation`.
|
||||
//! Without `shaderFloat16` the `fast` chain is held at `float` precision
|
||||
//! (`lower::arith::half_chain`).
|
||||
//!
|
||||
//! `llvm-as` assembles the modules; without it the tests skip visibly.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::device::HalfChainPolicy;
|
||||
use crate::pipeline::artifact::PrecisionNote;
|
||||
use crate::pipeline::sym::{Axis, ResourceKind, ResourceSlot, SpecKey, Stage};
|
||||
use crate::pipeline::testing::{
|
||||
compile, exact_maths, link_and_validate, llvm_assemble, profile, typed_module, AssembleError,
|
||||
Scratch,
|
||||
compile, link_and_validate, llvm_assemble, profile, typed_module, AssembleError, Scratch,
|
||||
};
|
||||
use crate::spirv::interp::{run, Buffer, Config, Order, Resources};
|
||||
use crate::spirv::testing::committed_profiles;
|
||||
@@ -509,22 +506,15 @@ fn half_operations_read_their_16_bit_operands_directly() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Without `shaderFloat16` the `fast` chain's first sum is held at `float` under
|
||||
/// `HalfChainPolicy::AtExits`, the default: one quantize, at the chain's exit, and the chain's
|
||||
/// sum rounded once; under `HalfChainPolicy::EachOperation` (`exact_answers`) each sum rounds, two
|
||||
/// quantizes and the rounded chain. The chain without flags rounds each sum under both, and a
|
||||
/// profile with `shaderFloat16` takes no quantize under either. Each `fast` chain notes
|
||||
/// `FastMathRewrites`, and the two values make two profile fingerprints.
|
||||
/// Without `shaderFloat16` the `fast` chain's first sum is held at `float`: one quantize, at the
|
||||
/// chain's exit, and the chain's sum rounded once. The chain without flags rounds each sum, two
|
||||
/// quantizes and the rounded chain, and a profile with `shaderFloat16` takes no quantize. Each
|
||||
/// `fast` chain notes `FastMathRewrites`.
|
||||
#[test]
|
||||
fn half_chains_without_float16_round_at_their_exits_by_default() {
|
||||
let Some(bc) = assemble_text(HALF_MODULE) else {
|
||||
return;
|
||||
};
|
||||
assert_eq!(
|
||||
crate::device::DevicePolicy::UNTRUSTED.half_chains,
|
||||
HalfChainPolicy::AtExits
|
||||
);
|
||||
assert_eq!(exact_maths().half_chains, HalfChainPolicy::EachOperation);
|
||||
let quantizes = |words: &[u32]| {
|
||||
let mut n = 0;
|
||||
let mut i = 5;
|
||||
@@ -536,39 +526,30 @@ fn half_chains_without_float16_round_at_their_exits_by_default() {
|
||||
n
|
||||
};
|
||||
let mut emulated = 0;
|
||||
for (stem, fast_p) in committed_profiles().expect("profiles") {
|
||||
let exact_p = profile(&stem, exact_maths()).expect("profile");
|
||||
// The switch changes emitted code, so the profile's fingerprint (every cache key) covers it.
|
||||
assert_ne!(
|
||||
fast_p.fingerprint(),
|
||||
exact_p.fingerprint(),
|
||||
"{stem}: the half chains' policy keys no profile"
|
||||
);
|
||||
let device = crate::lower::arith::narrow::quantize_form(&fast_p)
|
||||
for (stem, p) in committed_profiles().expect("profiles") {
|
||||
let device = crate::lower::arith::narrow::quantize_form(&p)
|
||||
== crate::spirv::builder::QuantizeForm::Device;
|
||||
emulated += usize::from(device);
|
||||
for (entry, fast) in [("fast_half_chain", true), ("strict_half_chain", false)] {
|
||||
for (policy, p) in [("AtExits", &fast_p), ("EachOperation", &exact_p)] {
|
||||
let what = format!("{stem} {entry} {policy}");
|
||||
let a = compile(&bc, entry, p).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
let (_, words) =
|
||||
link_and_validate(&a, p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
let held = device && fast && policy == "AtExits";
|
||||
let want = match (device, held) {
|
||||
(false, _) => 0,
|
||||
(true, true) => 1,
|
||||
(true, false) => 2,
|
||||
};
|
||||
assert_eq!(quantizes(&words), want, "{what}: OpQuantizeToF16");
|
||||
let stored = interpret(&bc, entry, p, HALF_INPUT)[0] & 0xFFFF;
|
||||
assert_eq!(stored, if held { HELD } else { ROUNDED }, "{what}: stored");
|
||||
assert_eq!(
|
||||
a.precision.contains(&PrecisionNote::FastMathRewrites),
|
||||
fast,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
}
|
||||
let what = format!("{stem} {entry}");
|
||||
let a = compile(&bc, entry, &p).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
let (_, words) =
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
let held = device && fast;
|
||||
let want = match (device, held) {
|
||||
(false, _) => 0,
|
||||
(true, true) => 1,
|
||||
(true, false) => 2,
|
||||
};
|
||||
assert_eq!(quantizes(&words), want, "{what}: OpQuantizeToF16");
|
||||
let stored = interpret(&bc, entry, &p, HALF_INPUT)[0] & 0xFFFF;
|
||||
assert_eq!(stored, if held { HELD } else { ROUNDED }, "{what}: stored");
|
||||
assert_eq!(
|
||||
a.precision.contains(&PrecisionNote::FastMathRewrites),
|
||||
fast,
|
||||
"{what}: {:?}",
|
||||
a.precision
|
||||
);
|
||||
}
|
||||
}
|
||||
assert!(emulated > 0, "no committed profile lacks shaderFloat16");
|
||||
|
||||
@@ -119,7 +119,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -224,7 +224,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// `compile_with`, `None` where the device lacks a format's storage (refused whatever the blend).
|
||||
|
||||
@@ -146,7 +146,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
/// Whether `e` is a refusal the device's lack of a capability makes, whatever the blend (a
|
||||
|
||||
@@ -217,7 +217,7 @@ fn device(stem: &str) -> Device {
|
||||
.join(format!("{stem}.json"));
|
||||
let text = std::fs::read_to_string(path).expect("profile");
|
||||
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
|
||||
Device::new(desc, DevicePolicy::default()).expect("device")
|
||||
Device::from_queries(desc, DevicePolicy::default()).expect("device")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -33,7 +33,7 @@ use crate::lower::arith::libm::Mode;
|
||||
use crate::lower::arith::{denormal, float_binop_notes, float_call_notes, nan, narrow, FloatFmt};
|
||||
use crate::pipeline::artifact::{EntryMath, PrecisionNote};
|
||||
use crate::pipeline::testing::{
|
||||
compile, exact_maths, llvm_assemble, meter, typed_module, AssembleError, Scratch,
|
||||
compile, llvm_assemble, meter, typed_module, AssembleError, Scratch,
|
||||
};
|
||||
use crate::spirv::testing::committed_profiles_with;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
@@ -307,7 +307,9 @@ fn note_class(p: &DeviceProfile) -> NoteClass {
|
||||
/// One committed profile per note class (the first by name).
|
||||
fn one_profile_per_class() -> BTreeMap<NoteClass, (String, DeviceProfile)> {
|
||||
let mut out = BTreeMap::new();
|
||||
for (stem, p) in committed_profiles_with(exact_maths()).expect("profiles") {
|
||||
for (stem, p) in
|
||||
committed_profiles_with(crate::device::DevicePolicy::default()).expect("profiles")
|
||||
{
|
||||
out.entry(note_class(&p)).or_insert((stem, p));
|
||||
}
|
||||
let routes: BTreeSet<Route> = out.keys().map(|(route, _, _, _)| *route).collect();
|
||||
@@ -670,7 +672,8 @@ fn a_fast_math_entry_on_moltenvk_records_no_note_for_metals_own_operations() {
|
||||
let Some(bitcode) = assemble("moltenvk", 0, &module(&kernels)) else {
|
||||
return;
|
||||
};
|
||||
let profiles = committed_profiles_with(exact_maths()).expect("profiles");
|
||||
let profiles =
|
||||
committed_profiles_with(crate::device::DevicePolicy::default()).expect("profiles");
|
||||
let by_stem = |stem: &str| {
|
||||
profiles
|
||||
.iter()
|
||||
|
||||
Loaded 100 of 214 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user