diff --git a/src/backend/renderer/gles/mod.rs b/src/backend/renderer/gles/mod.rs index eae24a0faa36..a59dd3cd1525 100644 --- a/src/backend/renderer/gles/mod.rs +++ b/src/backend/renderer/gles/mod.rs @@ -627,7 +627,6 @@ impl GlesRenderer { #[profiling::function] fn cleanup(&mut self) { - #[cfg(feature = "wayland_frontend")] self.dmabuf_cache.retain(|entry, _tex| !entry.is_gone()); // Free outdated buffer resources // TODO: Replace with `drain_filter` once it lands diff --git a/src/backend/renderer/pixman/mod.rs b/src/backend/renderer/pixman/mod.rs index ace6a51297ed..05f4eec095f4 100644 --- a/src/backend/renderer/pixman/mod.rs +++ b/src/backend/renderer/pixman/mod.rs @@ -25,7 +25,7 @@ use crate::{ wayland::{compositor::SurfaceData, shm}, }; #[cfg(feature = "wayland_frontend")] -use wayland_server::{protocol::wl_buffer, Resource, Weak}; +use wayland_server::protocol::wl_buffer; #[cfg(all( feature = "wayland_frontend", @@ -89,7 +89,7 @@ struct PixmanDmabufMapping { #[derive(Debug)] struct PixmanImageInner { #[cfg(feature = "wayland_frontend")] - buffer: Option>, + buffer: Option, dmabuf: Option, image: RefCell>, _flipped: bool, /* TODO: What about flipped textures? */ @@ -101,13 +101,6 @@ struct PixmanImage(Rc); impl PixmanImage { #[profiling::function] fn accessor<'l>(&'l self) -> Result, PixmanError> { - #[cfg(feature = "wayland_frontend")] - let buffer = if let Some(buffer) = self.0.buffer.as_ref() { - Some(buffer.upgrade().map_err(|_| PixmanError::BufferDestroyed)?) - } else { - None - }; - let guard = if let Some(mapping) = self.0.dmabuf.as_ref() { let dmabuf = mapping.dmabuf.upgrade().ok_or(PixmanError::BufferDestroyed)?; Some(DmabufReadGuard::new(dmabuf)?) @@ -117,7 +110,7 @@ impl PixmanImage { Ok(TextureAccessor { #[cfg(feature = "wayland_frontend")] - buffer, + buffer: self.0.buffer.clone(), image: &self.0.image, _guard: guard, }) @@ -746,6 +739,9 @@ impl PixmanRenderer { }); } + dmabuf.sync_plane(0, DmabufSyncFlags::START | DmabufSyncFlags::READ)?; + dmabuf.sync_plane(0, DmabufSyncFlags::END | DmabufSyncFlags::READ)?; + let image: Image<'_, '_> = unsafe { pixman::Image::from_raw_mut( format, @@ -1127,7 +1123,7 @@ impl ImportMemWl for PixmanRenderer { std::result::Result::<_, PixmanError>::Ok(image) })??; Ok(PixmanTexture(PixmanImage(Rc::new(PixmanImageInner { - buffer: Some(buffer.downgrade()), + buffer: Some(buffer.clone()), dmabuf: None, image: RefCell::new(image), _flipped: false,