Skip to content

Instantly share code, notes, and snippets.

@PilzAdam
Created June 25, 2013 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PilzAdam/5862737 to your computer and use it in GitHub Desktop.
Save PilzAdam/5862737 to your computer and use it in GitHub Desktop.
diff --git a/minetest.conf.example b/minetest.conf.example
index 07063b9..fa03517 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -178,6 +178,8 @@
# The time in seconds it takes between repeated
# right clicks when holding the right mouse button
#repeat_rightclick_time = 0.25
+# Increases performance on modern GPUs a lot
+#enable_vbo = false
# will only work for servers which use remote_media setting
# and only for clients compiled with cURL
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 501a04f..43ebbad 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -121,6 +121,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_sound", "true");
settings->setDefault("sound_volume", "0.8");
settings->setDefault("desynchronize_mapblock_texture_animation", "true");
+ settings->setDefault("enable_vbo", "false");
settings->setDefault("mip_map", "false");
settings->setDefault("anisotropic_filter", "false");
diff --git a/src/main.cpp b/src/main.cpp
index eda9927..6586773 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1573,7 +1573,7 @@ int main(int argc, char *argv[])
This changes the minimum allowed number of vertices in a VBO.
Default is 500.
*/
- //driver->setMinHardwareBufferVertexCount(50);
+ driver->setMinHardwareBufferVertexCount(50);
// Create time getter
g_timegetter = new IrrlichtTimeGetter(device);
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index be88b19..a993c7c 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -1014,6 +1014,7 @@ static void updateAllFastFaceRows(MeshMakeData *data,
*/
MapBlockMesh::MapBlockMesh(MeshMakeData *data):
+ clearHardwareBuffer(true),
m_mesh(new scene::SMesh()),
m_gamedef(data->m_gamedef),
m_animation_force_timer(0), // force initial animation
@@ -1210,8 +1211,8 @@ static void updateAllFastFaceRows(MeshMakeData *data,
#endif
// Use VBO for mesh (this just would set this for ever buffer)
- // This will lead to infinite memory usage because or irrlicht.
- //m_mesh->setHardwareMappingHint(scene::EHM_STATIC);
+ if(g_settings->getBool("enable_vbo"))
+ m_mesh->setHardwareMappingHint(scene::EHM_STATIC);
/*
NOTE: If that is enabled, some kind of a queue to the main
@@ -1231,6 +1232,11 @@ static void updateAllFastFaceRows(MeshMakeData *data,
MapBlockMesh::~MapBlockMesh()
{
+ if(clearHardwareBuffer)
+ for(u32 i=0; i<m_mesh->getMeshBufferCount(); i++){
+ scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i);
+ m_gamedef->tsrc()->getDevice()->getVideoDriver()->removeHardwareBuffer(buf);
+ }
m_mesh->drop();
m_mesh = NULL;
}
diff --git a/src/mapblock_mesh.h b/src/mapblock_mesh.h
index c759840..3c58ad2 100644
--- a/src/mapblock_mesh.h
+++ b/src/mapblock_mesh.h
@@ -108,6 +108,8 @@ class MapBlockMesh
m_animation_force_timer--;
}
+ bool clearHardwareBuffer;
+
private:
scene::SMesh *m_mesh;
IGameDef *m_gamedef;
diff --git a/src/mapsector.cpp b/src/mapsector.cpp
index ebb050e..5cab72d 100644
--- a/src/mapsector.cpp
+++ b/src/mapsector.cpp
@@ -21,6 +21,7 @@
#include "jmutexautolock.h"
#ifndef SERVER
#include "client.h"
+#include "mapblock_mesh.h"
#endif
#include "exceptions.h"
#include "mapblock.h"
@@ -48,6 +49,10 @@ void MapSector::deleteBlocks()
for(std::map<s16, MapBlock*>::iterator i = m_blocks.begin();
i != m_blocks.end(); ++i)
{
+#ifndef SERVER
+ if(i->second->mesh)
+ i->second->mesh->clearHardwareBuffer = false;
+#endif
delete i->second;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment