From e8b83d2abc6a6797153742b11a1c96a907560b88 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 9 Jan 2024 03:28:08 -0800 Subject: [PATCH 1/4] wayland: Fix buffer age We need to reset the age of the *new* front buffer to 1, not the old one. It turns out they're easy to mix up right when you're about to swap them. Cherry-picked from `master` to 0.3. --- src/wayland/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 05b409f8..713515d9 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -147,14 +147,14 @@ impl WaylandImpl { .dispatch_pending(&mut State); if let Some((front, back)) = &mut self.buffers { + // Swap front and back buffer + std::mem::swap(front, back); + front.age = 1; if back.age != 0 { back.age += 1; } - // Swap front and back buffer - std::mem::swap(front, back); - front.attach(&self.surface); // Like Mesa's EGL/WSI implementation, we damage the whole buffer with `i32::MAX` if From b81db342a10bc713309eb70e17693c254f226351 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 14 Nov 2023 08:33:56 -0800 Subject: [PATCH 2/4] Update `drm` to 0.11 Drm-rs now no longer requires separate generated bindings for each platform, so this fixes the build on architectures/OSes where drm didn't have bindings. It also now uses Rustix instead of Nix, but Nix is still used by the Wayland and X11 backends, until the next wayland-rs and x11rb release. This is not a breaking change since `drm` isn't exposed in the API. Cherry-picked from `master` to 0.3. --- Cargo.toml | 2 +- src/kms.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5800cbf3..b9781556 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ raw-window-handle = "0.5.0" [target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dependencies] as-raw-xcb-connection = { version = "1.0.0", optional = true } bytemuck = { version = "1.12.3", optional = true } -drm = { version = "0.10.0", default-features = false, optional = true } +drm = { version = "0.11.0", default-features = false, optional = true } fastrand = { version = "2.0.0", optional = true } memmap2 = { version = "0.9.0", optional = true } rustix = { version = "0.38.19", features = ["fs", "mm", "shm", "std"], default-features = false, optional = true } diff --git a/src/kms.rs b/src/kms.rs index aa7ebb55..a83bd2a7 100644 --- a/src/kms.rs +++ b/src/kms.rs @@ -333,8 +333,7 @@ impl BufferImpl<'_> { // returns `ENOSYS` and check that before allocating the above and running this. match self.display.dirty_framebuffer(self.front_fb, &rectangles) { Ok(()) => {} - Err(drm::SystemError::Unknown { errno }) - if errno as i32 == rustix::io::Errno::NOSYS.raw_os_error() => {} + Err(e) if e.raw_os_error() == Some(rustix::io::Errno::NOSYS.raw_os_error()) => {} Err(e) => { return Err(SoftBufferError::PlatformError( Some("failed to dirty framebuffer".into()), From 782584c4f340a099aae8ff34f4cea2888445ba46 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 10 Jan 2024 15:40:53 -0800 Subject: [PATCH 3/4] `cargo fmt` to make CI happy --- src/x11.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/x11.rs b/src/x11.rs index d040d490..43a79ca6 100644 --- a/src/x11.rs +++ b/src/x11.rs @@ -8,7 +8,10 @@ use crate::error::SwResultExt; use crate::{Rect, SoftBufferError}; use raw_window_handle::{XcbDisplayHandle, XcbWindowHandle, XlibDisplayHandle, XlibWindowHandle}; -use rustix::{fd::{AsFd, BorrowedFd, OwnedFd}, mm, shm as posix_shm}; +use rustix::{ + fd::{AsFd, BorrowedFd, OwnedFd}, + mm, shm as posix_shm, +}; use std::{ fmt, From 5c7daf1a1f70acbc82c092e2d5ac85fd459acd0c Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 9 Jan 2024 08:53:35 -0800 Subject: [PATCH 4/4] v0.3.4 --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ba9123..30c25153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.3.4 +* Fix buffer age on Wayland. (#191) +* Update `drm` to 0.11. (#178) + * Fixes build on architectures where drm-rs did not have generated bindings. + # 0.3.3 * Fix bad file descriptor crash on X11. (#168) diff --git a/Cargo.toml b/Cargo.toml index b9781556..3fe4b149 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "softbuffer" -version = "0.3.3" +version = "0.3.4" edition = "2021" license = "MIT OR Apache-2.0" description = "Cross-platform software buffer"