bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Faster MeshletMesh deserialization

Open JMS55 opened this issue 1 year ago • 0 comments

Objective

  • Using bincode to deserialize binary into a MeshletMesh is expensive (~77ms for a 5mb file).

Solution

  • Write a custom deserializer using bytemuck's Pod types and slice casting.
    • Total asset load time has gone from ~102ms to ~12ms.
  • Change some types I never meant to be public to private and other misc cleanup.

Testing

  • Ran the meshlet example and added timing spans to the asset loader.

Changelog

  • Improved MeshletMesh loading speed
  • The MeshletMesh disk format has changed, and MESHLET_MESH_ASSET_VERSION has been bumped
  • MeshletMesh fields are now private
  • Renamed MeshletMeshSaverLoad to MeshletMeshSaverLoader
  • The Meshlet, MeshletBoundingSpheres, and MeshletBoundingSphere types are now private
  • Removed MeshletMeshSaveOrLoadError::SerializationOrDeserialization
  • Added MeshletMeshSaveOrLoadError::WrongFileType

Migration Guide

  • Regenerate your MeshletMesh assets, as the disk format has changed, and MESHLET_MESH_ASSET_VERSION has been bumped
  • MeshletMesh fields are now private
  • MeshletMeshSaverLoad is now named MeshletMeshSaverLoader
  • The Meshlet, MeshletBoundingSpheres, and MeshletBoundingSphere types are now private
  • MeshletMeshSaveOrLoadError::SerializationOrDeserialization has been removed
  • Added MeshletMeshSaveOrLoadError::WrongFileType, match on this variant if you match on MeshletMeshSaveOrLoadError

JMS55 avatar Jul 06 '24 18:07 JMS55