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