rename DeviceDescriptor.limits to DeviceDescriptor.required_limits

This commit is contained in:
teoxoy 2023-11-29 14:29:11 +01:00 committed by Teodor Tanasoaia
parent 9be6c8890f
commit da73522720
19 changed files with 30 additions and 27 deletions

View File

@ -658,7 +658,7 @@ pub async fn op_webgpu_request_device(
let descriptor = wgpu_types::DeviceDescriptor {
label: Some(Cow::Owned(label)),
required_features: required_features.into(),
limits: required_limits.unwrap_or_default(),
required_limits: required_limits.unwrap_or_default(),
};
let (device, _queue, maybe_err) = gfx_select!(adapter => instance.adapter_request_device(

View File

@ -318,7 +318,7 @@ impl ExampleContext {
&wgpu::DeviceDescriptor {
label: None,
required_features: (optional_features & adapter_features) | required_features,
limits: needed_limits,
required_limits: needed_limits,
},
trace_dir.ok().as_ref().map(std::path::Path::new),
)

View File

@ -49,7 +49,7 @@ async fn execute_gpu(numbers: &[u32]) -> Option<Vec<u32>> {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -18,7 +18,7 @@ async fn run() {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -30,7 +30,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
label: None,
required_features: wgpu::Features::empty(),
// Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
limits: wgpu::Limits::downlevel_webgl2_defaults()
required_limits: wgpu::Limits::downlevel_webgl2_defaults()
.using_resolution(adapter.limits()),
},
None,

View File

@ -83,7 +83,7 @@ async fn run(event_loop: EventLoop<()>, viewports: Vec<(Arc<Window>, wgpu::Color
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -31,7 +31,7 @@ async fn run() {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -20,7 +20,7 @@ async fn run(_path: Option<String>) {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -168,7 +168,7 @@ impl WgpuContext {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -34,7 +34,7 @@ async fn run(_path: Option<String>) {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -215,7 +215,7 @@ async fn run() {
&wgpu::DeviceDescriptor {
label: None,
required_features: features,
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -114,7 +114,7 @@ impl WgpuContext {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
required_limits: wgpu::Limits::downlevel_defaults(),
},
None,
)

View File

@ -90,7 +90,7 @@ impl Test<'_> {
&wgt::DeviceDescriptor {
label: None,
required_features: self.features,
limits: wgt::Limits::default(),
required_limits: wgt::Limits::default(),
},
None,
device_id,

View File

@ -86,7 +86,7 @@ pub async fn initialize_device(
&wgpu::DeviceDescriptor {
label: None,
required_features: features,
limits,
required_limits: limits,
},
None,
)

View File

@ -80,7 +80,7 @@ async fn request_device_error_message() {
&wgpu::DeviceDescriptor {
// Force a failure by requesting absurd limits.
required_features: wgpu::Features::all(),
limits: wgpu::Limits {
required_limits: wgpu::Limits {
max_texture_dimension_1d: u32::MAX,
max_texture_dimension_2d: u32::MAX,
max_texture_dimension_3d: u32::MAX,

View File

@ -272,7 +272,7 @@ impl<A: HalApi> Device<A> {
}
})),
alignments,
limits: desc.limits.clone(),
limits: desc.required_limits.clone(),
features: desc.required_features,
downlevel,
instance_flags,

View File

@ -372,17 +372,20 @@ impl<A: HalApi> Adapter<A> {
//TODO
}
if let Some(failed) = check_limits(&desc.limits, &caps.limits).pop() {
if let Some(failed) = check_limits(&desc.required_limits, &caps.limits).pop() {
return Err(RequestDeviceError::LimitsExceeded(failed));
}
let open = unsafe { self.raw.adapter.open(desc.required_features, &desc.limits) }.map_err(
|err| match err {
hal::DeviceError::Lost => RequestDeviceError::DeviceLost,
hal::DeviceError::OutOfMemory => RequestDeviceError::OutOfMemory,
hal::DeviceError::ResourceCreationFailed => RequestDeviceError::Internal,
},
)?;
let open = unsafe {
self.raw
.adapter
.open(desc.required_features, &desc.required_limits)
}
.map_err(|err| match err {
hal::DeviceError::Lost => RequestDeviceError::DeviceLost,
hal::DeviceError::OutOfMemory => RequestDeviceError::OutOfMemory,
hal::DeviceError::ResourceCreationFailed => RequestDeviceError::Internal,
})?;
self.create_device_and_queue_from_hal(open, desc, instance_flags, trace_path)
}

View File

@ -1656,7 +1656,7 @@ pub struct DeviceDescriptor<L> {
pub required_features: Features,
/// Limits that the device should support. If any limit is "better" than the limit exposed by
/// the adapter, creating a device will panic.
pub limits: Limits,
pub required_limits: Limits,
}
impl<L> DeviceDescriptor<L> {
@ -1665,7 +1665,7 @@ impl<L> DeviceDescriptor<L> {
DeviceDescriptor {
label: fun(&self.label),
required_features: self.required_features,
limits: self.limits.clone(),
required_limits: self.required_limits.clone(),
}
}
}

View File

@ -1151,7 +1151,7 @@ impl crate::context::Context for Context {
// TODO: Migrate to a web_sys api.
// See https://github.com/rustwasm/wasm-bindgen/issues/3587
let limits_object = map_js_sys_limits(&desc.limits);
let limits_object = map_js_sys_limits(&desc.required_limits);
js_sys::Reflect::set(
&mapped_desc,