Trait bevy::render::render_phase::PhaseItem
pub trait PhaseItem: 'static + Sized + Send + Sync {
type SortKey: Ord;
fn sort_key(&self) -> Self::SortKey;
fn draw_function(&self) -> DrawFunctionId;
fn sort(items: &mut [Self]) { ... }
}
Expand description
An item which will be drawn to the screen. A phase item should be queued up for rendering
during the RenderStage::Queue
stage.
Afterwards it will be sorted and rendered automatically in the
RenderStage::PhaseSort
stage and
RenderStage::Render
stage, respectively.
Required Associated Types§
Required Methods§
fn sort_key(&self) -> Self::SortKey
fn sort_key(&self) -> Self::SortKey
Determines the order in which the items are drawn during the corresponding RenderPhase
.
fn draw_function(&self) -> DrawFunctionId
fn draw_function(&self) -> DrawFunctionId
Specifies the Draw
function used to render the item.
Provided Methods§
fn sort(items: &mut [Self])
fn sort(items: &mut [Self])
Sorts a slice of phase items into render order. Generally if the same type
implements BatchedPhaseItem
, this should use a stable sort like slice::sort_by_key
.
In almost all other cases, this should not be altered from the default,
which uses a unstable sort, as this provides the best balance of CPU and GPU
performance.
Implementers can optionally not sort the list at all. This is generally advisable if and only if the renderer supports a depth prepass, which is by default not supported by the rest of Bevy’s first party rendering crates. Even then, this may have a negative impact on GPU-side performance due to overdraw.
It’s advised to always profile for performance changes when changing this implementation.