summaryrefslogtreecommitdiff
path: root/src/client/game.cpp
diff options
context:
space:
mode:
authorLars <larsh@apache.org>2020-10-15 00:06:37 -0700
committerlhofhansl <larsh@apache.org>2020-10-17 13:22:30 -0700
commit738f62421872c0be5fcd483ad4573e5d879e7418 (patch)
tree27b2921268d0fff35567627d29da747e9b73b53a /src/client/game.cpp
parented22260822086f84016aa8384c3174bfc6d1739d (diff)
downloadminetest-738f62421872c0be5fcd483ad4573e5d879e7418.tar.gz
minetest-738f62421872c0be5fcd483ad4573e5d879e7418.tar.bz2
minetest-738f62421872c0be5fcd483ad4573e5d879e7418.zip
Periodically release all mesh HW buffers to avoid an Irrlicht bottleneck.
Diffstat (limited to 'src/client/game.cpp')
-rw-r--r--src/client/game.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 309a8e194..a7e367ae2 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -909,6 +909,7 @@ private:
bool m_does_lost_focus_pause_game = false;
+ int m_reset_HW_buffer_counter = 0;
#ifdef __ANDROID__
bool m_cache_hold_aux1;
bool m_android_chat_open;
@@ -3686,7 +3687,6 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
camera->setDigging(0); // Dig animation
}
-
void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
const CameraOrientation &cam)
{
@@ -3937,6 +3937,27 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
/*
End scene
*/
+ if (++m_reset_HW_buffer_counter > 500) {
+ /*
+ Periodically remove all mesh HW buffers.
+
+ Work around for a quirk in Irrlicht where a HW buffer is only
+ released after 20000 iterations (triggered from endScene()).
+
+ Without this, all loaded but unused meshes will retain their HW
+ buffers for at least 5 minutes, at which point looking up the HW buffers
+ becomes a bottleneck and the framerate drops (as much as 30%).
+
+ Tests showed that numbers between 50 and 1000 are good, so picked 500.
+ There are no other public Irrlicht APIs that allow interacting with the
+ HW buffers without tracking the status of every individual mesh.
+
+ The HW buffers for _visible_ meshes will be reinitialized in the next frame.
+ */
+ infostream << "Game::updateFrame(): Removing all HW buffers." << std::endl;
+ driver->removeAllHardwareBuffers();
+ m_reset_HW_buffer_counter = 0;
+ }
driver->endScene();
stats->drawtime = tt_draw.stop(true);