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

[Merged by Bors] - improve compile time by type-erasing wgpu structs #5950

Closed
wants to merge 10 commits into from
Prev Previous commit
add send/sync bounds
  • Loading branch information
robtfm committed Nov 17, 2022
commit c4b7b4eb2e85223c9f786f4d883067fa1e62e5c0
15 changes: 15 additions & 0 deletions crates/bevy_render/src/render_resource/resource_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ macro_rules! render_resource_wrapper {
}
}
}

// Arc<Box<()>> and Arc<()> will be Sync and Send even when $wgpu_type is not Sync or Send.
// We ensure correctness by checking that $wgpu_type does implement Send and Sync.
// If in future there is a case where a wrapper is required for a non-send/sync type
// we can implement a macro variant that also does `impl !Send for $wrapper_type {}` and
// `impl !Sync for $wrapper_type {}`
const _: () = {
trait AssertSendSyncBound: Send + Sync {}
impl AssertSendSyncBound for $wgpu_type {}
};
};
}

Expand Down Expand Up @@ -102,6 +112,11 @@ macro_rules! render_resource_wrapper {
self.0.as_ref()
}
}

const _: () = {
trait AssertSendSyncBound: Send + Sync {}
impl AssertSendSyncBound for $wgpu_type {}
};
};
}

Expand Down