diff options
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
| -rw-r--r-- | indra/newview/llviewertexture.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 82f4cc8341..2504278467 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -98,6 +98,21 @@ F32 LLViewerTexture::getMemoryPressureProgress() F32 cap = llmax((F32)max_mult, 1.0001f); return llclampf((sMemoryPressureMultiplier - 1.f) / (cap - 1.f)); } + +// Effective oversample factor for the per-texture pixel-area discard cap. +// Trends from TextureScreenSizeOversample toward +// TextureScreenSizeOversampleUnderPressure as the pressure multiplier +// walks its 0..1 range; pinned to the floor above the high water mark. +static F32 pixelCapOversampleForPressure() +{ + static LLCachedControl<F32> over_base(gSavedSettings, "TextureScreenSizeOversample", 1.5f); + static LLCachedControl<F32> over_pressure(gSavedSettings, "TextureScreenSizeOversampleUnderPressure", 0.5f); + F32 base = llmax((F32)over_base, 0.1f); + F32 floor = llclamp((F32)over_pressure, 0.1f, base); + if (LLViewerTexture::sAboveHighWater) return floor; + F32 progress = LLViewerTexture::getMemoryPressureProgress(); + return base + (floor - base) * progress; +} U32 LLViewerTexture::sBiasTexturesUpdated = 0; S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size @@ -3365,6 +3380,24 @@ void LLViewerLODTexture::processTextureStats() mDesiredDiscardLevel = llmin(effective_cap, (S32)discard_level); + // Pixel-area discard cap. Don't let mDesiredDiscardLevel push the + // GL resolution below the texture's largest on-screen contribution + // x an oversample factor (sharper when we have memory headroom, + // looser under pressure). Avatar bakes exempt. + if (!isAgentAvatarBoost(mBoostLevel) && mMaxOnScreenSize > 0.f && mTexelsPerImage > 0) + { + static const F64 log_4 = log(4.0); + F32 oversample = pixelCapOversampleForPressure(); + F32 visible_texels = mMaxOnScreenSize * oversample * oversample; + visible_texels = llclamp(visible_texels, (F32)MIN_IMAGE_AREA, (F32)mTexelsPerImage); + if ((F32)mTexelsPerImage > visible_texels) + { + S32 d_pixel_cap = (S32)floor(log((F32)mTexelsPerImage / visible_texels) / log_4); + d_pixel_cap = llclamp(d_pixel_cap, 0, dim_max_for_image_i); + mDesiredDiscardLevel = llmin((S32)mDesiredDiscardLevel, d_pixel_cap); + } + } + // Apply the setMinDiscardLevel cap, relaxed under VRAM pressure // (cap_relax = 1 - 1/mult: 0 at mult=1, ~0.5 at mult=2, ~0.9 at // mult=10). Caps of 0 (thumbnails) and avatar bakes are preserved. |
