Struct bevy_render::diagnostic::RenderDiagnosticsPlugin
source · pub struct RenderDiagnosticsPlugin;
Expand description
Enables collecting render diagnostics, such as CPU/GPU elapsed time per render pass, as well as pipeline statistics (number of primitives, number of shader invocations, etc).
To access the diagnostics, you can use DiagnosticsStore
resource,
or add LogDiagnosticsPlugin
.
To record diagnostics in your own passes:
-
First, obtain the diagnostic recorder using
RenderContext::diagnostic_recorder
.It won’t do anything unless
RenderDiagnosticsPlugin
is present, so you’re free to omit#[cfg]
clauses.ⓘlet diagnostics = render_context.diagnostic_recorder();
-
Begin the span inside a command encoder, or a render/compute pass encoder.
ⓘlet time_span = diagnostics.time_span(render_context.command_encoder(), "shadows");
-
End the span, providing the same encoder.
ⓘtime_span.end(render_context.command_encoder());
§Supported platforms
Timestamp queries and pipeline statistics are currently supported only on Vulkan and DX12. On other platforms (Metal, WebGPU, WebGL2) only CPU time will be recorded.
Trait Implementations§
source§impl Default for RenderDiagnosticsPlugin
impl Default for RenderDiagnosticsPlugin
source§fn default() -> RenderDiagnosticsPlugin
fn default() -> RenderDiagnosticsPlugin
source§impl Plugin for RenderDiagnosticsPlugin
impl Plugin for RenderDiagnosticsPlugin
source§fn finish(&self, app: &mut App)
fn finish(&self, app: &mut App)
App
, once all plugins registered are ready. This can
be useful for plugins that depends on another plugin asynchronous setup, like the renderer.source§fn ready(&self, _app: &App) -> bool
fn ready(&self, _app: &App) -> bool
finish
should be called.source§fn cleanup(&self, _app: &mut App)
fn cleanup(&self, _app: &mut App)
Auto Trait Implementations§
impl Freeze for RenderDiagnosticsPlugin
impl RefUnwindSafe for RenderDiagnosticsPlugin
impl Send for RenderDiagnosticsPlugin
impl Sync for RenderDiagnosticsPlugin
impl Unpin for RenderDiagnosticsPlugin
impl UnwindSafe for RenderDiagnosticsPlugin
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.