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;
7 use smithay::output::Output;7 use smithay::output::Output;
8 use smithay::wayland::dmabuf::DmabufFeedback;8 use smithay::wayland::dmabuf::DmabufFeedback;
9 9
10+use crate::config::Config;
10 use crate::input::CompositorMod;11 use crate::input::CompositorMod;
11 use crate::niri::OutputRenderElements;12 use crate::niri::OutputRenderElements;
12 use crate::Niri;13 use crate::Niri;
@@ -46,13 +47,14 @@ impl Backend {
46 47
47 pub fn render(48 pub fn render(
48 &mut self,49 &mut self,
50+ config: &Config,
49 niri: &mut Niri,51 niri: &mut Niri,
50 output: &Output,52 output: &Output,
51 elements: &[OutputRenderElements<GlesRenderer>],53 elements: &[OutputRenderElements<GlesRenderer>],
52 ) -> Option<&DmabufFeedback> {54 ) -> Option<&DmabufFeedback> {
53 match self {55 match self {
54- Backend::Tty(tty) => tty.render(niri, output, elements),56+ Backend::Tty(tty) => tty.render(config, niri, output, elements),
55- Backend::Winit(winit) => winit.render(niri, output, elements),57+ Backend::Winit(winit) => winit.render(config, niri, output, elements),
56 }58 }
57 }59 }
58 60
src/backend/tty.rsmodified+9 -5
@@ -8,7 +8,7 @@ use anyhow::{anyhow, Context};
8 use smithay::backend::allocator::dmabuf::Dmabuf;8 use smithay::backend::allocator::dmabuf::Dmabuf;
9 use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};9 use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
10 use smithay::backend::allocator::{Format as DrmFormat, Fourcc};10 use smithay::backend::allocator::{Format as DrmFormat, Fourcc};
11-use smithay::backend::drm::compositor::DrmCompositor;11+use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
12 use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime};12 use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime};
13 use smithay::backend::egl::{EGLContext, EGLDisplay};13 use smithay::backend::egl::{EGLContext, EGLDisplay};
14 use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};14 use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
@@ -33,6 +33,7 @@ use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufState,
33 use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};33 use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
34 use smithay_drm_extras::edid::EdidInfo;34 use smithay_drm_extras::edid::EdidInfo;
35 35
36+use crate::config::Config;
36 use crate::niri::{OutputRenderElements, State};37 use crate::niri::{OutputRenderElements, State};
37 use crate::utils::get_monotonic_time;38 use crate::utils::get_monotonic_time;
38 use crate::{LoopData, Niri};39 use crate::{LoopData, Niri};
@@ -626,6 +627,7 @@ impl Tty {
626 627
627 pub fn render(628 pub fn render(
628 &mut self,629 &mut self,
630+ config: &Config,
629 niri: &mut Niri,631 niri: &mut Niri,
630 output: &Output,632 output: &Output,
631 elements: &[OutputRenderElements<GlesRenderer>],633 elements: &[OutputRenderElements<GlesRenderer>],
@@ -645,10 +647,12 @@ impl Tty {
645 Ok(res) => {647 Ok(res) => {
646 assert!(!res.needs_sync());648 assert!(!res.needs_sync());
647 649
648- // if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {650+ if config.debug.wait_for_frame_completion_before_queueing {
649- // let _span = tracy_client::span!("wait for sync");651+ if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {
650- // element.sync.wait();652+ let _span = tracy_client::span!("wait for completion");
651- // }653+ element.sync.wait();
654+ }
655+ }
652 656
653 if res.damage.is_some() {657 if res.damage.is_some() {
654 let presentation_feedbacks =658 let presentation_feedbacks =
src/backend/winit.rsmodified+7 -0
@@ -15,6 +15,7 @@ use smithay::reexports::winit::window::WindowBuilder;
15 use smithay::utils::Transform;15 use smithay::utils::Transform;
16 use smithay::wayland::dmabuf::DmabufFeedback;16 use smithay::wayland::dmabuf::DmabufFeedback;
17 17
18+use crate::config::Config;
18 use crate::niri::OutputRenderElements;19 use crate::niri::OutputRenderElements;
19 use crate::utils::get_monotonic_time;20 use crate::utils::get_monotonic_time;
20 use crate::{LoopData, Niri};21 use crate::{LoopData, Niri};
@@ -136,6 +137,7 @@ impl Winit {
136 137
137 pub fn render(138 pub fn render(
138 &mut self,139 &mut self,
140+ config: &Config,
139 niri: &mut Niri,141 niri: &mut Niri,
140 output: &Output,142 output: &Output,
141 elements: &[OutputRenderElements<GlesRenderer>],143 elements: &[OutputRenderElements<GlesRenderer>],
@@ -149,6 +151,11 @@ impl Winit {
149 .render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])151 .render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])
150 .unwrap();152 .unwrap();
151 if let Some(damage) = res.damage {153 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+
152 self.backend.submit(Some(&damage)).unwrap();159 self.backend.submit(Some(&damage)).unwrap();
153 160
154 let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);161 let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);
src/config.rsmodified+3 -0
@@ -130,6 +130,8 @@ pub struct DebugConfig {
130 pub animation_slowdown: f64,130 pub animation_slowdown: f64,
131 #[knuffel(child)]131 #[knuffel(child)]
132 pub screen_cast_in_non_session_instances: bool,132 pub screen_cast_in_non_session_instances: bool,
133+ #[knuffel(child)]
134+ pub wait_for_frame_completion_before_queueing: bool,
133 }135 }
134 136
135 impl Default for DebugConfig {137 impl Default for DebugConfig {
@@ -137,6 +139,7 @@ impl Default for DebugConfig {
137 Self {139 Self {
138 animation_slowdown: 1.,140 animation_slowdown: 1.,
139 screen_cast_in_non_session_instances: false,141 screen_cast_in_non_session_instances: false,
142+ wait_for_frame_completion_before_queueing: false,
140 }143 }
141 }144 }
142 }145 }
src/niri.rsmodified+5 -3
@@ -690,7 +690,9 @@ impl Niri {
690 // Timer::immediate() adds a millisecond of delay for some reason.690 // Timer::immediate() adds a millisecond of delay for some reason.
691 // This should be fixed in calloop v0.11: https://github.com/Smithay/calloop/issues/142691 // This should be fixed in calloop v0.11: https://github.com/Smithay/calloop/issues/142
692 let idle = self.event_loop.insert_idle(move |data| {692 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);
694 });696 });
695 state.queued_redraw = Some(idle);697 state.queued_redraw = Some(idle);
696 }698 }
@@ -835,7 +837,7 @@ impl Niri {
835 elements837 elements
836 }838 }
837 839
838- fn redraw(&mut self, backend: &mut Backend, output: &Output) {840+ fn redraw(&mut self, config: &Config, backend: &mut Backend, output: &Output) {
839 let _span = tracy_client::span!("Niri::redraw");841 let _span = tracy_client::span!("Niri::redraw");
840 842
841 let state = self.output_state.get_mut(output).unwrap();843 let state = self.output_state.get_mut(output).unwrap();
@@ -852,7 +854,7 @@ impl Niri {
852 let elements = self.render(backend.renderer(), output);854 let elements = self.render(backend.renderer(), output);
853 855
854 // Hand it over to the backend.856 // 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);
856 858
857 // Send the dmabuf feedbacks.859 // Send the dmabuf feedbacks.
858 if let Some(feedback) = dmabuf_feedback {860 if let Some(feedback) = dmabuf_feedback {