You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Compared to the draw function the required ECS data is fetched automatically (by the [`RenderCommandState`]) from the render world.
141
-
/// Therefore the three types [`Param`](RenderCommand::Param), [`ViewWorldQuery`](RenderCommand::ViewWorldQuery) and [`WorldQuery`](RenderCommand::WorldQuery) are used.
144
+
/// Compared to the draw function the required ECS data is fetched automatically
145
+
/// (by the [`RenderCommandState`]) from the render world.
146
+
/// Therefore the three types [`Param`](RenderCommand::Param),
147
+
/// [`ViewWorldQuery`](RenderCommand::ViewWorldQuery) and
148
+
/// [`ItemWorldQuery`](RenderCommand::ItemWorldQuery) are used.
142
149
/// They specify which information is required to execute the render command.
143
150
///
144
151
/// Multiple render commands can be combined together by wrapping them in a tuple.
/// Specifies all ECS data required by [`RenderCommand::render`].
167
+
/// Specifies the general ECS data (e.g. resources) required by [`RenderCommand::render`].
161
168
/// All parameters have to be read only.
162
169
typeParam:SystemParam + 'static;
163
-
// Todo: add comment
170
+
/// Specifies the ECS data of the view required by [`RenderCommand::render`].
171
+
/// All components have to be accessed read only.
164
172
typeViewWorldQuery:ReadOnlyWorldQuery;
165
-
// Todo: add comment
173
+
/// Specifies the ECS data of the item required by [`RenderCommand::render`].
174
+
/// All components have to be accessed read only.
166
175
typeItemWorldQuery:ReadOnlyWorldQuery;
167
176
168
-
/// Renders a [`PhaseItem`] by recording commands (e.g. setting pipelines, binding bind groups, issuing draw calls, etc.) via the [`TrackedRenderPass`].
177
+
/// Renders a [`PhaseItem`] by recording commands (e.g. setting pipelines, binding bind groups,
178
+
/// issuing draw calls, etc.) via the [`TrackedRenderPass`].
/// Wraps a [`RenderCommand`] into a state so that it can be used as a [`Draw`] function.
211
-
/// Therefore the [`RenderCommand::Param`], [`RenderCommand::ViewWorldQuery`] and [`RenderCommand::WorldQuery`] are queried from the ECS and passed to the command.
221
+
///
222
+
/// The [`RenderCommand::Param`], [`RenderCommand::ViewWorldQuery`] and
223
+
/// [`RenderCommand::ItemWorldQuery`] are fetched from the ECS and passed to the command.
Copy file name to clipboardExpand all lines: crates/bevy_render/src/render_phase/draw_state.rs
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,9 @@ use wgpu::{IndexFormat, RenderPass};
12
12
13
13
/// Tracks the state of a [`TrackedRenderPass`].
14
14
///
15
-
/// This is used to skip redundant operations on the [`TrackedRenderPass`] (e.g. setting an already set pipeline, binding an already bound bind group).
15
+
/// This is used to skip redundant operations on the [`TrackedRenderPass`] (e.g. setting an already
16
+
/// set pipeline, binding an already bound bind group). These operations can otherwise be fairly
17
+
/// costly due to IO to the GPU, so deduplicating these calls results in a speedup.
Copy file name to clipboardExpand all lines: crates/bevy_render/src/render_phase/mod.rs
+29-14Lines changed: 29 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,44 @@
1
-
//! The modular rendering abstractions that queue, prepare, sort and draw entities as part of separate phases.
1
+
//! A modular rendering abstraction responsible for queuing, preparing, sorting and drawing entities
2
+
//! as part of separate phases.
2
3
//!
3
-
//! To draw an entity, a corresponding [`PhaseItem`] has to be added to one of the renderers multiple [`RenderPhase`]s (e.g. opaque, transparent, shadow, etc).
4
+
//! To draw an entity, a corresponding [`PhaseItem`] has to be added to one of the renderers
//! Therefore each [`PhaseItem`] is assigned a [`Draw`] function.
9
-
//! These set up the state of the [`TrackedRenderPass`] (i.e. select the [`RenderPipeline`](crate::render_resource::RenderPipeline), configure the [`BindGroup`](crate::render_resource::BindGroup)s, etc.) and then issue a draw call, for the corresponding [`PhaseItem`].
13
+
//! These set up the state of the [`TrackedRenderPass`] (i.e. select the
14
+
//! [`RenderPipeline`](crate::render_resource::RenderPipeline), configure the
15
+
//! [`BindGroup`](crate::render_resource::BindGroup)s, etc.) and then issue a draw call,
16
+
//! for the corresponding [`PhaseItem`].
10
17
//!
11
-
//! The [`Draw`] function trait can either be implemented directly or such a function can be created by composing multiple [`RenderCommand`]s.
18
+
//! The [`Draw`] function trait can either be implemented directly or such a function can be
19
+
//! created by composing multiple [`RenderCommand`]s.
12
20
13
21
mod draw;
14
22
mod draw_state;
15
23
mod rangefinder;
16
24
17
-
use bevy_ecs::entity::Entity;
18
25
pubuse draw::*;
19
26
pubuse draw_state::*;
20
27
pubuse rangefinder::*;
21
28
22
29
use bevy_ecs::prelude::*;
23
-
use bevy_ecs::world::World;
24
30
use std::ops::Range;
25
31
26
-
/// A render phase sorts and renders all [`PhaseItem`]s (entities) that are assigned to it.
32
+
/// A collection of all rendering instructions, that will be executed by the GPU, for a
33
+
/// single rendering phase for a single view.
27
34
///
28
-
/// It corresponds to exactly one [`TrackedRenderPass`] and thus renders all items into the same texture attachments (e.g. color, depth, stencil).
35
+
/// Each view (camera, or shadow-casting light, etc.) can have one or multiple render phases.
36
+
/// They are used to queue entities for rendering.
37
+
/// Multiple phases might be required due to different sorting/batching behaviours
38
+
/// (e.g. opaque: front to back, transparent: back to front) or because one phase depends on
39
+
/// the rendered texture of the previous phase (e.g. for screen-space reflections).
40
+
/// All [`PhaseItem`]s are then rendered using a single [`TrackedRenderPass`].
41
+
/// The render pass might be reused for multiple phases to reduce GPU overhead.
0 commit comments