Refactor global bind layout
This commit is contained in:
parent
bbd2ef7b53
commit
cb5af515df
3 changed files with 104 additions and 79 deletions
|
@ -1,3 +1,4 @@
|
|||
mod pipelines;
|
||||
|
||||
pub use pipelines::utils::create_render_pipeline;
|
||||
pub use pipelines::utils::create_render_pipeline;
|
||||
pub use pipelines::GlobalBindLayout;
|
|
@ -3,5 +3,97 @@ pub mod utils;
|
|||
pub struct GlobalBindLayout {
|
||||
texture: wgpu::BindGroupLayout,
|
||||
light: wgpu::BindGroupLayout,
|
||||
camera: wgpu::BindGroupLayout
|
||||
camera: wgpu::BindGroupLayout,
|
||||
}
|
||||
|
||||
impl GlobalBindLayout {
|
||||
pub fn new(device: &wgpu::Device) -> Self {
|
||||
let texture_bind_group_layout =
|
||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
multisampled: false,
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2,
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 2,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
multisampled: false,
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2,
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 3,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
count: None,
|
||||
},
|
||||
],
|
||||
label: Some("texture_bind_group_layout"),
|
||||
});
|
||||
|
||||
let camera_bind_group_layout =
|
||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
entries: &[wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Uniform,
|
||||
has_dynamic_offset: false,
|
||||
min_binding_size: None,
|
||||
},
|
||||
count: None,
|
||||
}],
|
||||
label: Some("camera_bind_group_layout"),
|
||||
});
|
||||
|
||||
let light_bind_group_layout =
|
||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
entries: &[wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Uniform,
|
||||
has_dynamic_offset: false,
|
||||
min_binding_size: None,
|
||||
},
|
||||
count: None,
|
||||
}],
|
||||
label: None,
|
||||
});
|
||||
|
||||
|
||||
Self {
|
||||
texture: texture_bind_group_layout,
|
||||
light: light_bind_group_layout,
|
||||
camera: camera_bind_group_layout,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_texture_bind_layout(&self) -> &wgpu::BindGroupLayout {
|
||||
&self.texture
|
||||
}
|
||||
|
||||
pub fn get_light_bind_layout(&self) -> &wgpu::BindGroupLayout {
|
||||
&self.light
|
||||
}
|
||||
|
||||
pub fn get_camera_bind_layout(&self) -> &wgpu::BindGroupLayout {
|
||||
&self.camera
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue