Combined transform systems

Profiler window calls count
Parallel transform system is now in the normal transform system
Removed unused parent system
This commit is contained in:
max
2024-10-20 03:51:59 +02:00
parent 82fe47f627
commit 2c84e650d6
6 changed files with 66 additions and 169 deletions
+1
View File
@@ -69,6 +69,7 @@ namespace Nerfed.Editor
foreach (MoonTools.ECS.System system in Program.editorSystems)
{
using ProfilerScope scope = new(system.GetType().Name);
system.Update(Engine.Timestep);
}
}
+8 -8
View File
@@ -28,7 +28,6 @@ internal class Program
{
//systems.Add(new ParentSystem(world));
systems.Add(new LocalToWorldSystem(world));
systems.Add(new LocalToWorldThreadedSystem(world));
editorSystems.Add(new EditorProfilerWindow(world));
editorSystems.Add(new EditorHierarchyWindow(world));
@@ -49,13 +48,13 @@ internal class Program
Entity ent5 = world.CreateBaseEntity("entity5");
for (int i = 0; i < 10; i++)
for (int i = 0; i < 256; i++)
{
Entity newEnt = world.CreateBaseEntity();
world.Set(newEnt, new LocalTransform(new Vector3(i, i, i), Quaternion.Identity, Vector3.One));
Entity parent = newEnt;
for (int j = 0; j < 10; j++) {
for (int j = 0; j < 2; j++) {
Entity newChildEnt = world.CreateEntity();
world.Set(newChildEnt, new LocalTransform(new Vector3(j, j, j), Quaternion.Identity, Vector3.One));
Transform.SetParent(world, newChildEnt, parent);
@@ -72,10 +71,8 @@ internal class Program
{
foreach (MoonTools.ECS.System system in systems)
{
using (new ProfilerScope(system.GetType().Name))
{
system.Update(Engine.Timestep);
}
using ProfilerScope scope = new(system.GetType().Name);
system.Update(Engine.Timestep);
}
using (new ProfilerScope("EditorGui.Update"))
@@ -94,7 +91,10 @@ internal class Program
private static void HandleOnRender()
{
EditorGui.Render();
using (new ProfilerScope("EditorGui.Render"))
{
EditorGui.Render();
}
}
private static void HandleOnQuit()
+12 -9
View File
@@ -78,34 +78,37 @@ namespace Nerfed.Editor.Systems
ImGui.BeginChild("Combined", new System.Numerics.Vector2(0, 0));
// Gather combined data.
Dictionary<string, double> combinedRecordData = new Dictionary<string, double>(128);
Dictionary<string, (double ms, uint calls)> combinedRecordData = new Dictionary<string, (double ms, uint calls)>(128);
foreach (Profiler.ProfileRecord record in frameData.records)
{
if (combinedRecordData.TryGetValue(record.label, out double totalMs))
if (combinedRecordData.TryGetValue(record.label, out (double ms, uint calls) combined))
{
combinedRecordData[record.label] = totalMs + record.ElapsedMilliseconds();
combinedRecordData[record.label] = (combined.ms + record.ElapsedMilliseconds(), combined.calls + 1);
}
else
{
combinedRecordData.Add(record.label, record.ElapsedMilliseconds());
combinedRecordData.Add(record.label, (record.ElapsedMilliseconds(), 1));
}
}
IOrderedEnumerable<KeyValuePair<string, double>> orderedCombinedData = combinedRecordData.OrderByDescending(x => x.Value);
IOrderedEnumerable<KeyValuePair<string, (double ms, uint calls)>> orderedCombinedData = combinedRecordData.OrderByDescending(x => x.Value.ms);
if (ImGui.BeginTable("ProfilerCombinedData", 2, tableFlags, new System.Numerics.Vector2(0, 0)))
if (ImGui.BeginTable("ProfilerCombinedData", 3, tableFlags, new System.Numerics.Vector2(0, 0)))
{
ImGui.TableSetupColumn("name", ImGuiTableColumnFlags.WidthStretch, 0.8f, 0);
ImGui.TableSetupColumn("name", ImGuiTableColumnFlags.WidthStretch, 0.6f, 0);
ImGui.TableSetupColumn("ms", ImGuiTableColumnFlags.WidthStretch, 0.2f, 1);
ImGui.TableSetupColumn("calls", ImGuiTableColumnFlags.WidthStretch, 0.2f, 2);
ImGui.TableSetupScrollFreeze(0, 1); // Make row always visible
ImGui.TableHeadersRow();
foreach (KeyValuePair<string, double> combinedData in orderedCombinedData)
foreach (KeyValuePair<string, (double ms, uint calls)> combinedData in orderedCombinedData)
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text($"{combinedData.Key}");
ImGui.TableNextColumn();
ImGui.Text($"{combinedData.Value:0.000}");
ImGui.Text($"{combinedData.Value.ms:0.000}");
ImGui.TableNextColumn();
ImGui.Text($"{combinedData.Value.calls}");
}
ImGui.EndTable();