Fixed perfomance counter
* Added vert-count and draw call count * extracted performance function to seperate header as inline functions
This commit is contained in:
@ -1,10 +1,5 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
#include "glm/glm.hpp"
|
||||
|
||||
#include "graphics/Shader.h"
|
||||
#include "graphics/Window.h"
|
||||
#include "graphics/Camera.h"
|
||||
@ -15,7 +10,9 @@
|
||||
#include "Graphics/Renderer.h"
|
||||
#include "Graphics/GUI/GUIManager.h"
|
||||
#include "Scene.h"
|
||||
#include "PerfCounter.h"
|
||||
|
||||
|
||||
|
||||
void ShowStats();
|
||||
extern void Start();
|
||||
extern void Update();
|
||||
extern void ImmediateGraphicsDraw();
|
||||
extern void Stop();
|
||||
|
50
BarinkEngine/Include/PerfCounter.h
Normal file
50
BarinkEngine/Include/PerfCounter.h
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
#include <imgui.h>
|
||||
|
||||
struct EngineStatistics {
|
||||
uint32_t lastSampleTime;
|
||||
float frameTime;
|
||||
uint32_t verts;
|
||||
uint32_t DC;
|
||||
|
||||
uint64_t frames;
|
||||
uint64_t FPS;
|
||||
};
|
||||
extern EngineStatistics* ES;
|
||||
|
||||
inline void PerfomanceSamplerInit(){
|
||||
ES = new EngineStatistics();
|
||||
ES->frames = 0;
|
||||
ES->lastSampleTime = 0;
|
||||
ES->lastSampleTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
||||
|
||||
}
|
||||
|
||||
inline void SamplePerformance(void) {
|
||||
ES->frames++;
|
||||
ES->DC = 0;
|
||||
ES->verts = 0;
|
||||
unsigned int now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
||||
unsigned int MilliSecondsPast = now - ES->lastSampleTime;
|
||||
if (MilliSecondsPast >= 1000) {
|
||||
|
||||
ES->frameTime = (float)1000 / ES->frames;
|
||||
ES->FPS = ES->frames;
|
||||
ES->frames = 0;
|
||||
ES->lastSampleTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void ShowStats() {
|
||||
ImGui::Begin("Statistics", false, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
|
||||
|
||||
ImGui::Text("FPS: %i", ES->FPS);
|
||||
ImGui::Text("Frame Time: %f", ES->frameTime);
|
||||
ImGui::Text("Verts: %i", ES->verts);
|
||||
ImGui::Text("Draw Calls: %i", ES->DC);
|
||||
ImGui::End();
|
||||
|
||||
}
|
Reference in New Issue
Block a user