diff --git a/Cargo.toml b/Cargo.toml index 476fa13047cc5..84b9e1d5455e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ members = ["crates/*", "pipelined/*", "examples/ios", "tools/ci"] [features] default = [ "bevy_audio", + "bevy_core_pipeline", "bevy_dynamic_plugin", "bevy_gilrs", "bevy_gltf", @@ -51,6 +52,7 @@ bevy_gltf = ["bevy_internal/bevy_gltf"] bevy_wgpu = ["bevy_internal/bevy_wgpu"] bevy_winit = ["bevy_internal/bevy_winit"] +bevy_core_pipeline = ["bevy_internal/bevy_core_pipeline"] bevy_render2 = ["bevy_internal/bevy_render2"] bevy_sprite2 = ["bevy_internal/bevy_sprite2"] bevy_pbr2 = ["bevy_internal/bevy_pbr2"] diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index b745c40f34fa5..036a053df4bee 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -66,6 +66,7 @@ bevy_window = { path = "../bevy_window", version = "0.5.0" } bevy_tasks = { path = "../bevy_tasks", version = "0.5.0" } # bevy (optional) bevy_audio = { path = "../bevy_audio", optional = true, version = "0.5.0" } +bevy_core_pipeline = { path = "../../pipelined/bevy_core_pipeline", optional = true, version = "0.5.0" } bevy_gltf = { path = "../bevy_gltf", optional = true, version = "0.5.0" } bevy_pbr = { path = "../bevy_pbr", optional = true, version = "0.5.0" } bevy_pbr2 = { path = "../../pipelined/bevy_pbr2", optional = true, version = "0.5.0" } diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs index 19dac798b0210..6d506e5651b27 100644 --- a/crates/bevy_internal/src/default_plugins.rs +++ b/crates/bevy_internal/src/default_plugins.rs @@ -121,16 +121,20 @@ impl PluginGroup for PipelinedDefaultPlugins { #[cfg(feature = "bevy_render2")] { group.add(bevy_render2::RenderPlugin::default()); - group.add(bevy_render2::core_pipeline::CorePipelinePlugin::default()); } - #[cfg(feature = "bevy_winit")] - group.add(bevy_winit::WinitPlugin::default()); + #[cfg(feature = "bevy_core_pipeline")] + { + group.add(bevy_core_pipeline::CorePipelinePlugin::default()); - #[cfg(feature = "bevy_sprite2")] - group.add(bevy_sprite2::SpritePlugin::default()); + #[cfg(feature = "bevy_sprite2")] + group.add(bevy_sprite2::SpritePlugin::default()); - #[cfg(feature = "bevy_pbr2")] - group.add(bevy_pbr2::PbrPlugin::default()); + #[cfg(feature = "bevy_pbr2")] + group.add(bevy_pbr2::PbrPlugin::default()); + } + + #[cfg(feature = "bevy_winit")] + group.add(bevy_winit::WinitPlugin::default()); } } diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs index 081ef2879defc..a47ee1984062a 100644 --- a/crates/bevy_internal/src/lib.rs +++ b/crates/bevy_internal/src/lib.rs @@ -82,6 +82,12 @@ pub mod audio { pub use bevy_audio::*; } +#[cfg(feature = "bevy_core_pipeline")] +pub mod core_pipeline { + //! Core render pipeline. + pub use bevy_core_pipeline::*; +} + #[cfg(feature = "bevy_gilrs")] pub mod gilrs { pub use bevy_gilrs::*; diff --git a/pipelined/bevy_core_pipeline/Cargo.toml b/pipelined/bevy_core_pipeline/Cargo.toml new file mode 100644 index 0000000000000..539816e466b03 --- /dev/null +++ b/pipelined/bevy_core_pipeline/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "bevy_core_pipeline" +version = "0.5.0" +edition = "2018" +authors = [ + "Bevy Contributors ", + "Carter Anderson ", +] +description = "Provides a core render pipeline for Bevy Engine." +homepage = "https://bevyengine.org" +repository = "https://github.com/bevyengine/bevy" +license = "MIT OR Apache-2.0" +keywords = ["bevy"] + +[dependencies] +# bevy +bevy_app = { path = "../../crates/bevy_app", version = "0.5.0" } +bevy_ecs = { path = "../../crates/bevy_ecs", version = "0.5.0" } +bevy_render2 = { path = "../bevy_render2", version = "0.5.0" } + diff --git a/pipelined/bevy_render2/src/core_pipeline/mod.rs b/pipelined/bevy_core_pipeline/src/lib.rs similarity index 97% rename from pipelined/bevy_render2/src/core_pipeline/mod.rs rename to pipelined/bevy_core_pipeline/src/lib.rs index 45bb313b6f23a..51012767332da 100644 --- a/pipelined/bevy_render2/src/core_pipeline/mod.rs +++ b/pipelined/bevy_core_pipeline/src/lib.rs @@ -6,19 +6,21 @@ pub use main_pass_2d::*; pub use main_pass_3d::*; pub use main_pass_driver::*; -use crate::{ +use bevy_app::{App, Plugin}; +use bevy_ecs::prelude::*; +use bevy_render2::{ camera::{ActiveCameras, CameraPlugin}, render_graph::{EmptyNode, RenderGraph, SlotInfo, SlotType}, render_phase::{sort_phase_system, RenderPhase}, - render_resource::{Texture, TextureView}, + render_resource::{ + Extent3d, Texture, TextureDescriptor, TextureDimension, TextureFormat, TextureUsage, + TextureView, + }, renderer::RenderDevice, texture::TextureCache, view::{ExtractedView, ViewPlugin}, RenderStage, }; -use bevy_app::{App, Plugin}; -use bevy_ecs::prelude::*; -use wgpu::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsage}; // Plugins that contribute to the RenderGraph should use the following label conventions: // 1. Graph modules should have a NAME, input module, and node module (where relevant) diff --git a/pipelined/bevy_render2/src/core_pipeline/main_pass_2d.rs b/pipelined/bevy_core_pipeline/src/main_pass_2d.rs similarity index 94% rename from pipelined/bevy_render2/src/core_pipeline/main_pass_2d.rs rename to pipelined/bevy_core_pipeline/src/main_pass_2d.rs index 969f0c7663200..50f91bdb9785f 100644 --- a/pipelined/bevy_render2/src/core_pipeline/main_pass_2d.rs +++ b/pipelined/bevy_core_pipeline/src/main_pass_2d.rs @@ -1,13 +1,13 @@ -use crate::{ +use crate::Transparent2dPhase; +use bevy_ecs::prelude::*; +use bevy_render2::{ color::Color, - core_pipeline::Transparent2dPhase, render_graph::{Node, NodeRunError, RenderGraphContext, SlotInfo, SlotType}, render_phase::{DrawFunctions, RenderPhase, TrackedRenderPass}, + render_resource::{LoadOp, Operations, RenderPassColorAttachment, RenderPassDescriptor}, renderer::RenderContext, view::ExtractedView, }; -use bevy_ecs::prelude::*; -use wgpu::{LoadOp, Operations, RenderPassColorAttachment, RenderPassDescriptor}; pub struct MainPass2dNode { query: QueryState<&'static RenderPhase, With>, diff --git a/pipelined/bevy_render2/src/core_pipeline/main_pass_3d.rs b/pipelined/bevy_core_pipeline/src/main_pass_3d.rs similarity index 93% rename from pipelined/bevy_render2/src/core_pipeline/main_pass_3d.rs rename to pipelined/bevy_core_pipeline/src/main_pass_3d.rs index c772fb654786e..c561bac2f3981 100644 --- a/pipelined/bevy_render2/src/core_pipeline/main_pass_3d.rs +++ b/pipelined/bevy_core_pipeline/src/main_pass_3d.rs @@ -1,16 +1,16 @@ -use crate::{ +use crate::Transparent3dPhase; +use bevy_ecs::prelude::*; +use bevy_render2::{ color::Color, - core_pipeline::Transparent3dPhase, render_graph::{Node, NodeRunError, RenderGraphContext, SlotInfo, SlotType}, render_phase::{DrawFunctions, RenderPhase, TrackedRenderPass}, + render_resource::{ + LoadOp, Operations, RenderPassColorAttachment, RenderPassDepthStencilAttachment, + RenderPassDescriptor, + }, renderer::RenderContext, view::ExtractedView, }; -use bevy_ecs::prelude::*; -use wgpu::{ - LoadOp, Operations, RenderPassColorAttachment, RenderPassDepthStencilAttachment, - RenderPassDescriptor, -}; pub struct MainPass3dNode { query: QueryState<&'static RenderPhase, With>, diff --git a/pipelined/bevy_render2/src/core_pipeline/main_pass_driver.rs b/pipelined/bevy_core_pipeline/src/main_pass_driver.rs similarity index 92% rename from pipelined/bevy_render2/src/core_pipeline/main_pass_driver.rs rename to pipelined/bevy_core_pipeline/src/main_pass_driver.rs index c4066fd1ed4c1..2e0736c3febb5 100644 --- a/pipelined/bevy_render2/src/core_pipeline/main_pass_driver.rs +++ b/pipelined/bevy_core_pipeline/src/main_pass_driver.rs @@ -1,11 +1,11 @@ -use crate::{ +use crate::ViewDepthTexture; +use bevy_ecs::world::World; +use bevy_render2::{ camera::{CameraPlugin, ExtractedCamera, ExtractedCameraNames}, - core_pipeline::{self, ViewDepthTexture}, render_graph::{Node, NodeRunError, RenderGraphContext, SlotValue}, renderer::RenderContext, view::ExtractedWindows, }; -use bevy_ecs::world::World; pub struct MainPassDriverNode; @@ -24,7 +24,7 @@ impl Node for MainPassDriverNode { let extracted_window = extracted_windows.get(&extracted_camera.window_id).unwrap(); let swap_chain_texture = extracted_window.swap_chain_frame.as_ref().unwrap().clone(); graph.run_sub_graph( - core_pipeline::draw_2d_graph::NAME, + crate::draw_2d_graph::NAME, vec![ SlotValue::Entity(*camera_2d), SlotValue::TextureView(swap_chain_texture), @@ -38,7 +38,7 @@ impl Node for MainPassDriverNode { let extracted_window = extracted_windows.get(&extracted_camera.window_id).unwrap(); let swap_chain_texture = extracted_window.swap_chain_frame.as_ref().unwrap().clone(); graph.run_sub_graph( - core_pipeline::draw_3d_graph::NAME, + crate::draw_3d_graph::NAME, vec![ SlotValue::Entity(*camera_3d), SlotValue::TextureView(swap_chain_texture), diff --git a/pipelined/bevy_pbr2/Cargo.toml b/pipelined/bevy_pbr2/Cargo.toml index 263089a07b91c..5f7f4e47b2dce 100644 --- a/pipelined/bevy_pbr2/Cargo.toml +++ b/pipelined/bevy_pbr2/Cargo.toml @@ -17,6 +17,7 @@ keywords = ["bevy"] bevy_app = { path = "../../crates/bevy_app", version = "0.5.0" } bevy_asset = { path = "../../crates/bevy_asset", version = "0.5.0" } bevy_core = { path = "../../crates/bevy_core", version = "0.5.0" } +bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.5.0" } bevy_ecs = { path = "../../crates/bevy_ecs", version = "0.5.0" } bevy_math = { path = "../../crates/bevy_math", version = "0.5.0" } bevy_reflect = { path = "../../crates/bevy_reflect", version = "0.5.0", features = ["bevy"] } diff --git a/pipelined/bevy_pbr2/src/lib.rs b/pipelined/bevy_pbr2/src/lib.rs index 02ecb7ae37b38..75561835d9a64 100644 --- a/pipelined/bevy_pbr2/src/lib.rs +++ b/pipelined/bevy_pbr2/src/lib.rs @@ -11,7 +11,6 @@ pub use render::*; use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_render2::{ - core_pipeline, render_graph::RenderGraph, render_phase::{sort_phase_system, DrawFunctions}, RenderStage, @@ -61,23 +60,23 @@ impl Plugin for PbrPlugin { let mut graph = render_world.get_resource_mut::().unwrap(); graph.add_node("pbr", PbrNode); graph - .add_node_edge("pbr", core_pipeline::node::MAIN_PASS_DEPENDENCIES) + .add_node_edge("pbr", bevy_core_pipeline::node::MAIN_PASS_DEPENDENCIES) .unwrap(); let draw_3d_graph = graph - .get_sub_graph_mut(core_pipeline::draw_3d_graph::NAME) + .get_sub_graph_mut(bevy_core_pipeline::draw_3d_graph::NAME) .unwrap(); draw_3d_graph.add_node(draw_3d_graph::node::SHADOW_PASS, shadow_pass_node); draw_3d_graph .add_node_edge( draw_3d_graph::node::SHADOW_PASS, - core_pipeline::draw_3d_graph::node::MAIN_PASS, + bevy_core_pipeline::draw_3d_graph::node::MAIN_PASS, ) .unwrap(); draw_3d_graph .add_slot_edge( draw_3d_graph.input_node().unwrap().id, - core_pipeline::draw_3d_graph::input::VIEW_ENTITY, + bevy_core_pipeline::draw_3d_graph::input::VIEW_ENTITY, draw_3d_graph::node::SHADOW_PASS, ShadowPassNode::IN_VIEW, ) diff --git a/pipelined/bevy_pbr2/src/render/light.rs b/pipelined/bevy_pbr2/src/render/light.rs index 12e229e1f372d..45ab08a3a8fb0 100644 --- a/pipelined/bevy_pbr2/src/render/light.rs +++ b/pipelined/bevy_pbr2/src/render/light.rs @@ -1,10 +1,10 @@ use crate::{AmbientLight, DirectionalLight, ExtractedMeshes, MeshMeta, PbrShaders, PointLight}; +use bevy_core_pipeline::Transparent3dPhase; use bevy_ecs::{prelude::*, system::SystemState}; use bevy_math::{const_vec3, Mat4, Vec3, Vec4}; use bevy_render2::{ camera::CameraProjection, color::Color, - core_pipeline::Transparent3dPhase, mesh::Mesh, render_asset::RenderAssets, render_graph::{Node, NodeRunError, RenderGraphContext, SlotInfo, SlotType}, diff --git a/pipelined/bevy_pbr2/src/render/mod.rs b/pipelined/bevy_pbr2/src/render/mod.rs index 94d9f1507554d..8c54071eb136c 100644 --- a/pipelined/bevy_pbr2/src/render/mod.rs +++ b/pipelined/bevy_pbr2/src/render/mod.rs @@ -1,11 +1,12 @@ mod light; pub use light::*; +use crate::{StandardMaterial, StandardMaterialUniformData}; use bevy_asset::{Assets, Handle}; +use bevy_core_pipeline::Transparent3dPhase; use bevy_ecs::{prelude::*, system::SystemState}; use bevy_math::Mat4; use bevy_render2::{ - core_pipeline::Transparent3dPhase, mesh::Mesh, render_asset::RenderAssets, render_graph::{Node, NodeRunError, RenderGraphContext}, @@ -24,8 +25,6 @@ use wgpu::{ TextureViewDescriptor, }; -use crate::{StandardMaterial, StandardMaterialUniformData}; - pub struct PbrShaders { pipeline: RenderPipeline, shader_module: ShaderModule, diff --git a/pipelined/bevy_render2/src/lib.rs b/pipelined/bevy_render2/src/lib.rs index 8083b12751458..580e0d0a6caa2 100644 --- a/pipelined/bevy_render2/src/lib.rs +++ b/pipelined/bevy_render2/src/lib.rs @@ -1,6 +1,5 @@ pub mod camera; pub mod color; -pub mod core_pipeline; pub mod mesh; pub mod render_asset; pub mod render_graph; diff --git a/pipelined/bevy_sprite2/Cargo.toml b/pipelined/bevy_sprite2/Cargo.toml index 1cebd3ef06dfd..28f7e64843a56 100644 --- a/pipelined/bevy_sprite2/Cargo.toml +++ b/pipelined/bevy_sprite2/Cargo.toml @@ -17,6 +17,7 @@ keywords = ["bevy"] bevy_app = { path = "../../crates/bevy_app", version = "0.5.0" } bevy_asset = { path = "../../crates/bevy_asset", version = "0.5.0" } bevy_core = { path = "../../crates/bevy_core", version = "0.5.0" } +bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.5.0" } bevy_ecs = { path = "../../crates/bevy_ecs", version = "0.5.0" } bevy_log = { path = "../../crates/bevy_log", version = "0.5.0" } bevy_math = { path = "../../crates/bevy_math", version = "0.5.0" } diff --git a/pipelined/bevy_sprite2/src/lib.rs b/pipelined/bevy_sprite2/src/lib.rs index 9aed799588077..9e5767b8f8c10 100644 --- a/pipelined/bevy_sprite2/src/lib.rs +++ b/pipelined/bevy_sprite2/src/lib.rs @@ -9,9 +9,7 @@ pub use render::*; pub use sprite::*; use bevy_app::prelude::*; -use bevy_render2::{ - core_pipeline, render_graph::RenderGraph, render_phase::DrawFunctions, RenderStage, -}; +use bevy_render2::{render_graph::RenderGraph, render_phase::DrawFunctions, RenderStage}; #[derive(Default)] pub struct SpritePlugin; @@ -37,7 +35,7 @@ impl Plugin for SpritePlugin { let mut graph = render_world.get_resource_mut::().unwrap(); graph.add_node("sprite", SpriteNode); graph - .add_node_edge("sprite", core_pipeline::node::MAIN_PASS_DEPENDENCIES) + .add_node_edge("sprite", bevy_core_pipeline::node::MAIN_PASS_DEPENDENCIES) .unwrap(); } } diff --git a/pipelined/bevy_sprite2/src/render/mod.rs b/pipelined/bevy_sprite2/src/render/mod.rs index 9f55cca8afa27..8e83f8c7113bc 100644 --- a/pipelined/bevy_sprite2/src/render/mod.rs +++ b/pipelined/bevy_sprite2/src/render/mod.rs @@ -1,9 +1,9 @@ use crate::Sprite; use bevy_asset::{Assets, Handle}; +use bevy_core_pipeline::Transparent2dPhase; use bevy_ecs::{prelude::*, system::SystemState}; use bevy_math::{Mat4, Vec2, Vec3, Vec4Swizzles}; use bevy_render2::{ - core_pipeline::Transparent2dPhase, mesh::{shape::Quad, Indices, Mesh, VertexAttributeValues}, render_asset::RenderAssets, render_graph::{Node, NodeRunError, RenderGraphContext},