Made the layouts more compact

This commit is contained in:
Capucho 2020-09-13 16:05:11 +01:00 committed by Imbris
parent 4fd9567da5
commit 91454ab0f7
11 changed files with 145 additions and 223 deletions

View File

@ -46,21 +46,6 @@ impl Locals {
flags, flags,
} }
} }
fn layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None,
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
}],
})
}
} }
impl Default for Locals { impl Default for Locals {
@ -127,21 +112,38 @@ pub type BoneMeshes = (Mesh<Vertex>, anim::vek::Aabb<f32>);
pub struct FigureLayout { pub struct FigureLayout {
pub locals: wgpu::BindGroupLayout, pub locals: wgpu::BindGroupLayout,
pub bone_data: wgpu::BindGroupLayout,
pub col_lights: wgpu::BindGroupLayout,
} }
impl FigureLayout { impl FigureLayout {
pub fn new(device: &wgpu::Device) -> Self { pub fn new(device: &wgpu::Device) -> Self {
Self { Self {
locals: Locals::layout(device), locals: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
bone_data: BoneData::layout(device),
col_lights: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: None,
entries: &[ entries: &[
// locals
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
},
// bone data
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
},
// col lights
wgpu::BindGroupLayoutEntry {
binding: 2,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2, dimension: wgpu::TextureViewDimension::D2,
@ -150,7 +152,7 @@ impl FigureLayout {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 3,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
@ -179,17 +181,7 @@ impl FigurePipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Figure pipeline layout"), label: Some("Figure pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[&global_layout.globals, &layout.locals],
&global_layout.globals,
&global_layout.alt_horizon,
&global_layout.light,
&global_layout.shadow,
&global_layout.shadow_maps,
&global_layout.light_shadows,
&layout.locals,
&layout.bone_data,
&layout.col_lights,
],
}); });
let samples = match aa_mode { let samples = match aa_mode {

View File

@ -95,15 +95,7 @@ impl FluidPipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Fluid pipeline layout"), label: Some("Fluid pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[&global_layout.globals, &layout.waves],
&global_layout.globals,
&global_layout.alt_horizon,
&global_layout.light,
&global_layout.shadow,
&global_layout.shadow_maps,
&global_layout.light_shadows,
&layout.waves,
],
}); });
let samples = match aa_mode { let samples = match aa_mode {

View File

@ -159,11 +159,7 @@ impl LodTerrainPipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Lod terrain pipeline layout"), label: Some("Lod terrain pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[&global_layout.globals],
&global_layout.globals,
&global_layout.alt_horizon,
&global_layout.lod_map,
],
}); });
let samples = match aa_mode { let samples = match aa_mode {

View File

@ -227,12 +227,6 @@ pub struct GlobalModel {
pub struct GlobalsLayouts { pub struct GlobalsLayouts {
pub globals: wgpu::BindGroupLayout, pub globals: wgpu::BindGroupLayout,
pub light: wgpu::BindGroupLayout,
pub shadow: wgpu::BindGroupLayout,
pub alt_horizon: wgpu::BindGroupLayout,
pub shadow_maps: wgpu::BindGroupLayout,
pub light_shadows: wgpu::BindGroupLayout,
pub lod_map: wgpu::BindGroupLayout,
} }
impl GlobalsLayouts { impl GlobalsLayouts {
@ -240,6 +234,7 @@ impl GlobalsLayouts {
let globals = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { let globals = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("Globals layout"), label: Some("Globals layout"),
entries: &[ entries: &[
// Global uniform
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
@ -249,6 +244,7 @@ impl GlobalsLayouts {
}, },
count: None, count: None,
}, },
// Noise tex
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 1,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
@ -265,76 +261,29 @@ impl GlobalsLayouts {
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
}, },
], // Light uniform
});
let light = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("Light layout"),
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
}],
});
let shadow = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("Shadow layout"),
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
}],
});
let alt_horizon = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("alt/horizon layout"),
entries: &[
wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2,
multisampled: false,
},
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false },
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 2,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2,
multisampled: false,
},
count: None,
},
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 3, binding: 3,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None, count: None,
}, },
], // Shadow uniform
});
let shadow_maps = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("Shadow maps layout"),
entries: &[
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 4,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
},
// Alt texture
wgpu::BindGroupLayoutEntry {
binding: 5,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
@ -344,19 +293,14 @@ impl GlobalsLayouts {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 6,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
}, },
], // Horizon texture
});
let light_shadows = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("Light shadows layout"),
entries: &[
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 7,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
@ -366,13 +310,14 @@ impl GlobalsLayouts {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 8,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
}, },
// light shadows
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 2, binding: 9,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
@ -382,19 +327,14 @@ impl GlobalsLayouts {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 3, binding: 10,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
}, },
], // point shadow_maps
});
let lod_map = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("Lod layout"),
entries: &[
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 11,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
@ -404,7 +344,41 @@ impl GlobalsLayouts {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 12,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false },
count: None,
},
// directed shadow maps
wgpu::BindGroupLayoutEntry {
binding: 13,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2,
multisampled: false,
},
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 14,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false },
count: None,
},
// lod map (t_map)
wgpu::BindGroupLayoutEntry {
binding: 15,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2,
multisampled: false,
},
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 16,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
@ -412,14 +386,6 @@ impl GlobalsLayouts {
], ],
}); });
Self { Self { globals }
globals,
light,
shadow,
alt_horizon,
shadow_maps,
light_shadows,
lod_map,
}
} }
} }

