Browse Source

fix: warning and docs

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

12
citro3d/src/uniform.rs

@ -22,17 +22,23 @@ impl From<Index> for i32 {
} }
} }
/// A shader uniform. This trait is implemented for types that can be bound to /// A uniform which may be bound as input to a shader program
/// shaders to be used as a uniform input to the shader.
pub enum Uniform { pub enum Uniform {
/// Single float uniform (`.fvec name`)
Float(FVec4), Float(FVec4),
/// Two element float uniform (`.fvec name[2]`)
Float2([FVec4; 2]), Float2([FVec4; 2]),
/// Three element float uniform (`.fvec name [3]`)
Float3([FVec4; 3]), Float3([FVec4; 3]),
/// Matrix/4 element float uniform (`.fvec name[4]`)
Float4(Matrix4), Float4(Matrix4),
/// Bool uniform (`.bool name`)
Bool(bool), Bool(bool),
/// Integer uniform (`.ivec name`)
Int(IVec), Int(IVec),
} }
impl Uniform { impl Uniform {
/// Get range of valid indexes for this uniform to bind to
pub fn index_range(&self) -> Range<Index> { pub fn index_range(&self) -> Range<Index> {
// 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
@ -45,6 +51,8 @@ impl Uniform {
Uniform::Bool(_) => Index(0x68)..Index(0x79), Uniform::Bool(_) => Index(0x68)..Index(0x79),
} }
} }
/// 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
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
match self { match self {
Uniform::Float(_) => 1, Uniform::Float(_) => 1,

Loading…
Cancel
Save