diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 02cb98d2bc..6a40726549 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -7,7 +7,7 @@ use crate::{ device::Device, hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Input, Token}, id::{AdapterId, DeviceId, SurfaceId, Valid}, - power, span, LifeGuard, PrivateFeatures, Stored, MAX_BIND_GROUPS, + span, LifeGuard, PrivateFeatures, Stored, MAX_BIND_GROUPS, }; use wgt::{Backend, BackendBit, DeviceDescriptor, PowerPreference, BIND_BUFFER_ALIGNMENT}; @@ -500,18 +500,9 @@ impl Global { } let preferred_gpu = match desc.power_preference { - PowerPreference::Default => match power::is_battery_discharging() { - Ok(false) => discrete.or(integrated).or(other).or(virt), - Ok(true) => integrated.or(discrete).or(other).or(virt), - Err(err) => { - tracing::debug!( - "Power info unavailable, preferring integrated gpu ({})", - err - ); - integrated.or(discrete).or(other).or(virt) - } - }, - PowerPreference::LowPower => integrated.or(other).or(discrete).or(virt), + PowerPreference::Default | PowerPreference::LowPower => { + integrated.or(other).or(discrete).or(virt) + } PowerPreference::HighPerformance => discrete.or(other).or(integrated).or(virt), }; diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index 225682552b..4944602450 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -37,7 +37,6 @@ pub mod id; pub mod instance; pub mod logging; pub mod pipeline; -pub mod power; pub mod resource; pub mod swap_chain; mod track; diff --git a/wgpu-core/src/power.rs b/wgpu-core/src/power.rs deleted file mode 100644 index 81abf64db8..0000000000 --- a/wgpu-core/src/power.rs +++ /dev/null @@ -1,66 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use thiserror::Error; - -#[derive(Debug, Error)] -pub enum Error { - #[error("battery status is unsupported on this platform")] - Unsupported, - #[error("battery status retrieval failed: {0}")] - Error(Box), -} - -#[cfg(all( - feature = "battery", - any( - target_os = "linux", - target_os = "macos", - target_os = "windows", - target_os = "dragonfly", - target_os = "freebsd" - ) -))] -mod platform { - use super::Error; - use battery::{self, Manager, State}; - - impl From for Error { - fn from(err: battery::errors::Error) -> Error { - // Box the error so that the battery::errors::Error type does - // not leak out of this module. - Error::Error(Box::new(err)) - } - } - - pub fn is_battery_discharging() -> Result { - let manager = Manager::new()?; - for battery in manager.batteries()? { - if battery?.state() == State::Discharging { - return Ok(true); - } - } - Ok(false) - } -} - -#[cfg(any( - not(feature = "battery"), - not(any( - target_os = "linux", - target_os = "macos", - target_os = "windows", - target_os = "dragonfly", - target_os = "freebsd" - )) -))] -mod platform { - use super::Error; - - pub fn is_battery_discharging() -> Result { - Err(Error::Unsupported) - } -} - -pub use platform::is_battery_discharging;