View File

@ -169,14 +169,7 @@ impl ParticlePipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Particle pipeline layout"), label: Some("Particle pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[&global_layout.globals],
&global_layout.globals,
&global_layout.alt_horizon,
&global_layout.light,
&global_layout.shadow,
&global_layout.shadow_maps,
&global_layout.light_shadows,
],
}); });
let samples = match aa_mode { let samples = match aa_mode {

View File

@ -1,5 +1,6 @@
use super::super::{ use super::super::{
AaMode, ColLightInfo, FigureLayout, GlobalsLayouts, Renderer, TerrainVertex, Texture, AaMode, ColLightInfo, FigureLayout, GlobalsLayouts, Renderer, TerrainLayout, TerrainVertex,
Texture,
}; };
use vek::*; use vek::*;
use zerocopy::AsBytes; use zerocopy::AsBytes;
@ -99,7 +100,8 @@ impl ShadowFigurePipeline {
fs_module: &wgpu::ShaderModule, fs_module: &wgpu::ShaderModule,
sc_desc: &wgpu::SwapChainDescriptor, sc_desc: &wgpu::SwapChainDescriptor,
global_layout: &GlobalsLayouts, global_layout: &GlobalsLayouts,
layout: &FigureLayout, figure_layout: &FigureLayout,
layout: &ShadowLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
let render_pipeline_layout = let render_pipeline_layout =
@ -108,8 +110,8 @@ impl ShadowFigurePipeline {
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[
&global_layout.globals, &global_layout.globals,
&global_layout.light_shadows, &figure_layout.locals,
&layout.waves, &layout.locals,
], ],
}); });
@ -180,6 +182,7 @@ impl ShadowPipeline {
fs_module: &wgpu::ShaderModule, fs_module: &wgpu::ShaderModule,
sc_desc: &wgpu::SwapChainDescriptor, sc_desc: &wgpu::SwapChainDescriptor,
global_layout: &GlobalsLayouts, global_layout: &GlobalsLayouts,
terrain_layout: &TerrainLayout,
layout: &ShadowLayout, layout: &ShadowLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
@ -189,7 +192,7 @@ impl ShadowPipeline {
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[
&global_layout.globals, &global_layout.globals,
&global_layout.light_shadows, &terrain_layout.locals,
&layout.locals, &layout.locals,
], ],
}); });

View File

