mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +00:00
update: debug panel: change avg calc method to fps
This commit is contained in:
parent
881253708c
commit
dc309c5fb3
1 changed files with 23 additions and 5 deletions
|
|
@ -70,16 +70,21 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||||
static int fpsMinOld = fpsMin;
|
static int fpsMinOld = fpsMin;
|
||||||
static int fpsMax = fps;
|
static int fpsMax = fps;
|
||||||
static int fpsMaxOld = fpsMax;
|
static int fpsMaxOld = fpsMax;
|
||||||
|
static int framesCount = 0;
|
||||||
|
static float deltaSum = 0.;
|
||||||
static float fpsAvgLong = fps;
|
static float fpsAvgLong = fps;
|
||||||
static std::wstring fpsString = L"";
|
static std::wstring fpsString = L"";
|
||||||
|
|
||||||
static int drawCalls = 0;
|
static int drawCalls = 0;
|
||||||
static int drawCallsMin = drawCalls;
|
static int drawCallsMin = drawCalls;
|
||||||
static int drawCallsMinOld = drawCallsMin;
|
static int drawCallsMinOld = drawCallsMin;
|
||||||
static int drawCallsMax = drawCalls;
|
static int drawCallsMax = drawCalls;
|
||||||
static int drawCallsMaxOld = drawCallsMax;
|
static int drawCallsMaxOld = drawCallsMax;
|
||||||
static float drawCallsAvgLong = drawCalls;
|
static float drawCallsAvgLong = drawCalls;
|
||||||
|
static std::wstring drawCallsString = L"";
|
||||||
|
|
||||||
static float AVG_ALPHA = 0.01;
|
|
||||||
|
static const float AVG_ALPHA = 0.3;
|
||||||
|
|
||||||
static size_t lastTotalDownload = 0;
|
static size_t lastTotalDownload = 0;
|
||||||
static size_t lastTotalUpload = 0;
|
static size_t lastTotalUpload = 0;
|
||||||
|
|
@ -89,7 +94,8 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||||
fps = 1.0f / engine.getTime().getDelta();
|
fps = 1.0f / engine.getTime().getDelta();
|
||||||
fpsMin = std::min(fps, fpsMin);
|
fpsMin = std::min(fps, fpsMin);
|
||||||
fpsMax = std::max(fps, fpsMax);
|
fpsMax = std::max(fps, fpsMax);
|
||||||
fpsAvgLong = fpsAvgLong * (1 - AVG_ALPHA) + fps * AVG_ALPHA;
|
framesCount++;
|
||||||
|
deltaSum += engine.getTime().getDelta();
|
||||||
|
|
||||||
drawCallsMin = std::min(drawCalls, drawCallsMin);
|
drawCallsMin = std::min(drawCalls, drawCallsMin);
|
||||||
drawCallsMax = std::max(drawCalls, drawCallsMax);
|
drawCallsMax = std::max(drawCalls, drawCallsMax);
|
||||||
|
|
@ -97,6 +103,18 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||||
drawCallsAvgLong * (1 - AVG_ALPHA) + drawCalls * AVG_ALPHA;
|
drawCallsAvgLong * (1 - AVG_ALPHA) + drawCalls * AVG_ALPHA;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
panel->listenInterval(0.2f, []() {
|
||||||
|
if (framesCount < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fpsAvgLong = framesCount / deltaSum;
|
||||||
|
framesCount = 0;
|
||||||
|
deltaSum = 0.0;
|
||||||
|
|
||||||
|
fpsString = std::to_wstring(int(fpsAvgLong));
|
||||||
|
drawCallsString = std::to_wstring(int(drawCallsAvgLong));
|
||||||
|
});
|
||||||
|
|
||||||
panel->listenInterval(2.0f, []() {
|
panel->listenInterval(2.0f, []() {
|
||||||
fpsMinOld = fpsMin;
|
fpsMinOld = fpsMin;
|
||||||
fpsMin = fps;
|
fpsMin = fps;
|
||||||
|
|
@ -124,7 +142,7 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||||
}
|
}
|
||||||
|
|
||||||
panel->add(create_label(gui, []() {
|
panel->add(create_label(gui, []() {
|
||||||
return L"fps: " + std::to_wstring(int(fpsAvgLong)) + L" / " +
|
return L"fps: " + fpsString + L" / " +
|
||||||
std::to_wstring(std::min(fpsMinOld, fpsMin)) + L" / " +
|
std::to_wstring(std::min(fpsMinOld, fpsMin)) + L" / " +
|
||||||
std::to_wstring(std::max(fpsMaxOld, fpsMax));
|
std::to_wstring(std::max(fpsMaxOld, fpsMax));
|
||||||
}));
|
}));
|
||||||
|
|
@ -134,8 +152,8 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||||
panel->add(create_label(gui, []() {
|
panel->add(create_label(gui, []() {
|
||||||
drawCalls = MeshStats::drawCalls;
|
drawCalls = MeshStats::drawCalls;
|
||||||
MeshStats::drawCalls = 0;
|
MeshStats::drawCalls = 0;
|
||||||
return L"draw-calls: " + std::to_wstring(drawCalls) +
|
return L"draw-calls: " + std::to_wstring(drawCalls) + L" ( avg: " +
|
||||||
L" (avg: " + std::to_wstring(int(drawCallsAvgLong)) + L" )";
|
drawCallsString + L" )";
|
||||||
}));
|
}));
|
||||||
panel->add(create_label(gui, []() {
|
panel->add(create_label(gui, []() {
|
||||||
return L" min/max: " +
|
return L" min/max: " +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue