-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - Fix FilteredAccessSet get_conflicts inconsistency #5105
Conversation
0bdf8e4
to
04758b8
Compare
04758b8
to
3b71c03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This debug formatting is so much nicer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on board for these changes!
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
Res
andQuery
parameter mutual exclusionThe
FilteredAccessSet::get_conflicts
methods didn't work properly withRes
andResMut
parameters. Because those added their access by usingthe
combined_access_mut
method and directly modifying the globalaccess state of the FilteredAccessSet. This caused an inconsistency,
because get_conflicts assumes that ALL added access have a corresponding
FilteredAccess
added to thefiltered_accesses
field.In practice, that means that SystemParam that adds their access through
the
Access
returned bycombined_access_mut
and the ones that addtheir access using the
add
method lived in two different universes. Asa result, they could never be mutually exclusive.
Solution
This commit fixes it by removing the
combined_access_mut
method. Thisensures that the
combined_access
field of FilteredAccessSet is alwaysupdated consistently with the addition of a filter. When checking for
filtered access, it is now possible to account for
Res
andResMut
invalid 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
Res
andQuery
parameter 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_mut
combined_access
add_unfiltered_{read,write}
methods instead ofcombined_access_mut
followed byadd_{read,write}