anvil: use fallback-device for gbm/nvidia

This commit is contained in:
Victor Brekenfeld 2020-05-22 23:15:07 +02:00
parent 9acd109a04
commit 0c19a461b6
2 changed files with 33 additions and 17 deletions

View File

@ -29,5 +29,5 @@ gl_generator = "0.14"
default = [ "winit", "egl", "udev", "logind" ] default = [ "winit", "egl", "udev", "logind" ]
egl = [ "smithay/use_system_lib" ] egl = [ "smithay/use_system_lib" ]
winit = [ "smithay/backend_winit" ] 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" ] logind = [ "smithay/backend_session_logind" ]

View File

@ -18,9 +18,10 @@ use smithay::{
backend::{ backend::{
drm::{ drm::{
atomic::AtomicDrmDevice, atomic::AtomicDrmDevice,
common::fallback::FallbackDevice, common::fallback::{FallbackDevice, FallbackSurface},
device_bind, device_bind,
egl::{EglDevice, EglSurface}, egl::{EglDevice, EglSurface},
eglstream::{egl::EglStreamDeviceBackend, EglStreamDevice, EglStreamSurface},
gbm::{egl::Gbm as EglGbmBackend, GbmDevice, GbmSurface}, gbm::{egl::Gbm as EglGbmBackend, GbmDevice, GbmSurface},
legacy::LegacyDrmDevice, legacy::LegacyDrmDevice,
DevPath, Device, DeviceHandler, Surface, DevPath, Device, DeviceHandler, Surface,
@ -76,12 +77,20 @@ impl AsRawFd for SessionFd {
} }
} }
type RenderDevice = EglDevice< type RenderDevice = FallbackDevice<
EglDevice<
EglGbmBackend<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>, EglGbmBackend<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
GbmDevice<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>, GbmDevice<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
>,
EglDevice<
EglStreamDeviceBackend<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
EglStreamDevice<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
>,
>;
type RenderSurface = FallbackSurface<
EglSurface<GbmSurface<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>>,
EglSurface<EglStreamSurface<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>>,
>; >;
type RenderSurface =
EglSurface<GbmSurface<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>>;
pub fn run_udev( pub fn run_udev(
display: Rc<RefCell<Display>>, display: Rc<RefCell<Display>>,
@ -376,23 +385,29 @@ impl<S: SessionNotifier, Data: 'static> UdevHandlerImpl<S, Data> {
OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
) )
.ok() .ok()
.and_then( .and_then(|fd| {
|fd| match FallbackDevice::new(SessionFd(fd), true, self.logger.clone()) { match FallbackDevice::<AtomicDrmDevice<_>, LegacyDrmDevice<_>>::new(
SessionFd(fd),
true,
self.logger.clone(),
) {
Ok(drm) => Some(drm), Ok(drm) => Some(drm),
Err(err) => { Err(err) => {
warn!(self.logger, "Skipping drm device, because of error: {}", err); warn!(self.logger, "Skipping drm device, because of error: {}", err);
None 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::<GbmDevice<_>, 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), Ok(egl) => Some(egl),
Err(err) => { Err(err) => {
warn!(self.logger, "Skipping egl device, because of error: {}", err); warn!(self.logger, "Skipping egl device, because of error: {}", err);
@ -657,6 +672,7 @@ impl DrmRenderer {
}; };
if reschedule { if reschedule {
debug!(self.logger, "Rescheduling");
match (timer, evt_handle) { match (timer, evt_handle) {
(Some(handle), _) => { (Some(handle), _) => {
let _ = handle.add_timeout( let _ = handle.add_timeout(