# Objective
- Currently the `Commands` and `CommandQueue` have no performance testing.
- As `Commands` are quite expensive due to the `Box<dyn Command>` allocated for each command, there should be perf tests for implementations that attempt to improve the performance.
## Solution
- Add some benchmarking for `Commands` and `CommandQueue`.
This can be your 6 months post-christmas present.
# Objective
- Make `.system` optional
- yeet
- It's ugly
- Alternative title: `.system` is dead; long live `.system`
- **yeet**
## Solution
- Use a higher ranked lifetime, and some trait magic.
N.B. This PR does not actually remove any `.system`s, except in a couple of examples. Once this is merged we can do that piecemeal across crates, and decide on syntax for labels.
# Objective
Re-introduce `AHashExt` and respective `with_capacity()` implementations to give a more ergonomic way to set a `HashMap` / `HashSet` capacity.
As a note, this has also been discussed and agreed on issue #2115, which this PR addresses (leaving `new()` out of the `AHashExt` trait).
Fixes#2115.
## Solution
PR #1235 had removed the `AHashExt` trait and respective `with_capacity()`s implementations, leaving only the less ergonomic `HashMap::with_capacity_and_hasher(size, Default::default())` option available.
This re-introduces `AHashExt` and respective `with_capacity()` implementations to give a more ergonomic way to set a `HashMap` / `HashSet` capacity.
# Objective
Currently, you can add `Option<Res<T>` or `Option<ResMut<T>` as a SystemParam, if the Resource could potentially not exist, but this functionality doesn't exist for `NonSend` and `NonSendMut`
## Solution
Adds implementations to use `Option<NonSend<T>>` and Option<NonSendMut<T>> as SystemParams.
Updates the requirements on [wgpu](https://github.com/gfx-rs/wgpu) to permit the latest version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/gfx-rs/wgpu/blob/master/CHANGELOG.md">wgpu's changelog</a>.</em></p>
<blockquote>
<h1>Change Log</h1>
<h2>v0.9 (2021-06-18)</h2>
<ul>
<li>Updated:
<ul>
<li>naga to <code>v0.5</code>.</li>
</ul>
</li>
<li>Added:
<ul>
<li><code>Features::VERTEX_WRITABLE_STORAGE</code>.</li>
<li><code>Features::CLEAR_COMMANDS</code> which allows you to use <code>cmd_buf.clear_texture</code> and <code>cmd_buf.clear_buffer</code>.</li>
</ul>
</li>
<li>Changed:
<ul>
<li>Updated default storage buffer/image limit to <code>8</code> from <code>4</code>.</li>
</ul>
</li>
<li>Fixed:
<ul>
<li><code>Buffer::get_mapped_range</code> can now have a range of zero.</li>
<li>Fixed output spirv requiring the "kernal" capability.</li>
<li>Fixed segfault due to improper drop order.</li>
<li>Fixed incorrect dynamic stencil reference for Replace ops.</li>
<li>Fixed tracking of temporary resources.</li>
<li>Stopped unconditionally adding cubemap flags when the backend doesn't support cubemaps.</li>
</ul>
</li>
<li>Validation:
<ul>
<li>Ensure that if resources are viewed from the vertex stage, they are read only unless <code>Features::VERTEX_WRITABLE_STORAGE</code> is true.</li>
<li>Ensure storage class (i.e. storage vs uniform) is consistent between the shader and the pipeline layout.</li>
<li>Error when a color texture is used as a depth/stencil texture.</li>
<li>Check that pipeline output formats are logical</li>
<li>Added shader label to log messages if validation fails.</li>
</ul>
</li>
<li>Tracing:
<ul>
<li>Make renderpasses show up in the trace before they are run.</li>
</ul>
</li>
<li>Docs:
<ul>
<li>Fix typo in <code>PowerPreference::LowPower</code> description.</li>
</ul>
</li>
<li>Player:
<ul>
<li>Automatically start and stop RenderDoc captures.</li>
</ul>
</li>
<li>Examples:
<ul>
<li>Handle winit's unconditional exception.</li>
</ul>
</li>
<li>Internal:
<ul>
<li>Merged wgpu-rs and wgpu back into a single repository.</li>
<li>The tracker was split into two different stateful/stateless trackers to reduce overhead.</li>
<li>Added code coverage testing</li>
<li>CI can now test on lavapipe</li>
<li>Add missing extern "C" in wgpu-core on <code>wgpu_render_pass_execute_bundles</code></li>
<li>Fix incorrect function name <code>wgpu_render_pass_bundle_indexed_indirect</code> to <code>wgpu_render_bundle_draw_indexed_indirect</code>.</li>
</ul>
</li>
</ul>
<h2>wgpu-types-0.8.1 (2021-06-08)</h2>
<ul>
<li>fix dynamic stencil reference for Replace ops</li>
</ul>
<h2>v0.8.1 (2021-05-06)</h2>
<ul>
<li>fix SPIR-V generation from WGSL, which was broken due to "Kernel" capability</li>
<li>validate buffer storage classes</li>
</ul>
<h2>Unreleased</h2>
<ul>
<li>Added support for storage texture arrays for Vulkan and Metal.</li>
</ul>
<h2>v0.8 (2021-04-29)</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/gfx-rs/wgpu/commits">compare view</a></li>
</ul>
</details>
<br />
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
# Objective
- Make it so that `Time` can be cloned
- Makes it so I can clone the entire current `Time` and easily pass it to the user in [Rusty Engine](https://github.com/CleanCut/rusty_engine) instead of [doing this](8302dc3914/src/game.rs (L147-L150))
## Solution
- Derive the `Clone` trait on `Time`
# Objective
- CI jobs are starting to fail due to `clippy::bool-assert-comparison` and `clippy::single_component_path_imports` being triggered.
## Solution
- Fix all uses where `asset_eq!(<condition>, <bool>)` could be replace by `assert!`
- Move the `#[allow()]` for `single_component_path_imports` to `#![allow()]` at the start of the files.
# Objective
- Currently `AssetServer::get_handle_path` always returns `None` since the inner hash map is never written to.
## Solution
- Inside the `load_untracked` function, insert the asset path into the map.
This is similar to #1290 (thanks @TheRawMeatball)
# Objective
- The `DetectChanges` trait is used for types that detect change on mutable access (such as `ResMut`, `Mut`, etc...)
- `DetectChanges` was not implemented for `NonSendMut`
## Solution
- implement `NonSendMut` in terms of `DetectChanges`
# Objective
Currently, you can't call `is_added` or `is_changed` on a `NonSend` SystemParam, unless the Resource is a Component (implements `Send` and `Sync`).
This defeats the purpose of providing change detection for NonSend Resources.
While fixing this, I also noticed that `NonSend` does not have a bound at all on its struct.
## Solution
Change the bounds of `T` to always be `'static`.
# Objective
- MPL should not be an authorised license for all crates
## Solution
- Add exception for MPL for wgpu and hexasphere
- Remove security issue for a crate we don't depend on anymore
# Objective
Prevent future unnecessary mental effort spent figuring out why this trait exists and how to resolve the `TODO`.
## Solution
I happened to notice this trait being used when expanding the `#[derive(Reflect)]` macro in my own crate to figure out how it worked, and noticed that there was a `TODO` comment on it because it is only used in the derive macro and thus appeared to be unused.
I figured I should document my findings to prevent someone else from finding them out the hard way in the future 😆
Co-authored-by: Waridley <Waridley64@gmail.com>
# Objective
- Currently, when calling any of the `AssetServer`'s `load` functions, if the extension does not exist for the given path, the returned handle's load state is always `LoadState::NotLoaded`.
- This is due to the `load_async` function early returning without properly creating a `SourceInfo` for the requested asset.
- Fixes#2261
## Solution
- Add the `SourceInfo` prior to checking for valid extension loaders. And set the `LoadState` to `Failed` if the according loader does not exist.
When loading a gltf, if there is an error loading textures, it is completely ignored.
This can happen for example when loading a file with `jpg` textures without the `jpeg` Bevy feature enabled.
This PR adds `warn` logs for the few cases that can happen when loading a texture.
Other possible fix would be to break on first error and returning, making the asset loading failed
1) Sets `LoadState` properly on all failing cases in `AssetServer::load_async`
2) Adds more tests for sad and happy paths of asset loading
_Note_: this brings in the `tempfile` crate.
fixes#2169
Instead of having custom methods with reduced visibility, implement `From<image::DynamicImage> for Texture` and `TryFrom<Texture> for image::DynamicImage`
[RENDERED](https://github.com/NiklasEi/bevy/blob/ecs_readme/crates/bevy_ecs/README.md)
Since I am trying to learn more about Bevy ECS at the moment, I thought this issue is a perfect fit.
This PR adds a readme to the `bevy_ecs` crate containing a minimal running example of stand alone `bevy_ecs`. Unique features like customizable component storage, Resources or change detection are introduced. For each of these features the readme links to an example in a newly created examples directory inside the `bevy_esc` crate.
Resolves#2008
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
# Objective
- the PR labeler workflow will always add the `needs-traige` label to every pull request event
## Solution
- Limit this workflow to only be on the `opened` event
# Objective
- Currently only issues automatically have labels assigned to them on creation.
- The enables pull requests to have the same functionality and currently only adds the `needs-triage` label to all PRs.
## Solution
- Integrate `actions/labeler@v2` into the github workflows to automatically tag PRs.
- Add a `label-config.yml` file that specifies how PRs should be labeled.
Since `visible_entities_system` already checks `Visiblie::is_visible` for each entity and requires it to be `true`, there's no reason to verify visibility in `PassNode::prepare` which consumes entities produced by the system.
# Objective
- When creating an asset, the `update_asset_storage` function was unnecessarily creating an extraneous `Handle` to the created asset via calling `set`. This has some overhead as the `RefChange::Increment/Decrement` event was being sent.
- A similar exteraneous handle is also created in `load_async` when loading dependencies.
## Solution
- Have the implementation use `Assets::set_untracked` and `AssetServer::load_untracked` so no intermediate handle is created.
When implementing `AssetLoader ` you need to specify which File extensions are supported by that loader.
Currently, Bevy always says it supports extensions that actually require activating a Feature beforehand.
This PR adds cf attributes, so Bevy only tries to load those Extensions whose Features were activated.
This prevents Bevy from Panicking and reports such a warning:
```
Jun 02 23:05:57.139 WARN bevy_asset::asset_server: no `AssetLoader` found for the following extension: ogg
```
This also fixes the Bug, that the `png Feature had to be activated even if you wanted to load a different image format.
Fixes#640
## Problem
- The `Query` struct does not provide an easy way to check if it is empty.
- Specifically, users have to use `.iter().peekable()` or `.iter().next().is_none()` which is not very ergonomic.
- Fixes: #2270
## Solution
- Implement an `is_empty` function for queries to more easily check if the query is empty.
This enables `SystemParams` to be used outside of function systems. Anything can create and store `SystemState`, which enables efficient "param state cached" access to `SystemParams`.
It adds a `ReadOnlySystemParamFetch` trait, which enables safe `SystemState::get` calls without unique world access.
I renamed the old `SystemState` to `SystemMeta` to enable us to mirror the `QueryState` naming convention (but I'm happy to discuss alternative names if people have other ideas). I initially pitched this as `ParamState`, but given that it needs to include full system metadata, that doesn't feel like a particularly accurate name.
```rust
#[derive(Eq, PartialEq, Debug)]
struct A(usize);
#[derive(Eq, PartialEq, Debug)]
struct B(usize);
let mut world = World::default();
world.insert_resource(A(42));
world.spawn().insert(B(7));
// we get nice lifetime elision when declaring the type on the left hand side
let mut system_state: SystemState<(Res<A>, Query<&B>)> = SystemState::new(&mut world);
let (a, query) = system_state.get(&world);
assert_eq!(*a, A(42), "returned resource matches initial value");
assert_eq!(
*query.single().unwrap(),
B(7),
"returned component matches initial value"
);
// mutable system params require unique world access
let mut system_state: SystemState<(ResMut<A>, Query<&mut B>)> = SystemState::new(&mut world);
let (a, query) = system_state.get_mut(&mut world);
// static lifetimes are required when declaring inside of structs
struct SomeContainer {
state: SystemState<(Res<'static, A>, Res<'static, B>)>
}
// this can be shortened using type aliases, which will be useful for complex param tuples
type MyParams<'a> = (Res<'a, A>, Res<'a, B>);
struct SomeContainer {
state: SystemState<MyParams<'static>>
}
// It is the user's responsibility to call SystemState::apply(world) for parameters that queue up work
let mut system_state: SystemState<(Commands, Query<&B>)> = SystemState::new(&mut world);
{
let (mut commands, query) = system_state.get(&world);
commands.insert_resource(3.14);
}
system_state.apply(&mut world);
```
## Future Work
* Actually use SystemState inside FunctionSystem. This would be trivial, but it requires FunctionSystem to wrap SystemState in Option in its current form (which complicates system metadata lookup). I'd prefer to hold off until we adopt something like the later designs linked in #1364, which enable us to contruct Systems using a World reference (and also remove the need for `.system`).
* Consider a "scoped" approach to automatically call SystemState::apply when systems params are no longer being used (either a container type with a Drop impl, or a function that takes a closure for user logic operating on params).
When dropping the data, we originally only checked the size of an individual item instead of the size of the allocation. However with a capacity of 0, we attempt to deallocate a pointer which was not the result of allocation. That is, an item of `Layout { size_: 8, align_: 8 }` produces an array of `Layout { size_: 0, align_: 8 }` when `capacity = 0`.
Fixes#2294
## Objective
- Fixes: #2275
- `Assets` were being flagged as 'changed' each frame regardless of if the assets were actually being updated.
## Solution
- Only have `Assets` change detection be triggered when the collection is actually modified.
- This includes utilizing `ResMut` further down the stack instead of a `&mut Assets` directly.
Fixes#2079Closes#2288
Modifies README.md, and creates a new SVG file for the logo. When Github appearance is in Dark Dimmed, the blackbird and BEVY text of the logo should not blend into the black background.
Continuing the work on reducing the safety footguns in the code, I've removed one extra `UnsafeCell` in favour of safe `Cell` usage inisde `ComponentTicks`. That change led to discovery of misbehaving component insert logic, where data wasn't properly dropped when overwritten. Apart from that being fixed, some method names were changed to better convey the "initialize new allocation" and "replace existing allocation" semantic.
Depends on #2221, I will rebase this PR after the dependency is merged. For now, review just the last commit.
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
`ResMut`, `Mut` and `ReflectMut` all share very similar code for change detection.
This PR is a first pass at refactoring these implementation and removing a lot of the duplicated code.
Note, this introduces a new trait `ChangeDetectable`.
Please feel free to comment away and let me know what you think!
Fixes#2274
When calling `despawn_recursive`, the recursive loop doesn't need to remove the entity from the children list of its parent when the parent will also be deleted
Upside:
* Removes two entity lookup per entity being recursively despawned
Downside:
* The change detection on the `Children` component of a deleted entity in the despawned hierarchy will not be triggered
I'm still here :) will try to land the ios audio support in cpal soon and then we can land this.
This PR also adds in assets as a directory reference and avoids the "Xcode is optimizing and breaking my PNGs" issue that I had earlier on during iOS testing on Bevy.
Re-testing this now.
Updates the requirements on [rodio](https://github.com/RustAudio/rodio) to permit the latest version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/RustAudio/rodio/blob/master/CHANGELOG.md">rodio's changelog</a>.</em></p>
<blockquote>
<h1>Version 0.14.0 (2021-05-21)</h1>
<ul>
<li>Re-export <code>cpal</code> in full.</li>
<li>Replace panics when calling <code>OutputStream::try_default</code>, <code>OutputStream::try_from_device</code> with new
<code>StreamError</code> variants.</li>
<li><code>OutputStream::try_default</code> will now fallback to non-default output devices if an <code>OutputStream</code>
cannot be created from the default device.</li>
</ul>
<h1>Version 0.13.1 (2021-03-28)</h1>
<ul>
<li>Fix panic when no <code>pulseaudio-alsa</code> was installed.</li>
</ul>
<h1>Version 0.13.0 (2020-11-03)</h1>
<ul>
<li>Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0130-2020-10-28">0.13</a>.</li>
<li>Add Android support.</li>
</ul>
<h1>Version 0.12.0 (2020-10-05)</h1>
<ul>
<li>Breaking: Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0120-2020-07-09">0.12</a>.</li>
<li>Breaking: Rework API removing global "rodio audio processing" thread & adapting to the upstream cpal API changes.</li>
<li>Add new_X format specific methods to Decoder.</li>
<li>Fix resampler dependency on internal <code>Vec::capacity</code> behaviour.</li>
</ul>
<h1>Version 0.11.0 (2020-03-16)</h1>
<ul>
<li>Update <code>lewton</code> to <a href="https://github.com/RustAudio/lewton/blob/master/CHANGELOG.md#release-0100---january-30-2020">0.10</a>.</li>
<li>Breaking: Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0110-2019-12-11">0.11</a></li>
</ul>
<h1>Version 0.10.0 (2019-11-16)</h1>
<ul>
<li>Removal of nalgebra in favour of own code.</li>
<li>Fix a bug that switched channels when resuming after having paused.</li>
<li>Attempt all supported output formats if the default format fails in <code>Sink::new</code>.</li>
<li>Breaking: Update <code>cpal</code> to <a href="https://github.com/RustAudio/cpal/blob/master/CHANGELOG.md#version-0100-2019-07-05">0.10</a>.</li>
</ul>
<h1>Version 0.9.0 (2019-06-08)</h1>
<ul>
<li>Remove exclusive <code>&mut</code> borrow requirements in <code>Sink</code> & <code>SpatialSink</code> setters.</li>
<li>Use <code>nalgebra</code> instead of <code>cgmath</code> for <code>Spatial</code> source.</li>
</ul>
<h1>Version 0.8.1 (2018-09-18)</h1>
<ul>
<li>Update <code>lewton</code> dependency to <a href="https://github.com/RustAudio/lewton/blob/master/CHANGELOG.md#release-090---august-16-2018">0.9</a></li>
<li>Change license from <code>Apache-2.0</code> only to <code>Apache-2.0 OR MIT</code></li>
</ul>
<h1>Version 0.8.0 (2018-06-22)</h1>
<ul>
<li>Add mp3 decoding capabilities via <code>minimp3</code></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/RustAudio/rodio/commits">compare view</a></li>
</ul>
</details>
<br />
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
I've noticed that we are overusing interior mutability of the Table data, where in many cases we already own a unique reference to it. That prompted a slight refactor aiming to reduce number of safety constraints that must be manually upheld. Now the majority of those are just about avoiding bound checking, which is relatively easy to prove right.
Another aspect is reducing the complexity of Table struct. Notably, we don't ever use archetypes stored there, so this whole thing goes away. Capacity and grow amount were mostly superficial, as we are already using Vecs inside anyway, so I've got rid of those too. Now the overall table capacity is being driven by the internal entity Vec capacity. This has a side effect of automatically implementing exponential growth pattern for BitVecs reallocations inside Table, which to my measurements slightly improves performance in tests that are heavy on inserts. YMMV, but I hope that those tests were at least remotely correct.