Skip to content

Commit

Permalink
Singleton -> FrameGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubpa committed Aug 9, 2020
1 parent ff1ca9a commit 4afcddc
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions src/core/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4afcddc

Please sign in to comment.