From 9be6c8890f72ab808c43668625428f6b0df44adb Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:26:56 +0100 Subject: [PATCH] rename `DeviceDescriptor.features` to `DeviceDescriptor.required_features` --- deno_webgpu/lib.rs | 2 +- examples/src/framework.rs | 2 +- examples/src/hello_compute/mod.rs | 2 +- examples/src/hello_synchronization/mod.rs | 2 +- examples/src/hello_triangle/mod.rs | 2 +- examples/src/hello_windows/mod.rs | 2 +- examples/src/hello_workgroups/mod.rs | 2 +- examples/src/render_to_texture/mod.rs | 2 +- examples/src/repeated_compute/mod.rs | 2 +- examples/src/storage_texture/mod.rs | 2 +- examples/src/timestamp_queries/mod.rs | 2 +- examples/src/uniform_values/mod.rs | 2 +- player/tests/test.rs | 2 +- tests/src/init.rs | 2 +- tests/tests/device.rs | 2 +- wgpu-core/src/device/resource.rs | 2 +- wgpu-core/src/instance.rs | 8 ++++---- wgpu-types/src/lib.rs | 4 ++-- wgpu/src/backend/direct.rs | 4 ++-- wgpu/src/backend/web.rs | 2 +- 20 files changed, 25 insertions(+), 25 deletions(-) diff --git a/deno_webgpu/lib.rs b/deno_webgpu/lib.rs index bf1c246ad..124e8b4c6 100644 --- a/deno_webgpu/lib.rs +++ b/deno_webgpu/lib.rs @@ -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(), }; diff --git a/examples/src/framework.rs b/examples/src/framework.rs index 555fb3cb7..804c265fe 100644 --- a/examples/src/framework.rs +++ b/examples/src/framework.rs @@ -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), diff --git a/examples/src/hello_compute/mod.rs b/examples/src/hello_compute/mod.rs index d93d804ef..3772f2b24 100644 --- a/examples/src/hello_compute/mod.rs +++ b/examples/src/hello_compute/mod.rs @@ -48,7 +48,7 @@ async fn execute_gpu(numbers: &[u32]) -> Option> { .request_device( &wgpu::DeviceDescriptor { label: None, - features: wgpu::Features::empty(), + required_features: wgpu::Features::empty(), limits: wgpu::Limits::downlevel_defaults(), }, None, diff --git a/examples/src/hello_synchronization/mod.rs b/examples/src/hello_synchronization/mod.rs index 476db4d96..fd8ab39a0 100644 --- a/examples/src/hello_synchronization/mod.rs +++ b/examples/src/hello_synchronization/mod.rs @@ -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, diff --git a/examples/src/hello_triangle/mod.rs b/examples/src/hello_triangle/mod.rs index e810cc1a1..882f3ce35 100644 --- a/examples/src/hello_triangle/mod.rs +++ b/examples/src/hello_triangle/mod.rs @@ -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()), diff --git a/examples/src/hello_windows/mod.rs b/examples/src/hello_windows/mod.rs index 1b4bbdc93..5e5aa4266 100644 --- a/examples/src/hello_windows/mod.rs +++ b/examples/src/hello_windows/mod.rs @@ -82,7 +82,7 @@ async fn run(event_loop: EventLoop<()>, viewports: Vec<(Arc, wgpu::Color .request_device( &wgpu::DeviceDescriptor { label: None, - features: wgpu::Features::empty(), + required_features: wgpu::Features::empty(), limits: wgpu::Limits::downlevel_defaults(), }, None, diff --git a/examples/src/hello_workgroups/mod.rs b/examples/src/hello_workgroups/mod.rs index 933364a6f..a9ca19f53 100644 --- a/examples/src/hello_workgroups/mod.rs +++ b/examples/src/hello_workgroups/mod.rs @@ -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, diff --git a/examples/src/render_to_texture/mod.rs b/examples/src/render_to_texture/mod.rs index 820618f6e..060690fe7 100644 --- a/examples/src/render_to_texture/mod.rs +++ b/examples/src/render_to_texture/mod.rs @@ -19,7 +19,7 @@ async fn run(_path: Option) { .request_device( &wgpu::DeviceDescriptor { label: None, - features: wgpu::Features::empty(), + required_features: wgpu::Features::empty(), limits: wgpu::Limits::downlevel_defaults(), }, None, diff --git a/examples/src/repeated_compute/mod.rs b/examples/src/repeated_compute/mod.rs index 735ebb958..c268a8504 100644 --- a/examples/src/repeated_compute/mod.rs +++ b/examples/src/repeated_compute/mod.rs @@ -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, diff --git a/examples/src/storage_texture/mod.rs b/examples/src/storage_texture/mod.rs index 0fac837e2..93cc7c7bd 100644 --- a/examples/src/storage_texture/mod.rs +++ b/examples/src/storage_texture/mod.rs @@ -33,7 +33,7 @@ async fn run(_path: Option) { .request_device( &wgpu::DeviceDescriptor { label: None, - features: wgpu::Features::empty(), + required_features: wgpu::Features::empty(), limits: wgpu::Limits::downlevel_defaults(), }, None, diff --git a/examples/src/timestamp_queries/mod.rs b/examples/src/timestamp_queries/mod.rs index 0f53d18b3..04a4de5b5 100644 --- a/examples/src/timestamp_queries/mod.rs +++ b/examples/src/timestamp_queries/mod.rs @@ -214,7 +214,7 @@ async fn run() { .request_device( &wgpu::DeviceDescriptor { label: None, - features, + required_features: features, limits: wgpu::Limits::downlevel_defaults(), }, None, diff --git a/examples/src/uniform_values/mod.rs b/examples/src/uniform_values/mod.rs index fdb6a5f85..04399ccf7 100644 --- a/examples/src/uniform_values/mod.rs +++ b/examples/src/uniform_values/mod.rs @@ -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, diff --git a/player/tests/test.rs b/player/tests/test.rs index e5c2a0b51..8c7357540 100644 --- a/player/tests/test.rs +++ b/player/tests/test.rs @@ -89,7 +89,7 @@ impl Test<'_> { adapter, &wgt::DeviceDescriptor { label: None, - features: self.features, + required_features: self.features, limits: wgt::Limits::default(), }, None, diff --git a/tests/src/init.rs b/tests/src/init.rs index 9ff2d08a6..d5fa78055 100644 --- a/tests/src/init.rs +++ b/tests/src/init.rs @@ -85,7 +85,7 @@ pub async fn initialize_device( .request_device( &wgpu::DeviceDescriptor { label: None, - features, + required_features: features, limits, }, None, diff --git a/tests/tests/device.rs b/tests/tests/device.rs index 18f5b1d4a..a7d3cd50b 100644 --- a/tests/tests/device.rs +++ b/tests/tests/device.rs @@ -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, diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 6d2e140a8..6c97c6e05 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -273,7 +273,7 @@ impl Device { })), alignments, limits: desc.limits.clone(), - features: desc.features, + features: desc.required_features, downlevel, instance_flags, pending_writes: Mutex::new(Some(pending_writes)), diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 6bc0abdb1..dff33c3ec 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -337,9 +337,9 @@ impl Adapter { trace_path: Option<&std::path::Path>, ) -> Result<(Device, Queue), 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 Adapter { // 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 Adapter { 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, diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 3e9ab37a2..86e5023c2 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1653,7 +1653,7 @@ pub struct DeviceDescriptor { 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 DeviceDescriptor { pub fn map_label(&self, fun: impl FnOnce(&L) -> K) -> DeviceDescriptor { DeviceDescriptor { label: fun(&self.label), - features: self.features, + required_features: self.required_features, limits: self.limits.clone(), } } diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 1e9701634..b1ed365a8 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -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, diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index d89e024c9..516042439 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -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