From 0c19a461b65c4eae368e24007bafe371c03d8220 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Fri, 22 May 2020 23:15:07 +0200 Subject: [PATCH] anvil: use fallback-device for gbm/nvidia --- anvil/Cargo.toml | 2 +- anvil/src/udev.rs | 48 +++++++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/anvil/Cargo.toml b/anvil/Cargo.toml index 263fff5..e8d5637 100644 --- a/anvil/Cargo.toml +++ b/anvil/Cargo.toml @@ -29,5 +29,5 @@ gl_generator = "0.14" default = [ "winit", "egl", "udev", "logind" ] egl = [ "smithay/use_system_lib" ] winit = [ "smithay/backend_winit" ] -udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm_atomic", "smithay/backend_drm_legacy", "smithay/backend_drm_gbm", "smithay/backend_drm_egl", "smithay/backend_session", "input" ] +udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm_atomic", "smithay/backend_drm_legacy", "smithay/backend_drm_gbm", "smithay/backend_drm_eglstream", "smithay/backend_drm_egl", "smithay/backend_session", "input" ] logind = [ "smithay/backend_session_logind" ] diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index 2579b7b..d489e85 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -18,9 +18,10 @@ use smithay::{ backend::{ drm::{ atomic::AtomicDrmDevice, - common::fallback::FallbackDevice, + common::fallback::{FallbackDevice, FallbackSurface}, device_bind, egl::{EglDevice, EglSurface}, + eglstream::{egl::EglStreamDeviceBackend, EglStreamDevice, EglStreamSurface}, gbm::{egl::Gbm as EglGbmBackend, GbmDevice, GbmSurface}, legacy::LegacyDrmDevice, DevPath, Device, DeviceHandler, Surface, @@ -76,12 +77,20 @@ impl AsRawFd for SessionFd { } } -type RenderDevice = EglDevice< - EglGbmBackend, LegacyDrmDevice>>, - GbmDevice, LegacyDrmDevice>>, +type RenderDevice = FallbackDevice< + EglDevice< + EglGbmBackend, LegacyDrmDevice>>, + GbmDevice, LegacyDrmDevice>>, + >, + EglDevice< + EglStreamDeviceBackend, LegacyDrmDevice>>, + EglStreamDevice, LegacyDrmDevice>>, + >, +>; +type RenderSurface = FallbackSurface< + EglSurface, LegacyDrmDevice>>>, + EglSurface, LegacyDrmDevice>>>, >; -type RenderSurface = - EglSurface, LegacyDrmDevice>>>; pub fn run_udev( display: Rc>, @@ -376,23 +385,29 @@ impl UdevHandlerImpl { OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, ) .ok() - .and_then( - |fd| match FallbackDevice::new(SessionFd(fd), true, self.logger.clone()) { + .and_then(|fd| { + match FallbackDevice::, LegacyDrmDevice<_>>::new( + SessionFd(fd), + true, + self.logger.clone(), + ) { Ok(drm) => Some(drm), Err(err) => { warn!(self.logger, "Skipping drm device, because of error: {}", err); None } - }, - ) - .and_then(|drm| match GbmDevice::new(drm, self.logger.clone()) { - Ok(gbm) => Some(gbm), - Err(err) => { - warn!(self.logger, "Skipping gbm device, because of error: {}", err); - None } }) - .and_then(|gbm| match EglDevice::new(gbm, self.logger.clone()) { + .and_then(|drm| { + match FallbackDevice::, EglStreamDevice<_>>::new(drm, self.logger.clone()) { + Ok(dev) => Some(dev), + Err(err) => { + warn!(self.logger, "Skipping device, because of error: {}", err); + None + } + } + }) + .and_then(|dev| match FallbackDevice::new_egl(dev, self.logger.clone()) { Ok(egl) => Some(egl), Err(err) => { warn!(self.logger, "Skipping egl device, because of error: {}", err); @@ -657,6 +672,7 @@ impl DrmRenderer { }; if reschedule { + debug!(self.logger, "Rescheduling"); match (timer, evt_handle) { (Some(handle), _) => { let _ = handle.add_timeout(