diff options
author | cosmic-linden <111533034+cosmic-linden@users.noreply.github.com> | 2024-04-10 16:43:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-10 16:43:20 -0700 |
commit | 5156347c4dd1798b4fdc173cfa9377e09ec193cb (patch) | |
tree | 1835a3f81988dac21c69bdf7a69b165ae6f39456 | |
parent | 7ef2b43802da07b8f30b455448cb84bd1c26320d (diff) | |
parent | b7b962affd12d8559d3dcf8a70533548df8d6f25 (diff) |
Merge pull request #1194 from secondlife/v-1163
viewer#1163: Avoid terrain texture memory leak
-rw-r--r-- | indra/newview/llvlcomposition.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index 234b24e440..6c0691c6a9 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -69,6 +69,11 @@ namespace if (!tex) { return; } tex->setBoostLevel(LLGLTexture::BOOST_NONE); tex->setMinDiscardLevel(MAX_DISCARD_LEVEL + 1); + + if (tex->getTextureState() == LLGLTexture::NO_DELETE) + { + tex->forceActive(); + } } void unboost_minimap_material(LLPointer<LLFetchedGLTFMaterial>& mat) @@ -91,6 +96,11 @@ LLTerrainMaterials::LLTerrainMaterials() LLTerrainMaterials::~LLTerrainMaterials() { + for (S32 i = 0; i < ASSET_COUNT; ++i) + { + unboost_minimap_texture(mDetailTextures[i]); + unboost_minimap_material(mDetailMaterials[i]); + } } BOOL LLTerrainMaterials::generateMaterials() @@ -131,6 +141,12 @@ LLPointer<LLViewerFetchedTexture> fetch_terrain_texture(const LLUUID& id) void LLTerrainMaterials::setDetailAssetID(S32 asset, const LLUUID& id) { + // *NOTE: If there were multiple terrain swatches using the same asset + // ID, the asset still in use will be temporarily unboosted. + // It will be boosted again during terrain rendering. + unboost_minimap_texture(mDetailTextures[asset]); + unboost_minimap_material(mDetailMaterials[asset]); + // This is terrain texture, but we are not setting it as BOOST_TERRAIN // since we will be manipulating it later as needed. mDetailTextures[asset] = fetch_terrain_texture(id); |