From 4afcddccef7ba1ded1c42327aec806b301a3e097 Mon Sep 17 00:00:00 2001 From: Ubpa <641614112@qq.com> Date: Sun, 9 Aug 2020 10:37:19 +0800 Subject: [PATCH] Singleton -> FrameGraph --- src/core/World.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/core/World.cpp b/src/core/World.cpp index eddaeee..c3d9cec 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -69,6 +69,7 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const { auto& registry = graph.GetRegistry(); auto& subgraph_cmpt = graph.GenSubgraph("Component Nodes"); + auto& subgraph_singleton = graph.GenSubgraph("Singleton Nodes"); auto& subgraph_sys = graph.GenSubgraph("System Function Nodes"); auto& subgraph_lastframe = graph.GenSubgraph("LastFrame Edges"); @@ -85,6 +86,10 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const { .RegisterGraphNodeAttr("shape", "ellipse") .RegisterGraphNodeAttr("color", "#6597AD"); + subgraph_singleton + .RegisterGraphNodeAttr("shape", "ellipse") + .RegisterGraphNodeAttr("color", "#BFB500"); + subgraph_sys .RegisterGraphNodeAttr("shape", "box") .RegisterGraphNodeAttr("color", "#F79646"); @@ -128,12 +133,17 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const { cmptTypes.insert(cmptType); for (auto cmptType : sysFunc->entityQuery.filter.NoneCmptTypes()) cmptTypes.insert(cmptType); + for (auto singleton : sysFunc->singletonLocator.SingletonTypes()) + cmptTypes.insert(singleton); } for (auto cmptType : cmptTypes) { auto cmptIdx = registry.RegisterNode(queryCmptName(cmptType)); cmptType2idx[cmptType] = cmptIdx; - subgraph_cmpt.AddNode(cmptIdx); + if (AccessMode_IsSingleton(cmptType.GetAccessMode())) + subgraph_singleton.AddNode(cmptIdx); + else + subgraph_cmpt.AddNode(cmptIdx); } for (const auto& [hash, sysFunc] : schedule.sysFuncs) { @@ -142,16 +152,16 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const { subgraph_sys.AddNode(sysIdx); - const auto& locator = sysFunc->entityQuery.locator; - for (const auto& cmptType : locator.LastFrameCmptTypes()) { + const auto& cmptlocator = sysFunc->entityQuery.locator; + for (const auto& cmptType : cmptlocator.LastFrameCmptTypes()) { auto edgeIdx = registry.RegisterEdge(cmptType2idx[cmptType], sysIdx); subgraph_lastframe.AddEdge(edgeIdx); } - for (const auto& cmptType : locator.WriteCmptTypes()) { + for (const auto& cmptType : cmptlocator.WriteCmptTypes()) { auto edgeIdx = registry.RegisterEdge(sysIdx, cmptType2idx[cmptType]); subgraph_write.AddEdge(edgeIdx); } - for (const auto& cmptType : locator.LatestCmptTypes()) { + for (const auto& cmptType : cmptlocator.LatestCmptTypes()) { auto edgeIdx = registry.RegisterEdge(cmptType2idx[cmptType], sysIdx); subgraph_latest.AddEdge(edgeIdx); } @@ -227,6 +237,20 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const { auto edgeIdx = registry.RegisterEdge(sysIdx, cmptType2idx[cmptType]); subgraph_none.AddEdge(edgeIdx); } + + const auto& singletonlocator = sysFunc->singletonLocator; + for (const auto& singleton : singletonlocator.LastFrameSingletonTypes()) { + auto edgeIdx = registry.RegisterEdge(cmptType2idx[singleton], sysIdx); + subgraph_lastframe.AddEdge(edgeIdx); + } + for (const auto& singleton : singletonlocator.WriteSingletonTypes()) { + auto edgeIdx = registry.RegisterEdge(sysIdx, cmptType2idx[singleton]); + subgraph_write.AddEdge(edgeIdx); + } + for (const auto& singleton : singletonlocator.LatestSingletonTypes()) { + auto edgeIdx = registry.RegisterEdge(cmptType2idx[singleton], sysIdx); + subgraph_latest.AddEdge(edgeIdx); + } } for (const auto& [from, to] : schedule.sysFuncOrder) {