Skip to content

Commit

Permalink
Remove egui plot, use simple timings
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Oct 5, 2024
1 parent 1da7686 commit cc1e630
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 38 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ winit = { workspace = true }
blade-render = { version = "0.3", path = "blade-render" }

[dev-dependencies]
egui_plot = "0.28"
blade-macros = { version = "0.3", path = "blade-macros" }
bytemuck = { workspace = true }
choir = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions blade-render/src/util/frame_pacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ impl FramePacer {
mem::swap(&mut self.prev_resources, &mut self.next_resources);
self.prev_sync_point.as_ref().unwrap()
}

pub fn timings(&self) -> &blade_graphics::Timings {
self.command_encoder.timings()
}
}
37 changes: 0 additions & 37 deletions examples/scene/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
use blade_graphics as gpu;
use blade_helpers::ControlledCamera;
use std::{
collections::VecDeque,
fmt, fs,
path::{Path, PathBuf},
sync::Arc,
time,
};

const FRAME_TIME_HISTORY: usize = 30;
const RENDER_WHILE_LOADING: bool = true;
const MAX_DEPTH: f32 = 1e9;

Expand Down Expand Up @@ -156,8 +154,6 @@ struct Example {
need_accumulation_reset: bool,
is_point_selected: bool,
is_file_hovered: bool,
last_render_time: time::Instant,
render_times: VecDeque<u32>,
ray_config: blade_render::RayConfig,
denoiser_enabled: bool,
denoiser_config: blade_render::DenoiserConfig,
Expand Down Expand Up @@ -254,8 +250,6 @@ impl Example {
need_accumulation_reset: true,
is_point_selected: false,
is_file_hovered: false,
last_render_time: time::Instant::now(),
render_times: VecDeque::with_capacity(FRAME_TIME_HISTORY),
ray_config: blade_helpers::default_ray_config(),
denoiser_enabled: true,
denoiser_config: blade_render::DenoiserConfig {
Expand Down Expand Up @@ -556,13 +550,6 @@ impl Example {
use blade_helpers::{populate_debug_selection, ExposeHud as _};
use strum::IntoEnumIterator as _;

let delta = self.last_render_time.elapsed();
self.last_render_time += delta;
while self.render_times.len() >= FRAME_TIME_HISTORY {
self.render_times.pop_back();
}
self.render_times.push_front(delta.as_millis() as u32);

if self.scene_load_task.is_some() {
ui.horizontal(|ui| {
ui.label("Loading...");
Expand Down Expand Up @@ -669,30 +656,6 @@ impl Example {
egui::CollapsingHeader::new("Tone Map").show(ui, |ui| {
self.post_proc_config.populate_hud(ui);
});

egui::CollapsingHeader::new("Performance").show(ui, |ui| {
let times = self.render_times.as_slices();
let fd_points = egui_plot::PlotPoints::from_iter(
times
.0
.iter()
.chain(times.1.iter())
.enumerate()
.map(|(x, &y)| [x as f64, y as f64]),
);
let fd_line = egui_plot::Line::new(fd_points).name("last");
egui_plot::Plot::new("Frame time")
.allow_zoom(false)
.allow_scroll(false)
.allow_drag(false)
.show_x(false)
.include_y(0.0)
.show_axes([false, true])
.show(ui, |plot_ui| {
plot_ui.line(fd_line);
plot_ui.hline(egui_plot::HLine::new(1000.0 / 60.0).name("smooth"));
});
});
}

#[profiling::function]
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,16 @@ impl Engine {
}
});

egui::CollapsingHeader::new("Performance").show(ui, |ui| {
for (name, time) in self.pacer.timings() {
let millis = time.as_secs_f32() * 1000.0;
ui.horizontal(|ui| {
ui.label(name);
ui.colored_label(egui::Color32::WHITE, format!("{:.2} ms", millis));
});
}
});

egui::CollapsingHeader::new("Objects")
.default_open(true)
.show(ui, |ui| {
Expand Down

0 comments on commit cc1e630

Please sign in to comment.