Impl From<u8> for ShaderType

This commit is contained in:
hodasemi 2023-01-27 17:42:04 +01:00
parent f49a7c299c
commit 1a7e31e1d3

View file

@ -24,18 +24,25 @@ pub enum ShaderType {
Intersection, Intersection,
} }
impl ShaderType { impl From<u8> for ShaderType {
pub const VERTEX: u8 = Self::Vertex as u8; fn from(value: u8) -> Self {
pub const FRAGMENT: u8 = Self::Fragment as u8; match value {
pub const GEOMETRY: u8 = Self::Geometry as u8; 0 => Self::None,
pub const TESSELATION_CONTROL: u8 = Self::TesselationControl as u8; 1 => Self::Vertex,
pub const TESSELATION_EVALUATION: u8 = Self::TesselationEvaluation as u8; 2 => Self::Fragment,
pub const COMPUTE: u8 = Self::Compute as u8; 3 => Self::Geometry,
pub const RAY_GENERATION: u8 = Self::RayGeneration as u8; 4 => Self::TesselationControl,
pub const CLOSEST_HIT: u8 = Self::ClosestHit as u8; 5 => Self::TesselationEvaluation,
pub const MISS: u8 = Self::Miss as u8; 6 => Self::Compute,
pub const ANY_HIT: u8 = Self::AnyHit as u8; 7 => Self::RayGeneration,
pub const INTERSECTION: u8 = Self::Intersection as u8; 8 => Self::ClosestHit,
9 => Self::Miss,
10 => Self::AnyHit,
11 => Self::Intersection,
_ => panic!("can't convert ShaderType from {}", value),
}
}
} }
impl Default for ShaderType { impl Default for ShaderType {