Struct wgpu_profiler::GpuProfiler
source · 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
impl GpuProfiler
sourcepub const ALL_WGPU_TIMER_FEATURES: Features = _
pub const ALL_WGPU_TIMER_FEATURES: Features = _
Combination of all timer query features GpuProfiler
can leverage.
sourcepub const REQUIRED_WGPU_FEATURES: Features = GpuProfiler::ALL_WGPU_TIMER_FEATURES
👎Deprecated since 0.9.0: Use ALL_WGPU_TIMER_FEATURES instead
pub const REQUIRED_WGPU_FEATURES: Features = GpuProfiler::ALL_WGPU_TIMER_FEATURES
Combination of all timer query features GpuProfiler
can leverage.
sourcepub fn new(settings: GpuProfilerSettings) -> Result<Self, CreationError>
pub fn new(settings: GpuProfilerSettings) -> Result<Self, CreationError>
Creates a new Profiler object.
There is nothing preventing the use of several independent profiler objects.
sourcepub fn change_settings(
&mut self,
settings: GpuProfilerSettings
) -> Result<(), SettingsError>
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
.
sourcepub fn begin_scope<Recorder: ProfilerCommandRecorder>(
&mut self,
label: &str,
encoder_or_pass: &mut Recorder,
device: &Device
)
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!
sourcepub fn end_scope<Recorder: ProfilerCommandRecorder>(
&mut self,
encoder_or_pass: &mut Recorder
) -> Result<(), ScopeError>
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
sourcepub fn resolve_queries(&mut self, encoder: &mut CommandEncoder)
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.)
sourcepub fn end_frame(&mut self) -> Result<(), EndFrameError>
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.
sourcepub fn process_finished_frame(
&mut self,
timestamp_period: f32
) -> Option<Vec<GpuTimerScopeResult>>
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.