forge
Explore
Log in

Don't you dare go Hollow

Add debug flag to wait for frame completion

Browse files at this commit

092095ead005ff073344b723f00b08a5b845f186Ivan MolodetskikhParent: ef11975
src/backend/mod.rsmodified+4 -2
@@ -7,6 +7,7 @@ use smithay::backend::renderer::gles::GlesRenderer;
77 use smithay::output::Output;
88 use smithay::wayland::dmabuf::DmabufFeedback;
99
10+use crate::config::Config;
1011 use crate::input::CompositorMod;
1112 use crate::niri::OutputRenderElements;
1213 use crate::Niri;
@@ -46,13 +47,14 @@ impl Backend {
4647
4748 pub fn render(
4849 &mut self,
50+ config: &Config,
4951 niri: &mut Niri,
5052 output: &Output,
5153 elements: &[OutputRenderElements<GlesRenderer>],
5254 ) -> Option<&DmabufFeedback> {
5355 match self {
54- Backend::Tty(tty) => tty.render(niri, output, elements),
55- Backend::Winit(winit) => winit.render(niri, output, elements),
56+ Backend::Tty(tty) => tty.render(config, niri, output, elements),
57+ Backend::Winit(winit) => winit.render(config, niri, output, elements),
5658 }
5759 }
5860
src/backend/tty.rsmodified+9 -5
@@ -8,7 +8,7 @@ use anyhow::{anyhow, Context};
88 use smithay::backend::allocator::dmabuf::Dmabuf;
99 use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
1010 use smithay::backend::allocator::{Format as DrmFormat, Fourcc};
11-use smithay::backend::drm::compositor::DrmCompositor;
11+use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
1212 use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime};
1313 use smithay::backend::egl::{EGLContext, EGLDisplay};
1414 use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
@@ -33,6 +33,7 @@ use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufState,
3333 use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
3434 use smithay_drm_extras::edid::EdidInfo;
3535
36+use crate::config::Config;
3637 use crate::niri::{OutputRenderElements, State};
3738 use crate::utils::get_monotonic_time;
3839 use crate::{LoopData, Niri};
@@ -626,6 +627,7 @@ impl Tty {
626627
627628 pub fn render(
628629 &mut self,
630+ config: &Config,
629631 niri: &mut Niri,
630632 output: &Output,
631633 elements: &[OutputRenderElements<GlesRenderer>],
@@ -645,10 +647,12 @@ impl Tty {
645647 Ok(res) => {
646648 assert!(!res.needs_sync());
647649
648- // if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {
649- // let _span = tracy_client::span!("wait for sync");
650- // element.sync.wait();
651- // }
650+ if config.debug.wait_for_frame_completion_before_queueing {
651+ if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {
652+ let _span = tracy_client::span!("wait for completion");
653+ element.sync.wait();
654+ }
655+ }
652656
653657 if res.damage.is_some() {
654658 let presentation_feedbacks =
src/backend/winit.rsmodified+7 -0
@@ -15,6 +15,7 @@ use smithay::reexports::winit::window::WindowBuilder;
1515 use smithay::utils::Transform;
1616 use smithay::wayland::dmabuf::DmabufFeedback;
1717
18+use crate::config::Config;
1819 use crate::niri::OutputRenderElements;
1920 use crate::utils::get_monotonic_time;
2021 use crate::{LoopData, Niri};
@@ -136,6 +137,7 @@ impl Winit {
136137
137138 pub fn render(
138139 &mut self,
140+ config: &Config,
139141 niri: &mut Niri,
140142 output: &Output,
141143 elements: &[OutputRenderElements<GlesRenderer>],
@@ -149,6 +151,11 @@ impl Winit {
149151 .render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])
150152 .unwrap();
151153 if let Some(damage) = res.damage {
154+ if config.debug.wait_for_frame_completion_before_queueing {
155+ let _span = tracy_client::span!("wait for completion");
156+ res.sync.wait();
157+ }
158+
152159 self.backend.submit(Some(&damage)).unwrap();
153160
154161 let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);
src/config.rsmodified+3 -0
@@ -130,6 +130,8 @@ pub struct DebugConfig {
130130 pub animation_slowdown: f64,
131131 #[knuffel(child)]
132132 pub screen_cast_in_non_session_instances: bool,
133+ #[knuffel(child)]
134+ pub wait_for_frame_completion_before_queueing: bool,
133135 }
134136
135137 impl Default for DebugConfig {
@@ -137,6 +139,7 @@ impl Default for DebugConfig {
137139 Self {
138140 animation_slowdown: 1.,
139141 screen_cast_in_non_session_instances: false,
142+ wait_for_frame_completion_before_queueing: false,
140143 }
141144 }
142145 }
src/niri.rsmodified+5 -3
@@ -690,7 +690,9 @@ impl Niri {
690690 // Timer::immediate() adds a millisecond of delay for some reason.
691691 // This should be fixed in calloop v0.11: https://github.com/Smithay/calloop/issues/142
692692 let idle = self.event_loop.insert_idle(move |data| {
693- data.state.niri.redraw(&mut data.state.backend, &output);
693+ data.state
694+ .niri
695+ .redraw(&data.state.config, &mut data.state.backend, &output);
694696 });
695697 state.queued_redraw = Some(idle);
696698 }
@@ -835,7 +837,7 @@ impl Niri {
835837 elements
836838 }
837839
838- fn redraw(&mut self, backend: &mut Backend, output: &Output) {
840+ fn redraw(&mut self, config: &Config, backend: &mut Backend, output: &Output) {
839841 let _span = tracy_client::span!("Niri::redraw");
840842
841843 let state = self.output_state.get_mut(output).unwrap();
@@ -852,7 +854,7 @@ impl Niri {
852854 let elements = self.render(backend.renderer(), output);
853855
854856 // Hand it over to the backend.
855- let dmabuf_feedback = backend.render(self, output, &elements);
857+ let dmabuf_feedback = backend.render(config, self, output, &elements);
856858
857859 // Send the dmabuf feedbacks.
858860 if let Some(feedback) = dmabuf_feedback {