@ -39,7 +39,7 @@ impl SkyboxPipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Skybox pipeline layout"), label: Some("Skybox pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[&layouts.globals, &layouts.alt_horizon], bind_group_layouts: &[&layouts.globals],
}); });
let samples = match aa_mode { let samples = match aa_mode {

View File

@ -163,19 +163,28 @@ impl Locals {
pub struct SpriteLayout { pub struct SpriteLayout {
pub locals: wgpu::BindGroupLayout, pub locals: wgpu::BindGroupLayout,
pub col_lights: wgpu::BindGroupLayout,
} }
impl SpriteLayout { impl SpriteLayout {
pub fn new(device: &wgpu::Device) -> Self { pub fn new(device: &wgpu::Device) -> Self {
Self { Self {
locals: Locals::layout(device), locals: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
col_lights: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: None,
entries: &[ entries: &[
// locals
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
},
// col lights
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2, dimension: wgpu::TextureViewDimension::D2,
@ -184,7 +193,7 @@ impl SpriteLayout {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 2,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
@ -216,14 +225,8 @@ impl SpritePipeline {
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[
&global_layout.globals, &global_layout.globals,
&global_layout.alt_horizon,
&global_layout.light,
&global_layout.shadow,
&global_layout.shadow_maps,
&global_layout.light_shadows,
&layout.col_lights,
&layout.locals,
&terrain_layout.locals, &terrain_layout.locals,
&layout.locals,
], ],
}); });

View File

@ -127,38 +127,32 @@ impl Locals {
atlas_offs: [0; 4], atlas_offs: [0; 4],
} }
} }
fn layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None,
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
}],
})
}
} }
pub struct TerrainLayout { pub struct TerrainLayout {
pub locals: wgpu::BindGroupLayout, pub locals: wgpu::BindGroupLayout,
pub col_lights: wgpu::BindGroupLayout,
} }
impl TerrainLayout { impl TerrainLayout {
pub fn new(device: &wgpu::Device) -> Self { pub fn new(device: &wgpu::Device) -> Self {
Self { Self {
locals: Locals::layout(device), locals: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
col_lights: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: None,
entries: &[ entries: &[
// locals
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
},
// col lights
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2, dimension: wgpu::TextureViewDimension::D2,
@ -167,7 +161,7 @@ impl TerrainLayout {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 2,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
@ -196,16 +190,7 @@ impl TerrainPipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Terrain pipeline layout"), label: Some("Terrain pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[ bind_group_layouts: &[&global_layout.globals, &layout.locals],
&global_layout.globals,
&global_layout.alt_horizon,
&global_layout.light,
&global_layout.shadow,
&global_layout.shadow_maps,
&global_layout.light_shadows,
&layout.locals,
&layout.col_lights,
],
}); });
let samples = match aa_mode { let samples = match aa_mode {

View File

@ -29,23 +29,6 @@ pub struct Locals {
pos: [f32; 4], pos: [f32; 4],
} }
impl Locals {
fn layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None,
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
}],
})
}
}
impl From<Vec4<f32>> for Locals { impl From<Vec4<f32>> for Locals {
fn from(pos: Vec4<f32>) -> Self { fn from(pos: Vec4<f32>) -> Self {
Self { Self {
@ -97,19 +80,28 @@ impl Mode {
pub struct UILayout { pub struct UILayout {
pub locals: wgpu::BindGroupLayout, pub locals: wgpu::BindGroupLayout,
pub tex: wgpu::BindGroupLayout,
} }
impl UILayout { impl UILayout {
pub fn new(device: &wgpu::Device) -> Self { pub fn new(device: &wgpu::Device) -> Self {
Self { Self {
locals: Locals::layout(device), locals: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
tex: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: None,
entries: &[ entries: &[
// locals
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::UniformBuffer {
dynamic: false,
min_binding_size: None,
},
count: None,
},
// texture
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::SampledTexture { ty: wgpu::BindingType::SampledTexture {
component_type: wgpu::TextureComponentType::Float, component_type: wgpu::TextureComponentType::Float,
dimension: wgpu::TextureViewDimension::D2, dimension: wgpu::TextureViewDimension::D2,
@ -118,7 +110,7 @@ impl UILayout {
count: None, count: None,
}, },
wgpu::BindGroupLayoutEntry { wgpu::BindGroupLayoutEntry {
binding: 1, binding: 2,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { comparison: false }, ty: wgpu::BindingType::Sampler { comparison: false },
count: None, count: None,
@ -147,7 +139,7 @@ impl UIPipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("UI pipeline layout"), label: Some("UI pipeline layout"),
push_constant_ranges: &[], push_constant_ranges: &[],
bind_group_layouts: &[&global_layout.globals, &layout.locals, &layout.tex], bind_group_layouts: &[&global_layout.globals, &layout.locals],
}); });
let samples = match aa_mode { let samples = match aa_mode {