diff options
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rwxr-xr-x | indra/newview/lltexturefetch.cpp | 750 |
1 files changed, 659 insertions, 91 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 7e6dfbc9d9..4f635bf855 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -151,7 +151,7 @@ public: /*virtual*/ bool doWork(S32 param); // Called from LLWorkerThread::processRequest() /*virtual*/ void finishWork(S32 param, bool completed); // called from finishRequest() (WORK THREAD) /*virtual*/ bool deleteOK(); // called from update() (WORK THREAD) - + ~LLTextureFetchWorker(); // void relese() { --mActiveCount; } @@ -196,6 +196,8 @@ private: bool processSimulatorPackets(); bool writeToCacheComplete(); + void removeFromHTTPQueue(); + void lockWorkMutex() { mWorkMutex.lock(); } void unlockWorkMutex() { mWorkMutex.unlock(); } @@ -275,6 +277,8 @@ private: S32 mRetryAttempt; S32 mActiveCount; U32 mGetStatus; + U32 mHTTPHandle; + F32 mDelay; std::string mGetReason; // Work Data @@ -328,6 +332,7 @@ public: mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, timeNow); } + S32 data_size = 0; lldebugs << "HTTP COMPLETE: " << mID << llendl; LLTextureFetchWorker* worker = mFetcher->getWorker(mID); if (worker) @@ -349,7 +354,7 @@ public: // llwarns << "CURL GET FAILED, status:" << status << " reason:" << reason << llendl; } - S32 data_size = worker->callbackHttpGet(channels, buffer, partial, success); + data_size = worker->callbackHttpGet(channels, buffer, partial, success); if(log_texture_traffic && data_size > 0) { @@ -359,9 +364,7 @@ public: gTotalTextureBytesPerBoostLevel[tex->getBoostLevel()] += data_size ; } } - - mFetcher->removeFromHTTPQueue(mID, data_size); - + if (worker->mMetricsStartTime) { LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE, @@ -376,9 +379,10 @@ public: } else { - mFetcher->removeFromHTTPQueue(mID); - llwarns << "Worker not found: " << mID << llendl; + llwarns << "Worker not found: " << mID << llendl; } + + mFetcher->getCurlRequest().completeRequest(data_size); } virtual bool followRedir() @@ -692,10 +696,12 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher, mLastPacket(-1), mTotalPackets(0), mImageCodec(IMG_CODEC_INVALID), - mMetricsStartTime(0) + mMetricsStartTime(0), + mHTTPHandle(0), + mDelay(-1.f) { mCanUseNET = mUrl.empty() ; - + calcWorkPriority(); mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL; // llinfos << "Create: " << mID << " mHost:" << host << " Discard=" << discard << llendl; @@ -726,7 +732,19 @@ LLTextureFetchWorker::~LLTextureFetchWorker() mFormattedImage = NULL; clearPackets(); unlockWorkMutex(); - mFetcher->removeFromHTTPQueue(mID); + + removeFromHTTPQueue(); +} + +void LLTextureFetchWorker::removeFromHTTPQueue() +{ + if(mHTTPHandle > 0) + { + llassert_always(mState == WAIT_HTTP_REQ); + + mFetcher->getCurlRequest().removeRequest(mHTTPHandle); + mHTTPHandle = 0; + } } void LLTextureFetchWorker::clearPackets() @@ -824,6 +842,7 @@ void LLTextureFetchWorker::setImagePriority(F32 priority) mImagePriority = priority; calcWorkPriority(); U32 work_priority = mWorkPriority | (getPriority() & LLWorkerThread::PRIORITY_HIGHBITS); + mFetcher->getCurlRequest().updatePriority(mHTTPHandle, mWorkPriority); setPriority(work_priority); } } @@ -912,6 +931,10 @@ bool LLTextureFetchWorker::doWork(S32 param) mCacheWriteHandle = LLTextureCache::nullHandle(); mState = LOAD_FROM_TEXTURE_CACHE; mInCache = FALSE; +<<<<<<< local + mDelay = -1.f; +======= +>>>>>>> other mDesiredSize = llmax(mDesiredSize, TEXTURE_CACHE_ENTRY_SIZE); // min desired size is TEXTURE_CACHE_ENTRY_SIZE LL_DEBUGS("Texture") << mID << ": Priority: " << llformat("%8.0f",mImagePriority) << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL; @@ -927,7 +950,7 @@ bool LLTextureFetchWorker::doWork(S32 param) S32 size = mDesiredSize - offset; if (size <= 0) { - mState = CACHE_POST; + mState = CACHE_POST; //have enough data, will fall to decode return false; } mFileSize = 0; @@ -944,7 +967,7 @@ bool LLTextureFetchWorker::doWork(S32 param) offset, size, responder); mCacheReadTimer.reset(); } - else if (mUrl.empty()) + else if (mUrl.empty() && mFetcher->canLoadFromCache()) { setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it @@ -953,7 +976,7 @@ bool LLTextureFetchWorker::doWork(S32 param) offset, size, responder); mCacheReadTimer.reset(); } - else if(mCanUseHTTP) + else if(!mUrl.empty() && mCanUseHTTP) { if (!(mUrl.compare(0, 7, "http://") == 0)) { @@ -981,6 +1004,9 @@ bool LLTextureFetchWorker::doWork(S32 param) } else { + // + //This should never happen + // return false; } } @@ -1020,6 +1046,7 @@ bool LLTextureFetchWorker::doWork(S32 param) LL_DEBUGS("Texture") << mID << ": Not in Cache" << LL_ENDL; mState = LOAD_FROM_NETWORK; } + // fall through LLTextureFetch::sCacheHitRate.addValue(0.f); } @@ -1060,7 +1087,7 @@ bool LLTextureFetchWorker::doWork(S32 param) } if (mCanUseHTTP && !mUrl.empty()) { - mState = LLTextureFetchWorker::SEND_HTTP_REQ; + mState = SEND_HTTP_REQ; setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); if(mWriteToCacheState != NOT_WRITE) { @@ -1156,17 +1183,6 @@ bool LLTextureFetchWorker::doWork(S32 param) { if(mCanUseHTTP) { - //NOTE: - //control the number of the http requests issued for: - //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 ; - if(mFetcher->getNumHTTPRequests() > MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE) - { - return false ; //wait. - } - mFetcher->removeFromNetworkQueue(this, false); S32 cur_size = 0; @@ -1179,6 +1195,7 @@ bool LLTextureFetchWorker::doWork(S32 param) { // We already have all the data, just decode it mLoadedDiscard = mFormattedImage->getDiscardLevel(); + setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); mState = DECODE_IMAGE; return false; } @@ -1209,7 +1226,6 @@ bool LLTextureFetchWorker::doWork(S32 param) setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); mState = WAIT_HTTP_REQ; - mFetcher->addToHTTPQueue(mID); if (! mMetricsStartTime) { mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp(); @@ -1221,8 +1237,16 @@ bool LLTextureFetchWorker::doWork(S32 param) // Will call callbackHttpGet when curl request completes std::vector<std::string> headers; headers.push_back("Accept: image/x-j2c"); - res = mFetcher->mCurlGetRequest->getByteRange(mUrl, headers, offset, mRequestedSize, - new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, offset, true)); + // If we try to fetch the whole file, we set the size to 0 so that we generate the correct curl range request + // Note: it looks a bit hacky but we need to limit this (size==0) to mean "whole file" to HTTP only as it messes up UDP fetching + if ((offset+mRequestedSize) == MAX_IMAGE_DATA_SIZE) + { + mRequestedSize = 0; + } + mHTTPHandle = mFetcher->mCurlGetRequest->getByteRange(mUrl, headers, offset, mRequestedSize, mWorkPriority, + new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, offset, true), mDelay); + mDelay = -1.f; //reset + res = true; } if (!res) { @@ -1269,12 +1293,15 @@ bool LLTextureFetchWorker::doWork(S32 param) ++mHTTPFailCount; max_attempts = mHTTPFailCount+1; // Keep retrying LL_INFOS_ONCE("Texture") << "Texture server busy (503): " << mUrl << LL_ENDL; + mDelay = 2.0f; //delay 2 second to re-issue the http request } else { const S32 HTTP_MAX_RETRY_COUNT = 3; max_attempts = HTTP_MAX_RETRY_COUNT + 1; ++mHTTPFailCount; + mDelay = 2.0f; //delay 2 second to re-issue the http request + llinfos << "HTTP GET failed for: " << mUrl << " Status: " << mGetStatus << " Reason: '" << mGetReason << "'" << " Attempt:" << mHTTPFailCount+1 << "/" << max_attempts << llendl; @@ -1286,6 +1313,7 @@ bool LLTextureFetchWorker::doWork(S32 param) { // Use available data mLoadedDiscard = mFormattedImage->getDiscardLevel(); + setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); mState = DECODE_IMAGE; return false; } @@ -1298,6 +1326,7 @@ bool LLTextureFetchWorker::doWork(S32 param) } else { + setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); mState = SEND_HTTP_REQ; return false; // retry } @@ -1357,13 +1386,42 @@ bool LLTextureFetchWorker::doWork(S32 param) } else { +<<<<<<< local + // + //No need to timeout, the responder should be triggered automatically. + // +======= if(FETCHING_TIMEOUT < mRequestedTimer.getElapsedTimeF32()) { //timeout, abort. mState = DONE; return true; } +>>>>>>> other + +<<<<<<< local + //if(FETCHING_TIMEOUT < mRequestedTimer.getElapsedTimeF32()) + //{ + // if(mFetcher->getCurlRequest().isWaiting(mHTTPHandle)) + // { + // mRequestedTimer.reset(); //still waiting, request not issued yet. + // } + // else if(!mHTTPWaitCount) + // { + // mHTTPWaitCount++; + // mRequestedTimer.reset(); //wait for one more FETCHING_TIMEOUT cycle in case the request is just issued. + // } + // else + // { + // //timeout, abort. + // removeFromHTTPQueue(); + // mState = DONE; + // return true; + // } + //} +======= +>>>>>>> other setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); return false; } @@ -1495,7 +1553,7 @@ bool LLTextureFetchWorker::doWork(S32 param) CacheWriteResponder* responder = new CacheWriteResponder(mFetcher, mID); mCacheWriteHandle = mFetcher->mTextureCache->writeToCache(mID, cache_priority, mFormattedImage->getData(), datasize, - mFileSize, responder); + mFileSize, mRawImage, mDecodedDiscard, responder); // fall through } @@ -1683,7 +1741,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels, S32 data_size = 0 ; LLMutexLock lock(&mWorkMutex); - + mHTTPHandle = 0; if (mState != WAIT_HTTP_REQ) { llwarns << "callbackHttpGet for unrequested fetch worker: " << mID @@ -1707,7 +1765,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels, mBuffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size); buffer->readAfter(channels.in(), NULL, mBuffer, data_size); mBufferSize += data_size; - if (data_size < mRequestedSize && mRequestedDiscard == 0) + if (mRequestedSize == 0) { mHaveAllData = TRUE; } @@ -1733,6 +1791,10 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels, { mRequestedSize = -1; // error } + // Clear the url since we're done with the fetch + // Note: mUrl is used to check is fetching is required so failure to clear it will force an http fetch + // next time the texture is requested, even if the data have already been fetched. + mUrl.clear(); mLoaded = TRUE; setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); @@ -1856,11 +1918,14 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mTextureCache(cache), mImageDecodeThread(imagedecodethread), mTextureBandwidth(0), - mHTTPTextureBits(0), - mTotalHTTPRequests(0), mCurlGetRequest(NULL), mQAMode(qa_mode), mFetchDebugger(NULL), +<<<<<<< local + mFetchSource(LLTextureFetch::FROM_ALL), + mOriginFetchSource(LLTextureFetch::FROM_ALL), +======= +>>>>>>> other mFetcherLocked(FALSE) { mCurlPOSTRequestCount = 0; @@ -1871,6 +1936,16 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image if(LLTextureFetchDebugger::isEnabled()) { mFetchDebugger = new LLTextureFetchDebugger(this, cache, imagedecodethread) ; +<<<<<<< local + mFetchSource = (e_tex_source)gSavedSettings.getS32("TextureFetchSource"); + if(mFetchSource < 0 && mFetchSource >= INVALID_SOURCE) + { + mFetchSource = LLTextureFetch::FROM_ALL; + gSavedSettings.setS32("TextureFetchSource", 0); + } + mOriginFetchSource = mFetchSource; +======= +>>>>>>> other } } @@ -1940,6 +2015,8 @@ bool LLTextureFetch::createRequest(const std::string& url, const LLUUID& id, con } else { + // If the requester knows nothing about the file, we fetch the smallest + // amount of data at the lowest resolution (highest discard level) possible. desired_size = TEXTURE_CACHE_ENTRY_SIZE; desired_discard = MAX_DISCARD_LEVEL; } @@ -2018,45 +2095,22 @@ void LLTextureFetch::removeFromNetworkQueue(LLTextureFetchWorker* worker, bool c } } -// protected -void LLTextureFetch::addToHTTPQueue(const LLUUID& id) -{ - LLMutexLock lock(&mNetworkQueueMutex); - mHTTPTextureQueue.insert(id); - mTotalHTTPRequests++; -} - -void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32 received_size) -{ - LLMutexLock lock(&mNetworkQueueMutex); - mHTTPTextureQueue.erase(id); - mHTTPTextureBits += received_size * 8; // Approximate - does not include header bits -} - void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel) { lockQueue() ; LLTextureFetchWorker* worker = getWorkerAfterLock(id); - if (worker) - { - size_t erased_1 = mRequestMap.erase(worker->mID); - unlockQueue() ; - - llassert_always(erased_1 > 0) ; - - removeFromNetworkQueue(worker, cancel); - llassert_always(!(worker->getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) ; + unlockQueue() ; - worker->scheduleDelete(); - } - else - { - unlockQueue() ; - } + removeRequest(worker, cancel); } void LLTextureFetch::removeRequest(LLTextureFetchWorker* worker, bool cancel) { + if(!worker) + { + return; + } + lockQueue() ; size_t erased_1 = mRequestMap.erase(worker->mID); unlockQueue() ; @@ -2065,9 +2119,28 @@ void LLTextureFetch::removeRequest(LLTextureFetchWorker* worker, bool cancel) removeFromNetworkQueue(worker, cancel); llassert_always(!(worker->getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) ; + worker->removeFromHTTPQueue(); worker->scheduleDelete(); } +void LLTextureFetch::deleteAllRequests() +{ + while(1) + { + lockQueue(); + if(mRequestMap.empty()) + { + unlockQueue() ; + break; + } + + LLTextureFetchWorker* worker = mRequestMap.begin()->second; + unlockQueue() ; + + removeRequest(worker, true); + } +} + S32 LLTextureFetch::getNumRequests() { lockQueue() ; @@ -2077,24 +2150,6 @@ S32 LLTextureFetch::getNumRequests() return size ; } -S32 LLTextureFetch::getNumHTTPRequests() -{ - mNetworkQueueMutex.lock() ; - S32 size = (S32)mHTTPTextureQueue.size(); - mNetworkQueueMutex.unlock() ; - - return size ; -} - -U32 LLTextureFetch::getTotalNumHTTPRequests() -{ - mNetworkQueueMutex.lock() ; - U32 size = mTotalHTTPRequests ; - mNetworkQueueMutex.unlock() ; - - return size ; -} - // call lockQueue() first! LLTextureFetchWorker* LLTextureFetch::getWorkerAfterLock(const LLUUID& id) { @@ -2180,7 +2235,7 @@ bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority) { worker->lockWorkMutex(); worker->setImagePriority(priority); - worker->unlockWorkMutex(); + worker->unlockWorkMutex(); res = true; } return res; @@ -2262,15 +2317,7 @@ S32 LLTextureFetch::update(F32 max_time_ms) { static LLCachedControl<F32> band_width(gSavedSettings,"ThrottleBandwidthKBPS"); - { - mNetworkQueueMutex.lock() ; - mMaxBandwidth = band_width ; - - gTextureList.sTextureBits += mHTTPTextureBits ; - mHTTPTextureBits = 0 ; - - mNetworkQueueMutex.unlock() ; - } + mMaxBandwidth = band_width ; S32 res = LLWorkerThread::update(max_time_ms); @@ -2281,13 +2328,32 @@ S32 LLTextureFetch::update(F32 max_time_ms) // won't work so don't bother trying if (LLStartUp::getStartupState() > STATE_AGENT_SEND) { +<<<<<<< local + sendRequestListToSimulators(); +======= sendRequestListToSimulators(); +>>>>>>> other } } if (!mThreaded) { commonUpdate(); + + if(mCurlGetRequest) + { + mCurlGetRequest->nextRequests(); + } + } + + if(mCurlGetRequest) + { + gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits(); + } + + if(mFetchDebugger) + { + mFetchDebugger->tryToStopDebug(); //check if need to stop debugger. } return res; @@ -2317,7 +2383,11 @@ void LLTextureFetch::shutDownImageDecodeThread() void LLTextureFetch::startThread() { // Construct mCurlGetRequest from Worker Thread +<<<<<<< local + mCurlGetRequest = new LLCurlTextureRequest(8); +======= mCurlGetRequest = new LLCurlRequest(); +>>>>>>> other if(mFetchDebugger) { @@ -2342,6 +2412,8 @@ void LLTextureFetch::threadedUpdate() { llassert_always(mCurlGetRequest); + mCurlGetRequest->nextRequests(); + // Limit update frequency const F32 PROCESS_TIME = 0.05f; static LLFrameTimer process_timer; @@ -3154,6 +3226,10 @@ public: llinfos << "Fetch Debugger : CURL GET FAILED, index = " << mIndex << ", status:" << status << " reason:" << reason << llendl; } mDebugger->callbackHTTP(mIndex, channels, buffer, partial, success); +<<<<<<< local + mDebugger->getCurlGetRequest()->completeRequest(0); +======= +>>>>>>> other } virtual bool followRedir() { @@ -3176,7 +3252,12 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur LLTextureFetchDebugger::~LLTextureFetchDebugger() { mFetchingHistory.clear(); +<<<<<<< local + mStopDebug = TRUE; + tryToStopDebug(); +======= stopDebug(); +>>>>>>> other } void LLTextureFetchDebugger::init() @@ -3191,6 +3272,11 @@ void LLTextureFetchDebugger::init() mTotalFetchingTime = 0.f; mRefetchVisCacheTime = -1.f; mRefetchVisHTTPTime = -1.f; +<<<<<<< local + mRefetchAllCacheTime = -1.f; + mRefetchAllHTTPTime = -1.f; +======= +>>>>>>> other mNumFetchedTextures = 0; mNumCacheHits = 0; @@ -3204,10 +3290,64 @@ void LLTextureFetchDebugger::init() mRenderedDecodedData = 0; mFetchedPixels = 0; mRenderedPixels = 0; +<<<<<<< local + mRefetchedVisData = 0; + mRefetchedVisPixels = 0; + mRefetchedAllData = 0; + mRefetchedAllPixels = 0; +======= mRefetchedData = 0; mRefetchedPixels = 0; +>>>>>>> other mFreezeHistory = FALSE; +<<<<<<< local + mStopDebug = FALSE; + mClearHistory = FALSE; +} + +void LLTextureFetchDebugger::startWork(e_debug_state state) +{ + switch(state) + { + case IDLE: + break; + case START_DEBUG: + startDebug(); + break; + case READ_CACHE: + debugCacheRead(); + break; + case WRITE_CACHE: + debugCacheWrite(); + break; + case DECODING: + debugDecoder(); + break; + case HTTP_FETCHING: + debugHTTP(); + break; + case GL_TEX: + debugGLTextureCreation(); + break; + case REFETCH_VIS_CACHE: + debugRefetchVisibleFromCache(); + break; + case REFETCH_VIS_HTTP: + debugRefetchVisibleFromHTTP(); + break; + case REFETCH_ALL_CACHE: + debugRefetchAllFromCache(); + break; + case REFETCH_ALL_HTTP: + debugRefetchAllFromHTTP(); + break; + default: + break; + } + return; +======= +>>>>>>> other } void LLTextureFetchDebugger::startDebug() @@ -3215,10 +3355,24 @@ void LLTextureFetchDebugger::startDebug() //lock the fetcher mFetcher->lockFetcher(true); mFreezeHistory = TRUE; +<<<<<<< local + mFetcher->resetLoadSource(); +======= +>>>>>>> other //clear the current fetching queue gTextureList.clearFetchingRequests(); +<<<<<<< local + mState = START_DEBUG; +} + +bool LLTextureFetchDebugger::processStartDebug(F32 max_time) +{ + mTimer.reset(); + +======= +>>>>>>> other //wait for all works to be done while(1) { @@ -3230,6 +3384,14 @@ void LLTextureFetchDebugger::startDebug() { break; } +<<<<<<< local + + if(mTimer.getElapsedTimeF32() > max_time) + { + return false; + } +======= +>>>>>>> other } //collect statistics @@ -3268,10 +3430,27 @@ void LLTextureFetchDebugger::startDebug() } mNumFetchedTextures = fetched_textures.size(); +<<<<<<< local + + return true; +======= +>>>>>>> other } +<<<<<<< local +void LLTextureFetchDebugger::tryToStopDebug() +======= void LLTextureFetchDebugger::stopDebug() +>>>>>>> other { +<<<<<<< local + if(!mStopDebug) + { + return; + } + +======= +>>>>>>> other //clear the current debug work S32 size = mFetchingHistory.size(); switch(mState) @@ -3300,37 +3479,107 @@ void LLTextureFetchDebugger::stopDebug() break; case GL_TEX: break; +<<<<<<< local + case REFETCH_VIS_CACHE: + break; + case REFETCH_VIS_HTTP: + break; + case REFETCH_ALL_CACHE: + mRefetchList.clear(); + break; + case REFETCH_ALL_HTTP: + mRefetchList.clear(); + break; +======= +>>>>>>> other default: break; } +<<<<<<< local + if(update(0.005f)) +======= while(1) +>>>>>>> other { +<<<<<<< local + //unlock the fetcher + mFetcher->lockFetcher(false); + mFetcher->resetLoadSource(); + mFreezeHistory = FALSE; + mStopDebug = FALSE; + + if(mClearHistory) +======= if(update()) +>>>>>>> other { +<<<<<<< local + mFetchingHistory.clear(); + init(); + mTotalFetchingTime = gDebugTimers[0].getElapsedTimeF32(); //reset +======= break; +>>>>>>> other } } +<<<<<<< local +======= //unlock the fetcher mFetcher->lockFetcher(false); mFreezeHistory = FALSE; mTotalFetchingTime = gDebugTimers[0].getElapsedTimeF32(); //reset +>>>>>>> other } //called in the main thread and when the fetching queue is empty void LLTextureFetchDebugger::clearHistory() { +<<<<<<< local + mClearHistory = TRUE; +======= mFetchingHistory.clear(); init(); +>>>>>>> other } void LLTextureFetchDebugger::addHistoryEntry(LLTextureFetchWorker* worker) { +<<<<<<< local + if(worker->mRawImage.isNull() || worker->mFormattedImage.isNull()) + { + return; + } + +======= +>>>>>>> other if(mFreezeHistory) { +<<<<<<< local + if(mState == REFETCH_VIS_CACHE || mState == REFETCH_VIS_HTTP) + { + mRefetchedVisPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight(); + mRefetchedVisData += worker->mFormattedImage->getDataSize(); + } + else + { + mRefetchedAllPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight(); + mRefetchedAllData += worker->mFormattedImage->getDataSize(); + + LLViewerFetchedTexture* tex = LLViewerTextureManager::findFetchedTexture(worker->mID); + if(tex && mRefetchList[tex].begin() != mRefetchList[tex].end()) + { + if(worker->mDecodedDiscard == mFetchingHistory[mRefetchList[tex][0]].mDecodedLevel) + { + mRefetchList[tex].erase(mRefetchList[tex].begin()); + } + } + } +======= mRefetchedPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight(); mRefetchedData += worker->mFormattedImage->getDataSize(); +>>>>>>> other return; } @@ -3342,9 +3591,14 @@ void LLTextureFetchDebugger::addHistoryEntry(LLTextureFetchWorker* worker) mDecodedData += worker->mRawImage->getDataSize(); mFetchedPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight(); +<<<<<<< local + mFetchingHistory.push_back(FetchEntry(worker->mID, worker->mDesiredSize, worker->mDecodedDiscard, + worker->mFormattedImage->getDataSize(), worker->mRawImage->getDataSize())); +======= mFetchingHistory.push_back(FetchEntry(worker->mID, worker->mDesiredSize, worker->mDecodedDiscard, worker->mFormattedImage->getDataSize(), worker->mRawImage->getDataSize())); //mFetchingHistory.push_back(FetchEntry(worker->mID, worker->mDesiredSize, worker->mHaveAllData ? 0 : worker->mLoadedDiscard, worker->mFormattedImage->getComponents(), //worker->mDecodedDiscard, worker->mFormattedImage->getDataSize(), worker->mRawImage->getDataSize())); +>>>>>>> other } void LLTextureFetchDebugger::lockCache() @@ -3361,6 +3615,10 @@ void LLTextureFetchDebugger::debugCacheRead() llassert_always(mState == IDLE); mTimer.reset(); mState = READ_CACHE; +<<<<<<< local + mCacheReadTime = -1.f; +======= +>>>>>>> other S32 size = mFetchingHistory.size(); for(S32 i = 0 ; i < size ; i++) @@ -3396,6 +3654,10 @@ void LLTextureFetchDebugger::debugCacheWrite() llassert_always(mState == IDLE); mTimer.reset(); mState = WRITE_CACHE; +<<<<<<< local + mCacheWriteTime = -1.f; +======= +>>>>>>> other S32 size = mFetchingHistory.size(); for(S32 i = 0 ; i < size ; i++) @@ -3405,7 +3667,11 @@ void LLTextureFetchDebugger::debugCacheWrite() mFetchingHistory[i].mCacheHandle = mTextureCache->writeToCache(mFetchingHistory[i].mID, LLWorkerThread::PRIORITY_NORMAL, mFetchingHistory[i].mFormattedImage->getData(), mFetchingHistory[i].mFetchedSize, mFetchingHistory[i].mDecodedLevel == 0 ? mFetchingHistory[i].mFetchedSize : mFetchingHistory[i].mFetchedSize + 1, +<<<<<<< local + NULL, 0, new LLDebuggerCacheWriteResponder(this, i)); +======= new LLDebuggerCacheWriteResponder(this, i)); +>>>>>>> other } } } @@ -3424,6 +3690,10 @@ void LLTextureFetchDebugger::debugDecoder() llassert_always(mState == IDLE); mTimer.reset(); mState = DECODING; +<<<<<<< local + mDecodingTime = -1.f; +======= +>>>>>>> other S32 size = mFetchingHistory.size(); for(S32 i = 0 ; i < size ; i++) @@ -3459,6 +3729,10 @@ void LLTextureFetchDebugger::debugHTTP() mTimer.reset(); mState = HTTP_FETCHING; +<<<<<<< local + mHTTPTime = -1.f; +======= +>>>>>>> other S32 size = mFetchingHistory.size(); for (S32 i = 0 ; i < size ; i++) @@ -3475,14 +3749,46 @@ void LLTextureFetchDebugger::debugHTTP() S32 LLTextureFetchDebugger::fillCurlQueue() { +<<<<<<< local + if(mStopDebug) //stop + { + mNbCurlCompleted = mFetchingHistory.size(); + return 0; + } +======= if (mNbCurlRequests == 24) return mNbCurlRequests; +>>>>>>> other S32 size = mFetchingHistory.size(); +<<<<<<< local + + if (mNbCurlRequests == size) //all issued + { + return 0; + } + + S32 counter = 8; + mNbCurlRequests = 0; +======= +>>>>>>> other for (S32 i = 0 ; i < size ; i++) { +<<<<<<< local + mNbCurlRequests++; + +======= +>>>>>>> other if (mFetchingHistory[i].mCurlState != FetchEntry::CURL_NOT_DONE) +<<<<<<< local + { +======= +>>>>>>> other continue; +<<<<<<< local + } +======= +>>>>>>> other std::string texture_url = mHTTPUrl + "/?texture_id=" + mFetchingHistory[i].mID.asString().c_str(); S32 requestedSize = mFetchingHistory[i].mRequestedSize; // We request the whole file if the size was not set. @@ -3491,6 +3797,13 @@ S32 LLTextureFetchDebugger::fillCurlQueue() requestedSize = (requestedSize == 33554432 ? 0 : requestedSize); std::vector<std::string> headers; headers.push_back("Accept: image/x-j2c"); +<<<<<<< local + mCurlGetRequest->getByteRange(texture_url, headers, 0, requestedSize, 0x10000, new LLDebuggerHTTPResponder(this, i)); + + mFetchingHistory[i].mCurlState = FetchEntry::CURL_IN_PROGRESS; + counter--; + if(counter < 1) +======= bool res = mCurlGetRequest->getByteRange(texture_url, headers, 0, requestedSize, new LLDebuggerHTTPResponder(this, i)); if (res) { @@ -3501,6 +3814,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue() break; } else +>>>>>>> other { break; } @@ -3513,7 +3827,11 @@ void LLTextureFetchDebugger::debugGLTextureCreation() { llassert_always(mState == IDLE); mState = GL_TEX; +<<<<<<< local + mTempTexList.clear(); +======= std::vector<LLViewerFetchedTexture*> tex_list; +>>>>>>> other S32 size = mFetchingHistory.size(); for(S32 i = 0 ; i < size ; i++) @@ -3524,28 +3842,91 @@ void LLTextureFetchDebugger::debugGLTextureCreation() if(tex && !tex->isForSculptOnly()) { tex->destroyGLTexture() ; +<<<<<<< local + mTempTexList.push_back(tex); +======= tex_list.push_back(tex); +>>>>>>> other } } } +<<<<<<< local + + mGLCreationTime = -1.f; + mTempIndex = 0; + mHistoryListIndex = 0; + + return; +} +======= +>>>>>>> other +<<<<<<< local +bool LLTextureFetchDebugger::processGLCreation(F32 max_time) +{ +======= +>>>>>>> other mTimer.reset(); +<<<<<<< local + + bool done = true; + S32 size = mFetchingHistory.size(); + S32 size1 = mTempTexList.size(); + for(; mHistoryListIndex < size && mTempIndex < size1; mHistoryListIndex++) +======= S32 j = 0 ; S32 size1 = tex_list.size(); for(S32 i = 0 ; i < size && j < size1; i++) +>>>>>>> other { +<<<<<<< local + if(mFetchingHistory[mHistoryListIndex].mRawImage.notNull()) +======= if(mFetchingHistory[i].mRawImage.notNull()) +>>>>>>> other { +<<<<<<< local + if(mFetchingHistory[mHistoryListIndex].mID == mTempTexList[mTempIndex]->getID()) +======= if(mFetchingHistory[i].mID == tex_list[j]->getID()) +>>>>>>> other { +<<<<<<< local + mTempTexList[mTempIndex]->createGLTexture(mFetchingHistory[mHistoryListIndex].mDecodedLevel, + mFetchingHistory[mHistoryListIndex].mRawImage, 0, TRUE, mTempTexList[mTempIndex]->getBoostLevel()); + mTempIndex++; +======= tex_list[j]->createGLTexture(mFetchingHistory[i].mDecodedLevel, mFetchingHistory[i].mRawImage, 0, TRUE, tex_list[j]->getBoostLevel()); j++; +>>>>>>> other } } +<<<<<<< local + + if(mTimer.getElapsedTimeF32() > max_time) + { + done = false; + break; + } +======= +>>>>>>> other + } + +<<<<<<< local + if(mGLCreationTime < 0.f) + { + mGLCreationTime = mTimer.getElapsedTimeF32() ; + } + else + { + mGLCreationTime += mTimer.getElapsedTimeF32() ; } + return done; +======= mGLCreationTime = mTimer.getElapsedTimeF32() ; return; +>>>>>>> other } //clear fetching results of all textures. @@ -3562,15 +3943,72 @@ void LLTextureFetchDebugger::clearTextures() } } +<<<<<<< local +void LLTextureFetchDebugger::makeRefetchList() +{ + mRefetchList.clear(); + S32 size = mFetchingHistory.size(); + for(S32 i = 0 ; i < size; i++) + { + LLViewerFetchedTexture* tex = LLViewerTextureManager::getFetchedTexture(mFetchingHistory[i].mID); + if(tex && tex->isJustBound()) //visible + { + continue; //the texture fetch pipeline will take care of visible textures. + } + + mRefetchList[tex].push_back(i); + } +} + +void LLTextureFetchDebugger::scanRefetchList() +{ + if(mStopDebug) + { + return; + } + if(!mRefetchNonVis) + { + return; + } + + for(std::map< LLPointer<LLViewerFetchedTexture>, std::vector<S32> >::iterator iter = mRefetchList.begin(); + iter != mRefetchList.end(); ) + { + if(iter->second.empty()) + { + gTextureList.setDebugFetching(iter->first, -1); + mRefetchList.erase(iter++); // This is the correct method to "erase and move on" in an std::map + } + else + { + gTextureList.setDebugFetching(iter->first, mFetchingHistory[iter->second[0]].mDecodedLevel); + ++iter; + } + } +} + +======= +>>>>>>> other void LLTextureFetchDebugger::debugRefetchVisibleFromCache() { llassert_always(mState == IDLE); mState = REFETCH_VIS_CACHE; clearTextures(); +<<<<<<< local + mFetcher->setLoadSource(LLTextureFetch::FROM_ALL); + +======= +>>>>>>> other mTimer.reset(); mFetcher->lockFetcher(false); +<<<<<<< local + mRefetchVisCacheTime = -1.f; + mRefetchedVisData = 0; + mRefetchedVisPixels = 0; +======= +>>>>>>> other } void LLTextureFetchDebugger::debugRefetchVisibleFromHTTP() @@ -3578,17 +4016,77 @@ void LLTextureFetchDebugger::debugRefetchVisibleFromHTTP() llassert_always(mState == IDLE); mState = REFETCH_VIS_HTTP; +<<<<<<< local +======= clearCache(); +>>>>>>> other + clearTextures(); +<<<<<<< local + mFetcher->setLoadSource(LLTextureFetch::FROM_HTTP_ONLY); +======= +>>>>>>> other + + mTimer.reset(); + mFetcher->lockFetcher(false); +<<<<<<< local + mRefetchVisHTTPTime = -1.f; + mRefetchedVisData = 0; + mRefetchedVisPixels = 0; +======= +>>>>>>> other +} + +<<<<<<< local +void LLTextureFetchDebugger::debugRefetchAllFromCache() +{ + llassert_always(mState == IDLE); + mState = REFETCH_ALL_CACHE; + + clearTextures(); + makeRefetchList(); + mFetcher->setLoadSource(LLTextureFetch::FROM_ALL); + + mTimer.reset(); + mFetcher->lockFetcher(false); + mRefetchAllCacheTime = -1.f; + mRefetchedAllData = 0; + mRefetchedAllPixels = 0; + mRefetchNonVis = FALSE; +} + +void LLTextureFetchDebugger::debugRefetchAllFromHTTP() +{ + llassert_always(mState == IDLE); + mState = REFETCH_ALL_HTTP; + clearTextures(); + makeRefetchList(); + mFetcher->setLoadSource(LLTextureFetch::FROM_HTTP_ONLY); mTimer.reset(); mFetcher->lockFetcher(false); + mRefetchAllHTTPTime = -1.f; + mRefetchedAllData = 0; + mRefetchedAllPixels = 0; + mRefetchNonVis = TRUE; } +bool LLTextureFetchDebugger::update(F32 max_time) +======= bool LLTextureFetchDebugger::update() +>>>>>>> other { switch(mState) { +<<<<<<< local + case START_DEBUG: + if(processStartDebug(max_time)) + { + mState = IDLE; + } + break; +======= +>>>>>>> other case READ_CACHE: if(!mTextureCache->update(1)) { @@ -3615,6 +4113,10 @@ bool LLTextureFetchDebugger::update() break; case HTTP_FETCHING: mCurlGetRequest->process(); +<<<<<<< local + mCurlGetRequest->nextRequests(); +======= +>>>>>>> other LLCurl::getCurlThread()->update(1); if (!fillCurlQueue() && mNbCurlCompleted == mFetchingHistory.size()) { @@ -3623,22 +4125,77 @@ bool LLTextureFetchDebugger::update() } break; case GL_TEX: +<<<<<<< local + if(processGLCreation(max_time)) + { + mState = IDLE; + mTempTexList.clear(); + } +======= mState = IDLE; +>>>>>>> other break; case REFETCH_VIS_CACHE: if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) { +<<<<<<< local + mRefetchVisCacheTime = mTimer.getElapsedTimeF32() ; +======= mRefetchVisCacheTime = gDebugTimers[0].getElapsedTimeF32() - mTotalFetchingTime; +>>>>>>> other mState = IDLE; mFetcher->lockFetcher(true); +<<<<<<< local + mFetcher->resetLoadSource(); +======= +>>>>>>> other } break; case REFETCH_VIS_HTTP: if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) { +<<<<<<< local + mRefetchVisHTTPTime = mTimer.getElapsedTimeF32() ; +======= mRefetchVisHTTPTime = gDebugTimers[0].getElapsedTimeF32() - mTotalFetchingTime; +>>>>>>> other + mState = IDLE; + mFetcher->lockFetcher(true); +<<<<<<< local + mFetcher->resetLoadSource(); + } + break; + case REFETCH_ALL_CACHE: + scanRefetchList(); + if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) + { + if(!mRefetchNonVis) + { + mRefetchNonVis = TRUE; //start to fetch non-vis + scanRefetchList(); + break; + } + + mRefetchAllCacheTime = mTimer.getElapsedTimeF32() ; + mState = IDLE; + mFetcher->lockFetcher(true); + mFetcher->resetLoadSource(); + mRefetchList.clear(); + mRefetchNonVis = FALSE; + } + break; + case REFETCH_ALL_HTTP: + scanRefetchList(); + if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) + { + mRefetchAllHTTPTime = mTimer.getElapsedTimeF32() ; mState = IDLE; mFetcher->lockFetcher(true); + mFetcher->resetLoadSource(); + mRefetchList.clear(); + mRefetchNonVis = FALSE; +======= +>>>>>>> other } break; default: @@ -3679,7 +4236,10 @@ void LLTextureFetchDebugger::callbackHTTP(S32 id, const LLChannelDescriptors& ch const LLIOPipe::buffer_ptr_t& buffer, bool partial, bool success) { +<<<<<<< local +======= mNbCurlRequests--; +>>>>>>> other if (success) { mFetchingHistory[id].mCurlState = FetchEntry::CURL_DONE; @@ -3693,7 +4253,11 @@ void LLTextureFetchDebugger::callbackHTTP(S32 id, const LLChannelDescriptors& ch U8* d_buffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size); buffer->readAfter(channels.in(), NULL, d_buffer, data_size); +<<<<<<< local + mFetchingHistory[id].mFormattedImage = NULL; +======= llassert_always(mFetchingHistory[id].mFormattedImage.isNull()); +>>>>>>> other { // For now, create formatted image based on extension std::string texture_url = mHTTPUrl + "/?texture_id=" + mFetchingHistory[id].mID.asString().c_str(); @@ -3715,6 +4279,10 @@ void LLTextureFetchDebugger::callbackHTTP(S32 id, const LLChannelDescriptors& ch { // Fetch will have to be redone mFetchingHistory[id].mCurlState = FetchEntry::CURL_NOT_DONE; +<<<<<<< local + mNbCurlRequests--; +======= +>>>>>>> other } else //skip { |