Browse Source

Set VBO hints in more places

sfan5 2 months ago
parent
commit
5280863300
5 changed files with 19 additions and 1 deletions
  1. 12 0
      src/client/content_cao.cpp
  2. 1 0
      src/client/hud.cpp
  3. 1 0
      src/client/minimap.cpp
  4. 1 0
      src/irrlicht_changes/CGUITTFont.cpp
  5. 4 1
      src/itemdef.cpp

+ 12 - 0
src/client/content_cao.cpp

@@ -818,6 +818,18 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
 				<<"\" not supported"<<std::endl;
 	}
 
+	/* Set VBO hint */
+	// - if shaders are disabled we modify the mesh often
+	// - sprites are also modified often
+	// - the wieldmesh sets its own hint
+	// - bone transformations do not need to modify the vertex data
+	if (m_enable_shaders && (m_meshnode || m_animated_meshnode)) {
+		if (m_meshnode)
+			m_meshnode->getMesh()->setHardwareMappingHint(scene::EHM_STATIC);
+		if (m_animated_meshnode)
+			m_animated_meshnode->getMesh()->setHardwareMappingHint(scene::EHM_STATIC);
+	}
+
 	/* don't update while punch texture modifier is active */
 	if (m_reset_textures_timer < 0)
 		updateTextures(m_current_texture_modifier);

+ 1 - 0
src/client/hud.cpp

@@ -135,6 +135,7 @@ Hud::Hud(Client *client, LocalPlayer *player,
 
 	m_rotation_mesh_buffer.getMaterial().Lighting = false;
 	m_rotation_mesh_buffer.getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+	m_rotation_mesh_buffer.setHardwareMappingHint(scene::EHM_STATIC);
 }
 
 Hud::~Hud()

+ 1 - 0
src/client/minimap.cpp

@@ -571,6 +571,7 @@ scene::SMeshBuffer *Minimap::getMinimapMeshBuffer()
 	buf->Indices[4] = 3;
 	buf->Indices[5] = 0;
 
+	buf->setHardwareMappingHint(scene::EHM_STATIC);
 	return buf;
 }
 

+ 1 - 0
src/irrlicht_changes/CGUITTFont.cpp

@@ -1046,6 +1046,7 @@ void CGUITTFont::createSharedPlane()
 	buf->append(vertices, 4, indices, 6);
 
 	shared_plane_.addMeshBuffer( buf );
+	shared_plane_.setHardwareMappingHint(EHM_STATIC);
 
 	shared_plane_ptr_ = &shared_plane_;
 	buf->drop(); //the addMeshBuffer method will grab it, so we can drop this ptr.

+ 4 - 1
src/itemdef.cpp

@@ -462,11 +462,14 @@ public:
 		// Create new ClientCached
 		auto cc = std::make_unique<ClientCached>();
 
-		// Create an inventory texture
 		cc->inventory_texture = NULL;
 		if (!inventory_image.empty())
 			cc->inventory_texture = tsrc->getTexture(inventory_image);
 		getItemMesh(client, item, &(cc->wield_mesh));
+		// note: vertices are modified frequently (see hud.cpp) so only indices
+		// can be mapped
+		if (auto mesh = cc->wield_mesh.mesh)
+			mesh->setHardwareMappingHint(scene::EHM_STATIC, scene::EBT_INDEX);
 
 		cc->palette = tsrc->getPalette(def.palette_image);