diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index b951c318bd..c7e0adf14f 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -856,10 +856,7 @@ impl Device { } None => match texture.desc.dimension { wgt::TextureDimension::D1 => wgt::TextureViewDimension::D1, - wgt::TextureDimension::D2 - if texture.desc.size.depth_or_array_layers > 1 - && desc.range.array_layer_count.is_none() => - { + wgt::TextureDimension::D2 if texture.desc.size.depth_or_array_layers > 1 => { wgt::TextureViewDimension::D2Array } wgt::TextureDimension::D2 => wgt::TextureViewDimension::D2, @@ -871,7 +868,13 @@ impl Device { desc.range.base_mip_level + desc.range.mip_level_count.map_or(1, |count| count.get()); let required_layer_count = match desc.range.array_layer_count { Some(count) => desc.range.base_array_layer + count.get(), - None => texture.desc.array_layer_count(), + None => match view_dim { + wgt::TextureViewDimension::D1 + | wgt::TextureViewDimension::D2 + | wgt::TextureViewDimension::D3 => 1, + wgt::TextureViewDimension::Cube => 6, + _ => texture.desc.array_layer_count(), + }, }; let level_end = texture.full_range.levels.end; let layer_end = texture.full_range.layers.end; diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 59b202059d..4373c8ba73 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -3118,8 +3118,8 @@ impl TextureDescriptor { /// Returns the number of array layers. pub fn array_layer_count(&self) -> u32 { match self.dimension { - TextureDimension::D1 | TextureDimension::D2 => self.size.depth_or_array_layers, - TextureDimension::D3 => 1, + TextureDimension::D1 | TextureDimension::D3 => 1, + TextureDimension::D2 => self.size.depth_or_array_layers, } } }