Fix compatible_surface overrides when RequestAdapterOptions is provided (#85)
- This will use the default `compatible_surface` from `SurfaceTexture` when `RequestAdapterOptions` is configured without `compatible_surface`.
This commit is contained in:
parent
4991d2cddc
commit
7779d682cf
15
src/lib.rs
15
src/lib.rs
|
@ -557,13 +557,18 @@ impl<'req> PixelsBuilder<'req> {
|
|||
/// Returns an error when a [`wgpu::Adapter`] cannot be found.
|
||||
pub fn build(self) -> Result<Pixels, Error> {
|
||||
// TODO: Use `options.pixel_aspect_ratio` to stretch the scaled texture
|
||||
let compatible_surface = Some(&self.surface_texture.surface);
|
||||
let adapter = pollster::block_on(wgpu::Adapter::request(
|
||||
&self
|
||||
.request_adapter_options
|
||||
.unwrap_or(wgpu::RequestAdapterOptions {
|
||||
compatible_surface: Some(&self.surface_texture.surface),
|
||||
&self.request_adapter_options.map_or_else(
|
||||
|| wgpu::RequestAdapterOptions {
|
||||
compatible_surface,
|
||||
power_preference: wgpu::PowerPreference::Default,
|
||||
}),
|
||||
},
|
||||
|rao| wgpu::RequestAdapterOptions {
|
||||
compatible_surface: rao.compatible_surface.or(compatible_surface),
|
||||
power_preference: rao.power_preference,
|
||||
},
|
||||
),
|
||||
self.backend,
|
||||
))
|
||||
.ok_or(Error::AdapterNotFound)?;
|
||||
|
|
Loading…
Reference in a new issue