-
-
Notifications
You must be signed in to change notification settings - Fork 744
Update to latest legion and implement new dispatcher #2400
Conversation
One thing I forgot to mention is the removal of stages and instead using the legion's way of scheduling. Systems are scheduled arbitrarily, but they respect data dependency order. For example if your system writes I think this greatly improves code readability as you can observe the full execution order by just looking at dispatcher builder. With stages there was no way to see system order without going into bundle definitions and looking at what stage they are executed. Another thing is that you can easily reorder systems by just swapping There is one regression though. System bundles now have no way to specify system insertion order. For example if there was Any objections? |
I believe this is ready for review now. Updated all ported crates and Everything (that is ported so far) compiles without warnings |
I don't have time to review this until the weekend, but because of the size, it should have at least two sets of eyes give the entire thing a review. These reviews don't need to guarantee correctness, but they should make an attempt to find any obvious issues. |
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.
Wow, very impressive work!
I have a few remarks, but nothing major.
Also, I think all the dispatcher stuff should be moved into a separate crate. legion_dispatch maybe?
Thanks a lot!
Thanks! Dispatcher is just a single file so I don't know if it's worth moving it into a crate? All the |
It is very convenient, so I'm sure other legion users would love it.
Exactly, we can't know if the user will use application or not. We should handle the insertion for them in the case where they don't, instead of crash. |
We cannot handle all the custom use cases. If user does not use |
What about moving it into |
Good points, let's go with how it is currently 👍 |
Ping @khionu |
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 PR is pretty big. Since CI is just around the corner, I'd want to wait for that and have it run on it. That, and the handful of concerns I noted, and it looks pretty good!
CI wouldn't work on legion branch yet because there is still a lot of thinngs to do: update all remaining crates, examples, inline examples, book. Also merge with master is quite big and I reserved another PR for that |
Yeah definitely don't merge master into legion before most of the legion port is completed. |
Merging master is not necessarily bad and is probably easier now since not everything is ported yet. I just don't want to do that in this PR as it is already big. |
Even if it's not going to work, CI on the Legion branch should happen soon, so we can have some indicator of progress. CI on the Legion branch needs to pass before it's merged. |
Sorry for a big one, but this due to changes to the way dispatcher and system bundles work.
There was a big discussion on discord about system data initialization/disposal (resources and/or entities). It was decided that systems should not contain any initialization logic and it should be solely left to system bundles. Systems are now simple
fn build() -> impl Runnable
functions instead of the horriblefn build() -> Box<dyn FnOnce(&mut World, &mut Resources) -> Box<dyn Schedulable>>
. New legion codegen macros can be used as well. This is howSystemBundle
looks now:This solves most of the problems that were present previously and also reduces code size considerably. This introduces some inconveniece for simple systems that use
shrev::EventChannel
, because aSystemBundle
has to be implemented for it to registerReaderId
. But I believe these ergonomic issues can later be solved with a macro how it was done in specs.Dispatcher currently does not use
ArcThreadPool
as this is blocked on a fix in legion. It will be resolved soon.Material example builds & works. Other already ported crates and examples will follow shortly.