From df2e4bd24b03dc01b054078bc832ed665d82031d Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 7 Jul 2026 07:43:17 -0400 Subject: Kill the dead byte ledger. --- indra/newview/llviewertexture.cpp | 82 ----------------------------------- indra/newview/llviewertexture.h | 22 ---------- indra/newview/llviewertexturelist.cpp | 1 - 3 files changed, 105 deletions(-) diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 7d07c95395..80daffdbf3 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -89,8 +89,6 @@ S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sPixelToTexelRatio = 1.f; U32 LLViewerTexture::sGCSuspendedFrame = 0; -S64 LLViewerTexture::sPendingAllocBytes = 0; -S64 LLViewerTexture::sPendingFreeBytes = 0; S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size constexpr S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64; @@ -1128,7 +1126,6 @@ FTType LLViewerFetchedTexture::getFTType() const void LLViewerFetchedTexture::cleanup() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - setPendingByteDelta(0); // never leak ledger entries on teardown for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); iter != mLoadedCallbackList.end(); ) { @@ -1328,20 +1325,15 @@ void LLViewerFetchedTexture::addToCreateTexture() //just update some variables, not to create a real GL texture. createGLTexture(mRawDiscardLevel, mRawImage, 0, false); mNeedsCreateTexture = false; - setPendingByteDelta(0); // no GL bytes will be committed destroyRawImage(); } else if(!force_update && getDiscardLevel() > -1 && getDiscardLevel() <= mRawDiscardLevel) { mNeedsCreateTexture = false; - setPendingByteDelta(0); // nothing to create; commitment over destroyRawImage(); } else { - // Dims are exact now (raw decoded) - refine the ledger entry to the - // discard level that will actually be created. - setPendingByteDelta(estimatedVRAMBytesAtDiscard(mRawDiscardLevel) - residentVRAMBytes()); scheduleCreateTexture(); } return; @@ -1466,61 +1458,6 @@ bool LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/) return res; } -S64 LLViewerFetchedTexture::estimatedVRAMBytesAtDiscard(S32 discard) const -{ - if (discard < 0) - { - return 0; - } - if (mFullWidth <= 0 || mFullHeight <= 0) - { - // Dims unknown (header not fetched yet): nominal placeholder, - // corrected as soon as the first decode reports real dimensions. - return 64 * 64 * 4; - } - S32 w = llmax(1, (S32)mFullWidth >> discard); - S32 h = llmax(1, (S32)mFullHeight >> discard); - S64 bytes = (S64)w * h * 4; // GL pads most formats to 4 components - bytes = bytes * 4 / 3; // mip chain - if (LLImageGL::sCompressTextures) - { - bytes /= 4; // rough DXT ratio - } - return bytes; -} - -S64 LLViewerFetchedTexture::residentVRAMBytes() const -{ - return mGLTexturep.notNull() ? (S64)mGLTexturep->mTextureMemory.value() : 0; -} - -void LLViewerFetchedTexture::setPendingByteDelta(S64 delta) -{ - if (delta == mPendingByteDelta) - { - return; - } - // retire the previous contribution - if (mPendingByteDelta > 0) - { - sPendingAllocBytes -= mPendingByteDelta; - } - else if (mPendingByteDelta < 0) - { - sPendingFreeBytes -= -mPendingByteDelta; - } - // apply the new one - if (delta > 0) - { - sPendingAllocBytes += delta; - } - else if (delta < 0) - { - sPendingFreeBytes += -delta; - } - mPendingByteDelta = delta; -} - bool LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/) { if (!mNeedsCreateTexture) @@ -1563,7 +1500,6 @@ void LLViewerFetchedTexture::postCreateTexture() } destroyRawImage(); // will save raw image if needed - setPendingByteDelta(0); // commitment realized - bytes now in LLImageGL accounting mNeedsCreateTexture = false; } @@ -2172,11 +2108,6 @@ bool LLViewerFetchedTexture::updateFetch() // bake textures are always at discard 0 mRequestedDiscardLevel = llmin(desired_discard, fetch_request_response); - // Open the committed-bytes ledger entry: bytes this request will make - // resident minus what's resident now. Settled at postCreateTexture (or - // on the cancel/failure paths). - setPendingByteDelta(estimatedVRAMBytesAtDiscard(mRequestedDiscardLevel) - residentVRAMBytes()); - mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP); } @@ -2225,12 +2156,6 @@ bool LLViewerFetchedTexture::updateFetch() LL_DEBUGS("Texture") << "exceeded idle time " << FETCH_IDLE_TIME << ", deleting request: " << getID() << LL_ENDL; LLAppViewer::getTextureFetch()->deleteRequest(getID(), true); mHasFetcher = false; - if (!mNeedsCreateTexture && !mCreatePending) - { - // fetch retired without delivering anything still queued - - // settle the ledger (delivered data settles at postCreateTexture) - setPendingByteDelta(0); - } } } @@ -2260,10 +2185,6 @@ void LLViewerFetchedTexture::forceToDeleteRequest() mHasFetcher = false; mIsFetching = false; } - if (!mNeedsCreateTexture && !mCreatePending) - { - setPendingByteDelta(0); // request dead, nothing queued to create - } resetTextureStats(); @@ -2301,7 +2222,6 @@ void LLViewerFetchedTexture::setIsMissingAsset(bool is_missing) mFetchState = 0; mFetchPriority = 0; } - setPendingByteDelta(0); // nothing will be committed for a missing asset } else { @@ -3295,8 +3215,6 @@ bool LLViewerLODTexture::scaleDown() { mDownScalePending = true; gTextureList.mDownScaleQueue.push(this); - // Pending-free ledger entry: bytes decided-freed, returned when the queue drains. - setPendingByteDelta(estimatedVRAMBytesAtDiscard(mDesiredDiscardLevel) - residentVRAMBytes()); } return true; diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 145661fefe..cc9fbe5e48 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -246,12 +246,6 @@ public: // this, so content can re-stamp after an alt-tab before anything is collected. static U32 sGCSuspendedFrame; - // Committed-but-not-yet-realized VRAM, in bytes (main thread only). - // effective_used = resident + sPendingAllocBytes - sPendingFreeBytes. - // Maintained by setPendingByteDelta; shown in the 1Hz pressure log. - static S64 sPendingAllocBytes; // in-flight toward allocation - static S64 sPendingFreeBytes; // queued for release, not yet returned - static S32 sMaxSculptRez ; static U32 sMinLargeImageSize ; static U32 sMaxSmallImageSize ; @@ -439,18 +433,6 @@ public: bool mCreatePending = false; // if true, this is in gTextureList.mCreateTextureList mutable bool mDownScalePending = false; // if true, this is in gTextureList.mDownScaleQueue - // --- committed-bytes ledger (main thread only) --- - // Estimated VRAM bytes this texture would occupy resident at `discard` - // (components ~4, x4/3 mip chain, /4 rough DXT when compression is on). - // Nominal small placeholder before dims are known. - S64 estimatedVRAMBytesAtDiscard(S32 discard) const; - // Actual bytes currently resident (LLImageGL accounting), 0 if none. - S64 residentVRAMBytes() const; - // Open/adjust/settle this texture's contribution to the global pending - // ledgers. delta > 0 = in-flight toward allocation; delta < 0 = queued - // free; 0 = settled. Replaces any previous contribution. - void setPendingByteDelta(S64 delta); - protected: S32 getCurrentDiscardLevelForFetching() ; void forceToRefetchTexture(S32 desired_discard = 0, F32 kept_time = 60.f); @@ -539,10 +521,6 @@ protected: LLFrameTimer mLastPacketTimer; // Time since last packet. LLFrameTimer mStopFetchingTimer; // Time since mDecodePriority == 0.f. - // This texture's open contribution to the pending-bytes ledgers - // (see setPendingByteDelta). 0 = no open commitment. Main thread only. - S64 mPendingByteDelta = 0; - bool mInImageList; // true if image is in list (in which case don't reset priority!) // This needs to be atomic, since it is written both in the main thread // and in the GL image worker thread... HB diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 8fab391997..3e1481f8b4 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1389,7 +1389,6 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time) img->scaleDown(image->getDesiredDiscardLevel()); } - image->setPendingByteDelta(0); // pending-free settled (or abandoned) image->mDownScalePending = false; mDownScaleQueue.pop(); -- cgit v1.3