mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Update texture_create_view logic to match spec (#2621)
This commit is contained in:
@@ -856,10 +856,7 @@ impl<A: HalApi> Device<A> {
|
||||
}
|
||||
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<A: HalApi> Device<A> {
|
||||
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;
|
||||
|
||||
@@ -3118,8 +3118,8 @@ impl<L> TextureDescriptor<L> {
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user