Skip to content
Snippets Groups Projects
Commit b89c79e9 authored by Kahrl's avatar Kahrl
Browse files

Delay deleting replaced textures (m_texture_trash)

parent 9fe74a34
No related branches found
No related tags found
No related merge requests found
...@@ -440,6 +440,10 @@ class TextureSource : public IWritableTextureSource ...@@ -440,6 +440,10 @@ class TextureSource : public IWritableTextureSource
// Queued texture fetches (to be processed by the main thread) // Queued texture fetches (to be processed by the main thread)
RequestQueue<std::string, u32, u8, u8> m_get_texture_queue; RequestQueue<std::string, u32, u8, u8> m_get_texture_queue;
// Textures that have been overwritten with other ones
// but can't be deleted because the ITexture* might still be used
std::list<video::ITexture*> m_texture_trash;
}; };
IWritableTextureSource* createTextureSource(IrrlichtDevice *device) IWritableTextureSource* createTextureSource(IrrlichtDevice *device)
...@@ -485,6 +489,16 @@ TextureSource::~TextureSource() ...@@ -485,6 +489,16 @@ TextureSource::~TextureSource()
} }
m_atlaspointer_cache.clear(); m_atlaspointer_cache.clear();
for (std::list<video::ITexture*>::iterator iter =
m_texture_trash.begin(); iter != m_texture_trash.end();
iter++)
{
video::ITexture *t = *iter;
//cleanup trashed texture
driver->removeTexture(t);
}
infostream << "~TextureSource() "<< textures_before << "/" infostream << "~TextureSource() "<< textures_before << "/"
<< driver->getTextureCount() << std::endl; << driver->getTextureCount() << std::endl;
} }
...@@ -870,7 +884,7 @@ void TextureSource::rebuildImagesAndTextures() ...@@ -870,7 +884,7 @@ void TextureSource::rebuildImagesAndTextures()
sap->intsize = img->getDimension(); sap->intsize = img->getDimension();
if (t_old != 0) if (t_old != 0)
driver->removeTexture(t_old); m_texture_trash.push_back(t_old);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment