mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 05:03:47 +00:00
bdb063497d
# Objective Fix a performance regression in the "[bevy vs pixi](https://github.com/SUPERCILEX/bevy-vs-pixi)" benchmark. This benchmark seems to have a slightly pathological distribution of `z` values -- Sprites are spawned with a random `z` value with a child sprite at `f32::EPSILON` relative to the parent. See discussion here: https://github.com/bevyengine/bevy/issues/8100#issuecomment-1726978633 ## Solution Use `radsort` for sorting `Transparent2d` `PhaseItem`s. Use random `z` values in bevymark to stress the phase sort. Add an `--ordered-z` option to `bevymark` that uses the old behavior. ## Benchmarks mac m1 max | benchmark | fps before | fps after | diff | | - | - | - | - | | bevymark --waves 120 --per-wave 1000 --random-z | 42.16 | 47.06 | 🟩 +11.6% | | bevymark --waves 120 --per-wave 1000 | 52.50 | 52.29 | 🟥 -0.4% | | bevymark --waves 120 --per-wave 1000 --mode mesh2d --random-z | 9.64 | 10.24 | 🟩 +6.2% | | bevymark --waves 120 --per-wave 1000 --mode mesh2d | 15.83 | 15.59 | 🟥 -1.5% | | bevy-vs-pixi | 39.71 | 59.88 | 🟩 +50.1% | ## Discussion It's possible that `TransparentUi` should also change. We could probably use `slice::sort_unstable_by_key` with the current sort key though, as its items are always sorted and unique. I'd prefer to follow up later to look into that. Here's a survey of sorts used by other `PhaseItem`s #### slice::sort_by_key `Transparent2d`, `TransparentUi` #### radsort `Opaque3d`, `AlphaMask3d`, `Transparent3d`, `Opaque3dPrepass`, `AlphaMask3dPrepass`, `Shadow` I also tried `slice::sort_unstable_by_key` with a compound sort key including `Entity`, but it didn't seem as promising and I didn't test it as thoroughly. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Robert Swain <robert.swain@gmail.com>
34 lines
1.2 KiB
TOML
34 lines
1.2 KiB
TOML
[package]
|
|
name = "bevy_sprite"
|
|
version = "0.12.0-dev"
|
|
edition = "2021"
|
|
description = "Provides sprite functionality for Bevy Engine"
|
|
homepage = "https://bevyengine.org"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
license = "MIT OR Apache-2.0"
|
|
keywords = ["bevy"]
|
|
|
|
[dependencies]
|
|
# bevy
|
|
bevy_app = { path = "../bevy_app", version = "0.12.0-dev" }
|
|
bevy_asset = { path = "../bevy_asset", version = "0.12.0-dev" }
|
|
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.12.0-dev" }
|
|
bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" }
|
|
bevy_log = { path = "../bevy_log", version = "0.12.0-dev" }
|
|
bevy_math = { path = "../bevy_math", version = "0.12.0-dev" }
|
|
bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = [
|
|
"bevy",
|
|
] }
|
|
bevy_render = { path = "../bevy_render", version = "0.12.0-dev" }
|
|
bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" }
|
|
bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }
|
|
bevy_derive = { path = "../bevy_derive", version = "0.12.0-dev" }
|
|
|
|
# other
|
|
bytemuck = { version = "1.5", features = ["derive"] }
|
|
fixedbitset = "0.4"
|
|
guillotiere = "0.6.0"
|
|
thiserror = "1.0"
|
|
rectangle-pack = "0.4"
|
|
bitflags = "2.3"
|
|
radsort = "0.1"
|