use crate::macros::{vulkan_bitflags, vulkan_enum};
vulkan_enum! {
#[non_exhaustive]
ImageAspect = ImageAspectFlags(u32);
Color = COLOR,
Depth = DEPTH,
Stencil = STENCIL,
Metadata = METADATA,
Plane0 = PLANE_0 {
api_version: V1_1,
device_extensions: [khr_sampler_ycbcr_conversion],
},
Plane1 = PLANE_1 {
api_version: V1_1,
device_extensions: [khr_sampler_ycbcr_conversion],
},
Plane2 = PLANE_2 {
api_version: V1_1,
device_extensions: [khr_sampler_ycbcr_conversion],
},
MemoryPlane0 = MEMORY_PLANE_0_EXT {
device_extensions: [ext_image_drm_format_modifier],
},
MemoryPlane1 = MEMORY_PLANE_1_EXT {
device_extensions: [ext_image_drm_format_modifier],
},
MemoryPlane2 = MEMORY_PLANE_2_EXT {
device_extensions: [ext_image_drm_format_modifier],
},
}
vulkan_bitflags! {
#[non_exhaustive]
ImageAspects = ImageAspectFlags(u32);
color = COLOR,
depth = DEPTH,
stencil = STENCIL,
metadata = METADATA,
plane0 = PLANE_0 {
api_version: V1_1,
device_extensions: [khr_sampler_ycbcr_conversion],
},
plane1 = PLANE_1 {
api_version: V1_1,
device_extensions: [khr_sampler_ycbcr_conversion],
},
plane2 = PLANE_2 {
api_version: V1_1,
device_extensions: [khr_sampler_ycbcr_conversion],
},
memory_plane0 = MEMORY_PLANE_0_EXT {
device_extensions: [ext_image_drm_format_modifier],
},
memory_plane1 = MEMORY_PLANE_1_EXT {
device_extensions: [ext_image_drm_format_modifier],
},
memory_plane2 = MEMORY_PLANE_2_EXT {
device_extensions: [ext_image_drm_format_modifier],
},
}
impl ImageAspects {
#[inline]
pub fn iter(&self) -> impl Iterator<Item = ImageAspect> {
let Self {
color,
depth,
stencil,
metadata,
plane0,
plane1,
plane2,
memory_plane0,
memory_plane1,
memory_plane2,
_ne: _,
} = *self;
[
color.then_some(ImageAspect::Color),
depth.then_some(ImageAspect::Depth),
stencil.then_some(ImageAspect::Stencil),
metadata.then_some(ImageAspect::Metadata),
plane0.then_some(ImageAspect::Plane0),
plane1.then_some(ImageAspect::Plane1),
plane2.then_some(ImageAspect::Plane2),
memory_plane0.then_some(ImageAspect::MemoryPlane0),
memory_plane1.then_some(ImageAspect::MemoryPlane1),
memory_plane2.then_some(ImageAspect::MemoryPlane2),
]
.into_iter()
.flatten()
}
}
impl From<ImageAspect> for ImageAspects {
#[inline]
fn from(aspect: ImageAspect) -> Self {
let mut result = Self::empty();
match aspect {
ImageAspect::Color => result.color = true,
ImageAspect::Depth => result.depth = true,
ImageAspect::Stencil => result.stencil = true,
ImageAspect::Metadata => result.metadata = true,
ImageAspect::Plane0 => result.plane0 = true,
ImageAspect::Plane1 => result.plane1 = true,
ImageAspect::Plane2 => result.plane2 = true,
ImageAspect::MemoryPlane0 => result.memory_plane0 = true,
ImageAspect::MemoryPlane1 => result.memory_plane1 = true,
ImageAspect::MemoryPlane2 => result.memory_plane2 = true,
}
result
}
}
impl FromIterator<ImageAspect> for ImageAspects {
fn from_iter<T: IntoIterator<Item = ImageAspect>>(iter: T) -> Self {
let mut result = Self::empty();
for aspect in iter {
match aspect {
ImageAspect::Color => result.color = true,
ImageAspect::Depth => result.depth = true,
ImageAspect::Stencil => result.stencil = true,
ImageAspect::Metadata => result.metadata = true,
ImageAspect::Plane0 => result.plane0 = true,
ImageAspect::Plane1 => result.plane1 = true,
ImageAspect::Plane2 => result.plane2 = true,
ImageAspect::MemoryPlane0 => result.memory_plane0 = true,
ImageAspect::MemoryPlane1 => result.memory_plane1 = true,
ImageAspect::MemoryPlane2 => result.memory_plane2 = true,
}
}
result
}
}