From 092095ead005ff073344b723f00b08a5b845f186 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 14 Sep 2023 09:33:42 +0400 Subject: Add debug flag to wait for frame completion --- src/backend/mod.rs | 6 ++++-- src/backend/tty.rs | 14 +++++++++----- src/backend/winit.rs | 7 +++++++ 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src/backend') diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 8473ccc2..ea795921 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -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], ) -> 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), } } diff --git a/src/backend/tty.rs b/src/backend/tty.rs index 475a007d..f2144770 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -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], @@ -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 = diff --git a/src/backend/winit.rs b/src/backend/winit.rs index e7a50ac7..f30c0784 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -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], @@ -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); -- cgit