From c299c8038e73e541cafe3c8df135752cb48b903c Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 29 May 2026 05:29:27 -0400 Subject: Add watermark driven discards. Does a much better job of staying within the memory budget. --- indra/llprimitive/lltextureentry.cpp | 15 ++++++++++++++- indra/llprimitive/lltextureentry.h | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index ac482ffbf9..5296e86a69 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -356,6 +356,7 @@ S32 LLTextureEntry::setScale(F32 s, F32 t) { mScaleS = s; mScaleT = t; + mMinScaleSq = -1.f; // invalidate cache for getMinScaleSq() retval = TEM_CHANGE_TEXTURE; } @@ -368,6 +369,7 @@ S32 LLTextureEntry::setScaleS(F32 s) if (mScaleS != s) { mScaleS = s; + mMinScaleSq = -1.f; // invalidate cache for getMinScaleSq() retval = TEM_CHANGE_TEXTURE; } return retval; @@ -379,11 +381,22 @@ S32 LLTextureEntry::setScaleT(F32 t) if (mScaleT != t) { mScaleT = t; + mMinScaleSq = -1.f; // invalidate cache for getMinScaleSq() retval = TEM_CHANGE_TEXTURE; } return retval; } +F32 LLTextureEntry::getMinScaleSq() const +{ + if (mMinScaleSq < 0.f) + { + F32 m = llmin(fabsf(mScaleS), fabsf(mScaleT)); + mMinScaleSq = m * m; + } + return mMinScaleSq; +} + S32 LLTextureEntry::setColor(const LLColor4 &color) { if (mColor != color) @@ -600,7 +613,7 @@ LLGLTFMaterial* LLTextureEntry::getGLTFRenderMaterial() const return mGLTFRenderMaterial; } - llassert(getGLTFMaterialOverride() == nullptr || getGLTFMaterialOverride()->isClearedForBaseMaterial()); + //llassert(getGLTFMaterialOverride() == nullptr || getGLTFMaterialOverride()->isClearedForBaseMaterial()); return getGLTFMaterial(); } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 78c61b4d65..765a5f5fdc 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -143,6 +143,13 @@ public: F32 getScaleS() const { return mScaleS; } F32 getScaleT() const { return mScaleT; } + // Cached min(|mScaleS|, |mScaleT|)^2, lazily computed and invalidated + // in setScale/setScaleS/setScaleT. Used by the texture streaming face + // loop (updateImageDecodePriority) to avoid the per-face per-frame + // sqrt/abs/min/multiply chain. Returns the raw (unclamped) value; + // callers still apply TextureScaleMin/MaxAreaFactor clamps. + F32 getMinScaleSq() const; + void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } F32 getOffsetS() const { return mOffsetS; } F32 getOffsetT() const { return mOffsetT; } @@ -218,6 +225,13 @@ public: F32 mOffsetT; // S, T offset F32 mRotation; // anti-clockwise rotation in rad about the bottom left corner +private: + // Cache for getMinScaleSq(). -1.f sentinel = stale. Invalidated by + // setScale/setScaleS/setScaleT. Mutable so getMinScaleSq() can fill it + // on first read without breaking const correctness for read-only callers. + mutable F32 mMinScaleSq = -1.f; +public: + static const LLTextureEntry null; // LLSD key defines -- cgit v1.3