move SwizzleComponent impl into proc module

This commit is contained in:
Frizi
2021-06-17 21:18:12 +02:00
committed by Dzmitry Malyshau
parent 20c6fd1862
commit b439868c00
2 changed files with 21 additions and 26 deletions

View File

@@ -773,32 +773,6 @@ pub enum SwizzleComponent {
W = 3,
}
impl SwizzleComponent {
pub const XYZW: [SwizzleComponent; 4] = [
SwizzleComponent::X,
SwizzleComponent::Y,
SwizzleComponent::Z,
SwizzleComponent::W,
];
pub fn index(&self) -> u32 {
match *self {
SwizzleComponent::X => 0,
SwizzleComponent::Y => 1,
SwizzleComponent::Z => 2,
SwizzleComponent::W => 3,
}
}
pub fn from_index(idx: u32) -> Self {
match idx {
0 => SwizzleComponent::X,
1 => SwizzleComponent::Y,
2 => SwizzleComponent::Z,
_ => SwizzleComponent::W,
}
}
}
bitflags::bitflags! {
/// Memory barrier flags.
#[cfg_attr(feature = "serialize", derive(Serialize))]

View File

@@ -267,3 +267,24 @@ impl std::hash::Hash for crate::ScalarValue {
}
}
}
impl super::SwizzleComponent {
pub const XYZW: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
pub fn index(&self) -> u32 {
match *self {
Self::X => 0,
Self::Y => 1,
Self::Z => 2,
Self::W => 3,
}
}
pub fn from_index(idx: u32) -> Self {
match idx {
0 => Self::X,
1 => Self::Y,
2 => Self::Z,
_ => Self::W,
}
}
}