remove unnecessary RwLock from Texture.clear_mode

This commit is contained in:
teoxoy 2024-08-07 15:30:19 +02:00 committed by Teodor Tanasoaia
parent 1aaaec22f6
commit c72bc7b84b
3 changed files with 7 additions and 11 deletions

View File

@ -281,7 +281,7 @@ pub(crate) fn clear_texture<A: HalApi, T: TextureTrackerSetSingle<A>>(
let dst_raw = dst_texture.try_raw(snatch_guard)?; let dst_raw = dst_texture.try_raw(snatch_guard)?;
// Issue the right barrier. // 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::BufferCopy => hal::TextureUses::COPY_DST,
TextureClearMode::RenderPass { TextureClearMode::RenderPass {
is_color: false, .. is_color: false, ..
@ -322,7 +322,7 @@ pub(crate) fn clear_texture<A: HalApi, T: TextureTrackerSetSingle<A>>(
} }
// Record actual clearing // Record actual clearing
match *dst_texture.clear_mode.read() { match dst_texture.clear_mode {
TextureClearMode::BufferCopy => clear_texture_via_buffer_copies::<A>( TextureClearMode::BufferCopy => clear_texture_via_buffer_copies::<A>(
&dst_texture.desc, &dst_texture.desc,
alignments, alignments,
@ -453,7 +453,6 @@ fn clear_texture_via_render_passes<A: HalApi>(
height: dst_texture.desc.size.height, height: dst_texture.desc.size.height,
depth_or_array_layers: 1, // Only one layer is cleared at a time. 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 { for mip_level in range.mip_range {
let extent = extent_base.mip_level_size(mip_level, dst_texture.desc.dimension); let extent = extent_base.mip_level_size(mip_level, dst_texture.desc.dimension);
@ -463,7 +462,7 @@ fn clear_texture_via_render_passes<A: HalApi>(
color_attachments_tmp = [Some(hal::ColorAttachment { color_attachments_tmp = [Some(hal::ColorAttachment {
target: hal::Attachment { target: hal::Attachment {
view: Texture::get_clear_view( view: Texture::get_clear_view(
clear_mode, &dst_texture.clear_mode,
&dst_texture.desc, &dst_texture.desc,
mip_level, mip_level,
depth_or_layer, depth_or_layer,
@ -481,7 +480,7 @@ fn clear_texture_via_render_passes<A: HalApi>(
Some(hal::DepthStencilAttachment { Some(hal::DepthStencilAttachment {
target: hal::Attachment { target: hal::Attachment {
view: Texture::get_clear_view( view: Texture::get_clear_view(
clear_mode, &dst_texture.clear_mode,
&dst_texture.desc, &dst_texture.desc,
mip_level, mip_level,
depth_or_layer, depth_or_layer,

View File

@ -133,7 +133,6 @@ define_lock_ranks! {
rank SURFACE_PRESENTATION "Surface::presentation" followed by { } rank SURFACE_PRESENTATION "Surface::presentation" followed by { }
rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { } rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { }
rank TEXTURE_INITIALIZATION_STATUS "Texture::initialization_status" 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 { } rank TEXTURE_VIEWS "Texture::views" followed by { }
#[cfg(test)] #[cfg(test)]

View File

@ -995,7 +995,7 @@ pub struct Texture<A: HalApi> {
/// The `label` from the descriptor used to create the resource. /// The `label` from the descriptor used to create the resource.
pub(crate) label: String, pub(crate) label: String,
pub(crate) tracking_data: TrackingData, pub(crate) tracking_data: TrackingData,
pub(crate) clear_mode: RwLock<TextureClearMode<A>>, pub(crate) clear_mode: TextureClearMode<A>,
pub(crate) views: Mutex<Vec<Weak<TextureView<A>>>>, pub(crate) views: Mutex<Vec<Weak<TextureView<A>>>>,
pub(crate) bind_groups: Mutex<Vec<Weak<BindGroup<A>>>>, pub(crate) bind_groups: Mutex<Vec<Weak<BindGroup<A>>>>,
} }
@ -1030,7 +1030,7 @@ impl<A: HalApi> Texture<A> {
}, },
label: desc.label.to_string(), label: desc.label.to_string(),
tracking_data: TrackingData::new(device.tracker_indices.textures.clone()), 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()), views: Mutex::new(rank::TEXTURE_VIEWS, Vec::new()),
bind_groups: Mutex::new(rank::TEXTURE_BIND_GROUPS, Vec::new()), bind_groups: Mutex::new(rank::TEXTURE_BIND_GROUPS, Vec::new()),
} }
@ -1056,9 +1056,7 @@ impl<A: HalApi> Texture<A> {
impl<A: HalApi> Drop for Texture<A> { impl<A: HalApi> Drop for Texture<A> {
fn drop(&mut self) { fn drop(&mut self) {
use hal::Device; use hal::Device;
let mut clear_mode = self.clear_mode.write(); match self.clear_mode {
let clear_mode = &mut *clear_mode;
match *clear_mode {
TextureClearMode::Surface { TextureClearMode::Surface {
ref mut clear_view, .. ref mut clear_view, ..
} => { } => {