From 55cbbdea625b9fffa770fa617db1848c45d5808f Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 31 Dec 2021 11:19:37 -0500 Subject: [PATCH] metal: fix surface texture clear view --- wgpu-core/src/present.rs | 12 +++--------- wgpu-hal/src/metal/device.rs | 2 ++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index 7421377ed7..e76807a64b 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -9,7 +9,7 @@ When this texture is presented, we remove it from the device tracker as well as extract it from the hub. !*/ -use std::{borrow::Borrow, num::NonZeroU32}; +use std::borrow::Borrow; #[cfg(feature = "trace")] use crate::device::trace::Action; @@ -128,17 +128,11 @@ impl Global { let (texture_id, status) = match unsafe { suf.raw.acquire_texture(FRAME_TIMEOUT_MS) } { Ok(Some(ast)) => { let clear_view_desc = hal::TextureViewDescriptor { - label: Some("clear texture view"), + label: Some("clear surface texture view"), format: config.format, dimension: wgt::TextureViewDimension::D2, usage: hal::TextureUses::COLOR_TARGET, - range: wgt::ImageSubresourceRange { - aspect: wgt::TextureAspect::All, - base_mip_level: 0, - mip_level_count: NonZeroU32::new(1), - base_array_layer: 0, - array_layer_count: NonZeroU32::new(1), - }, + range: wgt::ImageSubresourceRange::default(), }; let mut clear_views = smallvec::SmallVec::new(); clear_views.push( diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index 51b96a6657..84a2caf362 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -329,6 +329,8 @@ impl crate::Device for super::Device { conv::map_texture_view_dimension(desc.dimension) }; + //Note: this doesn't check properly if the mipmap level count or array layer count + // is explicitly set to 1. let raw = if raw_format == texture.raw_format && raw_type == texture.raw_type && desc.range == wgt::ImageSubresourceRange::default()