summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexture.cpp
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-10-17 00:06:22 -0700
committerRichard Linden <none@none>2012-10-17 00:06:22 -0700
commite6ca5471a2a816a24888ae1b38332531b22b7254 (patch)
tree8eb0adb0db391bc775e79dee6486e2d51a6e3c04 /indra/newview/llviewertexture.cpp
parent8d2f7a526545a10cd3669bf837a0b6f02cf5fe71 (diff)
SH-3275 Update viewer metrics system to be more flexible
put template parameter back in LLUnit units added free function operators for mathematical manipulation of unit values converted texture memory tracking to units
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
-rw-r--r--indra/newview/llviewertexture.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index b0f8f60d1e..f64134b8b7 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -64,6 +64,11 @@
#include "lltexturecache.h"
///////////////////////////////////////////////////////////////////////////////
+// extern
+const LLUnit::Megabytes<S32> gMinVideoRam = 32;
+const LLUnit::Megabytes<S32> gMaxVideoRam = 512;
+
+
// statics
LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL;
LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = NULL;
@@ -82,11 +87,11 @@ S32 LLViewerTexture::sAuxCount = 0;
LLFrameTimer LLViewerTexture::sEvaluationTimer;
F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
-S32 LLViewerTexture::sBoundTextureMemoryInBytes = 0;
-S32 LLViewerTexture::sTotalTextureMemoryInBytes = 0;
-S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0;
-S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0;
-S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ;
+LLUnit::Bytes<S32> LLViewerTexture::sBoundTextureMemory = 0;
+LLUnit::Bytes<S32> LLViewerTexture::sTotalTextureMemory = 0;
+LLUnit::Megabytes<S32> LLViewerTexture::sMaxBoundTextureMem = 0;
+LLUnit::Megabytes<S32> LLViewerTexture::sMaxTotalTextureMem = 0;
+LLUnit::Bytes<S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ;
F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
@@ -518,17 +523,17 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
LLViewerMediaTexture::updateClass() ;
}
- sBoundTextureMemoryInBytes = LLImageGL::sBoundTextureMemoryInBytes;//in bytes
- sTotalTextureMemoryInBytes = LLImageGL::sGlobalTextureMemoryInBytes;//in bytes
- sMaxBoundTextureMemInMegaBytes = gTextureList.getMaxResidentTexMem();//in MB
- sMaxTotalTextureMemInMegaBytes = gTextureList.getMaxTotalTextureMem() ;//in MB
- sMaxDesiredTextureMemInBytes = MEGA_BYTES_TO_BYTES(sMaxTotalTextureMemInMegaBytes) ; //in Bytes, by default and when total used texture memory is small.
+ sBoundTextureMemory = LLImageGL::sBoundTextureMemory;//in bytes
+ sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;//in bytes
+ sMaxBoundTextureMem = gTextureList.getMaxResidentTexMem();//in MB
+ sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem() ;//in MB
+ sMaxDesiredTextureMem = sMaxTotalTextureMem ; //in Bytes, by default and when total used texture memory is small.
- if (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) >= sMaxBoundTextureMemInMegaBytes ||
- BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) >= sMaxTotalTextureMemInMegaBytes)
+ if (sBoundTextureMemory >= sMaxBoundTextureMem ||
+ sTotalTextureMemory >= sMaxTotalTextureMem)
{
//when texture memory overflows, lower down the threashold to release the textures more aggressively.
- sMaxDesiredTextureMemInBytes = llmin((S32)(sMaxDesiredTextureMemInBytes * 0.75f) , MEGA_BYTES_TO_BYTES(MAX_VIDEO_RAM_IN_MEGA_BYTES)) ;//512 MB
+ sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, (LLUnit::Bytes<S32>)gMaxVideoRam) ;//512 MB
// If we are using more texture memory than we should,
// scale up the desired discard level
@@ -544,8 +549,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
sEvaluationTimer.reset();
}
else if (sDesiredDiscardBias > 0.0f &&
- BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale &&
- BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale)
+ sBoundTextureMemory < sMaxBoundTextureMem * texmem_lower_bound_scale &&
+ sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale)
{
// If we are using less texture memory than we should,
// scale down the desired discard level
@@ -563,8 +568,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1);
sCameraMovingDiscardBias = (S8)(sCameraMovingBias);
- LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) &&
- (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ;
+ LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < 0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale) &&
+ (sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale) ;
}
//end of static functions
@@ -3301,13 +3306,13 @@ void LLViewerLODTexture::processTextureStats()
scaleDown() ;
}
// Limit the amount of GL memory bound each frame
- else if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale &&
+ else if ( sBoundTextureMemory > sMaxBoundTextureMem * texmem_middle_bound_scale &&
(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel))
{
scaleDown() ;
}
// Only allow GL to have 2x the video card memory
- else if ( BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale &&
+ else if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale &&
(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel))
{
scaleDown() ;