bevy_render/render_resource/
bind_group_layout.rs

1use crate::define_atomic_id;
2use crate::renderer::WgpuWrapper;
3use alloc::sync::Arc;
4use core::ops::Deref;
5
6define_atomic_id!(BindGroupLayoutId);
7
8#[derive(Clone, Debug)]
9pub struct BindGroupLayout {
10    id: BindGroupLayoutId,
11    value: Arc<WgpuWrapper<wgpu::BindGroupLayout>>,
12}
13
14impl PartialEq for BindGroupLayout {
15    fn eq(&self, other: &Self) -> bool {
16        self.id == other.id
17    }
18}
19
20impl BindGroupLayout {
21    #[inline]
22    pub fn id(&self) -> BindGroupLayoutId {
23        self.id
24    }
25
26    #[inline]
27    pub fn value(&self) -> &wgpu::BindGroupLayout {
28        &self.value
29    }
30}
31
32impl From<wgpu::BindGroupLayout> for BindGroupLayout {
33    fn from(value: wgpu::BindGroupLayout) -> Self {
34        BindGroupLayout {
35            id: BindGroupLayoutId::new(),
36            value: Arc::new(WgpuWrapper::new(value)),
37        }
38    }
39}
40
41impl Deref for BindGroupLayout {
42    type Target = wgpu::BindGroupLayout;
43
44    #[inline]
45    fn deref(&self) -> &Self::Target {
46        &self.value
47    }
48}