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 87 88 89
use crate::track::{BufferTracker, TextureTracker}; use crate::{ LifeGuard, WeaklyStored, BindGroupLayoutId, BufferId, 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)] 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(crate) struct BindGroupLayout<B: hal::Backend> { pub raw: B::DescriptorSetLayout, } #[repr(C)] pub struct PipelineLayoutDescriptor { pub bind_group_layouts: *const BindGroupLayoutId, pub bind_group_layouts_length: usize, } pub(crate) struct PipelineLayout<B: hal::Backend> { pub raw: B::PipelineLayout, pub bind_group_layout_ids: Vec<WeaklyStored<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(crate) struct BindGroup<B: hal::Backend> { pub raw: B::DescriptorSet, pub layout_id: WeaklyStored<BindGroupLayoutId>, pub life_guard: LifeGuard, pub used_buffers: BufferTracker, pub used_textures: TextureTracker, }