Skip to content

Commit 9159922

Browse files
committed
#3371 Texture resolution cap #2
1 parent c85880a commit 9159922

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

indra/newview/llviewertexture.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTextur
108108

109109
const F64 log_2 = log(2.0);
110110

111-
#if ADDRESS_SIZE == 32
112-
const U32 DESIRED_NORMAL_TEXTURE_SIZE = (U32)LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT / 2;
113-
#else
114-
const U32 DESIRED_NORMAL_TEXTURE_SIZE = (U32)LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT;
115-
#endif
116-
117111
//----------------------------------------------------------------------------------------------
118112
//namespace: LLViewerTextureAccess
119113
//----------------------------------------------------------------------------------------------
@@ -1694,14 +1688,14 @@ void LLViewerFetchedTexture::processTextureStats()
16941688

16951689
static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes", false);
16961690

1691+
U32 max_tex_res = MAX_IMAGE_SIZE_DEFAULT;
16971692
if (mBoostLevel < LLGLTexture::BOOST_HIGH)
16981693
{
16991694
// restrict texture resolution to download based on RenderMaxTextureResolution
17001695
static LLCachedControl<U32> max_texture_resolution(gSavedSettings, "RenderMaxTextureResolution", 2048);
17011696
// sanity clamp debug setting to avoid settings hack shenanigans
1702-
F32 tex_res = (F32)llclamp((S32)max_texture_resolution, 512, MAX_IMAGE_SIZE_DEFAULT);
1703-
tex_res *= tex_res;
1704-
mMaxVirtualSize = llmin(mMaxVirtualSize, tex_res);
1697+
max_tex_res = (U32)llclamp((U32)max_texture_resolution, 512, MAX_IMAGE_SIZE_DEFAULT);
1698+
mMaxVirtualSize = llmin(mMaxVirtualSize, (F32)(max_tex_res * max_tex_res));
17051699
}
17061700

17071701
if (textures_fullres)
@@ -1725,10 +1719,9 @@ void LLViewerFetchedTexture::processTextureStats()
17251719
}
17261720
else
17271721
{
1728-
U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 2048 and max size ever is 4096
17291722
if(!mKnownDrawWidth || !mKnownDrawHeight || (S32)mFullWidth <= mKnownDrawWidth || (S32)mFullHeight <= mKnownDrawHeight)
17301723
{
1731-
if (mFullWidth > desired_size || mFullHeight > desired_size)
1724+
if (mFullWidth > max_tex_res || mFullHeight > max_tex_res)
17321725
{
17331726
mDesiredDiscardLevel = 1;
17341727
}
@@ -2958,14 +2951,14 @@ void LLViewerLODTexture::processTextureStats()
29582951

29592952
static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes", false);
29602953

2954+
F32 max_tex_res = MAX_IMAGE_SIZE_DEFAULT;
29612955
if (mBoostLevel < LLGLTexture::BOOST_HIGH)
29622956
{
29632957
// restrict texture resolution to download based on RenderMaxTextureResolution
29642958
static LLCachedControl<U32> max_texture_resolution(gSavedSettings, "RenderMaxTextureResolution", 2048);
29652959
// sanity clamp debug setting to avoid settings hack shenanigans
2966-
F32 tex_res = (F32)llclamp((S32)max_texture_resolution, 512, MAX_IMAGE_SIZE_DEFAULT);
2967-
tex_res *= tex_res;
2968-
mMaxVirtualSize = llmin(mMaxVirtualSize, tex_res);
2960+
max_tex_res = (F32)llclamp((S32)max_texture_resolution, 512, MAX_IMAGE_SIZE_DEFAULT);
2961+
mMaxVirtualSize = llmin(mMaxVirtualSize, max_tex_res * max_tex_res);
29692962
}
29702963

29712964
if (textures_fullres)
@@ -3021,12 +3014,7 @@ void LLViewerLODTexture::processTextureStats()
30213014
discard_level = floorf(discard_level);
30223015

30233016
F32 min_discard = 0.f;
3024-
U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 2048 and max size ever is 4096
3025-
if (mBoostLevel <= LLGLTexture::BOOST_SCULPTED)
3026-
{
3027-
desired_size = DESIRED_NORMAL_TEXTURE_SIZE;
3028-
}
3029-
if (mFullWidth > desired_size || mFullHeight > desired_size)
3017+
if (mFullWidth > max_tex_res || mFullHeight > max_tex_res)
30303018
min_discard = 1.f;
30313019

30323020
discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL);

0 commit comments

Comments
 (0)