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

Selectively disable direct-scanout to reduce bandwidth #969

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
20 changes: 19 additions & 1 deletion src/backend/kms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ use std::{
borrow::BorrowMut,
collections::{HashMap, HashSet},
path::Path,
sync::{atomic::AtomicBool, Arc, RwLock},
sync::{atomic::AtomicBool, mpsc::sync_channel, Arc, RwLock},
time::Duration,
};

mod device;
Expand Down Expand Up @@ -530,6 +531,17 @@ impl KmsState {

let mut all_outputs = Vec::new();
for device in self.drm_devices.values_mut() {
// we want to lower the resource usage to make sure we can modeset and enable new outputs
let mut receivers = Vec::new();
for surface in device.surfaces.values_mut() {
let (tx, rx) = sync_channel(1);
surface.set_direct_scanout(false, tx);
receivers.push(rx);
}
for rx in receivers {
let _ = rx.recv_timeout(Duration::from_millis(100));
}

// we only want outputs exposed to wayland - not leased ones
// but that is also not all surface, because that doesn't contain all detected, but unmapped outputs
let outputs = device
Expand Down Expand Up @@ -693,6 +705,12 @@ impl KmsState {
}
}

if !test_only && device.active_leases.is_empty() {
for surface in device.surfaces.values_mut() {
surface.set_direct_scanout(true, sync_channel(0).0);
}
}

all_outputs.extend(outputs);
}

Expand Down
Loading
Loading