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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
use crate::track::TrackerSet; use crate::{BindGroupLayoutId, BufferId, LifeGuard, SamplerId, TextureViewId}; use bitflags::bitflags; bitflags! { #[repr(transparent)] pub struct ShaderStageFlags: u32 { const VERTEX = 1; const FRAGMENT = 2; const COMPUTE = 4; } } #[repr(C)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] pub enum BindingType { UniformBuffer = 0, Sampler = 1, SampledTexture = 2, StorageBuffer = 3, } #[repr(C)] #[derive(Clone, Debug, Hash)] pub struct BindGroupLayoutBinding { pub binding: u32, pub visibility: ShaderStageFlags, pub ty: BindingType, } #[repr(C)] pub struct BindGroupLayoutDescriptor { pub bindings: *const BindGroupLayoutBinding, pub bindings_length: usize, } pub struct BindGroupLayout<B: hal::Backend> { pub(crate) raw: B::DescriptorSetLayout, pub(crate) bindings: Vec<BindGroupLayoutBinding>, } #[repr(C)] pub struct PipelineLayoutDescriptor { pub bind_group_layouts: *const BindGroupLayoutId, pub bind_group_layouts_length: usize, } pub struct PipelineLayout<B: hal::Backend> { pub(crate) raw: B::PipelineLayout, pub(crate) bind_group_layout_ids: Vec<BindGroupLayoutId>, } #[repr(C)] pub struct BufferBinding { pub buffer: BufferId, pub offset: u32, pub size: u32, } #[repr(C)] pub enum BindingResource { Buffer(BufferBinding), Sampler(SamplerId), TextureView(TextureViewId), } #[repr(C)] pub struct Binding { pub binding: u32, pub resource: BindingResource, } #[repr(C)] pub struct BindGroupDescriptor { pub layout: BindGroupLayoutId, pub bindings: *const Binding, pub bindings_length: usize, } pub struct BindGroup<B: hal::Backend> { pub(crate) raw: B::DescriptorSet, pub(crate) layout_id: BindGroupLayoutId, pub(crate) life_guard: LifeGuard, pub(crate) used: TrackerSet, }