mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-16 08:53:20 +00:00
Map texture dimension and size
This commit is contained in:
parent
1855e22d0c
commit
beac74c481
@ -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),
|
||||
}
|
||||
}
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user