Skip to content

Commit

Permalink
anvil/udev: Allow overriding the primary gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Mar 14, 2022
1 parent d3c5ef1 commit dadde8a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions anvil/src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,20 @@ pub fn run_udev(log: Logger) {
/*
* Initialize the compositor
*/
let primary_gpu = primary_gpu(&session.seat())
.unwrap()
.and_then(|x| DrmNode::from_path(x).ok()?.node_with_type(NodeType::Render)?.ok())
.unwrap_or_else(|| {
all_gpus(&session.seat())
.unwrap()
.into_iter()
.find_map(|x| DrmNode::from_path(x).ok())
.expect("No GPU!")
});
let primary_gpu = if let Ok(var) = std::env::var("ANVIL_DRM_DEVICE") {
DrmNode::from_path(var).expect("Invalid drm device path")
} else {
primary_gpu(&session.seat())
.unwrap()
.and_then(|x| DrmNode::from_path(x).ok()?.node_with_type(NodeType::Render)?.ok())
.unwrap_or_else(|| {
all_gpus(&session.seat())
.unwrap()
.into_iter()
.find_map(|x| DrmNode::from_path(x).ok())
.expect("No GPU!")
})
};
info!(log, "Using {} as primary gpu.", primary_gpu);

let mut gpus = GpuManager::new(EglGlesBackend, log.clone()).unwrap();
Expand Down

0 comments on commit dadde8a

Please sign in to comment.