mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Plot target presentation time offset
This commit is contained in:
+3
-1
@@ -1,5 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use smithay::backend::allocator::gbm::GbmDevice;
|
use smithay::backend::allocator::gbm::GbmDevice;
|
||||||
use smithay::backend::drm::DrmDeviceFd;
|
use smithay::backend::drm::DrmDeviceFd;
|
||||||
@@ -49,9 +50,10 @@ impl Backend {
|
|||||||
niri: &mut Niri,
|
niri: &mut Niri,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
elements: &[OutputRenderElements<GlesRenderer>],
|
elements: &[OutputRenderElements<GlesRenderer>],
|
||||||
|
target_presentation_time: Duration,
|
||||||
) -> Option<&DmabufFeedback> {
|
) -> Option<&DmabufFeedback> {
|
||||||
match self {
|
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),
|
Backend::Winit(winit) => winit.render(niri, output, elements),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-3
@@ -56,7 +56,7 @@ pub struct Tty {
|
|||||||
type GbmDrmCompositor = DrmCompositor<
|
type GbmDrmCompositor = DrmCompositor<
|
||||||
GbmAllocator<DrmDeviceFd>,
|
GbmAllocator<DrmDeviceFd>,
|
||||||
GbmDevice<DrmDeviceFd>,
|
GbmDevice<DrmDeviceFd>,
|
||||||
OutputPresentationFeedback,
|
(OutputPresentationFeedback, Duration),
|
||||||
DrmDeviceFd,
|
DrmDeviceFd,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@@ -89,6 +89,8 @@ struct Surface {
|
|||||||
vblank_frame_name: tracy_client::FrameName,
|
vblank_frame_name: tracy_client::FrameName,
|
||||||
/// Plot name for the VBlank dispatch offset plot.
|
/// Plot name for the VBlank dispatch offset plot.
|
||||||
vblank_plot_name: tracy_client::PlotName,
|
vblank_plot_name: tracy_client::PlotName,
|
||||||
|
/// Plot name for the presentation target offset plot.
|
||||||
|
presentation_plot_name: tracy_client::PlotName,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tty {
|
impl Tty {
|
||||||
@@ -362,7 +364,7 @@ impl Tty {
|
|||||||
|
|
||||||
// Mark the last frame as submitted.
|
// Mark the last frame as submitted.
|
||||||
match surface.compositor.frame_submitted() {
|
match surface.compositor.frame_submitted() {
|
||||||
Ok(Some(mut feedback)) => {
|
Ok(Some((mut feedback, target_presentation_time))) => {
|
||||||
let refresh = output_state
|
let refresh = output_state
|
||||||
.frame_clock
|
.frame_clock
|
||||||
.refresh_interval()
|
.refresh_interval()
|
||||||
@@ -379,6 +381,14 @@ impl Tty {
|
|||||||
seq,
|
seq,
|
||||||
flags,
|
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) => (),
|
Ok(None) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -585,6 +595,11 @@ impl Tty {
|
|||||||
format!("{output_name} vblank dispatch offset, ms\0").leak(),
|
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
|
self.connectors
|
||||||
.lock()
|
.lock()
|
||||||
@@ -598,6 +613,7 @@ impl Tty {
|
|||||||
vblank_frame: None,
|
vblank_frame: None,
|
||||||
vblank_frame_name,
|
vblank_frame_name,
|
||||||
vblank_plot_name,
|
vblank_plot_name,
|
||||||
|
presentation_plot_name,
|
||||||
};
|
};
|
||||||
let res = device.surfaces.insert(crtc, surface);
|
let res = device.surfaces.insert(crtc, surface);
|
||||||
assert!(res.is_none(), "crtc must not have already existed");
|
assert!(res.is_none(), "crtc must not have already existed");
|
||||||
@@ -650,6 +666,7 @@ impl Tty {
|
|||||||
niri: &mut Niri,
|
niri: &mut Niri,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
elements: &[OutputRenderElements<GlesRenderer>],
|
elements: &[OutputRenderElements<GlesRenderer>],
|
||||||
|
target_presentation_time: Duration,
|
||||||
) -> Option<&DmabufFeedback> {
|
) -> Option<&DmabufFeedback> {
|
||||||
let span = tracy_client::span!("Tty::render");
|
let span = tracy_client::span!("Tty::render");
|
||||||
|
|
||||||
@@ -683,8 +700,9 @@ impl Tty {
|
|||||||
if res.damage.is_some() {
|
if res.damage.is_some() {
|
||||||
let presentation_feedbacks =
|
let presentation_feedbacks =
|
||||||
niri.take_presentation_feedbacks(output, &res.states);
|
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(()) => {
|
Ok(()) => {
|
||||||
niri.output_state
|
niri.output_state
|
||||||
.get_mut(output)
|
.get_mut(output)
|
||||||
|
|||||||
+1
-1
@@ -937,7 +937,7 @@ impl Niri {
|
|||||||
let elements = self.render(backend.renderer(), output, true);
|
let elements = self.render(backend.renderer(), output, true);
|
||||||
|
|
||||||
// Hand it over to the backend.
|
// 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.
|
// Send the dmabuf feedbacks.
|
||||||
if let Some(feedback) = dmabuf_feedback {
|
if let Some(feedback) = dmabuf_feedback {
|
||||||
|
|||||||
Reference in New Issue
Block a user