use crate::primitive::UIRegion; use wgpu::VertexAttribute; #[repr(C)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] pub struct PrimitiveInstance { pub region: UIRegion, pub ptr: u32, } #[repr(C)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable, Default)] pub struct WindowUniform { pub width: f32, pub height: f32, } impl PrimitiveInstance { const ATTRIBS: [VertexAttribute; 5] = wgpu::vertex_attr_array![ 0 => Float32x2, 1 => Float32x2, 2 => Float32x2, 3 => Float32x2, 4 => Uint32, ]; pub fn desc() -> wgpu::VertexBufferLayout<'static> { wgpu::VertexBufferLayout { array_stride: std::mem::size_of::() as wgpu::BufferAddress, step_mode: wgpu::VertexStepMode::Instance, attributes: &Self::ATTRIBS, } } }