bevy_render/render_resource/
bind_group_layout.rs1use crate::renderer::wgpu_wrapper;
2use bevy_utils::define_atomic_id;
3use core::ops::Deref;
4
5define_atomic_id!(BindGroupLayoutId);
6
7wgpu_wrapper! {
8 #[derive(Clone, Debug)]
9 struct WgpuBindGroupLayout(wgpu::BindGroupLayout);
10}
11
12#[derive(Clone, Debug)]
21pub struct BindGroupLayout {
22 id: BindGroupLayoutId,
23 value: WgpuBindGroupLayout,
24}
25
26impl PartialEq for BindGroupLayout {
27 fn eq(&self, other: &Self) -> bool {
28 self.id == other.id
29 }
30}
31
32impl Eq for BindGroupLayout {}
33
34impl core::hash::Hash for BindGroupLayout {
35 fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
36 self.id.0.hash(state);
37 }
38}
39
40impl BindGroupLayout {
41 #[inline]
43 pub fn id(&self) -> BindGroupLayoutId {
44 self.id
45 }
46
47 #[inline]
48 pub fn value(&self) -> &wgpu::BindGroupLayout {
49 &self.value
50 }
51}
52
53impl From<wgpu::BindGroupLayout> for BindGroupLayout {
54 fn from(value: wgpu::BindGroupLayout) -> Self {
55 BindGroupLayout {
56 id: BindGroupLayoutId::new(),
57 value: WgpuBindGroupLayout::new(value),
58 }
59 }
60}
61
62impl Deref for BindGroupLayout {
63 type Target = wgpu::BindGroupLayout;
64
65 #[inline]
66 fn deref(&self) -> &Self::Target {
67 &self.value
68 }
69}