Map texture dimension and size

This commit is contained in:
Joshua Groves committed 2018-10-06 22:26:28 -06:00
1 parent 1855e22d0c
commit beac74c481
2 files changed
+23 -4

No files matched your search

+20 -1
View File
@@ -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),
}
}
+3 -3
View File
@@ -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)]