diff --git a/tests/src/lib.rs b/tests/src/lib.rs index 030224fabd..06352e4e97 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -405,7 +405,6 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te return; } - // Determine if we expect this test to fail, and if so, why. let expected_failure_reason = parameters .failures @@ -482,7 +481,7 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te } } -fn initialize_adapter() -> (Adapter, Option) { +fn initialize_adapter() -> (Instance, Adapter, Option) { let instance = initialize_instance(); let surface_guard: Option; let compatible_surface; diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 260177b833..bc84865d40 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -1936,12 +1936,14 @@ impl Global { } // Wait for all work to finish before configuring the surface. - if let Err(e) = device.maintain(hub, wgt::Maintain::Wait, &mut token) { + let fence = device.fence.read(); + let fence = fence.as_ref().unwrap(); + if let Err(e) = device.maintain(hub, fence, wgt::Maintain::Wait) { break e.into(); } // All textures must be destroyed before the surface can be re-configured. - if let Some(present) = surface.presentation.take() { + if let Some(present) = surface.presentation.lock().take() { if present.acquired_texture.is_some() { break E::PreviousOutputExists; } diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index ed7e20a7ea..4a88b05753 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -311,7 +311,7 @@ impl Global { let texture = hub.textures.unregister(texture_id); if let Some(texture) = texture { if let Ok(mut texture) = Arc::try_unwrap(texture) { - texture.clear_mode.destroy_clear_views(device.raw()); + texture.clear_mode.write().destroy_clear_views(device.raw()); let suf = A::get_surface(&surface); match texture.inner.take().unwrap() { @@ -396,15 +396,15 @@ impl Global { // and now we are moving it away. log::debug!( "Removing swapchain texture {:?} from the device tracker", - texture_id.value + texture_id ); device.trackers.lock().textures.remove(texture_id); let texture = hub.textures.unregister(texture_id); if let Some(texture) = texture { if let Ok(mut texture) = Arc::try_unwrap(texture) { - texture.clear_mode.destroy_clear_views(device.raw()); - + texture.clear_mode.write().destroy_clear_views(device.raw()); + let suf = A::get_surface(&surface); match texture.inner.take().unwrap() { resource::TextureInner::Surface { diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 01872cd928..82dd9600b5 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -720,13 +720,12 @@ pub enum TextureClearMode { None, } -impl TextureClearMode { - pub(crate) fn destroy_clear_views(self, device: &A::Device) { - if let TextureClearMode::RenderPass { clear_views, .. } = self { - for clear_view in clear_views { - unsafe { - hal::Device::destroy_texture_view(device, clear_view); - } +impl TextureClearMode { + pub(crate) fn destroy_clear_views(&mut self, device: &A::Device) { + if let TextureClearMode::Surface { ref mut clear_view } = *self { + unsafe { + let view = clear_view.take().unwrap(); + hal::Device::destroy_texture_view(device, view); } } } diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 20e646863d..e716ab0d93 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -113,7 +113,7 @@ impl Example { let exposed = adapters.swap_remove(0); (exposed.adapter, exposed.capabilities) }; - + let surface_caps = unsafe { adapter.surface_capabilities(&surface) } .ok_or("failed to get surface capabilities")?; log::info!("Surface caps: {:#?}", surface_caps); diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 97ec8fd624..77d696f268 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -570,7 +570,7 @@ impl crate::Instance for super::Instance { let entry = unsafe { ash::Entry::load() }.map_err(|err| { crate::InstanceError::with_source(String::from("missing Vulkan entry points"), err) })?; - + let driver_api_version = match entry.try_enumerate_instance_version() { // Vulkan 1.1+ Ok(Some(version)) => version, @@ -830,7 +830,6 @@ impl crate::Surface for super::Surface { device: &super::Device, config: &crate::SurfaceConfiguration, ) -> Result<(), crate::SurfaceError> { - // Safety: `configure`'s contract guarantees there are no resources derived from the swapchain in use. let mut swap_chain = self.swapchain.write(); let old = swap_chain