diff --git a/wgpu-core/src/command/clear.rs b/wgpu-core/src/command/clear.rs index f261e61d4..a93fe8345 100644 --- a/wgpu-core/src/command/clear.rs +++ b/wgpu-core/src/command/clear.rs @@ -281,7 +281,7 @@ pub(crate) fn clear_texture>( let dst_raw = dst_texture.try_raw(snatch_guard)?; // Issue the right barrier. - let clear_usage = match *dst_texture.clear_mode.read() { + let clear_usage = match dst_texture.clear_mode { TextureClearMode::BufferCopy => hal::TextureUses::COPY_DST, TextureClearMode::RenderPass { is_color: false, .. @@ -322,7 +322,7 @@ pub(crate) fn clear_texture>( } // Record actual clearing - match *dst_texture.clear_mode.read() { + match dst_texture.clear_mode { TextureClearMode::BufferCopy => clear_texture_via_buffer_copies::( &dst_texture.desc, alignments, @@ -453,7 +453,6 @@ fn clear_texture_via_render_passes( height: dst_texture.desc.size.height, depth_or_array_layers: 1, // Only one layer is cleared at a time. }; - let clear_mode = &dst_texture.clear_mode.read(); for mip_level in range.mip_range { let extent = extent_base.mip_level_size(mip_level, dst_texture.desc.dimension); @@ -463,7 +462,7 @@ fn clear_texture_via_render_passes( color_attachments_tmp = [Some(hal::ColorAttachment { target: hal::Attachment { view: Texture::get_clear_view( - clear_mode, + &dst_texture.clear_mode, &dst_texture.desc, mip_level, depth_or_layer, @@ -481,7 +480,7 @@ fn clear_texture_via_render_passes( Some(hal::DepthStencilAttachment { target: hal::Attachment { view: Texture::get_clear_view( - clear_mode, + &dst_texture.clear_mode, &dst_texture.desc, mip_level, depth_or_layer, diff --git a/wgpu-core/src/lock/rank.rs b/wgpu-core/src/lock/rank.rs index 2539ffe16..162d3d260 100644 --- a/wgpu-core/src/lock/rank.rs +++ b/wgpu-core/src/lock/rank.rs @@ -133,7 +133,6 @@ define_lock_ranks! { rank SURFACE_PRESENTATION "Surface::presentation" followed by { } rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { } rank TEXTURE_INITIALIZATION_STATUS "Texture::initialization_status" followed by { } - rank TEXTURE_CLEAR_MODE "Texture::clear_mode" followed by { } rank TEXTURE_VIEWS "Texture::views" followed by { } #[cfg(test)] diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 80ed66b31..f6742ba82 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -995,7 +995,7 @@ pub struct Texture { /// The `label` from the descriptor used to create the resource. pub(crate) label: String, pub(crate) tracking_data: TrackingData, - pub(crate) clear_mode: RwLock>, + pub(crate) clear_mode: TextureClearMode, pub(crate) views: Mutex>>>, pub(crate) bind_groups: Mutex>>>, } @@ -1030,7 +1030,7 @@ impl Texture { }, label: desc.label.to_string(), tracking_data: TrackingData::new(device.tracker_indices.textures.clone()), - clear_mode: RwLock::new(rank::TEXTURE_CLEAR_MODE, clear_mode), + clear_mode, views: Mutex::new(rank::TEXTURE_VIEWS, Vec::new()), bind_groups: Mutex::new(rank::TEXTURE_BIND_GROUPS, Vec::new()), } @@ -1056,9 +1056,7 @@ impl Texture { impl Drop for Texture { fn drop(&mut self) { use hal::Device; - let mut clear_mode = self.clear_mode.write(); - let clear_mode = &mut *clear_mode; - match *clear_mode { + match self.clear_mode { TextureClearMode::Surface { ref mut clear_view, .. } => {