bevy/crates
Robert Swain c5963b4fd5 Use storage buffers for clustered forward point lights (#3989)
# Objective

- Make use of storage buffers, where they are available, for clustered forward bindings to support far more point lights in a scene
- Fixes #3605 
- Based on top of #4079 

This branch on an M1 Max can keep 60fps with about 2150 point lights of radius 1m in the Sponza scene where I've been testing. The bottleneck is mostly assigning lights to clusters which grows faster than linearly (I think 1000 lights was about 1.5ms and 5000 was 7.5ms). I have seen papers and presentations leveraging compute shaders that can get this up to over 1 million. That said, I think any further optimisations should probably be done in a separate PR.

## Solution

- Add `RenderDevice` to the `Material` and `SpecializedMaterial` trait `::key()` functions to allow setting flags on the keys depending on feature/limit availability
- Make `GpuPointLights` and `ViewClusterBuffers` into enums containing `UniformVec` and `StorageBuffer` variants. Implement the necessary API on them to make usage the same for both cases, and the only difference is at initialisation time.
- Appropriate shader defs in the shader code to handle the two cases

## Context on some decisions / open questions

- I'm using `max_storage_buffers_per_shader_stage >= 3` as a check to see if storage buffers are supported. I was thinking about diving into 'binding resource management' but it feels like we don't have enough use cases to understand the problem yet, and it is mostly a separate concern to this PR, so I think it should be handled separately.
- Should `ViewClusterBuffers` and `ViewClusterBindings` be merged, duplicating the count variables into the enum variants?


Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2022-04-07 16:16:35 +00:00
..
bevy_animation animations: don't ignore curves with one keyframe (#4406) 2022-04-04 19:45:51 +00:00
bevy_app Fix formatting, spelling, phrasing and consistency (#4275) 2022-04-05 22:36:02 +00:00
bevy_asset Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_audio Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_core Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_core_pipeline Compute Pipeline Specialization (#3979) 2022-03-23 00:27:26 +00:00
bevy_crevice Add a helper for storage buffers similar to UniformVec (#4079) 2022-03-22 21:23:50 +00:00
bevy_derive bevy_derive: Add derives for Deref and DerefMut (#4328) 2022-03-29 02:10:06 +00:00
bevy_diagnostic Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_dylib Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_dynamic_plugin Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_ecs Add more FromWorld implementations (#3945) 2022-04-05 20:04:34 +00:00
bevy_ecs_compile_fail_tests REMOVE unsound lifetime annotations on EntityMut (#4096) 2022-04-04 21:33:33 +00:00
bevy_gilrs Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_gltf add AnimationPlayer component only on scene roots that are also animation roots (#4417) 2022-04-05 21:52:00 +00:00
bevy_hierarchy Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_input input clear should not clear pressed (#4418) 2022-04-04 22:10:00 +00:00
bevy_internal animation player (#4375) 2022-04-02 22:36:02 +00:00
bevy_log Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_macro_utils Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_math Remove face_toward.rs (#4277) 2022-04-03 14:40:46 +00:00
bevy_pbr Use storage buffers for clustered forward point lights (#3989) 2022-04-07 16:16:35 +00:00
bevy_reflect Re-enable test_property_type_registration() (#4419) 2022-04-05 18:34:27 +00:00
bevy_render Use storage buffers for clustered forward point lights (#3989) 2022-04-07 16:16:35 +00:00
bevy_scene Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_sprite Use storage buffers for clustered forward point lights (#3989) 2022-04-07 16:16:35 +00:00
bevy_tasks CI runs cargo miri test -p bevy_ecs (#4310) 2022-03-25 00:26:07 +00:00
bevy_text can specify an anchor for a sprite (#3463) 2022-04-04 22:09:59 +00:00
bevy_transform bevy_transform: Use Changed in the query for much faster transform_propagate_system (#4180) 2022-03-29 03:05:01 +00:00
bevy_ui ParamSet for conflicting SystemParam:s (#2765) 2022-03-29 23:39:38 +00:00
bevy_utils use error scope to handle errors on shader module creation (#3675) 2022-03-29 22:39:14 +00:00
bevy_window Bump Bevy to 0.7.0-dev (#4230) 2022-03-19 03:54:15 +00:00
bevy_winit Enable drag-and-drop events on windows (#3772) 2022-04-04 20:09:54 +00:00