diff options
author | sfan5 <sfan5@live.de> | 2020-05-19 20:45:02 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2020-05-20 22:55:51 +0200 |
commit | c47a680db7f3c2f241cc444a1257607492872412 (patch) | |
tree | 74476e22c213cb942c01a4d4f5ec804410df6bf0 /src/client | |
parent | 732c8008f495bc344957bd0ccbd4010adb939207 (diff) | |
download | minetest-c47a680db7f3c2f241cc444a1257607492872412.tar.gz minetest-c47a680db7f3c2f241cc444a1257607492872412.tar.bz2 minetest-c47a680db7f3c2f241cc444a1257607492872412.zip |
Stop wasting memory on identical textures when texture filtering is disabled
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/tile.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 0fa7a4ae2..d03588b2b 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -668,7 +668,14 @@ video::ITexture* TextureSource::getTexture(const std::string &name, u32 *id) video::ITexture* TextureSource::getTextureForMesh(const std::string &name, u32 *id) { - return getTexture(name + "^[applyfiltersformesh", id); + static thread_local bool filter_needed = + g_settings->getBool("texture_clean_transparent") || + ((m_setting_trilinear_filter || m_setting_bilinear_filter) && + g_settings->getS32("texture_min_size") > 1); + // Avoid duplicating texture if it won't actually change + if (filter_needed) + return getTexture(name + "^[applyfiltersformesh", id); + return getTexture(name, id); } Palette* TextureSource::getPalette(const std::string &name) @@ -1623,6 +1630,9 @@ bool TextureSource::generateImagePart(std::string part_of_name, */ else if (str_starts_with(part_of_name, "[applyfiltersformesh")) { + /* IMPORTANT: When changing this, getTextureForMesh() needs to be + * updated too. */ + // Apply the "clean transparent" filter, if configured. if (g_settings->getBool("texture_clean_transparent")) imageCleanTransparent(baseimg, 127); |