lumen_engine_gpu/
binding.rs1use crate::{BufferId, SamplerId, TextureId};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum TextureAccess {
5 Sampled,
6 Storage,
7 RenderTarget,
8}
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum BufferAccess {
12 Uniform,
13 Storage,
14 Vertex,
15 Index,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub enum BindingResource {
20 Texture {
21 id: TextureId,
22 access: TextureAccess,
23 },
24 Buffer {
25 id: BufferId,
26 access: BufferAccess,
27 },
28 Sampler(SamplerId),
29}
30
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct Binding {
33 pub group: u32,
34 pub binding: u32,
35 pub resource: BindingResource,
36}
37
38impl Binding {
39 pub const fn sampled_texture(group: u32, binding: u32, id: TextureId) -> Self {
40 Self {
41 group,
42 binding,
43 resource: BindingResource::Texture {
44 id,
45 access: TextureAccess::Sampled,
46 },
47 }
48 }
49
50 pub const fn storage_texture(group: u32, binding: u32, id: TextureId) -> Self {
51 Self {
52 group,
53 binding,
54 resource: BindingResource::Texture {
55 id,
56 access: TextureAccess::Storage,
57 },
58 }
59 }
60
61 pub const fn uniform(group: u32, binding: u32, id: BufferId) -> Self {
62 Self {
63 group,
64 binding,
65 resource: BindingResource::Buffer {
66 id,
67 access: BufferAccess::Uniform,
68 },
69 }
70 }
71
72 pub const fn storage_buffer(group: u32, binding: u32, id: BufferId) -> Self {
73 Self {
74 group,
75 binding,
76 resource: BindingResource::Buffer {
77 id,
78 access: BufferAccess::Storage,
79 },
80 }
81 }
82
83 pub const fn sampler(group: u32, binding: u32, id: SamplerId) -> Self {
84 Self {
85 group,
86 binding,
87 resource: BindingResource::Sampler(id),
88 }
89 }
90}