diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2010-08-18 11:33:01 -0600 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2010-08-18 11:33:01 -0600 |
commit | 3ac134ec228d81a222d4df58be9577faa6757539 (patch) | |
tree | 263b1bc328fa1f8fb2c9164146d8b69946b2f592 /indra | |
parent | 0742f89208c016e5b9e73e471e669445bffde744 (diff) |
EXT-8673: FIXED: UDP texture loading is slower in 2.x viewers than 1.23.5
Improved the following:
1, make sure the texture callback queue is properly handled and cleaned in time;
2, estimate the LLVOTree pixel area more accurately;
3, eliminate the possibility of back and forth stopping/restarting a texture fetching
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/llface.cpp | 45 | ||||
-rw-r--r-- | indra/newview/llface.h | 1 | ||||
-rw-r--r-- | indra/newview/lltexturefetch.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewertexture.cpp | 136 | ||||
-rw-r--r-- | indra/newview/llviewertexture.h | 2 | ||||
-rw-r--r-- | indra/newview/llvoavatarself.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llvotree.cpp | 33 | ||||
-rw-r--r-- | indra/newview/llwearable.cpp | 7 |
9 files changed, 169 insertions, 73 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 810b2d9a1d..2130713d50 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1741,6 +1741,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>DebugAvatarLocalTexLoadedTime</key> + <map> + <key>Comment</key> + <string>Display time for loading avatar local textures.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>DebugBeaconLineWidth</key> <map> <key>Comment</key> diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index f299518474..db3d90e0a0 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1392,24 +1392,13 @@ F32 LLFace::getTextureVirtualSize() face_area = mPixelArea / llclamp(texel_area, 0.015625f, 128.f); } - if(face_area > LLViewerTexture::sMaxSmallImageSize) + face_area = LLFace::adjustPixelArea(mImportanceToCamera, face_area) ; + if(face_area > LLViewerTexture::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping. { - if(mImportanceToCamera < LEAST_IMPORTANCE) //if the face is not important, do not load hi-res. - { - static const F32 MAX_LEAST_IMPORTANCE_IMAGE_SIZE = 128.0f * 128.0f ; - face_area = llmin(face_area * 0.5f, MAX_LEAST_IMPORTANCE_IMAGE_SIZE) ; - } - else if(face_area > LLViewerTexture::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping. - { - if(mImportanceToCamera < LEAST_IMPORTANCE_FOR_LARGE_IMAGE)//if the face is not important, do not load hi-res. - { - face_area = LLViewerTexture::sMinLargeImageSize ; - } - else if(mTexture.notNull() && mTexture->isLargeImage()) - { - face_area *= adjustPartialOverlapPixelArea(cos_angle_to_view_dir, radius ); - } - } + if(mImportanceToCamera > LEAST_IMPORTANCE_FOR_LARGE_IMAGE && mTexture.notNull() && mTexture->isLargeImage()) + { + face_area *= adjustPartialOverlapPixelArea(cos_angle_to_view_dir, radius ); + } } setVirtualSize(face_area) ; @@ -1536,6 +1525,28 @@ F32 LLFace::calcImportanceToCamera(F32 cos_angle_to_view_dir, F32 dist) return importance ; } +//static +F32 LLFace::adjustPixelArea(F32 importance, F32 pixel_area) +{ + if(pixel_area > LLViewerTexture::sMaxSmallImageSize) + { + if(importance < LEAST_IMPORTANCE) //if the face is not important, do not load hi-res. + { + static const F32 MAX_LEAST_IMPORTANCE_IMAGE_SIZE = 128.0f * 128.0f ; + pixel_area = llmin(pixel_area * 0.5f, MAX_LEAST_IMPORTANCE_IMAGE_SIZE) ; + } + else if(pixel_area > LLViewerTexture::sMinLargeImageSize) //if is large image, shrink face_area by considering the partial overlapping. + { + if(importance < LEAST_IMPORTANCE_FOR_LARGE_IMAGE)//if the face is not important, do not load hi-res. + { + pixel_area = LLViewerTexture::sMinLargeImageSize ; + } + } + } + + return pixel_area ; +} + BOOL LLFace::verify(const U32* indices_array) const { BOOL ok = TRUE; diff --git a/indra/newview/llface.h b/indra/newview/llface.h index de533a6864..8f17bc3178 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -214,6 +214,7 @@ private: BOOL calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) ; public: static F32 calcImportanceToCamera(F32 to_view_dir, F32 dist); + static F32 LLFace::adjustPixelArea(F32 importance, F32 pixel_area) ; public: diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index f4899d0d5d..bd0a43cd54 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -597,7 +597,7 @@ bool LLTextureFetchWorker::doWork(S32 param) return true; // abort } } - if(mImagePriority < 1.0f) + if(mImagePriority < F_ALMOST_ZERO) { if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR) { diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 9b3243a1bc..7a0f77a7e4 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1489,59 +1489,63 @@ void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height) //virtual void LLViewerFetchedTexture::processTextureStats() { - if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0) //force to refetch the texture. - { - mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel) ; - } - if(mFullyLoaded) { - if(mDesiredDiscardLevel <= mMinDesiredDiscardLevel)//already loaded + if(mDesiredDiscardLevel > mMinDesiredDiscardLevel)//need to load more { - return ; + mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ; + mFullyLoaded = FALSE ; } - mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ; - mFullyLoaded = FALSE ; - return ; - } - - updateVirtualSize() ; - - static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes"); - - if (textures_fullres) - { - mDesiredDiscardLevel = 0; - } - else if(!mFullWidth || !mFullHeight) - { - mDesiredDiscardLevel = getMaxDiscardLevel() ; } else - { - if(!mKnownDrawWidth || !mKnownDrawHeight || mFullWidth <= mKnownDrawWidth || mFullHeight <= mKnownDrawHeight) + { + updateVirtualSize() ; + + static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes"); + + if (textures_fullres) { - if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) + mDesiredDiscardLevel = 0; + } + else if(!mFullWidth || !mFullHeight) + { + mDesiredDiscardLevel = getMaxDiscardLevel() ; + } + else + { + if(!mKnownDrawWidth || !mKnownDrawHeight || mFullWidth <= mKnownDrawWidth || mFullHeight <= mKnownDrawHeight) { - mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 + if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) + { + mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 + } + else + { + mDesiredDiscardLevel = 0; + } } - else + else if(mKnownDrawSizeChanged)//known draw size is set + { + mDesiredDiscardLevel = (S8)llmin(log((F32)mFullWidth / mKnownDrawWidth) / log_2, + log((F32)mFullHeight / mKnownDrawHeight) / log_2) ; + mDesiredDiscardLevel = llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel()) ; + mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ; + } + mKnownDrawSizeChanged = FALSE ; + + if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel)) { - mDesiredDiscardLevel = 0; + mFullyLoaded = TRUE ; } } - else if(mKnownDrawSizeChanged)//known draw size is set - { - mDesiredDiscardLevel = (S8)llmin(log((F32)mFullWidth / mKnownDrawWidth) / log_2, - log((F32)mFullHeight / mKnownDrawHeight) / log_2) ; - mDesiredDiscardLevel = llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel()) ; - mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ; - } - mKnownDrawSizeChanged = FALSE ; - - if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel)) + } + + if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0) //force to refetch the texture. + { + mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel) ; + if(getDiscardLevel() < 0 || getDiscardLevel() > mDesiredDiscardLevel) { - mFullyLoaded = TRUE ; + mFullyLoaded = FALSE ; } } } @@ -1724,6 +1728,11 @@ void LLViewerFetchedTexture::setDecodePriority(F32 priority) llassert(!mInImageList); mDecodePriority = priority; + + if(mDecodePriority < F_ALMOST_ZERO) + { + mStopFetchingTimer.reset() ; + } } void LLViewerFetchedTexture::setAdditionalDecodePriority(F32 priority) @@ -1915,7 +1924,12 @@ bool LLViewerFetchedTexture::updateFetch() // llinfos << "Calling updateRequestPriority() with decode_priority = 0.0f" << llendl; // calcDecodePriority(); // } - LLAppViewer::getTextureFetch()->updateRequestPriority(mID, decode_priority); + static const F32 MAX_HOLD_TIME = 5.0f ; //seconds to wait before canceling fecthing if decode_priority is 0.f. + if(decode_priority > 0.0f || mStopFetchingTimer.getElapsedTimeF32() > MAX_HOLD_TIME) + { + mStopFetchingTimer.reset() ; + LLAppViewer::getTextureFetch()->updateRequestPriority(mID, decode_priority); + } } } @@ -2075,6 +2089,36 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call } } +void LLViewerFetchedTexture::clearCallbackEntryList() +{ + if(mLoadedCallbackList.empty()) + { + return ; + } + + for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); + iter != mLoadedCallbackList.end(); ) + { + LLLoadedCallbackEntry *entryp = *iter; + + // We never finished loading the image. Indicate failure. + // Note: this allows mLoadedCallbackUserData to be cleaned up. + entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData); + iter = mLoadedCallbackList.erase(iter) ; + delete entryp; + } + gTextureList.mCallbackList.erase(this); + + mMinDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; + mLoadedCallbackDesiredDiscardLevel = S8_MAX ; + if(mForceToSaveRawImage) + { + destroySavedRawImage() ; + } + + return ; +} + void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::source_callback_list_t* callback_list) { if(mLoadedCallbackList.empty() || !callback_list) @@ -2082,7 +2126,7 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so return ; } - S32 desired_discard = INVALID_DISCARD_LEVEL ; + S32 desired_discard = S8_MAX ; S32 desired_raw_discard = INVALID_DISCARD_LEVEL ; for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); iter != mLoadedCallbackList.end(); ) @@ -2652,6 +2696,12 @@ void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard, bool from_ } void LLViewerFetchedTexture::destroySavedRawImage() { + clearCallbackEntryList() ; + //if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0 && mDesiredSavedRawDiscardLevel < getDiscardLevel()) + //{ + // return ; //can not destroy the saved raw image before it is fully fetched, otherwise causing callbacks hanging there. + //} + mSavedRawImage = NULL ; mForceToSaveRawImage = FALSE ; mSavedRawDiscardLevel = -1 ; @@ -2902,7 +2952,7 @@ BOOL LLViewerLODTexture::isUpdateFrozen() void LLViewerLODTexture::processTextureStats() { updateVirtualSize() ; - + static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes"); if (textures_fullres) diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 1f0d760daf..6adfd2bae4 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -392,6 +392,7 @@ public: void unpauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list); bool doLoadedCallbacks(); void deleteCallbackEntry(const LLLoadedCallbackEntry::source_callback_list_t* callback_list); + void clearCallbackEntryList() ; void addToCreateTexture(); @@ -562,6 +563,7 @@ protected: // Timers LLFrameTimer mLastPacketTimer; // Time since last packet. + LLFrameTimer mStopFetchingTimer; // Time since mDecodePriority == 0.f. BOOL mInImageList; // TRUE if image is in list (in which case don't reset priority!) BOOL mNeedsCreateTexture; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 73ea629bc3..338b3155cc 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2145,6 +2145,11 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid ) void LLVOAvatarSelf::outputRezDiagnostics() const { + if(!gSavedSettings.getBOOL("DebugAvatarLocalTexLoadedTime")) + { + return ; + } + const F32 final_time = mDebugSelfLoadTimer.getElapsedTimeF32(); llinfos << "REZTIME: Myself rez stats:" << llendl; llinfos << "\t Time from avatar creation to load wearables: " << (S32)mDebugTimeWearablesLoaded << llendl; diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 0efe6682be..9c08c0eec1 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -448,22 +448,35 @@ void LLVOTree::render(LLAgent &agent) void LLVOTree::setPixelAreaAndAngle(LLAgent &agent) { - // First calculate values as for any other object (for mAppAngle) - LLViewerObject::setPixelAreaAndAngle(agent); - - // Re-calculate mPixelArea accurately + LLVector3 center = getPositionAgent();//center of tree. + LLVector3 viewer_pos_agent = gAgentCamera.getCameraPositionAgent(); + LLVector3 lookAt = center - viewer_pos_agent; + F32 dist = lookAt.normVec() ; + F32 cos_angle_to_view_dir = lookAt * LLViewerCamera::getInstance()->getXAxis() ; - // This should be the camera's center, as soon as we move to all region-local. - LLVector3 relative_position = getPositionAgent() - gAgentCamera.getCameraPositionAgent(); - F32 range_squared = relative_position.lengthSquared() ; + F32 range = dist - getMinScale()/2; + if (range < F_ALMOST_ZERO || isHUDAttachment()) // range == zero + { + mAppAngle = 180.f; + } + else + { + mAppAngle = (F32) atan2( getMaxScale(), range) * RAD_TO_DEG; + } F32 max_scale = mBillboardScale * getMaxScale(); F32 area = max_scale * (max_scale*mBillboardRatio); - // Compute pixels per meter at the given range - F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / tan(LLViewerCamera::getInstance()->getView()); + F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / (tan(LLViewerCamera::getInstance()->getView()) * dist); + mPixelArea = pixels_per_meter * pixels_per_meter * area ; + + F32 importance = LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist) ; + mPixelArea = LLFace::adjustPixelArea(importance, mPixelArea) ; + if (mPixelArea > LLViewerCamera::getInstance()->getScreenPixelArea()) + { + mAppAngle = 180.f; + } - mPixelArea = (pixels_per_meter) * (pixels_per_meter) * area / range_squared; #if 0 // mAppAngle is a bit of voodoo; // use the one calculated LLViewerObject::setPixelAreaAndAngle above diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp index c5042ca016..1209b60679 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -52,6 +52,7 @@ #include "llvoavatarself.h" #include "llvoavatardefines.h" #include "llwearable.h" +#include "llviewercontrol.h" using namespace LLVOAvatarDefines; @@ -444,8 +445,10 @@ BOOL LLWearable::importFile( LLFILE* file ) delete mSavedTEMap[te]; } - image->setLoadedCallback(LLVOAvatarSelf::debugOnTimingLocalTexLoaded,0,TRUE,FALSE, new LLVOAvatarSelf::LLAvatarTexData(id, (LLVOAvatarDefines::ETextureIndex)te), NULL); - + if(gSavedSettings.getBOOL("DebugAvatarLocalTexLoadedTime")) + { + image->setLoadedCallback(LLVOAvatarSelf::debugOnTimingLocalTexLoaded,0,TRUE,FALSE, new LLVOAvatarSelf::LLAvatarTexData(id, (LLVOAvatarDefines::ETextureIndex)te), NULL); + } LLUUID textureid(text_buffer); mTEMap[te] = new LLLocalTextureObject(image, textureid); mSavedTEMap[te] = new LLLocalTextureObject(image, textureid); |