[DebugOverlay] Added "Chunks rendered" + "Chunk draw calls".
They show their value per tick, and those values are computed from last second.
This commit is contained in:
parent
7da33916d9
commit
26fbc8737c
@ -121,6 +121,8 @@ void ChunkRenderer::draw(gk::RenderTarget &target, gk::RenderStates states, cons
|
||||
}
|
||||
|
||||
void ChunkRenderer::drawChunks(gk::RenderTarget &target, gk::RenderStates states, const std::vector<std::pair<ClientChunk*, gk::Transform>> &chunks, const Sky *currentSky) const {
|
||||
++ClientChunk::frameCounter;
|
||||
|
||||
if(Config::isWireframeModeEnabled) glCheck(glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
|
||||
|
||||
glCheck(glEnable(GL_DEPTH_TEST));
|
||||
@ -156,6 +158,11 @@ void ChunkRenderer::drawChunks(gk::RenderTarget &target, gk::RenderStates states
|
||||
target.drawArrays(GL_TRIANGLES, it.first->getBufferOffset(layer), (GLsizei)verticesCount);
|
||||
gk::VertexArray::bind(nullptr);
|
||||
|
||||
if (!it.first->hasBeenDrawn())
|
||||
++ClientChunk::chunkDrawCounter;
|
||||
|
||||
++ClientChunk::chunkDrawCallCounter;
|
||||
|
||||
it.first->setHasBeenDrawn(true);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,11 @@ void DebugOverlay::update(bool printOpenGLInfo) {
|
||||
stream << '\n';
|
||||
stream << "Alive entities: " << m_world.scene().registry().alive();
|
||||
stream << '\n';
|
||||
stream << "Chunk updates: " << ClientChunk::chunkUpdatesPerSec;
|
||||
stream << "Chunk updates: " << ClientChunk::chunkUpdatesPerSec << "/sec";
|
||||
stream << '\n';
|
||||
stream << "Chunks rendered: " << ClientChunk::chunksRenderedPerFrame << "/frame";
|
||||
stream << '\n';
|
||||
stream << "Chunk draw calls: " << ClientChunk::chunkDrawCallPerFrame << "/frame";
|
||||
stream << '\n';
|
||||
stream << "Ticks: " << GameTime::getTicks();
|
||||
stream << '\n';
|
||||
|
@ -31,10 +31,19 @@
|
||||
#include "TextureAtlas.hpp"
|
||||
#include "World.hpp"
|
||||
|
||||
// Debug values only used in DebugOverlay
|
||||
u32 ClientChunk::chunkUpdatesPerSec = 0;
|
||||
u32 ClientChunk::chunkUpdateCounter = 0;
|
||||
u64 ClientChunk::chunkUpdateTime = 0;
|
||||
|
||||
u64 ClientChunk::chunksRenderedPerFrame = 0;
|
||||
u64 ClientChunk::chunkDrawCallPerFrame = 0;
|
||||
u32 ClientChunk::chunkDrawCounter = 0;
|
||||
u32 ClientChunk::chunkDrawCallCounter = 0;
|
||||
u64 ClientChunk::chunkDrawTime = 0;
|
||||
u64 ClientChunk::chunkDrawStartFrame = 0;
|
||||
u64 ClientChunk::frameCounter = 0;
|
||||
|
||||
ClientChunk::ClientChunk(s32 x, s32 y, s32 z, const Dimension &dimension, ClientWorld &world)
|
||||
: Chunk(x, y, z, (World &)world), m_world(world), m_dimension(dimension)
|
||||
{
|
||||
|
@ -71,10 +71,19 @@ class ClientChunk : public Chunk {
|
||||
|
||||
int debugTimesReceived = 0; // Only used by Minimap
|
||||
|
||||
// Debug values only used in DebugOverlay
|
||||
static u32 chunkUpdatesPerSec;
|
||||
static u32 chunkUpdateCounter;
|
||||
static u64 chunkUpdateTime;
|
||||
|
||||
static u64 chunksRenderedPerFrame;
|
||||
static u64 chunkDrawCallPerFrame;
|
||||
static u32 chunkDrawCounter;
|
||||
static u32 chunkDrawCallCounter;
|
||||
static u64 chunkDrawTime;
|
||||
static u64 chunkDrawStartFrame;
|
||||
static u64 frameCounter;
|
||||
|
||||
private:
|
||||
ClientWorld &m_world;
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
#include <algorithm> // std::max
|
||||
|
||||
#include <gk/resource/ResourceHandler.hpp>
|
||||
|
||||
#include "ClientCommandHandler.hpp"
|
||||
@ -52,12 +54,21 @@ ClientWorld::ClientWorld()
|
||||
void ClientWorld::update(bool allowWorldReload) {
|
||||
World::update();
|
||||
|
||||
// Debug values only used in DebugOverlay
|
||||
u64 time = std::time(nullptr);
|
||||
if (time > ClientChunk::chunkUpdateTime) {
|
||||
ClientChunk::chunkUpdatesPerSec = ClientChunk::chunkUpdateCounter;
|
||||
ClientChunk::chunkUpdateCounter = 0;
|
||||
ClientChunk::chunkUpdateTime = time;
|
||||
}
|
||||
if (time > ClientChunk::chunkDrawTime) {
|
||||
ClientChunk::chunksRenderedPerFrame = ClientChunk::chunkDrawCounter / std::max(1ul, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame);
|
||||
ClientChunk::chunkDrawCallPerFrame = ClientChunk::chunkDrawCallCounter / std::max(1ul, ClientChunk::frameCounter - ClientChunk::chunkDrawStartFrame);
|
||||
ClientChunk::chunkDrawCounter = 0;
|
||||
ClientChunk::chunkDrawCallCounter = 0;
|
||||
ClientChunk::chunkDrawTime = time;
|
||||
ClientChunk::chunkDrawStartFrame = ClientChunk::frameCounter;
|
||||
}
|
||||
|
||||
for (auto it = m_chunksToRemove.begin() ; it != m_chunksToRemove.end() ;) {
|
||||
removeChunk(*it);
|
||||
|
Loading…
x
Reference in New Issue
Block a user