Skip to content

Commit

Permalink
feat: reenable with_bevy package demo as bevy 0.12 now supports wgpu …
Browse files Browse the repository at this point in the history
…0.17, update with_bevy demo to support bevy 0.12
  • Loading branch information
nixon-voxell committed Nov 5, 2023
1 parent 9375a52 commit 8ff303d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [

"examples/headless",
"examples/with_winit",
"examples/with_bevy", # Disable for now until bevy is using wgpu 0.17
"examples/with_bevy",
"examples/run_wasm",
"examples/scenes",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/with_bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { git = "https://github.com/bevyengine/bevy", rev = "7ca0a307f6d6277168a5e77f3b15fbeefbaf478e" }
bevy = "0.12"
vello = { path = "../../" }
17 changes: 12 additions & 5 deletions examples/with_bevy/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::render::{Render, RenderSet};
use vello::kurbo::{Affine, Point, Rect};
use vello::peniko::{Color, Fill, Gradient, Stroke};
use vello::kurbo::{Affine, Point, Rect, Stroke};
use vello::peniko::{Color, Fill, Gradient};
use vello::{Renderer, RendererOptions, Scene, SceneBuilder, SceneFragment};

use bevy::{
Expand All @@ -19,6 +19,8 @@ use bevy::{
#[derive(Resource)]
struct VelloRenderer(Renderer);

unsafe impl Sync for VelloRenderer {}

impl FromWorld for VelloRenderer {
fn from_world(world: &mut World) -> Self {
let device = world.resource::<RenderDevice>();
Expand All @@ -27,10 +29,11 @@ impl FromWorld for VelloRenderer {
VelloRenderer(
Renderer::new(
device.wgpu_device(),
&RendererOptions {
RendererOptions {
surface_format: None,
timestamp_period: queue.0.get_timestamp_period(),
antialiasing_support: vello::AaSupport::area_only(),
use_cpu: false,
},
)
.unwrap(),
Expand All @@ -42,13 +45,17 @@ struct VelloPlugin;

impl Plugin for VelloPlugin {
fn build(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};
// This should probably use the render graph, but working out the dependencies there is awkward
render_app.add_systems(Render, render_scenes.in_set(RenderSet::Render));
}

fn finish(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};
render_app.init_resource::<VelloRenderer>();
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/wgpu_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ struct BindMapBuffer {
label: &'static str,
}

// Prevent Bevy from complaining when used as a resource
unsafe impl Sync for BindMapBuffer {}

#[derive(Default)]
struct BindMap {
buf_map: HashMap<Id, BindMapBuffer>,
Expand Down

0 comments on commit 8ff303d

Please sign in to comment.