summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2012-04-13 17:20:53 -0700
committerMerov Linden <merov@lindenlab.com>2012-04-13 17:20:53 -0700
commitadf5b5c1efaed30dc043652b174d76c9088f4b18 (patch)
tree7ebd44c36f7777413406b4043ab436b492600e02
parent8778010feec5193c5ffc88d70e4a303aebaaaee4 (diff)
parent8b3703bd03487e6d70a793427ed1587b1cd86808 (diff)
Final pull from viewer-thx1138
-rw-r--r--indra/llimage/llimage.cpp4
-rw-r--r--indra/llimage/llimage.h4
-rwxr-xr-xindra/llimage/llimagej2c.cpp13
-rw-r--r--indra/llimage/llimagej2c.h1
-rwxr-xr-xindra/newview/app_settings/settings.xml33
-rw-r--r--indra/newview/llappviewer.cpp6
-rwxr-xr-xindra/newview/lltexturefetch.cpp13
-rw-r--r--indra/newview/llviewertexture.cpp33
-rw-r--r--indra/newview/llviewertexture.h2
-rw-r--r--indra/newview/llviewertexturelist.cpp25
-rw-r--r--indra/newview/llviewertexturelist.h2
11 files changed, 118 insertions, 18 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 7f95441075..6775b005f4 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -49,12 +49,14 @@
std::string LLImage::sLastErrorMessage;
LLMutex* LLImage::sMutex = NULL;
bool LLImage::sUseNewByteRange = false;
+S32 LLImage::sMinimalReverseByteRangePercent = 75;
LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ;
//static
-void LLImage::initClass(bool use_new_byte_range)
+void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent)
{
sUseNewByteRange = use_new_byte_range;
+ sMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent;
sMutex = new LLMutex(NULL);
LLImageBase::createPrivatePool() ;
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index a643e4d9f5..46e6d1a901 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -92,18 +92,20 @@ typedef enum e_image_codec
class LLImage
{
public:
- static void initClass(bool use_new_byte_range = false);
+ static void initClass(bool use_new_byte_range = false, S32 minimal_reverse_byte_range_percent = 75);
static void cleanupClass();
static const std::string& getLastError();
static void setLastError(const std::string& message);
static bool useNewByteRange() { return sUseNewByteRange; }
+ static S32 getReverseByteRangePercent() { return sMinimalReverseByteRangePercent; }
protected:
static LLMutex* sMutex;
static std::string sLastErrorMessage;
static bool sUseNewByteRange;
+ static S32 sMinimalReverseByteRangePercent;
};
//============================================================================
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 4e08f09b4e..a0e90b6b08 100755
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -289,8 +289,7 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r
S32 bytes;
S32 new_bytes = (S32) (sqrt((F32)(w*h))*(F32)(comp)*rate*1000.f/layer_factor);
S32 old_bytes = (S32)((F32)(w*h*comp)*rate);
- //llinfos << "Merov debug : w = " << w << ", h = " << h << ", c = " << comp << ", r = " << rate << ", d = " << discard_level << ", l = " << nb_layers << ", old = " << old_bytes << ", new = " << new_bytes << llendl;
- bytes = (LLImage::useNewByteRange() ? new_bytes : old_bytes);
+ bytes = (LLImage::useNewByteRange() && (new_bytes < old_bytes) ? new_bytes : old_bytes);
bytes = llmax(bytes, calcHeaderSizeJ2C());
return bytes;
}
@@ -329,8 +328,9 @@ S32 LLImageJ2C::calcDiscardLevelBytes(S32 bytes)
}
while (1)
{
- S32 bytes_needed = calcDataSize(discard_level); // virtual
- if (bytes >= bytes_needed - (bytes_needed>>2)) // For J2c, up the res at 75% of the optimal number of bytes
+ S32 bytes_needed = calcDataSize(discard_level);
+ // Use TextureReverseByteRange percent (see settings.xml) of the optimal size to qualify as correct rendering for the given discard level
+ if (bytes >= (bytes_needed*LLImage::getReverseByteRangePercent()/100))
{
break;
}
@@ -473,6 +473,7 @@ LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTester
mTotalTimeDecompression = 0.0f;
mTotalTimeCompression = 0.0f;
+ mRunTimeDecompression = 0.0f;
}
LLImageCompressionTester::~LLImageCompressionTester()
@@ -555,12 +556,14 @@ void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const
mTotalBytesInDecompression += bytesIn;
mRunBytesInDecompression += bytesIn;
mTotalBytesOutDecompression += bytesOut;
- if (mRunBytesInDecompression > (1000000))
+ //if (mRunBytesInDecompression > (1000000))
+ if ((mTotalTimeDecompression - mRunTimeDecompression) >= (5.0f))
{
// Output everything
outputTestResults();
// Reset the decompression data of the run
mRunBytesInDecompression = 0;
+ mRunTimeDecompression = mTotalTimeDecompression;
}
}
diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h
index 91c344d12f..42093e0e64 100644
--- a/indra/llimage/llimagej2c.h
+++ b/indra/llimage/llimagej2c.h
@@ -163,6 +163,7 @@ class LLImageCompressionTester : public LLMetricPerformanceTesterBasic
//
F32 mTotalTimeDecompression; // Total time spent in computing decompression
F32 mTotalTimeCompression; // Total time spent in computing compression
+ F32 mRunTimeDecompression; // Time in this run (we output every 5 sec in decompress)
};
#endif
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 5fc9c5d863..eb3fcc30ee 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -10631,6 +10631,28 @@
<key>Value</key>
<real>20.0</real>
</map>
+ <key>TextureCameraMotionThreshold</key>
+ <map>
+ <key>Comment</key>
+ <string>If the overall motion is lower than this value, textures will be loaded faster</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>F32</string>
+ <key>Value</key>
+ <integer>0.2</integer>
+ </map>
+ <key>TextureCameraMotionBoost</key>
+ <map>
+ <key>Comment</key>
+ <string>Progressive discard level decrement when the camera is still</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>S32</string>
+ <key>Value</key>
+ <integer>3</integer>
+ </map>
<key>TextureDecodeDisabled</key>
<map>
<key>Comment</key>
@@ -10719,6 +10741,17 @@
<key>Value</key>
<integer>2</integer>
</map>
+ <key>TextureReverseByteRange</key>
+ <map>
+ <key>Comment</key>
+ <string>Minimal percent of the optimal byte range allowed to render a given discard level</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>S32</string>
+ <key>Value</key>
+ <integer>50</integer>
+ </map>
<key>ThrottleBandwidthKBPS</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 9a52ee4312..a627f3868b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1339,13 +1339,11 @@ bool LLAppViewer::mainLoop()
ms_sleep(500);
}
- static const F64 FRAME_SLOW_THRESHOLD = 0.5; //2 frames per seconds
const F64 max_idle_time = llmin(.005*10.0*gFrameTimeSeconds, 0.005); // 5 ms a second
idleTimer.reset();
- bool is_slow = (frameTimer.getElapsedTimeF64() > FRAME_SLOW_THRESHOLD) ;
S32 total_work_pending = 0;
S32 total_io_pending = 0;
- while(!is_slow)//do not unpause threads if the frame rates are very low.
+ while(1)
{
S32 work_pending = 0;
S32 io_pending = 0;
@@ -1950,7 +1948,7 @@ bool LLAppViewer::initThreads()
static const bool enable_threads = true;
#endif
- LLImage::initClass(gSavedSettings.getBOOL("TextureNewByteRange"));
+ LLImage::initClass(gSavedSettings.getBOOL("TextureNewByteRange"),gSavedSettings.getS32("TextureReverseByteRange"));
LLVFSThread::initClass(enable_threads && false);
LLLFSThread::initClass(enable_threads && false);
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 5cc8de3d91..2e1b409fa7 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -846,6 +846,8 @@ void LLTextureFetchWorker::startWork(S32 param)
// Called from LLWorkerThread::processRequest()
bool LLTextureFetchWorker::doWork(S32 param)
{
+ static const F32 FETCHING_TIMEOUT = 120.f;//seconds
+
LLMutexLock lock(&mWorkMutex);
if ((mFetcher->isQuitting() || getFlags(LLWorkerClass::WCF_DELETE_REQUESTED)))
@@ -1152,7 +1154,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
//1, not openning too many file descriptors at the same time;
//2, control the traffic of http so udp gets bandwidth.
//
- static const S32 MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE = 8 ;
+ static const S32 MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE = 24 ;
if(mFetcher->getNumHTTPRequests() > MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE)
{
return false ; //wait.
@@ -1188,6 +1190,8 @@ bool LLTextureFetchWorker::doWork(S32 param)
bool res = false;
if (!mUrl.empty())
{
+ mRequestedTimer.reset();
+
mLoaded = FALSE;
mGetStatus = 0;
mGetReason.clear();
@@ -1346,6 +1350,13 @@ bool LLTextureFetchWorker::doWork(S32 param)
}
else
{
+ if(FETCHING_TIMEOUT < mRequestedTimer.getElapsedTimeF32())
+ {
+ //timeout, abort.
+ mState = DONE;
+ return true;
+ }
+
setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
return false;
}
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 2efc9ad4d0..d5b53f3cb1 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -88,6 +88,7 @@ S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0;
S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0;
S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ;
S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ;
+F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64 ;
const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez ;
@@ -546,7 +547,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ;
F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed();
- sCameraMovingDiscardBias = (S8)llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1) ;
+ sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1);
+ sCameraMovingDiscardBias = (S8)(sCameraMovingBias);
LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) &&
(BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ;
@@ -1888,6 +1890,8 @@ S32 LLViewerFetchedTexture::getCurrentDiscardLevelForFetching()
bool LLViewerFetchedTexture::updateFetch()
{
static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled");
+ static LLCachedControl<F32> sCameraMotionThreshold(gSavedSettings,"TextureCameraMotionThreshold");
+ static LLCachedControl<S32> sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost");
if(textures_decode_disabled)
{
return false ;
@@ -2050,18 +2054,24 @@ bool LLViewerFetchedTexture::updateFetch()
// make_request = false;
//}
- if(make_request)
+ if (make_request)
{
- //load the texture progressively.
+ // Load the texture progressively: we try not to rush to the desired discard too fast.
+ // If the camera is not moving, we do not tweak the discard level notch by notch but go to the desired discard with larger boosted steps
+ // This mitigates the "textures stay blurry" problem when loading while not killing the texture memory while moving around
S32 delta_level = (mBoostLevel > LLViewerTexture::BOOST_NONE) ? 2 : 1 ;
- if(current_discard < 0)
+ if (current_discard < 0)
{
desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level);
}
- else
+ else if (LLViewerTexture::sCameraMovingBias < sCameraMotionThreshold)
{
- desired_discard = llmax(desired_discard, current_discard - delta_level);
+ desired_discard = llmax(desired_discard, current_discard - sCameraMotionBoost);
}
+ else
+ {
+ desired_discard = llmax(desired_discard, current_discard - delta_level);
+ }
if (mIsFetching)
{
@@ -2129,6 +2139,17 @@ bool LLViewerFetchedTexture::updateFetch()
return mIsFetching ? true : false;
}
+void LLViewerFetchedTexture::forceToDeleteRequest()
+{
+ if (mHasFetcher)
+ {
+ LLAppViewer::getTextureFetch()->deleteRequest(getID(), true);
+ mHasFetcher = FALSE;
+ mIsFetching = FALSE ;
+ resetTextureStats();
+ }
+}
+
void LLViewerFetchedTexture::setIsMissingAsset()
{
if (mUrl.empty())
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 99053a8ccc..6ddff3e485 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -324,6 +324,7 @@ public:
static S32 sMaxTotalTextureMemInMegaBytes;
static S32 sMaxDesiredTextureMemInBytes ;
static S8 sCameraMovingDiscardBias;
+ static F32 sCameraMovingBias;
static S32 sMaxSculptRez ;
static S32 sMinLargeImageSize ;
static S32 sMaxSmallImageSize ;
@@ -490,6 +491,7 @@ public:
BOOL hasFetcher() const { return mHasFetcher;}
void setCanUseHTTP(bool can_use_http) {mCanUseHTTP = can_use_http;}
+ void forceToDeleteRequest();
protected:
/*virtual*/ void switchToCachedImage();
S32 getCurrentDiscardLevelForFetching() ;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 54ae519422..2008a884db 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -58,6 +58,7 @@
#include "pipeline.h"
#include "llappviewer.h"
#include "llxuiparser.h"
+#include "llagent.h"
////////////////////////////////////////////////////////////////////////////
@@ -597,6 +598,12 @@ static LLFastTimer::DeclareTimer FTM_IMAGE_STATS("Stats");
void LLViewerTextureList::updateImages(F32 max_time)
{
+ if(gAgent.getTeleportState() != LLAgent::TELEPORT_NONE)
+ {
+ clearFetchingRequests();
+ return;
+ }
+
LLAppViewer::getTextureFetch()->setTextureBandwidth(LLViewerStats::getInstance()->mTextureKBitStat.getMeanPerSec());
LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
@@ -659,6 +666,24 @@ void LLViewerTextureList::updateImages(F32 max_time)
}
}
+void LLViewerTextureList::clearFetchingRequests()
+{
+ if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
+ {
+ return;
+ }
+
+ for (image_priority_list_t::iterator iter = mImageList.begin();
+ iter != mImageList.end(); ++iter)
+ {
+ LLViewerFetchedTexture* image = *iter;
+ if(image->hasFetcher())
+ {
+ image->forceToDeleteRequest() ;
+ }
+ }
+}
+
void LLViewerTextureList::updateImagesDecodePriorities()
{
// Update the decode priority for N images each frame
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index e0a362596d..64e2c1f791 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -164,6 +164,8 @@ private:
// Implemented in header in case someone changes default params above. JC
LLViewerFetchedTexture* getImageFromHost(const LLUUID& image_id, LLHost host)
{ return getImage(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); }
+
+ void clearFetchingRequests();
public:
typedef std::set<LLPointer<LLViewerFetchedTexture> > image_list_t;