bevy/crates
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
..
bevy_a11y Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_animation Enable clippy::undocumented_unsafe_blocks warning across the workspace (#10646) 2023-11-21 02:06:24 +00:00
bevy_app Wait until FixedUpdate can see events before dropping them (#10077) 2023-11-26 23:04:41 +00:00
bevy_asset Fix GLTF scene dependencies and make full scene renders predictable (#10745) 2023-11-27 22:42:28 +00:00
bevy_audio Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_core Split WorldQuery into WorldQueryData and WorldQueryFilter (#9918) 2023-11-28 03:56:07 +00:00
bevy_core_pipeline Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
bevy_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_diagnostic Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_dylib Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_dynamic_plugin Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_ecs Split WorldQuery into WorldQueryData and WorldQueryFilter (#9918) 2023-11-28 03:56:07 +00:00
bevy_ecs_compile_fail_tests Split WorldQuery into WorldQueryData and WorldQueryFilter (#9918) 2023-11-28 03:56:07 +00:00
bevy_encase_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_gilrs Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_gizmos Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
bevy_gltf Fix GLTF scene dependencies and make full scene renders predictable (#10745) 2023-11-27 22:42:28 +00:00
bevy_hierarchy Split WorldQuery into WorldQueryData and WorldQueryFilter (#9918) 2023-11-28 03:56:07 +00:00
bevy_input Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_internal Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_log Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_macro_utils Allow #[derive(Bundle)] on tuple structs (take 3) (#10561) 2023-11-21 01:09:16 +00:00
bevy_macros_compile_fail_tests Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_math Use minor and major radii for Torus primitive shape (#10643) 2023-11-21 01:49:35 +00:00
bevy_mikktspace Enable clippy::undocumented_unsafe_blocks warning across the workspace (#10646) 2023-11-21 02:06:24 +00:00
bevy_pbr Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
bevy_ptr Enable clippy::undocumented_unsafe_blocks warning across the workspace (#10646) 2023-11-21 02:06:24 +00:00
bevy_reflect bevy_utils: Export generate_composite_uuid utility function (#10496) 2023-11-25 23:21:35 +00:00
bevy_reflect_compile_fail_tests Improve TypeUuid's derive macro error messages (#9315) 2023-10-02 12:42:01 +00:00
bevy_render Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
bevy_scene Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_sprite Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
bevy_tasks bump bevy_tasks futures-lite to 2.0.1 (#10675) 2023-11-24 00:11:02 +00:00
bevy_text Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_time Wait until FixedUpdate can see events before dropping them (#10077) 2023-11-26 23:04:41 +00:00
bevy_transform Enable clippy::undocumented_unsafe_blocks warning across the workspace (#10646) 2023-11-21 02:06:24 +00:00
bevy_ui Bind group layout entries (#10224) 2023-11-28 04:00:49 +00:00
bevy_utils bevy_utils: Export generate_composite_uuid utility function (#10496) 2023-11-25 23:21:35 +00:00
bevy_window add new event WindowOccluded from winit (#10735) 2023-11-26 21:58:54 +00:00
bevy_winit add new event WindowOccluded from winit (#10735) 2023-11-26 21:58:54 +00:00