Skip to content

Commit

Permalink
Fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shg8 committed Feb 21, 2024
1 parent b1cdcb2 commit f2cd510
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
7 changes: 3 additions & 4 deletions 3dgs/GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void GUIManager::buildGui() {

static ImPlotAxisFlags flags = ImPlotAxisFlags_AutoFit;
if (ImPlot::BeginPlot("##Scrolling", ImVec2(-1, -1))) {
ImPlot::SetupAxes("ms", "time", flags, flags);
ImPlot::SetupAxes("s", "time (ms)", flags, flags);
const auto t = ImGui::GetTime();
ImPlot::SetupAxisLimits(ImAxis_X1, t - history, t, ImGuiCond_Always);
ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 1);
Expand All @@ -42,18 +42,17 @@ void GUIManager::buildGui() {
ImGui::Text("WASD: Move");
ImGui::Text("Mouse: Look");
ImGui::End();

}

void GUIManager::pushMetric(const std::string& name, float value) {
int maxSize = 600;
if (!metricsMap->contains(name)) {
metricsMap->insert({name, ScrollingBuffer(maxSize)});
}
metricsMap->at(name).addPoint(ImGui::GetTime(), value / 1000000.0);
metricsMap->at(name).addPoint(ImGui::GetTime(), value);
}

void GUIManager::pushMetric(const std::unordered_map<std::string, unsigned long long>& name) {
void GUIManager::pushMetric(const std::unordered_map<std::string, float>& name) {
for (auto& [n, v]: name) {
pushMetric(n, v);
}
Expand Down
2 changes: 1 addition & 1 deletion 3dgs/GUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class GUIManager {

static void pushMetric(const std::string& name, float value);

static void pushMetric(const std::unordered_map<std::string, unsigned long long>& name);
static void pushMetric(const std::unordered_map<std::string, float>& name);

};

Expand Down
7 changes: 6 additions & 1 deletion 3dgs/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void Renderer::retrieveTimestamps() {
throw std::runtime_error("Failed to retrieve timestamps");
}

guiManager.pushMetric(queryManager->parseResults(timestamps));
auto metrics = queryManager->parseResults(timestamps);
for (auto& metric: metrics) {
guiManager.pushMetric(metric.first, metric.second / 1000000.0);
}
}

void Renderer::initializeVulkan() {
Expand Down Expand Up @@ -392,6 +395,8 @@ void Renderer::run() {
// assert(data2[i] <= data2[i+1]);
// }
}

context->device->waitIdle();
}

void Renderer::createCommandPool() {
Expand Down
8 changes: 8 additions & 0 deletions vulkan/ImguiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,11 @@ void ImguiManager::draw(vk::CommandBuffer commandBuffer, uint32_t currentImageIn
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), commandBuffer);
commandBuffer.endRenderingKHR();
}

ImguiManager::~ImguiManager() {
// Cleanup
context->device->waitIdle();
ImGui_ImplVulkan_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
2 changes: 2 additions & 0 deletions vulkan/ImguiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class ImguiManager {

void draw(vk::CommandBuffer commandBuffer, uint32_t currentImageIndex, std::function<void(void)> imguiFunction);

~ImguiManager();

private:
std::shared_ptr<VulkanContext> context;
std::shared_ptr<Swapchain> swapchain;
Expand Down

0 comments on commit f2cd510

Please sign in to comment.