EmbarkStudios / physx-rs

🎳 Rust binding for NVIDIA PhysX 🦀

Home Page:http://embark.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reevaluate structgen

Jake-Shadle opened this issue · comments

The goal of structgen is to output bit compatible C and Rust structs that can be marshalled over FFI via simple memcopies (which end up as nops). Right now we both check in the pre-generated sources for these for tier 1 platforms and aarch64-linux-android, with the option to regenerate them during compilation if using a compiler/target without pre-generated sources.

However, this is kind of overkill. For example, with #183 here is a diff between the x86_64-unknown-linux and aarch64-apple-darwin generated rust structs

-pub structgen_pad0: [u8; 8],
+pub structgen_pad0: [u8; 1],
-assert_eq!(size_of::<PxSIMDGuard>(), 8);
+assert_eq!(size_of::<PxSIMDGuard>(), 1);

That's...it. One struct, which is the only struct that we emit that has different fields depending on the target

  private:
#if !(PX_LINUX || PX_OSX) || (!PX_EMSCRIPTEN && PX_INTEL_FAMILY)
  PxU32			mControlWord;
  bool			mEnabled;
#endif

The thing is, we don't even need to emit this type at all because it's not part of the public API, which would give us rust and cpp layouts that are the exact same between x86_64 and aarch64, across targets...other than windows, but meh that can still be its own thing.

Actually nvm, just nuked the unnecessary duplicates in #183