Skip to content

Commit

Permalink
Test that Renderer + Scene are Send. (#556)
Browse files Browse the repository at this point in the history
Test that `Renderer` is `Send`, `Scene` is `Send` + `Sync`.

The `Renderer` will no be `Send` on wasm32 targets due to
differences in the underlying `wgpu` library (unless a
feature is enabled for `wgpu`).

Usages within Bevy and other frameworks are simpler when these
types are `Send`.
  • Loading branch information
waywardmonkeys authored Apr 25, 2024
1 parent 23ac080 commit d36f2e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ peniko = { workspace = true }
wgpu = { workspace = true, optional = true }
log = { workspace = true }
raw-window-handle = { workspace = true }
static_assertions = { workspace = true }
futures-intrusive = { workspace = true }
wgpu-profiler = { workspace = true, optional = true }

Expand All @@ -76,6 +77,7 @@ peniko = "0.1.0"
futures-intrusive = "0.5.0"
raw-window-handle = "0.6.0"
smallvec = "1.13.2"
static_assertions = "1.1.0"

# NOTE: Make sure to keep this in sync with the version badge in README.md
wgpu = { version = "0.19.3" }
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ pub struct Renderer {
#[cfg(feature = "wgpu-profiler")]
pub profile_result: Option<Vec<wgpu_profiler::GpuTimerQueryResult>>,
}
// This is not `Send` (or `Sync`) on WebAssembly as the
// underlying wgpu types are not. This can be enabled with the
// `fragile-send-sync-non-atomic-wasm` feature in wgpu.
// See https://github.com/gfx-rs/wgpu/discussions/4127 for
// further discussion of this topic.
#[cfg(all(feature = "wgpu", not(target_arch = "wasm32")))]
static_assertions::assert_impl_all!(Renderer: Send);

/// Parameters used in a single render that are configurable by the client.
pub struct RenderParams {
Expand Down
1 change: 1 addition & 0 deletions src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Scene {
#[cfg(feature = "bump_estimate")]
estimator: vello_encoding::BumpEstimator,
}
static_assertions::assert_impl_all!(Scene: Send, Sync);

impl Scene {
/// Creates a new scene.
Expand Down

0 comments on commit d36f2e6

Please sign in to comment.