Draw the profiler tree.
This commit is contained in:
parent
7c15a8eaf8
commit
4407e31d8a
@ -124,6 +124,11 @@ static void Run()
|
|||||||
|
|
||||||
g_profiler->EndScope();
|
g_profiler->EndScope();
|
||||||
|
|
||||||
|
if (g_settings->drawProfileTree)
|
||||||
|
{
|
||||||
|
g_view->InterfaceProfileTree();
|
||||||
|
}
|
||||||
|
|
||||||
g_profilerRecorder->BuildRecords();
|
g_profilerRecorder->BuildRecords();
|
||||||
|
|
||||||
if (g_settings->drawProfile)
|
if (g_settings->drawProfile)
|
||||||
|
@ -58,6 +58,9 @@ public:
|
|||||||
|
|
||||||
// End the top scope.
|
// End the top scope.
|
||||||
void EndScope();
|
void EndScope();
|
||||||
|
|
||||||
|
// Get the root profiler node.
|
||||||
|
ProfilerNode* GetRoot() { return m_root; }
|
||||||
private:
|
private:
|
||||||
friend class ProfilerRecorder;
|
friend class ProfilerRecorder;
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <testbed/framework/view.h>
|
#include <testbed/framework/view.h>
|
||||||
#include <testbed/framework/view_model.h>
|
#include <testbed/framework/view_model.h>
|
||||||
#include <testbed/framework/test.h>
|
#include <testbed/framework/test.h>
|
||||||
|
#include <testbed/framework/profiler.h>
|
||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#if defined (U_OPENGL_2)
|
#if defined (U_OPENGL_2)
|
||||||
@ -218,6 +219,7 @@ void View::Interface()
|
|||||||
if (ImGui::BeginMenu("View"))
|
if (ImGui::BeginMenu("View"))
|
||||||
{
|
{
|
||||||
ImGui::MenuItem("Profile", "", &settings.drawProfile);
|
ImGui::MenuItem("Profile", "", &settings.drawProfile);
|
||||||
|
ImGui::MenuItem("Profile Tree", "", &settings.drawProfileTree);
|
||||||
ImGui::MenuItem("Statistics", "", &settings.drawStats);
|
ImGui::MenuItem("Statistics", "", &settings.drawStats);
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -400,6 +402,53 @@ void View::Interface()
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TreeNode(ProfilerNode* node, u32& index)
|
||||||
|
{
|
||||||
|
ImGui::PushID(index);
|
||||||
|
++index;
|
||||||
|
|
||||||
|
if (ImGui::TreeNode(node->name))
|
||||||
|
{
|
||||||
|
float64 elapsedTime = node->t1 - node->t0;
|
||||||
|
ImGui::Text("%.4f [ms]", elapsedTime);
|
||||||
|
|
||||||
|
for (u32 i = 0; i < node->children.Count(); ++i)
|
||||||
|
{
|
||||||
|
TreeNode(node->children[i], index);
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::InterfaceProfileTree()
|
||||||
|
{
|
||||||
|
ImGui::Begin("Overlay", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
|
||||||
|
ImVec2 ws = ImGui::GetWindowSize();
|
||||||
|
ImVec2 wp = ImGui::GetWindowPos();
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
|
|
||||||
|
ImGui::SetNextWindowBgAlpha(0.0f);
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(0.0f, wp.y + ws.y));
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(g_camera->m_width - 250.0f, 0.0f));
|
||||||
|
|
||||||
|
ImGui::Begin("##ProfileTree", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
|
|
||||||
|
ProfilerNode* root = g_profiler->GetRoot();
|
||||||
|
if (root)
|
||||||
|
{
|
||||||
|
u32 index = 0;
|
||||||
|
TreeNode(root, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
}
|
||||||
|
|
||||||
void View::EndInterface()
|
void View::EndInterface()
|
||||||
{
|
{
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
|
|
||||||
void BeginInterface();
|
void BeginInterface();
|
||||||
void Interface();
|
void Interface();
|
||||||
|
void InterfaceProfileTree();
|
||||||
void EndInterface();
|
void EndInterface();
|
||||||
private:
|
private:
|
||||||
friend class ViewModel;
|
friend class ViewModel;
|
||||||
|
@ -33,6 +33,7 @@ struct Settings
|
|||||||
drawTriangles = true;
|
drawTriangles = true;
|
||||||
drawGrid = true;
|
drawGrid = true;
|
||||||
drawProfile = false;
|
drawProfile = false;
|
||||||
|
drawProfileTree = false;
|
||||||
drawStats = false;
|
drawStats = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ struct Settings
|
|||||||
bool drawTriangles;
|
bool drawTriangles;
|
||||||
bool drawGrid;
|
bool drawGrid;
|
||||||
bool drawProfile;
|
bool drawProfile;
|
||||||
|
bool drawProfileTree;
|
||||||
bool drawStats;
|
bool drawStats;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user