bevy/crates/bevy_pbr/src/render
IceSentry 6d0c11a28f
Bind group layout entries (#10224)
# 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:
86dab7f5da

---

## Changelog

- Added `BindGroupLayoutEntries` and all `BindingType` helper functions.

## Migration Guide

`RenderDevice::create_bind_group_layout()` doesn't take a
`BindGroupLayoutDescriptor` anymore. You need to provide the parameters
separately

```rust
// 0.12
let layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor {
    label: Some("post_process_bind_group_layout"),
    entries: &[
        BindGroupLayoutEntry {
			// ...
        },
    ],
});

// 0.13
let layout = render_device.create_bind_group_layout(
	"post_process_bind_group_layout",
    &[
        BindGroupLayoutEntry {
			// ...
        },
    ],
);
```

## TODO

- [x] implement a `Dynamic` variant
- [x] update the `RenderDevice::create_bind_group_layout()` api to match
the one from `RenderDevice::creat_bind_group()`
- [x] docs
2023-11-28 04:00:49 +00:00
..
clustered_forward.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
fog.rs Fix fog color being inaccurate (#10226) 2023-10-23 12:45:18 +00:00
fog.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
forward_io.wgsl pbr shader cleanup (#10105) 2023-10-13 19:12:40 +00:00
light.rs More inactive camera checks (#10555) 2023-11-14 13:44:42 +00:00
mesh.rs Use as_image_copy where possible (#10733) 2023-11-26 19:24:32 +00:00
mesh.wgsl Ensure instance_index push constant is always used in prepass.wgsl (#10706) 2023-11-28 01:13:25 +00:00
mesh_bindings.rs Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
mesh_bindings.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
mesh_functions.wgsl View Transformations (#9726) 2023-10-24 21:26:19 +00:00
mesh_types.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
mesh_view_bindings.rs Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
mesh_view_bindings.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
mesh_view_types.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
mod.rs Variable MeshPipeline View Bind Group Layout (#10156) 2023-10-21 11:19:44 +00:00
morph.rs Use EntityHashMap<Entity, T> for render world entity storage for better performance (#9903) 2023-09-27 08:28:28 +00:00
morph.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
parallax_mapping.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
pbr.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
pbr_ambient.wgsl Use “specular occlusion” term to consistently extinguish fresnel on Ambient and Environment Map lights (#10182) 2023-10-23 03:26:20 +00:00
pbr_bindings.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
pbr_fragment.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
pbr_functions.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
pbr_lighting.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
pbr_prepass.wgsl double sided normals: fix apply_normal_mapping calls (#10330) 2023-11-01 16:40:25 +00:00
pbr_prepass_functions.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
pbr_transmission.wgsl Non uniform transmission samples (#10674) 2023-11-22 18:54:45 +00:00
pbr_types.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
rgb9e5.wgsl Deferred Renderer (#9258) 2023-10-12 22:10:38 +00:00
shadow_sampling.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
shadows.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
skin.rs Use EntityHashMap<Entity, T> for render world entity storage for better performance (#9903) 2023-09-27 08:28:28 +00:00
skinning.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
utils.wgsl StandardMaterial Light Transmission (#8015) 2023-10-31 20:59:02 +00:00
view_transformations.wgsl View Transformations (#9726) 2023-10-24 21:26:19 +00:00
wireframe.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00