Use adapter limits (unless overridden) (#226)
- Fixes a regression caused by #223 - `downlevel_webgl2_defaults` only supports 2048x2048 pixels buffers - This will allow pixel buffers up to the max supported by the hardware
This commit is contained in:
parent
2a37e3ed1d
commit
acd42495f2
|
@ -6,7 +6,7 @@ use raw_window_handle::HasRawWindowHandle;
|
||||||
/// A builder to help create customized pixel buffers.
|
/// A builder to help create customized pixel buffers.
|
||||||
pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle> {
|
pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle> {
|
||||||
request_adapter_options: Option<wgpu::RequestAdapterOptions<'req>>,
|
request_adapter_options: Option<wgpu::RequestAdapterOptions<'req>>,
|
||||||
device_descriptor: wgpu::DeviceDescriptor<'dev>,
|
device_descriptor: Option<wgpu::DeviceDescriptor<'dev>>,
|
||||||
backend: wgpu::Backends,
|
backend: wgpu::Backends,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
|
@ -46,10 +46,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W>
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
request_adapter_options: None,
|
request_adapter_options: None,
|
||||||
device_descriptor: wgpu::DeviceDescriptor {
|
device_descriptor: None,
|
||||||
limits: wgpu::Limits::downlevel_webgl2_defaults(),
|
|
||||||
..wgpu::DeviceDescriptor::default()
|
|
||||||
},
|
|
||||||
backend: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY),
|
backend: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
@ -72,7 +69,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W>
|
||||||
|
|
||||||
/// Add options for requesting a [`wgpu::Device`].
|
/// Add options for requesting a [`wgpu::Device`].
|
||||||
pub fn device_descriptor(mut self, device_descriptor: wgpu::DeviceDescriptor<'dev>) -> Self {
|
pub fn device_descriptor(mut self, device_descriptor: wgpu::DeviceDescriptor<'dev>) -> Self {
|
||||||
self.device_descriptor = device_descriptor;
|
self.device_descriptor = Some(device_descriptor);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +197,14 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W>
|
||||||
});
|
});
|
||||||
let adapter = adapter.ok_or(Error::AdapterNotFound)?;
|
let adapter = adapter.ok_or(Error::AdapterNotFound)?;
|
||||||
|
|
||||||
let (device, queue) =
|
let device_descriptor = self
|
||||||
pollster::block_on(adapter.request_device(&self.device_descriptor, None))
|
.device_descriptor
|
||||||
|
.unwrap_or_else(|| wgpu::DeviceDescriptor {
|
||||||
|
limits: adapter.limits(),
|
||||||
|
..wgpu::DeviceDescriptor::default()
|
||||||
|
});
|
||||||
|
|
||||||
|
let (device, queue) = pollster::block_on(adapter.request_device(&device_descriptor, None))
|
||||||
.map_err(Error::DeviceNotFound)?;
|
.map_err(Error::DeviceNotFound)?;
|
||||||
|
|
||||||
let present_mode = self.present_mode;
|
let present_mode = self.present_mode;
|
||||||
|
|
|
@ -198,7 +198,7 @@ impl Pixels {
|
||||||
PixelsBuilder::new(width, height, surface_texture).build()
|
PixelsBuilder::new(width, height, surface_texture).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resize the pixel buffer.
|
/// Resize the pixel buffer and zero its contents.
|
||||||
///
|
///
|
||||||
/// This does not resize the surface upon which the pixel buffer texture is rendered. Use
|
/// This does not resize the surface upon which the pixel buffer texture is rendered. Use
|
||||||
/// [`Pixels::resize_surface`] to change the size of the surface texture.
|
/// [`Pixels::resize_surface`] to change the size of the surface texture.
|
||||||
|
|
Loading…
Reference in a new issue