gfx-rs / wgpu-rs

Rust bindings to wgpu native library
https://wgpu.rs
Mozilla Public License 2.0
1.69k stars 186 forks source link

How do I handle `get_swap_chain_preferred_format` returning `None`? #794

Closed expenses closed 3 years ago

expenses commented 3 years ago

After https://github.com/gfx-rs/wgpu-rs/pull/778, get_swap_chain_preferred_format can return None 'if the adapter does not support the surface'. I just had this happen on a friend's laptop with no obvious cause. Is it possible to handle this case by guessing a good swapchain format, or is the only good option to end the program?

expenses commented 3 years ago

Turns out the correct way to handle this is to pass in the surface to the compatible_surface field of RequestAdapterOptions and not have to deal with this problem 🥴🥴