diff --git a/3dgs/GUIManager.cpp b/3dgs/GUIManager.cpp index e5e5fd4..9d2bf82 100644 --- a/3dgs/GUIManager.cpp +++ b/3dgs/GUIManager.cpp @@ -3,9 +3,11 @@ #include static std::shared_ptr> metricsMap; +static std::shared_ptr> textMetricsMap; GUIManager::GUIManager() { metricsMap = std::make_shared>(); + textMetricsMap = std::make_shared>(); } void GUIManager::init() { @@ -45,6 +47,13 @@ void GUIManager::buildGui() { bool popen = true; ImGui::SetNextWindowPos(ImVec2(10, 270), ImGuiCond_FirstUseEver); + ImGui::Begin("Metrics", &popen, ImGuiWindowFlags_AlwaysAutoResize); + for (auto& [name, value]: *textMetricsMap) { + ImGui::Text("%s: %.2f", name.c_str(), value); + } + ImGui::End(); + + ImGui::SetNextWindowPos(ImVec2(10, 310), ImGuiCond_FirstUseEver); ImGui::Begin("Controls", &popen, ImGuiWindowFlags_AlwaysAutoResize); ImGui::Text("WASD: move"); ImGui::Text("Space: up"); @@ -59,6 +68,14 @@ void GUIManager::buildGui() { } } +void GUIManager::pushTextMetric(const std::string& name, float value) { + if (!textMetricsMap->contains(name)) { + textMetricsMap->insert({name, value}); + } else { + textMetricsMap->at(name) = value; + } +} + void GUIManager::pushMetric(const std::string& name, float value) { int maxSize = 600; if (!metricsMap->contains(name)) { diff --git a/3dgs/GUIManager.h b/3dgs/GUIManager.h index 83d5bc3..fb20965 100644 --- a/3dgs/GUIManager.h +++ b/3dgs/GUIManager.h @@ -41,6 +41,8 @@ class GUIManager { void buildGui(); + static void pushTextMetric(const std::string& name, float value); + static void pushMetric(const std::string& name, float value); static void pushMetric(const std::unordered_map& name); diff --git a/3dgs/Renderer.cpp b/3dgs/Renderer.cpp index b8807bd..5c1440d 100644 --- a/3dgs/Renderer.cpp +++ b/3dgs/Renderer.cpp @@ -526,6 +526,7 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) { } uint32_t numInstances = totalSumBufferHost->readOne(); + guiManager.pushTextMetric("instances", numInstances); if (numInstances > scene->getNumVertices() * sortBufferSizeMultiplier) { auto old = sortBufferSizeMultiplier; while (numInstances > scene->getNumVertices() * sortBufferSizeMultiplier) {