Skip to content

Commit

Permalink
Add more metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
shg8 committed Feb 29, 2024
1 parent cc3c39f commit 3371de7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 3dgs/GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <iostream>

static std::shared_ptr<std::unordered_map<std::string, ScrollingBuffer>> metricsMap;
static std::shared_ptr<std::unordered_map<std::string, float>> textMetricsMap;

GUIManager::GUIManager() {
metricsMap = std::make_shared<std::unordered_map<std::string, ScrollingBuffer>>();
textMetricsMap = std::make_shared<std::unordered_map<std::string, float>>();
}

void GUIManager::init() {
Expand Down Expand Up @@ -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");
Expand All @@ -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)) {
Expand Down
2 changes: 2 additions & 0 deletions 3dgs/GUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, float>& name);
Expand Down
1 change: 1 addition & 0 deletions 3dgs/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
}

uint32_t numInstances = totalSumBufferHost->readOne<uint32_t>();
guiManager.pushTextMetric("instances", numInstances);
if (numInstances > scene->getNumVertices() * sortBufferSizeMultiplier) {
auto old = sortBufferSizeMultiplier;
while (numInstances > scene->getNumVertices() * sortBufferSizeMultiplier) {
Expand Down

0 comments on commit 3371de7

Please sign in to comment.