@@ -889,12 +889,9 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
889
889
static LLCachedControl<F32> texture_scale_min (gSavedSettings , " TextureScaleMinAreaFactor" , 0 .04f );
890
890
static LLCachedControl<F32> texture_scale_max (gSavedSettings , " TextureScaleMaxAreaFactor" , 25 .f );
891
891
892
- if (imagep->getType () == LLViewerTexture::LOD_TEXTURE && imagep->getBoostLevel () == LLViewerTexture::BOOST_NONE)
893
- { // reset max virtual size for unboosted LOD_TEXTURES
894
- // this is an alternative to decaying mMaxVirtualSize over time
895
- // that keeps textures from continously downrezzing and uprezzing in the background
896
- imagep->mMaxVirtualSize = 0 .f ;
897
- }
892
+
893
+ F32 max_vsize = 0 .f ;
894
+ bool on_screen = false ;
898
895
899
896
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
900
897
for (U32 i = 0 ; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
@@ -911,6 +908,8 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
911
908
F32 vsize = face->getPixelArea ();
912
909
bool in_frustum = face->calcPixelArea (cos_angle_to_view_dir, radius);
913
910
911
+ on_screen = in_frustum;
912
+
914
913
// Scale desired texture resolution higher or lower depending on texture scale
915
914
//
916
915
// Minimum usage examples: a 1024x1024 texture with aplhabet, runing string
@@ -936,15 +935,40 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
936
935
if (apply_bias)
937
936
{
938
937
F32 bias = powf (4 , LLViewerTexture::sDesiredDiscardBias - 1 .f );
939
- bias = (F32)llround (bias);
938
+ bias = (F32) llround (bias);
940
939
vsize /= bias;
941
940
}
942
941
943
- imagep-> addTextureStats ( vsize);
942
+ max_vsize = llmax (max_vsize, vsize);
944
943
}
945
944
}
946
945
}
947
946
947
+ if (imagep->getType () == LLViewerTexture::LOD_TEXTURE && imagep->getBoostLevel () == LLViewerTexture::BOOST_NONE)
948
+ { // conditionally reset max virtual size for unboosted LOD_TEXTURES
949
+ // this is an alternative to decaying mMaxVirtualSize over time
950
+ // that keeps textures from continously downrezzing and uprezzing in the background
951
+
952
+ if (LLViewerTexture::sDesiredDiscardBias > 2 .f ||
953
+ (!on_screen && LLViewerTexture::sDesiredDiscardBias > 1 .f ))
954
+ {
955
+ imagep->mMaxVirtualSize = 0 .f ;
956
+ }
957
+ }
958
+
959
+
960
+ imagep->addTextureStats (max_vsize);
961
+
962
+ #if 0
963
+ imagep->setDebugText(llformat("%d/%d - %d/%d -- %d/%d",
964
+ (S32)sqrtf(max_vsize),
965
+ (S32)sqrtf(imagep->mMaxVirtualSize),
966
+ imagep->getDiscardLevel(),
967
+ imagep->getDesiredDiscardLevel(),
968
+ imagep->getWidth(),
969
+ imagep->getFullWidth()));
970
+ #endif
971
+
948
972
// make sure to addTextureStats for any spotlights that are using this texture
949
973
for (S32 vi = 0 ; vi < imagep->getNumVolumes (LLRender::LIGHT_TEX); ++vi)
950
974
{
@@ -955,18 +979,26 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
955
979
F32 max_inactive_time = 20 .f ; // inactive time before deleting saved raw image
956
980
S32 min_refs = 3 ; // 1 for mImageList, 1 for mUUIDMap, and 1 for "entries" in updateImagesFetchTextures
957
981
982
+ F32 lazy_flush_timeout = 30 .f ; // delete unused images after 30 seconds
983
+
958
984
//
959
985
// Flush formatted images using a lazy flush
960
986
//
961
987
S32 num_refs = imagep->getNumRefs ();
962
988
if (num_refs <= min_refs && flush_images)
963
989
{
964
- // Remove the unused image from the image list
965
- deleteImage (imagep);
966
- return ;
990
+ if (imagep->getLastReferencedTimer ()->getElapsedTimeF32 () > lazy_flush_timeout)
991
+ {
992
+ // Remove the unused image from the image list
993
+ deleteImage (imagep);
994
+ return ;
995
+ }
967
996
}
968
997
else
969
998
{
999
+ // still referenced outside of image list, reset timer
1000
+ imagep->getLastReferencedTimer ()->reset ();
1001
+
970
1002
if (imagep->hasSavedRawImage ())
971
1003
{
972
1004
if (imagep->getElapsedLastReferencedSavedRawImageTime () > max_inactive_time)
0 commit comments