diff --git a/wgpu-core/src/command/memory_init.rs b/wgpu-core/src/command/memory_init.rs index cfb0497562..8167d7cdd9 100644 --- a/wgpu-core/src/command/memory_init.rs +++ b/wgpu-core/src/command/memory_init.rs @@ -300,9 +300,6 @@ impl BakedCommands { .as_raw() .ok_or(DestroyedTextureError(texture_use.id))?; - debug_assert!(texture.hal_usage.contains(hal::TextureUses::COPY_DST), - "Every texture needs to have the COPY_DST flag. Otherwise we can't ensure initialized memory!"); - let mut texture_barriers = Vec::new(); let mut zero_buffer_copy_regions = Vec::new(); for range in &ranges { @@ -332,6 +329,8 @@ impl BakedCommands { } if !zero_buffer_copy_regions.is_empty() { + debug_assert!(texture.hal_usage.contains(hal::TextureUses::COPY_DST), + "Texture needs to have the COPY_DST flag. Otherwise we can't ensure initialized memory!"); unsafe { // TODO: Could safe on transition_textures calls by bundling barriers from *all* textures. // (a bbit more tricky because a naive approach would have to borrow same texture several times then) diff --git a/wgpu-core/src/conv.rs b/wgpu-core/src/conv.rs index fa1753d02c..930a532976 100644 --- a/wgpu-core/src/conv.rs +++ b/wgpu-core/src/conv.rs @@ -65,9 +65,7 @@ pub fn map_texture_usage( usage: wgt::TextureUsages, aspect: hal::FormatAspects, ) -> hal::TextureUses { - // Enforce COPY_DST, otherwise we wouldn't be able to initialize the texture. - let mut u = hal::TextureUses::COPY_DST; - + let mut u = hal::TextureUses::empty(); u.set( hal::TextureUses::COPY_SRC, usage.contains(wgt::TextureUsages::COPY_SRC), diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 3783f480a5..dae24ceede 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -625,7 +625,9 @@ impl Device { adapter: &crate::instance::Adapter, desc: &resource::TextureDescriptor, ) -> Result, resource::CreateTextureError> { - let hal_usage = conv::map_texture_usage(desc.usage, desc.format.into()); + // Enforce COPY_DST, otherwise we wouldn't be able to initialize the texture. + let hal_usage = + conv::map_texture_usage(desc.usage, desc.format.into()) | hal::TextureUses::COPY_DST; let hal_desc = hal::TextureDescriptor { label: desc.label.borrow_option(), @@ -685,7 +687,9 @@ impl Device { .map_err(DeviceError::from)? }; - Ok(self.create_texture_from_hal(raw, self_id, desc, format_features)) + let mut texture = self.create_texture_from_hal(raw, self_id, desc, format_features); + texture.hal_usage = hal_usage; + Ok(texture) } fn create_texture_view(