rustial_renderer_wgpu/gpu/
column_vertex.rs1use bytemuck::{Pod, Zeroable};
4
5#[repr(C)]
7#[derive(Debug, Clone, Copy, Pod, Zeroable)]
8pub struct ColumnVertex {
9 pub position: [f32; 3],
11 pub normal: [f32; 3],
13}
14
15impl ColumnVertex {
16 pub fn layout() -> wgpu::VertexBufferLayout<'static> {
18 wgpu::VertexBufferLayout {
19 array_stride: std::mem::size_of::<ColumnVertex>() as wgpu::BufferAddress,
20 step_mode: wgpu::VertexStepMode::Vertex,
21 attributes: &[
22 wgpu::VertexAttribute {
23 offset: 0,
24 shader_location: 0,
25 format: wgpu::VertexFormat::Float32x3,
26 },
27 wgpu::VertexAttribute {
28 offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
29 shader_location: 1,
30 format: wgpu::VertexFormat::Float32x3,
31 },
32 ],
33 }
34 }
35}
36
37#[repr(C)]
39#[derive(Debug, Clone, Copy, PartialEq, Pod, Zeroable)]
40pub struct ColumnInstanceData {
41 pub base_position: [f32; 3],
43 pub dimensions: [f32; 4],
45 pub color: [f32; 4],
47}
48
49impl ColumnInstanceData {
50 pub fn layout() -> wgpu::VertexBufferLayout<'static> {
52 wgpu::VertexBufferLayout {
53 array_stride: std::mem::size_of::<ColumnInstanceData>() as wgpu::BufferAddress,
54 step_mode: wgpu::VertexStepMode::Instance,
55 attributes: &[
56 wgpu::VertexAttribute {
57 offset: 0,
58 shader_location: 2,
59 format: wgpu::VertexFormat::Float32x3,
60 },
61 wgpu::VertexAttribute {
62 offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
63 shader_location: 3,
64 format: wgpu::VertexFormat::Float32x4,
65 },
66 wgpu::VertexAttribute {
67 offset: (std::mem::size_of::<[f32; 3]>() + std::mem::size_of::<[f32; 4]>())
68 as wgpu::BufferAddress,
69 shader_location: 4,
70 format: wgpu::VertexFormat::Float32x4,
71 },
72 ],
73 }
74 }
75}