[rs] Replace u32 with NonZeroU32 in TextureView

This commit is contained in:
Kunal Mohan
2020-08-05 22:54:41 +05:30
parent 768c606844
commit f9ab713d0e
4 changed files with 8 additions and 8 deletions

View File

@@ -27,14 +27,14 @@ vulkan-portability = ["wgc/gfx-backend-vulkan"]
package = "wgpu-core"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "78546f410da6c3d48152c8b7d2cf3799babf956b"
rev = "8057acf120f9944056a6b5de6cf326f18ae7671d"
features = ["raw-window-handle"]
[dependencies.wgt]
package = "wgpu-types"
version = "0.5"
git = "https://github.com/gfx-rs/wgpu"
rev = "78546f410da6c3d48152c8b7d2cf3799babf956b"
rev = "8057acf120f9944056a6b5de6cf326f18ae7671d"
[dependencies]
arrayvec = "0.5"

View File

@@ -2,7 +2,7 @@
mod framework;
use bytemuck::{Pod, Zeroable};
use std::borrow::Cow::Borrowed;
use std::{borrow::Cow::Borrowed, num::NonZeroU32};
use wgpu::util::DeviceExt;
const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
@@ -160,7 +160,7 @@ impl Example {
dimension: wgpu::TextureViewDimension::D2,
aspect: wgpu::TextureAspect::All,
base_mip_level: mip,
level_count: Some(1),
level_count: NonZeroU32::new(1),
base_array_layer: 0,
array_layer_count: None,
})

View File

@@ -1,4 +1,4 @@
use std::{borrow::Cow::Borrowed, iter, mem, ops::Range, rc::Rc};
use std::{borrow::Cow::Borrowed, iter, mem, num::NonZeroU32, ops::Range, rc::Rc};
#[path = "../framework.rs"]
mod framework;
@@ -391,7 +391,7 @@ impl framework::Example for Example {
base_mip_level: 0,
level_count: None,
base_array_layer: i as u32,
array_layer_count: Some(1),
array_layer_count: NonZeroU32::new(1),
}))
})
.collect::<Vec<_>>();

View File

@@ -1202,11 +1202,11 @@ impl crate::Context for Context {
mapped_desc.aspect(map_texture_aspect(d.aspect));
mapped_desc.base_array_layer(d.base_array_layer);
if let Some(count) = d.array_layer_count {
mapped_desc.array_layer_count(count);
mapped_desc.array_layer_count(count.get());
}
mapped_desc.base_mip_level(d.base_mip_level);
if let Some(count) = d.level_count {
mapped_desc.mip_level_count(count);
mapped_desc.mip_level_count(count.get());
}
// TODO: label
texture.0.create_view_with_descriptor(&mapped_desc)