aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltextureview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/lltextureview.cpp')
-rw-r--r--linden/indra/newview/lltextureview.cpp238
1 files changed, 182 insertions, 56 deletions
diff --git a/linden/indra/newview/lltextureview.cpp b/linden/indra/newview/lltextureview.cpp
index 903a6e5..04cebf5 100644
--- a/linden/indra/newview/lltextureview.cpp
+++ b/linden/indra/newview/lltextureview.cpp
@@ -57,16 +57,14 @@
57extern F32 texmem_lower_bound_scale; 57extern F32 texmem_lower_bound_scale;
58 58
59LLTextureView *gTextureView = NULL; 59LLTextureView *gTextureView = NULL;
60LLTextureSizeView *gTextureSizeView = NULL;
61LLTextureSizeView *gTextureCategoryView = NULL;
62 60
63//static 61//static
64std::set<LLViewerImage*> LLTextureView::sDebugImages; 62std::set<LLViewerImage*> LLTextureView::sDebugImages;
65 63
66//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
67 65
68static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download]"); 66static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max");
69static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download]"); 67static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max");
70static std::string title_string2("State"); 68static std::string title_string2("State");
71static std::string title_string3("Pkt Bnd"); 69static std::string title_string3("Pkt Bnd");
72static std::string title_string4(" W x H (Dis) Mem"); 70static std::string title_string4(" W x H (Dis) Mem");
@@ -203,14 +201,13 @@ void LLTextureBar::draw()
203 } 201 }
204 else 202 else
205 { 203 {
206 tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x) %1.2f", 204 tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x)",
207 uuid_str.c_str(), 205 uuid_str.c_str(),
208 mImagep->mMaxVirtualSize, 206 mImagep->mMaxVirtualSize,
209 mImagep->mDesiredDiscardLevel, 207 mImagep->mDesiredDiscardLevel,
210 mImagep->mRequestedDiscardLevel, 208 mImagep->mRequestedDiscardLevel,
211 mImagep->getDecodePriority(), 209 mImagep->getDecodePriority(),
212 mImagep->mFetchPriority, 210 mImagep->mFetchPriority);
213 mImagep->mDownloadProgress);
214 } 211 }
215 212
216 LLFontGL::getFontMonospace()->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(), 213 LLFontGL::getFontMonospace()->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(),
@@ -256,7 +253,7 @@ void LLTextureBar::draw()
256 253
257 // Draw the progress bar. 254 // Draw the progress bar.
258 S32 bar_width = 100; 255 S32 bar_width = 100;
259 S32 bar_left = 330; 256 S32 bar_left = 260;
260 left = bar_left; 257 left = bar_left;
261 right = left + bar_width; 258 right = left + bar_width;
262 259
@@ -265,7 +262,7 @@ void LLTextureBar::draw()
265 262
266 F32 data_progress = mImagep->mDownloadProgress; 263 F32 data_progress = mImagep->mDownloadProgress;
267 264
268 if (data_progress > 0.0f && data_progress <= 1.0f) 265 if (data_progress > 0.0f)
269 { 266 {
270 // Downloaded bytes 267 // Downloaded bytes
271 right = left + llfloor(data_progress * (F32)bar_width); 268 right = left + llfloor(data_progress * (F32)bar_width);
@@ -275,16 +272,6 @@ void LLTextureBar::draw()
275 gl_rect_2d(left, top, right, bottom); 272 gl_rect_2d(left, top, right, bottom);
276 } 273 }
277 } 274 }
278 else if (data_progress > 1.0f)
279 {
280 // Small cached textures generate this oddity. SNOW-168
281 right = left + bar_width;
282 if (right > left)
283 {
284 gGL.color4f(0.f, 0.33f, 0.f, 0.75f);
285 gl_rect_2d(left, top, right, bottom);
286 }
287 }
288 275
289 S32 pip_width = 6; 276 S32 pip_width = 6;
290 S32 pip_space = 14; 277 S32 pip_space = 14;
@@ -399,9 +386,9 @@ private:
399 386
400void LLGLTexMemBar::draw() 387void LLGLTexMemBar::draw()
401{ 388{
402 S32 bound_mem = (LLViewerImage::sBoundTextureMemoryInBytes >> 20); 389 S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sBoundTextureMemoryInBytes);
403 S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMemInMegaBytes; 390 S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMemInMegaBytes;
404 S32 total_mem = (LLViewerImage::sTotalTextureMemoryInBytes >> 20); 391 S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sTotalTextureMemoryInBytes);
405 S32 max_total_mem = LLViewerImage::sMaxTotalTextureMemInMegaBytes; 392 S32 max_total_mem = LLViewerImage::sMaxTotalTextureMemInMegaBytes;
406 F32 discard_bias = LLViewerImage::sDesiredDiscardBias; 393 F32 discard_bias = LLViewerImage::sDesiredDiscardBias;
407 S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); 394 S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
@@ -491,25 +478,28 @@ void LLGLTexMemBar::draw()
491#endif 478#endif
492 //---------------------------------------------------------------------------- 479 //----------------------------------------------------------------------------
493 480
494 text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d HTP:%d BW: %.0f/%.0f", 481 text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d HTP:%d",
495 gImageList.getNumImages(), 482 gImageList.getNumImages(),
496 LLAppViewer::getTextureFetch()->getNumRequests(), 483 LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(),
497 LLAppViewer::getTextureFetch()->getNumDeletes(), 484 LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount,
498 LLAppViewer::getTextureFetch()->mPacketCount, 485 LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(),
499 LLAppViewer::getTextureFetch()->mBadPacketCount,
500 LLAppViewer::getTextureCache()->getNumReads(),
501 LLAppViewer::getTextureCache()->getNumWrites(),
502 LLLFSThread::sLocal->getPending(), 486 LLLFSThread::sLocal->getPending(),
503 LLAppViewer::getImageDecodeThread()->getPending(), 487 LLAppViewer::getImageDecodeThread()->getPending(),
504 LLImageRaw::sRawImageCount, 488 LLImageRaw::sRawImageCount,
505 LLAppViewer::getTextureFetch()->getNumHTTPRequests(), 489 LLAppViewer::getTextureFetch()->getNumHTTPRequests());
506 LLAppViewer::getTextureFetch()->getTextureBandwidth(),
507 gSavedSettings.getF32("ThrottleBandwidthKBPS"));
508 490
509 LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2, 491 LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2,
510 text_color, LLFontGL::LEFT, LLFontGL::TOP); 492 text_color, LLFontGL::LEFT, LLFontGL::TOP);
511 493
512 left = 600; 494
495 left = 550;
496 F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
497 F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
498 color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color;
499 color[VALPHA] = text_color[VALPHA];
500 text = llformat("BW:%.0f/%.0f",bandwidth, max_bandwidth);
501 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, line_height*2,
502 color, LLFontGL::LEFT, LLFontGL::TOP);
513 503
514 S32 dx1 = 0; 504 S32 dx1 = 0;
515 if (LLAppViewer::getTextureFetch()->mDebugPause) 505 if (LLAppViewer::getTextureFetch()->mDebugPause)
@@ -576,7 +566,7 @@ public:
576 void setTop(S32 loaded, S32 bound, F32 scale) {mTopLoaded = loaded ; mTopBound = bound; mScale = scale ;} 566 void setTop(S32 loaded, S32 bound, F32 scale) {mTopLoaded = loaded ; mTopBound = bound; mScale = scale ;}
577 567
578 void draw(); 568 void draw();
579 BOOL handleHover(S32 x, S32 y, MASK mask) ; 569 BOOL handleHover(S32 x, S32 y, MASK mask, BOOL set_pick_size) ;
580 570
581private: 571private:
582 S32 mIndex ; 572 S32 mIndex ;
@@ -589,19 +579,16 @@ private:
589 F32 mScale ; 579 F32 mScale ;
590}; 580};
591 581
592BOOL LLGLTexSizeBar::handleHover(S32 x, S32 y, MASK mask) 582BOOL LLGLTexSizeBar::handleHover(S32 x, S32 y, MASK mask, BOOL set_pick_size)
593{ 583{
594#if !LL_RELEASE_FOR_DOWNLOAD
595 if(y > mBottom && (y < mBottom + (S32)(mTopLoaded * mScale) || y < mBottom + (S32)(mTopBound * mScale))) 584 if(y > mBottom && (y < mBottom + (S32)(mTopLoaded * mScale) || y < mBottom + (S32)(mTopBound * mScale)))
596 { 585 {
597 LLImageGL::setCurTexSizebar(mIndex); 586 LLImageGL::setCurTexSizebar(mIndex, set_pick_size);
598 } 587 }
599#endif
600 return TRUE ; 588 return TRUE ;
601} 589}
602void LLGLTexSizeBar::draw() 590void LLGLTexSizeBar::draw()
603{ 591{
604#if !LL_RELEASE_FOR_DOWNLOAD
605 LLGLSUIDefault gls_ui; 592 LLGLSUIDefault gls_ui;
606 593
607 if(LLImageGL::sCurTexSizeBar == mIndex) 594 if(LLImageGL::sCurTexSizeBar == mIndex)
@@ -622,7 +609,6 @@ void LLGLTexSizeBar::draw()
622 F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; 609 F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f};
623 gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ; 610 gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ;
624 gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ; 611 gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ;
625#endif
626} 612}
627//////////////////////////////////////////////////////////////////////////// 613////////////////////////////////////////////////////////////////////////////
628 614
@@ -927,7 +913,31 @@ LLTextureSizeView::~LLTextureSizeView()
927} 913}
928void LLTextureSizeView::draw() 914void LLTextureSizeView::draw()
929{ 915{
930#if !LL_RELEASE_FOR_DOWNLOAD 916 if(mType == TEXTURE_MEM_OVER_SIZE)
917 {
918 drawTextureSizeGraph();
919 }
920 else
921 {
922 drawTextureCategoryGraph() ;
923 }
924
925 LLView::draw();
926}
927
928BOOL LLTextureSizeView::handleHover(S32 x, S32 y, MASK mask)
929{
930 if(x > mTextureSizeBarRect.mLeft && x < mTextureSizeBarRect.mRight)
931 {
932 mTextureSizeBar[(x - mTextureSizeBarRect.mLeft) / mTextureSizeBarWidth]->handleHover(x, y, mask, (mType == TEXTURE_MEM_OVER_SIZE)) ;
933 }
934
935 return TRUE ;
936}
937
938//draw real-time texture mem bar over size
939void LLTextureSizeView::drawTextureSizeGraph()
940{
931 if(mTextureSizeBar.size() == 0) 941 if(mTextureSizeBar.size() == 0)
932 { 942 {
933 S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); 943 S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
@@ -948,29 +958,16 @@ void LLTextureSizeView::draw()
948 mTextureSizeBar[i]->draw() ; 958 mTextureSizeBar[i]->draw() ;
949 } 959 }
950 LLImageGL::resetCurTexSizebar(); 960 LLImageGL::resetCurTexSizebar();
951
952 LLView::draw();
953#endif
954}
955
956BOOL LLTextureSizeView::handleHover(S32 x, S32 y, MASK mask)
957{
958 if(x > mTextureSizeBarRect.mLeft && x < mTextureSizeBarRect.mRight)
959 {
960 mTextureSizeBar[(x - mTextureSizeBarRect.mLeft) / mTextureSizeBarWidth]->handleHover(x, y, mask) ;
961 }
962
963 return TRUE ;
964} 961}
965 962
966//draw background of texture size bar graph 963//draw background of texture size bar graph
967F32 LLTextureSizeView::drawTextureSizeDistributionGraph() 964F32 LLTextureSizeView::drawTextureSizeDistributionGraph()
968{ 965{
966 //scale
969 F32 scale = 1.0f ; 967 F32 scale = 1.0f ;
970#if !LL_RELEASE_FOR_DOWNLOAD 968
971 LLGLSUIDefault gls_ui; 969 LLGLSUIDefault gls_ui;
972 970
973 //scale
974 { 971 {
975 S32 count = 0 ; 972 S32 count = 0 ;
976 for(U32 i = 0 ; i < LLImageGL::sTextureLoadedCounter.size() ; i++) 973 for(U32 i = 0 ; i < LLImageGL::sTextureLoadedCounter.size() ; i++)
@@ -1060,7 +1057,136 @@ F32 LLTextureSizeView::drawTextureSizeDistributionGraph()
1060 text = llformat("Texture Size Distribution") ; 1057 text = llformat("Texture Size Distribution") ;
1061 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3, 1058 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3,
1062 text_color, LLFontGL::LEFT, LLFontGL::TOP); 1059 text_color, LLFontGL::LEFT, LLFontGL::TOP);
1060 return scale ;
1061}
1062
1063//draw real-time texture mem bar over category
1064void LLTextureSizeView::drawTextureCategoryGraph()
1065{
1066 if(mTextureSizeBar.size() == 0)
1067 {
1068 S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
1069 mTextureSizeBar.resize(LLImageGL::sTextureMemByCategory.size()) ;
1070 mTextureSizeBarRect.set(700, line_height * 2 + 400, 700 + mTextureSizeBar.size() * mTextureSizeBarWidth, line_height * 2) ;
1071
1072 for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++)
1073 {
1074 mTextureSizeBar[i] = new LLGLTexSizeBar(i, mTextureSizeBarRect.mLeft + i * mTextureSizeBarWidth ,
1075 line_height * 2, mTextureSizeBarRect.mLeft + (i + 1) * mTextureSizeBarWidth, line_height) ;
1076 }
1077 }
1078
1079 F32 size_bar_scale = drawTextureCategoryDistributionGraph() ;
1080 for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++)
1081 {
1082 mTextureSizeBar[i]->setTop(LLImageGL::sTextureMemByCategory[i] >> 20, LLImageGL::sTextureMemByCategoryBound[i] >> 20, size_bar_scale) ;
1083 mTextureSizeBar[i]->draw() ;
1084 }
1085 LLImageGL::resetCurTexSizebar();
1086}
1087
1088//draw background for TEXTURE_MEM_OVER_CATEGORY
1089F32 LLTextureSizeView::drawTextureCategoryDistributionGraph()
1090{
1091 //scale
1092 F32 scale = 4.0f ;
1093
1094 LLGLSUIDefault gls_ui;
1095
1096 {
1097 S32 count = 0 ;
1098 for(U32 i = 0 ; i < LLImageGL::sTextureMemByCategory.size() ; i++)
1099 {
1100 S32 tmp = LLImageGL::sTextureMemByCategory[i] >> 20 ;
1101 if(tmp > count)
1102 {
1103 count = tmp ;
1104 }
1105 }
1106 if(count > mTextureSizeBarRect.getHeight() * 0.25f)
1107 {
1108 scale = (F32)mTextureSizeBarRect.getHeight() * 0.25f / count ;
1109 }
1110 }
1111
1112 S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
1113 S32 left = mTextureSizeBarRect.mLeft ;
1114 S32 bottom = mTextureSizeBarRect.mBottom ;
1115 S32 right = mTextureSizeBarRect.mRight ;
1116 S32 top = mTextureSizeBarRect.mTop ;
1117
1118 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1119
1120 //background rect
1121 gl_rect_2d(left - 25, top + 30, right + 100, bottom - 25, LLColor4(0.0f, 0.0f, 0.0f, 0.25f)) ;
1122
1123 //--------------------------------------------------
1124 gGL.color4f(1.0f, 0.5f, 0.5f, 0.75f);
1125 gl_line_2d(left, bottom, right, bottom) ; //x axis
1126 gl_line_2d(left, bottom, left, top) ; //y axis
1127
1128 //ruler
1129 //--------------------------------------------------
1130 gGL.color4f(1.0f, 0.5f, 0.5f, 0.5f);
1131 for(S32 i = bottom + 50 ; i <= top ; i += 50)
1132 {
1133 gl_line_2d(left, i, right, i) ;
1134 }
1135
1136 //texts
1137 //--------------------------------------------------
1138 F32 text_color[] = {1.f, 1.f, 1.f, 0.75f};
1139 std::string text;
1140
1141 //-------
1142 //x axis: size label
1143 static char category[LLViewerImageBoostLevel::MAX_GL_IMAGE_CATEGORY][4] =
1144 {"Non", "Bak", "Av", "Cld", "Scp", "Hi", "Trn", "Slt", "Hud", "Bsf", "UI", "Pvw", "Map", "Mvs", "Slf", "Tbp", "Scr", "Fnt", "Bmp", "Dyn", "Tlc", "Mdi", "ALT", "Oth" } ;
1145
1146 text = llformat("%s", category[0]) ;
1147 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 12, bottom - line_height / 2,
1148 text_color, LLFontGL::LEFT, LLFontGL::TOP);
1149 for(U32 i = 1 ; i < mTextureSizeBar.size() ; i++)
1150 {
1151 text = llformat("%s", category[i]) ;
1152 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + i * mTextureSizeBarWidth + 12, bottom - line_height / 2,
1153 text_color, LLFontGL::LEFT, LLFontGL::TOP);
1154 }
1155 //-------
1156
1157 //y axis: number label
1158 for(S32 i = bottom + 50 ; i <= top ; i += 50)
1159 {
1160 text = llformat("%d", (S32)((i - bottom) / scale)) ;
1161 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left - 20, i + line_height / 2 ,
1162 text_color, LLFontGL::LEFT, LLFontGL::TOP);
1163 LLFontGL::getFontMonospace()->renderUTF8(text, 0, right + 5, i + line_height / 2 ,
1164 text_color, LLFontGL::LEFT, LLFontGL::TOP);
1165 }
1166
1167 text = llformat("MB") ;
1168 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left - 20, top + line_height * 2 ,
1169 text_color, LLFontGL::LEFT, LLFontGL::TOP);
1170 //--------------------------------------------------
1171 F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f};
1172 gl_rect_2d(left + 70, top + line_height * 2, left + 90, top + line_height, loaded_color) ;
1173 text = llformat("Loaded") ;
1174 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 100, top + line_height * 2,
1175 loaded_color,
1176 LLFontGL::LEFT, LLFontGL::TOP);
1177
1178 F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f};
1179 gl_rect_2d(left + 170, top + line_height * 2, left + 190, top + line_height, bound_color) ;
1180 text = llformat("Bound") ;
1181 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 200, top + line_height * 2,
1182 bound_color, LLFontGL::LEFT, LLFontGL::TOP);
1183
1184 //--------------------------------------------------
1185
1186 //title
1187 text = llformat("Texture Category Distribution") ;
1188 LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3,
1189 text_color, LLFontGL::LEFT, LLFontGL::TOP);
1063 1190
1064#endif
1065 return scale ; 1191 return scale ;
1066} 1192}