diff options
author | Jacek Antonelli | 2010-02-09 21:11:42 -0600 |
---|---|---|
committer | Jacek Antonelli | 2010-02-16 18:50:15 -0600 |
commit | e6247fbe78c4d3dacb74f3b2359aba2b6538133b (patch) | |
tree | 10c42d670a2c635b4339f7f68809c221756774f8 /linden/indra/newview/llviewerimagelist.cpp | |
parent | Ported some cURL and HTTP-related changes from Snowglobe. (diff) | |
download | meta-impy-e6247fbe78c4d3dacb74f3b2359aba2b6538133b.zip meta-impy-e6247fbe78c4d3dacb74f3b2359aba2b6538133b.tar.gz meta-impy-e6247fbe78c4d3dacb74f3b2359aba2b6538133b.tar.bz2 meta-impy-e6247fbe78c4d3dacb74f3b2359aba2b6538133b.tar.xz |
Ported many texture engine changes from Snowglobe.
Diffstat (limited to 'linden/indra/newview/llviewerimagelist.cpp')
-rw-r--r-- | linden/indra/newview/llviewerimagelist.cpp | 143 |
1 files changed, 84 insertions, 59 deletions
diff --git a/linden/indra/newview/llviewerimagelist.cpp b/linden/indra/newview/llviewerimagelist.cpp index bd834a0..2280937 100644 --- a/linden/indra/newview/llviewerimagelist.cpp +++ b/linden/indra/newview/llviewerimagelist.cpp | |||
@@ -42,6 +42,7 @@ | |||
42 | #include "llimagetga.h" | 42 | #include "llimagetga.h" |
43 | #include "llimagejpeg.h" | 43 | #include "llimagejpeg.h" |
44 | #include "llimagepng.h" | 44 | #include "llimagepng.h" |
45 | #include "llimageworker.h" | ||
45 | 46 | ||
46 | #include "llsdserialize.h" | 47 | #include "llsdserialize.h" |
47 | #include "llsys.h" | 48 | #include "llsys.h" |
@@ -58,6 +59,7 @@ | |||
58 | #include "llviewerimage.h" | 59 | #include "llviewerimage.h" |
59 | #include "llviewermedia.h" | 60 | #include "llviewermedia.h" |
60 | #include "llviewerregion.h" | 61 | #include "llviewerregion.h" |
62 | #include "llviewerstats.h" | ||
61 | #include "pipeline.h" | 63 | #include "pipeline.h" |
62 | #include "llappviewer.h" | 64 | #include "llappviewer.h" |
63 | 65 | ||
@@ -70,11 +72,6 @@ void (*LLViewerImageList::sUUIDCallback)(void **, const LLUUID&) = NULL; | |||
70 | U32 LLViewerImageList::sTextureBits = 0; | 72 | U32 LLViewerImageList::sTextureBits = 0; |
71 | U32 LLViewerImageList::sTexturePackets = 0; | 73 | U32 LLViewerImageList::sTexturePackets = 0; |
72 | 74 | ||
73 | const S32 IMAGES_PER_REQUEST = 42; | ||
74 | const S32 IMAGES_MIN_UPDATES = 4; // Always update the highest N images each frame | ||
75 | const S32 IMAGES_MAX_PACKET_UPDATES = 1; // Only send N packets of IMAGES_PER_REQUEST in a frame | ||
76 | const F32 RESEND_IMAGE_REQUEST_TIME = 15.f; // seconds | ||
77 | |||
78 | LLViewerImageList gImageList; | 75 | LLViewerImageList gImageList; |
79 | 76 | ||
80 | S32 LLViewerImageList::sNumImages = 0; | 77 | S32 LLViewerImageList::sNumImages = 0; |
@@ -182,6 +179,7 @@ static std::string get_texture_list_name() | |||
182 | 179 | ||
183 | void LLViewerImageList::doPrefetchImages() | 180 | void LLViewerImageList::doPrefetchImages() |
184 | { | 181 | { |
182 | #if 1 | ||
185 | if (LLAppViewer::instance()->getPurgeCache()) | 183 | if (LLAppViewer::instance()->getPurgeCache()) |
186 | { | 184 | { |
187 | // cache was purged, no point | 185 | // cache was purged, no point |
@@ -209,7 +207,7 @@ void LLViewerImageList::doPrefetchImages() | |||
209 | image->addTextureStats((F32)pixel_area); | 207 | image->addTextureStats((F32)pixel_area); |
210 | } | 208 | } |
211 | } | 209 | } |
212 | 210 | #endif | |
213 | 211 | ||
214 | } | 212 | } |
215 | 213 | ||
@@ -237,6 +235,10 @@ void LLViewerImageList::shutdown() | |||
237 | { | 235 | { |
238 | continue; // avoid UI, baked, and other special images | 236 | continue; // avoid UI, baked, and other special images |
239 | } | 237 | } |
238 | if(!image->getBoundRecently()) | ||
239 | { | ||
240 | continue ; | ||
241 | } | ||
240 | S32 desired = image->getDesiredDiscardLevel(); | 242 | S32 desired = image->getDesiredDiscardLevel(); |
241 | if (desired >= 0 && desired < MAX_DISCARD_LEVEL) | 243 | if (desired >= 0 && desired < MAX_DISCARD_LEVEL) |
242 | { | 244 | { |
@@ -323,17 +325,29 @@ LLViewerImage* LLViewerImageList::getImageFromFile(const std::string& filename, | |||
323 | LLGLenum primary_format, | 325 | LLGLenum primary_format, |
324 | const LLUUID& force_id) | 326 | const LLUUID& force_id) |
325 | { | 327 | { |
326 | if (gNoRender) | 328 | std::string full_path = gDirUtilp->findSkinnedFilename("textures", filename); |
329 | if (full_path.empty()) | ||
327 | { | 330 | { |
328 | // Never mind that this ignores image_set_id; | 331 | llwarns << "Failed to find local image file: " << filename << llendl; |
329 | // getImage() will handle that later. | ||
330 | return getImage(IMG_DEFAULT, TRUE, TRUE); | 332 | return getImage(IMG_DEFAULT, TRUE, TRUE); |
331 | } | 333 | } |
332 | 334 | ||
333 | std::string full_path = gDirUtilp->findSkinnedFilename("textures", filename); | 335 | std::string url = "file://" + full_path; |
334 | if (full_path.empty()) | 336 | |
337 | return getImageFromUrl(url, usemipmaps, level_immediate, internal_format, primary_format, force_id); | ||
338 | } | ||
339 | |||
340 | LLViewerImage* LLViewerImageList::getImageFromUrl(const std::string& url, | ||
341 | BOOL usemipmaps, | ||
342 | BOOL level_immediate, | ||
343 | LLGLint internal_format, | ||
344 | LLGLenum primary_format, | ||
345 | const LLUUID& force_id) | ||
346 | { | ||
347 | if (gNoRender) | ||
335 | { | 348 | { |
336 | llwarns << "Failed to find local image file: " << filename << llendl; | 349 | // Never mind that this ignores image_set_id; |
350 | // getImage() will handle that later. | ||
337 | return getImage(IMG_DEFAULT, TRUE, TRUE); | 351 | return getImage(IMG_DEFAULT, TRUE, TRUE); |
338 | } | 352 | } |
339 | 353 | ||
@@ -345,14 +359,14 @@ LLViewerImage* LLViewerImageList::getImageFromFile(const std::string& filename, | |||
345 | } | 359 | } |
346 | else | 360 | else |
347 | { | 361 | { |
348 | new_id.generate(full_path); | 362 | new_id.generate(url); |
349 | } | 363 | } |
350 | 364 | ||
351 | LLPointer<LLViewerImage> imagep = hasImage(new_id); | 365 | LLPointer<LLViewerImage> imagep = hasImage(new_id); |
352 | 366 | ||
353 | if (imagep.isNull()) | 367 | if (imagep.isNull()) |
354 | { | 368 | { |
355 | imagep = new LLViewerImage(full_path, new_id, usemipmaps); | 369 | imagep = new LLViewerImage(url, new_id, usemipmaps); |
356 | 370 | ||
357 | if (internal_format && primary_format) | 371 | if (internal_format && primary_format) |
358 | { | 372 | { |
@@ -364,7 +378,7 @@ LLViewerImage* LLViewerImageList::getImageFromFile(const std::string& filename, | |||
364 | if (level_immediate) | 378 | if (level_immediate) |
365 | { | 379 | { |
366 | imagep->dontDiscard(); | 380 | imagep->dontDiscard(); |
367 | imagep->setBoostLevel(LLViewerImage::BOOST_UI); | 381 | imagep->setBoostLevel(LLViewerImageBoostLevel::BOOST_UI); |
368 | } | 382 | } |
369 | } | 383 | } |
370 | 384 | ||
@@ -394,9 +408,7 @@ LLViewerImage* LLViewerImageList::getImage(const LLUUID &image_id, | |||
394 | 408 | ||
395 | if (imagep.isNull()) | 409 | if (imagep.isNull()) |
396 | { | 410 | { |
397 | imagep = new LLViewerImage(image_id, usemipmaps); | 411 | imagep = new LLViewerImage(image_id, request_from_host, usemipmaps); |
398 | // Might want to request from host other than where the agent is. JC | ||
399 | imagep->setTargetHost(request_from_host); | ||
400 | 412 | ||
401 | if (internal_format && primary_format) | 413 | if (internal_format && primary_format) |
402 | { | 414 | { |
@@ -408,7 +420,7 @@ LLViewerImage* LLViewerImageList::getImage(const LLUUID &image_id, | |||
408 | if (level_immediate) | 420 | if (level_immediate) |
409 | { | 421 | { |
410 | imagep->dontDiscard(); | 422 | imagep->dontDiscard(); |
411 | imagep->setBoostLevel(LLViewerImage::BOOST_UI); | 423 | imagep->setBoostLevel(LLViewerImageBoostLevel::BOOST_UI); |
412 | } | 424 | } |
413 | else | 425 | else |
414 | { | 426 | { |
@@ -511,23 +523,29 @@ void LLViewerImageList::dirtyImage(LLViewerImage *image) | |||
511 | void LLViewerImageList::updateImages(F32 max_time) | 523 | void LLViewerImageList::updateImages(F32 max_time) |
512 | { | 524 | { |
513 | llpushcallstacks ; | 525 | llpushcallstacks ; |
526 | LLAppViewer::getTextureFetch()->setTextureBandwidth(LLViewerStats::getInstance()->mTextureKBitStat.getMeanPerSec()); | ||
527 | |||
514 | sNumImagesStat.addValue(sNumImages); | 528 | sNumImagesStat.addValue(sNumImages); |
515 | sNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); | 529 | sNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); |
516 | sGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes)); | 530 | sGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes)); |
517 | sGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes)); | 531 | sGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes)); |
518 | sRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageRaw::sGlobalRawMemory)); | 532 | sRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageRaw::sGlobalRawMemory)); |
519 | sFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory)); | 533 | sFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory)); |
520 | 534 | ||
521 | llpushcallstacks ; | 535 | llpushcallstacks ; |
536 | |||
522 | updateImagesDecodePriorities(); | 537 | updateImagesDecodePriorities(); |
538 | |||
523 | llpushcallstacks ; | 539 | llpushcallstacks ; |
540 | F32 total_max_time = max_time; | ||
524 | max_time -= updateImagesFetchTextures(max_time); | 541 | max_time -= updateImagesFetchTextures(max_time); |
542 | |||
525 | llpushcallstacks ; | 543 | llpushcallstacks ; |
526 | max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f); | 544 | max_time = llmax(max_time, total_max_time*.25f); // at least 25% of max_time |
527 | max_time -= updateImagesCreateTextures(max_time); | 545 | max_time -= updateImagesCreateTextures(max_time); |
546 | |||
528 | llpushcallstacks ; | 547 | llpushcallstacks ; |
529 | max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f); | 548 | |
530 | llpushcallstacks ; | ||
531 | if (!mDirtyTextureList.empty()) | 549 | if (!mDirtyTextureList.empty()) |
532 | { | 550 | { |
533 | LLFastTimer t(LLFastTimer::FTM_IMAGE_MARK_DIRTY); | 551 | LLFastTimer t(LLFastTimer::FTM_IMAGE_MARK_DIRTY); |
@@ -541,7 +559,7 @@ void LLViewerImageList::updateImages(F32 max_time) | |||
541 | { | 559 | { |
542 | //trigger loaded callbacks on local textures immediately | 560 | //trigger loaded callbacks on local textures immediately |
543 | LLViewerImage* image = *iter++; | 561 | LLViewerImage* image = *iter++; |
544 | if (!image->mLocalFileName.empty()) | 562 | if (!image->mUrl.empty()) |
545 | { | 563 | { |
546 | // Do stuff to handle callbacks, update priorities, etc. | 564 | // Do stuff to handle callbacks, update priorities, etc. |
547 | didone = image->doLoadedCallbacks(); | 565 | didone = image->doLoadedCallbacks(); |
@@ -627,7 +645,7 @@ void LLViewerImageList::updateImagesDecodePriorities() | |||
627 | imagep->setInactive() ; | 645 | imagep->setInactive() ; |
628 | } | 646 | } |
629 | } | 647 | } |
630 | 648 | ||
631 | imagep->processTextureStats(); | 649 | imagep->processTextureStats(); |
632 | F32 old_priority = imagep->getDecodePriority(); | 650 | F32 old_priority = imagep->getDecodePriority(); |
633 | F32 old_priority_test = llmax(old_priority, 0.0f); | 651 | F32 old_priority_test = llmax(old_priority, 0.0f); |
@@ -701,7 +719,7 @@ F32 LLViewerImageList::updateImagesCreateTextures(F32 max_time) | |||
701 | return create_timer.getElapsedTimeF32(); | 719 | return create_timer.getElapsedTimeF32(); |
702 | } | 720 | } |
703 | 721 | ||
704 | void LLViewerImageList::forceImmediateUpdate(LLViewerImage* imagep) | 722 | void LLViewerImageList::bumpToMaxDecodePriority(LLViewerImage* imagep) |
705 | { | 723 | { |
706 | if(!imagep) | 724 | if(!imagep) |
707 | { | 725 | { |
@@ -709,6 +727,11 @@ void LLViewerImageList::forceImmediateUpdate(LLViewerImage* imagep) | |||
709 | } | 727 | } |
710 | if(imagep->mInImageList) | 728 | if(imagep->mInImageList) |
711 | { | 729 | { |
730 | if (imagep->getDecodePriority() == LLViewerImage::maxDecodePriority()) | ||
731 | { | ||
732 | // Already at maximum. | ||
733 | return; | ||
734 | } | ||
712 | removeImageFromList(imagep); | 735 | removeImageFromList(imagep); |
713 | } | 736 | } |
714 | 737 | ||
@@ -731,74 +754,76 @@ F32 LLViewerImageList::updateImagesFetchTextures(F32 max_time) | |||
731 | const size_t max_update_count = llmin((S32) (1024*10.f*gFrameIntervalSeconds)+1, 256); | 754 | const size_t max_update_count = llmin((S32) (1024*10.f*gFrameIntervalSeconds)+1, 256); |
732 | 755 | ||
733 | // 32 high priority entries | 756 | // 32 high priority entries |
734 | std::set<LLViewerImage*> entries; | 757 | typedef std::vector<LLViewerImage*> entries_list_t; |
758 | entries_list_t entries; | ||
735 | size_t update_counter = llmin(max_priority_count, mImageList.size()); | 759 | size_t update_counter = llmin(max_priority_count, mImageList.size()); |
736 | image_priority_list_t::iterator iter1 = mImageList.begin(); | 760 | image_priority_list_t::iterator iter1 = mImageList.begin(); |
737 | while(update_counter > 0) | 761 | while(update_counter > 0) |
738 | { | 762 | { |
739 | // added extra granularity and verbosity for crash logging during 1.19.1 RC. -Brad | 763 | entries.push_back(*iter1); |
740 | if(iter1 == mImageList.end()) | ||
741 | { | ||
742 | llerrs << "DEV-12002: update_counter not calculated correctly!" << llendl; | ||
743 | return 0.f; | ||
744 | } | ||
745 | |||
746 | LLPointer<LLViewerImage> const & ptr = *iter1; | ||
747 | |||
748 | LLViewerImage * img = ptr.get(); | ||
749 | |||
750 | // added extra granularity and verbosity for crash logging during 1.19.1 RC. -Brad | ||
751 | if(img == NULL) | ||
752 | { | ||
753 | llwarns << "DEV-12002: image is NULL!" << llendl; | ||
754 | } | ||
755 | |||
756 | entries.insert(img); | ||
757 | |||
758 | ++iter1; | 764 | ++iter1; |
759 | update_counter--; | 765 | update_counter--; |
760 | } | 766 | } |
761 | 767 | ||
762 | // 256 cycled entries | 768 | // 256 cycled entries |
763 | update_counter = llmin(max_update_count, mUUIDMap.size()); | 769 | update_counter = llmin(max_update_count, mUUIDMap.size()); |
764 | uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchUUID); | 770 | if (update_counter > 0) |
765 | while(update_counter > 0) | ||
766 | { | 771 | { |
767 | if (iter2 == mUUIDMap.end()) | 772 | uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchUUID); |
773 | uuid_map_t::iterator iter2p = iter2; | ||
774 | while(update_counter > 0) | ||
768 | { | 775 | { |
769 | iter2 = mUUIDMap.begin(); | 776 | if (iter2 == mUUIDMap.end()) |
777 | { | ||
778 | iter2 = mUUIDMap.begin(); | ||
779 | } | ||
780 | entries.push_back(iter2->second); | ||
781 | iter2p = iter2++; | ||
782 | update_counter--; | ||
770 | } | 783 | } |
771 | mLastFetchUUID = iter2->first; | 784 | mLastFetchUUID = iter2p->first; |
772 | entries.insert(iter2->second); | ||
773 | ++iter2; | ||
774 | update_counter--; | ||
775 | } | 785 | } |
776 | 786 | ||
787 | S32 fetch_count = 0; | ||
777 | S32 min_count = max_priority_count + max_update_count/4; | 788 | S32 min_count = max_priority_count + max_update_count/4; |
778 | for (std::set<LLViewerImage*>::iterator iter3 = entries.begin(); | 789 | for (entries_list_t::iterator iter3 = entries.begin(); |
779 | iter3 != entries.end(); ) | 790 | iter3 != entries.end(); ) |
780 | { | 791 | { |
781 | LLPointer<LLViewerImage> imagep = *iter3++; | 792 | LLPointer<LLViewerImage> imagep = *iter3++; |
782 | 793 | ||
783 | imagep->updateFetch(); | 794 | bool fetching = imagep->updateFetch(); |
795 | if (fetching) | ||
796 | { | ||
797 | fetch_count++; | ||
798 | } | ||
784 | if (min_count <= 0 && image_op_timer.getElapsedTimeF32() > max_time) | 799 | if (min_count <= 0 && image_op_timer.getElapsedTimeF32() > max_time) |
785 | { | 800 | { |
786 | break; | 801 | break; |
787 | } | 802 | } |
788 | min_count--; | 803 | min_count--; |
789 | } | 804 | } |
805 | if (fetch_count == 0) | ||
806 | { | ||
807 | gDebugTimers[0].pause(); | ||
808 | } | ||
809 | else | ||
810 | { | ||
811 | gDebugTimers[0].unpause(); | ||
812 | } | ||
813 | |||
814 | |||
790 | return image_op_timer.getElapsedTimeF32(); | 815 | return image_op_timer.getElapsedTimeF32(); |
791 | } | 816 | } |
792 | 817 | ||
793 | void LLViewerImageList::updateImagesUpdateStats() | 818 | void LLViewerImageList::updateImagesUpdateStats() |
794 | { | 819 | { |
795 | if (mUpdateStats) | 820 | if (mUpdateStats && mForceResetTextureStats) |
796 | { | 821 | { |
797 | for (image_priority_list_t::iterator iter = mImageList.begin(); | 822 | for (image_priority_list_t::iterator iter = mImageList.begin(); |
798 | iter != mImageList.end(); ) | 823 | iter != mImageList.end(); ) |
799 | { | 824 | { |
800 | LLViewerImage* imagep = *iter++; | 825 | LLViewerImage* imagep = *iter++; |
801 | imagep->resetTextureStats(mForceResetTextureStats); | 826 | imagep->resetTextureStats(); |
802 | } | 827 | } |
803 | mUpdateStats = FALSE; | 828 | mUpdateStats = FALSE; |
804 | mForceResetTextureStats = FALSE; | 829 | mForceResetTextureStats = FALSE; |
@@ -1348,7 +1373,7 @@ void LLUIImageList::onUIImageLoaded( BOOL success, LLViewerImage *src_vi, LLImag | |||
1348 | 1373 | ||
1349 | // for images grabbed from local files, apply clipping rectangle to restore original dimensions | 1374 | // for images grabbed from local files, apply clipping rectangle to restore original dimensions |
1350 | // from power-of-2 gl image | 1375 | // from power-of-2 gl image |
1351 | if (success && imagep.notNull() && src_vi && !src_vi->mLocalFileName.empty()) | 1376 | if (success && imagep.notNull() && src_vi && (src_vi->mUrl.compare(0, 7, "file://")==0)) |
1352 | { | 1377 | { |
1353 | F32 clip_x = (F32)src_vi->getOriginalWidth() / (F32)src_vi->getWidth(0); | 1378 | F32 clip_x = (F32)src_vi->getOriginalWidth() / (F32)src_vi->getWidth(0); |
1354 | F32 clip_y = (F32)src_vi->getOriginalHeight() / (F32)src_vi->getHeight(0); | 1379 | F32 clip_y = (F32)src_vi->getOriginalHeight() / (F32)src_vi->getHeight(0); |