diff options
author | Jacek Antonelli | 2009-06-13 13:17:14 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-06-13 13:17:20 -0500 |
commit | 0517fe4322443bdc317f8185590a63134e3f8394 (patch) | |
tree | 942c9c26d0792accc928010a113d123c5409659b /linden/indra/newview/llviewerimage.cpp | |
parent | Second Life viewer sources 1.23.2-RC (diff) | |
download | meta-impy-0517fe4322443bdc317f8185590a63134e3f8394.zip meta-impy-0517fe4322443bdc317f8185590a63134e3f8394.tar.gz meta-impy-0517fe4322443bdc317f8185590a63134e3f8394.tar.bz2 meta-impy-0517fe4322443bdc317f8185590a63134e3f8394.tar.xz |
Second Life viewer sources 1.23.3-RC
Diffstat (limited to 'linden/indra/newview/llviewerimage.cpp')
-rw-r--r-- | linden/indra/newview/llviewerimage.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp index ca8ed26..272fcb5 100644 --- a/linden/indra/newview/llviewerimage.cpp +++ b/linden/indra/newview/llviewerimage.cpp | |||
@@ -76,11 +76,11 @@ F32 LLViewerImage::sDesiredDiscardBias = 0.f; | |||
76 | static F32 sDesiredDiscardBiasMin = -2.0f; // -max number of levels to improve image quality by | 76 | static F32 sDesiredDiscardBiasMin = -2.0f; // -max number of levels to improve image quality by |
77 | static F32 sDesiredDiscardBiasMax = 1.5f; // max number of levels to reduce image quality by | 77 | static F32 sDesiredDiscardBiasMax = 1.5f; // max number of levels to reduce image quality by |
78 | F32 LLViewerImage::sDesiredDiscardScale = 1.1f; | 78 | F32 LLViewerImage::sDesiredDiscardScale = 1.1f; |
79 | S32 LLViewerImage::sBoundTextureMemory = 0; | 79 | S32 LLViewerImage::sBoundTextureMemoryInBytes = 0; |
80 | S32 LLViewerImage::sTotalTextureMemory = 0; | 80 | S32 LLViewerImage::sTotalTextureMemoryInBytes = 0; |
81 | S32 LLViewerImage::sMaxBoundTextureMem = 0; | 81 | S32 LLViewerImage::sMaxBoundTextureMemInMegaBytes = 0; |
82 | S32 LLViewerImage::sMaxTotalTextureMem = 0; | 82 | S32 LLViewerImage::sMaxTotalTextureMemInMegaBytes = 0; |
83 | S32 LLViewerImage::sMaxDesiredTextureMem = 0 ; | 83 | S32 LLViewerImage::sMaxDesiredTextureMemInBytes = 0 ; |
84 | BOOL LLViewerImage::sDontLoadVolumeTextures = FALSE; | 84 | BOOL LLViewerImage::sDontLoadVolumeTextures = FALSE; |
85 | 85 | ||
86 | // static | 86 | // static |
@@ -153,15 +153,17 @@ F32 texmem_middle_bound_scale = 0.925f; | |||
153 | void LLViewerImage::updateClass(const F32 velocity, const F32 angular_velocity) | 153 | void LLViewerImage::updateClass(const F32 velocity, const F32 angular_velocity) |
154 | { | 154 | { |
155 | llpushcallstacks ; | 155 | llpushcallstacks ; |
156 | sBoundTextureMemory = LLImageGL::sBoundTextureMemory;//in bytes | 156 | sBoundTextureMemoryInBytes = LLImageGL::sBoundTextureMemoryInBytes;//in bytes |
157 | sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;//in bytes | 157 | sTotalTextureMemoryInBytes = LLImageGL::sGlobalTextureMemoryInBytes;//in bytes |
158 | sMaxBoundTextureMem = gImageList.getMaxResidentTexMem();//in MB | 158 | sMaxBoundTextureMemInMegaBytes = gImageList.getMaxResidentTexMem();//in MB |
159 | sMaxTotalTextureMem = gImageList.getMaxTotalTextureMem() ;//in MB | 159 | sMaxTotalTextureMemInMegaBytes = gImageList.getMaxTotalTextureMem() ;//in MB |
160 | sMaxDesiredTextureMemInBytes = MEGA_BYTES_TO_BYTES(sMaxTotalTextureMemInMegaBytes) ; //in Bytes, by default and when total used texture memory is small. | ||
160 | 161 | ||
161 | if ((sBoundTextureMemory >> 20) >= sMaxBoundTextureMem || | 162 | if (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) >= sMaxBoundTextureMemInMegaBytes || |
162 | (sTotalTextureMemory >> 20) >= sMaxTotalTextureMem) | 163 | BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) >= sMaxTotalTextureMemInMegaBytes) |
163 | { | 164 | { |
164 | sMaxDesiredTextureMem = llmin((S32)(sMaxTotalTextureMem * 0.75f) , 0x20000000) ;//512 MB | 165 | //when texture memory overflows, lower down the threashold to release the textures more aggressively. |
166 | sMaxDesiredTextureMemInBytes = llmin((S32)(sMaxDesiredTextureMemInBytes * 0.75f) , MEGA_BYTES_TO_BYTES(MAX_VIDEO_RAM_IN_MEGA_BYTES)) ;//512 MB | ||
165 | 167 | ||
166 | // If we are using more texture memory than we should, | 168 | // If we are using more texture memory than we should, |
167 | // scale up the desired discard level | 169 | // scale up the desired discard level |
@@ -172,8 +174,8 @@ void LLViewerImage::updateClass(const F32 velocity, const F32 angular_velocity) | |||
172 | } | 174 | } |
173 | } | 175 | } |
174 | else if (sDesiredDiscardBias > 0.0f && | 176 | else if (sDesiredDiscardBias > 0.0f && |
175 | (sBoundTextureMemory >> 20) < sMaxBoundTextureMem*texmem_lower_bound_scale && | 177 | BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale && |
176 | (sTotalTextureMemory >> 20) < sMaxTotalTextureMem*texmem_lower_bound_scale) | 178 | BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale) |
177 | { | 179 | { |
178 | // If we are using less texture memory than we should, | 180 | // If we are using less texture memory than we should, |
179 | // scale down the desired discard level | 181 | // scale down the desired discard level |
@@ -351,7 +353,7 @@ void LLViewerImage::reinit(BOOL usemipmaps /* = TRUE */) | |||
351 | // ONLY called from LLViewerImageList | 353 | // ONLY called from LLViewerImageList |
352 | void LLViewerImage::destroyTexture() | 354 | void LLViewerImage::destroyTexture() |
353 | { | 355 | { |
354 | if(sGlobalTextureMemory < sMaxDesiredTextureMem)//not ready to release unused memory. | 356 | if(sGlobalTextureMemoryInBytes < sMaxDesiredTextureMemInBytes)//not ready to release unused memory. |
355 | { | 357 | { |
356 | return ; | 358 | return ; |
357 | } | 359 | } |
@@ -571,7 +573,7 @@ void LLViewerImage::processTextureStats() | |||
571 | if ((sDesiredDiscardBias > 0.0f) && | 573 | if ((sDesiredDiscardBias > 0.0f) && |
572 | (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) | 574 | (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) |
573 | { | 575 | { |
574 | if ( (sBoundTextureMemory >> 20) > sMaxBoundTextureMem*texmem_middle_bound_scale) | 576 | if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) |
575 | { | 577 | { |
576 | // Limit the amount of GL memory bound each frame | 578 | // Limit the amount of GL memory bound each frame |
577 | if (mDesiredDiscardLevel > current_discard) | 579 | if (mDesiredDiscardLevel > current_discard) |
@@ -579,7 +581,7 @@ void LLViewerImage::processTextureStats() | |||
579 | increase_discard = TRUE; | 581 | increase_discard = TRUE; |
580 | } | 582 | } |
581 | } | 583 | } |
582 | if ( (sTotalTextureMemory >> 20) > sMaxTotalTextureMem*texmem_middle_bound_scale) | 584 | if ( BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale) |
583 | { | 585 | { |
584 | // Only allow GL to have 2x the video card memory | 586 | // Only allow GL to have 2x the video card memory |
585 | if (!getBoundRecently()) | 587 | if (!getBoundRecently()) |
@@ -590,13 +592,13 @@ void LLViewerImage::processTextureStats() | |||
590 | if (increase_discard) | 592 | if (increase_discard) |
591 | { | 593 | { |
592 | // llinfos << "DISCARDED: " << mID << " Discard: " << current_discard << llendl; | 594 | // llinfos << "DISCARDED: " << mID << " Discard: " << current_discard << llendl; |
593 | sBoundTextureMemory -= mTextureMemory; | 595 | sBoundTextureMemoryInBytes -= mTextureMemory; |
594 | sTotalTextureMemory -= mTextureMemory; | 596 | sTotalTextureMemoryInBytes -= mTextureMemory; |
595 | // Increase the discard level (reduce the texture res) | 597 | // Increase the discard level (reduce the texture res) |
596 | S32 new_discard = current_discard+1; | 598 | S32 new_discard = current_discard+1; |
597 | setDiscardLevel(new_discard); | 599 | setDiscardLevel(new_discard); |
598 | sBoundTextureMemory += mTextureMemory; | 600 | sBoundTextureMemoryInBytes += mTextureMemory; |
599 | sTotalTextureMemory += mTextureMemory; | 601 | sTotalTextureMemoryInBytes += mTextureMemory; |
600 | } | 602 | } |
601 | } | 603 | } |
602 | } | 604 | } |