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: Submit frame images to Tracy #18904

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions desktop/src/gui/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct GuiController {
/// If this is set, we should not render the main menu.
no_gui: bool,
theme_controller: ThemeController,
#[cfg(feature = "tracy")]
tracy_frame_captures: crate::tracy::FrameCapturesHolder,
}

impl GuiController {
Expand Down Expand Up @@ -134,6 +136,9 @@ impl GuiController {

egui_extras::install_image_loaders(egui_winit.egui_ctx());

#[cfg(feature = "tracy")]
let tracy_frame_captures = crate::tracy::FrameCapturesHolder::new(&descriptors.device);

Ok(Self {
descriptors,
egui_winit,
Expand All @@ -148,6 +153,8 @@ impl GuiController {
size,
no_gui,
theme_controller,
#[cfg(feature = "tracy")]
tracy_frame_captures,
})
}

Expand Down Expand Up @@ -244,6 +251,8 @@ impl GuiController {
&self.descriptors.device,
self.size.width,
self.size.height,
#[cfg(feature = "tracy")]
self.tracy_frame_captures.clone(),
);
player.create(&opt, &movie_url, movie_view);
self.gui.on_player_created(
Expand Down Expand Up @@ -284,6 +293,12 @@ impl GuiController {
}
};

#[cfg(feature = "tracy")]
if player.is_none() {
self.tracy_frame_captures
.set_target(&self.descriptors.device, None);
}

let raw_input = self.egui_winit.take_egui_input(&self.window);
let show_menu = self.window.fullscreen().is_none() && !self.no_gui;
let mut full_output = self.egui_winit.egui_ctx().run(raw_input, |context| {
Expand Down Expand Up @@ -386,6 +401,13 @@ impl GuiController {

self.egui_renderer
.render(&mut render_pass, &clipped_primitives, &screen_descriptor);

#[cfg(feature = "tracy")]
{
drop(render_pass);
self.tracy_frame_captures
.capture_frame(&self.descriptors.device, &mut encoder);
}
}

for id in &full_output.textures_delta.free {
Expand All @@ -395,6 +417,8 @@ impl GuiController {
command_buffers.push(encoder.finish());
self.descriptors.queue.submit(command_buffers);
surface_texture.present();
#[cfg(feature = "tracy")]
self.tracy_frame_captures.finish_frame();
}

pub fn show_context_menu(
Expand Down
16 changes: 15 additions & 1 deletion desktop/src/gui/movie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ pub struct MovieView {
renderer: Arc<MovieViewRenderer>,
texture: wgpu::Texture,
bind_group: wgpu::BindGroup,
#[cfg(feature = "tracy")]
tracy_frame_captures: crate::tracy::FrameCapturesHolder,
}

impl MovieView {
Expand All @@ -164,6 +166,7 @@ impl MovieView {
device: &wgpu::Device,
width: u32,
height: u32,
#[cfg(feature = "tracy")] tracy_frame_captures: crate::tracy::FrameCapturesHolder,
) -> Self {
let texture = device.create_texture(&wgpu::TextureDescriptor {
label: None,
Expand Down Expand Up @@ -194,10 +197,14 @@ impl MovieView {
},
],
});
#[cfg(feature = "tracy")]
tracy_frame_captures.set_target(device, Some(&texture));
Self {
renderer,
texture,
bind_group,
#[cfg(feature = "tracy")]
tracy_frame_captures,
}
}

Expand All @@ -217,7 +224,14 @@ impl RenderTarget for MovieView {
type Frame = MovieViewFrame;

fn resize(&mut self, device: &wgpu::Device, width: u32, height: u32) {
*self = MovieView::new(self.renderer.clone(), device, width, height);
*self = MovieView::new(
self.renderer.clone(),
device,
width,
height,
#[cfg(feature = "tracy")]
self.tracy_frame_captures.clone(),
);
}

fn format(&self) -> wgpu::TextureFormat {
Expand Down
Loading