diff --git a/Cargo.lock b/Cargo.lock index 92b48d24..dcbdf2f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -521,7 +521,7 @@ dependencies = [ [[package]] name = "jay-compositor" -version = "1.0.2" +version = "1.0.3" dependencies = [ "ahash", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index d540d035..f5b02837 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jay-compositor" -version = "1.0.2" +version = "1.0.3" edition = "2021" build = "build/build.rs" license = "GPL-3.0-only" diff --git a/build/logging.rs b/build/logging.rs index 4b228d1e..5184b2db 100644 --- a/build/logging.rs +++ b/build/logging.rs @@ -1,5 +1,30 @@ +use { + crate::open, + std::{fmt::Write as _, io::Write as _, process::Command}, +}; + pub fn main() -> anyhow::Result<()> { + create_bridge()?; + create_version()?; + Ok(()) +} + +fn create_bridge() -> anyhow::Result<()> { println!("cargo:rerun-if-changed=src/bridge.c"); cc::Build::new().file("src/bridge.c").compile("bridge"); Ok(()) } + +fn create_version() -> anyhow::Result<()> { + let mut version_string = env!("CARGO_PKG_VERSION").to_string(); + if let Ok(output) = Command::new("git").arg("rev-parse").arg("HEAD").output() { + if output.status.success() { + if let Ok(commit) = std::str::from_utf8(&output.stdout) { + write!(version_string, " ({})", commit.trim())?; + } + } + } + let mut f = open("version.rs")?; + writeln!(f, "pub const VERSION: &str = \"{}\";", version_string)?; + Ok(()) +} diff --git a/deploy-notes.md b/deploy-notes.md index 404a50d0..96c414fb 100644 --- a/deploy-notes.md +++ b/deploy-notes.md @@ -1,5 +1,9 @@ # Unreleased +# 1.0.3 + +- Needs jay-compositor release. + # 1.0.2 - Needs jay-compositor release. diff --git a/release-notes.md b/release-notes.md index 65e7ea38..e3a4d288 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,6 +2,10 @@ - Add support for wp-alpha-modifier. +# 1.0.3 (2024-04-11) + +- Partially disable explicit sync on nvidia drivers. + # 1.0.2 (2024-04-10) - Fixed a bug that caused the portal to fail. diff --git a/src/backends/metal/video.rs b/src/backends/metal/video.rs index 7d28ff93..fc72a813 100644 --- a/src/backends/metal/video.rs +++ b/src/backends/metal/video.rs @@ -88,6 +88,7 @@ pub struct MetalDrmDevice { pub ctx: CloneCell>, pub on_change: OnChange, pub direct_scanout_enabled: Cell>, + pub is_nvidia: bool, } impl MetalDrmDevice { @@ -633,7 +634,6 @@ impl MetalConnector { .perform_render_pass(pass) .map_err(MetalError::RenderFrame)?; sync_file = buffer.copy_to_dev(sf)?; - self.next_buffer.fetch_add(1); output.perform_screencopies(&buffer.render_tex, !render_hw_cursor, 0, 0, None); fb = buffer.drm.clone(); } @@ -714,7 +714,9 @@ impl MetalConnector { c.change(plane.crtc_y.id, crtc_y as u64); c.change(plane.crtc_w.id, crtc_w as u64); c.change(plane.crtc_h.id, crtc_h as u64); - c.change(plane.in_fence_fd, in_fence as u64); + if !self.dev.is_nvidia { + c.change(plane.in_fence_fd, in_fence as u64); + } }); new_fb = Some(fb); } @@ -748,7 +750,9 @@ impl MetalConnector { c.change(plane.src_y.id, 0); c.change(plane.src_w.id, (width as u64) << 16); c.change(plane.src_h.id, (height as u64) << 16); - c.change(plane.in_fence_fd, in_fence as u64); + if !self.dev.is_nvidia { + c.change(plane.in_fence_fd, in_fence as u64); + } }); } else { changes.change_object(plane.id, |c| { @@ -782,6 +786,9 @@ impl MetalConnector { Err(MetalError::Commit(e)) } else { if let Some(fb) = new_fb { + if fb.direct_scanout_data.is_none() { + self.next_buffer.fetch_add(1); + } self.next_framebuffer.set(Some(fb)); } if cursor_swap_buffer { @@ -1586,6 +1593,22 @@ impl MetalBackend { Err(e) => return Err(MetalError::GbmDevice(e)), }; + let mut is_nvidia = false; + match gbm.drm.version() { + Ok(v) => { + is_nvidia = v.name.contains_str("nvidia"); + if is_nvidia { + log::warn!( + "Device {} use the nvidia driver. IN_FENCE_FD will not be used.", + pending.devnode.as_bytes().as_bstr(), + ); + } + } + Err(e) => { + log::warn!("Could not fetch DRM version information: {}", ErrorFmt(e)); + } + } + let dev = Rc::new(MetalDrmDevice { backend: self.clone(), id: pending.id, @@ -1608,6 +1631,7 @@ impl MetalBackend { ctx: CloneCell::new(ctx), on_change: Default::default(), direct_scanout_enabled: Default::default(), + is_nvidia, }); let (connectors, futures) = get_connectors(self, &dev, &resources.connectors)?; @@ -2385,6 +2409,7 @@ impl MetalBackend { if let Some(old) = connector.buffers.set(Some(buffers)) { old_buffers.push(old); } + connector.next_buffer.set(1); connector.primary_plane.set(Some(primary_plane.clone())); if let Some(cp) = &cursor_plane { cp.assigned.set(true); diff --git a/src/compositor.rs b/src/compositor.rs index 98e07650..068f281e 100644 --- a/src/compositor.rs +++ b/src/compositor.rs @@ -38,6 +38,7 @@ use { oserror::OsError, queue::AsyncQueue, refcounted::RefCounted, run_toplevel::RunToplevel, tri::Try, }, + version::VERSION, video::drm::wait_for_sync_obj::WaitForSyncObj, wheel::{Wheel, WheelError}, xkbcommon::XkbContext, @@ -122,6 +123,7 @@ fn start_compositor2( test_future: Option, ) -> Result<(), CompositorError> { log::info!("pid = {}", uapi::getpid()); + log::info!("version = {VERSION}"); init_fd_limit(); leaks::init(); clientmem::init()?; diff --git a/src/main.rs b/src/main.rs index e22cbc93..bdd39264 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,6 +87,7 @@ mod tree; mod udev; mod user_session; mod utils; +mod version; mod video; mod wheel; mod wire; diff --git a/src/portal.rs b/src/portal.rs index dc86725a..e196c9fb 100644 --- a/src/portal.rs +++ b/src/portal.rs @@ -31,6 +31,7 @@ use { run_toplevel::RunToplevel, xrd::xrd, }, + version::VERSION, video::dmabuf::DmaBufIds, wheel::Wheel, wire_dbus::org, @@ -226,6 +227,7 @@ async fn init_dbus_session(dbus: &Dbus, logger: Arc) -> Rc { Ok(r) if r.get().rv == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER => { log::info!("Acquired unique name {}", UNIQUE_NAME); logger.redirect("portal"); + log::info!("version = {VERSION}"); let fork = match fork_with_pidfd(false) { Ok(f) => f, Err(e) => fatal!("Could not fork: {}", ErrorFmt(e)), diff --git a/src/version.rs b/src/version.rs new file mode 100644 index 00000000..1a10d703 --- /dev/null +++ b/src/version.rs @@ -0,0 +1 @@ +include!(concat!(env!("OUT_DIR"), "/version.rs"));