Closed ian-h-chamberlain closed 1 year ago
The way we safely expose Citro3D matrices depends a whole lot on how we're gonna let developers safely pass matrices as uniforms for vertex shaders... Uniforms are their whole can of worms...
Yeah, this will definitely take some thought. Ideally, I would love to use an existing Rust library for handling matrix math etc., but I'm sure there would be some runtime cost converting back and forth which would not be ideal (maybe could be a Cargo feature, for convenience at the cost of performance?).
Probably there would be similar concerns with some other Citro3D "math types" although there aren't too many of them.
Regarding uniforms, we might just be able to limit to the fairly small set of types defined by citro3d, and write wrappers just for those. I think it's probably out of scope to allow arbitrary writes to the uniform buffer (with C3D_FVUnifWritePtr
), so it maybe could even be a trait like
trait Uniform {}
impl Uniform for bool {}
impl Uniform for (i32, i32, i32, i32) {} // ivec4
impl<const N: usize> Uniform for SafeMatrix4Wrapper<N> {} // or whatever matrix type we use
Mostly done in #27 although there may be some room for improvement on the uniform handling. I think I'll close this for now, and track any further changes in separate issues as they come up.