mirror of
https://github.com/bevyengine/bevy
synced 2024-12-20 18:13:10 +00:00
6d0c11a28f
# Objective
- Follow up to #9694
## Solution
- Same api as #9694 but adapted for `BindGroupLayoutEntry`
- Use the same `ShaderStages` visibilty for all entries by default
- Add `BindingType` helper function that mirror the wgsl equivalent and
that make writing layouts much simpler.
Before:
```rust
let layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor {
label: Some("post_process_bind_group_layout"),
entries: &[
BindGroupLayoutEntry {
binding: 0,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Texture {
sample_type: TextureSampleType::Float { filterable: true },
view_dimension: TextureViewDimension::D2,
multisampled: false,
},
count: None,
},
BindGroupLayoutEntry {
binding: 1,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
BindGroupLayoutEntry {
binding: 2,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Buffer {
ty: bevy::render::render_resource::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: Some(PostProcessSettings::min_size()),
},
count: None,
},
],
});
```
After:
```rust
let layout = render_device.create_bind_group_layout(
"post_process_bind_group_layout"),
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
(
texture_2d_f32(),
sampler(SamplerBindingType::Filtering),
uniform_buffer(false, Some(PostProcessSettings::min_size())),
),
),
);
```
Here's a more extreme example in bevy_solari:
|
||
---|---|---|
.. | ||
clustered_forward.wgsl | ||
fog.rs | ||
fog.wgsl | ||
forward_io.wgsl | ||
light.rs | ||
mesh.rs | ||
mesh.wgsl | ||
mesh_bindings.rs | ||
mesh_bindings.wgsl | ||
mesh_functions.wgsl | ||
mesh_types.wgsl | ||
mesh_view_bindings.rs | ||
mesh_view_bindings.wgsl | ||
mesh_view_types.wgsl | ||
mod.rs | ||
morph.rs | ||
morph.wgsl | ||
parallax_mapping.wgsl | ||
pbr.wgsl | ||
pbr_ambient.wgsl | ||
pbr_bindings.wgsl | ||
pbr_fragment.wgsl | ||
pbr_functions.wgsl | ||
pbr_lighting.wgsl | ||
pbr_prepass.wgsl | ||
pbr_prepass_functions.wgsl | ||
pbr_transmission.wgsl | ||
pbr_types.wgsl | ||
rgb9e5.wgsl | ||
shadow_sampling.wgsl | ||
shadows.wgsl | ||
skin.rs | ||
skinning.wgsl | ||
utils.wgsl | ||
view_transformations.wgsl | ||
wireframe.wgsl |