diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llviewerimage.cpp | 367 |
1 files changed, 103 insertions, 264 deletions
diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp index 93c17a2..400fb2f 100644 --- a/linden/indra/newview/llviewerimage.cpp +++ b/linden/indra/newview/llviewerimage.cpp | |||
@@ -60,8 +60,6 @@ | |||
60 | #include "pipeline.h" | 60 | #include "pipeline.h" |
61 | #include "llappviewer.h" | 61 | #include "llappviewer.h" |
62 | #include "llface.h" | 62 | #include "llface.h" |
63 | #include "lltextureatlas.h" | ||
64 | #include "lltextureatlasmanager.h" | ||
65 | #include "llviewercamera.h" | 63 | #include "llviewercamera.h" |
66 | /////////////////////////////////////////////////////////////////////////////// | 64 | /////////////////////////////////////////////////////////////////////////////// |
67 | 65 | ||
@@ -104,7 +102,7 @@ void LLViewerImage::initClass() | |||
104 | sNullImagep = new LLImageGL(1,1,3,TRUE); | 102 | sNullImagep = new LLImageGL(1,1,3,TRUE); |
105 | LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3); | 103 | LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3); |
106 | raw->clear(0x77, 0x77, 0x77, 0xFF); | 104 | raw->clear(0x77, 0x77, 0x77, 0xFF); |
107 | sNullImagep->createGLTexture(0, raw); | 105 | sNullImagep->createGLTexture(0, raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); |
108 | 106 | ||
109 | #if 1 | 107 | #if 1 |
110 | LLPointer<LLViewerImage> imagep = new LLViewerImage(IMG_DEFAULT); | 108 | LLPointer<LLViewerImage> imagep = new LLViewerImage(IMG_DEFAULT); |
@@ -133,7 +131,7 @@ void LLViewerImage::initClass() | |||
133 | } | 131 | } |
134 | } | 132 | } |
135 | } | 133 | } |
136 | imagep->createGLTexture(0, image_raw); | 134 | imagep->createGLTexture(0, image_raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); |
137 | image_raw = NULL; | 135 | image_raw = NULL; |
138 | gImageList.addImage(imagep); | 136 | gImageList.addImage(imagep); |
139 | imagep->dontDiscard(); | 137 | imagep->dontDiscard(); |
@@ -143,48 +141,48 @@ void LLViewerImage::initClass() | |||
143 | sSmokeImagep = gImageList.getImage(IMG_SMOKE, TRUE, TRUE); | 141 | sSmokeImagep = gImageList.getImage(IMG_SMOKE, TRUE, TRUE); |
144 | sSmokeImagep->setNoDelete() ; | 142 | sSmokeImagep->setNoDelete() ; |
145 | 143 | ||
146 | #if !LL_RELEASE_FOR_DOWNLOAD | 144 | if(gAuditTexture) |
147 | sDefaultTexturep = new LLImageGL() ; | ||
148 | image_raw = new LLImageRaw(dim,dim,3); | ||
149 | data = image_raw->getData(); | ||
150 | for (S32 i = 0; i<dim; i++) | ||
151 | { | 145 | { |
152 | for (S32 j = 0; j<dim; j++) | 146 | sDefaultTexturep = new LLImageGL() ; |
147 | image_raw = new LLImageRaw(dim,dim,3); | ||
148 | data = image_raw->getData(); | ||
149 | for (S32 i = 0; i<dim; i++) | ||
153 | { | 150 | { |
154 | const S32 border = 2; | 151 | for (S32 j = 0; j<dim; j++) |
155 | if (i<border || j<border || i>=(dim-border) || j>=(dim-border)) | ||
156 | { | ||
157 | *data++ = 0xff; | ||
158 | *data++ = 0xff; | ||
159 | *data++ = 0xff; | ||
160 | } | ||
161 | else | ||
162 | { | 152 | { |
163 | *data++ = 0xff; | 153 | const S32 border = 2; |
164 | *data++ = 0xff; | 154 | if (i<border || j<border || i>=(dim-border) || j>=(dim-border)) |
165 | *data++ = 0x00; | 155 | { |
156 | *data++ = 0xff; | ||
157 | *data++ = 0xff; | ||
158 | *data++ = 0xff; | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | *data++ = 0xff; | ||
163 | *data++ = 0xff; | ||
164 | *data++ = 0x00; | ||
165 | } | ||
166 | } | 166 | } |
167 | } | 167 | } |
168 | sDefaultTexturep->createGLTexture(0, image_raw, 0, TRUE, LLViewerImageBoostLevel::OTHER); | ||
169 | image_raw = NULL; | ||
170 | sDefaultTexturep->dontDiscard(); | ||
168 | } | 171 | } |
169 | sDefaultTexturep->createGLTexture(0, image_raw); | ||
170 | image_raw = NULL; | ||
171 | sDefaultTexturep->dontDiscard(); | ||
172 | #endif | ||
173 | } | 172 | } |
174 | 173 | ||
175 | // static | 174 | // static |
176 | void LLViewerImage::cleanupClass() | 175 | void LLViewerImage::cleanupClass() |
177 | { | 176 | { |
178 | stop_glerror(); | 177 | stop_glerror(); |
178 | LLImageGL::cleanupClass() ; | ||
179 | |||
179 | sNullImagep = NULL; | 180 | sNullImagep = NULL; |
180 | sDefaultImagep = NULL; | 181 | sDefaultImagep = NULL; |
181 | sSmokeImagep = NULL; | 182 | sSmokeImagep = NULL; |
182 | sMissingAssetImagep = NULL; | 183 | sMissingAssetImagep = NULL; |
183 | sWhiteImagep = NULL; | 184 | sWhiteImagep = NULL; |
184 | 185 | sDefaultTexturep = NULL ; | |
185 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
186 | LLImageGL::sDefaultTexturep = NULL ; | ||
187 | #endif | ||
188 | } | 186 | } |
189 | 187 | ||
190 | // tuning params | 188 | // tuning params |
@@ -233,7 +231,12 @@ void LLViewerImage::updateClass(const F32 velocity, const F32 angular_velocity) | |||
233 | } | 231 | } |
234 | sDesiredDiscardBias = llclamp(sDesiredDiscardBias, sDesiredDiscardBiasMin, sDesiredDiscardBiasMax); | 232 | sDesiredDiscardBias = llclamp(sDesiredDiscardBias, sDesiredDiscardBiasMin, sDesiredDiscardBiasMax); |
235 | 233 | ||
236 | LLImageGL::sUseTextureAtlas = gSavedSettings.getBOOL("EnableTextureAtlas") ; | 234 | F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ; |
235 | F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed(); | ||
236 | sCameraMovingDiscardBias = (S8)llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1) ; | ||
237 | |||
238 | LLViewerImage::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) && | ||
239 | (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ; | ||
237 | } | 240 | } |
238 | 241 | ||
239 | // static | 242 | // static |
@@ -379,7 +382,6 @@ LLViewerImage::~LLViewerImage() | |||
379 | void LLViewerImage::cleanup() | 382 | void LLViewerImage::cleanup() |
380 | { | 383 | { |
381 | mFaceList.clear() ; | 384 | mFaceList.clear() ; |
382 | |||
383 | for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); | 385 | for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); |
384 | iter != mLoadedCallbackList.end(); ) | 386 | iter != mLoadedCallbackList.end(); ) |
385 | { | 387 | { |
@@ -409,192 +411,6 @@ void LLViewerImage::reinit(BOOL usemipmaps /* = TRUE */) | |||
409 | setSize(0,0,0); | 411 | setSize(0,0,0); |
410 | } | 412 | } |
411 | 413 | ||
412 | void LLViewerImage::resetFaceAtlas() | ||
413 | { | ||
414 | //Nothing should be done here. | ||
415 | } | ||
416 | |||
417 | //invalidate all atlas slots for this image. | ||
418 | void LLViewerImage::invalidateAtlas(BOOL rebuild_geom) | ||
419 | { | ||
420 | for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) | ||
421 | { | ||
422 | if(*iter) | ||
423 | { | ||
424 | LLFace* facep = (LLFace*)*iter ; | ||
425 | facep->removeAtlas() ; | ||
426 | if(rebuild_geom && facep->getDrawable() && facep->getDrawable()->getSpatialGroup()) | ||
427 | { | ||
428 | facep->getDrawable()->getSpatialGroup()->setState(LLSpatialGroup::GEOM_DIRTY); | ||
429 | } | ||
430 | } | ||
431 | } | ||
432 | } | ||
433 | |||
434 | BOOL LLViewerImage::insertToAtlas() | ||
435 | { | ||
436 | if(mFaceList.size() < 1) | ||
437 | { | ||
438 | return FALSE ; | ||
439 | } | ||
440 | if(!canAddToAtlas()) | ||
441 | { | ||
442 | return FALSE ; | ||
443 | } | ||
444 | if(getDiscardLevelInAtlas() > 0 && mRawDiscardLevel >= getDiscardLevelInAtlas()) | ||
445 | { | ||
446 | return FALSE ; | ||
447 | } | ||
448 | if(!LLTextureAtlasManager::getInstance()->canAddToAtlas(mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents(), getTexTarget())) | ||
449 | { | ||
450 | return FALSE ; | ||
451 | } | ||
452 | |||
453 | BOOL ret = TRUE ;//if ret is set to false, will generate a gl texture for this image. | ||
454 | S32 raw_w = mRawImage->getWidth() ; | ||
455 | S32 raw_h = mRawImage->getHeight() ; | ||
456 | F32 xscale = 1.0f, yscale = 1.0f ; | ||
457 | LLPointer<LLTextureAtlasSlot> slot_infop; | ||
458 | LLTextureAtlasSlot* cur_slotp ;//no need to be smart pointer. | ||
459 | LLSpatialGroup* groupp ; | ||
460 | LLFace* facep; | ||
461 | |||
462 | //if the atlas slot pointers for some faces are null, process them later. | ||
463 | ll_face_list_t waiting_list ; | ||
464 | |||
465 | for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) | ||
466 | { | ||
467 | if(*iter) | ||
468 | { | ||
469 | facep = (LLFace*)*iter ; | ||
470 | |||
471 | //face can not use atlas. | ||
472 | if(!facep->canUseAtlas()) | ||
473 | { | ||
474 | if(facep->getAtlasInfo()) | ||
475 | { | ||
476 | facep->removeAtlas() ; | ||
477 | } | ||
478 | ret = FALSE ; | ||
479 | continue ; | ||
480 | } | ||
481 | |||
482 | //the atlas slot is updated | ||
483 | slot_infop = facep->getAtlasInfo() ; | ||
484 | groupp = facep->getDrawable()->getSpatialGroup() ; | ||
485 | |||
486 | if(slot_infop) | ||
487 | { | ||
488 | if(slot_infop->getSpatialGroup() != groupp) | ||
489 | { | ||
490 | if((cur_slotp = groupp->getCurUpdatingSlot(this))) //switch slot | ||
491 | { | ||
492 | facep->setAtlasInfo(cur_slotp) ; | ||
493 | facep->setAtlasInUse(TRUE) ; | ||
494 | continue ; | ||
495 | } | ||
496 | else //do not forget to update slot_infop->getSpatialGroup(). | ||
497 | { | ||
498 | LLSpatialGroup* gp = slot_infop->getSpatialGroup() ; | ||
499 | gp->setCurUpdatingTime(gFrameCount) ; | ||
500 | gp->setCurUpdatingTexture(this) ; | ||
501 | gp->setCurUpdatingSlot(slot_infop) ; | ||
502 | } | ||
503 | } | ||
504 | else //same group | ||
505 | { | ||
506 | if(gFrameCount && slot_infop->getUpdatedTime() == gFrameCount)//slot is just updated | ||
507 | { | ||
508 | facep->setAtlasInUse(TRUE) ; | ||
509 | continue ; | ||
510 | } | ||
511 | } | ||
512 | } | ||
513 | else | ||
514 | { | ||
515 | //if the slot is null, wait to process them later. | ||
516 | waiting_list.push_back(facep) ; | ||
517 | continue ; | ||
518 | } | ||
519 | |||
520 | //---------- | ||
521 | //insert to atlas | ||
522 | if(!LLImageGL::createGLTextureInAtlas(mRawDiscardLevel, mRawImage, slot_infop->getAtlas(), slot_infop->getSlotCol(), slot_infop->getSlotRow())) | ||
523 | { | ||
524 | //the texture does not qualify to add to atlas, do not bother to try for other faces. | ||
525 | //invalidateAtlas(); | ||
526 | return FALSE ; | ||
527 | } | ||
528 | |||
529 | //update texture scale | ||
530 | slot_infop->getAtlas()->getTexCoordScale(raw_w, raw_h, xscale, yscale) ; | ||
531 | slot_infop->setTexCoordScale(xscale, yscale) ; | ||
532 | slot_infop->setValid() ; | ||
533 | slot_infop->setUpdatedTime(gFrameCount) ; | ||
534 | |||
535 | //update spatial group atlas info | ||
536 | groupp->setCurUpdatingTime(gFrameCount) ; | ||
537 | groupp->setCurUpdatingTexture(this) ; | ||
538 | groupp->setCurUpdatingSlot(slot_infop) ; | ||
539 | |||
540 | //make the face to switch to the atlas. | ||
541 | facep->setAtlasInUse(TRUE) ; | ||
542 | } | ||
543 | } | ||
544 | |||
545 | //process the waiting_list | ||
546 | for(ll_face_list_t::iterator iter = waiting_list.begin(); iter != waiting_list.end(); ++iter) | ||
547 | { | ||
548 | facep = (LLFace*)*iter ; | ||
549 | groupp = facep->getDrawable()->getSpatialGroup() ; | ||
550 | |||
551 | //check if this texture already inserted to atlas for this group | ||
552 | if((cur_slotp = groupp->getCurUpdatingSlot(this))) | ||
553 | { | ||
554 | facep->setAtlasInfo(cur_slotp) ; | ||
555 | facep->setAtlasInUse(TRUE) ; | ||
556 | continue ; | ||
557 | } | ||
558 | |||
559 | //need to reserve a slot from atlas | ||
560 | slot_infop = LLTextureAtlasManager::getInstance()->reserveAtlasSlot(llmax(mFullWidth, mFullHeight), getComponents(), groupp, this) ; | ||
561 | |||
562 | facep->setAtlasInfo(slot_infop) ; | ||
563 | |||
564 | groupp->setCurUpdatingTime(gFrameCount) ; | ||
565 | groupp->setCurUpdatingTexture(this) ; | ||
566 | groupp->setCurUpdatingSlot(slot_infop) ; | ||
567 | |||
568 | //slot allocation failed. | ||
569 | if(!slot_infop || !slot_infop->getAtlas()) | ||
570 | { | ||
571 | ret = FALSE ; | ||
572 | facep->setAtlasInUse(FALSE) ; | ||
573 | continue ; | ||
574 | } | ||
575 | |||
576 | //insert to atlas | ||
577 | if(!LLImageGL::createGLTextureInAtlas(mRawDiscardLevel, mRawImage, slot_infop->getAtlas(), slot_infop->getSlotCol(), slot_infop->getSlotRow())) | ||
578 | { | ||
579 | //the texture does not qualify to add to atlas, do not bother to try for other faces. | ||
580 | ret = FALSE ; | ||
581 | //invalidateAtlas(); | ||
582 | break ; | ||
583 | } | ||
584 | |||
585 | //update texture scale | ||
586 | slot_infop->getAtlas()->getTexCoordScale(raw_w, raw_h, xscale, yscale) ; | ||
587 | slot_infop->setTexCoordScale(xscale, yscale) ; | ||
588 | slot_infop->setValid() ; | ||
589 | slot_infop->setUpdatedTime(gFrameCount) ; | ||
590 | |||
591 | //make the face to switch to the atlas. | ||
592 | facep->setAtlasInUse(TRUE) ; | ||
593 | } | ||
594 | |||
595 | return ret ; | ||
596 | } | ||
597 | |||
598 | /////////////////////////////////////////////////////////////////////////////// | 414 | /////////////////////////////////////////////////////////////////////////////// |
599 | // ONLY called from LLViewerImageList | 415 | // ONLY called from LLViewerImageList |
600 | void LLViewerImage::destroyTexture() | 416 | void LLViewerImage::destroyTexture() |
@@ -616,7 +432,7 @@ void LLViewerImage::addToCreateTexture() | |||
616 | if(isForSculptOnly()) | 432 | if(isForSculptOnly()) |
617 | { | 433 | { |
618 | //just update some variables, not to create a real GL texture. | 434 | //just update some variables, not to create a real GL texture. |
619 | createGLTexture(mRawDiscardLevel, mRawImage, 0) ; | 435 | createGLTexture(mRawDiscardLevel, mRawImage, 0, FALSE) ; |
620 | mNeedsCreateTexture = FALSE ; | 436 | mNeedsCreateTexture = FALSE ; |
621 | destroyRawImage(); | 437 | destroyRawImage(); |
622 | } | 438 | } |
@@ -679,7 +495,7 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) | |||
679 | mNeedsCreateTexture = FALSE; | 495 | mNeedsCreateTexture = FALSE; |
680 | if (mRawImage.isNull()) | 496 | if (mRawImage.isNull()) |
681 | { | 497 | { |
682 | llwarns << "LLViewerImage trying to create texture with no Raw Image" << llendl; | 498 | llerrs << "LLViewerImage trying to create texture with no Raw Image" << llendl; |
683 | } | 499 | } |
684 | // llinfos << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ", | 500 | // llinfos << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ", |
685 | // mRawDiscardLevel, | 501 | // mRawDiscardLevel, |
@@ -703,25 +519,32 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) | |||
703 | mOrigHeight = mFullHeight; | 519 | mOrigHeight = mFullHeight; |
704 | } | 520 | } |
705 | 521 | ||
706 | if (LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight())) | 522 | bool size_okay = true; |
523 | |||
524 | U32 raw_width = mRawImage->getWidth() << mRawDiscardLevel; | ||
525 | U32 raw_height = mRawImage->getHeight() << mRawDiscardLevel; | ||
526 | if( raw_width > MAX_IMAGE_SIZE || raw_height > MAX_IMAGE_SIZE ) | ||
707 | { | 527 | { |
708 | if(!(res = insertToAtlas())) | 528 | llinfos << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << llendl; |
709 | { | 529 | size_okay = false; |
710 | res = LLImageGL::createGLTexture(mRawDiscardLevel, mRawImage, usename); | ||
711 | resetFaceAtlas() ; | ||
712 | } | ||
713 | } | 530 | } |
714 | 531 | ||
715 | else | 532 | if (!LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight())) |
716 | { | 533 | { |
717 | // A non power-of-two image was uploaded (through a non standard client) | 534 | // A non power-of-two image was uploaded (through a non standard client) |
535 | llinfos << "Non power of two width or height: (" << mRawImage->getWidth() << "," << mRawImage->getHeight() << ")" << llendl; | ||
536 | size_okay = false; | ||
537 | } | ||
538 | |||
539 | if( !size_okay ) | ||
540 | { | ||
541 | // An inappropriately-sized image was uploaded (through a non standard client) | ||
718 | // We treat these images as missing assets which causes them to | 542 | // We treat these images as missing assets which causes them to |
719 | // be renderd as 'missing image' and to stop requesting data | 543 | // be renderd as 'missing image' and to stop requesting data |
720 | setIsMissingAsset(); | 544 | setIsMissingAsset(); |
721 | destroyRawImage(); | 545 | destroyRawImage(); |
722 | return FALSE; | 546 | return FALSE; |
723 | } | 547 | } |
724 | |||
725 | if (mRawImage->getComponents()>4) | 548 | if (mRawImage->getComponents()>4) |
726 | { | 549 | { |
727 | LL_DEBUGS("Openjpeg")<<"broken raw image" << LL_ENDL; | 550 | LL_DEBUGS("Openjpeg")<<"broken raw image" << LL_ENDL; |
@@ -730,6 +553,7 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) | |||
730 | return FALSE; | 553 | return FALSE; |
731 | } | 554 | } |
732 | 555 | ||
556 | res = LLImageGL::createGLTexture(mRawDiscardLevel, mRawImage, usename); | ||
733 | } | 557 | } |
734 | 558 | ||
735 | // | 559 | // |
@@ -831,7 +655,6 @@ void LLViewerImage::processTextureStats() | |||
831 | S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT); | 655 | S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT); |
832 | S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT); | 656 | S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT); |
833 | mTexelsPerImage = (F32)fullwidth * fullheight; | 657 | mTexelsPerImage = (F32)fullwidth * fullheight; |
834 | |||
835 | F32 discard_level = 0.f; | 658 | F32 discard_level = 0.f; |
836 | 659 | ||
837 | // If we know the output width and height, we can force the discard | 660 | // If we know the output width and height, we can force the discard |
@@ -839,8 +662,7 @@ void LLViewerImage::processTextureStats() | |||
839 | // data than we need to. | 662 | // data than we need to. |
840 | if (mBoostLevel == LLViewerImageBoostLevel::BOOST_UI || | 663 | if (mBoostLevel == LLViewerImageBoostLevel::BOOST_UI || |
841 | mBoostLevel == LLViewerImageBoostLevel::BOOST_PREVIEW || | 664 | mBoostLevel == LLViewerImageBoostLevel::BOOST_PREVIEW || |
842 | mBoostLevel == LLViewerImageBoostLevel::BOOST_AVATAR_SELF || | 665 | mBoostLevel == LLViewerImageBoostLevel::BOOST_AVATAR_SELF) // JAMESDEBUG what about AVATAR_BAKED_SELF? |
843 | mBoostLevel == LLViewerImageBoostLevel::BOOST_AVATAR_BAKED_SELF) | ||
844 | { | 666 | { |
845 | discard_level = 0; // full res | 667 | discard_level = 0; // full res |
846 | } | 668 | } |
@@ -855,6 +677,12 @@ void LLViewerImage::processTextureStats() | |||
855 | } | 677 | } |
856 | else | 678 | else |
857 | { | 679 | { |
680 | if(isLargeImage() && !isJustBound() && mAdditionalDecodePriority < 1.0f) | ||
681 | { | ||
682 | //if is a big image and not being used recently, nor close to the view point, do not load hi-res data. | ||
683 | mMaxVirtualSize = llmin(mMaxVirtualSize, (F32)LLViewerImage::sMinLargeImageSize) ; | ||
684 | } | ||
685 | |||
858 | if ((mCalculatedDiscardLevel >= 0.f) && | 686 | if ((mCalculatedDiscardLevel >= 0.f) && |
859 | (llabs(mMaxVirtualSize - mDiscardVirtualSize) < mMaxVirtualSize*.20f)) | 687 | (llabs(mMaxVirtualSize - mDiscardVirtualSize) < mMaxVirtualSize*.20f)) |
860 | { | 688 | { |
@@ -877,7 +705,6 @@ void LLViewerImage::processTextureStats() | |||
877 | discard_level += sCameraMovingDiscardBias ; | 705 | discard_level += sCameraMovingDiscardBias ; |
878 | } | 706 | } |
879 | discard_level = floorf(discard_level); | 707 | discard_level = floorf(discard_level); |
880 | // discard_level -= (gImageList.mVideoMemorySetting>>1); // more video ram = higher detail | ||
881 | 708 | ||
882 | F32 min_discard = 0.f; | 709 | F32 min_discard = 0.f; |
883 | if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) | 710 | if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) |
@@ -899,12 +726,15 @@ void LLViewerImage::processTextureStats() | |||
899 | if ((sDesiredDiscardBias > 0.0f) && | 726 | if ((sDesiredDiscardBias > 0.0f) && |
900 | (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) | 727 | (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) |
901 | { | 728 | { |
902 | if ( (sBoundTextureMemoryInBytes >> 20) > sMaxBoundTextureMemInMegaBytes*texmem_middle_bound_scale) | 729 | // Limit the amount of GL memory bound each frame |
730 | if ( (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) && | ||
731 | (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) | ||
903 | { | 732 | { |
904 | scaleDown() ; | 733 | scaleDown() ; |
905 | } | 734 | } |
906 | // Only allow GL to have 2x the video card memory | 735 | // Only allow GL to have 2x the video card memory |
907 | else if (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel) | 736 | else if ( (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale) && |
737 | (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) | ||
908 | { | 738 | { |
909 | scaleDown() ; | 739 | scaleDown() ; |
910 | } | 740 | } |
@@ -926,7 +756,7 @@ void LLViewerImage::updateVirtualSize() | |||
926 | if(facep->getDrawable()->isRecentlyVisible()) | 756 | if(facep->getDrawable()->isRecentlyVisible()) |
927 | { | 757 | { |
928 | addTextureStats(facep->getVirtualSize()) ; | 758 | addTextureStats(facep->getVirtualSize()) ; |
929 | //setAdditionalDecodePriority(facep->getImportanceToCamera()) ; | 759 | setAdditionalDecodePriority(facep->getImportanceToCamera()) ; |
930 | } | 760 | } |
931 | } | 761 | } |
932 | } | 762 | } |
@@ -966,7 +796,6 @@ void LLViewerImage::switchToCachedImage() | |||
966 | mNeedsCreateTexture = TRUE; | 796 | mNeedsCreateTexture = TRUE; |
967 | } | 797 | } |
968 | } | 798 | } |
969 | |||
970 | //============================================================================ | 799 | //============================================================================ |
971 | 800 | ||
972 | F32 LLViewerImage::calcDecodePriority() | 801 | F32 LLViewerImage::calcDecodePriority() |
@@ -988,6 +817,13 @@ F32 LLViewerImage::calcDecodePriority() | |||
988 | } | 817 | } |
989 | 818 | ||
990 | S32 cur_discard = getDiscardLevel(); | 819 | S32 cur_discard = getDiscardLevel(); |
820 | |||
821 | //no need to update if the texture reaches its highest res and the memory is sufficient. | ||
822 | //if(LLViewerImage::sFreezeImageScalingDown && !cur_discard) | ||
823 | //{ | ||
824 | // return -5.0f ; | ||
825 | //} | ||
826 | |||
991 | bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel)); | 827 | bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel)); |
992 | F32 pixel_priority = fsqrtf(mMaxVirtualSize); | 828 | F32 pixel_priority = fsqrtf(mMaxVirtualSize); |
993 | const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame | 829 | const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame |
@@ -1006,6 +842,14 @@ F32 LLViewerImage::calcDecodePriority() | |||
1006 | { | 842 | { |
1007 | priority = -1.0f ; | 843 | priority = -1.0f ; |
1008 | } | 844 | } |
845 | else if (!isJustBound() && mCachedRawImageReady) | ||
846 | { | ||
847 | priority = -1.0f; | ||
848 | } | ||
849 | else if(mCachedRawDiscardLevel > -1 && mDesiredDiscardLevel >= mCachedRawDiscardLevel) | ||
850 | { | ||
851 | priority = -1.0f; | ||
852 | } | ||
1009 | else if (mDesiredDiscardLevel > mMaxDiscardLevel) | 853 | else if (mDesiredDiscardLevel > mMaxDiscardLevel) |
1010 | { | 854 | { |
1011 | // Don't decode anything we don't need | 855 | // Don't decode anything we don't need |
@@ -1066,6 +910,7 @@ F32 LLViewerImage::calcDecodePriority() | |||
1066 | ddiscard-=2; | 910 | ddiscard-=2; |
1067 | } | 911 | } |
1068 | ddiscard = llclamp(ddiscard, 0, 4); | 912 | ddiscard = llclamp(ddiscard, 0, 4); |
913 | |||
1069 | priority = ddiscard*100000.f; | 914 | priority = ddiscard*100000.f; |
1070 | } | 915 | } |
1071 | if (priority > 0.0f) | 916 | if (priority > 0.0f) |
@@ -1097,7 +942,7 @@ F32 LLViewerImage::calcDecodePriority() | |||
1097 | //static | 942 | //static |
1098 | F32 LLViewerImage::maxDecodePriority() | 943 | F32 LLViewerImage::maxDecodePriority() |
1099 | { | 944 | { |
1100 | return 6000000.f; // KL 2000000 in render pipeline | 945 | return 6000000.f; |
1101 | } | 946 | } |
1102 | 947 | ||
1103 | void LLViewerImage::setDecodePriority(F32 priority) | 948 | void LLViewerImage::setDecodePriority(F32 priority) |
@@ -1124,7 +969,10 @@ void LLViewerImage::setBoostLevel(S32 level) | |||
1124 | { | 969 | { |
1125 | mBoostLevel = level; | 970 | mBoostLevel = level; |
1126 | 971 | ||
1127 | 972 | if(gAuditTexture) | |
973 | { | ||
974 | setCategory(mBoostLevel); | ||
975 | } | ||
1128 | 976 | ||
1129 | if(mBoostLevel != LLViewerImageBoostLevel::BOOST_NONE) | 977 | if(mBoostLevel != LLViewerImageBoostLevel::BOOST_NONE) |
1130 | { | 978 | { |
@@ -1174,15 +1022,11 @@ bool LLViewerImage::updateFetch() | |||
1174 | return false; // process any raw image data in callbacks before replacing | 1022 | return false; // process any raw image data in callbacks before replacing |
1175 | } | 1023 | } |
1176 | 1024 | ||
1177 | mFetchState = 0; | ||
1178 | mFetchPriority = 0; | ||
1179 | mFetchDeltaTime = 999999.f; | ||
1180 | mRequestDeltaTime = 999999.f; | ||
1181 | S32 current_discard = getDiscardLevel(); | 1025 | S32 current_discard = getDiscardLevel(); |
1182 | S32 desired_discard = getDesiredDiscardLevel(); | 1026 | S32 desired_discard = getDesiredDiscardLevel(); |
1183 | F32 decode_priority = getDecodePriority(); | 1027 | F32 decode_priority = getDecodePriority(); |
1184 | decode_priority = llmax(decode_priority, 0.0f); | 1028 | decode_priority = llmax(decode_priority, 0.0f); |
1185 | //decode_priority = llmin(decode_priority, maxDecodePriority()); | 1029 | decode_priority = llmin(decode_priority, maxDecodePriority()); |
1186 | 1030 | ||
1187 | if (mIsFetching) | 1031 | if (mIsFetching) |
1188 | { | 1032 | { |
@@ -1215,6 +1059,7 @@ bool LLViewerImage::updateFetch() | |||
1215 | if (mRawImage.notNull()) | 1059 | if (mRawImage.notNull()) |
1216 | { | 1060 | { |
1217 | mRawDiscardLevel = fetch_discard; | 1061 | mRawDiscardLevel = fetch_discard; |
1062 | |||
1218 | if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && | 1063 | if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && |
1219 | (current_discard < 0 || mRawDiscardLevel < current_discard)) | 1064 | (current_discard < 0 || mRawDiscardLevel < current_discard)) |
1220 | { | 1065 | { |
@@ -1333,6 +1178,10 @@ bool LLViewerImage::updateFetch() | |||
1333 | { | 1178 | { |
1334 | make_request = false; | 1179 | make_request = false; |
1335 | } | 1180 | } |
1181 | else if (!isJustBound() && mCachedRawImageReady) | ||
1182 | { | ||
1183 | make_request = false; | ||
1184 | } | ||
1336 | else | 1185 | else |
1337 | { | 1186 | { |
1338 | if (mIsFetching) | 1187 | if (mIsFetching) |
@@ -1367,13 +1216,14 @@ bool LLViewerImage::updateFetch() | |||
1367 | w, h, c, desired_discard, needsAux()); | 1216 | w, h, c, desired_discard, needsAux()); |
1368 | 1217 | ||
1369 | if (fetch_request_created) | 1218 | if (fetch_request_created) |
1370 | { | 1219 | { |
1371 | mHasFetcher = TRUE; | 1220 | mHasFetcher = TRUE; |
1372 | mIsFetching = TRUE; | 1221 | mIsFetching = TRUE; |
1373 | mRequestedDiscardLevel = desired_discard; | 1222 | mRequestedDiscardLevel = desired_discard; |
1223 | |||
1374 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, | 1224 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, |
1375 | mFetchPriority, mFetchDeltaTime, mRequestDeltaTime); | 1225 | mFetchPriority, mFetchDeltaTime, mRequestDeltaTime); |
1376 | } | 1226 | } |
1377 | 1227 | ||
1378 | // if createRequest() failed, we're finishing up a request for this UUID, | 1228 | // if createRequest() failed, we're finishing up a request for this UUID, |
1379 | // wait for it to complete | 1229 | // wait for it to complete |
@@ -1445,12 +1295,12 @@ BOOL LLViewerImage::forceFetch() | |||
1445 | w, h, c, desired_discard, needsAux()); | 1295 | w, h, c, desired_discard, needsAux()); |
1446 | 1296 | ||
1447 | if (fetch_request_created) | 1297 | if (fetch_request_created) |
1448 | { | 1298 | { |
1449 | mHasFetcher = TRUE; | 1299 | mHasFetcher = TRUE; |
1450 | mIsFetching = TRUE; | 1300 | mIsFetching = TRUE; |
1451 | // Set the image's decode priority to maxDecodePriority() too, or updateFetch() will set | 1301 | // Set the image's decode priority to maxDecodePriority() too, or updateFetch() will set |
1452 | // the request priority to 0 and terminate the fetch before we even started (SNOW-203). | 1302 | // the request priority to 0 and terminate the fetch before we even started (SNOW-203). |
1453 | // gImageList.bumpToMaxDecodePriority(this); // Kl force immediate update?? | 1303 | gImageList.bumpToMaxDecodePriority(this); |
1454 | mRequestedDiscardLevel = desired_discard ; | 1304 | mRequestedDiscardLevel = desired_discard ; |
1455 | 1305 | ||
1456 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, | 1306 | mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, |
@@ -1623,8 +1473,8 @@ bool LLViewerImage::doLoadedCallbacks() | |||
1623 | 1473 | ||
1624 | destroyRawImage(); | 1474 | destroyRawImage(); |
1625 | readBackRawImage(gl_discard); | 1475 | readBackRawImage(gl_discard); |
1626 | //llassert_always(mRawImage.notNull()); | 1476 | llassert_always(mRawImage.notNull()); |
1627 | //llassert_always(!mNeedsAux || mAuxRawImage.notNull()); | 1477 | llassert_always(!mNeedsAux || mAuxRawImage.notNull()); |
1628 | } | 1478 | } |
1629 | 1479 | ||
1630 | // | 1480 | // |
@@ -1786,18 +1636,7 @@ bool LLViewerImage::bindDefaultImage(S32 stage) | |||
1786 | //virtual | 1636 | //virtual |
1787 | void LLViewerImage::forceImmediateUpdate() | 1637 | void LLViewerImage::forceImmediateUpdate() |
1788 | { | 1638 | { |
1789 | //only immediately update a deleted texture which is now being re-used. | 1639 | gImageList.bumpToMaxDecodePriority(this) ; |
1790 | if(!isDeleted()) | ||
1791 | { | ||
1792 | return ; | ||
1793 | } | ||
1794 | //if already called forceImmediateUpdate() | ||
1795 | if(mInImageList && mDecodePriority == LLViewerImage::maxDecodePriority()) | ||
1796 | { | ||
1797 | return ; | ||
1798 | } | ||
1799 | |||
1800 | gImageList.forceImmediateUpdate(this) ; | ||
1801 | return ; | 1640 | return ; |
1802 | } | 1641 | } |
1803 | 1642 | ||
@@ -1808,7 +1647,7 @@ LLImageRaw* LLViewerImage::readBackRawImage(S8 discard_level) | |||
1808 | llassert_always(mComponents > 0); | 1647 | llassert_always(mComponents > 0); |
1809 | if (mRawImage.notNull()) | 1648 | if (mRawImage.notNull()) |
1810 | { | 1649 | { |
1811 | llwarns << "called with existing mRawImage" << llendl; | 1650 | llerrs << "called with existing mRawImage" << llendl; |
1812 | mRawImage = NULL; | 1651 | mRawImage = NULL; |
1813 | } | 1652 | } |
1814 | 1653 | ||
@@ -1826,7 +1665,7 @@ LLImageRaw* LLViewerImage::readBackRawImage(S8 discard_level) | |||
1826 | 1665 | ||
1827 | sRawCount++; | 1666 | sRawCount++; |
1828 | mIsRawImageValid = TRUE; | 1667 | mIsRawImageValid = TRUE; |
1829 | 1668 | ||
1830 | return mRawImage; | 1669 | return mRawImage; |
1831 | } | 1670 | } |
1832 | 1671 | ||