Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BindGroupEntries #2

Closed
wants to merge 35 commits into from
Closed

BindGroupEntries #2

wants to merge 35 commits into from

Conversation

robtfm
Copy link
Owner

@robtfm robtfm commented Sep 4, 2023

Objective

Simplify bind group creation code. alternative to (and based on) bevyengine#9476

Solution

  • Add a BindGroupEntries struct that can transparently be used where &[BindGroupEntry<'b>] is required in BindGroupDescriptors.

Allows constructing the descriptor's entries as:

render_device.create_bind_group(
    Some("my_bind_group"),
    &my_layout,
    BindGroupEntries::with_indexes((
        (2, &my_sampler),
        (3, my_uniform),
    )).as_slice(),
);

instead of

render_device.create_bind_group(
    Some("my_bind_group"),
    &my_layout,
    &[
        BindGroupEntry {
            binding: 2,
            resource: BindingResource::Sampler(&my_sampler),
        },
        BindGroupEntry {
            binding: 3,
            resource: my_uniform,
        },
    ],
);

or

render_device.create_bind_group(
    Some("my_bind_group"),
    &my_layout,
    BindGroupEntries::sequential((
        &my_sampler,
        my_uniform,
    )).as_slice(),
);

instead of

render_device.create_bind_group(
    Some("my_bind_group"),
    &my_layout,
    &[
        BindGroupEntry {
            binding: 0,
            resource: BindingResource::Sampler(&my_sampler),
        },
        BindGroupEntry {
            binding: 1,
            resource: my_uniform,
        },
    ],
);

the structs has no user facing macros, is tuple-type-based so stack allocated, and has no noticeable impact on compile time.

  • Also adds a DynamicBindGroupEntries struct with a similar api that uses a Vec under the hood and allows extending the entries.
  • Modifies RenderDevice::create_bind_group to take separate arguments label, layout and entries instead of a BindGroupDescriptor struct. The struct can't be stored due to the internal references, and with only 3 members arguably does not add enough context to justify itself.
  • Modify the codebase to use the new api and the BindGroupEntries / DynamicBindGroupEntries structs where appropriate (whenever the entries slice contains more than 1 member).

Migration Guide

Calls to RenderDevice::create_bind_group({BindGroupDescriptor { label, layout, entries }) must be amended to RenderDevice::create_bind_group(label, layout, entries).

@github-actions
Copy link

github-actions bot commented Sep 4, 2023

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@robtfm robtfm closed this Sep 4, 2023
@robtfm robtfm reopened this Sep 5, 2023
@robtfm robtfm closed this Oct 21, 2023
robtfm pushed a commit that referenced this pull request Jul 29, 2024
…3906)

# Objective

- Second part of bevyengine#13900 
- based on bevyengine#13905 

## Solution

- check_dir_light_mesh_visibility defers setting the entity's
`ViewVisibility `so that Bevy can schedule it to run in parallel with
`check_point_light_mesh_visibility`.

- Reduce HashMap lookups for directional light checking as much as
possible

- Use `par_iter `to parallelize the checking process within each system.

---------

Co-authored-by: Kristoffer Søholm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant