bevy/Cargo.toml
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

621 lines
13 KiB
TOML

[package]
name = "bevy"
version = "0.7.0-dev"
edition = "2021"
categories = ["game-engines", "graphics", "gui", "rendering"]
description = "A refreshingly simple data-driven game engine and app framework"
exclude = ["assets/**/*", "tools/**/*", ".github/**/*", "crates/**/*"]
homepage = "https://bevyengine.org"
keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/bevyengine/bevy"
[workspace]
exclude = ["benches", "crates/bevy_ecs_compile_fail_tests"]
members = ["crates/*", "examples/ios", "tools/ci", "errors"]
[features]
default = [
"animation",
"bevy_audio",
"bevy_gilrs",
"bevy_winit",
"render",
"png",
"hdr",
"vorbis",
"x11",
"filesystem_watcher",
]
# Force dynamic linking, which improves iterative compile times
dynamic = ["bevy_dylib"]
# Rendering support
render = [
"bevy_internal/bevy_core_pipeline",
"bevy_internal/bevy_pbr",
"bevy_internal/bevy_gltf",
"bevy_internal/bevy_render",
"bevy_internal/bevy_sprite",
"bevy_internal/bevy_text",
"bevy_internal/bevy_ui",
]
# Optional bevy crates
bevy_animation = ["bevy_internal/bevy_animation"]
bevy_audio = ["bevy_internal/bevy_audio"]
bevy_core_pipeline = ["bevy_internal/bevy_core_pipeline"]
bevy_dynamic_plugin = ["bevy_internal/bevy_dynamic_plugin"]
bevy_gilrs = ["bevy_internal/bevy_gilrs"]
bevy_gltf = ["bevy_internal/bevy_gltf"]
bevy_pbr = ["bevy_internal/bevy_pbr"]
bevy_render = ["bevy_internal/bevy_render"]
bevy_sprite = ["bevy_internal/bevy_sprite"]
bevy_text = ["bevy_internal/bevy_text"]
bevy_ui = ["bevy_internal/bevy_ui"]
bevy_winit = ["bevy_internal/bevy_winit"]
# Tracing features
trace_chrome = ["trace", "bevy_internal/trace_chrome"]
trace_tracy = ["trace", "bevy_internal/trace_tracy"]
trace = ["bevy_internal/trace"]
wgpu_trace = ["bevy_internal/wgpu_trace"]
# Image format support for texture loading (PNG and HDR are enabled by default)
hdr = ["bevy_internal/hdr"]
png = ["bevy_internal/png"]
tga = ["bevy_internal/tga"]
jpeg = ["bevy_internal/jpeg"]
bmp = ["bevy_internal/bmp"]
basis-universal = ["bevy_internal/basis-universal"]
dds = ["bevy_internal/dds"]
ktx2 = ["bevy_internal/ktx2"]
# For ktx2 supercompression
zlib = ["bevy_internal/zlib"]
zstd = ["bevy_internal/zstd"]
# Audio format support (vorbis is enabled by default)
flac = ["bevy_internal/flac"]
mp3 = ["bevy_internal/mp3"]
vorbis = ["bevy_internal/vorbis"]
wav = ["bevy_internal/wav"]
# Enable watching file system for asset hot reload
filesystem_watcher = ["bevy_internal/filesystem_watcher"]
serialize = ["bevy_internal/serialize"]
# Display server protocol support (X11 is enabled by default)
wayland = ["bevy_internal/wayland"]
x11 = ["bevy_internal/x11"]
# Enable rendering of font glyphs using subpixel accuracy
subpixel_glyph_atlas = ["bevy_internal/subpixel_glyph_atlas"]
# Enable systems that allow for automated testing on CI
bevy_ci_testing = ["bevy_internal/bevy_ci_testing"]
# Enable the "debug asset server" for hot reloading internal assets
debug_asset_server = ["bevy_internal/debug_asset_server"]
# Enable animation support, and glTF animation loading
animation = ["bevy_internal/animation"]
[dependencies]
bevy_dylib = { path = "crates/bevy_dylib", version = "0.7.0-dev", default-features = false, optional = true }
bevy_internal = { path = "crates/bevy_internal", version = "0.7.0-dev", default-features = false }
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy_internal = { path = "crates/bevy_internal", version = "0.7.0-dev", default-features = false, features = [
"webgl",
] }
[dev-dependencies]
anyhow = "1.0.4"
rand = "0.8.0"
ron = "0.7.0"
serde = { version = "1", features = ["derive"] }
bytemuck = "1.7"
# Needed to poll Task examples
futures-lite = "1.11.3"
crossbeam-channel = "0.5.0"
[[example]]
name = "hello_world"
path = "examples/hello_world.rs"
# 2D Rendering
[[example]]
name = "contributors"
path = "examples/2d/contributors.rs"
[[example]]
name = "many_sprites"
path = "examples/2d/many_sprites.rs"
[[example]]
name = "move_sprite"
path = "examples/2d/move_sprite.rs"
[[example]]
name = "rotation"
path = "examples/2d/rotation.rs"
[[example]]
name = "mesh2d"
path = "examples/2d/mesh2d.rs"
[[example]]
name = "mesh2d_manual"
path = "examples/2d/mesh2d_manual.rs"
[[example]]
name = "rect"
path = "examples/2d/rect.rs"
[[example]]
name = "sprite"
path = "examples/2d/sprite.rs"
[[example]]
name = "sprite_flipping"
path = "examples/2d/sprite_flipping.rs"
[[example]]
name = "sprite_sheet"
path = "examples/2d/sprite_sheet.rs"
[[example]]
name = "text2d"
path = "examples/2d/text2d.rs"
[[example]]
name = "texture_atlas"
path = "examples/2d/texture_atlas.rs"
# 3D Rendering
[[example]]
name = "3d_scene"
path = "examples/3d/3d_scene.rs"
[[example]]
name = "lighting"
path = "examples/3d/lighting.rs"
[[example]]
name = "load_gltf"
path = "examples/3d/load_gltf.rs"
[[example]]
name = "many_cubes"
path = "examples/3d/many_cubes.rs"
[[example]]
name = "msaa"
path = "examples/3d/msaa.rs"
[[example]]
name = "orthographic"
path = "examples/3d/orthographic.rs"
[[example]]
name = "parenting"
path = "examples/3d/parenting.rs"
[[example]]
name = "pbr"
path = "examples/3d/pbr.rs"
[[example]]
name = "shadow_biases"
path = "examples/3d/shadow_biases.rs"
[[example]]
name = "shadow_caster_receiver"
path = "examples/3d/shadow_caster_receiver.rs"
[[example]]
name = "spherical_area_lights"
path = "examples/3d/spherical_area_lights.rs"
[[example]]
name = "texture"
path = "examples/3d/texture.rs"
[[example]]
name = "render_to_texture"
path = "examples/3d/render_to_texture.rs"
[[example]]
name = "update_gltf_scene"
path = "examples/3d/update_gltf_scene.rs"
[[example]]
name = "wireframe"
path = "examples/3d/wireframe.rs"
# Animation
[[example]]
name = "animated_fox"
path = "examples/animation/animated_fox.rs"
[[example]]
name = "custom_skinned_mesh"
path = "examples/animation/custom_skinned_mesh.rs"
[[example]]
name = "gltf_skinned_mesh"
path = "examples/animation/gltf_skinned_mesh.rs"
# Application
[[example]]
name = "custom_loop"
path = "examples/app/custom_loop.rs"
[[example]]
name = "drag_and_drop"
path = "examples/app/drag_and_drop.rs"
[[example]]
name = "empty"
path = "examples/app/empty.rs"
[[example]]
name = "empty_defaults"
path = "examples/app/empty_defaults.rs"
[[example]]
name = "headless"
path = "examples/app/headless.rs"
[[example]]
name = "logs"
path = "examples/app/logs.rs"
[[example]]
name = "plugin"
path = "examples/app/plugin.rs"
[[example]]
name = "plugin_group"
path = "examples/app/plugin_group.rs"
[[example]]
name = "return_after_run"
path = "examples/app/return_after_run.rs"
[[example]]
name = "thread_pool_resources"
path = "examples/app/thread_pool_resources.rs"
[[example]]
name = "headless_defaults"
path = "examples/app/headless_defaults.rs"
[[example]]
name = "without_winit"
path = "examples/app/without_winit.rs"
# Assets
[[example]]
name = "asset_loading"
path = "examples/asset/asset_loading.rs"
[[example]]
name = "custom_asset"
path = "examples/asset/custom_asset.rs"
[[example]]
name = "custom_asset_io"
path = "examples/asset/custom_asset_io.rs"
[[example]]
name = "hot_asset_reloading"
path = "examples/asset/hot_asset_reloading.rs"
# Async Tasks
[[example]]
name = "async_compute"
path = "examples/async_tasks/async_compute.rs"
[[example]]
name = "external_source_external_thread"
path = "examples/async_tasks/external_source_external_thread.rs"
# Audio
[[example]]
name = "audio"
path = "examples/audio/audio.rs"
[[example]]
name = "audio_control"
path = "examples/audio/audio_control.rs"
# Diagnostics
[[example]]
name = "log_diagnostics"
path = "examples/diagnostics/log_diagnostics.rs"
[[example]]
name = "custom_diagnostic"
path = "examples/diagnostics/custom_diagnostic.rs"
# ECS (Entity Component System)
[[example]]
name = "ecs_guide"
path = "examples/ecs/ecs_guide.rs"
[[example]]
name = "component_change_detection"
path = "examples/ecs/component_change_detection.rs"
[[example]]
name = "custom_query_param"
path = "examples/ecs/custom_query_param.rs"
[[example]]
name = "event"
path = "examples/ecs/event.rs"
[[example]]
name = "fixed_timestep"
path = "examples/ecs/fixed_timestep.rs"
[[example]]
name = "generic_system"
path = "examples/ecs/generic_system.rs"
[[example]]
name = "hierarchy"
path = "examples/ecs/hierarchy.rs"
[[example]]
name = "iter_combinations"
path = "examples/ecs/iter_combinations.rs"
[[example]]
name = "parallel_query"
path = "examples/ecs/parallel_query.rs"
[[example]]
name = "removal_detection"
path = "examples/ecs/removal_detection.rs"
[[example]]
name = "startup_system"
path = "examples/ecs/startup_system.rs"
[[example]]
name = "state"
path = "examples/ecs/state.rs"
[[example]]
name = "system_chaining"
path = "examples/ecs/system_chaining.rs"
[[example]]
name = "system_param"
path = "examples/ecs/system_param.rs"
[[example]]
name = "system_sets"
path = "examples/ecs/system_sets.rs"
[[example]]
name = "timers"
path = "examples/ecs/timers.rs"
# Games
[[example]]
name = "alien_cake_addict"
path = "examples/game/alien_cake_addict.rs"
[[example]]
name = "breakout"
path = "examples/game/breakout.rs"
[[example]]
name = "game_menu"
path = "examples/game/game_menu.rs"
# Input
[[example]]
name = "char_input_events"
path = "examples/input/char_input_events.rs"
[[example]]
name = "gamepad_input"
path = "examples/input/gamepad_input.rs"
[[example]]
name = "gamepad_input_events"
path = "examples/input/gamepad_input_events.rs"
[[example]]
name = "keyboard_input"
path = "examples/input/keyboard_input.rs"
[[example]]
name = "keyboard_modifiers"
path = "examples/input/keyboard_modifiers.rs"
[[example]]
name = "keyboard_input_events"
path = "examples/input/keyboard_input_events.rs"
[[example]]
name = "mouse_input"
path = "examples/input/mouse_input.rs"
[[example]]
name = "mouse_input_events"
path = "examples/input/mouse_input_events.rs"
[[example]]
name = "mouse_grab"
path = "examples/input/mouse_grab.rs"
[[example]]
name = "touch_input"
path = "examples/input/touch_input.rs"
[[example]]
name = "touch_input_events"
path = "examples/input/touch_input_events.rs"
# Reflection
[[example]]
name = "reflection"
path = "examples/reflection/reflection.rs"
[[example]]
name = "generic_reflection"
path = "examples/reflection/generic_reflection.rs"
[[example]]
name = "reflection_types"
path = "examples/reflection/reflection_types.rs"
[[example]]
name = "trait_reflection"
path = "examples/reflection/trait_reflection.rs"
# Scene
[[example]]
name = "scene"
path = "examples/scene/scene.rs"
# Shaders
[[example]]
name = "custom_vertex_attribute"
path = "examples/shader/custom_vertex_attribute.rs"
[[example]]
name = "shader_defs"
path = "examples/shader/shader_defs.rs"
[[example]]
name = "shader_material"
path = "examples/shader/shader_material.rs"
[[example]]
name = "shader_material_screenspace_texture"
path = "examples/shader/shader_material_screenspace_texture.rs"
[[example]]
name = "shader_material_glsl"
path = "examples/shader/shader_material_glsl.rs"
[[example]]
name = "shader_instancing"
path = "examples/shader/shader_instancing.rs"
[[example]]
name = "animate_shader"
path = "examples/shader/animate_shader.rs"
[[example]]
name = "compute_shader_game_of_life"
path = "examples/shader/compute_shader_game_of_life.rs"
# Tools
[[example]]
name = "bevymark"
path = "examples/tools/bevymark.rs"
[[example]]
name = "scene_viewer"
path = "examples/tools/scene_viewer.rs"
# Transforms
[[example]]
name = "global_vs_local_translation"
path = "examples/transforms/global_vs_local_translation.rs"
[[example]]
name = "3d_rotation"
path = "examples/transforms/3d_rotation.rs"
[[example]]
name = "scale"
path = "examples/transforms/scale.rs"
[[example]]
name = "transform"
path = "examples/transforms/transform.rs"
[[example]]
name = "translation"
path = "examples/transforms/translation.rs"
# UI (User Interface)
[[example]]
name = "button"
path = "examples/ui/button.rs"
[[example]]
name = "font_atlas_debug"
path = "examples/ui/font_atlas_debug.rs"
[[example]]
name = "text"
path = "examples/ui/text.rs"
[[example]]
name = "text_debug"
path = "examples/ui/text_debug.rs"
[[example]]
name = "ui"
path = "examples/ui/ui.rs"
# Window
[[example]]
name = "clear_color"
path = "examples/window/clear_color.rs"
[[example]]
name = "low_power"
path = "examples/window/low_power.rs"
[[example]]
name = "multiple_windows"
path = "examples/window/multiple_windows.rs"
[[example]]
name = "scale_factor_override"
path = "examples/window/scale_factor_override.rs"
[[example]]
name = "transparent_window"
path = "examples/window/transparent_window.rs"
[[example]]
name = "window_settings"
path = "examples/window/window_settings.rs"
# Android
[[example]]
crate-type = ["cdylib"]
name = "android"
path = "examples/android/android.rs"
[package.metadata.android]
apk_label = "Bevy Example"
assets = "assets"
res = "assets/android-res"
icon = "@mipmap/ic_launcher"
build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
min_sdk_version = 16
target_sdk_version = 29
# Stress Tests
[[example]]
name = "many_lights"
path = "examples/stress_tests/many_lights.rs"
[[example]]
name = "transform_hierarchy"
path = "examples/stress_tests/transform_hierarchy.rs"