From c5cd236b7380c3689792934aeaecd2942713fa67 Mon Sep 17 00:00:00 2001 From: Bingus Date: Tue, 29 Nov 2022 19:50:58 -0800 Subject: Initial profiling support for Iced. --- glow/Cargo.toml | 6 ++++++ glow/src/image.rs | 6 ++++++ glow/src/quad.rs | 6 ++++++ glow/src/triangle.rs | 6 ++++++ 4 files changed, 24 insertions(+) (limited to 'glow') diff --git a/glow/Cargo.toml b/glow/Cargo.toml index f586d24d..6c150a74 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -8,6 +8,7 @@ license = "MIT AND OFL-1.1" repository = "https://github.com/iced-rs/iced" [features] +trace = ["iced_profiling"] svg = ["iced_graphics/svg"] image = ["iced_graphics/image"] png = ["iced_graphics/png"] @@ -42,6 +43,11 @@ version = "0.5" path = "../graphics" features = ["font-fallback", "font-icons", "opengl"] +[dependencies.iced_profiling] +version = "0.1.0" +path = "../profiling" +optional = true + [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] all-features = true diff --git a/glow/src/image.rs b/glow/src/image.rs index 521a01e7..351b98fa 100644 --- a/glow/src/image.rs +++ b/glow/src/image.rs @@ -21,6 +21,9 @@ use glow::HasContext; use std::cell::RefCell; +#[cfg(feature = "trace")] +use iced_profiling::info_span; + #[derive(Debug)] pub(crate) struct Pipeline { program: ::Program, @@ -148,6 +151,9 @@ impl Pipeline { images: &[layer::Image], layer_bounds: Rectangle, ) { + #[cfg(feature = "trace")] + let _ = info_span!("Glow::Image", "DRAW").entered(); + unsafe { gl.use_program(Some(self.program)); gl.bind_vertex_array(Some(self.vertex_array)); diff --git a/glow/src/quad.rs b/glow/src/quad.rs index d9f1c6ae..fc918bf2 100644 --- a/glow/src/quad.rs +++ b/glow/src/quad.rs @@ -7,6 +7,9 @@ use glow::HasContext; use iced_graphics::layer; use iced_native::Rectangle; +#[cfg(feature = "trace")] +use iced_profiling::info_span; + #[derive(Debug)] pub enum Pipeline { Core(core::Pipeline), @@ -42,6 +45,9 @@ impl Pipeline { scale: f32, bounds: Rectangle, ) { + #[cfg(feature = "trace")] + let _ = info_span!("Glow::Quad", "DRAW").enter(); + match self { Pipeline::Core(pipeline) => { pipeline.draw( diff --git a/glow/src/triangle.rs b/glow/src/triangle.rs index d0205e08..11d24349 100644 --- a/glow/src/triangle.rs +++ b/glow/src/triangle.rs @@ -9,6 +9,9 @@ use iced_graphics::triangle::{ColoredVertex2D, Vertex2D}; use glow::HasContext; use std::marker::PhantomData; +#[cfg(feature = "trace")] +use iced_profiling::info_span; + const DEFAULT_VERTICES: usize = 1_000; const DEFAULT_INDICES: usize = 1_000; @@ -58,6 +61,9 @@ impl Pipeline { transformation: Transformation, scale_factor: f32, ) { + #[cfg(feature = "trace")] + let _ = info_span!("Glow::Triangle", "DRAW").enter(); + unsafe { gl.enable(glow::MULTISAMPLE); gl.enable(glow::SCISSOR_TEST); -- cgit From 4b6d3797d43acb1d78a292a7ec712a0be7c8f6a2 Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Tue, 20 Dec 2022 20:41:09 -0800 Subject: Restructured everything to make profiling a feature of iced_winit. --- glow/Cargo.toml | 6 ++---- glow/src/image.rs | 6 +++--- glow/src/quad.rs | 6 +++--- glow/src/triangle.rs | 6 +++--- 4 files changed, 11 insertions(+), 13 deletions(-) (limited to 'glow') diff --git a/glow/Cargo.toml b/glow/Cargo.toml index 6c150a74..c126a511 100644 --- a/glow/Cargo.toml +++ b/glow/Cargo.toml @@ -8,7 +8,6 @@ license = "MIT AND OFL-1.1" repository = "https://github.com/iced-rs/iced" [features] -trace = ["iced_profiling"] svg = ["iced_graphics/svg"] image = ["iced_graphics/image"] png = ["iced_graphics/png"] @@ -43,9 +42,8 @@ version = "0.5" path = "../graphics" features = ["font-fallback", "font-icons", "opengl"] -[dependencies.iced_profiling] -version = "0.1.0" -path = "../profiling" +[dependencies.tracing] +version = "0.1.6" optional = true [package.metadata.docs.rs] diff --git a/glow/src/image.rs b/glow/src/image.rs index 351b98fa..d3a25b5b 100644 --- a/glow/src/image.rs +++ b/glow/src/image.rs @@ -21,8 +21,8 @@ use glow::HasContext; use std::cell::RefCell; -#[cfg(feature = "trace")] -use iced_profiling::info_span; +#[cfg(feature = "tracing")] +use tracing::info_span; #[derive(Debug)] pub(crate) struct Pipeline { @@ -151,7 +151,7 @@ impl Pipeline { images: &[layer::Image], layer_bounds: Rectangle, ) { - #[cfg(feature = "trace")] + #[cfg(feature = "tracing")] let _ = info_span!("Glow::Image", "DRAW").entered(); unsafe { diff --git a/glow/src/quad.rs b/glow/src/quad.rs index fc918bf2..67d9a098 100644 --- a/glow/src/quad.rs +++ b/glow/src/quad.rs @@ -7,8 +7,8 @@ use glow::HasContext; use iced_graphics::layer; use iced_native::Rectangle; -#[cfg(feature = "trace")] -use iced_profiling::info_span; +#[cfg(feature = "tracing")] +use tracing::info_span; #[derive(Debug)] pub enum Pipeline { @@ -45,7 +45,7 @@ impl Pipeline { scale: f32, bounds: Rectangle, ) { - #[cfg(feature = "trace")] + #[cfg(feature = "tracing")] let _ = info_span!("Glow::Quad", "DRAW").enter(); match self { diff --git a/glow/src/triangle.rs b/glow/src/triangle.rs index 11d24349..42c88455 100644 --- a/glow/src/triangle.rs +++ b/glow/src/triangle.rs @@ -9,8 +9,8 @@ use iced_graphics::triangle::{ColoredVertex2D, Vertex2D}; use glow::HasContext; use std::marker::PhantomData; -#[cfg(feature = "trace")] -use iced_profiling::info_span; +#[cfg(feature = "tracing")] +use tracing::info_span; const DEFAULT_VERTICES: usize = 1_000; const DEFAULT_INDICES: usize = 1_000; @@ -61,7 +61,7 @@ impl Pipeline { transformation: Transformation, scale_factor: f32, ) { - #[cfg(feature = "trace")] + #[cfg(feature = "tracing")] let _ = info_span!("Glow::Triangle", "DRAW").enter(); unsafe { -- cgit