rustial_renderer_wgpu/gpu/
model_vertex.rs1use bytemuck::{Pod, Zeroable};
4
5#[repr(C)]
7#[derive(Debug, Clone, Copy, Pod, Zeroable)]
8pub struct ModelVertex {
9 pub position: [f32; 3],
11 pub normal: [f32; 3],
13 pub uv: [f32; 2],
15}
16
17impl ModelVertex {
18 pub fn layout() -> wgpu::VertexBufferLayout<'static> {
20 wgpu::VertexBufferLayout {
21 array_stride: std::mem::size_of::<ModelVertex>() as wgpu::BufferAddress,
22 step_mode: wgpu::VertexStepMode::Vertex,
23 attributes: &[
24 wgpu::VertexAttribute {
25 offset: 0,
26 shader_location: 0,
27 format: wgpu::VertexFormat::Float32x3,
28 },
29 wgpu::VertexAttribute {
30 offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
31 shader_location: 1,
32 format: wgpu::VertexFormat::Float32x3,
33 },
34 wgpu::VertexAttribute {
35 offset: (std::mem::size_of::<[f32; 3]>() * 2) as wgpu::BufferAddress,
36 shader_location: 2,
37 format: wgpu::VertexFormat::Float32x2,
38 },
39 ],
40 }
41 }
42}