From d857e7326df7a3cd3c038246ab2274647c9749f1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 1 Nov 2026 01:30:39 +0300 Subject: [PATCH] add vertices count to debug panel --- src/frontend/debug_panel.cpp | 14 ++++++++++++++ src/graphics/core/Mesh.cpp | 3 ++- src/graphics/core/Mesh.hpp | 1 + src/graphics/core/Mesh.inl | 5 ++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index 84e85f3e9..86fa57de6 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -78,6 +78,8 @@ std::shared_ptr create_debug_panel( static int drawCallsMax = drawCalls; static std::wstring drawCallsAvgString = L""; static std::wstring drawCallsMinMaxString = L""; + static int verticesCount = 0; + static std::wstring verticesCountString = L""; static size_t lastTotalDownload = 0; static size_t lastTotalUpload = 0; @@ -151,6 +153,18 @@ std::shared_ptr create_debug_panel( panel->add(create_label(gui, []() { return drawCallsMinMaxString; })); + panel->add(create_label(gui, []() { + static int frame = 0; + verticesCount = std::max(verticesCount, MeshStats::vertices); + if (frame % 4 == 0) { + verticesCountString = + L"vertices: " + std::to_wstring(verticesCount); + } + frame++; + MeshStats::vertices = 0; + verticesCount = 0; + return verticesCountString; + })); panel->add(create_label(gui, []() { return L"speakers: " + std::to_wstring(audio::count_speakers()) + L" streams: " + std::to_wstring(audio::count_streams()); diff --git a/src/graphics/core/Mesh.cpp b/src/graphics/core/Mesh.cpp index f1f79f3e6..6cb2aa0d7 100644 --- a/src/graphics/core/Mesh.cpp +++ b/src/graphics/core/Mesh.cpp @@ -1,4 +1,5 @@ #include "graphics/core/Mesh.hpp" int MeshStats::meshesCount = 0; - int MeshStats::drawCalls = 0; \ No newline at end of file + int MeshStats::drawCalls = 0; + int MeshStats::vertices = 0; diff --git a/src/graphics/core/Mesh.hpp b/src/graphics/core/Mesh.hpp index 2ff15cc2a..f27fc4e2a 100644 --- a/src/graphics/core/Mesh.hpp +++ b/src/graphics/core/Mesh.hpp @@ -8,6 +8,7 @@ struct MeshStats { static int meshesCount; static int drawCalls; + static int vertices; }; struct IndexBufferData { diff --git a/src/graphics/core/Mesh.inl b/src/graphics/core/Mesh.inl index 4c6424dd1..b92c1b26e 100644 --- a/src/graphics/core/Mesh.inl +++ b/src/graphics/core/Mesh.inl @@ -126,17 +126,20 @@ void Mesh::draw(unsigned int primitive, int iboIndex) const { if (!ibos.empty()) { if (iboIndex < ibos.size()) { + size_t indexCount = ibos.at(iboIndex).indexCount; glBindVertexArray(vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibos[iboIndex].ibo); glDrawElements( - primitive, ibos.at(iboIndex).indexCount, GL_UNSIGNED_INT, nullptr + primitive, indexCount, GL_UNSIGNED_INT, nullptr ); glBindVertexArray(0); + MeshStats::vertices += indexCount; } } else if (vertexCount > 0) { glBindVertexArray(vao); glDrawArrays(primitive, 0, vertexCount); glBindVertexArray(0); + MeshStats::vertices += vertexCount; } }