Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

desktop: Track wgpu stats in Tracy #12099

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
desktop: Send wgpu stats to tracy
Dinnerbone committed Jul 19, 2023
commit e8d44dc73774b15b8354bd4252a34bcd73c4b120
9 changes: 3 additions & 6 deletions desktop/src/app.rs
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ use crate::custom_event::RuffleEvent;
use crate::gui::{GuiController, MENU_HEIGHT};
use crate::player::{PlayerController, PlayerOptions};
use crate::util::{
get_screen_size, parse_url, pick_file, winit_key_to_char, winit_to_ruffle_key_code,
winit_to_ruffle_text_control,
get_screen_size, parse_url, pick_file, plot_stats_in_tracy, winit_key_to_char,
winit_to_ruffle_key_code, winit_to_ruffle_text_control,
};
use anyhow::{Context, Error};
use ruffle_core::{PlayerEvent, StageDisplayState};
@@ -136,10 +136,7 @@ impl App {
} else {
self.gui.borrow_mut().render(None);
}
#[cfg(feature = "tracy")]
tracing_tracy::client::Client::running()
.expect("tracy client must be running")
.frame_mark();
plot_stats_in_tracy(&self.gui.borrow().descriptors().wgpu_instance);
}
}

39 changes: 39 additions & 0 deletions desktop/src/util.rs
Original file line number Diff line number Diff line change
@@ -342,3 +342,42 @@ pub fn pick_file(in_ui: bool, path: Option<PathBuf>) -> Option<PathBuf> {
pub fn pick_file(_in_ui: bool, path: Option<PathBuf>) -> Option<PathBuf> {
actually_pick_file(path)
}

#[cfg(not(feature = "tracy"))]
pub fn plot_stats_in_tracy(_instance: &wgpu::Instance) {}

#[cfg(feature = "tracy")]
pub fn plot_stats_in_tracy(instance: &wgpu::Instance) {
use tracing_tracy::client::*;
const BIND_GROUPS: PlotName = plot_name!("Bind Groups");
const BUFFERS: PlotName = plot_name!("Buffers");
const TEXTURES: PlotName = plot_name!("Textures");
const TEXTURE_VIEWS: PlotName = plot_name!("Texture Views");

let tracy = Client::running().expect("tracy client must be running");
let report = instance.generate_report();

#[allow(unused_mut)]
let mut backend = None;
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
{
backend = backend.or(report.vulkan).or(report.gl);
}
#[cfg(windows)]
{
backend = backend.or(report.dx12).or(report.dx11);
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
{
backend = backend.or(report.metal);
}

if let Some(stats) = backend {
tracy.plot(BIND_GROUPS, stats.bind_groups.num_occupied as f64);
tracy.plot(BUFFERS, stats.buffers.num_occupied as f64);
tracy.plot(TEXTURES, stats.textures.num_occupied as f64);
tracy.plot(TEXTURE_VIEWS, stats.texture_views.num_occupied as f64);
}

tracy.frame_mark();
}