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