mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
015617a774
## New Features This adds the following to the new renderer: * **Shader Assets** * Shaders are assets again! Users no longer need to call `include_str!` for their shaders * Shader hot-reloading * **Shader Defs / Shader Preprocessing** * Shaders now support `# ifdef NAME`, `# ifndef NAME`, and `# endif` preprocessor directives * **Bevy RenderPipelineDescriptor and RenderPipelineCache** * Bevy now provides its own `RenderPipelineDescriptor` and the wgpu version is now exported as `RawRenderPipelineDescriptor`. This allows users to define pipelines with `Handle<Shader>` instead of needing to manually compile and reference `ShaderModules`, enables passing in shader defs to configure the shader preprocessor, makes hot reloading possible (because the descriptor can be owned and used to create new pipelines when a shader changes), and opens the doors to pipeline specialization. * The `RenderPipelineCache` now handles compiling and re-compiling Bevy RenderPipelineDescriptors. It has internal PipelineLayout and ShaderModule caches. Users receive a `CachedPipelineId`, which can be used to look up the actual `&RenderPipeline` during rendering. * **Pipeline Specialization** * This enables defining per-entity-configurable pipelines that specialize on arbitrary custom keys. In practice this will involve specializing based on things like MSAA values, Shader Defs, Bind Group existence, and Vertex Layouts. * Adds a `SpecializedPipeline` trait and `SpecializedPipelines<MyPipeline>` resource. This is a simple layer that generates Bevy RenderPipelineDescriptors based on a custom key defined for the pipeline. * Specialized pipelines are also hot-reloadable. * This was the result of experimentation with two different approaches: 1. **"generic immediate mode multi-key hash pipeline specialization"** * breaks up the pipeline into multiple "identities" (the core pipeline definition, shader defs, mesh layout, bind group layout). each of these identities has its own key. looking up / compiling a specific version of a pipeline requires composing all of these keys together * the benefit of this approach is that it works for all pipelines / the pipeline is fully identified by the keys. the multiple keys allow pre-hashing parts of the pipeline identity where possible (ex: pre compute the mesh identity for all meshes) * the downside is that any per-entity data that informs the values of these keys could require expensive re-hashes. computing each key for each sprite tanked bevymark performance (sprites don't actually need this level of specialization yet ... but things like pbr and future sprite scenarios might). * this is the approach rafx used last time i checked 2. **"custom key specialization"** * Pipelines by default are not specialized * Pipelines that need specialization implement a SpecializedPipeline trait with a custom key associated type * This allows specialization keys to encode exactly the amount of information required (instead of needing to be a combined hash of the entire pipeline). Generally this should fit in a small number of bytes. Per-entity specialization barely registers anymore on things like bevymark. It also makes things like "shader defs" way cheaper to hash because we can use context specific bitflags instead of strings. * Despite the extra trait, it actually generally makes pipeline definitions + lookups simpler: managing multiple keys (and making the appropriate calls to manage these keys) was way more complicated. * I opted for custom key specialization. It performs better generally and in my opinion is better UX. Fortunately the way this is implemented also allows for custom caches as this all builds on a common abstraction: the RenderPipelineCache. The built in custom key trait is just a simple / pre-defined way to interact with the cache ## Callouts * The SpecializedPipeline trait makes it easy to inherit pipeline configuration in custom pipelines. The changes to `custom_shader_pipelined` and the new `shader_defs_pipelined` example illustrate how much simpler it is to define custom pipelines based on the PbrPipeline. * The shader preprocessor is currently pretty naive (it just uses regexes to process each line). Ultimately we might want to build a more custom parser for more performance + better error handling, but for now I'm happy to optimize for "easy to implement and understand". ## Next Steps * Port compute pipelines to the new system * Add more preprocessor directives (else, elif, import) * More flexible vertex attribute specialization / enable cheaply specializing on specific mesh vertex layouts
563 lines
12 KiB
TOML
563 lines
12 KiB
TOML
[package]
|
|
name = "bevy"
|
|
version = "0.5.0"
|
|
edition = "2021"
|
|
authors = [
|
|
"Bevy Contributors <bevyengine@gmail.com>",
|
|
"Carter Anderson <mcanders1@gmail.com>",
|
|
]
|
|
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"]
|
|
members = ["crates/*", "pipelined/*", "examples/ios", "tools/ci"]
|
|
|
|
[features]
|
|
default = [
|
|
"bevy_audio",
|
|
"bevy_core_pipeline",
|
|
"bevy_dynamic_plugin",
|
|
"bevy_gilrs",
|
|
"bevy_gltf2",
|
|
"bevy_wgpu",
|
|
"bevy_sprite2",
|
|
"bevy_render2",
|
|
"bevy_pbr2",
|
|
"bevy_winit",
|
|
"render",
|
|
"png",
|
|
"hdr",
|
|
"mp3",
|
|
"x11",
|
|
]
|
|
|
|
# Force dynamic linking, which improves iterative compile times
|
|
dynamic = ["bevy_dylib"]
|
|
|
|
# Rendering support (Also needs the bevy_wgpu feature or a third-party rendering backend)
|
|
render = [
|
|
"bevy_internal/bevy_pbr",
|
|
"bevy_internal/bevy_render",
|
|
"bevy_internal/bevy_sprite",
|
|
"bevy_internal/bevy_text",
|
|
"bevy_internal/bevy_ui",
|
|
]
|
|
|
|
# Optional bevy crates
|
|
bevy_audio = ["bevy_internal/bevy_audio"]
|
|
bevy_dynamic_plugin = ["bevy_internal/bevy_dynamic_plugin"]
|
|
bevy_gilrs = ["bevy_internal/bevy_gilrs"]
|
|
bevy_gltf = ["bevy_internal/bevy_gltf"]
|
|
bevy_wgpu = ["bevy_internal/bevy_wgpu"]
|
|
bevy_winit = ["bevy_internal/bevy_winit"]
|
|
|
|
bevy_core_pipeline = ["bevy_internal/bevy_core_pipeline"]
|
|
bevy_render2 = ["bevy_internal/bevy_render2"]
|
|
bevy_sprite2 = ["bevy_internal/bevy_sprite2"]
|
|
bevy_pbr2 = ["bevy_internal/bevy_pbr2"]
|
|
bevy_gltf2 = ["bevy_internal/bevy_gltf2"]
|
|
|
|
trace_chrome = ["bevy_internal/trace_chrome"]
|
|
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"]
|
|
dds = ["bevy_internal/dds"]
|
|
tga = ["bevy_internal/tga"]
|
|
jpeg = ["bevy_internal/jpeg"]
|
|
bmp = ["bevy_internal/bmp"]
|
|
|
|
# Audio format support (MP3 is enabled by default)
|
|
flac = ["bevy_internal/flac"]
|
|
mp3 = ["bevy_internal/mp3"]
|
|
vorbis = ["bevy_internal/vorbis"]
|
|
wav = ["bevy_internal/wav"]
|
|
|
|
# WASM support for audio (Currently only works with flac, wav and vorbis. Not with mp3)
|
|
wasm_audio = ["bevy_internal/wasm_audio"]
|
|
|
|
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"]
|
|
|
|
[dependencies]
|
|
bevy_dylib = { path = "crates/bevy_dylib", version = "0.5.0", default-features = false, optional = true }
|
|
bevy_internal = { path = "crates/bevy_internal", version = "0.5.0", default-features = false }
|
|
|
|
[dev-dependencies]
|
|
anyhow = "1.0.4"
|
|
rand = "0.8.0"
|
|
ron = "0.6.2"
|
|
serde = { version = "1", features = ["derive"] }
|
|
# Needed to poll Task examples
|
|
futures-lite = "1.11.3"
|
|
crevice = {path = "crates/crevice"}
|
|
|
|
[[example]]
|
|
name = "hello_world"
|
|
path = "examples/hello_world.rs"
|
|
|
|
# 2D Rendering
|
|
[[example]]
|
|
name = "contributors"
|
|
path = "examples/2d/contributors.rs"
|
|
|
|
[[example]]
|
|
name = "mesh"
|
|
path = "examples/2d/mesh.rs"
|
|
|
|
[[example]]
|
|
name = "many_sprites"
|
|
path = "examples/2d/many_sprites.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"
|
|
|
|
[[example]]
|
|
name = "pipelined_texture_atlas"
|
|
path = "examples/2d/pipelined_texture_atlas.rs"
|
|
|
|
# 3D Rendering
|
|
[[example]]
|
|
name = "3d_scene"
|
|
path = "examples/3d/3d_scene.rs"
|
|
|
|
[[example]]
|
|
name = "3d_scene_pipelined"
|
|
path = "examples/3d/3d_scene_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "many_cubes_pipelined"
|
|
path = "examples/3d/many_cubes_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "cornell_box_pipelined"
|
|
path = "examples/3d/cornell_box_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "load_gltf"
|
|
path = "examples/3d/load_gltf.rs"
|
|
|
|
[[example]]
|
|
name = "load_gltf_pipelined"
|
|
path = "examples/3d/load_gltf_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "msaa"
|
|
path = "examples/3d/msaa.rs"
|
|
|
|
[[example]]
|
|
name = "orthographic"
|
|
path = "examples/3d/orthographic.rs"
|
|
|
|
[[example]]
|
|
name = "orthographic_pipelined"
|
|
path = "examples/3d/orthographic_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "parenting"
|
|
path = "examples/3d/parenting.rs"
|
|
|
|
[[example]]
|
|
name = "pbr"
|
|
path = "examples/3d/pbr.rs"
|
|
|
|
[[example]]
|
|
name = "pbr_pipelined"
|
|
path = "examples/3d/pbr_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "render_to_texture"
|
|
path = "examples/3d/render_to_texture.rs"
|
|
|
|
[[example]]
|
|
name = "shadow_biases_pipelined"
|
|
path = "examples/3d/shadow_biases_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "shadow_caster_receiver_pipelined"
|
|
path = "examples/3d/shadow_caster_receiver_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "spawner"
|
|
path = "examples/3d/spawner.rs"
|
|
|
|
[[example]]
|
|
name = "texture"
|
|
path = "examples/3d/texture.rs"
|
|
|
|
[[example]]
|
|
name = "texture_pipelined"
|
|
path = "examples/3d/texture_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "update_gltf_scene"
|
|
path = "examples/3d/update_gltf_scene.rs"
|
|
|
|
[[example]]
|
|
name = "wireframe"
|
|
path = "examples/3d/wireframe.rs"
|
|
|
|
[[example]]
|
|
name = "z_sort_debug"
|
|
path = "examples/3d/z_sort_debug.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"
|
|
|
|
# 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"
|
|
|
|
# Audio
|
|
[[example]]
|
|
name = "audio"
|
|
path = "examples/audio/audio.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 = "event"
|
|
path = "examples/ecs/event.rs"
|
|
|
|
[[example]]
|
|
name = "fixed_timestep"
|
|
path = "examples/ecs/fixed_timestep.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"
|
|
|
|
# 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 = "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 = "animate_shader"
|
|
path = "examples/shader/animate_shader.rs"
|
|
|
|
[[example]]
|
|
name = "array_texture"
|
|
path = "examples/shader/array_texture.rs"
|
|
|
|
[[example]]
|
|
name = "hot_shader_reloading"
|
|
path = "examples/shader/hot_shader_reloading.rs"
|
|
|
|
[[example]]
|
|
name = "mesh_custom_attribute"
|
|
path = "examples/shader/mesh_custom_attribute.rs"
|
|
|
|
[[example]]
|
|
name = "shader_custom_material"
|
|
path = "examples/shader/shader_custom_material.rs"
|
|
|
|
[[example]]
|
|
name = "shader_defs"
|
|
path = "examples/shader/shader_defs.rs"
|
|
|
|
[[example]]
|
|
name = "custom_shader_pipelined"
|
|
path = "examples/shader/custom_shader_pipelined.rs"
|
|
|
|
[[example]]
|
|
name = "shader_defs_pipelined"
|
|
path = "examples/shader/shader_defs_pipelined.rs"
|
|
|
|
# Tools
|
|
[[example]]
|
|
name = "bevymark"
|
|
path = "examples/tools/bevymark.rs"
|
|
|
|
[[example]]
|
|
name = "bevymark_pipelined"
|
|
path = "examples/tools/bevymark_pipelined.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 = "clear_color_pipelined"
|
|
path = "examples/window/clear_color_pipelined.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 = "window_settings"
|
|
path = "examples/window/window_settings.rs"
|
|
|
|
# WASM
|
|
[[example]]
|
|
name = "hello_wasm"
|
|
path = "examples/wasm/hello_wasm.rs"
|
|
required-features = []
|
|
|
|
[[example]]
|
|
name = "assets_wasm"
|
|
path = "examples/wasm/assets_wasm.rs"
|
|
required-features = ["bevy_winit"]
|
|
|
|
[[example]]
|
|
name = "headless_wasm"
|
|
path = "examples/wasm/headless_wasm.rs"
|
|
required-features = []
|
|
|
|
[[example]]
|
|
name = "winit_wasm"
|
|
path = "examples/wasm/winit_wasm.rs"
|
|
required-features = ["bevy_winit"]
|
|
|
|
# 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
|