diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llrender/CMakeLists.txt | 5 | ||||
-rw-r--r-- | linden/indra/llrender/llcubemap.cpp | 17 | ||||
-rw-r--r-- | linden/indra/llrender/llfont.cpp | 2 | ||||
-rw-r--r-- | linden/indra/llrender/llfontgl.cpp | 6 | ||||
-rw-r--r-- | linden/indra/llrender/llgl.cpp | 8 | ||||
-rw-r--r-- | linden/indra/llrender/llgl.h | 31 | ||||
-rw-r--r-- | linden/indra/llrender/llglslshader.cpp | 2 | ||||
-rw-r--r-- | linden/indra/llrender/llimagegl.cpp | 451 | ||||
-rw-r--r-- | linden/indra/llrender/llimagegl.h | 117 | ||||
-rw-r--r-- | linden/indra/llrender/llrender.cpp | 64 | ||||
-rw-r--r-- | linden/indra/llrender/llrendertarget.cpp | 57 | ||||
-rw-r--r-- | linden/indra/llrender/llrendertarget.h | 1 | ||||
-rw-r--r-- | linden/indra/llrender/lltextureatlas.cpp | 411 | ||||
-rw-r--r-- | linden/indra/llrender/lltextureatlas.h | 92 | ||||
-rw-r--r-- | linden/indra/llrender/llvertexbuffer.cpp | 72 |
15 files changed, 356 insertions, 980 deletions
diff --git a/linden/indra/llrender/CMakeLists.txt b/linden/indra/llrender/CMakeLists.txt index 3ba841e..0bdb55f 100644 --- a/linden/indra/llrender/CMakeLists.txt +++ b/linden/indra/llrender/CMakeLists.txt | |||
@@ -32,9 +32,9 @@ set(llrender_SOURCE_FILES | |||
32 | llgldbg.cpp | 32 | llgldbg.cpp |
33 | llglslshader.cpp | 33 | llglslshader.cpp |
34 | llimagegl.cpp | 34 | llimagegl.cpp |
35 | llpostprocess.cpp | ||
35 | llrendersphere.cpp | 36 | llrendersphere.cpp |
36 | llshadermgr.cpp | 37 | llshadermgr.cpp |
37 | lltextureatlas.cpp | ||
38 | llvertexbuffer.cpp | 38 | llvertexbuffer.cpp |
39 | ) | 39 | ) |
40 | 40 | ||
@@ -53,10 +53,10 @@ set(llrender_HEADER_FILES | |||
53 | llglstates.h | 53 | llglstates.h |
54 | llgltypes.h | 54 | llgltypes.h |
55 | llimagegl.h | 55 | llimagegl.h |
56 | llpostprocess.h | ||
56 | llrender.h | 57 | llrender.h |
57 | llrendersphere.h | 58 | llrendersphere.h |
58 | llshadermgr.h | 59 | llshadermgr.h |
59 | lltextureatlas.h | ||
60 | llvertexbuffer.h | 60 | llvertexbuffer.h |
61 | ) | 61 | ) |
62 | 62 | ||
@@ -81,7 +81,6 @@ if (SERVER AND NOT WINDOWS AND NOT DARWIN) | |||
81 | ${llrender_SOURCE_FILES} | 81 | ${llrender_SOURCE_FILES} |
82 | ${server_SOURCE_FILES} | 82 | ${server_SOURCE_FILES} |
83 | ) | 83 | ) |
84 | add_dependencies(llrenderheadless prepare) | ||
85 | else (SERVER AND NOT WINDOWS AND NOT DARWIN) | 84 | else (SERVER AND NOT WINDOWS AND NOT DARWIN) |
86 | list(APPEND llrender_SOURCE_FILES | 85 | list(APPEND llrender_SOURCE_FILES |
87 | llgl.cpp | 86 | llgl.cpp |
diff --git a/linden/indra/llrender/llcubemap.cpp b/linden/indra/llrender/llcubemap.cpp index e0923e4..a5c677d 100644 --- a/linden/indra/llrender/llcubemap.cpp +++ b/linden/indra/llrender/llcubemap.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2010, Linden Research, Inc. | 7 | * Copyright (c) 2002-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -63,12 +63,6 @@ LLCubeMap::LLCubeMap() | |||
63 | mTextureCoordStage(0), | 63 | mTextureCoordStage(0), |
64 | mMatrixStage(0) | 64 | mMatrixStage(0) |
65 | { | 65 | { |
66 | mTargets[0] = GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB; | ||
67 | mTargets[1] = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB; | ||
68 | mTargets[2] = GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB; | ||
69 | mTargets[3] = GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB; | ||
70 | mTargets[4] = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB; | ||
71 | mTargets[5] = GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB; | ||
72 | } | 66 | } |
73 | 67 | ||
74 | LLCubeMap::~LLCubeMap() | 68 | LLCubeMap::~LLCubeMap() |
@@ -81,6 +75,13 @@ void LLCubeMap::initGL() | |||
81 | 75 | ||
82 | if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) | 76 | if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) |
83 | { | 77 | { |
78 | mTargets[0] = GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB; | ||
79 | mTargets[1] = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB; | ||
80 | mTargets[2] = GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB; | ||
81 | mTargets[3] = GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB; | ||
82 | mTargets[4] = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB; | ||
83 | mTargets[5] = GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB; | ||
84 | |||
84 | // Not initialized, do stuff. | 85 | // Not initialized, do stuff. |
85 | if (mImages[0].isNull()) | 86 | if (mImages[0].isNull()) |
86 | { | 87 | { |
@@ -93,7 +94,7 @@ void LLCubeMap::initGL() | |||
93 | mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE)); | 94 | mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE)); |
94 | mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP); | 95 | mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP); |
95 | mRawImages[i] = new LLImageRaw(64, 64, 4); | 96 | mRawImages[i] = new LLImageRaw(64, 64, 4); |
96 | mImages[i]->createGLTexture(0, mRawImages[i], texname); | 97 | mImages[i]->createGLTexture(0, mRawImages[i], texname, TRUE); |
97 | 98 | ||
98 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname); | 99 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname); |
99 | mImages[i]->setAddressMode(LLTexUnit::TAM_CLAMP); | 100 | mImages[i]->setAddressMode(LLTexUnit::TAM_CLAMP); |
diff --git a/linden/indra/llrender/llfont.cpp b/linden/indra/llrender/llfont.cpp index 946f52f..5ee3929 100644 --- a/linden/indra/llrender/llfont.cpp +++ b/linden/indra/llrender/llfont.cpp | |||
@@ -81,7 +81,7 @@ LLFontManager::LLFontManager() | |||
81 | if (error) | 81 | if (error) |
82 | { | 82 | { |
83 | // Clean up freetype libs. | 83 | // Clean up freetype libs. |
84 | llwarns << "Freetype initialization failure!" << llendl; | 84 | llerrs << "Freetype initialization failure!" << llendl; |
85 | FT_Done_FreeType(gFTLibrary); | 85 | FT_Done_FreeType(gFTLibrary); |
86 | } | 86 | } |
87 | } | 87 | } |
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp index 9d1f1d4..5d3d6a7 100644 --- a/linden/indra/llrender/llfontgl.cpp +++ b/linden/indra/llrender/llfontgl.cpp | |||
@@ -121,7 +121,7 @@ LLFontGL::LLFontGL() | |||
121 | 121 | ||
122 | LLFontGL::LLFontGL(const LLFontGL &source) | 122 | LLFontGL::LLFontGL(const LLFontGL &source) |
123 | { | 123 | { |
124 | llwarns << "Not implemented!" << llendl; | 124 | llerrs << "Not implemented!" << llendl; |
125 | } | 125 | } |
126 | 126 | ||
127 | LLFontGL::~LLFontGL() | 127 | LLFontGL::~LLFontGL() |
@@ -278,7 +278,7 @@ void LLFontGL::destroyGL() | |||
278 | 278 | ||
279 | LLFontGL &LLFontGL::operator=(const LLFontGL &source) | 279 | LLFontGL &LLFontGL::operator=(const LLFontGL &source) |
280 | { | 280 | { |
281 | llwarns << "Not implemented" << llendl; | 281 | llerrs << "Not implemented" << llendl; |
282 | return *this; | 282 | return *this; |
283 | } | 283 | } |
284 | 284 | ||
@@ -584,7 +584,7 @@ S32 LLFontGL::render(const LLWString &wstr, | |||
584 | const LLFontGlyphInfo* fgi= getGlyphInfo(wch); | 584 | const LLFontGlyphInfo* fgi= getGlyphInfo(wch); |
585 | if (!fgi) | 585 | if (!fgi) |
586 | { | 586 | { |
587 | llwarns << "Missing Glyph Info" << llendl; | 587 | llerrs << "Missing Glyph Info" << llendl; |
588 | break; | 588 | break; |
589 | } | 589 | } |
590 | // Per-glyph bitmap texture. | 590 | // Per-glyph bitmap texture. |
diff --git a/linden/indra/llrender/llgl.cpp b/linden/indra/llrender/llgl.cpp index d73f7b6..2e9b2bd 100644 --- a/linden/indra/llrender/llgl.cpp +++ b/linden/indra/llrender/llgl.cpp | |||
@@ -59,13 +59,11 @@ | |||
59 | BOOL gDebugGL = FALSE; | 59 | BOOL gDebugGL = FALSE; |
60 | BOOL gClothRipple = FALSE; | 60 | BOOL gClothRipple = FALSE; |
61 | BOOL gNoRender = FALSE; | 61 | BOOL gNoRender = FALSE; |
62 | BOOL gGLActive = FALSE; | ||
63 | LLMatrix4 gGLObliqueProjectionInverse; | 62 | LLMatrix4 gGLObliqueProjectionInverse; |
64 | 63 | ||
65 | #define LL_GL_NAME_POOLING 0 | 64 | #define LL_GL_NAME_POOLING 0 |
66 | 65 | ||
67 | LLGLNamePool::pool_list_t LLGLNamePool::sInstances; | 66 | LLGLNamePool::pool_list_t LLGLNamePool::sInstances; |
68 | std::list<LLGLUpdate*> LLGLUpdate::sGLQ; | ||
69 | 67 | ||
70 | #if (LL_WINDOWS || LL_LINUX || LL_SOLARIS) && !LL_MESA_HEADLESS | 68 | #if (LL_WINDOWS || LL_LINUX || LL_SOLARIS) && !LL_MESA_HEADLESS |
71 | // ATI prototypes | 69 | // ATI prototypes |
@@ -1011,7 +1009,7 @@ void assert_glerror() | |||
1011 | 1009 | ||
1012 | if (quit) | 1010 | if (quit) |
1013 | { | 1011 | { |
1014 | llwarns << "One or more unhandled GL errors." << llendl; | 1012 | llerrs << "One or more unhandled GL errors." << llendl; |
1015 | } | 1013 | } |
1016 | } | 1014 | } |
1017 | 1015 | ||
@@ -1705,11 +1703,11 @@ void LLGLNamePool::release(GLuint name) | |||
1705 | } | 1703 | } |
1706 | else | 1704 | else |
1707 | { | 1705 | { |
1708 | llwarns << "Attempted to release a pooled name that is not in use!" << llendl; | 1706 | llerrs << "Attempted to release a pooled name that is not in use!" << llendl; |
1709 | } | 1707 | } |
1710 | } | 1708 | } |
1711 | } | 1709 | } |
1712 | llwarns << "Attempted to release a non pooled name!" << llendl; | 1710 | llerrs << "Attempted to release a non pooled name!" << llendl; |
1713 | #else | 1711 | #else |
1714 | releaseName(name); | 1712 | releaseName(name); |
1715 | #endif | 1713 | #endif |
diff --git a/linden/indra/llrender/llgl.h b/linden/indra/llrender/llgl.h index 90642b3..cc7ebff 100644 --- a/linden/indra/llrender/llgl.h +++ b/linden/indra/llrender/llgl.h | |||
@@ -359,35 +359,6 @@ protected: | |||
359 | virtual void releaseName(GLuint name) = 0; | 359 | virtual void releaseName(GLuint name) = 0; |
360 | }; | 360 | }; |
361 | 361 | ||
362 | /* | ||
363 | Interface for objects that need periodic GL updates applied to them. | ||
364 | Used to synchronize GL updates with GL thread. | ||
365 | */ | ||
366 | class LLGLUpdate | ||
367 | { | ||
368 | public: | ||
369 | |||
370 | static std::list<LLGLUpdate*> sGLQ; | ||
371 | |||
372 | BOOL mInQ; | ||
373 | LLGLUpdate() | ||
374 | : mInQ(FALSE) | ||
375 | { | ||
376 | } | ||
377 | virtual ~LLGLUpdate() | ||
378 | { | ||
379 | if (mInQ) | ||
380 | { | ||
381 | std::list<LLGLUpdate*>::iterator iter = std::find(sGLQ.begin(), sGLQ.end(), this); | ||
382 | if (iter != sGLQ.end()) | ||
383 | { | ||
384 | sGLQ.erase(iter); | ||
385 | } | ||
386 | } | ||
387 | } | ||
388 | virtual void updateGL() = 0; | ||
389 | }; | ||
390 | |||
391 | extern LLMatrix4 gGLObliqueProjectionInverse; | 362 | extern LLMatrix4 gGLObliqueProjectionInverse; |
392 | 363 | ||
393 | #include "llglstates.h" | 364 | #include "llglstates.h" |
@@ -406,6 +377,4 @@ void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor | |||
406 | 377 | ||
407 | extern BOOL gClothRipple; | 378 | extern BOOL gClothRipple; |
408 | extern BOOL gNoRender; | 379 | extern BOOL gNoRender; |
409 | extern BOOL gGLActive; | ||
410 | |||
411 | #endif // LL_LLGL_H | 380 | #endif // LL_LLGL_H |
diff --git a/linden/indra/llrender/llglslshader.cpp b/linden/indra/llrender/llglslshader.cpp index 18974a7..08d6548 100644 --- a/linden/indra/llrender/llglslshader.cpp +++ b/linden/indra/llrender/llglslshader.cpp | |||
@@ -408,7 +408,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) | |||
408 | { | 408 | { |
409 | if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode) | 409 | if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode) |
410 | { | 410 | { |
411 | llwarns << "Texture channel " << index << " texture type corrupted." << llendl; | 411 | llerrs << "Texture channel " << index << " texture type corrupted." << llendl; |
412 | } | 412 | } |
413 | gGL.getTexUnit(index)->disable(); | 413 | gGL.getTexUnit(index)->disable(); |
414 | } | 414 | } |
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp index 1bddd49..7cd4dd7 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 | #include "lltextureatlas.h" | ||
47 | |||
48 | //---------------------------------------------------------------------------- | 46 | //---------------------------------------------------------------------------- |
49 | 47 | ||
50 | const F32 MIN_TEXTURE_LIFETIME = 10.f; | 48 | const F32 MIN_TEXTURE_LIFETIME = 10.f; |
@@ -58,17 +56,19 @@ S32 LLImageGL::sGlobalTextureMemoryInBytes = 0; | |||
58 | S32 LLImageGL::sBoundTextureMemoryInBytes = 0; | 56 | S32 LLImageGL::sBoundTextureMemoryInBytes = 0; |
59 | S32 LLImageGL::sCurBoundTextureMemory = 0; | 57 | S32 LLImageGL::sCurBoundTextureMemory = 0; |
60 | S32 LLImageGL::sCount = 0; | 58 | S32 LLImageGL::sCount = 0; |
61 | std::list<U32> LLImageGL::sDeadTextureList; | ||
62 | 59 | ||
63 | BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; | 60 | BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; |
64 | F32 LLImageGL::sLastFrameTime = 0.f; | 61 | F32 LLImageGL::sLastFrameTime = 0.f; |
65 | BOOL LLImageGL::sUseTextureAtlas = FALSE ; // render-pipeline KL | 62 | BOOL LLImageGL::sAllowReadBackRaw = FALSE ; |
66 | 63 | ||
67 | std::set<LLImageGL*> LLImageGL::sImageList; | 64 | std::set<LLImageGL*> LLImageGL::sImageList; |
68 | 65 | ||
69 | #if !LL_RELEASE_FOR_DOWNLOAD | 66 | //**************************************************************************************************** |
67 | //The below for texture auditing use only | ||
68 | //**************************************************************************************************** | ||
70 | //----------------------- | 69 | //----------------------- |
71 | //debug use | 70 | //debug use |
71 | BOOL gAuditTexture = FALSE ; | ||
72 | #define MAX_TEXTURE_LOG_SIZE 22 //2048 * 2048 | 72 | #define MAX_TEXTURE_LOG_SIZE 22 //2048 * 2048 |
73 | std::vector<S32> LLImageGL::sTextureLoadedCounter(MAX_TEXTURE_LOG_SIZE + 1) ; | 73 | std::vector<S32> LLImageGL::sTextureLoadedCounter(MAX_TEXTURE_LOG_SIZE + 1) ; |
74 | std::vector<S32> LLImageGL::sTextureBoundCounter(MAX_TEXTURE_LOG_SIZE + 1) ; | 74 | std::vector<S32> LLImageGL::sTextureBoundCounter(MAX_TEXTURE_LOG_SIZE + 1) ; |
@@ -76,8 +76,15 @@ std::vector<S32> LLImageGL::sTextureCurBoundCounter(MAX_TEXTURE_LOG_SIZE + 1) ; | |||
76 | S32 LLImageGL::sCurTexSizeBar = -1 ; | 76 | S32 LLImageGL::sCurTexSizeBar = -1 ; |
77 | S32 LLImageGL::sCurTexPickSize = -1 ; | 77 | S32 LLImageGL::sCurTexPickSize = -1 ; |
78 | LLPointer<LLImageGL> LLImageGL::sDefaultTexturep = NULL; | 78 | LLPointer<LLImageGL> LLImageGL::sDefaultTexturep = NULL; |
79 | S32 LLImageGL::sMaxCatagories = 1 ; | ||
80 | |||
81 | std::vector<S32> LLImageGL::sTextureMemByCategory; | ||
82 | std::vector<S32> LLImageGL::sTextureMemByCategoryBound ; | ||
83 | std::vector<S32> LLImageGL::sTextureCurMemByCategoryBound ; | ||
79 | //------------------------ | 84 | //------------------------ |
80 | #endif | 85 | //**************************************************************************************************** |
86 | //End for texture auditing use only | ||
87 | //**************************************************************************************************** | ||
81 | 88 | ||
82 | //************************************************************************************** | 89 | //************************************************************************************** |
83 | //below are functions for debug use | 90 | //below are functions for debug use |
@@ -103,12 +110,9 @@ void LLImageGL::checkTexSize() const | |||
103 | { | 110 | { |
104 | GLint texname; | 111 | GLint texname; |
105 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname); | 112 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname); |
106 | BOOL error = FALSE; | ||
107 | if (texname != mTexName) | 113 | if (texname != mTexName) |
108 | { | 114 | { |
109 | 115 | llerrs << "Invalid texture bound!" << llendl; | |
110 | llwarns << "Invalid texture bound!" << llendl; | ||
111 | |||
112 | } | 116 | } |
113 | stop_glerror() ; | 117 | stop_glerror() ; |
114 | LLGLint x = 0, y = 0 ; | 118 | LLGLint x = 0, y = 0 ; |
@@ -121,15 +125,7 @@ void LLImageGL::checkTexSize() const | |||
121 | } | 125 | } |
122 | if(x != (mWidth >> mCurrentDiscardLevel) || y != (mHeight >> mCurrentDiscardLevel)) | 126 | if(x != (mWidth >> mCurrentDiscardLevel) || y != (mHeight >> mCurrentDiscardLevel)) |
123 | { | 127 | { |
124 | error = TRUE; | 128 | llerrs << "wrong texture size and discard level!" << llendl ; |
125 | |||
126 | llwarns << "wrong texture size and discard level!" << llendl; | ||
127 | |||
128 | } | ||
129 | |||
130 | if (error) | ||
131 | { | ||
132 | llwarns << "LLImageGL::checkTexSize failed." << llendl; | ||
133 | } | 129 | } |
134 | } | 130 | } |
135 | } | 131 | } |
@@ -137,6 +133,20 @@ void LLImageGL::checkTexSize() const | |||
137 | //************************************************************************************** | 133 | //************************************************************************************** |
138 | 134 | ||
139 | //---------------------------------------------------------------------------- | 135 | //---------------------------------------------------------------------------- |
136 | //static | ||
137 | void 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 | ||
147 | void LLImageGL::cleanupClass() | ||
148 | { | ||
149 | } | ||
140 | 150 | ||
141 | //static | 151 | //static |
142 | S32 LLImageGL::dataFormatBits(S32 dataformat) | 152 | S32 LLImageGL::dataFormatBits(S32 dataformat) |
@@ -155,7 +165,7 @@ S32 LLImageGL::dataFormatBits(S32 dataformat) | |||
155 | case GL_RGBA: return 32; | 165 | case GL_RGBA: return 32; |
156 | case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac | 166 | case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac |
157 | default: | 167 | default: |
158 | llwarns << "LLImageGL::Unknown format: " << dataformat << llendl; | 168 | llerrs << "LLImageGL::Unknown format: " << dataformat << llendl; |
159 | return 0; | 169 | return 0; |
160 | } | 170 | } |
161 | } | 171 | } |
@@ -190,7 +200,7 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat) | |||
190 | case GL_RGBA: return 4; | 200 | case GL_RGBA: return 4; |
191 | case GL_BGRA: return 4; // Used for QuickTime media textures on the Mac | 201 | case GL_BGRA: return 4; // Used for QuickTime media textures on the Mac |
192 | default: | 202 | default: |
193 | llwarns << "LLImageGL::Unknown format: " << dataformat << llendl; | 203 | llerrs << "LLImageGL::Unknown format: " << dataformat << llendl; |
194 | return 0; | 204 | return 0; |
195 | } | 205 | } |
196 | } | 206 | } |
@@ -204,25 +214,43 @@ void LLImageGL::updateStats(F32 current_time) | |||
204 | sBoundTextureMemoryInBytes = sCurBoundTextureMemory; | 214 | sBoundTextureMemoryInBytes = sCurBoundTextureMemory; |
205 | sCurBoundTextureMemory = 0; | 215 | sCurBoundTextureMemory = 0; |
206 | 216 | ||
207 | #if !LL_RELEASE_FOR_DOWNLOAD | 217 | if(gAuditTexture) |
208 | for(U32 i = 0 ; i < sTextureCurBoundCounter.size() ; i++) | ||
209 | { | 218 | { |
210 | sTextureBoundCounter[i] = sTextureCurBoundCounter[i] ; | 219 | for(U32 i = 0 ; i < sTextureCurBoundCounter.size() ; i++) |
211 | sTextureCurBoundCounter[i] = 0 ; | 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 | } | ||
212 | } | 229 | } |
213 | #endif | ||
214 | } | 230 | } |
215 | 231 | ||
216 | //static | 232 | //static |
217 | //#if !LL_RELEASE_FOR_DOWNLOAD | 233 | S32 LLImageGL::updateBoundTexMemStatic(const S32 delta, const S32 size, S32 category) |
218 | //S32 LLImageGL::updateBoundTexMem(const S32 delta, const S32 size) | 234 | { |
219 | //{ | 235 | if(gAuditTexture) |
220 | // sTextureCurBoundCounter[getTextureCounterIndex(size)]++ ; | 236 | { |
221 | //#else | 237 | sTextureCurBoundCounter[getTextureCounterIndex(size)]++ ; |
222 | S32 LLImageGL::updateBoundTexMem(const S32 delta) | 238 | sTextureCurMemByCategoryBound[category] += delta ; |
223 | { | 239 | } |
224 | //#endif | 240 | |
225 | LLImageGL::sCurBoundTextureMemory += delta; | 241 | LLImageGL::sCurBoundTextureMemory += delta ; |
242 | return LLImageGL::sCurBoundTextureMemory; | ||
243 | } | ||
244 | |||
245 | S32 LLImageGL::updateBoundTexMem()const | ||
246 | { | ||
247 | if(gAuditTexture) | ||
248 | { | ||
249 | sTextureCurBoundCounter[getTextureCounterIndex(mTextureMemory / mComponents)]++ ; | ||
250 | sTextureCurMemByCategoryBound[mCategory] += mTextureMemory ; | ||
251 | } | ||
252 | |||
253 | LLImageGL::sCurBoundTextureMemory += mTextureMemory ; | ||
226 | return LLImageGL::sCurBoundTextureMemory; | 254 | return LLImageGL::sCurBoundTextureMemory; |
227 | } | 255 | } |
228 | 256 | ||
@@ -236,6 +264,7 @@ void LLImageGL::destroyGL(BOOL save_state) | |||
236 | gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); | 264 | gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); |
237 | } | 265 | } |
238 | 266 | ||
267 | sAllowReadBackRaw = true ; | ||
239 | for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); | 268 | for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); |
240 | iter != sImageList.end(); iter++) | 269 | iter != sImageList.end(); iter++) |
241 | { | 270 | { |
@@ -255,7 +284,7 @@ void LLImageGL::destroyGL(BOOL save_state) | |||
255 | stop_glerror(); | 284 | stop_glerror(); |
256 | } | 285 | } |
257 | } | 286 | } |
258 | // sAllowReadBackRaw = false ; | 287 | sAllowReadBackRaw = false ; |
259 | } | 288 | } |
260 | 289 | ||
261 | //static | 290 | //static |
@@ -267,13 +296,13 @@ void LLImageGL::restoreGL() | |||
267 | LLImageGL* glimage = *iter; | 296 | LLImageGL* glimage = *iter; |
268 | if(glimage->getTexName()) | 297 | if(glimage->getTexName()) |
269 | { | 298 | { |
270 | llwarns << "tex name is not 0." << llendl ; | 299 | llerrs << "tex name is not 0." << llendl ; |
271 | } | 300 | } |
272 | if (glimage->mSaveData.notNull()) | 301 | if (glimage->mSaveData.notNull()) |
273 | { | 302 | { |
274 | if (glimage->getComponents() && glimage->mSaveData->getComponents()) | 303 | if (glimage->getComponents() && glimage->mSaveData->getComponents()) |
275 | { | 304 | { |
276 | glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData); | 305 | glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData, 0, TRUE, glimage->getCategory()); |
277 | stop_glerror(); | 306 | stop_glerror(); |
278 | } | 307 | } |
279 | glimage->mSaveData = NULL; // deletes data | 308 | glimage->mSaveData = NULL; // deletes data |
@@ -355,7 +384,7 @@ void LLImageGL::init(BOOL usemipmaps) | |||
355 | mTextureState = NO_DELETE ; | 384 | mTextureState = NO_DELETE ; |
356 | mTextureMemory = 0; | 385 | mTextureMemory = 0; |
357 | mLastBindTime = 0.f; | 386 | mLastBindTime = 0.f; |
358 | 387 | ||
359 | mTarget = GL_TEXTURE_2D; | 388 | mTarget = GL_TEXTURE_2D; |
360 | mBindTarget = LLTexUnit::TT_TEXTURE; | 389 | mBindTarget = LLTexUnit::TT_TEXTURE; |
361 | mUseMipMaps = usemipmaps; | 390 | mUseMipMaps = usemipmaps; |
@@ -382,12 +411,9 @@ void LLImageGL::init(BOOL usemipmaps) | |||
382 | mHasExplicitFormat = FALSE; | 411 | mHasExplicitFormat = FALSE; |
383 | 412 | ||
384 | mGLTextureCreated = FALSE ; | 413 | mGLTextureCreated = FALSE ; |
414 | |||
385 | mIsMask = FALSE; | 415 | mIsMask = FALSE; |
386 | // mCategory = -1 ; | 416 | mCategory = -1 ; |
387 | mCanAddToAtlas = TRUE ; | ||
388 | mDiscardLevelInAtlas = -1 ; | ||
389 | mTexelsInAtlas = 0 ; | ||
390 | mTexelsInGLTexture = 0 ; | ||
391 | } | 417 | } |
392 | 418 | ||
393 | void LLImageGL::cleanup() | 419 | void LLImageGL::cleanup() |
@@ -429,7 +455,7 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents) | |||
429 | // Check if dimensions are a power of two! | 455 | // Check if dimensions are a power of two! |
430 | if (!checkSize(width,height)) | 456 | if (!checkSize(width,height)) |
431 | { | 457 | { |
432 | llwarns << llformat("Texture has non power of two dimention: %dx%d",width,height) << llendl; | 458 | llerrs << llformat("Texture has non power of two dimention: %dx%d",width,height) << llendl; |
433 | } | 459 | } |
434 | 460 | ||
435 | if (mTexName) | 461 | if (mTexName) |
@@ -487,6 +513,10 @@ void LLImageGL::dump() | |||
487 | } | 513 | } |
488 | 514 | ||
489 | //---------------------------------------------------------------------------- | 515 | //---------------------------------------------------------------------------- |
516 | void LLImageGL::forceUpdateBindStats(void) const | ||
517 | { | ||
518 | mLastBindTime = sLastFrameTime; | ||
519 | } | ||
490 | 520 | ||
491 | void LLImageGL::updateBindStats(void) const | 521 | void LLImageGL::updateBindStats(void) const |
492 | { | 522 | { |
@@ -500,12 +530,8 @@ void LLImageGL::updateBindStats(void) const | |||
500 | { | 530 | { |
501 | // we haven't accounted for this texture yet this frame | 531 | // we haven't accounted for this texture yet this frame |
502 | sUniqueCount++; | 532 | sUniqueCount++; |
503 | 533 | ||
504 | //#if !LL_RELEASE_FOR_DOWNLOAD | 534 | updateBoundTexMem(); |
505 | // updateBoundTexMem(mTextureMemory, getWidth(mCurrentDiscardLevel) * getHeight(mCurrentDiscardLevel)) ; | ||
506 | //#else | ||
507 | updateBoundTexMem(mTextureMemory); | ||
508 | //#endif | ||
509 | mLastBindTime = sLastFrameTime; | 535 | mLastBindTime = sLastFrameTime; |
510 | } | 536 | } |
511 | } | 537 | } |
@@ -518,7 +544,7 @@ bool LLImageGL::bindError(const S32 stage) const | |||
518 | } | 544 | } |
519 | 545 | ||
520 | //virtual | 546 | //virtual |
521 | bool LLImageGL::bindDefaultImage(const S32 stage) const | 547 | bool LLImageGL::bindDefaultImage(const S32 stage) |
522 | { | 548 | { |
523 | return false; | 549 | return false; |
524 | } | 550 | } |
@@ -557,7 +583,6 @@ void LLImageGL::setImage(const LLImageRaw* imageraw) | |||
557 | void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) | 583 | void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) |
558 | { | 584 | { |
559 | // LLFastTimer t1(LLFastTimer::FTM_TEMP1); | 585 | // LLFastTimer t1(LLFastTimer::FTM_TEMP1); |
560 | llpushcallstacks ; | ||
561 | bool is_compressed = false; | 586 | bool is_compressed = false; |
562 | if (mFormatPrimary >= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && mFormatPrimary <= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) | 587 | if (mFormatPrimary >= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && mFormatPrimary <= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) |
563 | { | 588 | { |
@@ -565,7 +590,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) | |||
565 | } | 590 | } |
566 | 591 | ||
567 | // LLFastTimer t2(LLFastTimer::FTM_TEMP2); | 592 | // LLFastTimer t2(LLFastTimer::FTM_TEMP2); |
568 | llverify(gGL.getTexUnit(0)->bind(this, false, true)); | 593 | gGL.getTexUnit(0)->bind(this); |
569 | 594 | ||
570 | if (mUseMipMaps) | 595 | if (mUseMipMaps) |
571 | { | 596 | { |
@@ -728,7 +753,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) | |||
728 | } | 753 | } |
729 | else | 754 | else |
730 | { | 755 | { |
731 | llwarns << "Compressed Image has mipmaps but data does not (can not auto generate compressed mips)" << llendl; | 756 | llerrs << "Compressed Image has mipmaps but data does not (can not auto generate compressed mips)" << llendl; |
732 | } | 757 | } |
733 | mHasMipMaps = true; | 758 | mHasMipMaps = true; |
734 | } | 759 | } |
@@ -770,63 +795,10 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) | |||
770 | } | 795 | } |
771 | stop_glerror(); | 796 | stop_glerror(); |
772 | mGLTextureCreated = true; | 797 | mGLTextureCreated = true; |
773 | llpushcallstacks ; | ||
774 | } | ||
775 | |||
776 | BOOL LLImageGL::canAddToAtlas() | ||
777 | { | ||
778 | return sUseTextureAtlas && mCanAddToAtlas ; | ||
779 | } | ||
780 | |||
781 | BOOL LLImageGL::addToAtlas(const LLImageRaw* raw_image, LLTextureAtlas* atlasp, S16 slot_col, S16 slot_row) | ||
782 | { | ||
783 | if(!atlasp) | ||
784 | { | ||
785 | return FALSE ; | ||
786 | } | ||
787 | |||
788 | preAddToAtlas(raw_image->getWidth()) ; | ||
789 | LLGLuint tex_name = atlasp->insertSubTexture(raw_image, slot_col, slot_row); | ||
790 | postAddToAtlas() ; | ||
791 | |||
792 | if(tex_name > 0) //successfully added to atlas | ||
793 | { | ||
794 | //gGL.getTexUnit(0)->setHasMipMaps(mHasMipMaps); | ||
795 | //gGL.getTexUnit(0)->setTextureAddressMode(mAddressMode); | ||
796 | gGL.getTexUnit(0)->setTextureFilteringOption(mFilterOption); | ||
797 | return TRUE ; | ||
798 | } | ||
799 | |||
800 | return FALSE ; | ||
801 | } | ||
802 | |||
803 | void LLImageGL::preAddToAtlas(S32 data_width) | ||
804 | { | ||
805 | glPixelStorei(GL_UNPACK_ROW_LENGTH, data_width); | ||
806 | stop_glerror(); | ||
807 | |||
808 | if(mFormatSwapBytes) | ||
809 | { | ||
810 | glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); | ||
811 | stop_glerror(); | ||
812 | } | ||
813 | } | 798 | } |
814 | 799 | ||
815 | void LLImageGL::postAddToAtlas() | 800 | BOOL 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) |
816 | { | 801 | { |
817 | if(mFormatSwapBytes) | ||
818 | { | ||
819 | glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); | ||
820 | stop_glerror(); | ||
821 | } | ||
822 | |||
823 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | ||
824 | stop_glerror(); | ||
825 | } | ||
826 | |||
827 | BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height) | ||
828 | { | ||
829 | llpushcallstacks ; | ||
830 | if (!width || !height) | 802 | if (!width || !height) |
831 | { | 803 | { |
832 | return TRUE; | 804 | return TRUE; |
@@ -842,7 +814,8 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 | |||
842 | return FALSE; | 814 | return FALSE; |
843 | } | 815 | } |
844 | 816 | ||
845 | if (x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight() && data_width == width && data_height == height) | 817 | // 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. |
818 | if (!force_fast_update && x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight() && data_width == width && data_height == height) | ||
846 | { | 819 | { |
847 | setImage(datap, FALSE); | 820 | setImage(datap, FALSE); |
848 | } | 821 | } |
@@ -851,7 +824,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 | |||
851 | if (mUseMipMaps) | 824 | if (mUseMipMaps) |
852 | { | 825 | { |
853 | dump(); | 826 | dump(); |
854 | llwarns << "setSubImage called with mipmapped image (not supported)" << llendl; | 827 | llerrs << "setSubImage called with mipmapped image (not supported)" << llendl; |
855 | } | 828 | } |
856 | llassert_always(mCurrentDiscardLevel == 0); | 829 | llassert_always(mCurrentDiscardLevel == 0); |
857 | llassert_always(x_pos >= 0 && y_pos >= 0); | 830 | llassert_always(x_pos >= 0 && y_pos >= 0); |
@@ -860,7 +833,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 | |||
860 | (y_pos + height) > getHeight()) | 833 | (y_pos + height) > getHeight()) |
861 | { | 834 | { |
862 | dump(); | 835 | dump(); |
863 | llwarns << "Subimage not wholly in target image!" | 836 | llerrs << "Subimage not wholly in target image!" |
864 | << " x_pos " << x_pos | 837 | << " x_pos " << x_pos |
865 | << " y_pos " << y_pos | 838 | << " y_pos " << y_pos |
866 | << " width " << width | 839 | << " width " << width |
@@ -874,7 +847,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 | |||
874 | (y_pos + height) > data_height) | 847 | (y_pos + height) > data_height) |
875 | { | 848 | { |
876 | dump(); | 849 | dump(); |
877 | llwarns << "Subimage not wholly in source image!" | 850 | llerrs << "Subimage not wholly in source image!" |
878 | << " x_pos " << x_pos | 851 | << " x_pos " << x_pos |
879 | << " y_pos " << y_pos | 852 | << " y_pos " << y_pos |
880 | << " width " << width | 853 | << " width " << width |
@@ -897,7 +870,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 | |||
897 | datap += (y_pos * data_width + x_pos) * getComponents(); | 870 | datap += (y_pos * data_width + x_pos) * getComponents(); |
898 | // Update the GL texture | 871 | // Update the GL texture |
899 | BOOL res = gGL.getTexUnit(0)->bindManual(mBindTarget, mTexName); | 872 | BOOL res = gGL.getTexUnit(0)->bindManual(mBindTarget, mTexName); |
900 | if (!res) llwarns << "LLImageGL::setSubImage(): bindTexture failed" << llendl; | 873 | if (!res) llerrs << "LLImageGL::setSubImage(): bindTexture failed" << llendl; |
901 | stop_glerror(); | 874 | stop_glerror(); |
902 | 875 | ||
903 | glTexSubImage2D(mTarget, 0, x_pos, y_pos, | 876 | glTexSubImage2D(mTarget, 0, x_pos, y_pos, |
@@ -915,13 +888,12 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 | |||
915 | stop_glerror(); | 888 | stop_glerror(); |
916 | mGLTextureCreated = true; | 889 | mGLTextureCreated = true; |
917 | } | 890 | } |
918 | llpushcallstacks ; | ||
919 | return TRUE; | 891 | return TRUE; |
920 | } | 892 | } |
921 | 893 | ||
922 | BOOL LLImageGL::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height) | 894 | BOOL LLImageGL::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height, BOOL force_fast_update) |
923 | { | 895 | { |
924 | return setSubImage(imageraw->getData(), imageraw->getWidth(), imageraw->getHeight(), x_pos, y_pos, width, height); | 896 | return setSubImage(imageraw->getData(), imageraw->getWidth(), imageraw->getHeight(), x_pos, y_pos, width, height, force_fast_update); |
925 | } | 897 | } |
926 | 898 | ||
927 | // Copy sub image from frame buffer | 899 | // Copy sub image from frame buffer |
@@ -929,6 +901,7 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_ | |||
929 | { | 901 | { |
930 | if (gGL.getTexUnit(0)->bind(this, false, true)) | 902 | if (gGL.getTexUnit(0)->bind(this, false, true)) |
931 | { | 903 | { |
904 | //checkTexSize() ; | ||
932 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height); | 905 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height); |
933 | mGLTextureCreated = true; | 906 | mGLTextureCreated = true; |
934 | stop_glerror(); | 907 | stop_glerror(); |
@@ -949,17 +922,13 @@ void LLImageGL::generateTextures(S32 numTextures, U32 *textures) | |||
949 | // static | 922 | // static |
950 | void LLImageGL::deleteTextures(S32 numTextures, U32 *textures) | 923 | void LLImageGL::deleteTextures(S32 numTextures, U32 *textures) |
951 | { | 924 | { |
952 | for (S32 i = 0; i < numTextures; i++) | 925 | glDeleteTextures(numTextures, (GLuint*)textures); |
953 | { | ||
954 | sDeadTextureList.push_back(textures[i]); | ||
955 | } | ||
956 | } | 926 | } |
957 | 927 | ||
958 | // static | 928 | // static |
959 | void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels) | 929 | void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels) |
960 | { | 930 | { |
961 | glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, pixels); | 931 | glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, pixels); |
962 | stop_glerror(); | ||
963 | } | 932 | } |
964 | 933 | ||
965 | //create an empty GL texture: just create a texture name | 934 | //create an empty GL texture: just create a texture name |
@@ -986,26 +955,21 @@ BOOL LLImageGL::createGLTexture() | |||
986 | stop_glerror(); | 955 | stop_glerror(); |
987 | if (!mTexName) | 956 | if (!mTexName) |
988 | { | 957 | { |
989 | llwarns << "LLImageGL::createGLTexture failed to make an empty texture" << llendl; | 958 | llerrs << "LLImageGL::createGLTexture failed to make an empty texture" << llendl; |
990 | } | 959 | } |
991 | 960 | ||
992 | return TRUE ; | 961 | return TRUE ; |
993 | } | 962 | } |
994 | 963 | ||
995 | BOOL LLImageGL::createGLTextureInAtlas(S32 discard_level, const LLImageRaw* imageraw, LLTextureAtlas* atlasp, S16 slot_col, S16 slot_row) | 964 | BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/, BOOL to_create, S32 category) |
996 | { | 965 | { |
997 | if(!sUseTextureAtlas) | ||
998 | { | ||
999 | return FALSE ; | ||
1000 | } | ||
1001 | |||
1002 | if (gGLManager.mIsDisabled) | 966 | if (gGLManager.mIsDisabled) |
1003 | { | 967 | { |
1004 | llwarns << "Trying to create a texture while GL is disabled!" << llendl; | 968 | llwarns << "Trying to create a texture while GL is disabled!" << llendl; |
1005 | return FALSE; | 969 | return FALSE; |
1006 | } | 970 | } |
1007 | 971 | ||
1008 | // mGLTextureCreated = false ; // KL not in SD | 972 | mGLTextureCreated = false ; |
1009 | llassert(gGLManager.mInited); | 973 | llassert(gGLManager.mInited); |
1010 | stop_glerror(); | 974 | stop_glerror(); |
1011 | 975 | ||
@@ -1017,8 +981,10 @@ BOOL LLImageGL::createGLTextureInAtlas(S32 discard_level, const LLImageRaw* imag | |||
1017 | discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel); | 981 | discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel); |
1018 | 982 | ||
1019 | // Actual image width/height = raw image width/height * 2^discard_level | 983 | // Actual image width/height = raw image width/height * 2^discard_level |
1020 | S32 w = imageraw->getWidth() << discard_level; | 984 | S32 raw_w = imageraw->getWidth() ; |
1021 | S32 h = imageraw->getHeight() << discard_level; | 985 | S32 raw_h = imageraw->getHeight() ; |
986 | S32 w = raw_w << discard_level; | ||
987 | S32 h = raw_h << discard_level; | ||
1022 | 988 | ||
1023 | // setSize may call destroyGLTexture if the size does not match | 989 | // setSize may call destroyGLTexture if the size does not match |
1024 | setSize(w, h, imageraw->getComponents()); | 990 | setSize(w, h, imageraw->getComponents()); |
@@ -1050,87 +1016,27 @@ BOOL LLImageGL::createGLTextureInAtlas(S32 discard_level, const LLImageRaw* imag | |||
1050 | mFormatType = GL_UNSIGNED_BYTE; | 1016 | mFormatType = GL_UNSIGNED_BYTE; |
1051 | break; | 1017 | break; |
1052 | default: | 1018 | default: |
1053 | llwarns << "Bad number of components for texture: " << (U32)getComponents() << llendl; | 1019 | LL_DEBUGS("Openjpeg") << "Bad number of components for texture: " << (U32)getComponents() << LL_ENDL; |
1020 | to_create = false; | ||
1021 | break; | ||
1054 | } | 1022 | } |
1055 | } | 1023 | } |
1056 | 1024 | ||
1057 | if(addToAtlas(imageraw, atlasp, slot_col, slot_row)) | 1025 | if(!to_create) //not create a gl texture |
1058 | { | 1026 | { |
1059 | // destroyGLTexture(); | 1027 | destroyGLTexture(); |
1060 | mCurrentDiscardLevel = discard_level; | 1028 | mCurrentDiscardLevel = discard_level; |
1061 | mDiscardLevelInAtlas = discard_level; | ||
1062 | mTexelsInAtlas = imageraw->getWidth() * imageraw->getHeight() ; | ||
1063 | mLastBindTime = sLastFrameTime; | 1029 | mLastBindTime = sLastFrameTime; |
1064 | mGLTextureCreated = false ; | ||
1065 | return TRUE ; | 1030 | return TRUE ; |
1066 | } | 1031 | } |
1067 | return FALSE ; | ||
1068 | } | ||
1069 | |||
1070 | BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/) | ||
1071 | { | ||
1072 | if (gGLManager.mIsDisabled) | ||
1073 | { | ||
1074 | llwarns << "Trying to create a texture while GL is disabled!" << llendl; | ||
1075 | return FALSE; | ||
1076 | } | ||
1077 | |||
1078 | mGLTextureCreated = false ; | ||
1079 | llassert(gGLManager.mInited); | ||
1080 | stop_glerror(); | ||
1081 | |||
1082 | if (discard_level < 0) | ||
1083 | { | ||
1084 | llassert(mCurrentDiscardLevel >= 0); | ||
1085 | discard_level = mCurrentDiscardLevel; | ||
1086 | } | ||
1087 | discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel); | ||
1088 | |||
1089 | // Actual image width/height = raw image width/height * 2^discard_level | ||
1090 | S32 w = imageraw->getWidth() << discard_level; | ||
1091 | S32 h = imageraw->getHeight() << discard_level; | ||
1092 | |||
1093 | // setSize may call destroyGLTexture if the size does not match | ||
1094 | setSize(w, h, imageraw->getComponents()); | ||
1095 | |||
1096 | if( !mHasExplicitFormat ) | ||
1097 | { | ||
1098 | switch (mComponents) | ||
1099 | { | ||
1100 | case 1: | ||
1101 | // Use luminance alpha (for fonts) | ||
1102 | mFormatInternal = GL_LUMINANCE8; | ||
1103 | mFormatPrimary = GL_LUMINANCE; | ||
1104 | mFormatType = GL_UNSIGNED_BYTE; | ||
1105 | break; | ||
1106 | case 2: | ||
1107 | // Use luminance alpha (for fonts) | ||
1108 | mFormatInternal = GL_LUMINANCE8_ALPHA8; | ||
1109 | mFormatPrimary = GL_LUMINANCE_ALPHA; | ||
1110 | mFormatType = GL_UNSIGNED_BYTE; | ||
1111 | break; | ||
1112 | case 3: | ||
1113 | mFormatInternal = GL_RGB8; | ||
1114 | mFormatPrimary = GL_RGB; | ||
1115 | mFormatType = GL_UNSIGNED_BYTE; | ||
1116 | break; | ||
1117 | case 4: | ||
1118 | mFormatInternal = GL_RGBA8; | ||
1119 | mFormatPrimary = GL_RGBA; | ||
1120 | mFormatType = GL_UNSIGNED_BYTE; | ||
1121 | break; | ||
1122 | default: | ||
1123 | llwarns << "Bad number of components for texture: " << (U32)getComponents() << llendl; | ||
1124 | } | ||
1125 | } | ||
1126 | 1032 | ||
1033 | mCategory = category ; | ||
1127 | const U8* rawdata = imageraw->getData(); | 1034 | const U8* rawdata = imageraw->getData(); |
1128 | return createGLTexture(discard_level, rawdata, FALSE, usename); | 1035 | return createGLTexture(discard_level, rawdata, FALSE, usename); |
1129 | } | 1036 | } |
1130 | 1037 | ||
1131 | BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_hasmips, S32 usename) | 1038 | BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_hasmips, S32 usename) |
1132 | { | 1039 | { |
1133 | llpushcallstacks ; | ||
1134 | llassert(data_in); | 1040 | llassert(data_in); |
1135 | 1041 | ||
1136 | if (discard_level < 0) | 1042 | if (discard_level < 0) |
@@ -1167,7 +1073,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ | |||
1167 | } | 1073 | } |
1168 | if (!mTexName) | 1074 | if (!mTexName) |
1169 | { | 1075 | { |
1170 | llwarns << "LLImageGL::createGLTexture failed to make texture" << llendl; | 1076 | llerrs << "LLImageGL::createGLTexture failed to make texture" << llendl; |
1171 | } | 1077 | } |
1172 | 1078 | ||
1173 | if (mUseMipMaps) | 1079 | if (mUseMipMaps) |
@@ -1198,30 +1104,30 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ | |||
1198 | if (old_name != 0) | 1104 | if (old_name != 0) |
1199 | { | 1105 | { |
1200 | sGlobalTextureMemoryInBytes -= mTextureMemory; | 1106 | sGlobalTextureMemoryInBytes -= mTextureMemory; |
1201 | #if !LL_RELEASE_FOR_DOWNLOAD | 1107 | |
1202 | decTextureCounter(mTextureMemory / mComponents) ; | 1108 | if(gAuditTexture) |
1203 | #endif | 1109 | { |
1110 | decTextureCounter() ; | ||
1111 | } | ||
1204 | 1112 | ||
1205 | LLImageGL::deleteTextures(1, &old_name); | 1113 | LLImageGL::deleteTextures(1, &old_name); |
1114 | |||
1206 | stop_glerror(); | 1115 | stop_glerror(); |
1207 | } | 1116 | } |
1208 | 1117 | ||
1209 | mTextureMemory = getMipBytes(discard_level); | 1118 | mTextureMemory = getMipBytes(discard_level); |
1210 | sGlobalTextureMemoryInBytes += mTextureMemory; | 1119 | sGlobalTextureMemoryInBytes += mTextureMemory; |
1211 | mTexelsInGLTexture = getWidth() * getHeight() ; | ||
1212 | |||
1213 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
1214 | incTextureCounter(mTextureMemory / mComponents) ; | ||
1215 | #endif | ||
1216 | setActive() ; | 1120 | setActive() ; |
1217 | 1121 | ||
1122 | if(gAuditTexture) | ||
1123 | { | ||
1124 | incTextureCounter() ; | ||
1125 | } | ||
1218 | // mark this as bound at this point, so we don't throw it out immediately | 1126 | // mark this as bound at this point, so we don't throw it out immediately |
1219 | mLastBindTime = sLastFrameTime; | 1127 | mLastBindTime = sLastFrameTime; |
1220 | |||
1221 | llpushcallstacks ; | ||
1222 | return TRUE; | 1128 | return TRUE; |
1223 | } | 1129 | } |
1224 | 1130 | #if 0 | |
1225 | BOOL LLImageGL::setDiscardLevel(S32 discard_level) | 1131 | BOOL LLImageGL::setDiscardLevel(S32 discard_level) |
1226 | { | 1132 | { |
1227 | llassert(discard_level >= 0); | 1133 | llassert(discard_level >= 0); |
@@ -1243,7 +1149,7 @@ BOOL LLImageGL::setDiscardLevel(S32 discard_level) | |||
1243 | { | 1149 | { |
1244 | // larger image | 1150 | // larger image |
1245 | dump(); | 1151 | dump(); |
1246 | llwarns << "LLImageGL::setDiscardLevel() called with larger discard level; use createGLTexture()" << llendl; | 1152 | llerrs << "LLImageGL::setDiscardLevel() called with larger discard level; use createGLTexture()" << llendl; |
1247 | return FALSE; | 1153 | return FALSE; |
1248 | } | 1154 | } |
1249 | else if (mUseMipMaps) | 1155 | else if (mUseMipMaps) |
@@ -1268,30 +1174,19 @@ BOOL LLImageGL::setDiscardLevel(S32 discard_level) | |||
1268 | { | 1174 | { |
1269 | #if !LL_LINUX && !LL_SOLARIS | 1175 | #if !LL_LINUX && !LL_SOLARIS |
1270 | // *FIX: This should not be skipped for the linux client. | 1176 | // *FIX: This should not be skipped for the linux client. |
1271 | llwarns << "LLImageGL::setDiscardLevel() called on image without mipmaps" << llendl; | 1177 | llerrs << "LLImageGL::setDiscardLevel() called on image without mipmaps" << llendl; |
1272 | #endif | 1178 | #endif |
1273 | return FALSE; | 1179 | return FALSE; |
1274 | } | 1180 | } |
1275 | } | 1181 | } |
1276 | 1182 | #endif | |
1277 | BOOL LLImageGL::isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) | ||
1278 | { | ||
1279 | assert_glerror(); | ||
1280 | S32 gl_discard = discard_level - mCurrentDiscardLevel; | ||
1281 | LLGLint glwidth = 0; | ||
1282 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_WIDTH, (GLint*)&glwidth); | ||
1283 | LLGLint glheight = 0; | ||
1284 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_HEIGHT, (GLint*)&glheight); | ||
1285 | LLGLint glcomponents = 0 ; | ||
1286 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_INTERNAL_FORMAT, (GLint*)&glcomponents); | ||
1287 | assert_glerror(); | ||
1288 | |||
1289 | return glwidth >= image_width && glheight >= image_height && (GL_RGB8 == glcomponents || GL_RGBA8 == glcomponents) ; | ||
1290 | } | ||
1291 | 1183 | ||
1292 | BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) | 1184 | BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) |
1293 | { | 1185 | { |
1294 | llpushcallstacks ; | 1186 | // VWR-13505 : Merov : Allow gl texture read back so save texture works again (temporary) |
1187 | //llassert_always(sAllowReadBackRaw) ; | ||
1188 | //llerrs << "should not call this function!" << llendl ; | ||
1189 | |||
1295 | if (discard_level < 0) | 1190 | if (discard_level < 0) |
1296 | { | 1191 | { |
1297 | discard_level = mCurrentDiscardLevel; | 1192 | discard_level = mCurrentDiscardLevel; |
@@ -1396,48 +1291,41 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre | |||
1396 | return FALSE ; | 1291 | return FALSE ; |
1397 | } | 1292 | } |
1398 | //----------------------------------------------------------------------------------------------- | 1293 | //----------------------------------------------------------------------------------------------- |
1399 | llpushcallstacks ; | 1294 | |
1400 | return TRUE ; | 1295 | return TRUE ; |
1401 | } | 1296 | } |
1402 | 1297 | ||
1403 | void LLImageGL::deleteDeadTextures() | 1298 | void LLImageGL::destroyGLTexture() |
1404 | { | 1299 | { |
1405 | while (!sDeadTextureList.empty()) | 1300 | if (mTexName != 0) |
1406 | { | 1301 | { |
1407 | GLuint tex = sDeadTextureList.front(); | 1302 | stop_glerror(); |
1408 | sDeadTextureList.pop_front(); | 1303 | |
1409 | for (int i = 0; i < gGLManager.mNumTextureUnits; i++) | 1304 | for (int i = 0; i < gGLManager.mNumTextureUnits; i++) |
1410 | { | 1305 | { |
1411 | if (sCurrentBoundTextures[i] == tex) | 1306 | if (sCurrentBoundTextures[i] == mTexName) |
1412 | { | 1307 | { |
1413 | gGL.getTexUnit(i)->unbind(LLTexUnit::TT_TEXTURE); | 1308 | gGL.getTexUnit(i)->unbind(LLTexUnit::TT_TEXTURE); |
1414 | stop_glerror(); | 1309 | stop_glerror(); |
1415 | } | 1310 | } |
1416 | } | 1311 | } |
1417 | 1312 | ||
1418 | glDeleteTextures(1, &tex); | ||
1419 | stop_glerror(); | ||
1420 | } | ||
1421 | } | ||
1422 | |||
1423 | void LLImageGL::destroyGLTexture() | ||
1424 | { | ||
1425 | if (mTexName != 0) | ||
1426 | { | ||
1427 | if(mTextureMemory) | 1313 | if(mTextureMemory) |
1428 | { | 1314 | { |
1429 | #if !LL_RELEASE_FOR_DOWNLOAD | 1315 | if(gAuditTexture) |
1430 | decTextureCounter(mTextureMemory / mComponents) ; | 1316 | { |
1431 | #endif | 1317 | decTextureCounter() ; |
1318 | } | ||
1432 | sGlobalTextureMemoryInBytes -= mTextureMemory; | 1319 | sGlobalTextureMemoryInBytes -= mTextureMemory; |
1433 | mTextureMemory = 0; | 1320 | mTextureMemory = 0; |
1434 | } | 1321 | } |
1435 | 1322 | ||
1436 | LLImageGL::deleteTextures(1, &mTexName); | 1323 | LLImageGL::deleteTextures(1, &mTexName); |
1437 | mTextureState = DELETED ; | 1324 | mTextureState = DELETED ; |
1438 | mTexName = 0; | 1325 | mTexName = 0; |
1439 | mCurrentDiscardLevel = -1 ; //invalidate mCurrentDiscardLevel. | 1326 | mCurrentDiscardLevel = -1 ; //invalidate mCurrentDiscardLevel. |
1440 | mGLTextureCreated = FALSE ; | 1327 | mGLTextureCreated = FALSE ; |
1328 | stop_glerror(); | ||
1441 | } | 1329 | } |
1442 | } | 1330 | } |
1443 | 1331 | ||
@@ -1466,12 +1354,12 @@ void LLImageGL::setFilteringOption(LLTexUnit::eTextureFilterOptions option) | |||
1466 | mFilterOption = option; | 1354 | mFilterOption = option; |
1467 | } | 1355 | } |
1468 | 1356 | ||
1469 | if (mTexName != 0 && gGL.getTexUnit(gGL.getCurrentTexUnitIndex())->getCurrTexture() == mTexName) | 1357 | if (gGL.getTexUnit(gGL.getCurrentTexUnitIndex())->getCurrTexture() == mTexName) |
1470 | { | 1358 | { |
1471 | gGL.getTexUnit(gGL.getCurrentTexUnitIndex())->setTextureFilteringOption(option); | 1359 | gGL.getTexUnit(gGL.getCurrentTexUnitIndex())->setTextureFilteringOption(option); |
1472 | mTexOptionsDirty = false; | 1360 | mTexOptionsDirty = false; |
1473 | stop_glerror(); | ||
1474 | } | 1361 | } |
1362 | stop_glerror(); | ||
1475 | } | 1363 | } |
1476 | 1364 | ||
1477 | BOOL LLImageGL::getIsResident(BOOL test_now) | 1365 | BOOL LLImageGL::getIsResident(BOOL test_now) |
@@ -1547,6 +1435,11 @@ S32 LLImageGL::getMipBytes(S32 discard_level) const | |||
1547 | return res; | 1435 | return res; |
1548 | } | 1436 | } |
1549 | 1437 | ||
1438 | BOOL LLImageGL::isJustBound() const | ||
1439 | { | ||
1440 | return (BOOL)(sLastFrameTime - mLastBindTime < 0.5f); | ||
1441 | } | ||
1442 | |||
1550 | BOOL LLImageGL::getBoundRecently() const | 1443 | BOOL LLImageGL::getBoundRecently() const |
1551 | { | 1444 | { |
1552 | return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME); | 1445 | return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME); |
@@ -1708,7 +1601,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) | |||
1708 | U32 pick_offset = pick_bit%8; | 1601 | U32 pick_offset = pick_bit%8; |
1709 | if (pick_idx >= mPickMaskSize) | 1602 | if (pick_idx >= mPickMaskSize) |
1710 | { | 1603 | { |
1711 | llwarns << "WTF?" << llendl; | 1604 | llerrs << "WTF?" << llendl; |
1712 | } | 1605 | } |
1713 | 1606 | ||
1714 | mPickMask[pick_idx] |= 1 << pick_offset; | 1607 | mPickMask[pick_idx] |= 1 << pick_offset; |
@@ -1734,7 +1627,7 @@ BOOL LLImageGL::getMask(const LLVector2 &tc) | |||
1734 | if (u < 0.f || u > 1.f || | 1627 | if (u < 0.f || u > 1.f || |
1735 | v < 0.f || v > 1.f) | 1628 | v < 0.f || v > 1.f) |
1736 | { | 1629 | { |
1737 | llwarns << "WTF?" << llendl; // WTF really useful info NOT | 1630 | llerrs << "WTF?" << llendl; |
1738 | } | 1631 | } |
1739 | 1632 | ||
1740 | S32 x = (S32)(u * width); | 1633 | S32 x = (S32)(u * width); |
@@ -1757,8 +1650,24 @@ BOOL LLImageGL::getMask(const LLVector2 &tc) | |||
1757 | return res; | 1650 | return res; |
1758 | } | 1651 | } |
1759 | 1652 | ||
1760 | //---------------------------------------------------------------------------- | 1653 | void LLImageGL::setCategory(S32 category) |
1761 | #if !LL_RELEASE_FOR_DOWNLOAD | 1654 | { |
1655 | if(!gAuditTexture) | ||
1656 | { | ||
1657 | return ; | ||
1658 | } | ||
1659 | if(mCategory != category) | ||
1660 | { | ||
1661 | if(mCategory > -1) | ||
1662 | { | ||
1663 | sTextureMemByCategory[mCategory] -= mTextureMemory ; | ||
1664 | } | ||
1665 | sTextureMemByCategory[category] += mTextureMemory ; | ||
1666 | |||
1667 | mCategory = category; | ||
1668 | } | ||
1669 | } | ||
1670 | |||
1762 | //for debug use | 1671 | //for debug use |
1763 | //val is a "power of two" number | 1672 | //val is a "power of two" number |
1764 | S32 LLImageGL::getTextureCounterIndex(U32 val) | 1673 | S32 LLImageGL::getTextureCounterIndex(U32 val) |
@@ -1782,18 +1691,38 @@ S32 LLImageGL::getTextureCounterIndex(U32 val) | |||
1782 | return ret ; | 1691 | return ret ; |
1783 | } | 1692 | } |
1784 | } | 1693 | } |
1785 | void LLImageGL::incTextureCounter(U32 val) | 1694 | void LLImageGL::incTextureCounterStatic(U32 val, S32 ncomponents, S32 category) |
1786 | { | 1695 | { |
1787 | sTextureLoadedCounter[getTextureCounterIndex(val)]++ ; | 1696 | sTextureLoadedCounter[getTextureCounterIndex(val)]++ ; |
1697 | sTextureMemByCategory[category] += (S32)val * ncomponents ; | ||
1788 | } | 1698 | } |
1789 | void LLImageGL::decTextureCounter(U32 val) | 1699 | void LLImageGL::decTextureCounterStatic(U32 val, S32 ncomponents, S32 category) |
1790 | { | 1700 | { |
1791 | sTextureLoadedCounter[getTextureCounterIndex(val)]-- ; | 1701 | sTextureLoadedCounter[getTextureCounterIndex(val)]-- ; |
1702 | sTextureMemByCategory[category] += (S32)val * ncomponents ; | ||
1703 | } | ||
1704 | void LLImageGL::incTextureCounter() | ||
1705 | { | ||
1706 | sTextureLoadedCounter[getTextureCounterIndex(mTextureMemory / mComponents)]++ ; | ||
1707 | sTextureMemByCategory[mCategory] += mTextureMemory ; | ||
1708 | } | ||
1709 | void LLImageGL::decTextureCounter() | ||
1710 | { | ||
1711 | sTextureLoadedCounter[getTextureCounterIndex(mTextureMemory / mComponents)]-- ; | ||
1712 | sTextureMemByCategory[mCategory] -= mTextureMemory ; | ||
1792 | } | 1713 | } |
1793 | void LLImageGL::setCurTexSizebar(S32 index) | 1714 | void LLImageGL::setCurTexSizebar(S32 index, BOOL set_pick_size) |
1794 | { | 1715 | { |
1795 | sCurTexSizeBar = index ; | 1716 | sCurTexSizeBar = index ; |
1796 | sCurTexPickSize = (1 << index) ; | 1717 | |
1718 | if(set_pick_size) | ||
1719 | { | ||
1720 | sCurTexPickSize = (1 << index) ; | ||
1721 | } | ||
1722 | else | ||
1723 | { | ||
1724 | sCurTexPickSize = -1 ; | ||
1725 | } | ||
1797 | } | 1726 | } |
1798 | void LLImageGL::resetCurTexSizebar() | 1727 | void LLImageGL::resetCurTexSizebar() |
1799 | { | 1728 | { |
@@ -1801,7 +1730,9 @@ void LLImageGL::resetCurTexSizebar() | |||
1801 | sCurTexPickSize = -1 ; | 1730 | sCurTexPickSize = -1 ; |
1802 | } | 1731 | } |
1803 | //---------------------------------------------------------------------------- | 1732 | //---------------------------------------------------------------------------- |
1804 | #endif | 1733 | |
1734 | //---------------------------------------------------------------------------- | ||
1735 | |||
1805 | 1736 | ||
1806 | // Manual Mip Generation | 1737 | // Manual Mip Generation |
1807 | /* | 1738 | /* |
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 | ||
48 | class LLTextureAtlas ; | ||
49 | //============================================================================ | 48 | //============================================================================ |
50 | |||
51 | class LLImageGL : public LLRefCount | 49 | class LLImageGL : public LLRefCount |
52 | { | 50 | { |
53 | friend class LLTexUnit; | 51 | friend class LLTexUnit; |
54 | public: | 52 | public: |
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: | |||
97 | public: | 90 | public: |
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 | ||
197 | private: | 180 | void setTextureSize(S32 size) {mTextureMemory = size;} |
198 | void preAddToAtlas(S32 data_width) ; | ||
199 | void postAddToAtlas() ; | ||
200 | |||
201 | protected: | 181 | protected: |
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 | ||
210 | private: | 190 | private: |
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 | |||
230 | protected: | 206 | protected: |
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 | |||
261 | public: | ||
262 | static void initClass(S32 num_catagories) ; | ||
263 | static void cleanupClass() ; | ||
264 | private: | ||
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 | //**************************************************************************************************** | ||
274 | private: | ||
275 | S32 mCategory ; | ||
276 | public: | ||
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 | ||
312 | extern BOOL gAuditTexture; | ||
308 | #endif // LL_LLIMAGEGL_H | 313 | #endif // LL_LLIMAGEGL_H |
diff --git a/linden/indra/llrender/llrender.cpp b/linden/indra/llrender/llrender.cpp index 07ba9f1..b1fe153 100644 --- a/linden/indra/llrender/llrender.cpp +++ b/linden/indra/llrender/llrender.cpp | |||
@@ -47,7 +47,7 @@ F64 gGLLastModelView[16]; | |||
47 | F64 gGLProjection[16]; | 47 | F64 gGLProjection[16]; |
48 | S32 gGLViewport[4]; | 48 | S32 gGLViewport[4]; |
49 | 49 | ||
50 | static const U32 LL_NUM_TEXTURE_LAYERS = 16; // KL was 8 ( keep a track on this ) 16 in render-pipeline | 50 | static const U32 LL_NUM_TEXTURE_LAYERS = 8; |
51 | 51 | ||
52 | static GLenum sGLTextureType[] = | 52 | static GLenum sGLTextureType[] = |
53 | { | 53 | { |
@@ -192,25 +192,24 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind) | |||
192 | 192 | ||
193 | if (!texture->getTexName()) //if texture does not exist | 193 | if (!texture->getTexName()) //if texture does not exist |
194 | { | 194 | { |
195 | //if deleted, will re-generate it immediately | 195 | if (texture->isDeleted()) |
196 | texture->forceImmediateUpdate() ; | 196 | { |
197 | // This will re-generate the texture immediately. | ||
198 | texture->forceImmediateUpdate() ; | ||
199 | } | ||
197 | 200 | ||
201 | texture->forceUpdateBindStats() ; | ||
198 | return texture->bindDefaultImage(mIndex); | 202 | return texture->bindDefaultImage(mIndex); |
199 | } | 203 | } |
200 | 204 | ||
201 | #if !LL_RELEASE_FOR_DOWNLOAD | 205 | if(gAuditTexture && for_rendering && LLImageGL::sCurTexPickSize > 0) |
202 | if(for_rendering) | ||
203 | { | 206 | { |
204 | int w = texture->getWidth(texture->getDiscardLevel()) ; | 207 | if(texture->getWidth() * texture->getHeight() == LLImageGL::sCurTexPickSize) |
205 | int h = texture->getHeight(texture->getDiscardLevel()) ; | ||
206 | |||
207 | if(w * h == LLImageGL::sCurTexPickSize) | ||
208 | { | 208 | { |
209 | texture->updateBindStats(); | 209 | texture->updateBindStats(); |
210 | return bind(LLImageGL::sDefaultTexturep.get()); | 210 | return bind(LLImageGL::sDefaultTexturep.get()); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | #endif | ||
214 | 213 | ||
215 | if ((mCurrTexture != texture->getTexName()) || forceBind) | 214 | if ((mCurrTexture != texture->getTexName()) || forceBind) |
216 | { | 215 | { |
@@ -228,6 +227,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind) | |||
228 | setTextureFilteringOption(texture->mFilterOption); | 227 | setTextureFilteringOption(texture->mFilterOption); |
229 | } | 228 | } |
230 | } | 229 | } |
230 | |||
231 | return true; | 231 | return true; |
232 | } | 232 | } |
233 | 233 | ||
@@ -280,11 +280,6 @@ bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth) | |||
280 | 280 | ||
281 | if (bindDepth) | 281 | if (bindDepth) |
282 | { | 282 | { |
283 | if (renderTarget->hasStencil()) | ||
284 | { | ||
285 | llwarns << "Cannot bind a render buffer for sampling. Allocate render target without a stencil buffer if sampling of depth buffer is required." << llendl; | ||
286 | } | ||
287 | |||
288 | bindManual(renderTarget->getUsage(), renderTarget->getDepth()); | 283 | bindManual(renderTarget->getUsage(), renderTarget->getDepth()); |
289 | } | 284 | } |
290 | else | 285 | else |
@@ -298,18 +293,15 @@ bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth) | |||
298 | 293 | ||
299 | bool LLTexUnit::bindManual(eTextureType type, U32 texture, bool hasMips) | 294 | bool LLTexUnit::bindManual(eTextureType type, U32 texture, bool hasMips) |
300 | { | 295 | { |
301 | if (mIndex < 0) return false; | 296 | if (mIndex < 0 || mCurrTexture == texture) return false; |
302 | 297 | ||
303 | if(mCurrTexture != texture) | 298 | gGL.flush(); |
304 | { | ||
305 | gGL.flush(); | ||
306 | 299 | ||
307 | activate(); | 300 | activate(); |
308 | enable(type); | 301 | enable(type); |
309 | mCurrTexture = texture; | 302 | mCurrTexture = texture; |
310 | glBindTexture(sGLTextureType[type], texture); | 303 | glBindTexture(sGLTextureType[type], texture); |
311 | mHasMipMaps = hasMips; | 304 | mHasMipMaps = hasMips; |
312 | } | ||
313 | return true; | 305 | return true; |
314 | } | 306 | } |
315 | 307 | ||
@@ -422,7 +414,7 @@ void LLTexUnit::setTextureBlendType(eTextureBlendType type) | |||
422 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); | 414 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); |
423 | break; | 415 | break; |
424 | default: | 416 | default: |
425 | llwarns << "Unknown Texture Blend Type: " << type << llendl; | 417 | llerrs << "Unknown Texture Blend Type: " << type << llendl; |
426 | break; | 418 | break; |
427 | } | 419 | } |
428 | setColorScale(scale_amount); | 420 | setColorScale(scale_amount); |
@@ -817,7 +809,7 @@ void LLRender::setSceneBlendType(eBlendType type) | |||
817 | glBlendFunc(GL_ONE, GL_ZERO); | 809 | glBlendFunc(GL_ONE, GL_ZERO); |
818 | break; | 810 | break; |
819 | default: | 811 | default: |
820 | llwarns << "Unknown Scene Blend Type: " << type << llendl; | 812 | llerrs << "Unknown Scene Blend Type: " << type << llendl; |
821 | break; | 813 | break; |
822 | } | 814 | } |
823 | } | 815 | } |
@@ -891,7 +883,7 @@ void LLRender::begin(const GLuint& mode) | |||
891 | } | 883 | } |
892 | else if (mCount != 0) | 884 | else if (mCount != 0) |
893 | { | 885 | { |
894 | llwarns << "gGL.begin() called redundantly." << llendl; | 886 | llerrs << "gGL.begin() called redundantly." << llendl; |
895 | } | 887 | } |
896 | 888 | ||
897 | mMode = mode; | 889 | mMode = mode; |
@@ -922,22 +914,22 @@ void LLRender::flush() | |||
922 | #if 0 | 914 | #if 0 |
923 | if (!glIsEnabled(GL_VERTEX_ARRAY)) | 915 | if (!glIsEnabled(GL_VERTEX_ARRAY)) |
924 | { | 916 | { |
925 | llwarns << "foo 1" << llendl; | 917 | llerrs << "foo 1" << llendl; |
926 | } | 918 | } |
927 | 919 | ||
928 | if (!glIsEnabled(GL_COLOR_ARRAY)) | 920 | if (!glIsEnabled(GL_COLOR_ARRAY)) |
929 | { | 921 | { |
930 | llwarns << "foo 2" << llendl; | 922 | llerrs << "foo 2" << llendl; |
931 | } | 923 | } |
932 | 924 | ||
933 | if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY)) | 925 | if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY)) |
934 | { | 926 | { |
935 | llwarns << "foo 3" << llendl; | 927 | llerrs << "foo 3" << llendl; |
936 | } | 928 | } |
937 | 929 | ||
938 | if (glIsEnabled(GL_NORMAL_ARRAY)) | 930 | if (glIsEnabled(GL_NORMAL_ARRAY)) |
939 | { | 931 | { |
940 | llwarns << "foo 7" << llendl; | 932 | llerrs << "foo 7" << llendl; |
941 | } | 933 | } |
942 | 934 | ||
943 | GLvoid* pointer; | 935 | GLvoid* pointer; |
@@ -945,19 +937,19 @@ void LLRender::flush() | |||
945 | glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer); | 937 | glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer); |
946 | if (pointer != &(mBuffer[0].v)) | 938 | if (pointer != &(mBuffer[0].v)) |
947 | { | 939 | { |
948 | llwarns << "foo 4" << llendl; | 940 | llerrs << "foo 4" << llendl; |
949 | } | 941 | } |
950 | 942 | ||
951 | glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer); | 943 | glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer); |
952 | if (pointer != &(mBuffer[0].c)) | 944 | if (pointer != &(mBuffer[0].c)) |
953 | { | 945 | { |
954 | llwarns << "foo 5" << llendl; | 946 | llerrs << "foo 5" << llendl; |
955 | } | 947 | } |
956 | 948 | ||
957 | glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer); | 949 | glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer); |
958 | if (pointer != &(mBuffer[0].uv)) | 950 | if (pointer != &(mBuffer[0].uv)) |
959 | { | 951 | { |
960 | llwarns << "foo 6" << llendl; | 952 | llerrs << "foo 6" << llendl; |
961 | } | 953 | } |
962 | #endif | 954 | #endif |
963 | 955 | ||
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp index 151b761..4cf8451 100644 --- a/linden/indra/llrender/llrendertarget.cpp +++ b/linden/indra/llrender/llrendertarget.cpp | |||
@@ -47,10 +47,10 @@ void check_framebuffer_status() | |||
47 | case GL_FRAMEBUFFER_COMPLETE_EXT: | 47 | case GL_FRAMEBUFFER_COMPLETE_EXT: |
48 | break; | 48 | break; |
49 | case GL_FRAMEBUFFER_UNSUPPORTED_EXT: | 49 | case GL_FRAMEBUFFER_UNSUPPORTED_EXT: |
50 | llwarns << "WTF?" << llendl; | 50 | llerrs << "WTF?" << llendl; |
51 | break; | 51 | break; |
52 | default: | 52 | default: |
53 | llwarns << "WTF?" << llendl; | 53 | llerrs << "WTF?" << llendl; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
@@ -139,9 +139,9 @@ void LLRenderTarget::addColorAttachment(U32 color_fmt) | |||
139 | 139 | ||
140 | U32 offset = mTex.size(); | 140 | U32 offset = mTex.size(); |
141 | if (offset >= 4 || | 141 | if (offset >= 4 || |
142 | offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers)) | 142 | (offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers))) |
143 | { | 143 | { |
144 | llwarns << "Too many color attachments!" << llendl; // KL | 144 | llerrs << "Too many color attachments!" << llendl; |
145 | } | 145 | } |
146 | 146 | ||
147 | U32 tex; | 147 | U32 tex; |
@@ -203,7 +203,7 @@ void LLRenderTarget::allocateDepth() | |||
203 | gGL.getTexUnit(0)->bindManual(mUsage, mDepth); | 203 | gGL.getTexUnit(0)->bindManual(mUsage, mDepth); |
204 | U32 internal_type = LLTexUnit::getInternalType(mUsage); | 204 | U32 internal_type = LLTexUnit::getInternalType(mUsage); |
205 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); | 205 | gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); |
206 | LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); | 206 | LLImageGL::setManualImage(internal_type, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
@@ -211,7 +211,7 @@ void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target) | |||
211 | { | 211 | { |
212 | if (!mFBO || !target.mFBO) | 212 | if (!mFBO || !target.mFBO) |
213 | { | 213 | { |
214 | llwarns << "Cannot share depth buffer between non FBO render targets." << llendl; | 214 | llerrs << "Cannot share depth buffer between non FBO render targets." << llendl; |
215 | } | 215 | } |
216 | 216 | ||
217 | if (mDepth) | 217 | if (mDepth) |
@@ -349,16 +349,16 @@ U32 LLRenderTarget::getTexture(U32 attachment) const | |||
349 | { | 349 | { |
350 | if (attachment > mTex.size()-1) | 350 | if (attachment > mTex.size()-1) |
351 | { | 351 | { |
352 | llwarns << "Invalid attachment index [getTexture]." << llendl; // lets not crash KL its a pain in the ass! | 352 | llerrs << "Invalid attachment index." << llendl; |
353 | } | 353 | } |
354 | return mTex[attachment]; | 354 | return mTex[attachment]; |
355 | } | 355 | } |
356 | 356 | ||
357 | void LLRenderTarget::bindTexture(U32 index, S32 channel) | 357 | void LLRenderTarget::bindTexture(U32 index, S32 channel) |
358 | { | 358 | { |
359 | if (index > 6)//mTex.size()-1) // KL yeah i know its a bit arbitary but make the number big enough as some unused render defer elements cause this to go wild | 359 | if (index > mTex.size()-1) |
360 | { | 360 | { |
361 | llwarns << "Invalid attachment index [bindtexture]." << llendl; | 361 | llerrs << "Invalid attachment index." << llendl; |
362 | } | 362 | } |
363 | gGL.getTexUnit(channel)->bindManual(mUsage, mTex[index]); | 363 | gGL.getTexUnit(channel)->bindManual(mUsage, mTex[index]); |
364 | } | 364 | } |
@@ -440,7 +440,7 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, | |||
440 | #if !LL_DARWIN | 440 | #if !LL_DARWIN |
441 | if (!source.mFBO || !mFBO) | 441 | if (!source.mFBO || !mFBO) |
442 | { | 442 | { |
443 | llwarns << "Cannot copy framebuffer contents for non FBO render targets." << llendl; | 443 | llerrs << "Cannot copy framebuffer contents for non FBO render targets." << llendl; |
444 | } | 444 | } |
445 | 445 | ||
446 | if (mSampleBuffer) | 446 | if (mSampleBuffer) |
@@ -449,27 +449,12 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, | |||
449 | } | 449 | } |
450 | else | 450 | else |
451 | { | 451 | { |
452 | if (mask == GL_DEPTH_BUFFER_BIT && source.mStencil != mStencil) | 452 | glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, source.mFBO); |
453 | { | 453 | glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, mFBO); |
454 | source.bindTarget(); | ||
455 | gGL.getTexUnit(0)->bind(this, true); | ||
456 | 454 | ||
457 | glCopyTexSubImage2D(LLTexUnit::getInternalType(mUsage), 0, srcX0, srcY0, dstX0, dstY0, dstX1, dstY1); | 455 | glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
458 | source.flush(); | 456 | |
459 | } | 457 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); |
460 | else | ||
461 | { | ||
462 | glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, source.mFBO); | ||
463 | stop_glerror(); | ||
464 | glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, mFBO); | ||
465 | stop_glerror(); | ||
466 | check_framebuffer_status(); | ||
467 | stop_glerror(); | ||
468 | glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | ||
469 | stop_glerror(); | ||
470 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | ||
471 | stop_glerror(); | ||
472 | } | ||
473 | } | 458 | } |
474 | #endif | 459 | #endif |
475 | } | 460 | } |
@@ -568,14 +553,14 @@ void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth | |||
568 | 553 | ||
569 | if (!gGLManager.mHasFramebufferMultisample) | 554 | if (!gGLManager.mHasFramebufferMultisample) |
570 | { | 555 | { |
571 | llwarns << "Attempting to allocate unsupported render target type!" << llendl; | 556 | llerrs << "Attempting to allocate unsupported render target type!" << llendl; |
572 | } | 557 | } |
573 | 558 | ||
574 | mSamples = samples; | 559 | mSamples = samples; |
575 | 560 | ||
576 | if (mSamples <= 1) | 561 | if (mSamples <= 1) |
577 | { | 562 | { |
578 | llwarns << "Cannot create a multisample buffer with less than 2 samples." << llendl; | 563 | llerrs << "Cannot create a multisample buffer with less than 2 samples." << llendl; |
579 | } | 564 | } |
580 | 565 | ||
581 | stop_glerror(); | 566 | stop_glerror(); |
@@ -623,9 +608,9 @@ void LLMultisampleBuffer::addColorAttachment(U32 color_fmt) | |||
623 | 608 | ||
624 | U32 offset = mTex.size(); | 609 | U32 offset = mTex.size(); |
625 | if (offset >= 4 || | 610 | if (offset >= 4 || |
626 | offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers)) | 611 | (offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers))) |
627 | { | 612 | { |
628 | llwarns << "Too many color attachments!" << llendl; | 613 | llerrs << "Too many color attachments!" << llendl; |
629 | } | 614 | } |
630 | 615 | ||
631 | U32 tex; | 616 | U32 tex; |
@@ -646,10 +631,10 @@ void LLMultisampleBuffer::addColorAttachment(U32 color_fmt) | |||
646 | case GL_FRAMEBUFFER_COMPLETE_EXT: | 631 | case GL_FRAMEBUFFER_COMPLETE_EXT: |
647 | break; | 632 | break; |
648 | case GL_FRAMEBUFFER_UNSUPPORTED_EXT: | 633 | case GL_FRAMEBUFFER_UNSUPPORTED_EXT: |
649 | llwarns << "WTF?" << llendl; | 634 | llerrs << "WTF?" << llendl; |
650 | break; | 635 | break; |
651 | default: | 636 | default: |
652 | llwarns << "WTF?" << llendl; | 637 | llerrs << "WTF?" << llendl; |
653 | } | 638 | } |
654 | 639 | ||
655 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | 640 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); |
diff --git a/linden/indra/llrender/llrendertarget.h b/linden/indra/llrender/llrendertarget.h index 69af1ea..d5d809b 100644 --- a/linden/indra/llrender/llrendertarget.h +++ b/linden/indra/llrender/llrendertarget.h | |||
@@ -121,7 +121,6 @@ public: | |||
121 | U32 getTexture(U32 attachment = 0) const; | 121 | U32 getTexture(U32 attachment = 0) const; |
122 | 122 | ||
123 | U32 getDepth(void) const { return mDepth; } | 123 | U32 getDepth(void) const { return mDepth; } |
124 | BOOL hasStencil() const { return mStencil; } | ||
125 | 124 | ||
126 | void bindTexture(U32 index, S32 channel); | 125 | void bindTexture(U32 index, S32 channel); |
127 | 126 | ||
diff --git a/linden/indra/llrender/lltextureatlas.cpp b/linden/indra/llrender/lltextureatlas.cpp deleted file mode 100644 index c0f5419..0000000 --- a/linden/indra/llrender/lltextureatlas.cpp +++ /dev/null | |||
@@ -1,411 +0,0 @@ | |||
1 | /** | ||
2 | * @file lltextureatlas.cpp | ||
3 | * @brief LLTextureAtlas class implementation. | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2002-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | #include "linden_common.h" | ||
33 | #include "llerror.h" | ||
34 | #include "llimage.h" | ||
35 | #include "llmath.h" | ||
36 | #include "llgl.h" | ||
37 | #include "llrender.h" | ||
38 | #include "lltextureatlas.h" | ||
39 | |||
40 | //------------------- | ||
41 | S16 LLTextureAtlas::sMaxSubTextureSize = 64 ; | ||
42 | S16 LLTextureAtlas::sSlotSize = 32 ; | ||
43 | |||
44 | #ifndef DEBUG_ATLAS | ||
45 | #define DEBUG_ATLAS 0 | ||
46 | #endif | ||
47 | |||
48 | #ifndef DEBUG_USAGE_BITS | ||
49 | #define DEBUG_USAGE_BITS 0 | ||
50 | #endif | ||
51 | //************************************************************************************************************** | ||
52 | LLTextureAtlas::LLTextureAtlas(U8 ncomponents, S16 atlas_dim) : LLImageGL(), | ||
53 | mAtlasDim(atlas_dim) | ||
54 | { | ||
55 | setComponents(ncomponents) ; | ||
56 | |||
57 | mCanAddToAtlas = FALSE ;//do not add one atlas to another. | ||
58 | mNumSlotsReserved = 0 ; | ||
59 | mMaxSlotsInAtlas = mAtlasDim * mAtlasDim ; | ||
60 | |||
61 | generateEmptyUsageBits() ; | ||
62 | |||
63 | //generate an empty texture | ||
64 | S32 dim = mAtlasDim * sSlotSize ; //number of pixels per dimension | ||
65 | LLPointer<LLImageRaw> image_raw = new LLImageRaw(dim, dim, getComponents()); | ||
66 | createGLTexture(0, image_raw, 0); | ||
67 | image_raw = NULL; | ||
68 | dontDiscard(); | ||
69 | } | ||
70 | |||
71 | LLTextureAtlas::~LLTextureAtlas() | ||
72 | { | ||
73 | if(mSpatialGroupList.size() > 0) | ||
74 | { | ||
75 | llwarns << "Not clean up the spatial groups!" << llendl ; | ||
76 | } | ||
77 | releaseUsageBits() ; | ||
78 | } | ||
79 | |||
80 | void LLTextureAtlas::getTexCoordOffset(S16 col, S16 row, F32& xoffset, F32& yoffset) | ||
81 | { | ||
82 | #if !DEBUG_ATLAS | ||
83 | xoffset = (F32)col / mAtlasDim ; | ||
84 | yoffset = (F32)row / mAtlasDim ; | ||
85 | #endif | ||
86 | } | ||
87 | |||
88 | void LLTextureAtlas::getTexCoordScale(S32 w, S32 h, F32& xscale, F32& yscale) | ||
89 | { | ||
90 | #if !DEBUG_ATLAS | ||
91 | xscale = (F32)w / (mAtlasDim * sSlotSize) ; | ||
92 | yscale = (F32)h / (mAtlasDim * sSlotSize) ; | ||
93 | #endif | ||
94 | } | ||
95 | |||
96 | //insert a texture piece into the atlas | ||
97 | LLGLuint LLTextureAtlas::insertSubTexture(const LLImageRaw* raw_image, S16 slot_col, S16 slot_row) | ||
98 | { | ||
99 | S32 w = raw_image->getWidth() ; | ||
100 | S32 h = raw_image->getHeight() ; | ||
101 | if(w < 8 || w > sMaxSubTextureSize || h < 8 || h > sMaxSubTextureSize) | ||
102 | { | ||
103 | //size overflow | ||
104 | return 0 ; | ||
105 | } | ||
106 | |||
107 | BOOL res = gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, getTexName()); | ||
108 | if (!res) llwarns << "bindTexture failed" << llendl; | ||
109 | stop_glerror(); | ||
110 | |||
111 | GLint xoffset = sSlotSize * slot_col ; | ||
112 | GLint yoffset = sSlotSize * slot_row ; | ||
113 | |||
114 | glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, TRUE); | ||
115 | glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, | ||
116 | w, h, mFormatPrimary, mFormatType, raw_image->getData()); | ||
117 | |||
118 | return getTexName(); | ||
119 | } | ||
120 | |||
121 | //release a sub-texture slot from the atlas | ||
122 | void LLTextureAtlas::releaseSlot(S16 slot_col, S16 slot_row, S8 slot_width) | ||
123 | { | ||
124 | unmarkUsageBits(slot_width, slot_col, slot_row) ; | ||
125 | mNumSlotsReserved -= slot_width * slot_width ; | ||
126 | } | ||
127 | |||
128 | BOOL LLTextureAtlas::isEmpty() const | ||
129 | { | ||
130 | return !mNumSlotsReserved ; | ||
131 | } | ||
132 | |||
133 | BOOL LLTextureAtlas::isFull(S8 to_be_reserved) const | ||
134 | { | ||
135 | return mNumSlotsReserved + to_be_reserved > mMaxSlotsInAtlas ; | ||
136 | } | ||
137 | F32 LLTextureAtlas::getFullness() const | ||
138 | { | ||
139 | return (F32)mNumSlotsReserved / mMaxSlotsInAtlas ; | ||
140 | } | ||
141 | |||
142 | void LLTextureAtlas::addSpatialGroup(LLSpatialGroup* groupp) | ||
143 | { | ||
144 | if(groupp && !hasSpatialGroup(groupp)) | ||
145 | { | ||
146 | mSpatialGroupList.push_back(groupp); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | void LLTextureAtlas::removeSpatialGroup(LLSpatialGroup* groupp) | ||
151 | { | ||
152 | if(groupp) | ||
153 | { | ||
154 | mSpatialGroupList.remove(groupp); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | void LLTextureAtlas::clearSpatialGroup() | ||
159 | { | ||
160 | mSpatialGroupList.clear(); | ||
161 | } | ||
162 | void LLTextureAtlas::removeLastSpatialGroup() | ||
163 | { | ||
164 | mSpatialGroupList.pop_back() ; | ||
165 | } | ||
166 | |||
167 | LLSpatialGroup* LLTextureAtlas::getLastSpatialGroup() | ||
168 | { | ||
169 | if(mSpatialGroupList.size() > 0) | ||
170 | { | ||
171 | return mSpatialGroupList.back() ; | ||
172 | } | ||
173 | return NULL ; | ||
174 | } | ||
175 | |||
176 | BOOL LLTextureAtlas::hasSpatialGroup(LLSpatialGroup* groupp) | ||
177 | { | ||
178 | for(std::list<LLSpatialGroup*>::iterator iter = mSpatialGroupList.begin(); iter != mSpatialGroupList.end() ; ++iter) | ||
179 | { | ||
180 | if(*iter == groupp) | ||
181 | { | ||
182 | return TRUE ; | ||
183 | } | ||
184 | } | ||
185 | return FALSE ; | ||
186 | } | ||
187 | |||
188 | //-------------------------------------------------------------------------------------- | ||
189 | //private | ||
190 | void LLTextureAtlas::generateEmptyUsageBits() | ||
191 | { | ||
192 | S32 col_len = (mAtlasDim + 7) >> 3 ; | ||
193 | mUsageBits = new U8*[mAtlasDim] ; | ||
194 | *mUsageBits = new U8[mAtlasDim * col_len] ; | ||
195 | |||
196 | mUsageBits[0] = *mUsageBits ; | ||
197 | for(S32 i = 1 ; i < mAtlasDim ; i++) | ||
198 | { | ||
199 | mUsageBits[i] = mUsageBits[i-1] + col_len ; | ||
200 | |||
201 | for(S32 j = 0 ; j < col_len ; j++) | ||
202 | { | ||
203 | //init by 0 for all bits. | ||
204 | mUsageBits[i][j] = 0 ; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | //do not forget mUsageBits[0]! | ||
209 | for(S32 j = 0 ; j < col_len ; j++) | ||
210 | { | ||
211 | //init by 0 for all bits. | ||
212 | mUsageBits[0][j] = 0 ; | ||
213 | } | ||
214 | |||
215 | mTestBits = NULL ; | ||
216 | #if DEBUG_USAGE_BITS | ||
217 | //------------ | ||
218 | //test | ||
219 | mTestBits = new U8*[mAtlasDim] ; | ||
220 | *mTestBits = new U8[mAtlasDim * mAtlasDim] ; | ||
221 | mTestBits[0] = *mTestBits ; | ||
222 | for(S32 i = 1 ; i < mAtlasDim ; i++) | ||
223 | { | ||
224 | mTestBits[i] = mTestBits[i-1] + mAtlasDim ; | ||
225 | |||
226 | for(S32 j = 0 ; j < mAtlasDim ; j++) | ||
227 | { | ||
228 | //init by 0 for all bits. | ||
229 | mTestBits[i][j] = 0 ; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | for(S32 j = 0 ; j < mAtlasDim ; j++) | ||
234 | { | ||
235 | //init by 0 for all bits. | ||
236 | mTestBits[0][j] = 0 ; | ||
237 | } | ||
238 | #endif | ||
239 | } | ||
240 | |||
241 | void LLTextureAtlas::releaseUsageBits() | ||
242 | { | ||
243 | if(mUsageBits) | ||
244 | { | ||
245 | delete[] *mUsageBits ; | ||
246 | delete[] mUsageBits ; | ||
247 | } | ||
248 | mUsageBits = NULL ; | ||
249 | |||
250 | //test | ||
251 | if( mTestBits) | ||
252 | { | ||
253 | delete[] *mTestBits; | ||
254 | delete[] mTestBits; | ||
255 | } | ||
256 | mTestBits = NULL ; | ||
257 | } | ||
258 | |||
259 | void LLTextureAtlas::markUsageBits(S8 bits_len, U8 mask, S16 col, S16 row) | ||
260 | { | ||
261 | S16 x = col >> 3 ; | ||
262 | |||
263 | for(S8 i = 0 ; i < bits_len ; i++) | ||
264 | { | ||
265 | mUsageBits[row + i][x] |= mask ; | ||
266 | } | ||
267 | |||
268 | #if DEBUG_USAGE_BITS | ||
269 | //test | ||
270 | for(S8 i = row ; i < row + bits_len ; i++) | ||
271 | { | ||
272 | for(S8 j = col ; j < col + bits_len ; j++) | ||
273 | { | ||
274 | mTestBits[i][j] = 1 ; | ||
275 | } | ||
276 | } | ||
277 | #endif | ||
278 | } | ||
279 | |||
280 | void LLTextureAtlas::unmarkUsageBits(S8 bits_len, S16 col, S16 row) | ||
281 | { | ||
282 | S16 x = col >> 3 ; | ||
283 | U8 mask = 1 ; | ||
284 | for(S8 i = 1 ; i < bits_len ; i++) | ||
285 | { | ||
286 | mask |= (1 << i) ; | ||
287 | } | ||
288 | mask <<= (col & 7) ; | ||
289 | mask = ~mask ; | ||
290 | |||
291 | for(S8 i = 0 ; i < bits_len ; i++) | ||
292 | { | ||
293 | mUsageBits[row + i][x] &= mask ; | ||
294 | } | ||
295 | |||
296 | #if DEBUG_USAGE_BITS | ||
297 | //test | ||
298 | for(S8 i = row ; i < row + bits_len ; i++) | ||
299 | { | ||
300 | for(S8 j = col ; j < col + bits_len ; j++) | ||
301 | { | ||
302 | mTestBits[i][j] = 0 ; | ||
303 | } | ||
304 | } | ||
305 | #endif | ||
306 | } | ||
307 | |||
308 | //return true if any of bits in the range marked. | ||
309 | BOOL LLTextureAtlas::areUsageBitsMarked(S8 bits_len, U8 mask, S16 col, S16 row) | ||
310 | { | ||
311 | BOOL ret = FALSE ; | ||
312 | S16 x = col >> 3 ; | ||
313 | |||
314 | for(S8 i = 0 ; i < bits_len ; i++) | ||
315 | { | ||
316 | if(mUsageBits[row + i][x] & mask) | ||
317 | { | ||
318 | ret = TRUE ; | ||
319 | break ; | ||
320 | //return TRUE ; | ||
321 | } | ||
322 | } | ||
323 | |||
324 | #if DEBUG_USAGE_BITS | ||
325 | //test | ||
326 | BOOL ret2 = FALSE ; | ||
327 | for(S8 i = row ; i < row + bits_len ; i++) | ||
328 | { | ||
329 | for(S8 j = col ; j < col + bits_len ; j++) | ||
330 | { | ||
331 | if(mTestBits[i][j]) | ||
332 | { | ||
333 | ret2 = TRUE ; | ||
334 | } | ||
335 | } | ||
336 | } | ||
337 | |||
338 | if(ret != ret2) | ||
339 | { | ||
340 | llwarns << "bits map corrupted." << llendl ; | ||
341 | } | ||
342 | #endif | ||
343 | return ret ;//FALSE ; | ||
344 | } | ||
345 | |||
346 | //---------------------------------------------------------------------- | ||
347 | // | ||
348 | //index order: Z order, i.e.: | ||
349 | // |-----|-----|-----|-----| | ||
350 | // | 10 | 11 | 14 | 15 | | ||
351 | // |-----|-----|-----|-----| | ||
352 | // | 8 | 9 | 12 | 13 | | ||
353 | // |-----|-----|-----|-----| | ||
354 | // | 2 | 3 | 6 | 7 | | ||
355 | // |-----|-----|-----|-----| | ||
356 | // | 0 | 1 | 4 | 5 | | ||
357 | // |-----|-----|-----|-----| | ||
358 | void LLTextureAtlas::getPositionFromIndex(S16 index, S16& col, S16& row) | ||
359 | { | ||
360 | col = 0 ; | ||
361 | row = 0 ; | ||
362 | |||
363 | S16 index_copy = index ; | ||
364 | for(S16 i = 0 ; index_copy && i < 16 ; i += 2) | ||
365 | { | ||
366 | col |= ((index & (1 << i)) >> i) << (i >> 1) ; | ||
367 | row |= ((index & (1 << (i + 1))) >> (i + 1)) << (i >> 1) ; | ||
368 | index_copy >>= 2 ; | ||
369 | } | ||
370 | } | ||
371 | void LLTextureAtlas::getIndexFromPosition(S16 col, S16 row, S16& index) | ||
372 | { | ||
373 | index = 0 ; | ||
374 | S16 col_copy = col ; | ||
375 | S16 row_copy = row ; | ||
376 | for(S16 i = 0 ; (col_copy || row_copy) && i < 16 ; i++) | ||
377 | { | ||
378 | index |= ((col & 1 << i) << i) | ((row & 1 << i) << ( i + 1)) ; | ||
379 | col_copy >>= 1 ; | ||
380 | row_copy >>= 1 ; | ||
381 | } | ||
382 | } | ||
383 | //---------------------------------------------------------------------- | ||
384 | //return TRUE if succeeds. | ||
385 | BOOL LLTextureAtlas::getNextAvailableSlot(S8 bits_len, S16& col, S16& row) | ||
386 | { | ||
387 | S16 index_step = bits_len * bits_len ; | ||
388 | |||
389 | U8 mask = 1 ; | ||
390 | for(S8 i = 1 ; i < bits_len ; i++) | ||
391 | { | ||
392 | mask |= (1 << i) ; | ||
393 | } | ||
394 | |||
395 | U8 cur_mask ; | ||
396 | for(S16 index = 0 ; index < mMaxSlotsInAtlas ; index += index_step) | ||
397 | { | ||
398 | getPositionFromIndex(index, col, row) ; | ||
399 | |||
400 | cur_mask = mask << (col & 7) ; | ||
401 | if(!areUsageBitsMarked(bits_len, cur_mask, col, row)) | ||
402 | { | ||
403 | markUsageBits(bits_len, cur_mask, col, row) ; | ||
404 | mNumSlotsReserved += bits_len * bits_len ; | ||
405 | |||
406 | return TRUE ; | ||
407 | } | ||
408 | } | ||
409 | |||
410 | return FALSE ; | ||
411 | } | ||
diff --git a/linden/indra/llrender/lltextureatlas.h b/linden/indra/llrender/lltextureatlas.h deleted file mode 100644 index 4922175..0000000 --- a/linden/indra/llrender/lltextureatlas.h +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | /** | ||
2 | * @file lltextureatlas.h | ||
3 | * @brief LLTextureAtlas base class. | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2002-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | |||
34 | #ifndef LL_TEXTUREATLAS_H | ||
35 | #define LL_TEXTUREATLAS_H | ||
36 | |||
37 | #include "llimagegl.h" | ||
38 | class LLSpatialGroup ; | ||
39 | |||
40 | class LLTextureAtlas : public LLImageGL | ||
41 | { | ||
42 | public: | ||
43 | LLTextureAtlas(U8 ncomponents, S16 atlas_dim = 16) ; | ||
44 | ~LLTextureAtlas() ; | ||
45 | |||
46 | LLGLuint insertSubTexture(const LLImageRaw* raw_image, S16 slot_col, S16 slot_row) ; | ||
47 | void releaseSlot(S16 slot_col, S16 slot_row, S8 slot_width); | ||
48 | |||
49 | BOOL getNextAvailableSlot(S8 bits_len, S16& col, S16& row) ; | ||
50 | void getTexCoordOffset(S16 col, S16 row, F32& xoffset, F32& yOffset) ; | ||
51 | void getTexCoordScale(S32 w, S32 h, F32& xscale, F32& yscale) ; | ||
52 | |||
53 | BOOL isEmpty() const ; | ||
54 | BOOL isFull(S8 to_be_reserved = 1) const ; | ||
55 | F32 getFullness() const ; | ||
56 | |||
57 | void addSpatialGroup(LLSpatialGroup* groupp) ; | ||
58 | void removeSpatialGroup(LLSpatialGroup* groupp) ; | ||
59 | LLSpatialGroup* getLastSpatialGroup() ; | ||
60 | void removeLastSpatialGroup() ; | ||
61 | BOOL hasSpatialGroup(LLSpatialGroup* groupp) ; | ||
62 | void clearSpatialGroup() ; | ||
63 | std::list<LLSpatialGroup*>* getSpatialGroupList() {return &mSpatialGroupList;} | ||
64 | private: | ||
65 | void generateEmptyUsageBits() ; | ||
66 | void releaseUsageBits() ; | ||
67 | |||
68 | void markUsageBits(S8 bits_len, U8 mask, S16 col, S16 row) ; | ||
69 | void unmarkUsageBits(S8 bits_len, S16 col, S16 row) ; | ||
70 | |||
71 | void getPositionFromIndex(S16 index, S16& col, S16& row) ; | ||
72 | void getIndexFromPosition(S16 col, S16 row, S16& index) ; | ||
73 | BOOL areUsageBitsMarked(S8 bits_len, U8 mask, S16 col, S16 row) ; | ||
74 | |||
75 | private: | ||
76 | S16 mAtlasDim ; //number of slots per edge, i.e, there are "mAtlasDim * mAtlasDim" total slots in the atlas. | ||
77 | S16 mNumSlotsReserved ; | ||
78 | S16 mMaxSlotsInAtlas ; | ||
79 | U8 **mUsageBits ; | ||
80 | std::list<LLSpatialGroup*> mSpatialGroupList ; | ||
81 | |||
82 | public: | ||
83 | //debug use only | ||
84 | U8 **mTestBits ; | ||
85 | |||
86 | public: | ||
87 | static S16 sMaxSubTextureSize ; | ||
88 | static S16 sSlotSize ; | ||
89 | }; | ||
90 | |||
91 | #endif | ||
92 | |||
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp index 31c2d75..461edbe 100644 --- a/linden/indra/llrender/llvertexbuffer.cpp +++ b/linden/indra/llrender/llvertexbuffer.cpp | |||
@@ -96,7 +96,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) | |||
96 | { | 96 | { |
97 | /*if (LLGLImmediate::sStarted) | 97 | /*if (LLGLImmediate::sStarted) |
98 | { | 98 | { |
99 | llwarns << "Cannot use LLGLImmediate and LLVertexBuffer simultaneously!" << llendl; | 99 | llerrs << "Cannot use LLGLImmediate and LLVertexBuffer simultaneously!" << llendl; |
100 | }*/ | 100 | }*/ |
101 | 101 | ||
102 | if (sLastMask != data_mask) | 102 | if (sLastMask != data_mask) |
@@ -129,7 +129,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) | |||
129 | { //needs to be enabled, make sure it was (DEBUG TEMPORARY) | 129 | { //needs to be enabled, make sure it was (DEBUG TEMPORARY) |
130 | if (i > 0 && !glIsEnabled(array[i])) | 130 | if (i > 0 && !glIsEnabled(array[i])) |
131 | { | 131 | { |
132 | llwarns << "Bad client state! " << array[i] << " disabled." << llendl; | 132 | llerrs << "Bad client state! " << array[i] << " disabled." << llendl; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
@@ -141,7 +141,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) | |||
141 | } | 141 | } |
142 | else if (gDebugGL && glIsEnabled(array[i])) | 142 | else if (gDebugGL && glIsEnabled(array[i])) |
143 | { //needs to be disabled, make sure it was (DEBUG TEMPORARY) | 143 | { //needs to be disabled, make sure it was (DEBUG TEMPORARY) |
144 | llwarns << "Bad client state! " << array[i] << " enabled." << llendl; | 144 | llerrs << "Bad client state! " << array[i] << " enabled." << llendl; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | } | 147 | } |
@@ -197,28 +197,28 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi | |||
197 | if (start >= (U32) mRequestedNumVerts || | 197 | if (start >= (U32) mRequestedNumVerts || |
198 | end >= (U32) mRequestedNumVerts) | 198 | end >= (U32) mRequestedNumVerts) |
199 | { | 199 | { |
200 | llwarns << "Bad vertex buffer draw range: [" << start << ", " << end << "]" << llendl; | 200 | llerrs << "Bad vertex buffer draw range: [" << start << ", " << end << "]" << llendl; |
201 | } | 201 | } |
202 | 202 | ||
203 | if (indices_offset >= (U32) mRequestedNumIndices || | 203 | if (indices_offset >= (U32) mRequestedNumIndices || |
204 | indices_offset + count > (U32) mRequestedNumIndices) | 204 | indices_offset + count > (U32) mRequestedNumIndices) |
205 | { | 205 | { |
206 | llwarns << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; | 206 | llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; |
207 | } | 207 | } |
208 | 208 | ||
209 | if (mGLIndices != sGLRenderIndices) | 209 | if (mGLIndices != sGLRenderIndices) |
210 | { | 210 | { |
211 | llwarns << "Wrong index buffer bound." << llendl; | 211 | llerrs << "Wrong index buffer bound." << llendl; |
212 | } | 212 | } |
213 | 213 | ||
214 | if (mGLBuffer != sGLRenderBuffer) | 214 | if (mGLBuffer != sGLRenderBuffer) |
215 | { | 215 | { |
216 | llwarns << "Wrong vertex buffer bound." << llendl; | 216 | llerrs << "Wrong vertex buffer bound." << llendl; |
217 | } | 217 | } |
218 | 218 | ||
219 | if (mode > LLRender::NUM_MODES) | 219 | if (mode > LLRender::NUM_MODES) |
220 | { | 220 | { |
221 | llwarns << "Invalid draw mode: " << mode << llendl; | 221 | llerrs << "Invalid draw mode: " << mode << llendl; |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | 224 | ||
@@ -233,22 +233,22 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const | |||
233 | if (indices_offset >= (U32) mRequestedNumIndices || | 233 | if (indices_offset >= (U32) mRequestedNumIndices || |
234 | indices_offset + count > (U32) mRequestedNumIndices) | 234 | indices_offset + count > (U32) mRequestedNumIndices) |
235 | { | 235 | { |
236 | llwarns << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; | 236 | llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; |
237 | } | 237 | } |
238 | 238 | ||
239 | if (mGLIndices != sGLRenderIndices) | 239 | if (mGLIndices != sGLRenderIndices) |
240 | { | 240 | { |
241 | llwarns << "Wrong index buffer bound." << llendl; | 241 | llerrs << "Wrong index buffer bound." << llendl; |
242 | } | 242 | } |
243 | 243 | ||
244 | if (mGLBuffer != sGLRenderBuffer) | 244 | if (mGLBuffer != sGLRenderBuffer) |
245 | { | 245 | { |
246 | llwarns << "Wrong vertex buffer bound." << llendl; | 246 | llerrs << "Wrong vertex buffer bound." << llendl; |
247 | } | 247 | } |
248 | 248 | ||
249 | if (mode > LLRender::NUM_MODES) | 249 | if (mode > LLRender::NUM_MODES) |
250 | { | 250 | { |
251 | llwarns << "Invalid draw mode: " << mode << llendl; | 251 | llerrs << "Invalid draw mode: " << mode << llendl; |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | 254 | ||
@@ -263,17 +263,17 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const | |||
263 | if (first >= (U32) mRequestedNumVerts || | 263 | if (first >= (U32) mRequestedNumVerts || |
264 | first + count > (U32) mRequestedNumVerts) | 264 | first + count > (U32) mRequestedNumVerts) |
265 | { | 265 | { |
266 | llwarns << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << llendl; | 266 | llerrs << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << llendl; |
267 | } | 267 | } |
268 | 268 | ||
269 | if (mGLBuffer != sGLRenderBuffer || useVBOs() != sVBOActive) | 269 | if (mGLBuffer != sGLRenderBuffer || useVBOs() != sVBOActive) |
270 | { | 270 | { |
271 | llwarns << "Wrong vertex buffer bound." << llendl; | 271 | llerrs << "Wrong vertex buffer bound." << llendl; |
272 | } | 272 | } |
273 | 273 | ||
274 | if (mode > LLRender::NUM_MODES) | 274 | if (mode > LLRender::NUM_MODES) |
275 | { | 275 | { |
276 | llwarns << "Invalid draw mode: " << mode << llendl; | 276 | llerrs << "Invalid draw mode: " << mode << llendl; |
277 | return; | 277 | return; |
278 | } | 278 | } |
279 | 279 | ||
@@ -530,7 +530,7 @@ void LLVertexBuffer::destroyGLBuffer() | |||
530 | { | 530 | { |
531 | if (mMappedData || mMappedIndexData) | 531 | if (mMappedData || mMappedIndexData) |
532 | { | 532 | { |
533 | llwarns << "Vertex buffer destroyed while mapped!" << llendl; | 533 | llerrs << "Vertex buffer destroyed while mapped!" << llendl; |
534 | } | 534 | } |
535 | releaseBuffer(); | 535 | releaseBuffer(); |
536 | } | 536 | } |
@@ -557,7 +557,7 @@ void LLVertexBuffer::destroyGLIndices() | |||
557 | { | 557 | { |
558 | if (mMappedData || mMappedIndexData) | 558 | if (mMappedData || mMappedIndexData) |
559 | { | 559 | { |
560 | llwarns << "Vertex buffer destroyed while mapped." << llendl; | 560 | llerrs << "Vertex buffer destroyed while mapped." << llendl; |
561 | } | 561 | } |
562 | releaseIndices(); | 562 | releaseIndices(); |
563 | } | 563 | } |
@@ -634,7 +634,7 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) | |||
634 | 634 | ||
635 | if (mMappedData) | 635 | if (mMappedData) |
636 | { | 636 | { |
637 | llwarns << "LLVertexBuffer::allocateBuffer() called redundantly." << llendl; | 637 | llerrs << "LLVertexBuffer::allocateBuffer() called redundantly." << llendl; |
638 | } | 638 | } |
639 | if (create && (nverts || nindices)) | 639 | if (create && (nverts || nindices)) |
640 | { | 640 | { |
@@ -782,11 +782,11 @@ U8* LLVertexBuffer::mapBuffer(S32 access) | |||
782 | LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); | 782 | LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); |
783 | if (mFinal) | 783 | if (mFinal) |
784 | { | 784 | { |
785 | llwarns << "LLVertexBuffer::mapBuffer() called on a finalized buffer." << llendl; | 785 | llerrs << "LLVertexBuffer::mapBuffer() called on a finalized buffer." << llendl; |
786 | } | 786 | } |
787 | if (!useVBOs() && !mMappedData && !mMappedIndexData) | 787 | if (!useVBOs() && !mMappedData && !mMappedIndexData) |
788 | { | 788 | { |
789 | llwarns << "LLVertexBuffer::mapBuffer() called on unallocated buffer." << llendl; | 789 | llerrs << "LLVertexBuffer::mapBuffer() called on unallocated buffer." << llendl; |
790 | } | 790 | } |
791 | 791 | ||
792 | if (!mLocked && useVBOs()) | 792 | if (!mLocked && useVBOs()) |
@@ -813,11 +813,11 @@ U8* LLVertexBuffer::mapBuffer(S32 access) | |||
813 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); | 813 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); |
814 | if (buff != mGLBuffer) | 814 | if (buff != mGLBuffer) |
815 | { | 815 | { |
816 | llwarns << "Invalid GL vertex buffer bound: " << buff << llendl; | 816 | llerrs << "Invalid GL vertex buffer bound: " << buff << llendl; |
817 | } | 817 | } |
818 | 818 | ||
819 | 819 | ||
820 | llwarns << "glMapBuffer returned NULL (no vertex data)" << llendl; | 820 | llerrs << "glMapBuffer returned NULL (no vertex data)" << llendl; |
821 | } | 821 | } |
822 | 822 | ||
823 | if (!mMappedIndexData) | 823 | if (!mMappedIndexData) |
@@ -826,10 +826,10 @@ U8* LLVertexBuffer::mapBuffer(S32 access) | |||
826 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); | 826 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); |
827 | if (buff != mGLIndices) | 827 | if (buff != mGLIndices) |
828 | { | 828 | { |
829 | llwarns << "Invalid GL index buffer bound: " << buff << llendl; | 829 | llerrs << "Invalid GL index buffer bound: " << buff << llendl; |
830 | } | 830 | } |
831 | 831 | ||
832 | llwarns << "glMapBuffer returned NULL (no index data)" << llendl; | 832 | llerrs << "glMapBuffer returned NULL (no index data)" << llendl; |
833 | } | 833 | } |
834 | 834 | ||
835 | sMappedCount++; | 835 | sMappedCount++; |
@@ -908,7 +908,7 @@ template <class T,S32 type> struct VertexBufferStrider | |||
908 | } | 908 | } |
909 | else | 909 | else |
910 | { | 910 | { |
911 | llwarns << "VertexBufferStrider could not find valid vertex data." << llendl; | 911 | llerrs << "VertexBufferStrider could not find valid vertex data." << llendl; |
912 | } | 912 | } |
913 | return FALSE; | 913 | return FALSE; |
914 | } | 914 | } |
@@ -965,7 +965,7 @@ void LLVertexBuffer::setStride(S32 type, S32 new_stride) | |||
965 | LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); | 965 | LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); |
966 | if (mNumVerts) | 966 | if (mNumVerts) |
967 | { | 967 | { |
968 | llwarns << "LLVertexBuffer::setOffset called with mNumVerts = " << mNumVerts << llendl; | 968 | llerrs << "LLVertexBuffer::setOffset called with mNumVerts = " << mNumVerts << llendl; |
969 | } | 969 | } |
970 | // This code assumes that setStride() will only be called once per VBO per type. | 970 | // This code assumes that setStride() will only be called once per VBO per type. |
971 | S32 delta = new_stride - sTypeOffsets[type]; | 971 | S32 delta = new_stride - sTypeOffsets[type]; |
@@ -1020,15 +1020,15 @@ void LLVertexBuffer::setBuffer(U32 data_mask) | |||
1020 | { | 1020 | { |
1021 | GLint buff; | 1021 | GLint buff; |
1022 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); | 1022 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); |
1023 | if ((GLuint)buff != mGLBuffer) | 1023 | if (buff != mGLBuffer) |
1024 | { | 1024 | { |
1025 | llwarns << "Invalid GL vertex buffer bound: " << buff << llendl; | 1025 | llerrs << "Invalid GL vertex buffer bound: " << buff << llendl; |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); | 1028 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); |
1029 | if ((GLuint)buff != mGLIndices) | 1029 | if (buff != mGLIndices) |
1030 | { | 1030 | { |
1031 | llwarns << "Invalid GL index buffer bound: " << buff << llendl; | 1031 | llerrs << "Invalid GL index buffer bound: " << buff << llendl; |
1032 | } | 1032 | } |
1033 | } | 1033 | } |
1034 | 1034 | ||
@@ -1038,15 +1038,15 @@ void LLVertexBuffer::setBuffer(U32 data_mask) | |||
1038 | { | 1038 | { |
1039 | GLint buff; | 1039 | GLint buff; |
1040 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); | 1040 | glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); |
1041 | if ((GLuint)buff != mGLBuffer) | 1041 | if (buff != mGLBuffer) |
1042 | { | 1042 | { |
1043 | llwarns << "Invalid GL vertex buffer bound: " << buff << llendl; | 1043 | llerrs << "Invalid GL vertex buffer bound: " << buff << llendl; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); | 1046 | glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); |
1047 | if ((GLuint)buff != mGLIndices) | 1047 | if (buff != mGLIndices) |
1048 | { | 1048 | { |
1049 | llwarns << "Invalid GL index buffer bound: " << buff << llendl; | 1049 | llerrs << "Invalid GL index buffer bound: " << buff << llendl; |
1050 | } | 1050 | } |
1051 | } | 1051 | } |
1052 | 1052 | ||
@@ -1068,7 +1068,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) | |||
1068 | 1068 | ||
1069 | if (data_mask != 0) | 1069 | if (data_mask != 0) |
1070 | { | 1070 | { |
1071 | llwarns << "Buffer set for rendering before being filled after resize." << llendl; | 1071 | llerrs << "Buffer set for rendering before being filled after resize." << llendl; |
1072 | } | 1072 | } |
1073 | } | 1073 | } |
1074 | 1074 | ||
@@ -1129,7 +1129,7 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const | |||
1129 | 1129 | ||
1130 | if ((data_mask & mTypeMask) != data_mask) | 1130 | if ((data_mask & mTypeMask) != data_mask) |
1131 | { | 1131 | { |
1132 | llwarns << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl; | 1132 | llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | if (data_mask & MAP_NORMAL) | 1135 | if (data_mask & MAP_NORMAL) |