mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Add more puffin profile scopes to eframe (#3330)
* Add puffin profile scopes to the startup and running of eframe * puffin_profiler example: start puffin right away * cargo format let-else statements * More profile scopes * Add some `#[inline]` * Standardize puffin profile scope definitions * standardize again * Silence warning when puffin is disabled
This commit is contained in:
@@ -203,22 +203,30 @@ pub fn depth_format_from_bits(depth_buffer: u8, stencil_buffer: u8) -> Option<wg
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Profiling macro for feature "puffin"
|
||||
macro_rules! profile_function {
|
||||
($($arg: tt)*) => {
|
||||
#[cfg(feature = "puffin")]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
puffin::profile_function!($($arg)*);
|
||||
};
|
||||
}
|
||||
pub(crate) use profile_function;
|
||||
mod profiling_scopes {
|
||||
#![allow(unused_macros)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
/// Profiling macro for feature "puffin"
|
||||
macro_rules! profile_scope {
|
||||
($($arg: tt)*) => {
|
||||
#[cfg(feature = "puffin")]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
puffin::profile_scope!($($arg)*);
|
||||
};
|
||||
/// Profiling macro for feature "puffin"
|
||||
macro_rules! profile_function {
|
||||
($($arg: tt)*) => {
|
||||
#[cfg(feature = "puffin")]
|
||||
#[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there.
|
||||
puffin::profile_function!($($arg)*);
|
||||
};
|
||||
}
|
||||
pub(crate) use profile_function;
|
||||
|
||||
/// Profiling macro for feature "puffin"
|
||||
macro_rules! profile_scope {
|
||||
($($arg: tt)*) => {
|
||||
#[cfg(feature = "puffin")]
|
||||
#[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there.
|
||||
puffin::profile_scope!($($arg)*);
|
||||
};
|
||||
}
|
||||
pub(crate) use profile_scope;
|
||||
}
|
||||
pub(crate) use profile_scope;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use profiling_scopes::*;
|
||||
|
||||
@@ -137,6 +137,7 @@ impl Painter {
|
||||
render_state: &RenderState,
|
||||
present_mode: wgpu::PresentMode,
|
||||
) {
|
||||
crate::profile_function!();
|
||||
let usage = if surface_state.supports_screenshot {
|
||||
wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_DST
|
||||
} else {
|
||||
@@ -181,6 +182,7 @@ impl Painter {
|
||||
&mut self,
|
||||
window: Option<&winit::window::Window>,
|
||||
) -> Result<(), crate::WgpuError> {
|
||||
crate::profile_function!();
|
||||
match window {
|
||||
Some(window) => {
|
||||
let surface = unsafe { self.instance.create_surface(&window)? };
|
||||
@@ -254,6 +256,7 @@ impl Painter {
|
||||
width_in_pixels: u32,
|
||||
height_in_pixels: u32,
|
||||
) {
|
||||
crate::profile_function!();
|
||||
let render_state = self.render_state.as_ref().unwrap();
|
||||
let surface_state = self.surface_state.as_mut().unwrap();
|
||||
|
||||
@@ -309,6 +312,7 @@ impl Painter {
|
||||
}
|
||||
|
||||
pub fn on_window_resized(&mut self, width_in_pixels: u32, height_in_pixels: u32) {
|
||||
crate::profile_function!();
|
||||
if self.surface_state.is_some() {
|
||||
self.resize_and_generate_depth_texture_view_and_msaa_view(
|
||||
width_in_pixels,
|
||||
|
||||
Reference in New Issue
Block a user