use crate::descriptor_set::layout::DescriptorType;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(i32)]
pub enum ImageLayout {
Undefined = ash::vk::ImageLayout::UNDEFINED.as_raw(),
General = ash::vk::ImageLayout::GENERAL.as_raw(),
ColorAttachmentOptimal = ash::vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL.as_raw(),
DepthStencilAttachmentOptimal = ash::vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL.as_raw(),
DepthStencilReadOnlyOptimal = ash::vk::ImageLayout::DEPTH_STENCIL_READ_ONLY_OPTIMAL.as_raw(),
ShaderReadOnlyOptimal = ash::vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL.as_raw(),
TransferSrcOptimal = ash::vk::ImageLayout::TRANSFER_SRC_OPTIMAL.as_raw(),
TransferDstOptimal = ash::vk::ImageLayout::TRANSFER_DST_OPTIMAL.as_raw(),
Preinitialized = ash::vk::ImageLayout::PREINITIALIZED.as_raw(),
PresentSrc = ash::vk::ImageLayout::PRESENT_SRC_KHR.as_raw(),
}
impl From<ImageLayout> for ash::vk::ImageLayout {
#[inline]
fn from(val: ImageLayout) -> Self {
Self::from_raw(val as i32)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ImageDescriptorLayouts {
pub storage_image: ImageLayout,
pub combined_image_sampler: ImageLayout,
pub sampled_image: ImageLayout,
pub input_attachment: ImageLayout,
}
impl ImageDescriptorLayouts {
#[inline]
pub fn layout_for(&self, descriptor_type: DescriptorType) -> ImageLayout {
match descriptor_type {
DescriptorType::CombinedImageSampler => self.combined_image_sampler,
DescriptorType::SampledImage => self.sampled_image,
DescriptorType::StorageImage => self.storage_image,
DescriptorType::InputAttachment => self.input_attachment,
_ => panic!("{:?} is not an image descriptor type", descriptor_type),
}
}
}