pub struct GpuProfiler { /* private fields */ }
Expand description

Profiler instance.

You can have an arbitrary number of independent profiler instances per application/adapter. Manages all the necessary wgpu::QuerySet and wgpu::Buffer behind the scenes.

Implementations§

source§

impl GpuProfiler

source

pub const ALL_WGPU_TIMER_FEATURES: Features = _

Combination of all timer query features GpuProfiler can leverage.

source

pub const REQUIRED_WGPU_FEATURES: Features = GpuProfiler::ALL_WGPU_TIMER_FEATURES

👎Deprecated since 0.9.0: Use ALL_WGPU_TIMER_FEATURES instead

Combination of all timer query features GpuProfiler can leverage.

source

pub fn new(settings: GpuProfilerSettings) -> Result<Self, CreationError>

Creates a new Profiler object.

There is nothing preventing the use of several independent profiler objects.

source

pub fn change_settings( &mut self, settings: GpuProfilerSettings ) -> Result<(), SettingsError>

Changes the settings of an existing profiler.

This fails if there are open profiling scopes.

If timer scopes are disabled (by setting GpuProfilerSettings::enable_timer_scopes to false), any timer queries that are in flight will still be processed, but unused query sets and buffers will be deallocated during Self::process_finished_frame.

source

pub fn begin_scope<Recorder: ProfilerCommandRecorder>( &mut self, label: &str, encoder_or_pass: &mut Recorder, device: &Device )

Starts a new debug & timer scope on a given encoder or rendering/compute pass if enabled.

If an wgpu::CommandEncoder is passed but the wgpu::Device does not support [wgpu::Features::TIMESTAMP_QUERY], no scope will be opened. If an wgpu::ComputePass or wgpu::RenderPass is passed but the wgpu::Device does not support [wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES], no scope will be opened.

May allocate a new wgpu::QuerySet and wgpu::Buffer internally if necessary. After the first call, the same wgpu::Device must be used with all subsequent calls (and all passed references to wgpu objects must originate from that device).

See also GpuProfiler::end_scope, wgpu_profiler!

source

pub fn end_scope<Recorder: ProfilerCommandRecorder>( &mut self, encoder_or_pass: &mut Recorder ) -> Result<(), ScopeError>

Ends currently open debug & timer scope if any.

Fails if no scope was previously opened. Behavior is not defined if the last open scope was opened on a different encoder or pass.

If the previous call to begin_scope did not open a timer scope because it was not supported or disabled, this call will do nothing (except closing the currently open debug scope if enabled).

See also wgpu_profiler!, GpuProfiler::begin_scope

source

pub fn resolve_queries(&mut self, encoder: &mut CommandEncoder)

Puts query resolve commands in the encoder for all unresolved, pending queries of the current profiler frame.

Note that you do not need to do this for every encoder, it is sufficient do do this once per frame as long as you submit this encoder after all other encoders that may have opened scopes in the same frame. (It does not matter if the passed encoder itself has previously opened scopes or not.)

source

pub fn end_frame(&mut self) -> Result<(), EndFrameError>

Marks the end of a frame.

Needs to be called after submitting any encoder used in the current profiler frame.

Fails if there are still open scopes or unresolved queries.

source

pub fn process_finished_frame( &mut self, timestamp_period: f32 ) -> Option<Vec<GpuTimerScopeResult>>

Checks if all timer queries for the oldest pending finished frame are done and returns that snapshot if any.

timestamp_period: The timestamp period of the device. Pass the result of wgpu::Queue::get_timestamp_period(). Note that some implementations (Chrome as of writing) may converge to a timestamp period while the application is running, so caching this value is usually not recommended.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for Twhere T: Send,

§

impl<T> WasmNotSync for Twhere T: Sync,