mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
remove unnecessary RwLock
from Texture.clear_mode
This commit is contained in:
parent
1aaaec22f6
commit
c72bc7b84b
@ -281,7 +281,7 @@ pub(crate) fn clear_texture<A: HalApi, T: TextureTrackerSetSingle<A>>(
|
||||
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<A: HalApi, T: TextureTrackerSetSingle<A>>(
|
||||
}
|
||||
|
||||
// Record actual clearing
|
||||
match *dst_texture.clear_mode.read() {
|
||||
match dst_texture.clear_mode {
|
||||
TextureClearMode::BufferCopy => clear_texture_via_buffer_copies::<A>(
|
||||
&dst_texture.desc,
|
||||
alignments,
|
||||
@ -453,7 +453,6 @@ fn clear_texture_via_render_passes<A: HalApi>(
|
||||
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<A: HalApi>(
|
||||
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<A: HalApi>(
|
||||
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,
|
||||
|
@ -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)]
|
||||
|
@ -995,7 +995,7 @@ pub struct Texture<A: HalApi> {
|
||||
/// The `label` from the descriptor used to create the resource.
|
||||
pub(crate) label: String,
|
||||
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) bind_groups: Mutex<Vec<Weak<BindGroup<A>>>>,
|
||||
}
|
||||
@ -1030,7 +1030,7 @@ impl<A: HalApi> Texture<A> {
|
||||
},
|
||||
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<A: HalApi> Texture<A> {
|
||||
impl<A: HalApi> Drop for Texture<A> {
|
||||
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, ..
|
||||
} => {
|
||||
|
Loading…
Reference in New Issue
Block a user