-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvertex.rs
More file actions
49 lines (44 loc) · 1.48 KB
/
vertex.rs
File metadata and controls
49 lines (44 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Vertex color/attribute formats used by the platform layer.
//!
//! These map directly to `wgpu` texture/vertex formats and are re‑exported via
//! the high‑level rendering module. This is an internal surface that may
//! evolve with engine needs.
/// Canonical color/attribute formats used by engine pipelines.
#[derive(Clone, Copy, Debug)]
pub enum ColorFormat {
Rgb32Sfloat,
Rgba8Srgb,
}
impl ColorFormat {
pub(crate) fn to_texture_format(self) -> wgpu::TextureFormat {
return match self {
ColorFormat::Rgb32Sfloat => wgpu::TextureFormat::Rgba32Float,
ColorFormat::Rgba8Srgb => wgpu::TextureFormat::Rgba8UnormSrgb,
};
}
pub(crate) fn to_vertex_format(self) -> wgpu::VertexFormat {
return match self {
ColorFormat::Rgb32Sfloat => wgpu::VertexFormat::Float32x3,
ColorFormat::Rgba8Srgb => wgpu::VertexFormat::Unorm8x4,
};
}
}
/// Step mode applied to a vertex buffer layout.
///
/// `Vertex` advances attributes per vertex; `Instance` advances attributes per
/// instance. This mirrors `wgpu::VertexStepMode` without exposing the raw
/// dependency to higher layers.
#[derive(Clone, Copy, Debug)]
pub enum VertexStepMode {
Vertex,
Instance,
}
impl VertexStepMode {
/// Map the engine step mode to the underlying graphics API.
pub(crate) fn to_wgpu(self) -> wgpu::VertexStepMode {
return match self {
VertexStepMode::Vertex => wgpu::VertexStepMode::Vertex,
VertexStepMode::Instance => wgpu::VertexStepMode::Instance,
};
}
}