fu5ha / ultraviolet

A wide linear algebra crate for games and graphics.
https://crates.io/crates/ultraviolet
750 stars 81 forks source link

rkyv support #165

Open stefnotch opened 1 year ago

stefnotch commented 1 year ago

I was wondering if you'd consider adding rkyv support to this library, of course behind a feature flag?

Hopefully all that would need to be done is deriving the types, and everything works. I would also prepare a PR with that if wanted.

fu5ha commented 1 year ago

Hey, yes I would definitely consider it. Some care would need to be taken though or it might be a bit of a waste... I think ideally, when the rkyv feature flag is enabled all the types would have their <T as rkyv::Archive>::Archived type be Self. That way you could do math operations directly on the loaded archived form. Otherwise if you have to deserialize to actually do anything it would be a bit of a waste of rkyv's power.

To accomplish that properly we'd need to also add #[repr(C)] on things when the rkyv feature is on and maybe even add support to the underlying vector types in wide, if we want to support simd wide vectors too.

stefnotch commented 1 year ago

Hey, yes I would definitely consider it. Some care would need to be taken though or it might be a bit of a waste... I think ideally, when the rkyv feature flag is enabled all the types would have their <T as rkyv::Archive>::Archived type be Self. That way you could do math operations directly on the loaded archived form.

That would definitely be awesome. I'm not certain if that's fully possible at the moment, due to endian-ness https://github.com/rkyv/rkyv/issues/292 . (And sadly the official documentation chapter 18.1. Impl duplication hasn't been written yet either https://rkyv.org/ )