aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llviewerimage.cpp')
-rw-r--r--linden/indra/newview/llviewerimage.cpp48
1 files changed, 13 insertions, 35 deletions
diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp
index 926de7d..33210cf 100644
--- a/linden/indra/newview/llviewerimage.cpp
+++ b/linden/indra/newview/llviewerimage.cpp
@@ -238,7 +238,6 @@ void LLViewerImage::init(bool firstinit)
238 mTexelsPerImage = 64.f*64.f; 238 mTexelsPerImage = 64.f*64.f;
239 mMaxVirtualSize = 0.f; 239 mMaxVirtualSize = 0.f;
240 mDiscardVirtualSize = 0.f; 240 mDiscardVirtualSize = 0.f;
241 mMaxCosAngle = -1.f;
242 mRequestedDiscardLevel = -1; 241 mRequestedDiscardLevel = -1;
243 mRequestedDownloadPriority = 0.f; 242 mRequestedDownloadPriority = 0.f;
244 mFullyLoaded = FALSE; 243 mFullyLoaded = FALSE;
@@ -422,20 +421,12 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/)
422 421
423//============================================================================ 422//============================================================================
424 423
425void LLViewerImage::addTextureStats(F32 pixel_area, 424void LLViewerImage::addTextureStats(F32 virtual_size) const // = 1.0
426 F32 texel_area_ratio, // = 1.0
427 F32 cos_center_angle) const // = 1.0
428{ 425{
429 F32 virtual_size = pixel_area / texel_area_ratio;
430 if (virtual_size > mMaxVirtualSize) 426 if (virtual_size > mMaxVirtualSize)
431 { 427 {
432 mMaxVirtualSize = virtual_size; 428 mMaxVirtualSize = virtual_size;
433 } 429 }
434 cos_center_angle = llclamp(cos_center_angle, -1.f, 1.f);
435 if (cos_center_angle > mMaxCosAngle)
436 {
437 mMaxCosAngle = cos_center_angle;
438 }
439} 430}
440 431
441void LLViewerImage::resetTextureStats(BOOL zero) 432void LLViewerImage::resetTextureStats(BOOL zero)
@@ -443,12 +434,10 @@ void LLViewerImage::resetTextureStats(BOOL zero)
443 if (zero) 434 if (zero)
444 { 435 {
445 mMaxVirtualSize = 0.0f; 436 mMaxVirtualSize = 0.0f;
446 mMaxCosAngle = -1.0f;
447 } 437 }
448 else if (getBoostLevel() != LLViewerImage::BOOST_SCULPTED) //don't decay sculpted prim textures 438 else
449 { 439 {
450 mMaxVirtualSize -= mMaxVirtualSize * .10f; // decay by 5%/update 440 mMaxVirtualSize -= mMaxVirtualSize * .10f; // decay by 5%/update
451 mMaxCosAngle = -1.0f;
452 } 441 }
453} 442}
454 443
@@ -548,7 +537,7 @@ void LLViewerImage::processTextureStats()
548 if ((sDesiredDiscardBias > 0.0f) && 537 if ((sDesiredDiscardBias > 0.0f) &&
549 (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) 538 (current_discard >= 0 && mDesiredDiscardLevel >= current_discard))
550 { 539 {
551 if ( sBoundTextureMemory > sMaxBoundTextureMem*texmem_middle_bound_scale) 540 if ( (sBoundTextureMemory >> 20) > sMaxBoundTextureMem*texmem_middle_bound_scale)
552 { 541 {
553 // Limit the amount of GL memory bound each frame 542 // Limit the amount of GL memory bound each frame
554 if (mDesiredDiscardLevel > current_discard) 543 if (mDesiredDiscardLevel > current_discard)
@@ -556,7 +545,7 @@ void LLViewerImage::processTextureStats()
556 increase_discard = TRUE; 545 increase_discard = TRUE;
557 } 546 }
558 } 547 }
559 if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale) 548 if ( (sTotalTextureMemory >> 20) > sMaxTotalTextureMem*texmem_middle_bound_scale)
560 { 549 {
561 // Only allow GL to have 2x the video card memory 550 // Only allow GL to have 2x the video card memory
562 if (!getBoundRecently()) 551 if (!getBoundRecently())
@@ -598,7 +587,7 @@ F32 LLViewerImage::calcDecodePriority()
598 F32 priority; 587 F32 priority;
599 S32 cur_discard = getDiscardLevel(); 588 S32 cur_discard = getDiscardLevel();
600 bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel)); 589 bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel));
601 F32 pixel_priority = fsqrtf(mMaxVirtualSize) * (1.f + mMaxCosAngle); 590 F32 pixel_priority = fsqrtf(mMaxVirtualSize);
602 const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame 591 const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame
603 mDecodeFrame++; 592 mDecodeFrame++;
604 if (pixel_priority > 0.f) 593 if (pixel_priority > 0.f)
@@ -638,17 +627,12 @@ F32 LLViewerImage::calcDecodePriority()
638 return mDecodePriority; 627 return mDecodePriority;
639 } 628 }
640 } 629 }
641 else if ((mBoostLevel == LLViewerImage::BOOST_SCULPTED) && !have_all_data)
642 {
643 // Sculpted images are small, treat them like they always have no data.
644 priority = 900000.f;
645 }
646 else if (cur_discard < 0) 630 else if (cur_discard < 0)
647 { 631 {
648 // We don't have any data yet, so we don't know the size of the image, treat as 1024x1024 632 // We don't have any data yet, so we don't know the size of the image, treat as 32x32
649// priority = 900000.f; 633// priority = 900000.f;
650 static const F64 log_2 = log(2.0); 634 static const F64 log_2 = log(2.0);
651 F32 desired = (F32)(log(1024.0/pixel_priority) / log_2); 635 F32 desired = (F32)(log(32.0/pixel_priority) / log_2);
652 S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired + 1; 636 S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired + 1;
653 ddiscard = llclamp(ddiscard, 1, 9); 637 ddiscard = llclamp(ddiscard, 1, 9);
654 priority = ddiscard*100000.f; 638 priority = ddiscard*100000.f;
@@ -702,14 +686,7 @@ F32 LLViewerImage::maxDecodePriority()
702void LLViewerImage::setDecodePriority(F32 priority) 686void LLViewerImage::setDecodePriority(F32 priority)
703{ 687{
704 llassert(!mInImageList); 688 llassert(!mInImageList);
705 if (priority < 0.0f) 689 mDecodePriority = priority;
706 {
707 mDecodePriority = calcDecodePriority();
708 }
709 else
710 {
711 mDecodePriority = priority;
712 }
713} 690}
714 691
715void LLViewerImage::setBoostLevel(S32 level) 692void LLViewerImage::setBoostLevel(S32 level)
@@ -766,6 +743,7 @@ bool LLViewerImage::updateFetch()
766 S32 current_discard = getDiscardLevel(); 743 S32 current_discard = getDiscardLevel();
767 S32 desired_discard = getDesiredDiscardLevel(); 744 S32 desired_discard = getDesiredDiscardLevel();
768 F32 decode_priority = getDecodePriority(); 745 F32 decode_priority = getDecodePriority();
746 decode_priority = llmax(decode_priority, 0.0f);
769 747
770 if (mIsFetching) 748 if (mIsFetching)
771 { 749 {
@@ -783,7 +761,7 @@ bool LLViewerImage::updateFetch()
783 else 761 else
784 { 762 {
785 mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, 763 mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority,
786 mFetchPriority, mFetchDeltaTime, mRequestDeltaTime); 764 mFetchPriority, mFetchDeltaTime, mRequestDeltaTime);
787 } 765 }
788 766
789 // We may have data ready regardless of whether or not we are finished (e.g. waiting on write) 767 // We may have data ready regardless of whether or not we are finished (e.g. waiting on write)
@@ -817,7 +795,7 @@ bool LLViewerImage::updateFetch()
817 795
818 if (!mIsFetching) 796 if (!mIsFetching)
819 { 797 {
820 if (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL) 798 if ((decode_priority > 0) && (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL))
821 { 799 {
822 // We finished but received no data 800 // We finished but received no data
823 if (current_discard < 0) 801 if (current_discard < 0)
@@ -840,9 +818,9 @@ bool LLViewerImage::updateFetch()
840 destroyRawImage(); 818 destroyRawImage();
841 } 819 }
842 } 820 }
843 else if (mDecodePriority >= 0.f) 821 else
844 { 822 {
845 LLAppViewer::getTextureFetch()->updateRequestPriority(mID, mDecodePriority); 823 LLAppViewer::getTextureFetch()->updateRequestPriority(mID, decode_priority);
846 } 824 }
847 } 825 }
848 826