Skip to content

Commit 89512d4

Browse files
updateImageDecodePriority - Avoid Long Face Loop (#4019, #4021)
* updateImageDecodePriority - Avoid Long Face Loop To avoid running a long loop on thousands of faces, some textures were being set to a BOOST level to avoid the updateImageDecodePriority function entirely but this was causing many of them to never be deleted over the course of a user's travels. Instead of relying on BOOST, this commit changes the logic of the texture channel loop such that the face loop will only run if the number of faces is below the threshold. To do this, we move the face_count incrementing outside of the face loop into the channel loop and increment it using the getNumFaces function instead. We then check the face_count against the maximum number of faces we want to check and if it exceeds the number we set the number of faces for the face loop to check down to zero. This avoids branch prediction misses and the long face loop issue. Later, if the face_count is above the threshold, we assign the virtual size to the maximum. I personally believe the max_faces_to_check should be lower than 1024, but I left that value in for continuity. I use 64 faces as my max on my compiled version of the viewer without any noticeable issues for memory use. * updateImageDecodePriority - Face Loop Increment Swap Looks like compilers like knowing the incrementing in the for loop information for optimizations and parallelization. Sorry for the tiny commit. * updateImageDecodePriority - Suggested Cleanup Remove trailing white-space. Co-authored-by: Andrey Lihatskiy <[email protected]>
1 parent ac5d59b commit 89512d4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

indra/newview/llviewertexturelist.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
911911
bool on_screen = false;
912912

913913
U32 face_count = 0;
914+
U32 max_faces_to_check = 1024;
914915

915916
// get adjusted bias based on image resolution
916917
LLImageGL* img = imagep->getGLTexture();
@@ -923,13 +924,15 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
923924
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
924925
for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
925926
{
926-
for (S32 fi = 0; fi < imagep->getNumFaces(i); ++fi)
927+
face_count += imagep->getNumFaces(i);
928+
S32 faces_to_check = (face_count > max_faces_to_check) ? 0 : imagep->getNumFaces(i);
929+
930+
for (S32 fi = 0; fi < faces_to_check; ++fi)
927931
{
928932
LLFace* face = (*(imagep->getFaceList(i)))[fi];
929933

930934
if (face && face->getViewerObject())
931935
{
932-
++face_count;
933936
F32 radius;
934937
F32 cos_angle_to_view_dir;
935938

@@ -992,11 +995,10 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
992995
}
993996
}
994997

995-
if (face_count > 1024)
998+
if (face_count > max_faces_to_check)
996999
{ // this texture is used in so many places we should just boost it and not bother checking its vsize
9971000
// this is especially important because the above is not time sliced and can hit multiple ms for a single texture
998-
imagep->setBoostLevel(LLViewerFetchedTexture::BOOST_HIGH);
999-
// Do we ever remove it? This also sets texture nodelete!
1001+
max_vsize = MAX_IMAGE_AREA;
10001002
}
10011003

10021004
if (imagep->getType() == LLViewerTexture::LOD_TEXTURE && imagep->getBoostLevel() == LLViewerTexture::BOOST_NONE)

0 commit comments

Comments
 (0)