Commit graph

1095 commits

Author SHA1 Message Date
Paweł Grabarz
93cc7219bc small ecs cleanup and remove_bundle drop bugfix (#2172)
- simplified code around archetype generations a little bit, as the special case value is not actually needed
- removed unnecessary UnsafeCell around pointer value that is never updated through shared references
- fixed and added a test for correct drop behaviour when removing sparse components through remove_bundle command
2021-05-18 19:25:57 +00:00
Nathan Ward
4563e69e06 Update glam (0.15.1) and hexasphere (3.4) (#2199)
This is a version of #2195 which addresses the `glam` breaking changes.
Also update hexasphere to ensure versions of `glam` are matching
2021-05-18 18:56:15 +00:00
Gregory Oakes
2fcac67712 Bump winit to 0.25 (#2186)
winit v0.25 includes support for propagating mouse motion events in the HTML canvas to the winit window.
2021-05-18 18:36:36 +00:00
Daniel Burrows
d4ffa3f490 Document what Config is and how to use it. (#2185)
While trying to figure out how to implement a `SystemParam`, I spent a
long time looking for a feature that would do exactly what `Config`
does.  I ignored it at first because all the examples I could find used
`()` and I couldn't see a way to modify it.

This is documented in other places, but `Config` is a logical place to
include some breadcrumbs.  I've added some text that gives a brief
overview of what `Config` is for, and links to the existing docs on
`FunctionSystem::config` for more details.

This would have saved me from embarrassing myself by filing https://github.com/bevyengine/bevy/issues/2178.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-18 00:10:18 +00:00
Federico Rinaldi
1f0988be87 Improve legibility of RunOnce::run_unsafe param (#2181)
During PR #2046 @cart suggested that the `(): ()` notation is less legible than `_input: ()`. The first notation still managed to slip in though. This PR applies the second writing.
2021-05-18 00:10:17 +00:00
Paweł Grabarz
a81fb7aa7e Add a method iter_combinations on query to iterate over combinations of query results (#1763)
Related to [discussion on discord](https://discord.com/channels/691052431525675048/742569353878437978/824731187724681289)

With const generics, it is now possible to write generic iterator over multiple entities at once.

This enables patterns of query iterations like

```rust
for [e1, e2, e3] in query.iter_combinations() {
   // do something with relation of all three entities
}
```

The compiler is able to infer the correct iterator for given size of array, so either of those work
```rust
for [e1, e2] in query.iter_combinations()  { ... }
for [e1, e2, e3] in query.iter_combinations()  { ... }
```

This feature can be very useful for systems like collision detection.

When you ask for permutations of size K of N entities:
- if K == N, you get one result of all entities
- if K < N, you get all possible subsets of N with size K, without repetition
- if K > N, the result set is empty (no permutation of size K exist)

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-17 23:33:47 +00:00
Andre Popovitch
cb98d31b27 Impl AsRef+AsMut for Res, ResMut, and Mut (#2189)
This can save users from having to type `&*X` all the time at the cost of some complexity in the type signature. For instance, this allows me to accommodate @jakobhellermann's suggestion in #1799 without requiring users to type `&*windows` 99% of the time.
2021-05-17 23:07:19 +00:00
Aevyrie
85b17294b9 Fix PBR regression for unlit materials (#2197)
Fixes the frag shader for unlit materials by correcting the scope of the `#ifndef` to include the light functions. Closes #2190, introduced in #2112.

Tested by changing materials in the the `3d_scene` example to be unlit. Unsure how to prevent future regressions without creating a test case scene that will catch these runtime panics.
2021-05-17 22:45:07 +00:00
Paweł Grabarz
189df30a83 use bytemuck crate instead of Byteable trait (#2183)
This gets rid of multiple unsafe blocks that we had to maintain ourselves, and instead depends on library that's commonly used and supported by the ecosystem. We also get support for glam types for free.

There is still some things to clear up with the `Bytes` trait, but that is a bit more substantial change and can be done separately. Also there are already separate efforts to use `crevice` crate, so I've just added that as a TODO.
2021-05-17 22:29:10 +00:00
Nathan Ward
071965996b revert supporting generics for deriving TypeUuid (#2204)
This reverts some of the changes made in #2044 as supporting generics for a `#[derive(TypeUuid)]` should not work as each generic instantiation would have the same uuid.

Stems from [this conversation](https://github.com/bevyengine/bevy/pull/2044#issuecomment-841743135)
2021-05-17 20:28:50 +00:00
Paweł Grabarz
3cf10e2ef2 prevent memory leak when dropping ParallelSystemContainer (#2176)
`ParallelSystemContainer`'s `system` pointer was extracted from box, but it was never deallocated. This change adds missing drop implementation that cleans up that memory.
2021-05-17 20:01:25 +00:00
bjorn3
1d652941ea Some cleanups (#2170)
The first commit monomorphizes `add_system_inner` which I think was intended to be monomorphized anyway. The second commit moves the type argument of `GraphNode` to an associated type.
2021-05-17 19:06:05 +00:00
dependabot[bot]
b8c98a9065 Update gltf requirement from 0.15.2 to 0.16.0 (#2196)
Updates the requirements on [gltf](https://github.com/gltf-rs/gltf) to permit the latest version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/gltf-rs/gltf/blob/master/CHANGELOG.md">gltf's changelog</a>.</em></p>
<blockquote>
<h2>[0.16.0] - 2021-05-13</h2>
<h3>Added</h3>
<ul>
<li>Support for the <code>KHR_texture_transform</code> extension.</li>
<li>Support for the <code>KHR_materials_transmission_ior extension</code>.</li>
</ul>
<h3>Changed</h3>
<ul>
<li><code>Material::alpha_cutoff</code> is now optional.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>URIs with embedded data failing to import when using <code>import_slice</code>.</li>
<li>Serialization of empty primitives object being skipped.</li>
</ul>
<h2>[0.15.2] - 2020-03-29</h2>
<h3>Changed</h3>
<ul>
<li>All features are now exposed in the <a href="http://docs.rs/gltf">online documentation</a>.</li>
<li>Primary iterators now implement <code>Iterator::nth</code> explicitly for improved performance.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Compiler warnings regarding deprecation of <code>std::error::Error::description</code>.</li>
</ul>
<h2>[0.15.1] - 2020-03-15</h2>
<h3>Added</h3>
<ul>
<li>New feature <code>guess_mime_type</code> which, as the name suggests, attempts to guess
the MIME type of an image if it doesn't exactly match the standard.</li>
</ul>
<h3>Changed</h3>
<ul>
<li><code>base64</code> updated to <code>0.11</code>.</li>
<li><code>byteorder</code> updated to <code>1.3</code>.</li>
<li><code>image</code> updated to <code>0.23.0</code>.</li>
<li><code>Format</code> has additional variants for 16-bit pixel formats.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Off-by-one error when reading whole files incurring a gratuitous reallocation.</li>
</ul>
<h2>[0.15.0] - 2020-01-18</h2>
<h3>Added</h3>
<ul>
<li>Support for the <code>KHR_materials_unlit</code> extension, which adds an <code>unlit</code> field</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/gltf-rs/gltf/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>
2021-05-17 18:44:04 +00:00
MsK`
73f4a9d18f Directional light (#2112)
This PR adds a `DirectionalLight` component to bevy_pbr.
2021-05-14 20:37:34 +00:00
Jonas Matser
d1f40148fd Allows a number of clippy lints and fixes 2 (#1999)
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-14 20:37:32 +00:00
François
739224f981 fix diagnostic length for asset count (#2165)
fixes #2156 
limit the diagnostic name to `MAX_DIAGNOSTIC_NAME_WIDTH` length
2021-05-14 19:31:36 +00:00
Federico Rinaldi
b4f80c29ee Add module level documentation for collide_aabb (#2152)
Related to #2105.

Doc comments are present on the `collide` function, but not on the module level.
2021-05-14 18:45:31 +00:00
Nathan Ward
883abbb27a [bevy_ecs] Cleanup SparseSetIndex impls (#2099)
Problem:
- SparseSetIndex trait implementations had a lot of duplicated code.

Solution:
- Utilize a macro to implement the trait for a generic type.
2021-05-07 00:46:54 +00:00
Jonas Matser
bfd15d2d4b Fixes incorrect PipelineCompiler::compile_pipeline() step_mode (#2126)
There's what might be considered a proper bug in `PipelineCompiler::compile_pipeline()`, where it overwrites the `step_mode` for the passed in `VertexBufferLayout` with `InputStepMode::Vertex`. Due to this some ugly workarounds are needed to do any kind of instancing.

In the somewhat longer term, `PipelineCompiler::compile_pipeline()` should probably also handle a `Vec<VertexBufferLayout>`, but that would be a (slightly) larger PR, rather than a bugfix. And I'd love to have this fix in sooner than we can deal with a bigger PR.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-07 00:28:35 +00:00
Nathan Ward
1690a9db97 [bevy_derive] Refactor modules for better error message. (#2059)
Problem:
- When using the 'as_crate' attribute, if 'as_crate' was empty, the only
  error you would get is 'integer underflow'.

Solution:
- Provide an explicit check for the 'as_crate' attribute's token stream
  to ensure the formatting is correct.

Note:
- Also reworked 'get_meta' by not making it call 'Manifest::find' twice.
2021-05-06 23:45:23 +00:00
Carter Anderson
ce6dda2d4e fix new "inconsistent struct constructor" lint (#2127)
Not super sold on the rationale behind this one, but we can revisit if it ever becomes painful.
2021-05-06 23:25:16 +00:00
Denis Laprise
7d0e98f34c Implement rotation for Text2d (#2084)
Fixes https://github.com/bevyengine/bevy/issues/2080

![CleanShot 2021-05-02 at 22 50 09](https://user-images.githubusercontent.com/11653/116844876-373ca780-ab99-11eb-8f61-8d93d929bff0.gif)


Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Denis Laprise <nside@users.noreply.github.com>
2021-05-06 03:55:55 +00:00
Felipe Jorge
41d9122740 Mesh vertex attributes for skinning and animation (#1831)
Required by #1429,

- Adds the `Ushort4` vertex attribute for joint indices
- `Mesh::ATTRIBUTE_JOINT_WEIGHT` and `Mesh::ATTRIBUTE_JOINT_INDEX` to import vertex attributes related to skinning from GLTF
- impl `Default` for `Mesh` a empty triangle mesh is created (needed by reflect)
- impl `Reflect` for `Mesh` all attributes are ignored (needed by the animation system)
2021-05-06 03:31:20 +00:00
Jakob Hellermann
cf8ef7660c load zeroed UVs as fallback in gltf loader (#1803)
fixes a lot of gltf loading failures (see https://github.com/bevyengine/bevy/issues/1802)
2021-05-06 03:08:53 +00:00
Mika
73ae6af6ef Add inline documentation to bevy code (#1404)
For review, first iteration of bevy code documentation.

I can continue submitting docs every now and then for relevant parts.

Some challenges I found:
* plugins example had to be commented out, as adding bevy_internal (where plugins reside) would pull in too many dependencies

Co-authored-by: Mika <1299457+blaind@users.noreply.github.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-05-06 02:26:54 +00:00
Patrik Buhring
4e524841a1 Bump glam and hexasphere versions (#2111)
Also fixes typo "feautres" in smallvec dependency.
2021-05-06 00:41:18 +00:00
TheRawMeatball
ce6889b9a8 Implement direct mutable dereferencing (#2100)
This PR adds a way to get the underlying mutable reference for it's full lifetime.

Context:
https://discord.com/channels/691052431525675048/692572690833473578/839255317287796796
2021-05-05 19:35:07 +00:00
TheRawMeatball
81279f3090 Move to smallvec v1.6 (#2074) 2021-05-05 19:14:39 +00:00
jak6jak
809877ade6 official 2D examples linked in rustdoc (#2081)
I linked to examples within the rustdoc for the 2d examples as per issue #1934
2021-05-05 18:45:49 +00:00
François
4f0499b91f Asset re-loading while it's being deleted (#2011)
fixes #824
fixes #1956 

* marked asset loading methods as `must_use`
* fixed asset re-loading while asset is still loading to work as comment is describing code
* introduced a 1 frame delay between unused asset marking and actual asset removal
2021-05-04 20:34:22 +00:00
dependabot[bot]
2390bee647 Update rectangle-pack requirement from 0.3 to 0.4 (#2086)
Updates the requirements on [rectangle-pack](https://github.com/chinedufn/rectangle-pack) to permit the latest version.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/chinedufn/rectangle-pack/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>
2021-05-03 21:20:35 +00:00
François
afaf4ad3da update for wgpu 0.8 (#1959)
Changes to get Bevy to compile with wgpu master.

With this, on a Mac:
* 2d examples look fine
* ~~3d examples crash with an error specific to metal about a compilation error~~
* 3d examples work fine after enabling feature `wgpu/cross`


Feature `wgpu/cross` seems to be needed only on some platforms, not sure how to know which. It was introduced in https://github.com/gfx-rs/wgpu-rs/pull/826
2021-05-02 20:45:25 +00:00
Nikita Zdanovitch
5390be0871 Replace derive(Default) with impl in AssetCountDiagnosticsPlugin (#2077)
Hi, ran into this problem with the derive macro.

It fails trying to derive the Default trait when the asset does not implements it also. This is unnecessary because this plugin does not need that from the asset type, just needs to create the phantom data.
2021-05-02 20:00:55 +00:00
bjorn3
3af3334cfe Various cleanups (#2046)
This includes a few safety improvements and a variety of other cleanups. See the individual commits.
2021-05-01 20:07:06 +00:00
Nathan Ward
b07db8462f Bevy derives handling generics in impl definitions. (#2044)
Fixes #2037 (and then some)

Problem:
- `TypeUuid`, `RenderResource`, and `Bytes` derive macros did not properly handle generic structs. 

Solution:
- Rework the derive macro implementations to handle the generics.
2021-05-01 02:57:20 +00:00
forbjok
1e0c950004 Implement Debug for Res and ResMut (#2050)
This commit adds blanket implementations of Debug for Res and ResMut, as discussed in https://github.com/bevyengine/bevy/issues/2048.
2021-05-01 02:32:32 +00:00
François
c9b33e15f8 gltf: load textures asynchronously using io task pool (#1767)
While trying to reduce load time of gltf files, I noticed most of the loading time is spent transforming bytes into an actual texture.

This PR add asynchronously loading for them using io task pool in gltf loader. It reduces loading of a large glb file from 15 seconds to 6~8 on my laptop

To allow asynchronous tasks in an asset loader, I added a reference to the task pool from the asset server in the load context, which I can use later in the loader.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-30 20:12:50 +00:00
François
07e772814f add a span for frames (#2053)
add a span for frames
2021-04-30 02:08:49 +00:00
TheRawMeatball
dbf519c1d7 Fix unsoundness in Query::for_each_mut (#2045) 2021-04-29 18:12:07 +00:00
speak
85ab55a05b Adds an alias mouse position -> cursor position (#2038)
This alias is to aid people finding the cursor_position function, as the mouse
pressed / moved functionality and naming likely primes people for thinking
of "mouse" before "cursor" when searching the api documentation.
2021-04-28 21:26:47 +00:00
CGMossa
86ad5bf420 Adding WorldQuery for WithBundle (#2024)
In response to #2023, here is a draft for a PR. 

Fixes #2023

I've added an example to show how to use `WithBundle`, and also to test it out. 

Right now there is a bug: If a bundle and a query are "the same", then it doesn't filter out
what it needs to filter out. 

Example: 

```
Print component initated from bundle.
[examples/ecs/query_bundle.rs:57] x = Dummy( <========= This should not get printed
    111,
)
[examples/ecs/query_bundle.rs:57] x = Dummy(
    222,
)
Show all components
[examples/ecs/query_bundle.rs:50] x = Dummy(
    111,
)
[examples/ecs/query_bundle.rs:50] x = Dummy(
    222,
)
```

However, it behaves the right way, if I add one more component to the bundle,
so the query and the bundle doesn't look the same:

```
Print component initated from bundle.
[examples/ecs/query_bundle.rs:57] x = Dummy(
    222,
)
Show all components
[examples/ecs/query_bundle.rs:50] x = Dummy(
    111,
)
[examples/ecs/query_bundle.rs:50] x = Dummy(
    222,
)
```

I hope this helps. I'm definitely up for tinkering with this, and adding anything that I'm asked to add
or change. 





Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-04-28 21:03:10 +00:00
deprilula28
cdb9097ed4 Make Command's public? (#2034)
I'm using Bevy ECS in a project of mine and I'd like to do world changes asynchronously. 

The current public API for creating entities, `Commands` , has a lifetime that restricts it from being sent across threads. `CommandQueue` on the other hand is a Vec of commands that can be later ran on a World. 

So far this is all public, but the commands themselves are private API. I know the intented use is with `Commands`, but that's not possible for my use case as I mentioned, and so I simply copied over the code for the commands I need and it works. Obviously, this isn't a nice solution, so I'd like to ask if it's not out of scope to make the commands public?
2021-04-28 20:08:33 +00:00
TehPers
cf40f4ab08 Fix mesh with no vertex attributes causing panic (#2036)
If a mesh without any vertex attributes is rendered (for example, one that only has indices), bevy will crash since the mesh still creates a vertex buffer even though it's empty. Later code assumes that there is vertex data, causing an index-out-of-bounds panic. This PR fixes the issue by adding a check that there is any vertex data before creating a vertex buffer.

I ran into this issue while rendering a tilemap without any vertex attributes (only indices).

Stack trace:
```
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', C:\Dev\Games\bevy\crates\bevy_render\src\render_graph\nodes\pass_node.rs:346:9
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/bb491ed23937aef876622e4beb68ae95938b3bf9\/library\std\src\panicking.rs:493
   1: core::panicking::panic_fmt
             at /rustc/bb491ed23937aef876622e4beb68ae95938b3bf9\/library\core\src\panicking.rs:92
   2: core::panicking::panic_bounds_check
             at /rustc/bb491ed23937aef876622e4beb68ae95938b3bf9\/library\core\src\panicking.rs:69
   3: core::slice::index::{{impl}}::index<core::option::Option<tuple<bevy_render::renderer::render_resource::buffer::BufferId, u64>>>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\slice\index.rs:184
   4: core::slice::index::{{impl}}::index<core::option::Option<tuple<bevy_render::renderer::render_resource::buffer::BufferId, u64>>,usize>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\slice\index.rs:15
   5: alloc::vec::{{impl}}::index<core::option::Option<tuple<bevy_render::renderer::render_resource::buffer::BufferId, u64>>,usize,alloc::alloc::Global>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\vec\mod.rs:2386
   6: bevy_render::render_graph::nodes::pass_node::DrawState::is_vertex_buffer_set
             at C:\Dev\Games\bevy\crates\bevy_render\src\render_graph\nodes\pass_node.rs:346
   7: bevy_render::render_graph::nodes::pass_node::{{impl}}::update::{{closure}}<bevy_render::render_graph::base::MainPass*>
             at C:\Dev\Games\bevy\crates\bevy_render\src\render_graph\nodes\pass_node.rs:285
   8: bevy_wgpu::renderer::wgpu_render_context::{{impl}}::begin_pass
             at C:\Dev\Games\bevy\crates\bevy_wgpu\src\renderer\wgpu_render_context.rs:196
   9: bevy_render::render_graph::nodes::pass_node::{{impl}}::update<bevy_render::render_graph::base::MainPass*>
             at C:\Dev\Games\bevy\crates\bevy_render\src\render_graph\nodes\pass_node.rs:244
  10: bevy_wgpu::renderer::wgpu_render_graph_executor::WgpuRenderGraphExecutor::execute
             at C:\Dev\Games\bevy\crates\bevy_wgpu\src\renderer\wgpu_render_graph_executor.rs:75
  11: bevy_wgpu::wgpu_renderer::{{impl}}::run_graph::{{closure}}
             at C:\Dev\Games\bevy\crates\bevy_wgpu\src\wgpu_renderer.rs:115
  12: bevy_ecs::world::World::resource_scope<bevy_render::render_graph::graph::RenderGraph,tuple<>,closure-0>
             at C:\Dev\Games\bevy\crates\bevy_ecs\src\world\mod.rs:715
  13: bevy_wgpu::wgpu_renderer::WgpuRenderer::run_graph
             at C:\Dev\Games\bevy\crates\bevy_wgpu\src\wgpu_renderer.rs:104
  14: bevy_wgpu::wgpu_renderer::WgpuRenderer::update
             at C:\Dev\Games\bevy\crates\bevy_wgpu\src\wgpu_renderer.rs:121
  15: bevy_wgpu::get_wgpu_render_system::{{closure}}
             at C:\Dev\Games\bevy\crates\bevy_wgpu\src\lib.rs:112
  16: alloc::boxed::{{impl}}::call_mut<tuple<mut bevy_ecs::world::World*>,FnMut<tuple<mut bevy_ecs::world::World*>>,alloc::alloc::Global>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:1553
  17: bevy_ecs::system::exclusive_system::{{impl}}::run
             at C:\Dev\Games\bevy\crates\bevy_ecs\src\system\exclusive_system.rs:41
  18: bevy_ecs::schedule::stage::{{impl}}::run
             at C:\Dev\Games\bevy\crates\bevy_ecs\src\schedule\stage.rs:812
  19: bevy_ecs::schedule::Schedule::run_once
             at C:\Dev\Games\bevy\crates\bevy_ecs\src\schedule\mod.rs:201
  20: bevy_ecs::schedule::{{impl}}::run
             at C:\Dev\Games\bevy\crates\bevy_ecs\src\schedule\mod.rs:219
  21: bevy_app::app::App::update
             at C:\Dev\Games\bevy\crates\bevy_app\src\app.rs:58
  22: bevy_winit::winit_runner_with::{{closure}}
             at C:\Dev\Games\bevy\crates\bevy_winit\src\lib.rs:485
  23: winit::platform_impl::platform::event_loop::{{impl}}::run_return::{{closure}}<tuple<>,closure-1>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:203
  24: alloc::boxed::{{impl}}::call_mut<tuple<winit::event::Event<tuple<>>, mut winit::event_loop::ControlFlow*>,FnMut<tuple<winit::event::Event<tuple<>>, mut winit::event_loop::ControlFlow*>>,alloc::alloc::Global>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:1553
  25: winit::platform_impl::platform::event_loop:🏃:{{impl}}::call_event_handler::{{closure}}<tuple<>>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:245
  26: std::panic::{{impl}}::call_once<tuple<>,closure-0>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:344
  27: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,tuple<>>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:379
  28: hashbrown::set::HashSet<mut winapi::shared::windef::HWND__*, std::collections:#️⃣:map::RandomState, alloc::alloc::Global>::iter<mut winapi::shared::windef::HWND__*,std::collections:#️⃣:map::RandomState,alloc::alloc::Global>
  29: std::panicking::try<tuple<>,std::panic::AssertUnwindSafe<closure-0>>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:343
  30: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,tuple<>>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:431
  31: winit::platform_impl::platform::event_loop:🏃:EventLoopRunner<tuple<>>::catch_unwind<tuple<>,tuple<>,closure-0>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:152
  32: winit::platform_impl::platform::event_loop:🏃:EventLoopRunner<tuple<>>::call_event_handler<tuple<>>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:239
  33: winit::platform_impl::platform::event_loop:🏃:EventLoopRunner<tuple<>>::move_state_to<tuple<>>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:341
  34: winit::platform_impl::platform::event_loop:🏃:EventLoopRunner<tuple<>>::main_events_cleared<tuple<>>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:227
  35: winit::platform_impl::platform::event_loop::flush_paint_messages<tuple<>>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:676
  36: winit::platform_impl::platform::event_loop::thread_event_target_callback::{{closure}}<tuple<>>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:1967
  37: std::panic::{{impl}}::call_once<isize,closure-0>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:344
  38: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,isize>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:379
  39: hashbrown::set::HashSet<mut winapi::shared::windef::HWND__*, std::collections:#️⃣:map::RandomState, alloc::alloc::Global>::iter<mut winapi::shared::windef::HWND__*,std::collections:#️⃣:map::RandomState,alloc::alloc::Global>
  40: std::panicking::try<isize,std::panic::AssertUnwindSafe<closure-0>>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:343
  41: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,isize>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:431
  42: winit::platform_impl::platform::event_loop:🏃:EventLoopRunner<tuple<>>::catch_unwind<tuple<>,isize,closure-0>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop\runner.rs:152
  43: winit::platform_impl::platform::event_loop::thread_event_target_callback<tuple<>>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:2151
  44: DefSubclassProc
  45: DefSubclassProc
  46: CallWindowProcW
  47: DispatchMessageW
  48: SendMessageTimeoutW
  49: KiUserCallbackDispatcher
  50: NtUserDispatchMessage
  51: DispatchMessageW
  52: winit::platform_impl::platform::event_loop::EventLoop<tuple<>>::run_return<tuple<>,closure-1>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:218
  53: winit::platform_impl::platform::event_loop::EventLoop<tuple<>>::run<tuple<>,closure-1>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\platform_impl\windows\event_loop.rs:188
  54: winit::event_loop::EventLoop<tuple<>>::run<tuple<>,closure-1>
             at C:\Users\tehpe\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.24.0\src\event_loop.rs:154
  55: bevy_winit::run<closure-1>
             at C:\Dev\Games\bevy\crates\bevy_winit\src\lib.rs:171
  56: bevy_winit::winit_runner_with
             at C:\Dev\Games\bevy\crates\bevy_winit\src\lib.rs:493
  57: bevy_winit::winit_runner
             at C:\Dev\Games\bevy\crates\bevy_winit\src\lib.rs:211
  58: core::ops::function::Fn::call<fn(bevy_app::app::App),tuple<bevy_app::app::App>>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:70
  59: alloc::boxed::{{impl}}::call<tuple<bevy_app::app::App>,Fn<tuple<bevy_app::app::App>>,alloc::alloc::Global>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\boxed.rs:1560
  60: bevy_app::app::App::run
             at C:\Dev\Games\bevy\crates\bevy_app\src\app.rs:68
  61: bevy_app::app_builder::AppBuilder::run
             at C:\Dev\Games\bevy\crates\bevy_app\src\app_builder.rs:54
  62: game_main::main
             at .\crates\game_main\src\main.rs:23
  63: core::ops::function::FnOnce::call_once<fn(),tuple<>>
             at C:\Users\tehpe\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Apr 27 21:51:01.026 ERROR gpu_descriptor::allocator: `DescriptorAllocator` is dropped while some descriptor sets were not deallocated
error: process didn't exit successfully: `target/cargo\debug\game_main.exe` (exit code: 0xc000041d)
```
2021-04-28 19:04:01 +00:00
bjorn3
2fcd8a3fb0 Monomorphize various things (#1914)
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
```
2021-04-28 19:04:00 +00:00
François
6f7da027c7 Automatic System Spans (#2033)
As mentioned in https://github.com/bevyengine/bevy/issues/2025#issuecomment-827867660, systems used to have spans by default.

* add spans by default for every system executed
* create folder if missing for feature `wgpu_trace`
2021-04-28 18:41:16 +00:00
Lucas Rocha
b1ed28e17e Hide re-exported docs (#1985)
Solves #1957 

Co-authored-by: caelumLaron <caelum.laron@gmail.com>
2021-04-27 18:29:33 +00:00
TheRawMeatball
c32c37d737 Detect camera projection changes (#2015) 2021-04-27 01:11:04 +00:00
François
fcf8fafa71 fix dead intra links in doc on Input and Reflect (#2007)
fix a few dead links

* Links in `Input` missed a refactor
* `Reflect::downcast` can't use the intra doc link format, as it's not a link to a trait function, but to a function implemented on `dyn Reflect`

noticed in https://github.com/bevyengine/bevy/pull/1781#discussion_r619777879
2021-04-25 17:24:09 +00:00
François
0a8576b710 support assets of any size (#1997)
Fixes #1892 

The following code is a cut down version of the issue, and crashes the same way:
```rust
enum AssetLifecycleEvent <T> {
    Create(T),
    Free
}

fn main() {
    let (sender, _receiver) = crossbeam_channel::unbounded();
    sender.send(AssetLifecycleEvent::<[u32; 32000]>::Free).unwrap();
}
```

- We're creating a channel that need to be able to hold `AssetLifecycleEvent::Create(T)` which has the size of our type `T`
- The two variants of the enums have a very different size

By keeping `T` boxed while sending through the channel, it doesn't crash
2021-04-24 18:14:04 +00:00
TehPers
d653ad2bda Updated docs for ShouldRun (#1987)
The documentation for `ShouldRun` doesn't completely explain what each of the variants you can return does. For instance, it isn't very clear that looping systems aren't executed again until after all the systems in a stage have had a chance to run.

This PR adds to the documentation for `ShouldRun`, and hopefully clarifies what is happening during a stage's execution when run criteria are checked and systems are being executed.
2021-04-23 18:38:18 +00:00