Added stat to monitor LODs blocked by non-ready meshes

This commit is contained in:
Marc Gilleron 2019-05-05 19:15:50 +01:00
parent fc4dee54d7
commit 310e2172ff
2 changed files with 18 additions and 2 deletions

View File

@ -682,6 +682,7 @@ void VoxelLodTerrain::_process() {
{ {
struct SubdivideAction { struct SubdivideAction {
VoxelLodTerrain *self; VoxelLodTerrain *self;
int non_meshed_blocks = 0;
bool can_do(LodOctree<bool>::Node *node, unsigned int lod_index) { bool can_do(LodOctree<bool>::Node *node, unsigned int lod_index) {
CRASH_COND(lod_index == 0); CRASH_COND(lod_index == 0);
@ -693,7 +694,11 @@ void VoxelLodTerrain::_process() {
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
Vector3i child_pos = LodOctree<bool>::get_child_position(node->position, i); Vector3i child_pos = LodOctree<bool>::get_child_position(node->position, i);
VoxelBlock *block = lod.map->get_block(child_pos); VoxelBlock *block = lod.map->get_block(child_pos);
if (block == nullptr || !block->has_been_meshed) { if (block == nullptr) {
return false;
}
if (!block->has_been_meshed) {
++non_meshed_blocks;
return false; return false;
} }
} }
@ -713,6 +718,7 @@ void VoxelLodTerrain::_process() {
struct UnsubdivideAction { struct UnsubdivideAction {
VoxelLodTerrain *self; VoxelLodTerrain *self;
int non_meshed_blocks = 0;
bool can_do(LodOctree<bool>::Node *node, unsigned int lod_index) { bool can_do(LodOctree<bool>::Node *node, unsigned int lod_index) {
// Can only unsubdivide if the parent mesh is ready // Can only unsubdivide if the parent mesh is ready
@ -721,8 +727,12 @@ void VoxelLodTerrain::_process() {
if (block == nullptr) { if (block == nullptr) {
// Ok, that block got unloaded? Might happen if you teleport away // Ok, that block got unloaded? Might happen if you teleport away
return true; return true;
}
if (block->has_been_meshed) {
return true;
} else { } else {
return block->has_been_meshed; ++non_meshed_blocks;
return false;
} }
} }
@ -744,6 +754,10 @@ void VoxelLodTerrain::_process() {
unsubdivide_action.self = this; unsubdivide_action.self = this;
_lod_octree.update(viewer_pos, subdivide_action, unsubdivide_action); _lod_octree.update(viewer_pos, subdivide_action, unsubdivide_action);
// Ideally, this stat should stabilize to zero.
// If not, something in the meshing process prevents LODs to properly show up and should be fixed.
_stats.blocked_lods = subdivide_action.non_meshed_blocks + unsubdivide_action.non_meshed_blocks;
} }
_stats.time_process_lod = profiling_clock.restart(); _stats.time_process_lod = profiling_clock.restart();
@ -762,6 +776,7 @@ Dictionary VoxelLodTerrain::get_stats() const {
d["provider"] = VoxelProviderThread::to_dictionary(_stats.provider); d["provider"] = VoxelProviderThread::to_dictionary(_stats.provider);
d["updater"] = VoxelMeshUpdater::to_dictionary(_stats.updater); d["updater"] = VoxelMeshUpdater::to_dictionary(_stats.updater);
d["process"] = process; d["process"] = process;
d["blocked_lods"] = _stats.blocked_lods;
return d; return d;
} }

View File

@ -61,6 +61,7 @@ public:
uint64_t time_request_blocks_to_update = 0; uint64_t time_request_blocks_to_update = 0;
uint64_t time_process_update_responses = 0; uint64_t time_process_update_responses = 0;
uint64_t time_process_lod = 0; uint64_t time_process_lod = 0;
int blocked_lods = 0;
}; };
Dictionary get_stats() const; Dictionary get_stats() const;