Allow configuration of gpu backends, features, and limits

This commit is contained in:
Jarrod Doyle 2024-04-25 18:07:28 +01:00
parent d7f48d4627
commit 20e4ff829c
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 9 additions and 4 deletions

View File

@ -29,10 +29,15 @@ pub struct Context<'window> {
} }
impl<'window> Context<'window> { impl<'window> Context<'window> {
pub async fn new(window: Arc<Window>, limits: wgpu::Limits) -> Result<Self, ContextError> { pub async fn new(
window: Arc<Window>,
backends: wgpu::Backends,
required_features: wgpu::Features,
required_limits: wgpu::Limits,
) -> Result<Self, ContextError> {
log::info!("Initialising WGPU context..."); log::info!("Initialising WGPU context...");
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::VULKAN, backends,
dx12_shader_compiler: Default::default(), dx12_shader_compiler: Default::default(),
..Default::default() ..Default::default()
}); });
@ -63,8 +68,8 @@ impl<'window> Context<'window> {
.request_device( .request_device(
&wgpu::DeviceDescriptor { &wgpu::DeviceDescriptor {
label: None, label: None,
required_features: wgpu::Features::empty(), required_features,
required_limits: limits, required_limits,
}, },
None, None,
) )