Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metal: disable IN_FENCE_FD on nvidia driver #160

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
25 changes: 25 additions & 0 deletions build/logging.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
4 changes: 4 additions & 0 deletions deploy-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

# 1.0.3

- Needs jay-compositor release.

# 1.0.2

- Needs jay-compositor release.
Expand Down
4 changes: 4 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
31 changes: 28 additions & 3 deletions src/backends/metal/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct MetalDrmDevice {
pub ctx: CloneCell<Rc<MetalRenderContext>>,
pub on_change: OnChange<crate::backend::DrmEvent>,
pub direct_scanout_enabled: Cell<Option<bool>>,
pub is_nvidia: bool,
}

impl MetalDrmDevice {
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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)?;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -122,6 +123,7 @@ fn start_compositor2(
test_future: Option<TestFuture>,
) -> Result<(), CompositorError> {
log::info!("pid = {}", uapi::getpid());
log::info!("version = {VERSION}");
init_fd_limit();
leaks::init();
clientmem::init()?;
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ mod tree;
mod udev;
mod user_session;
mod utils;
mod version;
mod video;
mod wheel;
mod wire;
Expand Down
2 changes: 2 additions & 0 deletions src/portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use {
run_toplevel::RunToplevel,
xrd::xrd,
},
version::VERSION,
video::dmabuf::DmaBufIds,
wheel::Wheel,
wire_dbus::org,
Expand Down Expand Up @@ -226,6 +227,7 @@ async fn init_dbus_session(dbus: &Dbus, logger: Arc<Logger>) -> Rc<DbusSocket> {
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)),
Expand Down
1 change: 1 addition & 0 deletions src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/version.rs"));
Loading