rename DeviceDescriptor.features to DeviceDescriptor.required_features

This commit is contained in:
teoxoy 2023-11-29 14:26:56 +01:00 committed by Teodor Tanasoaia
parent c4ef520657
commit 9be6c8890f
20 changed files with 25 additions and 25 deletions

View File

@ -657,7 +657,7 @@ pub async fn op_webgpu_request_device(
let descriptor = wgpu_types::DeviceDescriptor {
label: Some(Cow::Owned(label)),
features: required_features.into(),
required_features: required_features.into(),
limits: required_limits.unwrap_or_default(),
};

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(),
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()
.using_resolution(adapter.limits()),

View File

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

View File

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

View File

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

View File

@ -167,7 +167,7 @@ impl WgpuContext {
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(),
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
},
None,

View File

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

View File

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

View File

@ -113,7 +113,7 @@ impl WgpuContext {
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(),
required_features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
},
None,

View File

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

View File

@ -85,7 +85,7 @@ pub async fn initialize_device(
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features,
required_features: features,
limits,
},
None,

View File

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

View File

@ -273,7 +273,7 @@ impl<A: HalApi> Device<A> {
})),
alignments,
limits: desc.limits.clone(),
features: desc.features,
features: desc.required_features,
downlevel,
instance_flags,
pending_writes: Mutex::new(Some(pending_writes)),

View File

@ -337,9 +337,9 @@ impl<A: HalApi> Adapter<A> {
trace_path: Option<&std::path::Path>,
) -> Result<(Device<A>, Queue<A>), RequestDeviceError> {
// Verify all features were exposed by the adapter
if !self.raw.features.contains(desc.features) {
if !self.raw.features.contains(desc.required_features) {
return Err(RequestDeviceError::UnsupportedFeature(
desc.features - self.raw.features,
desc.required_features - self.raw.features,
));
}
@ -358,7 +358,7 @@ impl<A: HalApi> Adapter<A> {
// Verify feature preconditions
if desc
.features
.required_features
.contains(wgt::Features::MAPPABLE_PRIMARY_BUFFERS)
&& self.raw.info.device_type == wgt::DeviceType::DiscreteGpu
{
@ -376,7 +376,7 @@ impl<A: HalApi> Adapter<A> {
return Err(RequestDeviceError::LimitsExceeded(failed));
}
let open = unsafe { self.raw.adapter.open(desc.features, &desc.limits) }.map_err(
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,

View File

@ -1653,7 +1653,7 @@ pub struct DeviceDescriptor<L> {
pub label: L,
/// Features that the device should support. If any feature is not supported by
/// the adapter, creating a device will panic.
pub features: Features,
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,
@ -1664,7 +1664,7 @@ impl<L> DeviceDescriptor<L> {
pub fn map_label<K>(&self, fun: impl FnOnce(&L) -> K) -> DeviceDescriptor<K> {
DeviceDescriptor {
label: fun(&self.label),
features: self.features,
required_features: self.required_features,
limits: self.limits.clone(),
}
}

View File

@ -122,7 +122,7 @@ impl Context {
let device = Device {
id: device_id,
error_sink: error_sink.clone(),
features: desc.features,
features: desc.required_features,
};
let queue = Queue {
id: queue_id,
@ -646,7 +646,7 @@ impl crate::Context for Context {
let device = Device {
id: device_id,
error_sink: error_sink.clone(),
features: desc.features,
features: desc.required_features,
};
let queue = Queue {
id: queue_id,

View File

@ -1164,7 +1164,7 @@ impl crate::context::Context for Context {
.iter()
.copied()
.flat_map(|(flag, value)| {
if desc.features.contains(flag) {
if desc.required_features.contains(flag) {
Some(JsValue::from(value))
} else {
None