diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2022-06-09 13:03:58 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2022-06-09 13:03:58 -0400 |
commit | a65e039174b0e7abb2a7b03b88d879092e8dd0ca (patch) | |
tree | aa4c8646e0d43019cfa5cbbe63c44153200e2925 | |
parent | 50dca86f64a167fe0db901310d04784b2f0dfa1f (diff) | |
parent | da069765b1974e60df5ebf9e973c7fd00c52e329 (diff) |
SL-17483: Merge branch 'DRTVWR-563' of viewer into sl-17483
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 3 | ||||
-rw-r--r-- | indra/newview/lltexturefetch.cpp | 35 | ||||
-rw-r--r-- | indra/newview/llviewertexture.cpp | 43 | ||||
-rw-r--r-- | indra/newview/llviewertexture.h | 3 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.cpp | 11 |
6 files changed, 80 insertions, 37 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index da79660239..20443988ab 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -65,7 +65,6 @@ #include <d3d9.h> #include <dxgi1_4.h> - // Require DirectInput version 8 #define DIRECTINPUT_VERSION 0x0800 @@ -4649,23 +4648,34 @@ void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info); // try to use no more than the available reserve minus 10% - U32 target = info.AvailableForReservation / 1024 / 1024; - target -= target / 10; + U32 target = info.Budget / 1024 / 1024; + + // EXPERIMENTAL + // Trying to zero in on a good target usage, code here should be tuned against observed behavior + // of various hardware. + if (target > 4096) // if 4GB are installed, try to leave 2GB free + { + target -= 2048; + } + else // if less than 4GB are installed, try not to use more than half of it + { + target /= 2; + } U32 used_vram = info.CurrentUsage / 1024 / 1024; mAvailableVRAM = used_vram < target ? target - used_vram : 0; - /*LL_INFOS() << "\nLocal\nAFR: " << info.AvailableForReservation / 1024 / 1024 + LL_INFOS("Window") << "\nLocal\nAFR: " << info.AvailableForReservation / 1024 / 1024 << "\nBudget: " << info.Budget / 1024 / 1024 << "\nCR: " << info.CurrentReservation / 1024 / 1024 << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL; mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &info); - LL_INFOS() << "\nNon-Local\nAFR: " << info.AvailableForReservation / 1024 / 1024 + LL_INFOS("Window") << "\nNon-Local\nAFR: " << info.AvailableForReservation / 1024 / 1024 << "\nBudget: " << info.Budget / 1024 / 1024 << "\nCR: " << info.CurrentReservation / 1024 / 1024 - << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL;*/ + << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL; } else if (mD3DDevice != NULL) { // fallback to D3D9 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index ae0c9d4dd6..55c0b31bf6 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1847,8 +1847,6 @@ bool LLAppViewer::cleanup() LL_INFOS() << "Cache files removed" << LL_ENDL; - // Wait for any pending LFS IO - flushLFSIO(); LL_INFOS() << "Shutting down Views" << LL_ENDL; // Destroy the UI @@ -2055,6 +2053,7 @@ bool LLAppViewer::cleanup() sTextureFetch->shutDownTextureCacheThread() ; sTextureFetch->shutDownImageDecodeThread() ; + LLLFSThread::sLocal->shutdown(); LL_INFOS() << "Shutting down message system" << LL_ENDL; end_messaging_system(); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 539e2454ea..604444b64a 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1071,7 +1071,7 @@ void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) // Locks: Mw void LLTextureFetchWorker::setImagePriority(F32 priority) { - mImagePriority = priority; //should map to max virtual size + mImagePriority = priority; //should map to max virtual size, abort if zero } // Locks: Mw @@ -1348,7 +1348,7 @@ bool LLTextureFetchWorker::doWork(S32 param) { if (mFTType != FTT_DEFAULT) { - LL_WARNS(LOG_TXT) << "trying to seek a non-default texture on the sim. Bad!" << LL_ENDL; + LL_WARNS(LOG_TXT) << "Trying to fetch a texture of non-default type by UUID. This probably won't work!" << LL_ENDL; } setUrl(http_url + "/?texture_id=" + mID.asString().c_str()); LL_DEBUGS(LOG_TXT) << "Texture URL: " << mUrl << LL_ENDL; @@ -1397,7 +1397,7 @@ bool LLTextureFetchWorker::doWork(S32 param) else { // Shouldn't need to do anything here - llassert(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end()); + //llassert(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end()); return false; } } @@ -1671,7 +1671,7 @@ bool LLTextureFetchWorker::doWork(S32 param) << LL_ENDL; } - if (mFTType != FTT_SERVER_BAKE) + if (mFTType != FTT_SERVER_BAKE && mFTType != FTT_MAP_TILE) { mUrl.clear(); } @@ -2695,6 +2695,11 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const return false; // 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 false; // similar request has failed or is in a transitional state + } worker->mActiveCount++; worker->mNeedsAux = needs_aux; worker->setImagePriority(priority); @@ -3011,16 +3016,18 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority) { LL_PROFILE_ZONE_SCOPED; - bool res = false; - LLTextureFetchWorker* worker = getWorker(id); - if (worker) - { - worker->lockWorkMutex(); // +Mw - worker->setImagePriority(priority); - worker->unlockWorkMutex(); // -Mw - res = true; - } - return res; + mRequestQueue.tryPost([=]() + { + LLTextureFetchWorker* worker = getWorker(id); + if (worker) + { + worker->lockWorkMutex(); // +Mw + worker->setImagePriority(priority); + worker->unlockWorkMutex(); // -Mw + } + }); + + return true; } // Replicates and expands upon the base class's diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 0544bceb9f..e31bc5ec6e 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -653,6 +653,11 @@ void LLViewerTexture::cleanup() { notifyAboutMissingAsset(); + if (LLAppViewer::getTextureFetch()) + { + LLAppViewer::getTextureFetch()->updateRequestPriority(mID, 0.f); + } + mFaceList[LLRender::DIFFUSE_MAP].clear(); mFaceList[LLRender::NORMAL_MAP].clear(); mFaceList[LLRender::SPECULAR_MAP].clear(); @@ -798,14 +803,8 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co } virtual_size *= sTexelPixelRatio; - /*if (!mMaxVirtualSizeResetCounter) - { - //flag to reset the values because the old values are used. - resetMaxVirtualSizeResetCounter(); - mMaxVirtualSize = virtual_size; - mNeedsGLTexture = needs_gltexture; - } - else*/ if (virtual_size > mMaxVirtualSize) + + if (virtual_size > mMaxVirtualSize) { mMaxVirtualSize = virtual_size; } @@ -1796,6 +1795,12 @@ void LLViewerFetchedTexture::updateVirtualSize() return; } + if (sDesiredDiscardBias > 0.f) + { + // running out of video memory, don't hold onto high res textures in the background + mMaxVirtualSize = 0.f; + } + for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) { llassert(mNumFaces[ch] <= mFaceList[ch].size()); @@ -1884,6 +1889,16 @@ bool LLViewerFetchedTexture::isActiveFetching() return mFetchState > 7 && mFetchState < 10 && monitor_enabled; //in state of WAIT_HTTP_REQ or DECODE_IMAGE. } +void LLViewerFetchedTexture::setBoostLevel(S32 level) +{ + LLViewerTexture::setBoostLevel(level); + + if (level >= LLViewerTexture::BOOST_HIGH) + { + mDesiredDiscardLevel = 0; + } +} + bool LLViewerFetchedTexture::updateFetch() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -1931,6 +1946,11 @@ bool LLViewerFetchedTexture::updateFetch() LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - in fast cache"); return false; } + if (mGLTexturep.isNull()) + { // fix for crash inside getCurrentDiscardLevelForFetching (shouldn't happen but appears to be happening) + llassert(false); + return false; + } S32 current_discard = getCurrentDiscardLevelForFetching(); S32 desired_discard = getDesiredDiscardLevel(); @@ -2192,8 +2212,11 @@ bool LLViewerFetchedTexture::updateFetch() mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP); } - // if createRequest() failed, we're finishing up a request for this UUID, - // wait for it to complete + // If createRequest() failed, that means one of two things: + // 1. We're finishing up a request for this UUID, so we + // should wait for it to complete + // 2. We've failed a request for this UUID, so there is + // no need to create another request } else if (mHasFetcher && !mIsFetching) { diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index a5e5c37c22..f3bc9061a2 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -134,7 +134,7 @@ public: /*virtual*/ bool isActiveFetching(); /*virtual*/ const LLUUID& getID() const { return mID; } - void setBoostLevel(S32 level); + virtual void setBoostLevel(S32 level); S32 getBoostLevel() { return mBoostLevel; } void setTextureListType(S32 tex_type) { mTextureListType = tex_type; } S32 getTextureListType() { return mTextureListType; } @@ -343,6 +343,7 @@ public: S32 getDesiredDiscardLevel() { return mDesiredDiscardLevel; } void setMinDiscardLevel(S32 discard) { mMinDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel,(S8)discard); } + void setBoostLevel(S32 level) override; bool updateFetch(); bool setDebugFetching(S32 debug_level); bool isInDebug() const { return mInDebug; } diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index ac036bce31..8faeb70553 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1025,7 +1025,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLTimer image_op_timer; - typedef std::vector<LLViewerFetchedTexture*> entries_list_t; + typedef std::vector<LLPointer<LLViewerFetchedTexture> > entries_list_t; entries_list_t entries; // update N textures at beginning of mImageList @@ -1057,10 +1057,13 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) } } - for (auto* imagep : entries) + for (auto& imagep : entries) { - updateImageDecodePriority(imagep); - imagep->updateFetch(); + if (imagep->getNumRefs() > 1) // make sure this image hasn't been deleted before attempting to update (may happen as a side effect of some other image updating) + { + updateImageDecodePriority(imagep); + imagep->updateFetch(); + } } if (entries.size() > 0) |