#[cfg(all(feature = "debug_layers", feature = "wgpu"))]
mod renderer;
#[cfg(all(feature = "debug_layers", feature = "wgpu"))]
mod validate;
use std::fmt::Debug;
#[cfg(all(feature = "debug_layers", feature = "wgpu"))]
pub(crate) use renderer::*;
#[cfg_attr(docsrs, doc(hidden))]
#[derive(Copy, Clone)]
pub struct DebugLayers(u8);
impl Debug for DebugLayers {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut tuple = f.debug_tuple("DebugLayers");
if self.contains(Self::BOUNDING_BOXES) {
tuple.field(&"BOUNDING_BOXES");
}
if self.contains(Self::LINESOUP_SEGMENTS) {
tuple.field(&"LINESOUP_SEGMENTS");
}
if self.contains(Self::LINESOUP_POINTS) {
tuple.field(&"LINESOUP_POINTS");
}
if self.contains(Self::VALIDATION) {
tuple.field(&"VALIDATION");
}
tuple.finish()
}
}
impl DebugLayers {
pub const BOUNDING_BOXES: Self = Self(1 << 0);
pub const LINESOUP_SEGMENTS: Self = Self(1 << 1);
pub const LINESOUP_POINTS: Self = Self(1 << 2);
pub const VALIDATION: Self = Self(1 << 3);
pub const fn from_bits(bits: u8) -> Self {
Self(bits)
}
pub const fn bits(self) -> u8 {
self.0
}
pub const fn none() -> Self {
Self(0)
}
pub const fn all() -> Self {
Self(
Self::BOUNDING_BOXES.0
| Self::LINESOUP_SEGMENTS.0
| Self::LINESOUP_POINTS.0
| Self::VALIDATION.0,
)
}
pub const fn is_empty(self) -> bool {
self.0 == 0
}
pub const fn contains(self, mask: Self) -> bool {
self.0 & mask.0 == mask.0
}
pub fn toggle(&mut self, mask: Self) {
self.0 ^= mask.0;
}
}
impl std::ops::BitOr for DebugLayers {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}