Skip to main content

RenderCommand

Trait RenderCommand 

Source
pub trait RenderCommand<P>
where P: PhaseItem,
{ type Param: SystemParam + 'static; type ViewQuery: ReadOnlyQueryData; type ItemQuery: ReadOnlyQueryData; // Required method fn render<'w>( item: &P, view: <<Self::ViewQuery as QueryData>::ReadOnly as QueryData>::Item<'w, '_>, entity: Option<<<Self::ItemQuery as QueryData>::ReadOnly as QueryData>::Item<'w, '_>>, param: <Self::Param as SystemParam>::Item<'w, '_>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult; }
Expand description

RenderCommands 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, ViewQuery and ItemQuery 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 DrawMaterial draw function is created from the following render command tuple. Const generics are used to set specific bind group locations:

pub type DrawMaterial<M> = (
    SetItemPipeline,
    SetMeshViewBindGroup<0>,
    SetMeshViewBindingArrayBindGroup<1>,
    SetMeshBindGroup<2>,
    SetMaterialBindGroup<M, 3>,
    DrawMesh,
);

Required Associated Types§

Source

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.

Source

type ViewQuery: ReadOnlyQueryData

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.

Source

type ItemQuery: ReadOnlyQueryData

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.

For efficiency reasons, Bevy doesn’t always extract entities to the render world; for instance, entities that simply consist of meshes are often not extracted. If the entity doesn’t exist in the render world, the supplied query data will be None.

Required Methods§

Source

fn render<'w>( item: &P, view: <<Self::ViewQuery as QueryData>::ReadOnly as QueryData>::Item<'w, '_>, entity: Option<<<Self::ItemQuery as QueryData>::ReadOnly as QueryData>::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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<P, C> RenderCommand<P> for (C₁, C₂, …, Cₙ)
where P: PhaseItem, C: RenderCommand<P>,

This trait is implemented for tuples up to 16 items long.

Source§

type Param = (<C as RenderCommand<P>>::Param,)

Source§

type ViewQuery = (<C as RenderCommand<P>>::ViewQuery,)

Source§

type ItemQuery = (<C as RenderCommand<P>>::ItemQuery,)

Source§

fn render<'w>( _item: &P, _: <<<(C,) as RenderCommand<P>>::ViewQuery as QueryData>::ReadOnly as QueryData>::Item<'w, '_>, maybe_entities: Option<<<<(C,) as RenderCommand<P>>::ItemQuery as QueryData>::ReadOnly as QueryData>::Item<'w, '_>>, _: <<(C,) as RenderCommand<P>>::Param as SystemParam>::Item<'w, '_>, _pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult

Source§

impl<P> RenderCommand<P> for ()
where P: PhaseItem,

Source§

type Param = ()

Source§

type ViewQuery = ()

Source§

type ItemQuery = ()

Source§

fn render<'w>( _item: &P, _: <<<() as RenderCommand<P>>::ViewQuery as QueryData>::ReadOnly as QueryData>::Item<'w, '_>, maybe_entities: Option<<<<() as RenderCommand<P>>::ItemQuery as QueryData>::ReadOnly as QueryData>::Item<'w, '_>>, _: <<() as RenderCommand<P>>::Param as SystemParam>::Item<'w, '_>, _pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult

Implementors§

Source§

impl<P, M, const I: usize> RenderCommand<P> for SetMatUiViewBindGroup<M, I>
where P: PhaseItem, M: UiMaterial,

Source§

impl<P, M, const I: usize> RenderCommand<P> for SetMaterial2dBindGroup<M, I>
where P: PhaseItem, M: Material2d,

Source§

impl<P, M, const I: usize> RenderCommand<P> for SetUiMaterialBindGroup<M, I>
where P: PhaseItem, M: UiMaterial,

Source§

impl<P, M> RenderCommand<P> for DrawUiMaterialNode<M>
where P: PhaseItem, M: UiMaterial,

Source§

impl<P, const I: usize> RenderCommand<P> for SetBoxShadowViewBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetMaterialBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetMesh2dBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetMesh2dViewBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetMeshBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetMeshViewBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetMeshViewBindingArrayBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetMeshViewEmptyBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetPrepassEmptyMaterialBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetPrepassViewBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetPrepassViewEmptyBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetSlicerTextureBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetSlicerViewBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetSpriteTextureBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetSpriteViewBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetUiTextureBindGroup<I>
where P: PhaseItem,

Source§

impl<P, const I: usize> RenderCommand<P> for SetUiViewBindGroup<I>
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for DrawBoxShadow
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for DrawMesh2d
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for DrawMesh
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for DrawSlicer
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for DrawSpriteBatch
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for DrawUiNode
where P: PhaseItem,

Source§

type Param = Res<'static, UiMeta>

Source§

type ViewQuery = ()

Source§

type ItemQuery = &'static UiBatch

Source§

impl<P> RenderCommand<P> for DrawWireframeMeshPulled
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for SetItemPipeline

Source§

impl<P> RenderCommand<P> for SetWireframe2dImmediates
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for SetWireframe3dThinImmediates
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for SetWireframe3dWideBindGroup
where P: PhaseItem,

Source§

impl<P> RenderCommand<P> for SetWireframe3dWideImmediates
where P: PhaseItem,