Add debug flag to wait for frame completion

This commit is contained in:
Ivan Molodetskikh
2023-09-14 09:33:42 +04:00
parent ef11975ec5
commit 092095ead0
5 changed files with 28 additions and 10 deletions
+4 -2
View File
@@ -7,6 +7,7 @@ use smithay::backend::renderer::gles::GlesRenderer;
use smithay::output::Output;
use smithay::wayland::dmabuf::DmabufFeedback;
use crate::config::Config;
use crate::input::CompositorMod;
use crate::niri::OutputRenderElements;
use crate::Niri;
@@ -46,13 +47,14 @@ impl Backend {
pub fn render(
&mut self,
config: &Config,
niri: &mut Niri,
output: &Output,
elements: &[OutputRenderElements<GlesRenderer>],
) -> Option<&DmabufFeedback> {
match self {
Backend::Tty(tty) => tty.render(niri, output, elements),
Backend::Winit(winit) => winit.render(niri, output, elements),
Backend::Tty(tty) => tty.render(config, niri, output, elements),
Backend::Winit(winit) => winit.render(config, niri, output, elements),
}
}
+9 -5
View File
@@ -8,7 +8,7 @@ use anyhow::{anyhow, Context};
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
use smithay::backend::allocator::{Format as DrmFormat, Fourcc};
use smithay::backend::drm::compositor::DrmCompositor;
use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime};
use smithay::backend::egl::{EGLContext, EGLDisplay};
use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
@@ -33,6 +33,7 @@ use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufState,
use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
use smithay_drm_extras::edid::EdidInfo;
use crate::config::Config;
use crate::niri::{OutputRenderElements, State};
use crate::utils::get_monotonic_time;
use crate::{LoopData, Niri};
@@ -626,6 +627,7 @@ impl Tty {
pub fn render(
&mut self,
config: &Config,
niri: &mut Niri,
output: &Output,
elements: &[OutputRenderElements<GlesRenderer>],
@@ -645,10 +647,12 @@ impl Tty {
Ok(res) => {
assert!(!res.needs_sync());
// if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {
// let _span = tracy_client::span!("wait for sync");
// element.sync.wait();
// }
if config.debug.wait_for_frame_completion_before_queueing {
if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {
let _span = tracy_client::span!("wait for completion");
element.sync.wait();
}
}
if res.damage.is_some() {
let presentation_feedbacks =
+7
View File
@@ -15,6 +15,7 @@ use smithay::reexports::winit::window::WindowBuilder;
use smithay::utils::Transform;
use smithay::wayland::dmabuf::DmabufFeedback;
use crate::config::Config;
use crate::niri::OutputRenderElements;
use crate::utils::get_monotonic_time;
use crate::{LoopData, Niri};
@@ -136,6 +137,7 @@ impl Winit {
pub fn render(
&mut self,
config: &Config,
niri: &mut Niri,
output: &Output,
elements: &[OutputRenderElements<GlesRenderer>],
@@ -149,6 +151,11 @@ impl Winit {
.render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])
.unwrap();
if let Some(damage) = res.damage {
if config.debug.wait_for_frame_completion_before_queueing {
let _span = tracy_client::span!("wait for completion");
res.sync.wait();
}
self.backend.submit(Some(&damage)).unwrap();
let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);
+3
View File
@@ -130,6 +130,8 @@ pub struct DebugConfig {
pub animation_slowdown: f64,
#[knuffel(child)]
pub screen_cast_in_non_session_instances: bool,
#[knuffel(child)]
pub wait_for_frame_completion_before_queueing: bool,
}
impl Default for DebugConfig {
@@ -137,6 +139,7 @@ impl Default for DebugConfig {
Self {
animation_slowdown: 1.,
screen_cast_in_non_session_instances: false,
wait_for_frame_completion_before_queueing: false,
}
}
}
+5 -3
View File
@@ -690,7 +690,9 @@ impl Niri {
// Timer::immediate() adds a millisecond of delay for some reason.
// This should be fixed in calloop v0.11: https://github.com/Smithay/calloop/issues/142
let idle = self.event_loop.insert_idle(move |data| {
data.state.niri.redraw(&mut data.state.backend, &output);
data.state
.niri
.redraw(&data.state.config, &mut data.state.backend, &output);
});
state.queued_redraw = Some(idle);
}
@@ -835,7 +837,7 @@ impl Niri {
elements
}
fn redraw(&mut self, backend: &mut Backend, output: &Output) {
fn redraw(&mut self, config: &Config, backend: &mut Backend, output: &Output) {
let _span = tracy_client::span!("Niri::redraw");
let state = self.output_state.get_mut(output).unwrap();
@@ -852,7 +854,7 @@ impl Niri {
let elements = self.render(backend.renderer(), output);
// Hand it over to the backend.
let dmabuf_feedback = backend.render(self, output, &elements);
let dmabuf_feedback = backend.render(config, self, output, &elements);
// Send the dmabuf feedbacks.
if let Some(feedback) = dmabuf_feedback {