bevy/crates/bevy_pbr/src
James Liu 6d547d7ce6
Allow Mesh-related queue phase systems to parallelize (#11804)
# Objective
Partially addresses #3548. `queue_shadows` and `queue_material_meshes`
cannot parallelize because of the `ResMut<RenderMeshInstances>`
parameter for `queue_material_meshes`.

## Solution
Change the `material_bind_group` field to use atomics instead of needing
full mutable access. Change the `ResMut` to a `Res`, which should allow
both sets of systems to parallelize without issue.

## Performance
Tested against `many_foxes`, this has a significant improvement over the
entire render schedule. (Yellow is this PR, red is main)

![image](https://github.com/bevyengine/bevy/assets/3137680/6cc7f346-4f50-4f12-a383-682a9ce1daf6)

The use of atomics does seem to have a negative effect on
`queue_material_meshes` (roughly a 8.29% increase in time spent in the
system).

![image](https://github.com/bevyengine/bevy/assets/3137680/7907079a-863d-4760-aa5b-df68c006ea36)

`queue_shadows` seems to be ever so slightly slower (1.6% more time
spent) in the system.

![image](https://github.com/bevyengine/bevy/assets/3137680/6d90af73-b922-45e4-bae5-df200e8b9784)

`batch_and_prepare_render_phase` seems to be a mix, but overall seems to
be slightly *faster* by about 5%.

![image](https://github.com/bevyengine/bevy/assets/3137680/fac638ff-8c90-436b-9362-c6209b18957c)
2024-02-20 00:12:41 +00:00
..
deferred Rename Core Render Graph Labels (#11882) 2024-02-15 23:15:16 +00:00
light_probe Disable irradiance volumes on WebGL and WebGPU. (#11909) 2024-02-17 01:49:46 +00:00
lightmap Move EntityHash related types into bevy_ecs (#11498) 2024-02-12 15:02:24 +00:00
prepass Stop extracting mesh entities to the render world. (#11803) 2024-02-10 10:46:10 +00:00
render Allow Mesh-related queue phase systems to parallelize (#11804) 2024-02-20 00:12:41 +00:00
ssao Rename Core Render Graph Labels (#11882) 2024-02-15 23:15:16 +00:00
alpha.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
bundle.rs Move EntityHash related types into bevy_ecs (#11498) 2024-02-12 15:02:24 +00:00
extended_material.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
fog.rs Missing registrations (#11736) 2024-02-06 16:33:17 +00:00
lib.rs Rename Core Render Graph Labels (#11882) 2024-02-15 23:15:16 +00:00
light.rs New Exposure and Lighting Defaults (and calibrate examples) (#11868) 2024-02-15 20:42:48 +00:00
material.rs Allow Mesh-related queue phase systems to parallelize (#11804) 2024-02-20 00:12:41 +00:00
parallax.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
pbr_material.rs Gate diffuse and specular transmission behind shader defs (#11627) 2024-02-02 15:01:56 +00:00
wireframe.rs Fix global wireframe behavior not being applied on new meshes (#11792) 2024-02-12 19:48:45 +00:00