From 6ae0a3510ac66052e64b2d5edbbeccb267c70d09 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Sat, 22 Jan 2022 22:11:57 +0100 Subject: [PATCH] winit: Fix returned buffer age --- src/backend/renderer/gles2/mod.rs | 5 ++--- src/backend/winit/mod.rs | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backend/renderer/gles2/mod.rs b/src/backend/renderer/gles2/mod.rs index 9df9829..0d0bce2 100644 --- a/src/backend/renderer/gles2/mod.rs +++ b/src/backend/renderer/gles2/mod.rs @@ -874,6 +874,7 @@ impl Bind> for Gles2Renderer { fn bind(&mut self, surface: Rc) -> Result<(), Gles2Error> { self.unbind()?; self.target_surface = Some(surface); + self.make_current()?; Ok(()) } } @@ -881,9 +882,7 @@ impl Bind> for Gles2Renderer { impl Bind for Gles2Renderer { fn bind(&mut self, dmabuf: Dmabuf) -> Result<(), Gles2Error> { self.unbind()?; - unsafe { - self.egl.make_current()?; - } + self.make_current()?; // Free outdated buffer resources // TODO: Replace with `drain_filter` once it lands diff --git a/src/backend/winit/mod.rs b/src/backend/winit/mod.rs index d78560a..6223c90 100644 --- a/src/backend/winit/mod.rs +++ b/src/backend/winit/mod.rs @@ -302,7 +302,11 @@ impl WinitGraphicsBackend { Ok(()) } - /// Retrieve the buffer age of the current backbuffer of the window + /// Retrieve the buffer age of the current backbuffer of the window. + /// + /// This will only return a meaningful value, if this `WinitGraphicsBackend` + /// is currently bound (by previously calling [`WinitGraphicsBackend::bind`]). + /// Otherwise the contents of the return value are undefined. pub fn buffer_age(&self) -> usize { if self.damage_tracking { self.egl.buffer_age() as usize