aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llimagegl.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llimagegl.h117
1 files changed, 56 insertions, 61 deletions
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h
index c7114c3..56f79ff 100644
--- a/linden/indra/llrender/llimagegl.h
+++ b/linden/indra/llrender/llimagegl.h
@@ -45,18 +45,23 @@
45#define BYTES_TO_MEGA_BYTES(x) ((x) >> 20) 45#define BYTES_TO_MEGA_BYTES(x) ((x) >> 20)
46#define MEGA_BYTES_TO_BYTES(x) ((x) << 20) 46#define MEGA_BYTES_TO_BYTES(x) ((x) << 20)
47 47
48class LLTextureAtlas ;
48//============================================================================ 49//============================================================================
50
49class LLImageGL : public LLRefCount 51class LLImageGL : public LLRefCount
50{ 52{
51 friend class LLTexUnit; 53 friend class LLTexUnit;
52public: 54public:
55 static std::list<U32> sDeadTextureList;
56
57 static void deleteDeadTextures();
58
53 // Size calculation 59 // Size calculation
54 static S32 dataFormatBits(S32 dataformat); 60 static S32 dataFormatBits(S32 dataformat);
55 static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); 61 static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height);
56 static S32 dataFormatComponents(S32 dataformat); 62 static S32 dataFormatComponents(S32 dataformat);
57 63
58 void updateBindStats(void) const; 64 void updateBindStats(void) const;
59 void forceUpdateBindStats(void) const;
60 65
61 // needs to be called every frame 66 // needs to be called every frame
62 static void updateStats(F32 current_time); 67 static void updateStats(F32 current_time);
@@ -65,10 +70,12 @@ public:
65 static void destroyGL(BOOL save_state = TRUE); 70 static void destroyGL(BOOL save_state = TRUE);
66 static void restoreGL(); 71 static void restoreGL();
67 72
68 // Sometimes called externally for textures not using LLImageGL (should go away...) 73 // Sometimes called externally for textures not using LLImageGL (should go away...)
69 static S32 updateBoundTexMemStatic(const S32 delta, const S32 size, S32 category) ; 74//#if !LL_RELEASE_FOR_DOWNLOAD
70 S32 updateBoundTexMem()const; 75// static S32 updateBoundTexMem(const S32 delta, const S32 size) ;
71 76//#else
77 static S32 updateBoundTexMem(const S32 delta);
78//#endif
72 static bool checkSize(S32 width, S32 height); 79 static bool checkSize(S32 width, S32 height);
73 80
74 // Not currently necessary for LLImageGL, but required in some derived classes, 81 // Not currently necessary for LLImageGL, but required in some derived classes,
@@ -90,7 +97,7 @@ protected:
90public: 97public:
91 virtual void dump(); // debugging info to llinfos 98 virtual void dump(); // debugging info to llinfos
92 virtual bool bindError(const S32 stage = 0) const; 99 virtual bool bindError(const S32 stage = 0) const;
93 virtual bool bindDefaultImage(const S32 stage = 0) ; 100 virtual bool bindDefaultImage(const S32 stage = 0) const;
94 virtual void forceImmediateUpdate() ; 101 virtual void forceImmediateUpdate() ;
95 102
96 void setSize(S32 width, S32 height, S32 ncomponents); 103 void setSize(S32 width, S32 height, S32 ncomponents);
@@ -102,15 +109,14 @@ public:
102 static void setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels); 109 static void setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels);
103 110
104 BOOL createGLTexture() ; 111 BOOL createGLTexture() ;
105 BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0, BOOL to_create = TRUE, 112 BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0);
106 S32 category = sMaxCatagories - 1);
107 BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0); 113 BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0);
108 void setImage(const LLImageRaw* imageraw); 114 void setImage(const LLImageRaw* imageraw);
109 void setImage(const U8* data_in, BOOL data_hasmips = FALSE); 115 void setImage(const U8* data_in, BOOL data_hasmips = FALSE);
110 BOOL setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height, BOOL force_fast_update = FALSE); 116 BOOL setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height);
111 BOOL setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height, BOOL force_fast_update = FALSE); 117 BOOL setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height);
112 BOOL setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height); 118 BOOL setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height);
113 119 BOOL setDiscardLevel(S32 discard_level);
114 // Read back a raw image for this discard level, if it exists 120 // Read back a raw image for this discard level, if it exists
115 BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok); 121 BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok);
116 void destroyGLTexture(); 122 void destroyGLTexture();
@@ -130,7 +136,7 @@ public:
130 S32 getBytes(S32 discard_level = -1) const; 136 S32 getBytes(S32 discard_level = -1) const;
131 S32 getMipBytes(S32 discard_level = -1) const; 137 S32 getMipBytes(S32 discard_level = -1) const;
132 BOOL getBoundRecently() const; 138 BOOL getBoundRecently() const;
133 BOOL isJustBound() const; 139 //BOOL isJustBound() const;
134 LLGLenum getPrimaryFormat() const { return mFormatPrimary; } 140 LLGLenum getPrimaryFormat() const { return mFormatPrimary; }
135 141
136 BOOL getHasGLTexture() const { return mTexName != 0; } 142 BOOL getHasGLTexture() const { return mTexName != 0; }
@@ -151,6 +157,8 @@ public:
151 BOOL getUseDiscard() const { return mUseMipMaps && !mDontDiscard; } 157 BOOL getUseDiscard() const { return mUseMipMaps && !mDontDiscard; }
152 BOOL getDontDiscard() const { return mDontDiscard; } 158 BOOL getDontDiscard() const { return mDontDiscard; }
153 159
160 BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ;
161
154 void updatePickMask(S32 width, S32 height, const U8* data_in); 162 void updatePickMask(S32 width, S32 height, const U8* data_in);
155 BOOL getMask(const LLVector2 &tc); 163 BOOL getMask(const LLVector2 &tc);
156 164
@@ -176,8 +184,20 @@ public:
176 void setActive() ; 184 void setActive() ;
177 void forceActive() ; 185 void forceActive() ;
178 void setNoDelete() ; 186 void setNoDelete() ;
187
188 BOOL canAddToAtlas() ;
189 BOOL createGLTextureInAtlas(S32 discard_level, const LLImageRaw* imageraw, LLTextureAtlas* atlasp, S16 slot_col, S16 slot_row);
190 BOOL addToAtlas(const LLImageRaw* raw_image, LLTextureAtlas* atlasp, S16 slot_col, S16 slot_row) ;
191
192 LLGLenum getTexTarget()const { return mTarget ;}
193 S8 getDiscardLevelInAtlas()const {return mDiscardLevelInAtlas;}
194 U32 getTexelsInAtlas()const { return mTexelsInAtlas ;}
195 U32 getTexelsInGLTexture()const {return mTexelsInGLTexture;}
179 196
180 void setTextureSize(S32 size) {mTextureMemory = size;} 197private:
198 void preAddToAtlas(S32 data_width) ;
199 void postAddToAtlas() ;
200
181protected: 201protected:
182 void init(BOOL usemipmaps); 202 void init(BOOL usemipmaps);
183 virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors 203 virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors
@@ -186,7 +206,7 @@ public:
186 // Various GL/Rendering options 206 // Various GL/Rendering options
187 S32 mTextureMemory; 207 S32 mTextureMemory;
188 mutable F32 mLastBindTime; // last time this was bound, by discard level 208 mutable F32 mLastBindTime; // last time this was bound, by discard level
189 209
190private: 210private:
191 LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL 211 LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL
192 U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel 212 U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel
@@ -202,8 +222,15 @@ private:
202 U16 mWidth; 222 U16 mWidth;
203 U16 mHeight; 223 U16 mHeight;
204 S8 mCurrentDiscardLevel; 224 S8 mCurrentDiscardLevel;
205 225
226 S8 mDiscardLevelInAtlas;
227 U32 mTexelsInAtlas ;
228 U32 mTexelsInGLTexture;
229
206protected: 230protected:
231
232 BOOL mCanAddToAtlas ;
233
207 LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps) 234 LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps)
208 LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps) 235 LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps)
209 bool mHasMipMaps; 236 bool mHasMipMaps;
@@ -241,42 +268,18 @@ public:
241 static S32 sCount; 268 static S32 sCount;
242 269
243 static F32 sLastFrameTime; 270 static F32 sLastFrameTime;
244 271
245 static LLGLuint sCurrentBoundTextures[MAX_GL_TEXTURE_UNITS]; // Currently bound texture ID 272 static LLGLuint sCurrentBoundTextures[MAX_GL_TEXTURE_UNITS]; // Currently bound texture ID
246 273
247 // Global memory statistics 274 // Global memory statistics
248 static S32 sGlobalTextureMemoryInBytes; // Tracks main memory texmem 275 static S32 sGlobalTextureMemoryInBytes; // Tracks main memory texmem
249 static S32 sBoundTextureMemoryInBytes; // Tracks bound texmem for last completed frame 276 static S32 sBoundTextureMemoryInBytes; // Tracks bound texmem for last completed frame
250 static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame 277 static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame
251 static U32 sBindCount; // Tracks number of texture binds for current frame 278 static U32 sBindCount; // Tracks number of texture binds for current frame
252 static U32 sUniqueCount; // Tracks number of unique texture binds for current frame 279 static U32 sUniqueCount; // Tracks number of unique texture binds for current frame
253 static BOOL sGlobalUseAnisotropic; 280 static BOOL sGlobalUseAnisotropic;
254#if DEBUG_MISS 281 static BOOL sUseTextureAtlas ;
255 BOOL mMissed; // Missed on last bind? 282#if !LL_RELEASE_FOR_DOWNLOAD
256 BOOL getMissed() const { return mMissed; };
257#else
258 BOOL getMissed() const { return FALSE; };
259#endif
260
261public:
262 static void initClass(S32 num_catagories) ;
263 static void cleanupClass() ;
264private:
265 static S32 sMaxCatagories ;
266
267 //the flag to allow to call readBackRaw(...).
268 //can be removed if we do not use that function at all.
269 static BOOL sAllowReadBackRaw ;
270//
271//****************************************************************************************************
272//The below for texture auditing use only
273//****************************************************************************************************
274private:
275 S32 mCategory ;
276public:
277 void setCategory(S32 category) ;
278 S32 getCategory()const {return mCategory ;}
279
280 //for debug use: show texture size distribution 283 //for debug use: show texture size distribution
281 //---------------------------------------- 284 //----------------------------------------
282 static LLPointer<LLImageGL> sDefaultTexturep; //default texture to replace normal textures 285 static LLPointer<LLImageGL> sDefaultTexturep; //default texture to replace normal textures
@@ -287,27 +290,19 @@ public:
287 static S32 sCurTexPickSize ; 290 static S32 sCurTexPickSize ;
288 291
289 static S32 getTextureCounterIndex(U32 val) ; 292 static S32 getTextureCounterIndex(U32 val) ;
290 static void incTextureCounterStatic(U32 val, S32 ncomponents, S32 category) ; 293 static void incTextureCounter(U32 val) ;
291 static void decTextureCounterStatic(U32 val, S32 ncomponents, S32 category) ; 294 static void decTextureCounter(U32 val) ;
292 static void setCurTexSizebar(S32 index, BOOL set_pick_size = TRUE) ; 295 static void setCurTexSizebar(S32 index) ;
293 static void resetCurTexSizebar(); 296 static void resetCurTexSizebar();
294
295 void incTextureCounter() ;
296 void decTextureCounter() ;
297 //---------------------------------------- 297 //----------------------------------------
298#endif
298 299
299 //for debug use: show texture category distribution 300#if DEBUG_MISS
300 //---------------------------------------- 301 BOOL mMissed; // Missed on last bind?
301 302 BOOL getMissed() const { return mMissed; };
302 static std::vector<S32> sTextureMemByCategory; 303#else
303 static std::vector<S32> sTextureMemByCategoryBound ; 304 BOOL getMissed() const { return FALSE; };
304 static std::vector<S32> sTextureCurMemByCategoryBound ; 305#endif
305 //----------------------------------------
306//****************************************************************************************************
307//End of definitions for texture auditing use only
308//****************************************************************************************************
309
310}; 306};
311 307
312extern BOOL gAuditTexture;
313#endif // LL_LLIMAGEGL_H 308#endif // LL_LLIMAGEGL_H