Browse Source

chore: Uniform -> Self

pull/43/head
Natasha England-Elbro 11 months ago
parent
commit
44e3850bb1
No known key found for this signature in database
GPG Key ID: 46F323AE9236FD6A
  1. 28
      citro3d/src/uniform.rs

28
citro3d/src/uniform.rs

@ -43,23 +43,23 @@ impl Uniform {
// these indexes are from the uniform table in the shader see: https://www.3dbrew.org/wiki/SHBIN#Uniform_Table_Entry // these indexes are from the uniform table in the shader see: https://www.3dbrew.org/wiki/SHBIN#Uniform_Table_Entry
// the input registers then are excluded by libctru, see: https://github.com/devkitPro/libctru/blob/0da8705527f03b4b08ff7fee4dd1b7f28df37905/libctru/source/gpu/shbin.c#L93 // the input registers then are excluded by libctru, see: https://github.com/devkitPro/libctru/blob/0da8705527f03b4b08ff7fee4dd1b7f28df37905/libctru/source/gpu/shbin.c#L93
match self { match self {
Uniform::Float(_) | Uniform::Float2(_) | Uniform::Float3(_) | Uniform::Float4(_) => { Self::Float(_) | Self::Float2(_) | Self::Float3(_) | Self::Float4(_) => {
Index(0)..Index(0x60) Index(0)..Index(0x60)
} }
Uniform::Int(_) => Index(0x60)..Index(0x64), Self::Int(_) => Index(0x60)..Index(0x64),
// this gap is intentional // this gap is intentional
Uniform::Bool(_) => Index(0x68)..Index(0x79), Self::Bool(_) => Index(0x68)..Index(0x79),
} }
} }
/// Get length of uniform, i.e. how many registers it will write to /// Get length of uniform, i.e. how many registers it will write to
#[allow(clippy::len_without_is_empty)] // is_empty doesn't make sense here #[allow(clippy::len_without_is_empty)] // is_empty doesn't make sense here
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
match self { match self {
Uniform::Float(_) => 1, Self::Float(_) => 1,
Uniform::Float2(_) => 2, Self::Float2(_) => 2,
Uniform::Float3(_) => 3, Self::Float3(_) => 3,
Uniform::Float4(_) => 4, Self::Float4(_) => 4,
Uniform::Bool(_) | Uniform::Int(_) => 1, Self::Bool(_) | Uniform::Int(_) => 1,
} }
} }
@ -91,10 +91,10 @@ impl Uniform {
} }
}; };
match self { match self {
Uniform::Bool(b) => unsafe { Self::Bool(b) => unsafe {
citro3d_sys::C3D_BoolUnifSet(ty.into(), index.into(), b); citro3d_sys::C3D_BoolUnifSet(ty.into(), index.into(), b);
}, },
Uniform::Int(i) => unsafe { Self::Int(i) => unsafe {
citro3d_sys::C3D_IVUnifSet( citro3d_sys::C3D_IVUnifSet(
ty.into(), ty.into(),
index.into(), index.into(),
@ -104,12 +104,12 @@ impl Uniform {
i.w() as i32, i.w() as i32,
); );
}, },
Uniform::Float(f) => set_fvs(&[f]), Self::Float(f) => set_fvs(&[f]),
Uniform::Float2(fs) => { Self::Float2(fs) => {
set_fvs(&fs); set_fvs(&fs);
} }
Uniform::Float3(fs) => set_fvs(&fs), Self::Float3(fs) => set_fvs(&fs),
Uniform::Float4(m) => { Self::Float4(m) => {
set_fvs(&m.rows_wzyx()); set_fvs(&m.rows_wzyx());
} }
} }

Loading…
Cancel
Save