diff --git a/Cargo.lock b/Cargo.lock index 38fb8790..5713295b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3966,9 +3966,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ "memchr", ] @@ -4556,7 +4556,7 @@ checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/smithay//smithay?rev=8f132ec#8f132ecded5705e55fc1ce6cfa4b59850c6b038e" +source = "git+https://github.com/ids1024/smithay?branch=drm-syncobj#85a4426661142b7fa5f60304a178ca6fa4ae71a5" dependencies = [ "appendlist", "ash", @@ -5533,13 +5533,12 @@ dependencies = [ [[package]] name = "wayland-backend" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" +version = "0.3.3" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "cc", "downcast-rs", - "nix 0.26.4", + "rustix 0.38.32", "scoped-tls", "smallvec", "wayland-sys", @@ -5547,12 +5546,11 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" +version = "0.31.2" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "bitflags 2.4.2", - "nix 0.26.4", + "rustix 0.38.32", "wayland-backend", "wayland-scanner", ] @@ -5570,11 +5568,11 @@ dependencies = [ [[package]] name = "wayland-cursor" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" +checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" dependencies = [ - "nix 0.26.4", + "rustix 0.38.32", "wayland-client", "xcursor", ] @@ -5582,8 +5580,7 @@ dependencies = [ [[package]] name = "wayland-egl" version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355f652e5a24ae02d2ad536c8fc2d3dcc6c2bd635027cd6103a193e7d75eeda2" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "wayland-backend", "wayland-sys", @@ -5592,8 +5589,7 @@ dependencies = [ [[package]] name = "wayland-protocols" version = "0.31.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "bitflags 2.4.2", "wayland-backend", @@ -5605,8 +5601,7 @@ dependencies = [ [[package]] name = "wayland-protocols-misc" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa5933740b200188c9b4c38601b8212e8c154d7de0d2cb171944e137a77de1e" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "bitflags 2.4.2", "wayland-backend", @@ -5631,8 +5626,7 @@ dependencies = [ [[package]] name = "wayland-protocols-wlr" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "bitflags 2.4.2", "wayland-backend", @@ -5644,9 +5638,8 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" +version = "0.31.1" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "proc-macro2", "quick-xml", @@ -5655,14 +5648,13 @@ dependencies = [ [[package]] name = "wayland-server" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3f0c52a445936ca1184c98f1a69cf4ad9c9130788884531ef04428468cb1ce" +version = "0.31.1" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "bitflags 2.4.2", "downcast-rs", "io-lifetimes 2.0.3", - "nix 0.26.4", + "rustix 0.38.32", "wayland-backend", "wayland-scanner", ] @@ -5670,8 +5662,7 @@ dependencies = [ [[package]] name = "wayland-sys" version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" +source = "git+https://github.com/smithay/wayland-rs#da5fde826432361f0d9bf996120fa2984b91e22f" dependencies = [ "dlib", "log", diff --git a/Cargo.toml b/Cargo.toml index f010c106..ea91d3c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,4 +118,17 @@ inherits = "release" lto = "fat" [patch."https://github.com/Smithay/smithay.git"] -smithay = {git = "https://github.com/smithay//smithay", rev = "8f132ec"} +# smithay = {git = "https://github.com/smithay//smithay", rev = "8f132ec"} +smithay = {git = "https://github.com/ids1024/smithay", branch = "drm-syncobj"} +# smithay = {path = "../../smithay"} + +[patch.crates-io] +wayland-egl = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs" } +wayland-protocols-misc = { git = "https://github.com/smithay/wayland-rs" } +wayland-server = { git = "https://github.com/smithay/wayland-rs" } +wayland-client = { git = "https://github.com/smithay/wayland-rs" } +wayland-sys = { git = "https://github.com/smithay/wayland-rs" } +wayland-backend = { git = "https://github.com/smithay/wayland-rs" } +wayland-scanner = { git = "https://github.com/smithay/wayland-rs" } diff --git a/src/backend/kms/mod.rs b/src/backend/kms/mod.rs index 6d684dce..d5709efc 100644 --- a/src/backend/kms/mod.rs +++ b/src/backend/kms/mod.rs @@ -78,6 +78,7 @@ use smithay::{ wayland::{ dmabuf::{get_dmabuf, DmabufFeedbackBuilder, DmabufGlobal}, drm_lease::{DrmLease, DrmLeaseState}, + drm_syncobj::DrmSyncobjState, relative_pointer::RelativePointerManagerState, seat::WaylandFocus, shm::{shm_format_to_fourcc, with_buffer_contents}, @@ -450,6 +451,9 @@ pub fn init_backend( // Create relative pointer global RelativePointerManagerState::new::(&dh); + // TODO check if main device supports syncobj eventfd? + DrmSyncobjState::new::(&dh); + state.launch_xwayland(Some(primary)); for (dev, path) in udev_dispatcher.as_source_ref().device_list() { diff --git a/src/wayland/handlers/compositor.rs b/src/wayland/handlers/compositor.rs index d81149d2..ac790e19 100644 --- a/src/wayland/handlers/compositor.rs +++ b/src/wayland/handlers/compositor.rs @@ -14,6 +14,7 @@ use smithay::{ CompositorHandler, CompositorState, SurfaceAttributes, }, dmabuf::get_dmabuf, + drm_syncobj::DrmSyncobjCachedState, seat::WaylandFocus, shell::{ wlr_layer::LayerSurfaceAttributes, @@ -100,7 +101,13 @@ impl CompositorHandler for State { fn new_surface(&mut self, surface: &WlSurface) { add_pre_commit_hook::(surface, move |state, _dh, surface| { + let mut acquire_point = None; let maybe_dmabuf = with_states(surface, |surface_data| { + acquire_point = surface_data + .cached_state + .pending::() + .acquire_point + .clone(); surface_data .cached_state .pending::() @@ -112,6 +119,25 @@ impl CompositorHandler for State { }) }); if let Some(dmabuf) = maybe_dmabuf { + if let Some(acquire_point) = acquire_point { + if let Ok((blocker, source)) = acquire_point.generate_blocker() { + let client = surface.client().unwrap(); + let res = state.common.event_loop_handle.insert_source( + source, + move |_, _, state| { + let dh = state.common.display_handle.clone(); + state + .client_compositor_state(&client) + .blocker_cleared(state, &dh); + Ok(()) + }, + ); + if res.is_ok() { + add_blocker(surface, blocker); + return; + } + } + } if let Ok((blocker, source)) = dmabuf.generate_blocker(Interest::READ) { let client = surface.client().unwrap(); let res = diff --git a/src/wayland/handlers/drm_syncobj.rs b/src/wayland/handlers/drm_syncobj.rs new file mode 100644 index 00000000..bcbb9671 --- /dev/null +++ b/src/wayland/handlers/drm_syncobj.rs @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-3.0-only + +use crate::state::{BackendData, State}; +use smithay::{ + backend::drm::DrmDeviceFd, delegate_drm_syncobj, wayland::drm_syncobj::DrmSyncobjHandler, +}; + +impl DrmSyncobjHandler for State { + fn import_device(&self) -> &DrmDeviceFd { + let kms = match &self.backend { + BackendData::Kms(kms) => kms, + _ => unreachable!(), + }; + kms.devices[&kms + .primary_node + .node_with_type(smithay::backend::drm::NodeType::Primary) + .unwrap() + .unwrap()] + .drm + .device_fd() + } +} + +delegate_drm_syncobj!(State); diff --git a/src/wayland/handlers/mod.rs b/src/wayland/handlers/mod.rs index 56971a96..9bc30272 100644 --- a/src/wayland/handlers/mod.rs +++ b/src/wayland/handlers/mod.rs @@ -8,6 +8,7 @@ pub mod decoration; pub mod dmabuf; pub mod drm; pub mod drm_lease; +pub mod drm_syncobj; pub mod fractional_scale; pub mod idle_inhibit; pub mod idle_notify;