From c747cc526bdc381e6eec817203aee8e3c2f8127a Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Sun, 10 Apr 2022 02:05:21 +0000 Subject: [PATCH] Group stress test examples (#4289) # Objective - Several examples are useful for qualitative tests of Bevy's performance - By contrast, these are less useful for learning material: they are often relatively complex and have large amounts of setup and are performance optimized. ## Solution - Move bevymark, many_sprites and many_cubes into the new stress_tests example folder - Move contributors into the games folder: unlike the remaining examples in the 2d folder, it is not focused on demonstrating a clear feature. --- Cargo.toml | 54 ++++++++++--------- examples/README.md | 47 ++++++++-------- examples/{game => games}/alien_cake_addict.rs | 0 examples/{game => games}/breakout.rs | 0 examples/{2d => games}/contributors.rs | 0 examples/{game => games}/game_menu.rs | 0 examples/{tools => stress_tests}/bevymark.rs | 0 examples/{3d => stress_tests}/many_cubes.rs | 0 examples/{2d => stress_tests}/many_sprites.rs | 0 9 files changed, 52 insertions(+), 49 deletions(-) rename examples/{game => games}/alien_cake_addict.rs (100%) rename examples/{game => games}/breakout.rs (100%) rename examples/{2d => games}/contributors.rs (100%) rename examples/{game => games}/game_menu.rs (100%) rename examples/{tools => stress_tests}/bevymark.rs (100%) rename examples/{3d => stress_tests}/many_cubes.rs (100%) rename examples/{2d => stress_tests}/many_sprites.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 74927f5531..adddf0273f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,14 +127,6 @@ 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" @@ -188,10 +180,6 @@ path = "examples/3d/lighting.rs" 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" @@ -414,15 +402,19 @@ path = "examples/ecs/timers.rs" # Games [[example]] name = "alien_cake_addict" -path = "examples/game/alien_cake_addict.rs" +path = "examples/games/alien_cake_addict.rs" [[example]] name = "breakout" -path = "examples/game/breakout.rs" +path = "examples/games/breakout.rs" + +[[example]] +name = "contributors" +path = "examples/games/contributors.rs" [[example]] name = "game_menu" -path = "examples/game/game_menu.rs" +path = "examples/games/game_menu.rs" # Input [[example]] @@ -524,10 +516,29 @@ path = "examples/shader/animate_shader.rs" name = "compute_shader_game_of_life" path = "examples/shader/compute_shader_game_of_life.rs" -# Tools +# Stress tests + [[example]] name = "bevymark" -path = "examples/tools/bevymark.rs" +path = "examples/stress_tests/bevymark.rs" + +[[example]] +name = "many_cubes" +path = "examples/stress_tests/many_cubes.rs" + +[[example]] +name = "many_lights" +path = "examples/stress_tests/many_lights.rs" + +[[example]] +name = "many_sprites" +path = "examples/stress_tests/many_sprites.rs" + +[[example]] +name = "transform_hierarchy" +path = "examples/stress_tests/transform_hierarchy.rs" + +# Tools [[example]] name = "scene_viewer" @@ -614,12 +625,3 @@ 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" diff --git a/examples/README.md b/examples/README.md index 8ad65c7b04..5bea69d41b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -51,6 +51,7 @@ git checkout v0.4.0 - [Reflection](#reflection) - [Scene](#scene) - [Shaders](#shaders) + - [Stress Tests](#stress-tests) - [Tests](#tests) - [Tools](#tools) - [Transforms](#transforms) @@ -67,7 +68,7 @@ git checkout v0.4.0 - [WASM](#wasm) - [Setup](#setup-2) - [Build & Run](#build--run-2) -- [Stress Tests](#stress-tests) + - [Loading Assets](#loading-assets) # The Bare Minimum @@ -85,8 +86,6 @@ Example | File | Description Example | File | Description --- | --- | --- -`contributors` | [`2d/contributors.rs`](./2d/contributors.rs) | Displays each contributor as a bouncy bevy-ball! -`many_sprites` | [`2d/many_sprites.rs`](./2d/many_sprites.rs) | Displays many sprites in a grid arragement! Used for performance testing. `move_sprite` | [`2d/move_sprite.rs`](./2d/move_sprite.rs) | Changes the transform of a sprite. `mesh2d` | [`2d/mesh2d.rs`](./2d/mesh2d.rs) | Renders a 2d mesh `mesh2d_manual` | [`2d/mesh2d_manual.rs`](./2d/mesh2d_manual.rs) | Renders a custom mesh "manually" with "mid-level" renderer apis. @@ -105,7 +104,6 @@ Example | File | Description `3d_scene` | [`3d/3d_scene.rs`](./3d/3d_scene.rs) | Simple 3D scene with basic shapes and lighting `lighting` | [`3d/lighting.rs`](./3d/lighting.rs) | Illustrates various lighting options in a simple scene `load_gltf` | [`3d/load_gltf.rs`](./3d/load_gltf.rs) | Loads and renders a gltf file as a scene -`many_cubes` | [`3d/many_cubes.rs`](./3d/many_cubes.rs) | Simple benchmark to test per-entity draw overhead `msaa` | [`3d/msaa.rs`](./3d/msaa.rs) | Configures MSAA (Multi-Sample Anti-Aliasing) for smoother edges `orthographic` | [`3d/orthographic.rs`](./3d/orthographic.rs) | Shows how to create a 3D orthographic view (for isometric-look games or CAD applications) `parenting` | [`3d/parenting.rs`](./3d/parenting.rs) | Demonstrates parent->child relationships and relative transformations @@ -199,9 +197,10 @@ Example | File | Description Example | File | Description --- | --- | --- -`alien_cake_addict` | [`game/alien_cake_addict.rs`](./game/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game -`breakout` | [`game/breakout.rs`](./game/breakout.rs) | An implementation of the classic game "Breakout" -`game_menu` | [`game/game_menu.rs`](./game/game_menu.rs) | A simple game menu +`alien_cake_addict` | [`games/alien_cake_addict.rs`](./games/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game +`breakout` | [`games/breakout.rs`](./games/breakout.rs) | An implementation of the classic game "Breakout" +`contributors` | [`games/contributors.rs`](./games/contributors.rs) | Displays each contributor as a bouncy bevy-ball! +`game_menu` | [`games/game_menu.rs`](./games/game_menu.rs) | A simple game menu ## Input @@ -247,6 +246,24 @@ Example | File | Description `compute_shader_game_of_life` | [`shader/compute_shader_game_of_life.rs`](./shader/compute_shader_game_of_life.rs) | A compute shader simulating Conway's Game of Life `shader_defs` | [`shader/shader_defs.rs`](./shader/shader_defs.rs) | Demonstrates creating a custom material that uses "shaders defs" (a tool to selectively toggle parts of a shader) +## Stress Tests + +These examples are used to test the performance and stability of various parts of the engine in an isolated way. + +Due to the focus on performance it's recommended to run the stress tests in release mode: + +```sh +cargo run --release --example +``` + +Example | File | Description +--- | --- | --- +`bevymark` | [`stress_tests/bevymark.rs`](./stress_tests/bevymark.rs) | A heavy sprite rendering workload to benchmark your system with Bevy +`many_cubes` | [`stress_tests/many_cubes.rs`](./stress_tests/many_cubes.rs) | Simple benchmark to test per-entity draw overhead +`many_lights` | [`stress_tests/many_lights.rs`](./stress_tests/many_lights.rs) | Simple benchmark to test rendering many point lights. Run with `WGPU_SETTINGS_PRIO=webgl2` to restrict to uniform buffers and max 256 lights. +`many_sprites` | [`stress_tests/many_sprites.rs`](./stress_tests/many_sprites.rs) | Displays many sprites in a grid arragement! Used for performance testing. +`transform_hierarchy.rs` | [`stress_tests/transform_hierarchy.rs`](./stress_tests/transform_hierarchy.rs) | Various test cases for hierarchy and transform propagation performance + ## Tests Example | File | Description @@ -257,7 +274,6 @@ Example | File | Description Example | File | Description --- | --- | --- -`bevymark` | [`tools/bevymark.rs`](./tools/bevymark.rs) | A heavy sprite rendering workload to benchmark your system with Bevy `scene_viewer` | [`tools/scene_viewer.rs`](./tools/scene_viewer.rs) | A simple way to view glTF models with Bevy. Just run `cargo run --release --example scene_viewer -- /path/to/model.gltf#Scene0`, replacing the path as appropriate. With no arguments it will load the FieldHelmet glTF model from the repository assets subdirectory. ## Transforms @@ -431,18 +447,3 @@ ruby -run -ehttpd examples/wasm To load assets, they need to be available in the folder examples/wasm/assets. Cloning this repository will set it up as a symlink on Linux and macOS, but you will need to manually move the assets on Windows. - -# Stress Tests - -These examples are used to test the performance and stability of various parts of the engine in an isolated way. - -Due to the focus on performance it's recommended to run the stress tests in release mode: - -```sh -cargo run --release --example -``` - -Example | File | Description ---- | --- | --- -`many_lights` | [`stress_tests/many_lights.rs`](./stress_tests/many_lights.rs) | Simple benchmark to test rendering many point lights. Run with `WGPU_SETTINGS_PRIO=webgl2` to restrict to uniform buffers and max 256 lights. -`transform_hierarchy.rs` | [`stress_tests/transform_hierarchy.rs`](./stress_tests/transform_hierarchy.rs) | Various test cases for hierarchy and transform propagation performance diff --git a/examples/game/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs similarity index 100% rename from examples/game/alien_cake_addict.rs rename to examples/games/alien_cake_addict.rs diff --git a/examples/game/breakout.rs b/examples/games/breakout.rs similarity index 100% rename from examples/game/breakout.rs rename to examples/games/breakout.rs diff --git a/examples/2d/contributors.rs b/examples/games/contributors.rs similarity index 100% rename from examples/2d/contributors.rs rename to examples/games/contributors.rs diff --git a/examples/game/game_menu.rs b/examples/games/game_menu.rs similarity index 100% rename from examples/game/game_menu.rs rename to examples/games/game_menu.rs diff --git a/examples/tools/bevymark.rs b/examples/stress_tests/bevymark.rs similarity index 100% rename from examples/tools/bevymark.rs rename to examples/stress_tests/bevymark.rs diff --git a/examples/3d/many_cubes.rs b/examples/stress_tests/many_cubes.rs similarity index 100% rename from examples/3d/many_cubes.rs rename to examples/stress_tests/many_cubes.rs diff --git a/examples/2d/many_sprites.rs b/examples/stress_tests/many_sprites.rs similarity index 100% rename from examples/2d/many_sprites.rs rename to examples/stress_tests/many_sprites.rs