forge
Explore
Log in

Don't you dare go Hollow

Return RenderResult from render()

Browse files at this commit

29053a807b8969d3e2eb88c7065a087aaa137a31Ivan MolodetskikhParent: 0a32747
src/backend/mod.rsmodified+11 -1
@@ -20,6 +20,16 @@ pub enum Backend {
20 Winit(Winit),20 Winit(Winit),
21 }21 }
22 22
23+#[derive(PartialEq, Eq)]
24+pub enum RenderResult {
25+ /// The frame was submitted to the backend for presentation.
26+ Submitted,
27+ /// Rendering succeeded, but there was no damage.
28+ NoDamage,
29+ /// An error has occurred, the frame was not submitted.
30+ Error,
31+}
32+
23 impl Backend {33 impl Backend {
24 pub fn init(&mut self, niri: &mut Niri) {34 pub fn init(&mut self, niri: &mut Niri) {
25 match self {35 match self {
@@ -48,7 +58,7 @@ impl Backend {
48 output: &Output,58 output: &Output,
49 elements: &[OutputRenderElements<GlesRenderer>],59 elements: &[OutputRenderElements<GlesRenderer>],
50 target_presentation_time: Duration,60 target_presentation_time: Duration,
51- ) {61+ ) -> RenderResult {
52 match self {62 match self {
53 Backend::Tty(tty) => tty.render(niri, output, elements, target_presentation_time),63 Backend::Tty(tty) => tty.render(niri, output, elements, target_presentation_time),
54 Backend::Winit(winit) => winit.render(niri, output, elements),64 Backend::Winit(winit) => winit.render(niri, output, elements),
src/backend/tty.rsmodified+12 -4
@@ -43,6 +43,8 @@ use crate::niri::{OutputRenderElements, State, RedrawState};
43 use crate::utils::get_monotonic_time;43 use crate::utils::get_monotonic_time;
44 use crate::Niri;44 use crate::Niri;
45 45
46+use super::RenderResult;
47+
46 const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888];48 const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888];
47 49
48 pub struct Tty {50 pub struct Tty {
@@ -837,18 +839,20 @@ impl Tty {
837 output: &Output,839 output: &Output,
838 elements: &[OutputRenderElements<GlesRenderer>],840 elements: &[OutputRenderElements<GlesRenderer>],
839 target_presentation_time: Duration,841 target_presentation_time: Duration,
840- ) {842+ ) -> RenderResult {
841 let span = tracy_client::span!("Tty::render");843 let span = tracy_client::span!("Tty::render");
842 844
845+ let mut rv = RenderResult::Error;
846+
843 let Some(device) = self.output_device.as_mut() else {847 let Some(device) = self.output_device.as_mut() else {
844 error!("missing output device");848 error!("missing output device");
845- return;849+ return rv;
846 };850 };
847 851
848 let tty_state: &TtyOutputState = output.user_data().get().unwrap();852 let tty_state: &TtyOutputState = output.user_data().get().unwrap();
849 let Some(surface) = device.surfaces.get_mut(&tty_state.crtc) else {853 let Some(surface) = device.surfaces.get_mut(&tty_state.crtc) else {
850 error!("missing surface");854 error!("missing surface");
851- return;855+ return rv;
852 };856 };
853 857
854 span.emit_text(&surface.name);858 span.emit_text(&surface.name);
@@ -896,12 +900,14 @@ impl Tty {
896 }900 }
897 };901 };
898 902
899- return;903+ return RenderResult::Submitted;
900 }904 }
901 Err(err) => {905 Err(err) => {
902 error!("error queueing frame: {err}");906 error!("error queueing frame: {err}");
903 }907 }
904 }908 }
909+ } else {
910+ rv = RenderResult::NoDamage;
905 }911 }
906 }912 }
907 Err(err) => {913 Err(err) => {
@@ -915,6 +921,8 @@ impl Tty {
915 921
916 // Queue a timer to fire at the predicted vblank time.922 // Queue a timer to fire at the predicted vblank time.
917 queue_estimated_vblank_timer(niri, output.clone(), target_presentation_time);923 queue_estimated_vblank_timer(niri, output.clone(), target_presentation_time);
924+
925+ rv
918 }926 }
919 927
920 pub fn change_vt(&mut self, vt: i32) {928 pub fn change_vt(&mut self, vt: i32) {
src/backend/winit.rsmodified+9 -1
@@ -17,6 +17,7 @@ use smithay::reexports::winit::dpi::LogicalSize;
17 use smithay::reexports::winit::window::WindowBuilder;17 use smithay::reexports::winit::window::WindowBuilder;
18 use smithay::utils::Transform;18 use smithay::utils::Transform;
19 19
20+use super::RenderResult;
20 use crate::config::Config;21 use crate::config::Config;
21 use crate::niri::{OutputRenderElements, RedrawState, State};22 use crate::niri::{OutputRenderElements, RedrawState, State};
22 use crate::utils::get_monotonic_time;23 use crate::utils::get_monotonic_time;
@@ -151,7 +152,7 @@ impl Winit {
151 niri: &mut Niri,152 niri: &mut Niri,
152 output: &Output,153 output: &Output,
153 elements: &[OutputRenderElements<GlesRenderer>],154 elements: &[OutputRenderElements<GlesRenderer>],
154- ) {155+ ) -> RenderResult {
155 let _span = tracy_client::span!("Winit::render");156 let _span = tracy_client::span!("Winit::render");
156 157
157 self.backend.bind().unwrap();158 self.backend.bind().unwrap();
@@ -164,6 +165,7 @@ impl Winit {
164 165
165 niri.update_primary_scanout_output(output, &res.states);166 niri.update_primary_scanout_output(output, &res.states);
166 167
168+ let rv;
167 if let Some(damage) = res.damage {169 if let Some(damage) = res.damage {
168 if self170 if self
169 .config171 .config
@@ -186,6 +188,10 @@ impl Winit {
186 0,188 0,
187 wp_presentation_feedback::Kind::empty(),189 wp_presentation_feedback::Kind::empty(),
188 );190 );
191+
192+ rv = RenderResult::Submitted;
193+ } else {
194+ rv = RenderResult::NoDamage;
189 }195 }
190 196
191 let output_state = niri.output_state.get_mut(output).unwrap();197 let output_state = niri.output_state.get_mut(output).unwrap();
@@ -200,6 +206,8 @@ impl Winit {
200 if output_state.unfinished_animations_remain {206 if output_state.unfinished_animations_remain {
201 self.backend.window().request_redraw();207 self.backend.window().request_redraw();
202 }208 }
209+
210+ rv
203 }211 }
204 212
205 pub fn toggle_debug_tint(&mut self) {213 pub fn toggle_debug_tint(&mut self) {