Trait bevy::render::render_phase::RenderCommand
pub trait RenderCommand<P>where
P: PhaseItem,{
type Param: SystemParam + 'static;
type ViewWorldQuery: ReadOnlyWorldQueryData;
type ItemWorldQuery: ReadOnlyWorldQueryData;
// Required method
fn render<'w>(
item: &P,
view: <<Self::ViewWorldQuery as WorldQueryData>::ReadOnly as WorldQuery>::Item<'w>,
entity: <<Self::ItemWorldQuery as WorldQueryData>::ReadOnly as WorldQuery>::Item<'w>,
param: <Self::Param as SystemParam>::Item<'w, '_>,
pass: &mut TrackedRenderPass<'w>
) -> RenderCommandResult;
}
Expand description
RenderCommand
s are modular standardized pieces of render logic that can be composed into
Draw
functions.
To turn a stateless render command into a usable draw function it has to be wrapped by a
RenderCommandState
.
This is done automatically when registering a render command as a Draw
function via the
AddRenderCommand::add_render_command
method.
Compared to the draw function the required ECS data is fetched automatically
(by the RenderCommandState
) from the render world.
Therefore the three types Param
,
ViewWorldQuery
and
ItemWorldQuery
are used.
They specify which information is required to execute the render command.
Multiple render commands can be combined together by wrapping them in a tuple.
Example
The DrawPbr
draw function is created from the following render command
tuple. Const generics are used to set specific bind group locations:
pub type DrawPbr = (
SetItemPipeline,
SetMeshViewBindGroup<0>,
SetStandardMaterialBindGroup<1>,
SetTransformBindGroup<2>,
DrawMesh,
);
Required Associated Types§
type Param: SystemParam + 'static
type Param: SystemParam + 'static
Specifies the general ECS data (e.g. resources) required by RenderCommand::render
.
When fetching resources, note that, due to lifetime limitations of the Deref
trait,
SRes::into_inner
must be called on each SRes
reference in the
RenderCommand::render
method, instead of being automatically dereferenced as is the
case in normal systems
.
All parameters have to be read only.
type ViewWorldQuery: ReadOnlyWorldQueryData
type ViewWorldQuery: ReadOnlyWorldQueryData
Specifies the ECS data of the view entity required by RenderCommand::render
.
The view entity refers to the camera, or shadow-casting light, etc. from which the phase item will be rendered from. All components have to be accessed read only.
type ItemWorldQuery: ReadOnlyWorldQueryData
type ItemWorldQuery: ReadOnlyWorldQueryData
Specifies the ECS data of the item entity required by RenderCommand::render
.
The item is the entity that will be rendered for the corresponding view. All components have to be accessed read only.
Required Methods§
fn render<'w>(
item: &P,
view: <<Self::ViewWorldQuery as WorldQueryData>::ReadOnly as WorldQuery>::Item<'w>,
entity: <<Self::ItemWorldQuery as WorldQueryData>::ReadOnly as WorldQuery>::Item<'w>,
param: <Self::Param as SystemParam>::Item<'w, '_>,
pass: &mut TrackedRenderPass<'w>
) -> RenderCommandResult
fn render<'w>( item: &P, view: <<Self::ViewWorldQuery as WorldQueryData>::ReadOnly as WorldQuery>::Item<'w>, entity: <<Self::ItemWorldQuery as WorldQueryData>::ReadOnly as WorldQuery>::Item<'w>, param: <Self::Param as SystemParam>::Item<'w, '_>, pass: &mut TrackedRenderPass<'w> ) -> RenderCommandResult
Renders a PhaseItem
by recording commands (e.g. setting pipelines, binding bind groups,
issuing draw calls, etc.) via the TrackedRenderPass
.