diff --git a/src/header.rs b/src/header.rs index d2cfd29..340df89 100644 --- a/src/header.rs +++ b/src/header.rs @@ -239,6 +239,8 @@ pub struct WindowDescriptor { pub resizable: bool, /// Define how much power should the app ask for pub power_preference: crate::PowerPreference, + /// The backend to use for the draw + pub backends: crate::Backends, } impl std::default::Default for WindowDescriptor { /// Will quickly create a window with default settings @@ -250,6 +252,7 @@ impl std::default::Default for WindowDescriptor { decorations: true, resizable: true, power_preference: crate::PowerPreference::LowPower, + backends: crate::Backends::all(), } } } diff --git a/src/header/imports.rs b/src/header/imports.rs index b53e704..f817abd 100644 --- a/src/header/imports.rs +++ b/src/header/imports.rs @@ -17,6 +17,8 @@ pub use bytemuck::Pod; /// Zeroable trait for custom uniform buffer structure pub use bytemuck::Zeroable; +/// Backends +pub use wgpu::Backends; /// Encoder from wgpu pub use wgpu::CommandEncoder; pub use wgpu::LoadOp; @@ -62,4 +64,3 @@ pub use winit::window::Window; pub use winit_input_helper::WinitInputHelper as InputHelper; pub const DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth32Float; - diff --git a/src/render.rs b/src/render.rs index d251a2f..a8c35e6 100644 --- a/src/render.rs +++ b/src/render.rs @@ -31,11 +31,15 @@ impl Renderer { pub(crate) async fn new( window: &Window, power_preference: crate::PowerPreference, + backends: crate::Backends, ) -> anyhow::Result { let size = window.inner_size(); // The instance is a handle to our GPU - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default()); + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + backends, + ..Default::default() + }); #[cfg(not(feature = "android"))] let surface = Some(unsafe { instance.create_surface(window) }.unwrap()); diff --git a/src/window.rs b/src/window.rs index 6c173bd..a5223b8 100644 --- a/src/window.rs +++ b/src/window.rs @@ -63,8 +63,11 @@ impl Engine { let window = Window::new(&event_loop).unwrap(); // The renderer init on current window - let mut renderer = - futures::executor::block_on(Renderer::new(&window, settings.power_preference))?; + let mut renderer = futures::executor::block_on(Renderer::new( + &window, + settings.power_preference, + settings.backends, + ))?; let camera = Camera::new(window.inner_size(), &mut renderer)?;