From 60f2ad232338ba3dada9c7f419e1d9e15c479aa0 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Tue, 23 Dec 2025 17:59:29 +0300 Subject: [PATCH 01/11] add: debug panel: fps avg --- src/frontend/debug_panel.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index 5dc70af0d..b569170bf 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -70,6 +70,10 @@ std::shared_ptr create_debug_panel( static int fps = 0; static int fpsMin = fps; static int fpsMax = fps; + static float fpsAvgFast = fps; + static float fpsAvgLong = fps; + static float fpsAvgAlpha = 0.1; + static float fpsAvgBeta = 0.01; static std::wstring fpsString = L""; static size_t lastTotalDownload = 0; @@ -80,10 +84,11 @@ std::shared_ptr create_debug_panel( fps = 1.0f / engine.getTime().getDelta(); fpsMin = std::min(fps, fpsMin); fpsMax = std::max(fps, fpsMax); + fpsAvgFast = fpsAvgFast * (1 - fpsAvgAlpha) + fps * fpsAvgAlpha; + fpsAvgLong = fpsAvgLong * (1 - fpsAvgBeta) + fps * fpsAvgBeta; }); - panel->listenInterval(0.5f, []() { - fpsString = std::to_wstring(fpsMax)+L" / "+std::to_wstring(fpsMin); + panel->listenInterval(2.0f, []() { fpsMin = fps; fpsMax = fps; }); @@ -101,8 +106,10 @@ std::shared_ptr create_debug_panel( }); } - panel->add(create_label(gui, []() { return L"fps: "+fpsString;})); - + panel->add(create_label(gui, []() { + return L"fps: " + std::to_wstring(int(fpsAvgFast)) + L" / " + std::to_wstring(int(fpsAvgLong)) + L" / " + + std::to_wstring(fpsMin) + L" / " + std::to_wstring(fpsMax); + })); panel->add(create_label(gui, []() { return L"meshes: " + std::to_wstring(MeshStats::meshesCount); })); From 79e46a1017d4d75ba4d5c2c00a07e592328af8f0 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Tue, 23 Dec 2025 18:04:04 +0300 Subject: [PATCH 02/11] update: debug panel: smooth min/max fps --- src/frontend/debug_panel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index b569170bf..80f4904ee 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -69,7 +69,9 @@ std::shared_ptr create_debug_panel( static int fps = 0; static int fpsMin = fps; + static int fpsMinOld = fpsMin; static int fpsMax = fps; + static int fpsMaxOld = fpsMax; static float fpsAvgFast = fps; static float fpsAvgLong = fps; static float fpsAvgAlpha = 0.1; @@ -89,7 +91,9 @@ std::shared_ptr create_debug_panel( }); panel->listenInterval(2.0f, []() { + fpsMinOld = fpsMin; fpsMin = fps; + fpsMaxOld = fpsMax; fpsMax = fps; }); @@ -108,7 +112,7 @@ std::shared_ptr create_debug_panel( panel->add(create_label(gui, []() { return L"fps: " + std::to_wstring(int(fpsAvgFast)) + L" / " + std::to_wstring(int(fpsAvgLong)) + L" / " + - std::to_wstring(fpsMin) + L" / " + std::to_wstring(fpsMax); + std::to_wstring(std::min(fpsMinOld, fpsMin)) + L" / " + std::to_wstring(std::max(fpsMaxOld, fpsMax)); })); panel->add(create_label(gui, []() { return L"meshes: " + std::to_wstring(MeshStats::meshesCount); From 976a9ff3507726cc14628c811ddcc27c11de69c1 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Tue, 23 Dec 2025 18:22:14 +0300 Subject: [PATCH 03/11] update: move avg consts into constants --- src/constants.hpp | 3 +++ src/frontend/debug_panel.cpp | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/constants.hpp b/src/constants.hpp index 1ae27a545..323106a12 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -73,3 +73,6 @@ inline const std::string SKELETONS_FOLDER = "skeletons"; inline const std::string POST_EFFECTS_FOLDER = "shaders/effects"; inline const std::string FONT_DEFAULT = "normal"; + +inline const float AVG_ALPHA = 0.1; +inline const float AVG_BETA = 0.01; \ No newline at end of file diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index 80f4904ee..12af68a2b 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -1,3 +1,4 @@ +#include "constants.hpp" #include "audio/audio.hpp" #include "delegates.hpp" #include "engine/Engine.hpp" @@ -74,8 +75,6 @@ std::shared_ptr create_debug_panel( static int fpsMaxOld = fpsMax; static float fpsAvgFast = fps; static float fpsAvgLong = fps; - static float fpsAvgAlpha = 0.1; - static float fpsAvgBeta = 0.01; static std::wstring fpsString = L""; static size_t lastTotalDownload = 0; @@ -86,8 +85,8 @@ std::shared_ptr create_debug_panel( fps = 1.0f / engine.getTime().getDelta(); fpsMin = std::min(fps, fpsMin); fpsMax = std::max(fps, fpsMax); - fpsAvgFast = fpsAvgFast * (1 - fpsAvgAlpha) + fps * fpsAvgAlpha; - fpsAvgLong = fpsAvgLong * (1 - fpsAvgBeta) + fps * fpsAvgBeta; + fpsAvgFast = fpsAvgFast * (1 - AVG_ALPHA) + fps * AVG_ALPHA; + fpsAvgLong = fpsAvgLong * (1 - AVG_BETA) + fps * AVG_BETA; }); panel->listenInterval(2.0f, []() { From bb885acb7fa282ee9b097834eb18ef96966eba85 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Tue, 23 Dec 2025 18:31:10 +0300 Subject: [PATCH 04/11] add: debug panel: draw-calls avg/min/max --- src/frontend/debug_panel.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index 12af68a2b..e278c8d78 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -76,6 +76,12 @@ std::shared_ptr create_debug_panel( static float fpsAvgFast = fps; static float fpsAvgLong = fps; static std::wstring fpsString = L""; + static int drawCalls = 0; + static int drawCallsMin = drawCalls; + static int drawCallsMinOld = drawCallsMin; + static int drawCallsMax = drawCalls; + static int drawCallsMaxOld = drawCallsMax; + static float drawCallsAvgLong = drawCalls; static size_t lastTotalDownload = 0; static size_t lastTotalUpload = 0; @@ -87,6 +93,10 @@ std::shared_ptr create_debug_panel( fpsMax = std::max(fps, fpsMax); fpsAvgFast = fpsAvgFast * (1 - AVG_ALPHA) + fps * AVG_ALPHA; fpsAvgLong = fpsAvgLong * (1 - AVG_BETA) + fps * AVG_BETA; + + drawCallsMin = std::min(drawCalls, drawCallsMin); + drawCallsMax = std::max(drawCalls, drawCallsMax); + drawCallsAvgLong = drawCallsAvgLong * (1 - AVG_BETA) + drawCalls * AVG_BETA; }); panel->listenInterval(2.0f, []() { @@ -94,6 +104,11 @@ std::shared_ptr create_debug_panel( fpsMin = fps; fpsMaxOld = fpsMax; fpsMax = fps; + + drawCallsMinOld = drawCallsMin; + drawCallsMin = drawCalls; + drawCallsMaxOld = drawCallsMax; + drawCallsMax = drawCalls; }); if (network) { @@ -117,9 +132,11 @@ std::shared_ptr create_debug_panel( return L"meshes: " + std::to_wstring(MeshStats::meshesCount); })); panel->add(create_label(gui, []() { - int drawCalls = MeshStats::drawCalls; + drawCalls = MeshStats::drawCalls; MeshStats::drawCalls = 0; - return L"draw-calls: " + std::to_wstring(drawCalls); + return L"draw-calls: " + std::to_wstring(int(drawCallsAvgLong)) + L" / " + + std::to_wstring(std::min(drawCallsMinOld, drawCallsMin)) + L" / " + + std::to_wstring(std::max(drawCallsMaxOld, drawCallsMax)); })); panel->add(create_label(gui, []() { return L"speakers: " + std::to_wstring(audio::count_speakers())+ From 84462643acd81e3d4c614a183998a1326373717c Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Tue, 23 Dec 2025 22:05:17 +0300 Subject: [PATCH 05/11] update: move back avg consts --- src/constants.hpp | 3 --- src/frontend/debug_panel.cpp | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/constants.hpp b/src/constants.hpp index 323106a12..1ae27a545 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -73,6 +73,3 @@ inline const std::string SKELETONS_FOLDER = "skeletons"; inline const std::string POST_EFFECTS_FOLDER = "shaders/effects"; inline const std::string FONT_DEFAULT = "normal"; - -inline const float AVG_ALPHA = 0.1; -inline const float AVG_BETA = 0.01; \ No newline at end of file diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index e278c8d78..16432a1fb 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -83,6 +83,9 @@ std::shared_ptr create_debug_panel( static int drawCallsMaxOld = drawCallsMax; static float drawCallsAvgLong = drawCalls; + inline const float AVG_ALPHA = 0.1; + inline const float AVG_BETA = 0.01; + static size_t lastTotalDownload = 0; static size_t lastTotalUpload = 0; static std::wstring netSpeedString = L""; From 36efc9aa49b2692659a76ebca5df09a8e3a442d7 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Tue, 23 Dec 2025 22:07:12 +0300 Subject: [PATCH 06/11] remove: debug panel: fpsAvgFast --- src/frontend/debug_panel.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index 16432a1fb..a3e96e8e4 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -73,7 +73,6 @@ std::shared_ptr create_debug_panel( static int fpsMinOld = fpsMin; static int fpsMax = fps; static int fpsMaxOld = fpsMax; - static float fpsAvgFast = fps; static float fpsAvgLong = fps; static std::wstring fpsString = L""; static int drawCalls = 0; @@ -83,8 +82,7 @@ std::shared_ptr create_debug_panel( static int drawCallsMaxOld = drawCallsMax; static float drawCallsAvgLong = drawCalls; - inline const float AVG_ALPHA = 0.1; - inline const float AVG_BETA = 0.01; + inline const float AVG_ALPHA = 0.01; static size_t lastTotalDownload = 0; static size_t lastTotalUpload = 0; @@ -94,12 +92,11 @@ std::shared_ptr create_debug_panel( fps = 1.0f / engine.getTime().getDelta(); fpsMin = std::min(fps, fpsMin); fpsMax = std::max(fps, fpsMax); - fpsAvgFast = fpsAvgFast * (1 - AVG_ALPHA) + fps * AVG_ALPHA; - fpsAvgLong = fpsAvgLong * (1 - AVG_BETA) + fps * AVG_BETA; + fpsAvgLong = fpsAvgLong * (1 - AVG_ALPHA) + fps * AVG_ALPHA; drawCallsMin = std::min(drawCalls, drawCallsMin); drawCallsMax = std::max(drawCalls, drawCallsMax); - drawCallsAvgLong = drawCallsAvgLong * (1 - AVG_BETA) + drawCalls * AVG_BETA; + drawCallsAvgLong = drawCallsAvgLong * (1 - AVG_ALPHA) + drawCalls * AVG_ALPHA; }); panel->listenInterval(2.0f, []() { @@ -128,7 +125,7 @@ std::shared_ptr create_debug_panel( } panel->add(create_label(gui, []() { - return L"fps: " + std::to_wstring(int(fpsAvgFast)) + L" / " + std::to_wstring(int(fpsAvgLong)) + L" / " + + return L"fps: " + std::to_wstring(int(fpsAvgLong)) + L" / " + std::to_wstring(std::min(fpsMinOld, fpsMin)) + L" / " + std::to_wstring(std::max(fpsMaxOld, fpsMax)); })); panel->add(create_label(gui, []() { From 21815a4fab4941dd483df603d69581312b0a4c36 Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Tue, 23 Dec 2025 22:10:54 +0300 Subject: [PATCH 07/11] fix: debug panel --- src/frontend/debug_panel.cpp | 138 +++++++++++++++++------------------ 1 file changed, 68 insertions(+), 70 deletions(-) diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index a3e96e8e4..834851aec 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -1,28 +1,34 @@ -#include "constants.hpp" +#include +#include +#include +#include +#include + #include "audio/audio.hpp" +#include "constants.hpp" +#include "content/Content.hpp" #include "delegates.hpp" #include "engine/Engine.hpp" -#include "settings.hpp" -#include "hud.hpp" -#include "content/Content.hpp" #include "graphics/core/Mesh.hpp" -#include "graphics/ui/elements/CheckBox.hpp" -#include "graphics/ui/elements/TextBox.hpp" -#include "graphics/ui/elements/TrackBar.hpp" -#include "graphics/ui/elements/InputBindBox.hpp" -#include "graphics/ui/GUI.hpp" -#include "graphics/render/WorldRenderer.hpp" -#include "graphics/render/ParticlesRenderer.hpp" #include "graphics/render/ChunksRenderer.hpp" #include "graphics/render/DebugLinesRenderer.hpp" +#include "graphics/render/ParticlesRenderer.hpp" +#include "graphics/render/WorldRenderer.hpp" +#include "graphics/ui/GUI.hpp" +#include "graphics/ui/elements/CheckBox.hpp" +#include "graphics/ui/elements/InputBindBox.hpp" +#include "graphics/ui/elements/TextBox.hpp" +#include "graphics/ui/elements/TrackBar.hpp" +#include "hud.hpp" #include "logic/scripting/scripting.hpp" #include "network/Network.hpp" +#include "objects/Entities.hpp" +#include "objects/Entity.hpp" +#include "objects/EntityDef.hpp" #include "objects/Player.hpp" #include "objects/Players.hpp" -#include "objects/Entities.hpp" -#include "objects/EntityDef.hpp" -#include "objects/Entity.hpp" #include "physics/Hitbox.hpp" +#include "settings.hpp" #include "util/stringutil.hpp" #include "voxels/Block.hpp" #include "voxels/Chunk.hpp" @@ -31,12 +37,6 @@ #include "world/Level.hpp" #include "world/World.hpp" -#include -#include -#include -#include -#include - using namespace gui; static std::shared_ptr