diff --git a/wgpu-native/src/conv.rs b/wgpu-native/src/conv.rs index 3d6c8e312b..7b0c4bfc1b 100644 --- a/wgpu-native/src/conv.rs +++ b/wgpu-native/src/conv.rs @@ -1,6 +1,6 @@ use hal; -use {binding_model, pipeline, resource}; +use {Extent3d, binding_model, pipeline, resource}; pub(crate) fn map_buffer_usage( usage: resource::BufferUsageFlags, @@ -237,3 +237,22 @@ pub(crate) fn map_texture_format(texture_format: resource::TextureFormat) -> hal D32FloatS8Uint => H::D32FloatS8Uint, } } + +fn checked_u32_as_u16(value: u32) -> u16 { + assert!(value <= ::std::u16::MAX as u32); + value as u16 +} + +pub(crate) fn map_texture_dimension_size(dimension: resource::TextureDimension, size: Extent3d) -> hal::image::Kind { + use hal::image::Kind as H; + use resource::TextureDimension::*; + let Extent3d { width, height, depth } = size; + match dimension { + D1 => { + assert_eq!(height, 1); + H::D1(width, checked_u32_as_u16(depth)) + } + D2 => H::D2(width, height, checked_u32_as_u16(depth), 1), // TODO: Samples + D3 => H::D3(width, height, depth), + } +} diff --git a/wgpu-native/src/lib.rs b/wgpu-native/src/lib.rs index be09827a45..68a903fc51 100644 --- a/wgpu-native/src/lib.rs +++ b/wgpu-native/src/lib.rs @@ -76,9 +76,9 @@ pub struct Origin3d { #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct Extent3d { - pub width: f32, - pub height: f32, - pub depth: f32, + pub width: u32, + pub height: u32, + pub depth: u32, } #[repr(C)]