diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index bc44945033..9a99b14a0c 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -28,14 +28,14 @@ vulkan = ["wgc/gfx-backend-vulkan"] package = "wgpu-core" version = "0.5" git = "https://github.com/gfx-rs/wgpu" -rev = "ac9587e9ced5b043abad68e260cb8c9e812cffb5" +rev = "041db60f9080769b5edc40888cf9683ccb255399" features = ["raw-window-handle"] [dependencies.wgt] package = "wgpu-types" version = "0.5" git = "https://github.com/gfx-rs/wgpu" -rev = "ac9587e9ced5b043abad68e260cb8c9e812cffb5" +rev = "041db60f9080769b5edc40888cf9683ccb255399" [dependencies] arrayvec = "0.5" diff --git a/wgpu/examples/capture/main.rs b/wgpu/examples/capture/main.rs index 17b03468d8..9aa7d20a50 100644 --- a/wgpu/examples/capture/main.rs +++ b/wgpu/examples/capture/main.rs @@ -1,10 +1,10 @@ +use std::env; /// This example shows how to capture an image by rendering it to a texture, copying the texture to /// a buffer, and retrieving it from the buffer. This could be used for "taking a screenshot," with /// the added benefit that this method doesn't require a window to be created. use std::fs::File; -use std::mem::size_of; -use std::env; use std::io::Write; +use std::mem::size_of; async fn run() { let adapter = wgpu::Instance::new() @@ -13,6 +13,7 @@ async fn run() { power_preference: wgpu::PowerPreference::Default, compatible_surface: None, }, + wgpu::UnsafeExtensions::disallow(), wgpu::BackendBit::PRIMARY, ) .await @@ -132,7 +133,11 @@ async fn run() { if let Ok(()) = buffer_future.await { let padded_buffer = output_buffer.get_mapped_range(0, wgt::BufferSize::WHOLE); - let mut png_encoder = png::Encoder::new(File::create("red.png").unwrap(), width as u32, height as u32); + let mut png_encoder = png::Encoder::new( + File::create("red.png").unwrap(), + width as u32, + height as u32, + ); png_encoder.set_depth(png::BitDepth::Eight); png_encoder.set_color(png::ColorType::RGBA); let mut png_writer = png_encoder diff --git a/wgpu/examples/cube/main.rs b/wgpu/examples/cube/main.rs index b6e7d8f969..14c05ed619 100644 --- a/wgpu/examples/cube/main.rs +++ b/wgpu/examples/cube/main.rs @@ -205,7 +205,7 @@ impl framework::Example for Example { lod_min_clamp: 0.0, lod_max_clamp: 100.0, compare: None, - anisotropy_clamp: None, + ..Default::default() }); let mx_total = Self::generate_matrix(sc_desc.width as f32 / sc_desc.height as f32); let mx_ref: &[f32; 16] = mx_total.as_ref(); diff --git a/wgpu/examples/describe/main.rs b/wgpu/examples/describe/main.rs index 8b123cfd7b..befdaf4bb2 100644 --- a/wgpu/examples/describe/main.rs +++ b/wgpu/examples/describe/main.rs @@ -6,6 +6,7 @@ async fn run() { power_preference: wgpu::PowerPreference::Default, compatible_surface: None, }, + unsafe { wgpu::UnsafeExtensions::allow() }, wgpu::BackendBit::PRIMARY, ) .await diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index 9bc3a1f7bd..bb67212c31 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -66,6 +66,7 @@ async fn run_async(event_loop: EventLoop<()>, window: Window) { power_preference: wgpu::PowerPreference::Default, compatible_surface: Some(&surface), }, + wgpu::UnsafeExtensions::disallow(), wgpu::BackendBit::PRIMARY, ) .await diff --git a/wgpu/examples/hello-compute/main.rs b/wgpu/examples/hello-compute/main.rs index cf0b16c0fc..be821dd3bd 100644 --- a/wgpu/examples/hello-compute/main.rs +++ b/wgpu/examples/hello-compute/main.rs @@ -29,6 +29,7 @@ async fn execute_gpu(numbers: Vec) -> Vec { power_preference: wgpu::PowerPreference::Default, compatible_surface: None, }, + wgpu::UnsafeExtensions::disallow(), wgpu::BackendBit::PRIMARY, ) .await diff --git a/wgpu/examples/hello-triangle/main.rs b/wgpu/examples/hello-triangle/main.rs index 7186f4c8ec..d3b85d7a2c 100644 --- a/wgpu/examples/hello-triangle/main.rs +++ b/wgpu/examples/hello-triangle/main.rs @@ -14,6 +14,7 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu:: power_preference: wgpu::PowerPreference::Default, compatible_surface: Some(&surface), }, + wgpu::UnsafeExtensions::disallow(), wgpu::BackendBit::PRIMARY, ) .await diff --git a/wgpu/examples/mipmap/main.rs b/wgpu/examples/mipmap/main.rs index aacfab480f..ff7b6c66c5 100644 --- a/wgpu/examples/mipmap/main.rs +++ b/wgpu/examples/mipmap/main.rs @@ -157,7 +157,7 @@ impl Example { lod_min_clamp: 0.0, lod_max_clamp: 100.0, compare: None, - anisotropy_clamp: None, + ..Default::default() }); let views = (0..mip_count) @@ -310,7 +310,7 @@ impl framework::Example for Example { lod_min_clamp: 0.0, lod_max_clamp: 100.0, compare: None, - anisotropy_clamp: None, + ..Default::default() }); let mx_total = Self::generate_matrix(sc_desc.width as f32 / sc_desc.height as f32); let mx_ref: &[f32; 16] = mx_total.as_ref(); diff --git a/wgpu/examples/shadow/main.rs b/wgpu/examples/shadow/main.rs index 2e2a698684..b810cd0ef4 100644 --- a/wgpu/examples/shadow/main.rs +++ b/wgpu/examples/shadow/main.rs @@ -353,7 +353,7 @@ impl framework::Example for Example { lod_min_clamp: -100.0, lod_max_clamp: 100.0, compare: Some(wgpu::CompareFunction::LessEqual), - anisotropy_clamp: None, + ..Default::default() }); let shadow_texture = device.create_texture(&wgpu::TextureDescriptor { diff --git a/wgpu/examples/skybox/main.rs b/wgpu/examples/skybox/main.rs index 34ff85e4b0..f49326f998 100644 --- a/wgpu/examples/skybox/main.rs +++ b/wgpu/examples/skybox/main.rs @@ -130,7 +130,7 @@ impl framework::Example for Skybox { lod_min_clamp: 0.0, lod_max_clamp: 100.0, compare: None, - anisotropy_clamp: None, + ..Default::default() }); let paths: [&'static [u8]; 6] = [ diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index ffbd37fb03..6bf4aa7ed2 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -223,6 +223,7 @@ impl crate::Context for Context { fn instance_request_adapter( &self, options: &crate::RequestAdapterOptions<'_>, + unsafe_extensions: wgt::UnsafeExtensions, backends: wgt::BackendBit, ) -> Self::RequestAdapterFuture { let id = self.pick_adapter( @@ -230,6 +231,7 @@ impl crate::Context for Context { power_preference: options.power_preference, compatible_surface: options.compatible_surface.map(|surface| surface.id), }, + unsafe_extensions, wgc::instance::AdapterInputs::Mask(backends, |_| PhantomData), ); ready(id) diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 5fd322dce7..d3d3da1743 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -660,6 +660,7 @@ impl crate::Context for Context { fn instance_request_adapter( &self, options: &crate::RequestAdapterOptions<'_>, + _unsafe_extensions: wgt::UnsafeExtensions, _backends: wgt::BackendBit, ) -> Self::RequestAdapterFuture { //TODO: support this check, return `None` if the flag is not set. @@ -689,6 +690,11 @@ impl crate::Context for Context { if trace_dir.is_some() { //Error: Tracing isn't supported on the Web target } + assert!( + !desc.extensions.intersects(crate::Extensions::ALL_NATIVE), + "The web backend doesn't support any native extensions. Enabled native extensions: {:?}", + desc.extensions & crate::Extensions::ALL_NATIVE + ); let mut mapped_desc = web_sys::GpuDeviceDescriptor::new(); // TODO: label, extensions let mut mapped_limits = web_sys::GpuLimits::new(); diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index f484bea4cc..65ecb32820 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -27,8 +27,8 @@ pub use wgt::{ RasterizationStateDescriptor, ShaderLocation, ShaderStage, StencilOperation, StencilStateFaceDescriptor, StoreOp, SwapChainDescriptor, SwapChainStatus, TextureAspect, TextureComponentType, TextureDataLayout, TextureDimension, TextureFormat, TextureUsage, - TextureViewDimension, VertexAttributeDescriptor, VertexFormat, BIND_BUFFER_ALIGNMENT, - COPY_BYTES_PER_ROW_ALIGNMENT, + TextureViewDimension, UnsafeExtensions, VertexAttributeDescriptor, VertexFormat, + BIND_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, }; use backend::Context as C; @@ -123,6 +123,7 @@ trait Context: Sized { fn instance_request_adapter( &self, options: &RequestAdapterOptions<'_>, + unsafe_extensions: wgt::UnsafeExtensions, backends: wgt::BackendBit, ) -> Self::RequestAdapterFuture; fn adapter_request_device( @@ -923,12 +924,17 @@ impl Instance { /// Retrieves all available [`Adapter`]s that match the given backends. #[cfg(not(target_arch = "wasm32"))] - pub fn enumerate_adapters(&self, backends: wgt::BackendBit) -> impl Iterator { + pub fn enumerate_adapters( + &self, + unsafe_extensions: wgt::UnsafeExtensions, + backends: wgt::BackendBit, + ) -> impl Iterator { let context = Arc::clone(&self.context); self.context - .enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| { - PhantomData - })) + .enumerate_adapters( + unsafe_extensions, + wgc::instance::AdapterInputs::Mask(backends, |_| PhantomData), + ) .into_iter() .map(move |id| crate::Adapter { id, @@ -982,11 +988,12 @@ impl Instance { pub fn request_adapter( &self, options: &RequestAdapterOptions<'_>, + unsafe_extensions: wgt::UnsafeExtensions, backends: BackendBit, ) -> impl Future> + Send { let context = Arc::clone(&self.context); self.context - .instance_request_adapter(options, backends) + .instance_request_adapter(options, unsafe_extensions, backends) .map(|option| option.map(|id| Adapter { context, id })) } }