bevy_render/render_resource/
bind_group_layout.rs

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