2fcd8a3fb0
Based on #1910 This shrinks breakout from 310k to 293k. Most of the win is in outlining the drop glue of `App`. The other two commits save about 800 bytes total when using two empty systems and two simple resources. After this PR the full disassembly for ```rust fn main() { App::build().run(); } ``` is about as minimal as it gets, so pretty much all other costs scale linear in the amount of resources, systems, etc. ```asm 0000000000001100 <_ZN4core3ptr54drop_in_place$LT$bevy_app..app_builder..AppBuilder$GT$17h76850422c20653deE>: 1100: ff 25 52 21 00 00 jmpq *0x2152(%rip) # 3258 <_ZN60_$LT$bevy_app..app..App$u20$as$u20$core..ops..drop..Drop$GT$4drop17h67d177ae549d917bE@Base> 1106: cc int3 1107: cc int3 1108: cc int3 1109: cc int3 110a: cc int3 110b: cc int3 110c: cc int3 110d: cc int3 110e: cc int3 110f: cc int3 0000000000001110 <_ZN8breakout4main17h7cbe07b319de1042E>: 1110: 53 push %rbx 1111: 48 81 ec 00 03 00 00 sub $0x300,%rsp 1118: 48 8d 5c 24 08 lea 0x8(%rsp),%rbx 111d: 48 89 df mov %rbx,%rdi 1120: ff 15 3a 21 00 00 callq *0x213a(%rip) # 3260 <_ZN8bevy_app3app3App5build17h8b0ea6be9050d6ccE@Base> 1126: 48 89 df mov %rbx,%rdi 1129: ff 15 39 21 00 00 callq *0x2139(%rip) # 3268 <_ZN8bevy_app11app_builder10AppBuilder3run17hfc8cf50692acdbdeE@Base> 112f: 48 8d 7c 24 08 lea 0x8(%rsp),%rdi 1134: ff 15 1e 21 00 00 callq *0x211e(%rip) # 3258 <_ZN60_$LT$bevy_app..app..App$u20$as$u20$core..ops..drop..Drop$GT$4drop17h67d177ae549d917bE@Base> 113a: 48 81 c4 00 03 00 00 add $0x300,%rsp 1141: 5b pop %rbx 1142: c3 retq 1143: 48 89 c3 mov %rax,%rbx 1146: 48 8d 7c 24 08 lea 0x8(%rsp),%rdi 114b: e8 b0 ff ff ff callq 1100 <_ZN4core3ptr54drop_in_place$LT$bevy_app..app_builder..AppBuilder$GT$17h76850422c20653deE> 1150: 48 89 df mov %rbx,%rdi 1153: e8 18 01 00 00 callq 1270 <_Unwind_Resume@plt> 1158: 0f 0b ud2 115a: cc int3 115b: cc int3 115c: cc int3 115d: cc int3 115e: cc int3 115f: cc int3 0000000000001160 <main>: 1160: 48 83 ec 08 sub $0x8,%rsp 1164: 48 89 f1 mov %rsi,%rcx 1167: 48 63 d7 movslq %edi,%rdx 116a: 48 8d 05 9f ff ff ff lea -0x61(%rip),%rax # 1110 <_ZN8breakout4main17h7cbe07b319de1042E> 1171: 48 89 04 24 mov %rax,(%rsp) 1175: 48 8d 35 94 1e 00 00 lea 0x1e94(%rip),%rsi # 3010 <__init_array_end> 117c: 48 89 e7 mov %rsp,%rdi 117f: ff 15 eb 20 00 00 callq *0x20eb(%rip) # 3270 <_ZN3std2rt19lang_start_internal17he77194431b0ee4a2E@Base> 1185: 59 pop %rcx 1186: c3 retq 1187: cc int3 1188: cc int3 1189: cc int3 118a: cc int3 118b: cc int3 118c: cc int3 118d: cc int3 118e: cc int3 118f: cc int3 0000000000001190 <_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h83a5b8d55f23dff8E.llvm.909376793398482062>: 1190: 48 83 ec 08 sub $0x8,%rsp 1194: 48 8b 3f mov (%rdi),%rdi 1197: e8 54 ff ff ff callq 10f0 <_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h6e238af75680eb28E> 119c: 31 c0 xor %eax,%eax 119e: 59 pop %rcx 119f: c3 retq 00000000000011a0 <_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hb05d591cd29dea4fE.llvm.909376793398482062>: 11a0: 48 83 ec 08 sub $0x8,%rsp 11a4: 48 8b 3f mov (%rdi),%rdi 11a7: e8 44 ff ff ff callq 10f0 <_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h6e238af75680eb28E> 11ac: 31 c0 xor %eax,%eax 11ae: 59 pop %rcx 11af: c3 retq 00000000000011b0 <_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17he9aeeba375093b99E.llvm.909376793398482062>: 11b0: c3 retq 11b1: cc int3 11b2: cc int3 11b3: cc int3 11b4: cc int3 11b5: cc int3 11b6: cc int3 11b7: cc int3 11b8: cc int3 11b9: cc int3 11ba: cc int3 11bb: cc int3 11bc: cc int3 11bd: cc int3 11be: cc int3 11bf: cc int3 ``` |
||
---|---|---|
.cargo | ||
.github | ||
assets | ||
benches | ||
crates | ||
docs | ||
examples | ||
src | ||
tests | ||
tools | ||
.gitignore | ||
Cargo.toml | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CREDITS.md | ||
LICENSE | ||
README.md | ||
rustfmt.toml |
What is Bevy?
Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever!
WARNING
Bevy is still in the very early stages of development. APIs can and will change (now is the time to make suggestions!). Important features are missing. Documentation is sparse. Please don't build any serious projects in Bevy unless you are prepared to be broken by API changes constantly.
Design Goals
- Capable: Offer a complete 2D and 3D feature set
- Simple: Easy for newbies to pick up, but infinitely flexible for power users
- Data Focused: Data-oriented architecture using the Entity Component System paradigm
- Modular: Use only what you need. Replace what you don't like
- Fast: App logic should run quickly, and when possible, in parallel
- Productive: Changes should compile quickly ... waiting isn't fun
About
- Features: A quick overview of Bevy's features.
- Roadmap: The Bevy team's development plan.
- Introducing Bevy: A blog post covering some of Bevy's features
Docs
- The Bevy Book: Bevy's official documentation. The best place to start learning Bevy.
- Bevy Rust API Docs: Bevy's Rust API docs, which are automatically generated from the doc comments in this repo.
- Community-Made Learning Resources: Tutorials, documentation, and examples made by the Bevy community.
Community
Before contributing or participating in discussions with the community, you should familiarize yourself with our Code of Conduct and How to Contribute
- Discord: Bevy's official discord server.
- Reddit: Bevy's official subreddit.
- Stack Overflow: Questions tagged Bevy on Stack Overflow.
- Awesome Bevy: A collection of awesome Bevy projects.
Getting Started
We recommend checking out The Bevy Book for a full tutorial.
Follow the Setup guide to ensure your development environment is set up correctly. Once set up, you can quickly try out the examples by cloning this repo and running the following commands:
# Switch to the correct version (latest release, default is main development branch)
git checkout latest
# Runs the "breakout" example
cargo run --example breakout
Fast Compiles
Bevy can be built just fine using default configuration on stable Rust. However for really fast iterative compiles, you should enable the "fast compiles" setup by following the instructions here.
Focus Areas
Bevy has the following Focus Areas. We are currently focusing our development efforts in these areas, and they will receive priority for Bevy developers' time. If you would like to contribute to Bevy, you are heavily encouraged to join in on these efforts:
Editor-Ready UI
PBR / Clustered Forward Rendering
Scenes
Libraries Used
Bevy is only possible because of the hard work put into these foundational technologies:
- wgpu-rs: modern / low-level / cross-platform graphics library inspired by Vulkan
- glam-rs: a simple and fast 3D math library for games and graphics
- winit: cross-platform window creation and management in Rust
- spirv-reflect: Reflection API in rust for SPIR-V shader byte code
Bevy Cargo Features
This list outlines the different cargo features supported by Bevy. These allow you to customize the Bevy feature set for your use-case.
Third Party Plugins
Plugins are very welcome to extend Bevy's features. Guidelines are available to help integration and usage.
Thanks and Alternatives
Additionally, we would like to thank the Amethyst, macroquad, coffee, ggez, rg3d, and Piston projects for providing solid examples of game engine development in Rust. If you are looking for a Rust game engine, it is worth considering all of your options. Each engine has different design goals, and some will likely resonate with you more than others.