1pub mod cubemap;
2pub mod material;
3pub mod material_instance;
4pub mod samplers;
5pub mod textures;
6
7pub struct BindingEntry {
8 pub name: &'static str,
9 pub kind: BindingKind,
10}
11
12pub enum BindingKind {
13 Texture,
14 Sampler,
15 Buffer,
16 TextureCubemap,
17}
18
19impl BindingEntry {
20 pub fn texture(name: &'static str) -> Self {
21 Self {
22 name,
23 kind: BindingKind::Texture,
24 }
25 }
26
27 pub fn sampler(name: &'static str) -> Self {
28 Self {
29 name,
30 kind: BindingKind::Sampler,
31 }
32 }
33
34 pub fn buffer(name: &'static str) -> Self {
35 Self {
36 name,
37 kind: BindingKind::Buffer,
38 }
39 }
40
41 pub fn cubemap(name: &'static str) -> Self {
42 Self {
43 name,
44 kind: BindingKind::TextureCubemap,
45 }
46 }
47
48 pub fn layout_entry(&self, binding: u32) -> wgpu::BindGroupLayoutEntry {
49 match self.kind {
50 BindingKind::Texture => wgpu::BindGroupLayoutEntry {
51 binding,
52 visibility: wgpu::ShaderStages::FRAGMENT,
53 ty: wgpu::BindingType::Texture {
54 sample_type: wgpu::TextureSampleType::Float { filterable: true },
55 view_dimension: wgpu::TextureViewDimension::D2,
56 multisampled: false,
57 },
58 count: None,
59 },
60 BindingKind::Sampler => wgpu::BindGroupLayoutEntry {
61 binding,
62 visibility: wgpu::ShaderStages::FRAGMENT,
63 ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
64 count: None,
65 },
66 BindingKind::Buffer => wgpu::BindGroupLayoutEntry {
67 binding,
68 visibility: wgpu::ShaderStages::VERTEX_FRAGMENT,
69 ty: wgpu::BindingType::Buffer {
70 ty: wgpu::BufferBindingType::Uniform,
71 has_dynamic_offset: false,
72 min_binding_size: None,
73 },
74 count: None,
75 },
76 BindingKind::TextureCubemap => wgpu::BindGroupLayoutEntry {
77 binding,
78 visibility: wgpu::ShaderStages::FRAGMENT,
79 ty: wgpu::BindingType::Texture {
80 sample_type: wgpu::TextureSampleType::Float { filterable: true },
81 view_dimension: wgpu::TextureViewDimension::Cube,
82 multisampled: false,
83 },
84 count: None,
85 },
86 }
87 }
88}