tty: Add name and presentation to vblank mark
Browse files at this commitacb9376d05b389ae045b6eeeafbcd06dc586430cParent: acf30161 changed file +19 -7
- src/backend/tty.rs +19 -7
src/backend/tty.rsmodified+19 -7
| @@ -33,6 +33,7 @@ use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner}; | |||
| 33 | use smithay_drm_extras::edid::EdidInfo; | 33 | use smithay_drm_extras::edid::EdidInfo; |
| 34 | 34 | ||
| 35 | use crate::niri::OutputRenderElements; | 35 | use crate::niri::OutputRenderElements; |
| 36 | +use crate::utils::get_monotonic_time; | ||
| 36 | use crate::{LoopData, Niri}; | 37 | use crate::{LoopData, Niri}; |
| 37 | 38 | ||
| 38 | const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.]; | 39 | const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.]; |
| @@ -275,14 +276,12 @@ impl Tty { | |||
| 275 | let tty = data.state.backend.tty(); | 276 | let tty = data.state.backend.tty(); |
| 276 | match event { | 277 | match event { |
| 277 | DrmEvent::VBlank(crtc) => { | 278 | DrmEvent::VBlank(crtc) => { |
| 278 | - tracy_client::Client::running() | 279 | + let now = get_monotonic_time(); |
| 279 | - .unwrap() | ||
| 280 | - .message("vblank", 0); | ||
| 281 | - trace!("vblank {metadata:?}"); | ||
| 282 | 280 | ||
| 283 | let device = tty.output_device.as_mut().unwrap(); | 281 | let device = tty.output_device.as_mut().unwrap(); |
| 284 | - let drm_compositor = | 282 | + let surface = device.surfaces.get_mut(&crtc).unwrap(); |
| 285 | - &mut device.surfaces.get_mut(&crtc).unwrap().compositor; | 283 | + let name = &surface.name; |
| 284 | + trace!("vblank on {name} {metadata:?}"); | ||
| 286 | 285 | ||
| 287 | let presentation_time = match metadata.as_mut().unwrap().time { | 286 | let presentation_time = match metadata.as_mut().unwrap().time { |
| 288 | DrmEventTime::Monotonic(time) => time, | 287 | DrmEventTime::Monotonic(time) => time, |
| @@ -294,8 +293,21 @@ impl Tty { | |||
| 294 | } | 293 | } |
| 295 | }; | 294 | }; |
| 296 | 295 | ||
| 296 | + let message = if presentation_time.is_zero() { | ||
| 297 | + format!("vblank on {name}, presentation time unknown") | ||
| 298 | + } else if presentation_time > now { | ||
| 299 | + let diff = presentation_time - now; | ||
| 300 | + format!("vblank on {name}, presentation is {diff:?} later") | ||
| 301 | + } else { | ||
| 302 | + let diff = now - presentation_time; | ||
| 303 | + format!("vblank on {name}, presentation was {diff:?} ago") | ||
| 304 | + }; | ||
| 305 | + tracy_client::Client::running() | ||
| 306 | + .unwrap() | ||
| 307 | + .message(&message, 0); | ||
| 308 | + | ||
| 297 | // Mark the last frame as submitted. | 309 | // Mark the last frame as submitted. |
| 298 | - match drm_compositor.frame_submitted() { | 310 | + match surface.compositor.frame_submitted() { |
| 299 | Ok(Some(mut feedback)) => { | 311 | Ok(Some(mut feedback)) => { |
| 300 | let refresh = | 312 | let refresh = |
| 301 | feedback.output().unwrap().current_mode().unwrap().refresh | 313 | feedback.output().unwrap().current_mode().unwrap().refresh |