aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llimagegl.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2010-02-09 21:11:42 -0600
committerJacek Antonelli2010-02-16 18:50:15 -0600
commite6247fbe78c4d3dacb74f3b2359aba2b6538133b (patch)
tree10c42d670a2c635b4339f7f68809c221756774f8 /linden/indra/llrender/llimagegl.cpp
parentPorted some cURL and HTTP-related changes from Snowglobe. (diff)
downloadmeta-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 '')
-rw-r--r--linden/indra/llrender/llimagegl.cpp273
1 files changed, 225 insertions, 48 deletions
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index d1efb11..27b1d55 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -43,8 +43,6 @@
43#include "llmath.h" 43#include "llmath.h"
44#include "llgl.h" 44#include "llgl.h"
45#include "llrender.h" 45#include "llrender.h"
46
47
48//---------------------------------------------------------------------------- 46//----------------------------------------------------------------------------
49 47
50const F32 MIN_TEXTURE_LIFETIME = 10.f; 48const F32 MIN_TEXTURE_LIFETIME = 10.f;
@@ -61,8 +59,33 @@ S32 LLImageGL::sCount = 0;
61 59
62BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; 60BOOL LLImageGL::sGlobalUseAnisotropic = FALSE;
63F32 LLImageGL::sLastFrameTime = 0.f; 61F32 LLImageGL::sLastFrameTime = 0.f;
62BOOL LLImageGL::sAllowReadBackRaw = FALSE ;
64 63
65std::set<LLImageGL*> LLImageGL::sImageList; 64std::set<LLImageGL*> LLImageGL::sImageList;
65
66//****************************************************************************************************
67//The below for texture auditing use only
68//****************************************************************************************************
69//-----------------------
70//debug use
71BOOL gAuditTexture = FALSE ;
72#define MAX_TEXTURE_LOG_SIZE 22 //2048 * 2048
73std::vector<S32> LLImageGL::sTextureLoadedCounter(MAX_TEXTURE_LOG_SIZE + 1) ;
74std::vector<S32> LLImageGL::sTextureBoundCounter(MAX_TEXTURE_LOG_SIZE + 1) ;
75std::vector<S32> LLImageGL::sTextureCurBoundCounter(MAX_TEXTURE_LOG_SIZE + 1) ;
76S32 LLImageGL::sCurTexSizeBar = -1 ;
77S32 LLImageGL::sCurTexPickSize = -1 ;
78LLPointer<LLImageGL> LLImageGL::sDefaultTexturep = NULL;
79S32 LLImageGL::sMaxCatagories = 1 ;
80
81std::vector<S32> LLImageGL::sTextureMemByCategory;
82std::vector<S32> LLImageGL::sTextureMemByCategoryBound ;
83std::vector<S32> LLImageGL::sTextureCurMemByCategoryBound ;
84//------------------------
85//****************************************************************************************************
86//End for texture auditing use only
87//****************************************************************************************************
88
66//************************************************************************************** 89//**************************************************************************************
67//below are functions for debug use 90//below are functions for debug use
68//do not delete them even though they are not currently being used. 91//do not delete them even though they are not currently being used.
@@ -110,6 +133,20 @@ void LLImageGL::checkTexSize() const
110//************************************************************************************** 133//**************************************************************************************
111 134
112//---------------------------------------------------------------------------- 135//----------------------------------------------------------------------------
136//static
137void LLImageGL::initClass(S32 num_catagories)
138{
139 sMaxCatagories = num_catagories ;
140
141 sTextureMemByCategory.resize(sMaxCatagories);
142 sTextureMemByCategoryBound.resize(sMaxCatagories) ;
143 sTextureCurMemByCategoryBound.resize(sMaxCatagories) ;
144}
145
146//static
147void LLImageGL::cleanupClass()
148{
149}
113 150
114//static 151//static
115S32 LLImageGL::dataFormatBits(S32 dataformat) 152S32 LLImageGL::dataFormatBits(S32 dataformat)
@@ -176,12 +213,44 @@ void LLImageGL::updateStats(F32 current_time)
176 sLastFrameTime = current_time; 213 sLastFrameTime = current_time;
177 sBoundTextureMemoryInBytes = sCurBoundTextureMemory; 214 sBoundTextureMemoryInBytes = sCurBoundTextureMemory;
178 sCurBoundTextureMemory = 0; 215 sCurBoundTextureMemory = 0;
216
217 if(gAuditTexture)
218 {
219 for(U32 i = 0 ; i < sTextureCurBoundCounter.size() ; i++)
220 {
221 sTextureBoundCounter[i] = sTextureCurBoundCounter[i] ;
222 sTextureCurBoundCounter[i] = 0 ;
223 }
224 for(U32 i = 0 ; i < sTextureCurMemByCategoryBound.size() ; i++)
225 {
226 sTextureMemByCategoryBound[i] = sTextureCurMemByCategoryBound[i] ;
227 sTextureCurMemByCategoryBound[i] = 0 ;
228 }
229 }
179} 230}
180 231
181//static 232//static
182S32 LLImageGL::updateBoundTexMem(const S32 delta) 233S32 LLImageGL::updateBoundTexMemStatic(const S32 delta, const S32 size, S32 category)
234{
235 if(gAuditTexture)
236 {
237 sTextureCurBoundCounter[getTextureCounterIndex(size)]++ ;
238 sTextureCurMemByCategoryBound[category] += delta ;
239 }
240
241 LLImageGL::sCurBoundTextureMemory += delta ;
242 return LLImageGL::sCurBoundTextureMemory;
243}
244
245S32 LLImageGL::updateBoundTexMem()const
183{ 246{
184 LLImageGL::sCurBoundTextureMemory += delta; 247 if(gAuditTexture)
248 {
249 sTextureCurBoundCounter[getTextureCounterIndex(mTextureMemory / mComponents)]++ ;
250 sTextureCurMemByCategoryBound[mCategory] += mTextureMemory ;
251 }
252
253 LLImageGL::sCurBoundTextureMemory += mTextureMemory ;
185 return LLImageGL::sCurBoundTextureMemory; 254 return LLImageGL::sCurBoundTextureMemory;
186} 255}
187 256
@@ -195,6 +264,7 @@ void LLImageGL::destroyGL(BOOL save_state)
195 gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); 264 gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE);
196 } 265 }
197 266
267 sAllowReadBackRaw = true ;
198 for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); 268 for (std::set<LLImageGL*>::iterator iter = sImageList.begin();
199 iter != sImageList.end(); iter++) 269 iter != sImageList.end(); iter++)
200 { 270 {
@@ -204,7 +274,7 @@ void LLImageGL::destroyGL(BOOL save_state)
204 if (save_state && glimage->isGLTextureCreated() && glimage->mComponents) 274 if (save_state && glimage->isGLTextureCreated() && glimage->mComponents)
205 { 275 {
206 glimage->mSaveData = new LLImageRaw; 276 glimage->mSaveData = new LLImageRaw;
207 if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) 277 if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it.
208 { 278 {
209 glimage->mSaveData = NULL ; 279 glimage->mSaveData = NULL ;
210 } 280 }
@@ -214,6 +284,7 @@ void LLImageGL::destroyGL(BOOL save_state)
214 stop_glerror(); 284 stop_glerror();
215 } 285 }
216 } 286 }
287 sAllowReadBackRaw = false ;
217} 288}
218 289
219//static 290//static
@@ -231,7 +302,7 @@ void LLImageGL::restoreGL()
231 { 302 {
232 if (glimage->getComponents() && glimage->mSaveData->getComponents()) 303 if (glimage->getComponents() && glimage->mSaveData->getComponents())
233 { 304 {
234 glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData); 305 glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData, 0, TRUE, glimage->getCategory());
235 stop_glerror(); 306 stop_glerror();
236 } 307 }
237 glimage->mSaveData = NULL; // deletes data 308 glimage->mSaveData = NULL; // deletes data
@@ -311,7 +382,7 @@ void LLImageGL::init(BOOL usemipmaps)
311 mTextureState = NO_DELETE ; 382 mTextureState = NO_DELETE ;
312 mTextureMemory = 0; 383 mTextureMemory = 0;
313 mLastBindTime = 0.f; 384 mLastBindTime = 0.f;
314 385
315 mTarget = GL_TEXTURE_2D; 386 mTarget = GL_TEXTURE_2D;
316 mBindTarget = LLTexUnit::TT_TEXTURE; 387 mBindTarget = LLTexUnit::TT_TEXTURE;
317 mUseMipMaps = usemipmaps; 388 mUseMipMaps = usemipmaps;
@@ -338,7 +409,9 @@ void LLImageGL::init(BOOL usemipmaps)
338 mHasExplicitFormat = FALSE; 409 mHasExplicitFormat = FALSE;
339 410
340 mGLTextureCreated = FALSE ; 411 mGLTextureCreated = FALSE ;
412
341 mIsMask = FALSE; 413 mIsMask = FALSE;
414 mCategory = -1 ;
342} 415}
343 416
344void LLImageGL::cleanup() 417void LLImageGL::cleanup()
@@ -438,6 +511,10 @@ void LLImageGL::dump()
438} 511}
439 512
440//---------------------------------------------------------------------------- 513//----------------------------------------------------------------------------
514void LLImageGL::forceUpdateBindStats(void) const
515{
516 mLastBindTime = sLastFrameTime;
517}
441 518
442void LLImageGL::updateBindStats(void) const 519void LLImageGL::updateBindStats(void) const
443{ 520{
@@ -451,7 +528,8 @@ void LLImageGL::updateBindStats(void) const
451 { 528 {
452 // we haven't accounted for this texture yet this frame 529 // we haven't accounted for this texture yet this frame
453 sUniqueCount++; 530 sUniqueCount++;
454 updateBoundTexMem(mTextureMemory); 531
532 updateBoundTexMem();
455 mLastBindTime = sLastFrameTime; 533 mLastBindTime = sLastFrameTime;
456 } 534 }
457 } 535 }
@@ -464,7 +542,7 @@ bool LLImageGL::bindError(const S32 stage) const
464} 542}
465 543
466//virtual 544//virtual
467bool LLImageGL::bindDefaultImage(const S32 stage) const 545bool LLImageGL::bindDefaultImage(const S32 stage)
468{ 546{
469 return false; 547 return false;
470} 548}
@@ -503,7 +581,6 @@ void LLImageGL::setImage(const LLImageRaw* imageraw)
503void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) 581void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
504{ 582{
505// LLFastTimer t1(LLFastTimer::FTM_TEMP1); 583// LLFastTimer t1(LLFastTimer::FTM_TEMP1);
506 llpushcallstacks ;
507 bool is_compressed = false; 584 bool is_compressed = false;
508 if (mFormatPrimary >= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && mFormatPrimary <= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) 585 if (mFormatPrimary >= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && mFormatPrimary <= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
509 { 586 {
@@ -716,12 +793,10 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
716 } 793 }
717 stop_glerror(); 794 stop_glerror();
718 mGLTextureCreated = true; 795 mGLTextureCreated = true;
719 llpushcallstacks ;
720} 796}
721 797
722BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height) 798BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height, BOOL force_fast_update)
723{ 799{
724 llpushcallstacks ;
725 if (!width || !height) 800 if (!width || !height)
726 { 801 {
727 return TRUE; 802 return TRUE;
@@ -737,7 +812,8 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
737 return FALSE; 812 return FALSE;
738 } 813 }
739 814
740 if (x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight() && data_width == width && data_height == height) 815 // HACK: allow the caller to explicitly force the fast path (i.e. using glTexSubImage2D here instead of calling setImage) even when updating the full texture.
816 if (!force_fast_update && x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight() && data_width == width && data_height == height)
741 { 817 {
742 setImage(datap, FALSE); 818 setImage(datap, FALSE);
743 } 819 }
@@ -810,20 +886,20 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
810 stop_glerror(); 886 stop_glerror();
811 mGLTextureCreated = true; 887 mGLTextureCreated = true;
812 } 888 }
813 llpushcallstacks ;
814 return TRUE; 889 return TRUE;
815} 890}
816 891
817BOOL LLImageGL::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height) 892BOOL LLImageGL::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height, BOOL force_fast_update)
818{ 893{
819 return setSubImage(imageraw->getData(), imageraw->getWidth(), imageraw->getHeight(), x_pos, y_pos, width, height); 894 return setSubImage(imageraw->getData(), imageraw->getWidth(), imageraw->getHeight(), x_pos, y_pos, width, height, force_fast_update);
820} 895}
821 896
822// Copy sub image from frame buffer 897// Copy sub image from frame buffer
823BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height) 898BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height)
824{ 899{
825 if (gGL.getTexUnit(0)->bind(this, true)) 900 if (gGL.getTexUnit(0)->bind(this, false, true))
826 { 901 {
902 //checkTexSize() ;
827 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height); 903 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height);
828 mGLTextureCreated = true; 904 mGLTextureCreated = true;
829 stop_glerror(); 905 stop_glerror();
@@ -883,14 +959,14 @@ BOOL LLImageGL::createGLTexture()
883 return TRUE ; 959 return TRUE ;
884} 960}
885 961
886BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/) 962BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/, BOOL to_create, S32 category)
887{ 963{
888 llpushcallstacks ;
889 if (gGLManager.mIsDisabled) 964 if (gGLManager.mIsDisabled)
890 { 965 {
891 llwarns << "Trying to create a texture while GL is disabled!" << llendl; 966 llwarns << "Trying to create a texture while GL is disabled!" << llendl;
892 return FALSE; 967 return FALSE;
893 } 968 }
969
894 mGLTextureCreated = false ; 970 mGLTextureCreated = false ;
895 llassert(gGLManager.mInited); 971 llassert(gGLManager.mInited);
896 stop_glerror(); 972 stop_glerror();
@@ -903,8 +979,10 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
903 discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel); 979 discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel);
904 980
905 // Actual image width/height = raw image width/height * 2^discard_level 981 // Actual image width/height = raw image width/height * 2^discard_level
906 S32 w = imageraw->getWidth() << discard_level; 982 S32 raw_w = imageraw->getWidth() ;
907 S32 h = imageraw->getHeight() << discard_level; 983 S32 raw_h = imageraw->getHeight() ;
984 S32 w = raw_w << discard_level;
985 S32 h = raw_h << discard_level;
908 986
909 // setSize may call destroyGLTexture if the size does not match 987 // setSize may call destroyGLTexture if the size does not match
910 setSize(w, h, imageraw->getComponents()); 988 setSize(w, h, imageraw->getComponents());
@@ -940,13 +1018,21 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
940 } 1018 }
941 } 1019 }
942 1020
1021 if(!to_create) //not create a gl texture
1022 {
1023 destroyGLTexture();
1024 mCurrentDiscardLevel = discard_level;
1025 mLastBindTime = sLastFrameTime;
1026 return TRUE ;
1027 }
1028
1029 mCategory = category ;
943 const U8* rawdata = imageraw->getData(); 1030 const U8* rawdata = imageraw->getData();
944 return createGLTexture(discard_level, rawdata, FALSE, usename); 1031 return createGLTexture(discard_level, rawdata, FALSE, usename);
945} 1032}
946 1033
947BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_hasmips, S32 usename) 1034BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_hasmips, S32 usename)
948{ 1035{
949 llpushcallstacks ;
950 llassert(data_in); 1036 llassert(data_in);
951 1037
952 if (discard_level < 0) 1038 if (discard_level < 0)
@@ -1014,7 +1100,14 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
1014 if (old_name != 0) 1100 if (old_name != 0)
1015 { 1101 {
1016 sGlobalTextureMemoryInBytes -= mTextureMemory; 1102 sGlobalTextureMemoryInBytes -= mTextureMemory;
1103
1104 if(gAuditTexture)
1105 {
1106 decTextureCounter() ;
1107 }
1108
1017 LLImageGL::deleteTextures(1, &old_name); 1109 LLImageGL::deleteTextures(1, &old_name);
1110
1018 stop_glerror(); 1111 stop_glerror();
1019 } 1112 }
1020 1113
@@ -1022,13 +1115,15 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
1022 sGlobalTextureMemoryInBytes += mTextureMemory; 1115 sGlobalTextureMemoryInBytes += mTextureMemory;
1023 setActive() ; 1116 setActive() ;
1024 1117
1118 if(gAuditTexture)
1119 {
1120 incTextureCounter() ;
1121 }
1025 // mark this as bound at this point, so we don't throw it out immediately 1122 // mark this as bound at this point, so we don't throw it out immediately
1026 mLastBindTime = sLastFrameTime; 1123 mLastBindTime = sLastFrameTime;
1027
1028 llpushcallstacks ;
1029 return TRUE; 1124 return TRUE;
1030} 1125}
1031 1126#if 0
1032BOOL LLImageGL::setDiscardLevel(S32 discard_level) 1127BOOL LLImageGL::setDiscardLevel(S32 discard_level)
1033{ 1128{
1034 llassert(discard_level >= 0); 1129 llassert(discard_level >= 0);
@@ -1080,25 +1175,14 @@ BOOL LLImageGL::setDiscardLevel(S32 discard_level)
1080 return FALSE; 1175 return FALSE;
1081 } 1176 }
1082} 1177}
1083 1178#endif
1084BOOL LLImageGL::isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents)
1085{
1086 assert_glerror();
1087 S32 gl_discard = discard_level - mCurrentDiscardLevel;
1088 LLGLint glwidth = 0;
1089 glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_WIDTH, (GLint*)&glwidth);
1090 LLGLint glheight = 0;
1091 glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_HEIGHT, (GLint*)&glheight);
1092 LLGLint glcomponents = 0 ;
1093 glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_INTERNAL_FORMAT, (GLint*)&glcomponents);
1094 assert_glerror();
1095
1096 return glwidth >= image_width && glheight >= image_height && (GL_RGB8 == glcomponents || GL_RGBA8 == glcomponents) ;
1097}
1098 1179
1099BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) 1180BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok)
1100{ 1181{
1101 llpushcallstacks ; 1182 // VWR-13505 : Merov : Allow gl texture read back so save texture works again (temporary)
1183 //llassert_always(sAllowReadBackRaw) ;
1184 //llerrs << "should not call this function!" << llendl ;
1185
1102 if (discard_level < 0) 1186 if (discard_level < 0)
1103 { 1187 {
1104 discard_level = mCurrentDiscardLevel; 1188 discard_level = mCurrentDiscardLevel;
@@ -1201,7 +1285,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1201 return FALSE ; 1285 return FALSE ;
1202 } 1286 }
1203 //----------------------------------------------------------------------------------------------- 1287 //-----------------------------------------------------------------------------------------------
1204 llpushcallstacks ; 1288
1205 return TRUE ; 1289 return TRUE ;
1206} 1290}
1207 1291
@@ -1219,12 +1303,19 @@ void LLImageGL::destroyGLTexture()
1219 stop_glerror(); 1303 stop_glerror();
1220 } 1304 }
1221 } 1305 }
1222 1306
1223 sGlobalTextureMemoryInBytes -= mTextureMemory; 1307 if(mTextureMemory)
1224 mTextureMemory = 0; 1308 {
1225 1309 if(gAuditTexture)
1310 {
1311 decTextureCounter() ;
1312 }
1313 sGlobalTextureMemoryInBytes -= mTextureMemory;
1314 mTextureMemory = 0;
1315 }
1316
1226 LLImageGL::deleteTextures(1, &mTexName); 1317 LLImageGL::deleteTextures(1, &mTexName);
1227 mTextureState = DELETED ; 1318 mTextureState = DELETED ;
1228 mTexName = 0; 1319 mTexName = 0;
1229 mCurrentDiscardLevel = -1 ; //invalidate mCurrentDiscardLevel. 1320 mCurrentDiscardLevel = -1 ; //invalidate mCurrentDiscardLevel.
1230 mGLTextureCreated = FALSE ; 1321 mGLTextureCreated = FALSE ;
@@ -1338,6 +1429,11 @@ S32 LLImageGL::getMipBytes(S32 discard_level) const
1338 return res; 1429 return res;
1339} 1430}
1340 1431
1432BOOL LLImageGL::isJustBound() const
1433{
1434 return (BOOL)(sLastFrameTime - mLastBindTime < 0.5f);
1435}
1436
1341BOOL LLImageGL::getBoundRecently() const 1437BOOL LLImageGL::getBoundRecently() const
1342{ 1438{
1343 return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME); 1439 return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME);
@@ -1539,6 +1635,87 @@ BOOL LLImageGL::getMask(const LLVector2 &tc)
1539 return res; 1635 return res;
1540} 1636}
1541 1637
1638void LLImageGL::setCategory(S32 category)
1639{
1640 if(!gAuditTexture)
1641 {
1642 return ;
1643 }
1644 if(mCategory != category)
1645 {
1646 if(mCategory > -1)
1647 {
1648 sTextureMemByCategory[mCategory] -= mTextureMemory ;
1649 }
1650 sTextureMemByCategory[category] += mTextureMemory ;
1651
1652 mCategory = category;
1653 }
1654}
1655
1656//for debug use
1657//val is a "power of two" number
1658S32 LLImageGL::getTextureCounterIndex(U32 val)
1659{
1660 //index range is [0, MAX_TEXTURE_LOG_SIZE].
1661 if(val < 2)
1662 {
1663 return 0 ;
1664 }
1665 else if(val >= (1 << MAX_TEXTURE_LOG_SIZE))
1666 {
1667 return MAX_TEXTURE_LOG_SIZE ;
1668 }
1669 else
1670 {
1671 S32 ret = 0 ;
1672 while(val >>= 1)
1673 {
1674 ++ret;
1675 }
1676 return ret ;
1677 }
1678}
1679void LLImageGL::incTextureCounterStatic(U32 val, S32 ncomponents, S32 category)
1680{
1681 sTextureLoadedCounter[getTextureCounterIndex(val)]++ ;
1682 sTextureMemByCategory[category] += (S32)val * ncomponents ;
1683}
1684void LLImageGL::decTextureCounterStatic(U32 val, S32 ncomponents, S32 category)
1685{
1686 sTextureLoadedCounter[getTextureCounterIndex(val)]-- ;
1687 sTextureMemByCategory[category] += (S32)val * ncomponents ;
1688}
1689void LLImageGL::incTextureCounter()
1690{
1691 sTextureLoadedCounter[getTextureCounterIndex(mTextureMemory / mComponents)]++ ;
1692 sTextureMemByCategory[mCategory] += mTextureMemory ;
1693}
1694void LLImageGL::decTextureCounter()
1695{
1696 sTextureLoadedCounter[getTextureCounterIndex(mTextureMemory / mComponents)]-- ;
1697 sTextureMemByCategory[mCategory] -= mTextureMemory ;
1698}
1699void LLImageGL::setCurTexSizebar(S32 index, BOOL set_pick_size)
1700{
1701 sCurTexSizeBar = index ;
1702
1703 if(set_pick_size)
1704 {
1705 sCurTexPickSize = (1 << index) ;
1706 }
1707 else
1708 {
1709 sCurTexPickSize = -1 ;
1710 }
1711}
1712void LLImageGL::resetCurTexSizebar()
1713{
1714 sCurTexSizeBar = -1 ;
1715 sCurTexPickSize = -1 ;
1716}
1717//----------------------------------------------------------------------------
1718
1542//---------------------------------------------------------------------------- 1719//----------------------------------------------------------------------------
1543 1720
1544 1721