Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up rkyv serialization #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bounding_volume/simd_aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use simba::simd::{SimdPartialOrd, SimdValue};
#[derive(Debug, Copy, Clone)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize),
)]
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
pub struct SimdAabb {
Expand Down
1 change: 1 addition & 0 deletions src/partitioning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub use self::qbvh::{
};
pub use self::qbvh::{
GenericQbvh, IndexedData, NodeIndex, Qbvh, QbvhNode, QbvhProxy, QbvhStorage, SimdNodeIndex,
QbvhNodeFlags,
};
#[cfg(feature = "parallel")]
pub use self::visitor::{ParallelSimdSimultaneousVisitor, ParallelSimdVisitor};
Expand Down
9 changes: 7 additions & 2 deletions src/partitioning/qbvh/qbvh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bitflags! {
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
#[derive(Default)]
/// The status of a QBVH node.
pub struct QbvhNodeFlags: u8 {
pub struct QbvhNodeFlags: u64 {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular change is the one I wanted to highlight / discuss.

/// If this bit is set, the node is a leaf.
const LEAF = 0b0001;
/// If this bit is set, this node was recently changed.
Expand All @@ -115,9 +115,10 @@ bitflags! {
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize),
)]
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
#[repr(C)]
pub struct QbvhNode {
/// The Aabbs of the qbvh nodes represented by this node.
pub simd_aabb: SimdAabb,
Expand Down Expand Up @@ -234,9 +235,13 @@ impl<LeafData> QbvhProxy<LeafData> {
#[derive(Debug)]
pub struct GenericQbvh<LeafData, Storage: QbvhStorage<LeafData>> {
pub(super) root_aabb: Aabb,
#[cfg_attr(feature = "rkyv", with(rkyv::with::CopyOptimize))]
pub(super) nodes: Storage::Nodes,
#[cfg_attr(feature = "rkyv", with(rkyv::with::CopyOptimize))]
pub(super) dirty_nodes: Storage::ArrayU32,
#[cfg_attr(feature = "rkyv", with(rkyv::with::CopyOptimize))]
pub(super) free_list: Storage::ArrayU32,
#[cfg_attr(feature = "rkyv", with(rkyv::with::CopyOptimize))]
pub(super) proxies: Storage::ArrayProxies,
}

Expand Down
2 changes: 2 additions & 0 deletions src/shape/trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ bitflags::bitflags! {
/// A triangle mesh.
pub struct GenericTriMesh<Storage: TriMeshStorage> {
qbvh: GenericQbvh<u32, Storage::QbvhStorage>,
#[cfg_attr(feature = "rkyv", with(rkyv::with::CopyOptimize))]
vertices: Storage::ArrayPoint,
#[cfg_attr(feature = "rkyv", with(rkyv::with::CopyOptimize))]
indices: Storage::ArrayIdx,
#[cfg(feature = "dim3")]
pub(crate) pseudo_normals: Option<TriMeshPseudoNormals<Storage>>,
Expand Down