From 72f98e71bad003777416c342a49960e8b921b847 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 16 Feb 2024 12:08:16 -0800 Subject: [PATCH] Bind dmabuf v5 This makes creating a dmabuf with different modifiers for different planes a protocol error. This *could* be considered a breaking API change, but I don't think we need a semver bump for it because: * Callers should never have actually used different modifiers for different planes, since this was never valid. * Most users of this protocol tend to use `create_immed`, in which case they would get a protocol error. So it's "breaking" if an application calls `create` with non-sense params and then expects to get `failed`. When we do have an API break, the API should probably be changed to only allow a single modifier. This change isn't important, but will be needed for future updates to dmabuf. --- Cargo.toml | 2 +- examples/dmabuf_formats.rs | 4 ++-- src/dmabuf.rs | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cbfb69a9f..3c3e1ce67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ thiserror = "1.0.30" wayland-backend = "0.3.0" wayland-client = "0.31.1" wayland-cursor = "0.31.0" -wayland-protocols = { version = "0.31.0", features = ["client", "staging", "unstable"] } +wayland-protocols = { version = "0.31.2", features = ["client", "staging", "unstable"] } wayland-protocols-wlr = { version = "0.2.0", features = ["client"] } wayland-scanner = "0.31.0" wayland-csd-frame = "0.3.0" diff --git a/examples/dmabuf_formats.rs b/examples/dmabuf_formats.rs index 27828571f..1ac838dd9 100644 --- a/examples/dmabuf_formats.rs +++ b/examples/dmabuf_formats.rs @@ -92,8 +92,8 @@ fn main() { return; } - Some(4..) => { - println!("Version `4` of `zwp_linux_dmabuf_v1` supported. Showing default dmabuf feedback.\n"); + Some(ver @ 4..) => { + println!("Version `{}` of `zwp_linux_dmabuf_v1` supported. Showing default dmabuf feedback.\n", ver); app_data.dmabuf_state.get_default_feedback(&qh).unwrap(); diff --git a/src/dmabuf.rs b/src/dmabuf.rs index c1c34841a..a947b58ca 100644 --- a/src/dmabuf.rs +++ b/src/dmabuf.rs @@ -124,7 +124,7 @@ impl DmabufState { D: Dispatch + 'static, { // Mesa (at least the latest version) also requires version 3 or 4 - let zwp_linux_dmabuf = GlobalProxy::from(globals.bind(qh, 3..=4, GlobalData)); + let zwp_linux_dmabuf = GlobalProxy::from(globals.bind(qh, 3..=5, GlobalData)); Self { zwp_linux_dmabuf, modifiers: Vec::new() } } @@ -230,6 +230,9 @@ impl DmabufParams { /// /// In version `4`, it is a protocol error if `format`/`modifier` pair wasn't /// advertised as supported. + /// + /// `modifier` should be the same for all planes. It is a protocol error in version `5` if + /// they differ. pub fn add(&self, fd: BorrowedFd<'_>, plane_idx: u32, offset: u32, stride: u32, modifier: u64) { let modifier_hi = (modifier >> 32) as u32; let modifier_lo = (modifier & 0xffffffff) as u32;