diff --git a/CHANGELOG.md b/CHANGELOG.md index e3b1538..728bdbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Remove `InputBackend::dispatch_new_events`, turning `InputBackend` into a definition of backend event types. Future input backends should be a `calloop::EventSource`. - Remove `InputBackend::EventError` associated type as it is unneeded since `dispatch_new_events` was removed. - `Swapchain` does not have a generic Userdata-parameter anymore, but utilizes `UserDataMap` instead +- `GbmBufferedSurface::next_buffer` now additionally returns the age of the buffer ### Additions diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index fbec837..957a419 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -738,7 +738,7 @@ fn render_surface( return Ok(()); }; - let dmabuf = surface.surface.next_buffer()?; + let (dmabuf, _age) = surface.surface.next_buffer()?; renderer.bind(dmabuf)?; // and draw to our buffer @@ -867,7 +867,7 @@ fn schedule_initial_render( } fn initial_render(surface: &mut RenderSurface, renderer: &mut Gles2Renderer) -> Result<(), SwapBuffersError> { - let dmabuf = surface.next_buffer()?; + let (dmabuf, _age) = surface.next_buffer()?; renderer.bind(dmabuf)?; // Does not matter if we render an empty frame renderer diff --git a/src/backend/drm/surface/gbm.rs b/src/backend/drm/surface/gbm.rs index b6b8be2..3bc5be0 100644 --- a/src/backend/drm/surface/gbm.rs +++ b/src/backend/drm/surface/gbm.rs @@ -167,11 +167,11 @@ where } } - /// Retrieves the next buffer to be rendered into. + /// Retrieves the next buffer to be rendered into and it's age. /// /// *Note*: This function can be called multiple times and /// will return the same buffer until it is queued (see [`GbmBufferedSurface::queue_buffer`]). - pub fn next_buffer(&mut self) -> Result { + pub fn next_buffer(&mut self) -> Result<(Dmabuf, u8), Error> { if self.next_fb.is_none() { let slot = self.swapchain.acquire()?.ok_or(Error::NoFreeSlotsError)?; @@ -189,7 +189,7 @@ where } let slot = self.next_fb.as_ref().unwrap(); - Ok(slot.userdata().get::().unwrap().clone()) + Ok((slot.userdata().get::().unwrap().clone(), slot.age())) } /// Queues the current buffer for rendering. @@ -213,6 +213,7 @@ where pub fn frame_submitted(&mut self) -> Result<(), Error> { if let Some(mut pending) = self.pending_fb.take() { std::mem::swap(&mut pending, &mut self.current_fb); + self.swapchain.submitted(pending); if self.queued_fb.is_some() { self.submit()?; }