From b6beba55d3e74417fcb8ec7d6dcb9621bdb942b2 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 19 Dec 2023 12:45:20 +0100 Subject: [PATCH] egui-wgpu: Show `wgpu` profiling scopes when using `puffin` profiler --- Cargo.lock | 19 +++++++++++++++++-- crates/egui-wgpu/Cargo.toml | 10 +++++++++- crates/egui-wgpu/src/winit.rs | 15 +++++---------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 978db37bd..e22fbccd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1218,6 +1218,7 @@ dependencies = [ "egui", "epaint", "log", + "profiling", "puffin", "thiserror", "type-map", @@ -2881,9 +2882,23 @@ dependencies = [ [[package]] name = "profiling" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f89dff0959d98c9758c88826cc002e2c3d0b9dfac4139711d1f30de442f1139b" +checksum = "1de09527cd2ea2c2d59fb6c2f8c1ab8c71709ed9d1b6d60b0e1c9fbb6fdcb33c" +dependencies = [ + "profiling-procmacros", + "puffin", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d8f36e3c621a72254893ed5cc57d1a069162adb3f98bfef610788661db6ad8d" +dependencies = [ + "quote", + "syn 2.0.37", +] [[package]] name = "puffin" diff --git a/crates/egui-wgpu/Cargo.toml b/crates/egui-wgpu/Cargo.toml index 546c1b329..9559e5643 100644 --- a/crates/egui-wgpu/Cargo.toml +++ b/crates/egui-wgpu/Cargo.toml @@ -43,15 +43,23 @@ epaint = { version = "0.24.1", path = "../epaint", default-features = false, fea bytemuck = "1.7" log = { version = "0.4", features = ["std"] } +# wgpu uses the `profiling` crate for its profiling scopes. +# This will hook them up to the puffin profiler as backend: +profiling = { version = "1.0.12", default-features = false, features = [ + "profile-with-puffin", +] } thiserror.workspace = true type-map = "0.5.0" wgpu.workspace = true + #! ### Optional dependencies ## Enable this when generating docs. document-features = { version = "0.2", optional = true } -winit = { version = "0.29.4", default-features = false, optional = true, features = ["rwh_05"] } +winit = { version = "0.29.4", default-features = false, optional = true, features = [ + "rwh_05", +] } # Native: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/crates/egui-wgpu/src/winit.rs b/crates/egui-wgpu/src/winit.rs index 5cf71b648..665430820 100644 --- a/crates/egui-wgpu/src/winit.rs +++ b/crates/egui-wgpu/src/winit.rs @@ -622,12 +622,9 @@ impl Painter { }; // Submit the commands: both the main buffer and user-defined ones. - { - crate::profile_scope!("Queue::submit"); - render_state - .queue - .submit(user_cmd_bufs.into_iter().chain([encoded])); - }; + render_state + .queue + .submit(user_cmd_bufs.into_iter().chain([encoded])); let screenshot = if capture { let screen_capture_state = self.screen_capture_state.as_ref()?; @@ -636,10 +633,8 @@ impl Painter { None }; - { - crate::profile_scope!("present"); - output_frame.present(); - } + output_frame.present(); + screenshot }