wde_renderer/lib.rs
1//! The main renderer plugin and related utilities.
2//!
3//! This crate provides the main rendering plugin for the engine, as well as core types and utilities for defining render pipelines, render passes and related resources. It is designed to be flexible and extensible, allowing users to define their own render pipelines and passes while providing a solid foundation of core functionality.
4//! It is an overlay over [`wde_wgpu`](wde_wgpu) that integrates it with the engine's asset system, ECS and render graph.
5//!
6//! The renderer flow is composed of the following stages:
7//! ```text
8//! |--------------------------------------------------------------------|
9//! | | | Main World Update |
10//! | Sync | Extract |---------------------------------------------------|
11//! | | | Render World Update |
12//! |--------------------------------------------------------------------|
13//! ```
14//! Where:
15//! - The **Sync** stage is responsible for synchronizing entities between the main and render worlds (see the [`sync`](crate::sync) module for more details).
16//! - The **Extract** stage is responsible for extracting resources, queries and entities from the main world to the render world, so that they can be used by the render passes (see the [`core`](crate::core) and [`sync`](crate::sync) modules for more details).
17//! - The **Main World Update** and **Render World Update** stages are responsible for running the systems in the main and render worlds, respectively.
18//!
19//! The main components of this crate are:
20//! - The [`assets`](crate::assets) module that defines the render pipeline asset system and related types.
21//! - The [`core`](crate::core) module that defines core types and resources for the renderer, such as the render graph and pipeline manager.
22//! - The [`passes`](crate::passes) module that defines the traits and types for render passes and sub-passes, as well as a simple render graph implementation.
23//! - The [`sync`](crate::sync) module that provides utilities to automatically extract resources, query and entities from the main to the render world.
24//! - The [`utils`](crate::utils) module that provides utility resources and systems, such as the depth texture and meshes for rendering.
25
26extern crate self as wde_renderer;
27
28#[doc(hidden)]
29pub mod prelude {
30 pub use crate::assets::*;
31 pub use crate::core::*;
32 pub use crate::passes::*;
33 pub use crate::sync::*;
34 pub use crate::utils::*;
35
36 // Re-export the macros
37 pub use wde_renderer_macros::*;
38}
39
40pub mod wgpu_utils {
41 pub use wde_wgpu::command_buffer::{
42 CommandBuffer, RenderPassBuilder, RenderPassColorAttachment, RenderPassDepth,
43 };
44}
45
46pub mod assets;
47pub mod core;
48pub mod passes;
49pub mod sync;
50pub mod utils;
51
52use crate::{assets::AssetsPlugin, core::RenderCorePlugin, sync::SyncPlugin, utils::UtilsPlugin};
53use bevy::prelude::*;
54
55pub struct RenderPlugin;
56impl Plugin for RenderPlugin {
57 fn build(&self, app: &mut App) {
58 // First, add the core plugin
59 app.add_plugins(RenderCorePlugin);
60
61 // Finally, add the other plugins
62 app.add_plugins((SyncPlugin, UtilsPlugin, AssetsPlugin));
63 }
64}