From 6d51d1dea011c0ec5b9f2cde1ac3fd10534cf71c Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Wed, 22 Dec 2021 21:02:22 +0100 Subject: [PATCH] x11: Don't use modifiers on old dri3 versions Older dri3 versions (< 1.2) do only support dmabufs with one plane. Lets limit the modifiers early, if we detect that, so we do not end up allocating buffers the interface does not accept. --- src/backend/x11/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/x11/mod.rs b/src/backend/x11/mod.rs index a32d48f..ec98786 100644 --- a/src/backend/x11/mod.rs +++ b/src/backend/x11/mod.rs @@ -367,7 +367,12 @@ impl X11Handle { return Err(X11Error::InvalidWindow); } - let modifiers = modifiers.collect::>(); + let mut modifiers = modifiers.collect::>(); + // older dri3 versions do only support buffers with one plane. + // we need to make sure, we don't accidently allocate buffers with more. + if window.0.extensions.dri3 < Some((1, 2)) { + modifiers.retain(|modi| modi == &DrmModifier::Invalid || modi == &DrmModifier::Linear); + } let format = window.0.format; let size = window.size();