Created
May 2, 2022 15:19
-
-
Save Hexlord/03f0a2ab85064fcd94ee4dd10406453b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main-threaded systems are always executed after the ECS tick, that's why such systems are listed in the end. | |
Impl::MultiThreadedSection([&]() { | |
/// Logic | |
Import<MLifespanSystemsMT>(ECS); | |
Import<MGeometryFluctuationSystemsMT>(ECS); | |
SetModuleEnabled<MGeometryFluctuationSystemsMT>(ECS, false); | |
// Update game state debug text. | |
Import<MGameStateSystemsMT>(ECS); | |
/// Physics | |
// Must happen as close to Syncpoint 1 as possible, because physics thread is getting blocked. | |
Import<MPhysicsLockSystemsMT>(ECS); | |
// Read-write physics state here. | |
// Keep this part as short as possible to unlock physics asap. | |
}); | |
// Most visible entities are created above this line. | |
// -------------------------------------------------------------- | |
// All systems related to making entities visible must be below. | |
// Merges arbitrary gameplay changes. | |
Syncpoint(ECS, "Syncpoint 1", [](ecs &ECS) { | |
// Must happen as close to MPhysicsLockSystems as possible, because physics thread is getting blocked. | |
Physics::Impl::UnlockAndSchedulePhysics(); | |
// We do that here first time to allow input to ignore destructed entities (like old scene). | |
Impl::PropagateBeingDestructed(ECS); | |
Impl::ProcessEventQueue(ECS); | |
// It is better to have input handler created entities visible immediately, than having 0 frame latency on objects of input state. | |
// That's why we process input before our UI rebuild and transform systems. | |
SE::Impl::ProcessInput(ECS); | |
if (Time::GetGameTicks() > 1) { | |
Layout::Impl::UpdateHierarchies(ECS); | |
} | |
// We do that here second time to allow results of input destruction to be considered destructed. | |
Impl::PropagateBeingDestructed(ECS); | |
Impl::ProcessEventQueue(ECS); | |
// Now we check that no-one new was destructed. | |
Impl::AssertBeingDestructedPropagation(ECS); | |
}); | |
// All destruction (CBeingDestructed) must happen above this line. | |
// -------------------------------------------------------------- | |
/// Layered event listeners | |
Import<MInputLayer>(ECS); | |
Impl::SingleThreadedSection([&]() { | |
Import<MLayoutStyleSystemsST>(ECS); | |
Import<MTextureRefCountSystemsST>(ECS); | |
}); | |
Impl::MultiThreadedSection([&]() { | |
Import<MTextureStreamingSystemsPureMT>(ECS); | |
Import<MAnimationSystemsExclusiveSectionMT>(ECS); | |
}); | |
Impl::SingleThreadedSection([&]() { Import<MTextureNativeSizeSystemsST>(ECS); }); | |
// All systems related to UI must be above this line. | |
// All visible entities most be created above this line. | |
// -------------------------------------------------------------- | |
// Merges graphics. | |
Syncpoint(ECS, "Syncpoint 2", [](ecs &ECS) { | |
Impl::ProcessEventQueue(ECS); | |
Primitives::Impl::PreloadGlyphs(ECS); | |
Impl::AssertBeingDestructedPropagation(ECS); | |
}); | |
Impl::MultiThreadedSection([&]() { | |
Import<MPrimitiveTextSystemsMT>(ECS); | |
Import<MLayoutDimensionSystemsMT>(ECS); | |
}); | |
Syncpoint(ECS, "Syncpoint 3", [](ecs &ECS) { | |
Impl::ProcessEventQueue(ECS); | |
Graphics::Impl::UpdateViewsPreLayout(ECS); | |
Layout::Impl::RebuildRootNodeLayout(ECS); | |
Graphics::Impl::UpdateViewsPostLayout(ECS); | |
Impl::ProcessEventQueue(ECS); | |
Impl::AssertBeingDestructedPropagation(ECS); | |
}); | |
Impl::MultiThreadedSection([&]() { Import<MTransformSystemsMT>(ECS); }); | |
Impl::SingleThreadedSection([&]() { Import<MPrimitiveBufferSystemsST>(ECS); }); | |
Impl::MultiThreadedSection([&]() { | |
/// Render cooking | |
// Do not add normal multi-threaded systems here, because render cooking uses query thread-split, thus reads arbitrary entities. | |
Import<MRenderPrimitivesCookingSystemsExclusiveSectionMT>(ECS); | |
Import<MRenderTilesCookingSystemsExclusiveSectionMT>(ECS); | |
}); | |
// Just validation stuff. | |
Syncpoint(ECS, "Syncpoint 4", [](ecs &ECS) { Impl::AssertBeingDestructedPropagation(ECS); }); | |
/// Render submit | |
Import<MRenderPrepareSystemsPureMain>(ECS); | |
Import<MRenderPrimitivesSubmitSystemsPureMain>(ECS); | |
Import<MRenderTilesSubmitSystemsPureMain>(ECS); | |
Import<MRenderRootSubmitSystemsPureMain>(ECS); | |
Import<MRenderFrameSystemsPureMain>(ECS); | |
Import<MRenderCleanupSystemsPureMain>(ECS); | |
Import<MCoreDestructionSystemsPureMain>(ECS); | |
Import<MCoreEntitySystemsPureMain>(ECS); | |
Import<MEntityInspectionSystemsMain>(ECS); | |
Import<MHierarchyPanelSystemsMain>(ECS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment