use crate::{layout::UiRegion, util::Id}; use wgpu::*; #[repr(C)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable, Default)] pub struct WindowUniform { pub width: f32, pub height: f32, } #[repr(C)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] pub struct PrimitiveInstance { pub region: UiRegion, pub binding: u32, pub idx: u32, pub mask_idx: MaskIdx, } impl PrimitiveInstance { const ATTRIBS: [VertexAttribute; 7] = vertex_attr_array![ 0 => Float32x2, 1 => Float32x2, 2 => Float32x2, 3 => Float32x2, 4 => Uint32, 5 => Uint32, 6 => Uint32, ]; pub fn desc() -> VertexBufferLayout<'static> { VertexBufferLayout { array_stride: std::mem::size_of::() as BufferAddress, step_mode: VertexStepMode::Instance, attributes: &Self::ATTRIBS, } } } pub type MaskIdx = Id; impl MaskIdx { pub const NONE: Self = Self::preset(u32::MAX); } #[repr(C)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] pub struct Mask { pub region: UiRegion, }