[Merged by Bors] - Fix FilteredAccessSet get_conflicts inconsistency#5105
[Merged by Bors] - Fix FilteredAccessSet get_conflicts inconsistency#5105nicopap wants to merge 3 commits intobevyengine:mainfrom
Conversation
0bdf8e4 to
04758b8
Compare
04758b8 to
3b71c03
Compare
alice-i-cecile
left a comment
There was a problem hiding this comment.
This is signifcantly clearer, and the logic changes make sense to me.
I particularly like the improved Debug methods.
3b71c03 to
ecb159a
Compare
|
I've hesitated between forcing to add filters and special-handling the case where there are no filters and a conflict in |
I would optimize for clarity and correctness over initialization speed here, due to the critical and complex nature of this code. I agree with your choice. |
|
bors try |
tryTimed out. |
|
@nicopap is this building for you locally? It's timing out on CI. |
|
No idea. Builds on my machine |
ecb159a to
c2072e0
Compare
|
Ok, now the tests are timing out on my own machine. |
|
Oh my god, I think this is a deadlock in the Edit: Turns out I'm an idiot! The change to |
c29ca7e to
61ce88e
Compare
|
Why can't we change |
Also I removed |
61ce88e to
84ecf53
Compare
|
bors try |
joseph-gio
left a comment
There was a problem hiding this comment.
I agree with the motivation for this PR, encapsulating the access invariants is very valuable. The implementation looks good and the doc changes are excellent.
| /// ```text | ||
| /// read_and_writes: [ ComponentId(5), ComponentId(7) ] | ||
| /// ``` | ||
| struct FormattedBitSet<'a, T: SparseSetIndex> { |
There was a problem hiding this comment.
This debug formatting is so much nicer.
The `FilteredAccessSet::get_conflicts` methods didn't work properly with
`Res` and `ResMut` parameters. Because those added their access by using
the `combined_access_mut` method and directly modifying the global
access state of the FilteredAccessSet. This caused an inconsistency,
because get_conflicts assumes that ALL added access have a corresponding
`FilteredAccess` added to the `filtered_accesses` field.
In practice, that means that SystemParam that adds their access through
the `Access` returned by `combined_access_mut` and the ones that add
their access using the `add` method lived in two different universes. As
a result, they could never be mutually exclusive.
This commit fixes it by removing the `combined_access_mut` method. This
ensures that the `combined_access` field of FilteredAccessSet is always
updated consistently with the addition of a filter. When checking for
filtered access, it is now possible to account for `Res` and `ResMut`
invalid access. This is currently not needed, but might be in the
future.
We add the `add_unfiltered_{read,write}` methods to replace previous
usages of `combined_access_mut`.
We also add improved Debug implementations on FixedBitSet so that their
meaning is much clearer in debug output.
84ecf53 to
8df367a
Compare
|
bors r+ |
# Objective * Enable `Res` and `Query` parameter mutual exclusion * Required for #5080 The `FilteredAccessSet::get_conflicts` methods didn't work properly with `Res` and `ResMut` parameters. Because those added their access by using the `combined_access_mut` method and directly modifying the global access state of the FilteredAccessSet. This caused an inconsistency, because get_conflicts assumes that ALL added access have a corresponding `FilteredAccess` added to the `filtered_accesses` field. In practice, that means that SystemParam that adds their access through the `Access` returned by `combined_access_mut` and the ones that add their access using the `add` method lived in two different universes. As a result, they could never be mutually exclusive. ## Solution This commit fixes it by removing the `combined_access_mut` method. This ensures that the `combined_access` field of FilteredAccessSet is always updated consistently with the addition of a filter. When checking for filtered access, it is now possible to account for `Res` and `ResMut` invalid access. This is currently not needed, but might be in the future. We add the `add_unfiltered_{read,write}` methods to replace previous usages of `combined_access_mut`. We also add improved Debug implementations on FixedBitSet so that their meaning is much clearer in debug output. --- ## Changelog * Fix `Res` and `Query` parameter never being mutually exclusive. ## Migration Guide Note: this mostly changes ECS internals, but since the API is public, it is technically breaking: * Removed `FilteredAccessSet::combined_access_mut` * Replace _immutable_ usage of those by `combined_access` * For _mutable_ usages, use the new `add_unfiltered_{read,write}` methods instead of `combined_access_mut` followed by `add_{read,write}`
# Objective * Enable `Res` and `Query` parameter mutual exclusion * Required for #5080 The `FilteredAccessSet::get_conflicts` methods didn't work properly with `Res` and `ResMut` parameters. Because those added their access by using the `combined_access_mut` method and directly modifying the global access state of the FilteredAccessSet. This caused an inconsistency, because get_conflicts assumes that ALL added access have a corresponding `FilteredAccess` added to the `filtered_accesses` field. In practice, that means that SystemParam that adds their access through the `Access` returned by `combined_access_mut` and the ones that add their access using the `add` method lived in two different universes. As a result, they could never be mutually exclusive. ## Solution This commit fixes it by removing the `combined_access_mut` method. This ensures that the `combined_access` field of FilteredAccessSet is always updated consistently with the addition of a filter. When checking for filtered access, it is now possible to account for `Res` and `ResMut` invalid access. This is currently not needed, but might be in the future. We add the `add_unfiltered_{read,write}` methods to replace previous usages of `combined_access_mut`. We also add improved Debug implementations on FixedBitSet so that their meaning is much clearer in debug output. --- ## Changelog * Fix `Res` and `Query` parameter never being mutually exclusive. ## Migration Guide Note: this mostly changes ECS internals, but since the API is public, it is technically breaking: * Removed `FilteredAccessSet::combined_access_mut` * Replace _immutable_ usage of those by `combined_access` * For _mutable_ usages, use the new `add_unfiltered_{read,write}` methods instead of `combined_access_mut` followed by `add_{read,write}`
# Objective * Enable `Res` and `Query` parameter mutual exclusion * Required for bevyengine#5080 The `FilteredAccessSet::get_conflicts` methods didn't work properly with `Res` and `ResMut` parameters. Because those added their access by using the `combined_access_mut` method and directly modifying the global access state of the FilteredAccessSet. This caused an inconsistency, because get_conflicts assumes that ALL added access have a corresponding `FilteredAccess` added to the `filtered_accesses` field. In practice, that means that SystemParam that adds their access through the `Access` returned by `combined_access_mut` and the ones that add their access using the `add` method lived in two different universes. As a result, they could never be mutually exclusive. ## Solution This commit fixes it by removing the `combined_access_mut` method. This ensures that the `combined_access` field of FilteredAccessSet is always updated consistently with the addition of a filter. When checking for filtered access, it is now possible to account for `Res` and `ResMut` invalid access. This is currently not needed, but might be in the future. We add the `add_unfiltered_{read,write}` methods to replace previous usages of `combined_access_mut`. We also add improved Debug implementations on FixedBitSet so that their meaning is much clearer in debug output. --- ## Changelog * Fix `Res` and `Query` parameter never being mutually exclusive. ## Migration Guide Note: this mostly changes ECS internals, but since the API is public, it is technically breaking: * Removed `FilteredAccessSet::combined_access_mut` * Replace _immutable_ usage of those by `combined_access` * For _mutable_ usages, use the new `add_unfiltered_{read,write}` methods instead of `combined_access_mut` followed by `add_{read,write}`
Objective
ResandQueryparameter mutual exclusionThe
FilteredAccessSet::get_conflictsmethods didn't work properly withResandResMutparameters. Because those added their access by usingthe
combined_access_mutmethod and directly modifying the globalaccess state of the FilteredAccessSet. This caused an inconsistency,
because get_conflicts assumes that ALL added access have a corresponding
FilteredAccessadded to thefiltered_accessesfield.In practice, that means that SystemParam that adds their access through
the
Accessreturned bycombined_access_mutand the ones that addtheir access using the
addmethod lived in two different universes. Asa result, they could never be mutually exclusive.
Solution
This commit fixes it by removing the
combined_access_mutmethod. Thisensures that the
combined_accessfield of FilteredAccessSet is alwaysupdated consistently with the addition of a filter. When checking for
filtered access, it is now possible to account for
ResandResMutinvalid access. This is currently not needed, but might be in the
future.
We add the
add_unfiltered_{read,write}methods to replace previoususages of
combined_access_mut.We also add improved Debug implementations on FixedBitSet so that their
meaning is much clearer in debug output.
Changelog
ResandQueryparameter never being mutually exclusive.Migration Guide
Note: this mostly changes ECS internals, but since the API is public, it is technically breaking:
FilteredAccessSet::combined_access_mutcombined_accessadd_unfiltered_{read,write}methods instead ofcombined_access_mutfollowed byadd_{read,write}