use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum BackendKind {
Vulkan,
WebGpu,
Metal,
Dx12,
Null,
}
impl BackendKind {
#[must_use]
pub const fn is_gpu(self) -> bool {
match self {
Self::Vulkan | Self::WebGpu | Self::Metal | Self::Dx12 => true,
Self::Null => false,
}
}
}
impl fmt::Display for BackendKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = match self {
Self::Vulkan => "vulkan",
Self::WebGpu => "webgpu",
Self::Metal => "metal",
Self::Dx12 => "dx12",
Self::Null => "null",
};
f.write_str(name)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum DeviceType {
Cpu,
Integrated,
Discrete,
Virtual,
Other,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AdapterId(pub u32);
#[derive(Clone, Debug, PartialEq)]
pub struct AdapterInfo {
pub id: AdapterId,
pub name: String,
pub vendor_id: u32,
pub device_id: u32,
pub device_type: DeviceType,
pub driver: String,
pub backend: BackendKind,
pub caps: DeviceCaps,
}
bitflags::bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Features: u64 {
const DESCRIPTOR_INDEXING = 1 << 0;
const BUFFER_DEVICE_ADDRESS = 1 << 1;
const DRAW_INDIRECT_COUNT = 1 << 2;
const MULTI_DRAW_INDIRECT = 1 << 3;
const INDIRECT_FIRST_INSTANCE = 1 << 4;
const TIMESTAMP_QUERY = 1 << 5;
const PIPELINE_STATISTICS_QUERY = 1 << 6;
const OCCLUSION_QUERY = 1 << 7;
const COMPUTE = 1 << 8;
const TIMELINE_SEMAPHORE = 1 << 9;
const ASYNC_COMPUTE_QUEUE = 1 << 10;
const TRANSFER_QUEUE = 1 << 11;
const PUSH_CONSTANTS = 1 << 12;
const DEPTH_CLAMP = 1 << 13;
const DEPTH_BIAS_CLAMP = 1 << 14;
const POLYGON_MODE_LINE = 1 << 15;
const TEXTURE_COMPRESSION_BC = 1 << 16;
const SAMPLER_ANISOTROPY = 1 << 17;
const DEBUG_MARKERS = 1 << 18;
const SHADER_DEBUG_PRINTF = 1 << 19;
const PRESENT_FEEDBACK = 1 << 20;
const PRESENT_TIMING = 1 << 21;
const MESH_SHADER = 1 << 22;
const TASK_SHADER = 1 << 23;
const RAY_QUERY = 1 << 24;
const RAY_TRACING_PIPELINE = 1 << 25;
const ACCELERATION_STRUCTURE = 1 << 26;
const DRAW_INDEX = 1 << 27;
const GPU_DRIVEN = Self::DESCRIPTOR_INDEXING.bits()
| Self::BUFFER_DEVICE_ADDRESS.bits()
| Self::DRAW_INDIRECT_COUNT.bits()
| Self::MULTI_DRAW_INDIRECT.bits()
| Self::COMPUTE.bits()
| Self::TIMELINE_SEMAPHORE.bits();
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Limits {
pub max_image_2d: u32,
pub max_image_3d: u32,
pub max_image_array_layers: u32,
pub max_storage_buffer_range: u64,
pub max_uniform_buffer_range: u64,
pub max_bind_groups: u32,
pub max_bindless_descriptors: u32,
pub max_push_constant_size: u32,
pub max_color_attachments: u32,
pub max_sample_count: u32,
pub max_draw_indirect_count: u32,
pub max_compute_workgroup_size: [u32; 3],
pub max_compute_invocations_per_workgroup: u32,
pub max_compute_workgroups_per_dimension: u32,
pub min_uniform_buffer_offset_alignment: u64,
pub min_storage_buffer_offset_alignment: u64,
pub optimal_buffer_copy_offset_alignment: u64,
pub max_sampler_anisotropy: f32,
}
impl Limits {
#[must_use]
pub const fn minimum() -> Self {
Self {
max_image_2d: 8192,
max_image_3d: 2048,
max_image_array_layers: 256,
max_storage_buffer_range: 128 << 20,
max_uniform_buffer_range: 64 << 10,
max_bind_groups: 4,
max_bindless_descriptors: 0,
max_push_constant_size: 0,
max_color_attachments: 4,
max_sample_count: 4,
max_draw_indirect_count: 1,
max_compute_workgroup_size: [256, 256, 64],
max_compute_invocations_per_workgroup: 256,
max_compute_workgroups_per_dimension: 65535,
min_uniform_buffer_offset_alignment: 256,
min_storage_buffer_offset_alignment: 256,
optimal_buffer_copy_offset_alignment: 256,
max_sampler_anisotropy: 1.0,
}
}
#[must_use]
pub const fn desktop() -> Self {
Self {
max_image_2d: 16384,
max_image_3d: 2048,
max_image_array_layers: 2048,
max_storage_buffer_range: u32::MAX as u64,
max_uniform_buffer_range: 64 << 10,
max_bind_groups: 8,
max_bindless_descriptors: 500_000,
max_push_constant_size: 128,
max_color_attachments: 8,
max_sample_count: 8,
max_draw_indirect_count: 1 << 20,
max_compute_workgroup_size: [1024, 1024, 64],
max_compute_invocations_per_workgroup: 1024,
max_compute_workgroups_per_dimension: 65535,
min_uniform_buffer_offset_alignment: 64,
min_storage_buffer_offset_alignment: 16,
optimal_buffer_copy_offset_alignment: 4,
max_sampler_anisotropy: 16.0,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum GeometryPath {
MeshShader,
IndirectCount,
IndirectPerBatch,
}
impl GeometryPath {
pub const INPUTS: Features = Features::MESH_SHADER.union(Features::DRAW_INDIRECT_COUNT);
#[must_use]
pub const fn from_features(features: Features) -> Self {
if features.contains(Features::MESH_SHADER) {
Self::MeshShader
} else if features.contains(Features::DRAW_INDIRECT_COUNT) {
Self::IndirectCount
} else {
Self::IndirectPerBatch
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum BindingModel {
Bindless,
ArrayPages,
}
impl BindingModel {
pub const INPUTS: Features = Features::DESCRIPTOR_INDEXING;
#[must_use]
pub const fn from_features(features: Features) -> Self {
if features.contains(Features::DESCRIPTOR_INDEXING) {
Self::Bindless
} else {
Self::ArrayPages
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum LightingPath {
RayTraced,
Rasterised,
}
impl LightingPath {
pub const INPUTS: Features = Features::RAY_QUERY.union(Features::ACCELERATION_STRUCTURE);
#[must_use]
pub const fn from_features(features: Features) -> Self {
if features.contains(Features::RAY_QUERY.union(Features::ACCELERATION_STRUCTURE)) {
Self::RayTraced
} else {
Self::Rasterised
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct DeviceCaps {
pub features: Features,
pub limits: Limits,
}
impl DeviceCaps {
#[must_use]
pub const fn geometry_path(&self) -> GeometryPath {
GeometryPath::from_features(self.features)
}
#[must_use]
pub const fn binding_model(&self) -> BindingModel {
BindingModel::from_features(self.features)
}
#[must_use]
pub const fn lighting_path(&self) -> LightingPath {
LightingPath::from_features(self.features)
}
#[must_use]
pub fn missing(&self, required: Features) -> Features {
required.difference(self.features)
}
#[must_use]
pub fn supports(&self, required: Features) -> bool {
self.features.contains(required)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum SelectedPath {
Geometry(GeometryPath),
Binding(BindingModel),
Lighting(LightingPath),
}
impl fmt::Display for SelectedPath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Geometry(path) => write!(f, "geometry {path:?}"),
Self::Binding(model) => write!(f, "binding {model:?}"),
Self::Lighting(path) => write!(f, "lighting {path:?}"),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Downgrade {
pub feature: Features,
pub name: &'static str,
pub selected: Option<SelectedPath>,
}
impl fmt::Display for Downgrade {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.selected {
Some(selected) => write!(f, "{} -> {selected}", self.name),
None => f.write_str(self.name),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Downgrades {
absent: Features,
geometry: GeometryPath,
binding: BindingModel,
lighting: LightingPath,
}
impl Downgrades {
#[must_use]
pub const fn absent(&self) -> Features {
self.absent
}
#[must_use]
pub const fn is_empty(&self) -> bool {
self.absent.is_empty()
}
pub fn iter(&self) -> impl Iterator<Item = Downgrade> + '_ {
use bitflags::Flags;
Features::FLAGS
.iter()
.filter(|flag| flag.value().bits().is_power_of_two())
.filter(|flag| self.absent.contains(*flag.value()))
.map(|flag| Downgrade {
feature: *flag.value(),
name: flag.name(),
selected: self.selected_for(*flag.value()),
})
}
fn selected_for(&self, feature: Features) -> Option<SelectedPath> {
if GeometryPath::INPUTS.contains(feature) {
Some(SelectedPath::Geometry(self.geometry))
} else if BindingModel::INPUTS.contains(feature) {
Some(SelectedPath::Binding(self.binding))
} else if LightingPath::INPUTS.contains(feature) {
Some(SelectedPath::Lighting(self.lighting))
} else {
None
}
}
}
impl fmt::Display for Downgrades {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for (index, downgrade) in self.iter().enumerate() {
if index > 0 {
f.write_str(", ")?;
}
write!(f, "{downgrade}")?;
}
Ok(())
}
}
#[must_use]
pub fn downgrades(requested: Features, granted: &DeviceCaps) -> Downgrades {
Downgrades {
absent: granted.missing(requested),
geometry: granted.geometry_path(),
binding: granted.binding_model(),
lighting: granted.lighting_path(),
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::HalError;
#[test]
fn mesh_shading_wins_without_a_draw_indirect_count() {
let mesh_only = GeometryPath::from_features(Features::MESH_SHADER);
assert_eq!(mesh_only, GeometryPath::MeshShader);
assert_eq!(
GeometryPath::from_features(Features::MESH_SHADER | Features::DRAW_INDIRECT_COUNT),
mesh_only,
"a draw count must not displace the mesh path"
);
assert_eq!(
GeometryPath::from_features(Features::DRAW_INDIRECT_COUNT),
GeometryPath::IndirectCount,
"the count alone is the middle path, not the floor"
);
}
#[test]
fn ray_traced_lighting_needs_both_halves() {
for (features, expected) in [
(Features::empty(), LightingPath::Rasterised),
(Features::RAY_QUERY, LightingPath::Rasterised),
(Features::ACCELERATION_STRUCTURE, LightingPath::Rasterised),
(
Features::RAY_TRACING_PIPELINE | Features::ACCELERATION_STRUCTURE,
LightingPath::Rasterised,
),
(
Features::RAY_QUERY | Features::ACCELERATION_STRUCTURE,
LightingPath::RayTraced,
),
] {
assert_eq!(
LightingPath::from_features(features),
expected,
"{features:?}"
);
}
}
#[test]
fn an_empty_feature_set_lands_on_the_floor_of_every_selector() {
let caps = DeviceCaps {
features: Features::empty(),
limits: Limits::minimum(),
};
assert_eq!(caps.geometry_path(), GeometryPath::IndirectPerBatch);
assert_eq!(caps.binding_model(), BindingModel::ArrayPages);
assert_eq!(caps.lighting_path(), LightingPath::Rasterised);
}
#[test]
fn the_accessors_follow_the_devices_features() {
let caps = DeviceCaps {
features: Features::MESH_SHADER
| Features::DESCRIPTOR_INDEXING
| Features::RAY_QUERY
| Features::ACCELERATION_STRUCTURE,
limits: Limits::desktop(),
};
assert_eq!(caps.geometry_path(), GeometryPath::MeshShader);
assert_eq!(caps.binding_model(), BindingModel::Bindless);
assert_eq!(caps.lighting_path(), LightingPath::RayTraced);
}
#[test]
fn adding_a_feature_never_selects_a_path_that_needs_more() {
const AXES: [Features; 5] = [
Features::MESH_SHADER,
Features::DRAW_INDIRECT_COUNT,
Features::DESCRIPTOR_INDEXING,
Features::RAY_QUERY,
Features::ACCELERATION_STRUCTURE,
];
fn rank(features: Features) -> [u8; 3] {
[
match GeometryPath::from_features(features) {
GeometryPath::IndirectPerBatch => 0,
GeometryPath::IndirectCount => 1,
GeometryPath::MeshShader => 2,
},
match BindingModel::from_features(features) {
BindingModel::ArrayPages => 0,
BindingModel::Bindless => 1,
},
match LightingPath::from_features(features) {
LightingPath::Rasterised => 0,
LightingPath::RayTraced => 1,
},
]
}
for subset in 0..(1u32 << AXES.len()) {
let base = AXES
.iter()
.enumerate()
.filter(|(bit, _)| subset & (1 << bit) != 0)
.fold(Features::empty(), |acc, (_, axis)| acc.union(*axis));
let before = rank(base);
for axis in AXES {
let after = rank(base.union(axis));
assert!(
after.iter().zip(&before).all(|(now, then)| now >= then),
"gaining {axis:?} on top of {base:?} went backwards: \
{before:?} -> {after:?}"
);
}
}
}
#[test]
fn gpu_driven_is_exactly_the_documented_bundle() {
let documented = Features::DESCRIPTOR_INDEXING
| Features::BUFFER_DEVICE_ADDRESS
| Features::DRAW_INDIRECT_COUNT
| Features::MULTI_DRAW_INDIRECT
| Features::COMPUTE
| Features::TIMELINE_SEMAPHORE;
assert_eq!(Features::GPU_DRIVEN, documented);
assert!(!Features::GPU_DRIVEN.contains(Features::PUSH_CONSTANTS));
assert!(!Features::GPU_DRIVEN.contains(Features::PRESENT_FEEDBACK));
assert!(!Features::GPU_DRIVEN.contains(Features::PRESENT_TIMING));
assert!(!Features::GPU_DRIVEN.contains(Features::MESH_SHADER));
assert!(!Features::GPU_DRIVEN.contains(Features::RAY_QUERY));
assert!(!Features::GPU_DRIVEN.contains(Features::ACCELERATION_STRUCTURE));
assert!(!Features::GPU_DRIVEN.contains(Features::DRAW_INDEX));
}
#[test]
fn missing_names_the_gap() {
let caps = DeviceCaps {
features: Features::COMPUTE | Features::TIMELINE_SEMAPHORE,
limits: Limits::minimum(),
};
let missing = caps.missing(Features::GPU_DRIVEN);
assert!(missing.contains(Features::DESCRIPTOR_INDEXING));
assert!(missing.contains(Features::BUFFER_DEVICE_ADDRESS));
assert!(!missing.contains(Features::COMPUTE));
assert!(!caps.supports(Features::GPU_DRIVEN));
assert!(caps.supports(Features::COMPUTE));
assert!(caps.missing(Features::COMPUTE).is_empty());
}
#[test]
fn minimum_limits_are_below_desktop_limits() {
let min = Limits::minimum();
let desktop = Limits::desktop();
assert!(min.max_image_2d < desktop.max_image_2d);
assert!(min.max_image_array_layers < desktop.max_image_array_layers);
assert!(min.max_storage_buffer_range < desktop.max_storage_buffer_range);
assert!(min.max_bind_groups < desktop.max_bind_groups);
assert!(min.max_bindless_descriptors < desktop.max_bindless_descriptors);
assert!(min.max_push_constant_size < desktop.max_push_constant_size);
assert!(min.max_color_attachments < desktop.max_color_attachments);
assert!(min.max_sample_count < desktop.max_sample_count);
assert!(min.max_draw_indirect_count < desktop.max_draw_indirect_count);
assert!(min.max_compute_workgroup_size[0] < desktop.max_compute_workgroup_size[0]);
assert!(min.max_compute_workgroup_size[1] < desktop.max_compute_workgroup_size[1]);
assert!(
min.max_compute_invocations_per_workgroup
< desktop.max_compute_invocations_per_workgroup
);
assert!(min.max_sampler_anisotropy < desktop.max_sampler_anisotropy);
assert!(min.max_image_3d <= desktop.max_image_3d);
assert!(min.max_uniform_buffer_range <= desktop.max_uniform_buffer_range);
assert!(min.max_compute_workgroup_size[2] <= desktop.max_compute_workgroup_size[2]);
assert!(
min.max_compute_workgroups_per_dimension
<= desktop.max_compute_workgroups_per_dimension
);
for limits in [min, desktop] {
assert!(limits.max_sample_count.is_power_of_two());
assert!(limits.max_sample_count <= 64);
}
assert!(
min.min_uniform_buffer_offset_alignment > desktop.min_uniform_buffer_offset_alignment
);
assert!(
min.min_storage_buffer_offset_alignment > desktop.min_storage_buffer_offset_alignment
);
assert!(
min.optimal_buffer_copy_offset_alignment > desktop.optimal_buffer_copy_offset_alignment
);
}
#[test]
fn every_feature_owns_a_distinct_bit() {
use bitflags::Flags;
let single_bit: Vec<&'static str> = Features::FLAGS
.iter()
.filter(|flag| flag.value().bits().is_power_of_two())
.map(bitflags::Flag::name)
.collect();
assert_eq!(
Features::all().bits().count_ones() as usize,
single_bit.len(),
"two of {single_bit:?} share a bit"
);
}
#[test]
fn every_feature_is_reported_one_at_a_time() {
use bitflags::Flags;
for flag in Features::FLAGS {
let feature = *flag.value();
if !feature.bits().is_power_of_two() {
continue;
}
let name = flag.name();
let without = DeviceCaps {
features: Features::all().difference(feature),
limits: Limits::desktop(),
};
assert_eq!(without.missing(feature), feature, "{name}");
assert!(!without.supports(feature), "{name}");
let only = DeviceCaps {
features: feature,
limits: Limits::minimum(),
};
assert!(only.supports(feature), "{name}");
assert!(only.missing(feature).is_empty(), "{name}");
assert!(
HalError::UnsupportedFeatures {
missing: without.missing(feature)
}
.to_string()
.contains(name),
"the error a backend owes must name {name}"
);
}
}
#[test]
fn minimum_limits_report_no_bindless_or_push_constants() {
let min = Limits::minimum();
assert_eq!(min.max_bindless_descriptors, 0);
assert_eq!(min.max_push_constant_size, 0);
assert_eq!(
min.max_draw_indirect_count, 1,
"the floor emits one draw per indirect call"
);
}
#[test]
fn selector_inputs_are_the_only_features_a_selector_reads() {
use bitflags::Flags;
let single_bits: Vec<Features> = Features::FLAGS
.iter()
.map(|flag| *flag.value())
.filter(|feature| feature.bits().is_power_of_two())
.collect();
type Select = fn(Features) -> u8;
let selectors: [(Features, Select); 3] = [
(GeometryPath::INPUTS, |features| {
GeometryPath::from_features(features) as u8
}),
(BindingModel::INPUTS, |features| {
BindingModel::from_features(features) as u8
}),
(LightingPath::INPUTS, |features| {
LightingPath::from_features(features) as u8
}),
];
for (inputs, select) in selectors {
let members: Vec<Features> = single_bits
.iter()
.copied()
.filter(|feature| inputs.contains(*feature))
.collect();
assert!(
!members.is_empty(),
"a selector reading nothing would pass this vacuously"
);
for subset in 0..(1u32 << members.len()) {
let base = members
.iter()
.enumerate()
.filter(|(bit, _)| subset & (1 << bit) != 0)
.fold(Features::empty(), |acc, (_, feature)| acc.union(*feature));
let expected = select(base);
for other in &single_bits {
if inputs.contains(*other) {
continue;
}
assert_eq!(
select(base.union(*other)),
expected,
"{other:?} moved a selector that does not list it in INPUTS"
);
}
}
for member in &members {
assert!(
(0..(1u32 << members.len())).any(|subset| {
let base = members
.iter()
.enumerate()
.filter(|(bit, _)| subset & (1 << bit) != 0)
.fold(Features::empty(), |acc, (_, feature)| acc.union(*feature));
select(base.union(*member)) != select(base.difference(*member))
}),
"{member:?} is listed in INPUTS but changes nothing"
);
}
}
}
#[test]
fn a_device_that_granted_everything_reports_no_downgrade() {
let caps = DeviceCaps {
features: Features::all(),
limits: Limits::desktop(),
};
for requested in [
Features::empty(),
Features::COMPUTE,
Features::GPU_DRIVEN,
Features::all(),
] {
let report = downgrades(requested, &caps);
assert!(report.is_empty(), "{requested:?}");
assert!(report.absent().is_empty(), "{requested:?}");
assert_eq!(report.iter().count(), 0, "{requested:?}");
assert_eq!(report.to_string(), "", "{requested:?}");
}
}
#[test]
fn one_absent_feature_names_itself_and_the_path_it_moved() {
for (feature, name, expected) in [
(
Features::MESH_SHADER,
"MESH_SHADER",
SelectedPath::Geometry(GeometryPath::IndirectCount),
),
(
Features::DRAW_INDIRECT_COUNT,
"DRAW_INDIRECT_COUNT",
SelectedPath::Geometry(GeometryPath::MeshShader),
),
(
Features::DESCRIPTOR_INDEXING,
"DESCRIPTOR_INDEXING",
SelectedPath::Binding(BindingModel::ArrayPages),
),
(
Features::RAY_QUERY,
"RAY_QUERY",
SelectedPath::Lighting(LightingPath::Rasterised),
),
(
Features::ACCELERATION_STRUCTURE,
"ACCELERATION_STRUCTURE",
SelectedPath::Lighting(LightingPath::Rasterised),
),
] {
let caps = DeviceCaps {
features: Features::all().difference(feature),
limits: Limits::desktop(),
};
let report = downgrades(Features::all(), &caps);
assert!(!report.is_empty(), "{name}");
assert_eq!(report.absent(), feature, "{name}");
let entries: Vec<Downgrade> = report.iter().collect();
assert_eq!(entries.len(), 1, "{name}");
assert_eq!(entries[0].feature, feature, "{name}");
assert_eq!(entries[0].name, name);
assert_eq!(entries[0].selected, Some(expected), "{name}");
let line = report.to_string();
assert!(line.starts_with(name), "{line}");
assert!(line.contains(&expected.to_string()), "{line}");
}
}
#[test]
fn an_absence_no_selector_reads_names_no_path() {
let caps = DeviceCaps {
features: Features::all().difference(Features::TIMESTAMP_QUERY),
limits: Limits::desktop(),
};
let report = downgrades(Features::all(), &caps);
let entries: Vec<Downgrade> = report.iter().collect();
assert_eq!(entries.len(), 1);
assert_eq!(entries[0].selected, None);
assert_eq!(report.to_string(), "TIMESTAMP_QUERY");
}
#[test]
fn every_absent_feature_is_named() {
let caps = DeviceCaps {
features: Features::COMPUTE | Features::TIMELINE_SEMAPHORE,
limits: Limits::minimum(),
};
let requested = Features::GPU_DRIVEN
| Features::MESH_SHADER
| Features::RAY_QUERY
| Features::ACCELERATION_STRUCTURE
| Features::TIMESTAMP_QUERY;
let report = downgrades(requested, &caps);
let named: Vec<&'static str> = report.iter().map(|downgrade| downgrade.name).collect();
assert_eq!(
named,
[
"DESCRIPTOR_INDEXING",
"BUFFER_DEVICE_ADDRESS",
"DRAW_INDIRECT_COUNT",
"MULTI_DRAW_INDIRECT",
"TIMESTAMP_QUERY",
"MESH_SHADER",
"RAY_QUERY",
"ACCELERATION_STRUCTURE",
],
"in flag-declaration order, and `GPU_DRIVEN` itself never named"
);
let line = report.to_string();
for name in &named {
assert!(line.contains(name), "{line} omits {name}");
}
assert!(line.contains("binding ArrayPages"), "{line}");
assert!(line.contains("geometry IndirectPerBatch"), "{line}");
assert!(line.contains("lighting Rasterised"), "{line}");
assert!(!line.contains("COMPUTE"), "{line}");
assert!(!line.contains("TIMELINE_SEMAPHORE"), "{line}");
assert!(!line.contains("PRESENT_FEEDBACK"), "{line}");
}
#[test]
fn backend_kind_displays_lowercase() {
assert_eq!(BackendKind::Vulkan.to_string(), "vulkan");
assert_eq!(BackendKind::Null.to_string(), "null");
assert_eq!(BackendKind::WebGpu.to_string(), "webgpu");
let every = [
BackendKind::Vulkan,
BackendKind::WebGpu,
BackendKind::Metal,
BackendKind::Dx12,
BackendKind::Null,
];
let names: std::collections::HashSet<String> =
every.iter().map(ToString::to_string).collect();
assert_eq!(names.len(), every.len(), "two backend kinds share a name");
}
}