viewer#1260 Fix thumbnail preview not loading

Standard and scaled textures couldn't share workers and if one finished
a request, second one failed to start a new one.
meow-7.2.2
Andrey Kleshchev 2024-04-18 02:46:18 +03:00 committed by Andrey Kleshchev
parent 3758618949
commit f660f1f0fd
4 changed files with 37 additions and 19 deletions

View File

@ -2509,12 +2509,13 @@ LLTextureFetch::~LLTextureFetch()
}
S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const LLUUID& id, const LLHost& host, F32 priority,
S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux, bool can_use_http)
S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux, bool can_use_http, S32& worker_discard)
{
LL_PROFILE_ZONE_SCOPED;
worker_discard = -1;
if (mDebugPause)
{
return -1;
return FETCH_REQUEST_CREATION_FAILED;
}
if (f_type == FTT_SERVER_BAKE)
@ -2530,7 +2531,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 FETCH_REQUEST_ABORTED;
}
}
@ -2583,13 +2584,14 @@ 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 FETCH_REQUEST_ABORTED; // need to wait for previous aborted request to complete
}
worker_discard = desired_discard;
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 FETCH_REQUEST_EXISTS; // similar request has failed or is in a transitional state
}
worker->mActiveCount++;
worker->mNeedsAux = needs_aux;
@ -2623,11 +2625,12 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L
worker->mNeedsAux = needs_aux;
worker->setCanUseHTTP(can_use_http) ;
worker->unlockWorkMutex(); // -Mw
worker_discard = desired_discard;
}
LL_DEBUGS(LOG_TXT) << "REQUESTED: " << id << " f_type " << fttype_to_string(f_type)
<< " Discard: " << desired_discard << " size " << desired_size << LL_ENDL;
return desired_discard;
return FETCH_REQUEST_OK;
}
// Threads: T*
//

View File

@ -76,9 +76,14 @@ public:
// Threads: Tmain
void shutDownImageDecodeThread();
// Threads: T* (but Tmain mostly)
S32 createRequest(FTType f_type, const std::string& url, const LLUUID& id, const LLHost& host, F32 priority,
S32 w, S32 h, S32 c, S32 discard, bool needs_aux, bool can_use_http);
static constexpr S32 FETCH_REQUEST_OK = 0;
static constexpr S32 FETCH_REQUEST_CREATION_FAILED = -1;
static constexpr S32 FETCH_REQUEST_ABORTED = -2;
static constexpr S32 FETCH_REQUEST_EXISTS = -3;
// Threads: T* (but Tmain mostly)
// returns discard on success, fail code otherwise
S32 createRequest(FTType f_type, const std::string& url, const LLUUID& id, const LLHost& host, F32 priority,
S32 w, S32 h, S32 c, S32 discard, bool needs_aux, bool can_use_http, S32& worker_disacrd);
// Requests that a fetch operation be deleted from the queue.
// If @cancel is true, also stops any I/O operations pending.

View File

@ -1032,7 +1032,8 @@ void LLViewerFetchedTexture::init(bool firstinit)
mOrigHeight = 0;
mHasAux = FALSE;
mNeedsAux = FALSE;
mRequestedDiscardLevel = -1;
mLastWorkerDiscardLevel = -1;
mRequestedDiscardLevel = -1;
mRequestedDownloadPriority = 0.f;
mFullyLoaded = FALSE;
mCanUseHTTP = true;
@ -2084,18 +2085,26 @@ bool LLViewerFetchedTexture::updateFetch()
}
// bypass texturefetch directly by pulling from LLTextureCache
S32 fetch_request_discard = -1;
fetch_request_discard = LLAppViewer::getTextureFetch()->createRequest(mFTType, mUrl, getID(), getTargetHost(), decode_priority,
w, h, c, desired_discard, needsAux(), mCanUseHTTP);
if (fetch_request_discard >= 0)
S32 worker_discard = -1;
S32 result = LLAppViewer::getTextureFetch()->createRequest(mFTType, mUrl, getID(), getTargetHost(), decode_priority,
w, h, c, desired_discard, needsAux(), mCanUseHTTP, worker_discard);
if ((result >= 0) // Worker created
// scaled and standard images share requests, they just process the result differently
// if mLastWorkerDiscardLevel doen't match worker, worker was requested by a different
// image and current one needs to schedule an update
|| (result == LLTextureFetch::FETCH_REQUEST_EXISTS
&& mLastWorkerDiscardLevel != worker_discard)
)
{
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - request created");
mHasFetcher = TRUE;
mIsFetching = TRUE;
mHasFetcher = TRUE;
mIsFetching = TRUE;
mLastWorkerDiscardLevel = worker_discard;
// in some cases createRequest can modify discard, as an example
// bake textures are always at discard 0
mRequestedDiscardLevel = llmin(desired_discard, fetch_request_discard);
mRequestedDiscardLevel = llmin(desired_discard, worker_discard);
mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority,
mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP);
}

View File

@ -452,7 +452,8 @@ protected:
S32 mKnownDrawHeight;
BOOL mKnownDrawSizeChanged ;
std::string mUrl;
S32 mLastWorkerDiscardLevel;
S32 mRequestedDiscardLevel;
F32 mRequestedDownloadPriority;
S32 mFetchState;