Skip to content

Commit

Permalink
Remove unnecessary GPU field
Browse files Browse the repository at this point in the history
The `bind_wl_display` can be called unconditionally and doesn't need to
check the GPU node path. So we can avoid getting the primary GPU
entirely.

Closes #155.
  • Loading branch information
chrisduerr committed Sep 2, 2024
1 parent de977fa commit 2cc5383
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use smithay::backend::renderer::{
};
use smithay::backend::session::libseat::LibSeatSession;
use smithay::backend::session::{AsErrno, Event as SessionEvent, Session};
use smithay::backend::udev;
use smithay::backend::udev::{UdevBackend, UdevEvent};
use smithay::output::{Mode, OutputModeSource, PhysicalProperties, Subpixel};
use smithay::reexports::calloop::generic::Generic;
Expand Down Expand Up @@ -142,7 +141,6 @@ pub struct Udev {
event_loop: LoopHandle<'static, Catacomb>,
output_device: Option<OutputDevice>,
session: LibSeatSession,
gpu: Option<PathBuf>,
}

impl Udev {
Expand Down Expand Up @@ -205,13 +203,9 @@ impl Udev {
})
.expect("insert notifier source");

// Find active GPUs for hardware acceleration.
let gpu = udev::primary_gpu(session.seat()).ok().flatten();

Self {
event_loop,
session,
gpu,
scheduled_redraws: Default::default(),
output_device: Default::default(),
}
Expand Down Expand Up @@ -362,9 +356,7 @@ impl Udev {
};

// Initialize GPU for EGL rendering.
if Some(path) == self.gpu.as_deref() {
trace_error!(gles.bind_wl_display(display_handle));
}
trace_error!(gles.bind_wl_display(display_handle));

// Create the DRM compositor.
let drm_compositor = self
Expand Down Expand Up @@ -432,13 +424,8 @@ impl Udev {

fn remove_device(&mut self, device_id: DeviceId) {
let output_device = self.output_device.take();
if let Some(mut output_device) = output_device.filter(|device| device.id == device_id) {
if let Some(output_device) = output_device.filter(|device| device.id == device_id) {
self.event_loop.remove(output_device.token);

// Disable hardware acceleration when the GPU is removed.
if output_device.gbm.dev_path() == self.gpu {
output_device.gles.unbind_wl_display();
}
}
}

Expand Down

0 comments on commit 2cc5383

Please sign in to comment.