summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturefetch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rw-r--r--indra/newview/lltexturefetch.cpp98
1 files changed, 74 insertions, 24 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 69c40066b4..087761cbd0 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -29,6 +29,7 @@
#include <iostream>
#include <map>
#include <algorithm>
+#include <atomic>
#include "lltexturefetch.h"
@@ -537,7 +538,6 @@ private:
F32 mImagePriority; // should map to max virtual size
F32 mRequestedPriority;
S32 mDesiredDiscard;
- S32 mSimRequestedDiscard;
S32 mRequestedDiscard;
S32 mLoadedDiscard;
S32 mDecodedDiscard;
@@ -870,7 +870,6 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
mImagePriority(priority),
mRequestedPriority(0.f),
mDesiredDiscard(-1),
- mSimRequestedDiscard(-1),
mRequestedDiscard(-1),
mLoadedDiscard(-1),
mDecodedDiscard(-1),
@@ -1505,18 +1504,13 @@ bool LLTextureFetchWorker::doWork(S32 param)
{
if (http_not_found == mGetStatus)
{
- if (mFTType != FTT_MAP_TILE)
- {
- LL_WARNS(LOG_TXT) << "Texture missing from server (404): " << mUrl << LL_ENDL;
- }
-
if(mWriteToCacheState == NOT_WRITE) //map tiles or server bakes
{
setState(DONE);
releaseHttpSemaphore();
if (mFTType != FTT_MAP_TILE)
{
- LL_WARNS(LOG_TXT) << mID << " abort: WAIT_HTTP_REQ not found" << LL_ENDL;
+ LL_WARNS(LOG_TXT) << mID << "NOT_WRITE texture missing from server (404), abort: " << mUrl << LL_ENDL;
}
return true;
}
@@ -1526,6 +1520,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
LLViewerRegion* region = getRegion();
if (!region || mLastRegionId != region->getRegionID())
{
+ if (mFTType != FTT_MAP_TILE)
+ {
+ LL_INFOS(LOG_TXT) << "Texture missing from server (404), retrying: " << mUrl << " mRetryAttempt " << mRetryAttempt << LL_ENDL;
+ }
// cap failure? try on new region.
mUrl.clear();
++mRetryAttempt;
@@ -1534,6 +1532,11 @@ bool LLTextureFetchWorker::doWork(S32 param)
return false;
}
}
+
+ if (mFTType != FTT_MAP_TILE)
+ {
+ LL_WARNS(LOG_TXT) << "Texture missing from server (404): " << mUrl << LL_ENDL;
+ }
}
else if (http_service_unavail == mGetStatus)
{
@@ -1759,7 +1762,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
mRawImage = NULL;
mAuxImage = NULL;
llassert_always(mFormattedImage.notNull());
- S32 discard = mHaveAllData ? 0 : mLoadedDiscard;
+
+ // if we have the entire image data (and the image is not J2C), decode the full res image
+ // DO NOT decode a higher res j2c than was requested. This is a waste of time and memory.
+ S32 discard = mHaveAllData && mFormattedImage->getCodec() != IMG_CODEC_J2C ? 0 : mLoadedDiscard;
mDecoded = false;
setState(DECODE_IMAGE_UPDATE);
LL_DEBUGS(LOG_TXT) << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard
@@ -2090,7 +2096,7 @@ bool LLTextureFetchWorker::deleteOK()
// Allow any pending reads or writes to complete
if (mCacheReadHandle != LLTextureCache::nullHandle())
{
- if (mFetcher->mTextureCache->readComplete(mCacheReadHandle, true))
+ if (!mFetcher->mTextureCache || mFetcher->mTextureCache->readComplete(mCacheReadHandle, true))
{
mCacheReadHandle = LLTextureCache::nullHandle();
}
@@ -2101,7 +2107,7 @@ bool LLTextureFetchWorker::deleteOK()
}
if (mCacheWriteHandle != LLTextureCache::nullHandle())
{
- if (mFetcher->mTextureCache->writeComplete(mCacheWriteHandle))
+ if (!mFetcher->mTextureCache || mFetcher->mTextureCache->writeComplete(mCacheWriteHandle))
{
mCacheWriteHandle = LLTextureCache::nullHandle();
}
@@ -2316,6 +2322,10 @@ void LLTextureFetchWorker::callbackDecoded(bool success, const std::string &erro
mRawImage = raw;
mAuxImage = aux;
mDecodedDiscard = mFormattedImage->getDiscardLevel();
+ if (mDecodedDiscard < mDesiredDiscard)
+ {
+ LL_WARNS_ONCE(LOG_TXT) << "Decoded higher resolution than requested" << LL_ENDL;
+ }
LL_DEBUGS(LOG_TXT) << mID << ": Decode Finished. Discard: " << mDecodedDiscard
<< " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL;
}
@@ -2479,7 +2489,7 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L
LL_PROFILE_ZONE_SCOPED;
if (mDebugPause)
{
- return -1;
+ return CREATE_REQUEST_ERROR_DEFAULT;
}
if (f_type == FTT_SERVER_BAKE)
@@ -2495,7 +2505,7 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L
<< host << " != " << worker->mHost << LL_ENDL;
removeRequest(worker, true);
worker = NULL;
- return -1;
+ return CREATE_REQUEST_ERROR_MHOSTS;
}
}
@@ -2548,13 +2558,13 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L
{
if (worker->wasAborted())
{
- return -1; // need to wait for previous aborted request to complete
+ return CREATE_REQUEST_ERROR_ABORTED; // need to wait for previous aborted request to complete
}
worker->lockWorkMutex(); // +Mw
if (worker->mState == LLTextureFetchWorker::DONE && worker->mDesiredSize == llmax(desired_size, TEXTURE_CACHE_ENTRY_SIZE) && worker->mDesiredDiscard == desired_discard) {
worker->unlockWorkMutex(); // -Mw
- return -1; // similar request has failed or is in a transitional state
+ return CREATE_REQUEST_ERROR_TRANSITION; // similar request has finished, failed or is in a transitional state
}
worker->mActiveCount++;
worker->mNeedsAux = needs_aux;
@@ -2736,7 +2746,7 @@ LLTextureFetchWorker* LLTextureFetch::getWorker(const LLUUID& id)
// Threads: T*
-bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
+bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, S32& worker_state,
LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux,
LLCore::HttpStatus& last_http_get_status)
{
@@ -2745,6 +2755,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
LLTextureFetchWorker* worker = getWorker(id);
if (worker)
{
+ worker_state = worker->mState;
if (worker->wasAborted())
{
res = true;
@@ -2823,6 +2834,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
}
else
{
+ worker_state = 0;
res = true;
}
return res;
@@ -2832,7 +2844,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority)
{
LL_PROFILE_ZONE_SCOPED;
- mRequestQueue.tryPost([=]()
+ mRequestQueue.tryPost([=, this]()
{
LLTextureFetchWorker* worker = getWorker(id);
if (worker)
@@ -3145,6 +3157,43 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r
return state;
}
+// Threads: T*
+S32 LLTextureFetch::getLastFetchState(const LLUUID& id, S32& requested_discard, S32& decoded_discard, bool& decoded)
+{
+ LL_PROFILE_ZONE_SCOPED;
+ S32 state = LLTextureFetchWorker::INVALID;
+
+ LLTextureFetchWorker* worker = getWorker(id);
+ if (worker) // Don't check haveWork, intent is to get whatever is in the worker
+ {
+ worker->lockWorkMutex(); // +Mw
+ state = worker->mState;
+ requested_discard = worker->mDesiredDiscard;
+ decoded_discard = worker->mDecodedDiscard;
+ decoded = worker->mDecoded;
+ worker->unlockWorkMutex(); // -Mw
+ }
+ return state;
+}
+
+// Threads: T*
+S32 LLTextureFetch::getLastRawImage(const LLUUID& id,
+ LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux)
+{
+ LL_PROFILE_ZONE_SCOPED;
+ S32 decoded_discard = -1;
+ LLTextureFetchWorker* worker = getWorker(id);
+ if (worker && !worker->haveWork() && worker->mDecodedDiscard >= 0)
+ {
+ worker->lockWorkMutex(); // +Mw
+ raw = worker->mRawImage;
+ aux = worker->mAuxImage;
+ decoded_discard = worker->mDecodedDiscard;
+ worker->unlockWorkMutex(); // -Mw
+ }
+ return decoded_discard;
+}
+
void LLTextureFetch::dump()
{
LL_INFOS(LOG_TXT) << "LLTextureFetch ACTIVE_HTTP:" << LL_ENDL;
@@ -3523,29 +3572,30 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
//if (! gViewerAssetStatsThread1)
// return true;
- static volatile bool reporting_started(false);
- static volatile S32 report_sequence(0);
+ static std::atomic<bool> reporting_started(false);
+ static std::atomic<S32> report_sequence(0);
// In mStatsSD, we have a copy we own of the LLSD representation
// of the asset stats. Add some additional fields and ship it off.
static const S32 metrics_data_version = 2;
- bool initial_report = !reporting_started;
+ bool initial_report = !reporting_started.load();
mStatsSD["session_id"] = mSessionID;
mStatsSD["agent_id"] = mAgentID;
mStatsSD["message"] = "ViewerAssetMetrics";
- mStatsSD["sequence"] = report_sequence;
+ mStatsSD["sequence"] = report_sequence.load();
mStatsSD["initial"] = initial_report;
mStatsSD["version"] = metrics_data_version;
mStatsSD["break"] = static_cast<bool>(LLTextureFetch::svMetricsDataBreak);
// Update sequence number
- if (S32_MAX == ++report_sequence)
+ if (S32_MAX == report_sequence.fetch_add(1))
{
- report_sequence = 0;
+ report_sequence.store(0);
}
- reporting_started = true;
+
+ reporting_started.store(true);
// Limit the size of the stats report if necessary.