From d76b2b032e7f113206abb8443a4c61eb7f3349a7 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sun, 26 Jan 2020 21:44:01 -0800 Subject: [PATCH] entity uniforms kind of work in the new render graph but only the last entity because they all use the same buffer --- .vscode/launch.json | 14 +- examples/entity_builder_comparison.rs | 8 +- .../plugin_loading/example_plugin/src/lib.rs | 8 +- examples/simple.rs | 8 +- examples/simple_new_graph.rs | 33 +- src/app/app.rs | 6 +- src/app/app_builder.rs | 3 +- src/ecs/entity_builder.rs | 2 +- src/render/render_graph_2/draw_target.rs | 4 +- src/render/render_graph_2/mod.rs | 2 +- src/render/render_graph_2/pipeline_layout.rs | 28 +- .../pipelines/forward/forward.frag | 6 +- .../pipelines/forward/forward.vert | 9 +- .../render_graph_2/pipelines/forward/mod.rs | 18 +- src/render/render_graph_2/renderer.rs | 13 +- src/render/render_graph_2/resource.rs | 4 + src/render/render_graph_2/shader.rs | 100 +++++-- src/render/render_graph_2/wgpu_renderer.rs | 281 +++++++++++++----- 18 files changed, 395 insertions(+), 152 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9843459763..7437063d50 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -26,15 +26,15 @@ { "type": "lldb", "request": "launch", - "name": "Debug example 'simple'", + "name": "Build and launch example", "cargo": { "args": [ "build", - "--example=simple", + "--example=simple_new_graph", "--package=bevy" ], "filter": { - "name": "simple", + "name": "simple_new_graph", "kind": "example" } }, @@ -44,13 +44,13 @@ { "type": "lldb", "request": "launch", - "name": "Debug unit tests in example 'simple'", + "name": "Launch example", "cargo": { "args": [ - "test", - "--no-run", + "run", "--example=simple", - "--package=bevy" + "--package=bevy", + "--release" ], "filter": { "name": "simple", diff --git a/examples/entity_builder_comparison.rs b/examples/entity_builder_comparison.rs index 651a0680ff..a07f5f6e33 100644 --- a/examples/entity_builder_comparison.rs +++ b/examples/entity_builder_comparison.rs @@ -120,21 +120,21 @@ fn create_entities_builder_add_component(world: &mut World, plane_handle: Handle fn create_entities_builder_archetype(world: &mut World, plane_handle: Handle, cube_handle: Handle) { world.build() // plane - .build_archetype(MeshEntity { + .add_archetype(MeshEntity { mesh: plane_handle.clone(), material: Material::new(Albedo::Color(math::vec4(0.1, 0.2, 0.1, 1.0))), local_to_world: LocalToWorld::identity(), translation: Translation::new(0.0, 0.0, 0.0), }) // cube - .build_archetype(MeshEntity { + .add_archetype(MeshEntity { mesh: cube_handle, material: Material::new(Albedo::Color(math::vec4(0.5, 0.3, 0.3, 1.0))), local_to_world: LocalToWorld::identity(), translation: Translation::new(0.0, 0.0, 1.0), }) // light - .build_archetype(LightEntity { + .add_archetype(LightEntity { light: Light { color: wgpu::Color { r: 0.8, @@ -151,7 +151,7 @@ fn create_entities_builder_archetype(world: &mut World, plane_handle: Handle, + uniform_selector::, + ] }, local_to_world: LocalToWorld::identity(), translation: Translation::new(0.0, 0.0, 1.0), }) + // .add_archetype(NewMeshEntity { + // mesh: cube_handle.clone(), + // material: StandardMaterial { + // albedo: math::vec4(0.0, 1.0, 0.0, 1.0), + // }, + // shader_uniforms: ShaderUniforms { + // uniform_selectors: vec![ + // uniform_selector::, + // uniform_selector::, + // ] + // }, + // local_to_world: LocalToWorld::identity(), + // translation: Translation::new(-2.0, 0.0, 1.0), + // }) // light - // .build_archetype(LightEntity { + // .add_archetype(LightEntity { // light: Light { // color: wgpu::Color { // r: 0.8, @@ -54,7 +69,7 @@ fn setup(world: &mut World) { // rotation: Rotation::from_euler_angles(0.0, 0.0, 0.0), // }) // camera - .build_archetype(CameraEntity { + .add_archetype(CameraEntity { camera: Camera::new(CameraType::Projection { fov: std::f32::consts::PI / 4.0, near: 1.0, diff --git a/src/app/app.rs b/src/app/app.rs index d04185bb8e..8f433fba46 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -52,7 +52,7 @@ impl App { } if let Some(ref mut renderer) = self.renderer { - renderer.process_render_graph(&self.render_graph, &mut self.world); + renderer.process_render_graph(&mut self.render_graph, &mut self.world); } if let Some(mut time) = self.world.resources.get_mut::