aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-20 11:51:25 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-20 11:51:25 +0400
commit9fc731c1150212a579a13a7cfee9c33d5fab6c3c (patch)
tree5790ed0e4b466245a55dd9ce35d5924258efe227 /src
parent1963aaa7755759442a2d25fffdc5af0938bf7c78 (diff)
downloadniri-9fc731c1150212a579a13a7cfee9c33d5fab6c3c.tar.gz
niri-9fc731c1150212a579a13a7cfee9c33d5fab6c3c.tar.bz2
niri-9fc731c1150212a579a13a7cfee9c33d5fab6c3c.zip
Plot target presentation time offset
Diffstat (limited to 'src')
-rw-r--r--src/backend/mod.rs4
-rw-r--r--src/backend/tty.rs24
-rw-r--r--src/niri.rs2
3 files changed, 25 insertions, 5 deletions
diff --git a/src/backend/mod.rs b/src/backend/mod.rs
index 8473ccc2..eca8cc2d 100644
--- a/src/backend/mod.rs
+++ b/src/backend/mod.rs
@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
+use std::time::Duration;
use smithay::backend::allocator::gbm::GbmDevice;
use smithay::backend::drm::DrmDeviceFd;
@@ -49,9 +50,10 @@ impl Backend {
niri: &mut Niri,
output: &Output,
elements: &[OutputRenderElements<GlesRenderer>],
+ target_presentation_time: Duration,
) -> Option<&DmabufFeedback> {
match self {
- Backend::Tty(tty) => tty.render(niri, output, elements),
+ Backend::Tty(tty) => tty.render(niri, output, elements, target_presentation_time),
Backend::Winit(winit) => winit.render(niri, output, elements),
}
}
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index fbb00fbc..9f126507 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -56,7 +56,7 @@ pub struct Tty {
type GbmDrmCompositor = DrmCompositor<
GbmAllocator<DrmDeviceFd>,
GbmDevice<DrmDeviceFd>,
- OutputPresentationFeedback,
+ (OutputPresentationFeedback, Duration),
DrmDeviceFd,
>;
@@ -89,6 +89,8 @@ struct Surface {
vblank_frame_name: tracy_client::FrameName,
/// Plot name for the VBlank dispatch offset plot.
vblank_plot_name: tracy_client::PlotName,
+ /// Plot name for the presentation target offset plot.
+ presentation_plot_name: tracy_client::PlotName,
}
impl Tty {
@@ -362,7 +364,7 @@ impl Tty {
// Mark the last frame as submitted.
match surface.compositor.frame_submitted() {
- Ok(Some(mut feedback)) => {
+ Ok(Some((mut feedback, target_presentation_time))) => {
let refresh = output_state
.frame_clock
.refresh_interval()
@@ -379,6 +381,14 @@ impl Tty {
seq,
flags,
);
+
+ if !presentation_time.is_zero() {
+ let diff = presentation_time.as_secs_f64()
+ - target_presentation_time.as_secs_f64();
+ tracy_client::Client::running()
+ .unwrap()
+ .plot(surface.presentation_plot_name, diff * 1000.);
+ }
}
Ok(None) => (),
Err(err) => {
@@ -585,6 +595,11 @@ impl Tty {
format!("{output_name} vblank dispatch offset, ms\0").leak(),
)
};
+ let presentation_plot_name = unsafe {
+ tracy_client::internal::create_plot(
+ format!("{output_name} presentation target offset, ms\0").leak(),
+ )
+ };
self.connectors
.lock()
@@ -598,6 +613,7 @@ impl Tty {
vblank_frame: None,
vblank_frame_name,
vblank_plot_name,
+ presentation_plot_name,
};
let res = device.surfaces.insert(crtc, surface);
assert!(res.is_none(), "crtc must not have already existed");
@@ -650,6 +666,7 @@ impl Tty {
niri: &mut Niri,
output: &Output,
elements: &[OutputRenderElements<GlesRenderer>],
+ target_presentation_time: Duration,
) -> Option<&DmabufFeedback> {
let span = tracy_client::span!("Tty::render");
@@ -683,8 +700,9 @@ impl Tty {
if res.damage.is_some() {
let presentation_feedbacks =
niri.take_presentation_feedbacks(output, &res.states);
+ let data = (presentation_feedbacks, target_presentation_time);
- match drm_compositor.queue_frame(presentation_feedbacks) {
+ match drm_compositor.queue_frame(data) {
Ok(()) => {
niri.output_state
.get_mut(output)
diff --git a/src/niri.rs b/src/niri.rs
index f4cb57ac..8966382a 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -937,7 +937,7 @@ impl Niri {
let elements = self.render(backend.renderer(), output, true);
// Hand it over to the backend.
- let dmabuf_feedback = backend.render(self, output, &elements);
+ let dmabuf_feedback = backend.render(self, output, &elements, presentation_time);
// Send the dmabuf feedbacks.
if let Some(feedback) = dmabuf_feedback {