Skip to content

Commit

Permalink
Bevy 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed Feb 19, 2024
1 parent ffefe9f commit 23714ac
Show file tree
Hide file tree
Showing 9 changed files with 816 additions and 311 deletions.
1,051 changes: 782 additions & 269 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ members = [
resolver = "2"

[workspace.dependencies]
bevy = "0.12"
bevy = "0.13"
6 changes: 3 additions & 3 deletions bevy_nannou/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bevy::core_pipeline::clear_color::ClearColorConfig;
use bevy::prelude::shape::Torus;
use bevy::prelude::*;
use bevy_nannou::NannouPlugin;
Expand Down Expand Up @@ -34,11 +33,11 @@ fn startup(mut commands: Commands, assets: Res<AssetServer>, mut meshes: ResMut<
(Camera3dBundle {
camera: Camera {
hdr: false,
// TODO: we should manage this in the nannou plugin as function of backgrond color
clear_color: ClearColorConfig::None,
..Default::default()
},
camera_3d: Camera3d {
// TODO: we should manage this in the nannou plugin as function of backgrond color
clear_color: ClearColorConfig::None,
..Default::default()
},
transform: Transform::from_xyz(0.0, 0.0, -10.0).looking_at(Vec3::ZERO, Vec3::Z),
Expand Down Expand Up @@ -79,6 +78,7 @@ fn update_draw(

// TODO: why is the texture rotated?
// draw.texture(texture_handle.clone(), texture.clone());
draw.line_mode();
draw.ellipse().w_h(100.0, 100.0).color(SALMON);
draw.ellipse()
.x(100.0 + time.elapsed().as_millis() as f32 / 100.0)
Expand Down
19 changes: 8 additions & 11 deletions bevy_nannou_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::Deref;

use bevy::asset::load_internal_asset;
use bevy::core_pipeline::core_3d;
use bevy::core_pipeline::core_3d::CORE_3D;
use bevy::core_pipeline::core_3d::graph::{Core3d, Node3d};
use bevy::prelude::*;
use bevy::render::camera::{ExtractedCamera, NormalizedRenderTarget};
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
Expand Down Expand Up @@ -72,17 +72,14 @@ impl Plugin for NannouRenderPlugin {
)
// Register the NannouViewNode with the render graph
// The node runs at the last stage of the main 3d pass
.add_render_graph_node::<ViewNodeRunner<NannouViewNode>>(
core_3d::graph::NAME,
NannouViewNode::NAME,
)
.add_render_graph_node::<ViewNodeRunner<NannouViewNode>>(Core3d, NannouViewNode)
.add_render_graph_edges(
CORE_3D,
&[
core_3d::graph::node::MAIN_TRANSPARENT_PASS,
NannouViewNode::NAME,
core_3d::graph::node::END_MAIN_PASS,
],
Core3d,
(
Node3d::MainTransparentPass,
NannouViewNode,
Node3d::EndMainPass,
),
);
}

Expand Down
22 changes: 9 additions & 13 deletions bevy_nannou_render/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ use std::ops::Deref;
use bevy::core::cast_slice;
use bevy::ecs::query::QueryItem;
use bevy::prelude::*;
use bevy::render::render_graph::{NodeRunError, RenderGraphContext, ViewNode};
use bevy::render::render_graph::{NodeRunError, RenderGraphContext, RenderLabel, ViewNode};
use bevy::render::render_resource as wgpu;
use bevy::render::render_resource::{
BufferInitDescriptor, LoadOp, Operations, PipelineCache, RenderPassDescriptor,
RenderPipelineDescriptor, SpecializedRenderPipeline,
};
use bevy::render::render_resource::{BufferInitDescriptor, LoadOp, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, SpecializedRenderPipeline, StoreOp};
use bevy::render::renderer::{RenderContext, RenderDevice};
use bevy::render::view::{ViewDepthTexture, ViewTarget, ViewUniform, ViewUniformOffset};
use bevy_nannou_draw::draw::mesh;
Expand Down Expand Up @@ -157,7 +154,7 @@ impl NannouPipeline {
false,
wgpu::TextureViewDimension::D2,
wgpu::TextureFormat::R8Unorm
.sample_type(None)
.sample_type(None, None)
.expect("Expected format to have sample type"),
)
.build(device)
Expand Down Expand Up @@ -273,6 +270,7 @@ impl FromWorld for NannouPipeline {
#[derive(Resource, Deref, DerefMut, Default)]
pub struct TextureBindGroupCache(HashMap<Handle<Image>, wgpu::BindGroup>);

#[derive(RenderLabel, Hash, PartialEq, Eq, Clone, Debug)]
pub struct NannouViewNode;

impl NannouViewNode {
Expand Down Expand Up @@ -350,21 +348,19 @@ impl ViewNode for NannouViewNode {
usage: wgpu::BufferUsages::INDEX,
});

// Create render pass builder.
let render_pass_descriptor = RenderPassDescriptor {
label: None,
color_attachments: &[Some(target.get_color_attachment(Operations {
load: LoadOp::Load,
store: true,
}))],
color_attachments: &[Some(target.get_color_attachment())],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &depth.view,
view: &depth.view(),
depth_ops: Some(Operations {
load: LoadOp::Clear(0.0),
store: false,
store: StoreOp::Discard,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
};
let mut render_pass = render_context.begin_tracked_render_pass(render_pass_descriptor);

Expand Down
2 changes: 1 addition & 1 deletion bevy_nannou_wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
[dependencies]
bevy = { workspace = true }
# We use bevy's mirrored wgpu types almost always, but in a few rare cases, we need to use wgpu types directly
wgpu-types = "0.17"
wgpu-types = "0.19"
6 changes: 1 addition & 5 deletions bevy_nannou_wgpu/src/bind_group_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ impl BindGroupLayoutBuilder {
}

let label = Some("nannou bind group layout");
let desc = wgpu::BindGroupLayoutDescriptor {
label,
entries: &entries,
};
device.create_bind_group_layout(&desc)
device.create_bind_group_layout(label, &entries)
}
}

Expand Down
17 changes: 10 additions & 7 deletions bevy_nannou_wgpu/src/render_pass.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bevy::prelude::*;
use bevy::render::render_phase::TrackedRenderPass;
use bevy::render::render_resource as wgpu;
use bevy::render::render_resource::StoreOp;
use bevy::render::renderer::RenderContext;
use wgpu_types::Color;

Expand Down Expand Up @@ -36,7 +37,7 @@ impl<'a> ColorAttachmentDescriptorBuilder<'a> {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(Color::TRANSPARENT),
store: true,
store: StoreOp::Store,
},
},
}
Expand Down Expand Up @@ -70,11 +71,11 @@ impl<'a> ColorAttachmentDescriptorBuilder<'a> {
impl<'a> DepthStencilAttachmentDescriptorBuilder<'a> {
pub const DEFAULT_DEPTH_LOAD_OP: wgpu::LoadOp<f32> =
wgpu::LoadOp::Clear(Self::DEFAULT_CLEAR_DEPTH);
pub const DEFAULT_DEPTH_STORE_OP: bool = true;
pub const DEFAULT_DEPTH_STORE_OP: StoreOp = StoreOp::Store;
pub const DEFAULT_CLEAR_DEPTH: f32 = 1.0;
pub const DEFAULT_STENCIL_LOAD_OP: wgpu::LoadOp<u32> =
wgpu::LoadOp::Clear(Self::DEFAULT_CLEAR_STENCIL);
pub const DEFAULT_STENCIL_STORE_OP: bool = true;
pub const DEFAULT_STENCIL_STORE_OP: StoreOp = StoreOp::Store;
pub const DEFAULT_CLEAR_STENCIL: u32 = 0;

fn new(attachment: &'a wgpu::TextureView) -> Self {
Expand Down Expand Up @@ -103,7 +104,7 @@ impl<'a> DepthStencilAttachmentDescriptorBuilder<'a> {
}

/// The end-of-pass store operation for this depth attachment.
pub fn depth_store_op(mut self, store: bool) -> Self {
pub fn depth_store_op(mut self, store: StoreOp) -> Self {
self.descriptor.depth_ops = Some(wgpu::Operations {
load: self.descriptor.depth_ops.expect("no depth ops field").load,
store,
Expand All @@ -125,7 +126,7 @@ impl<'a> DepthStencilAttachmentDescriptorBuilder<'a> {
}

/// The end-of-pass store operation for this stencil attachment.
pub fn stencil_store_op(mut self, store: bool) -> Self {
pub fn stencil_store_op(mut self, store: StoreOp) -> Self {
self.descriptor.stencil_ops = Some(wgpu::Operations {
load: self
.descriptor
Expand All @@ -145,13 +146,13 @@ impl<'a> RenderPassBuilder<'a> {
pub const DEFAULT_CLEAR_COLOR: Color = ColorAttachmentDescriptorBuilder::DEFAULT_CLEAR_COLOR;
pub const DEFAULT_DEPTH_LOAD_OP: wgpu::LoadOp<f32> =
DepthStencilAttachmentDescriptorBuilder::DEFAULT_DEPTH_LOAD_OP;
pub const DEFAULT_DEPTH_STORE_OP: bool =
pub const DEFAULT_DEPTH_STORE_OP: StoreOp =
DepthStencilAttachmentDescriptorBuilder::DEFAULT_DEPTH_STORE_OP;
pub const DEFAULT_CLEAR_DEPTH: f32 =
DepthStencilAttachmentDescriptorBuilder::DEFAULT_CLEAR_DEPTH;
pub const DEFAULT_STENCIL_LOAD_OP: wgpu::LoadOp<u32> =
DepthStencilAttachmentDescriptorBuilder::DEFAULT_STENCIL_LOAD_OP;
pub const DEFAULT_STENCIL_STORE_OP: bool =
pub const DEFAULT_STENCIL_STORE_OP: StoreOp =
DepthStencilAttachmentDescriptorBuilder::DEFAULT_STENCIL_STORE_OP;
pub const DEFAULT_CLEAR_STENCIL: u32 =
DepthStencilAttachmentDescriptorBuilder::DEFAULT_CLEAR_STENCIL;
Expand Down Expand Up @@ -219,6 +220,8 @@ impl<'a> RenderPassBuilder<'a> {
label: Some("nannou_render_pass"),
color_attachments: &color_attachments,
depth_stencil_attachment,
timestamp_writes: None,
occlusion_query_set: None,
};
render_context.begin_tracked_render_pass(descriptor)
}
Expand Down
2 changes: 1 addition & 1 deletion nannou_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage = "https://nannou.cc"
edition = "2018"

[dependencies]
glam = { version = "0.24.2", default-features = false, features = ["rand"] }
glam = { version = "0.25.0", default-features = false, features = ["rand"] }
# TODO: Awaiting `no-std` to be published.
# noise = 0.6
num-traits = { version = "0.2.14", default-features = false }
Expand Down

0 comments on commit 23714ac

Please sign in to comment.