diff options
author | Merov Linden <merov@lindenlab.com> | 2014-05-30 14:19:53 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2014-05-30 14:19:53 -0700 |
commit | 68b62747edb7073dd3f4975e2b38388ae80d801c (patch) | |
tree | 73730fdc31d3d74a2ba69ad156217299115cd810 /indra/llrender | |
parent | a1afe50feb1c42cc21c7f89b4187a8f7abe0c9fc (diff) | |
parent | 644ca6a0f8a7759119814f88df93b8e838321a12 (diff) |
Pull merge from lindenlab/viewer-release
Diffstat (limited to 'indra/llrender')
27 files changed, 744 insertions, 639 deletions
diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index 45a3b18179..af4e3fdda0 100755 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp @@ -100,7 +100,7 @@ void LLCubeMap::initGL() } else { - llwarns << "Using cube map without extension!" << llendl; + LL_WARNS() << "Using cube map without extension!" << LL_ENDL; } } diff --git a/indra/llrender/llfontbitmapcache.cpp b/indra/llrender/llfontbitmapcache.cpp index c985f6b959..f128636ab2 100755 --- a/indra/llrender/llfontbitmapcache.cpp +++ b/indra/llrender/llfontbitmapcache.cpp @@ -29,7 +29,8 @@ #include "llgl.h" #include "llfontbitmapcache.h" -LLFontBitmapCache::LLFontBitmapCache(): +LLFontBitmapCache::LLFontBitmapCache() +: LLTrace::MemTrackable<LLFontBitmapCache>("LLFontBitmapCache"), mNumComponents(0), mBitmapWidth(0), mBitmapHeight(0), @@ -81,6 +82,7 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm { // We're out of space in the current image, or no image // has been allocated yet. Make a new one. + mImageRawVec.push_back(new LLImageRaw); mBitmapNum = mImageRawVec.size()-1; LLImageRaw *image_raw = getImageRaw(mBitmapNum); @@ -122,6 +124,9 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm image_gl->createGLTexture(0, image_raw); gGL.getTexUnit(0)->bind(image_gl); image_gl->setFilteringOption(LLTexUnit::TFO_POINT); // was setMipFilterNearest(TRUE, TRUE); + + claimMem(image_raw); + claimMem(image_gl); } else { @@ -151,7 +156,20 @@ void LLFontBitmapCache::destroyGL() void LLFontBitmapCache::reset() { + for (std::vector<LLPointer<LLImageRaw> >::iterator it = mImageRawVec.begin(), end_it = mImageRawVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageRawVec.clear(); + + for (std::vector<LLPointer<LLImageGL> >::iterator it = mImageGLVec.begin(), end_it = mImageGLVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageGLVec.clear(); mBitmapWidth = 0; diff --git a/indra/llrender/llfontbitmapcache.h b/indra/llrender/llfontbitmapcache.h index c93b0c7320..75df3a94a7 100755 --- a/indra/llrender/llfontbitmapcache.h +++ b/indra/llrender/llfontbitmapcache.h @@ -28,10 +28,11 @@ #define LL_LLFONTBITMAPCACHE_H #include <vector> +#include "lltrace.h" // Maintain a collection of bitmaps containing rendered glyphs. // Generalizes the single-bitmap logic from LLFontFreetype and LLFontGL. -class LLFontBitmapCache: public LLRefCount +class LLFontBitmapCache : public LLTrace::MemTrackable<LLFontBitmapCache> { public: LLFontBitmapCache(); diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 84c782e958..25b1c533c1 100755 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -75,7 +75,7 @@ LLFontManager::LLFontManager() if (error) { // Clean up freetype libs. - llerrs << "Freetype initialization failure!" << llendl; + LL_ERRS() << "Freetype initialization failure!" << LL_ENDL; FT_Done_FreeType(gFTLibrary); } } @@ -101,7 +101,8 @@ LLFontGlyphInfo::LLFontGlyphInfo(U32 index) } LLFontFreetype::LLFontFreetype() -: mFontBitmapCachep(new LLFontBitmapCache), +: LLTrace::MemTrackable<LLFontFreetype>("LLFontFreetype"), + mFontBitmapCachep(new LLFontBitmapCache), mValid(FALSE), mAscender(0.f), mDescender(0.f), @@ -127,7 +128,7 @@ LLFontFreetype::~LLFontFreetype() std::for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); mCharGlyphInfoMap.clear(); - // mFontBitmapCachep will be cleaned up by LLPointer destructor. + delete mFontBitmapCachep; // mFallbackFonts cleaned up by LLPointer destructor } @@ -187,10 +188,12 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v S32 max_char_height = llround(0.5f + (y_max - y_min)); mFontBitmapCachep->init(components, max_char_width, max_char_height); + claimMem(mFontBitmapCachep); + if (!mFTFace->charmap) { - //llinfos << " no unicode encoding, set whatever encoding there is..." << llendl; + //LL_INFOS() << " no unicode encoding, set whatever encoding there is..." << LL_ENDL; FT_Set_Charmap(mFTFace, mFTFace->charmaps[0]); } @@ -201,6 +204,7 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v } mName = filename; + claimMem(mName); mPointSize = point_size; mStyle = LLFontGL::NORMAL; @@ -322,7 +326,7 @@ LLFontGlyphInfo* LLFontFreetype::addGlyph(llwchar wch) const return FALSE; llassert(!mIsFallback); - //lldebugs << "Adding new glyph for " << wch << " to font" << llendl; + //LL_DEBUGS() << "Adding new glyph for " << wch << " to font" << LL_ENDL; FT_UInt glyph_index; @@ -330,7 +334,7 @@ LLFontGlyphInfo* LLFontFreetype::addGlyph(llwchar wch) const glyph_index = FT_Get_Char_Index(mFTFace, wch); if (glyph_index == 0) { - //llinfos << "Trying to add glyph from fallback font!" << llendl; + //LL_INFOS() << "Trying to add glyph from fallback font!" << LL_ENDL; font_vector_t::const_iterator iter; for(iter = mFallbackFonts.begin(); iter != mFallbackFonts.end(); iter++) { @@ -477,6 +481,7 @@ void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const } else { + claimMem(gi); mCharGlyphInfoMap[wch] = gi; } } @@ -502,7 +507,7 @@ void LLFontFreetype::reset(F32 vert_dpi, F32 horz_dpi) // This is the head of the list - need to rebuild ourself and all fallbacks. if (mFallbackFonts.empty()) { - llwarns << "LLFontGL::reset(), no fallback fonts present" << llendl; + LL_WARNS() << "LLFontGL::reset(), no fallback fonts present" << LL_ENDL; } else { @@ -518,8 +523,15 @@ void LLFontFreetype::reset(F32 vert_dpi, F32 horz_dpi) void LLFontFreetype::resetBitmapCache() { - for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); + for (char_glyph_info_map_t::iterator it = mCharGlyphInfoMap.begin(), end_it = mCharGlyphInfoMap.end(); + it != end_it; + ++it) + { + disclaimMem(it->second); + delete it->second; + } mCharGlyphInfoMap.clear(); + disclaimMem(mFontBitmapCachep); mFontBitmapCachep->reset(); // Adding default glyph is skipped for fallback fonts here as well as in loadFace(). @@ -541,7 +553,7 @@ const std::string &LLFontFreetype::getName() const return mName; } -const LLPointer<LLFontBitmapCache> LLFontFreetype::getFontBitmapCache() const +const LLFontBitmapCache* LLFontFreetype::getFontBitmapCache() const { return mFontBitmapCachep; } diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index f1b23f22d5..2963fbd43d 100755 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -74,7 +74,7 @@ struct LLFontGlyphInfo extern LLFontManager *gFontManagerp; -class LLFontFreetype : public LLRefCount +class LLFontFreetype : public LLRefCount, public LLTrace::MemTrackable<LLFontFreetype> { public: LLFontFreetype(); @@ -134,7 +134,7 @@ public: const std::string& getName() const; - const LLPointer<LLFontBitmapCache> getFontBitmapCache() const; + const LLFontBitmapCache* getFontBitmapCache() const; void setStyle(U8 style); U8 getStyle() const; @@ -167,7 +167,7 @@ private: typedef boost::unordered_map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t; mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap - mutable LLPointer<LLFontBitmapCache> mFontBitmapCachep; + mutable LLFontBitmapCache* mFontBitmapCachep; mutable S32 mRenderGlyphCount; mutable S32 mAddGlyphCount; diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index c4f36cabd0..1d181b476a 100755 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -29,6 +29,7 @@ #include "llfontgl.h" // Linden library includes +#include "llfasttimer.h" #include "llfontfreetype.h" #include "llfontbitmapcache.h" #include "llfontregistry.h" @@ -97,7 +98,7 @@ BOOL LLFontGL::loadFace(const std::string& filename, F32 point_size, F32 vert_dp return mFontFreetype->loadFace(filename, point_size, vert_dpi, horz_dpi, components, is_fallback); } -static LLFastTimer::DeclareTimer FTM_RENDER_FONTS("Fonts"); +static LLTrace::BlockTimerStatHandle FTM_RENDER_FONTS("Fonts"); S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRect& rect, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, F32* right_x, BOOL use_ellipses) const @@ -128,7 +129,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRect& rect S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses) const { - LLFastTimer _(FTM_RENDER_FONTS); + LL_RECORD_BLOCK_TIME(FTM_RENDER_FONTS); if(!sDisplayFont) //do not display texts { @@ -275,7 +276,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons } if (!fgi) { - llerrs << "Missing Glyph Info" << llendl; + LL_ERRS() << "Missing Glyph Info" << LL_ENDL; break; } // Per-glyph bitmap texture. @@ -1069,7 +1070,7 @@ std::string LLFontGL::getFontPathSystem() system_root = getenv("SystemRoot"); /* Flawfinder: ignore */ if (!system_root) { - llwarns << "SystemRoot not found, attempting to load fonts from default path." << llendl; + LL_WARNS() << "SystemRoot not found, attempting to load fonts from default path." << LL_ENDL; } #endif @@ -1114,12 +1115,12 @@ std::string LLFontGL::getFontPathLocal() LLFontGL::LLFontGL(const LLFontGL &source) { - llerrs << "Not implemented!" << llendl; + LL_ERRS() << "Not implemented!" << LL_ENDL; } LLFontGL &LLFontGL::operator=(const LLFontGL &source) { - llerrs << "Not implemented" << llendl; + LL_ERRS() << "Not implemented" << LL_ENDL; return *this; } diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp index f5ca8d5b04..d003687415 100755 --- a/indra/llrender/llfontregistry.cpp +++ b/indra/llrender/llfontregistry.cpp @@ -34,13 +34,15 @@ #include "llcontrol.h" #include "lldir.h" #include "llwindow.h" +#include "llxmlnode.h" extern LLControlGroup gSavedSettings; using std::string; using std::map; -bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc); +bool font_desc_init_from_xml(LLXMLNodePtr node, LLFontDescriptor& desc); +bool init_from_xml(LLFontRegistry* registry, LLXMLNodePtr node); LLFontDescriptor::LLFontDescriptor(): mStyle(0) @@ -198,7 +200,7 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename) if ( root.isNull() || ! root->hasName( "fonts" ) ) { - llwarns << "Bad font info file: " << *path_it << llendl; + LL_WARNS() << "Bad font info file: " << *path_it << LL_ENDL; continue; } @@ -207,7 +209,7 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename) if (root->hasName("fonts")) { // Expect a collection of children consisting of "font" or "font_size" entries - bool init_succ = initFromXML(root); + bool init_succ = init_from_xml(this, root); success = success || init_succ; } } @@ -230,7 +232,7 @@ std::string currentOsName() #endif } -bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc) +bool font_desc_init_from_xml(LLXMLNodePtr node, LLFontDescriptor& desc) { if (node->hasName("font")) { @@ -263,14 +265,14 @@ bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc) { if (child_name == currentOsName()) { - fontDescInitFromXML(child, desc); + font_desc_init_from_xml(child, desc); } } } return true; } -bool LLFontRegistry::initFromXML(LLXMLNodePtr node) +bool init_from_xml(LLFontRegistry* registry, LLXMLNodePtr node) { LLXMLNodePtr child; @@ -281,17 +283,17 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node) if (child->hasName("font")) { LLFontDescriptor desc; - bool font_succ = fontDescInitFromXML(child, desc); + bool font_succ = font_desc_init_from_xml(child, desc); LLFontDescriptor norm_desc = desc.normalize(); if (font_succ) { // if this is the first time we've seen this font name, // create a new template map entry for it. - const LLFontDescriptor *match_desc = getMatchingFontDesc(desc); + const LLFontDescriptor *match_desc = registry->getMatchingFontDesc(desc); if (match_desc == NULL) { // Create a new entry (with no corresponding font). - mFontMap[norm_desc] = NULL; + registry->mFontMap[norm_desc] = NULL; } // otherwise, find the existing entry and combine data. else @@ -306,8 +308,8 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node) desc.getFileNames().end()); LLFontDescriptor new_desc = *match_desc; new_desc.getFileNames() = match_file_names; - mFontMap.erase(*match_desc); - mFontMap[new_desc] = NULL; + registry->mFontMap.erase(*match_desc); + registry->mFontMap[new_desc] = NULL; } } } @@ -318,7 +320,7 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node) if (child->getAttributeString("name",size_name) && child->getAttributeF32("size",size_value)) { - mFontSizes[size_name] = size_value; + registry->mFontSizes[size_name] = size_value; } } @@ -351,10 +353,10 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) bool found_size = nameToSize(norm_desc.getSize(),point_size); if (!found_size) { - llwarns << "createFont unrecognized size " << norm_desc.getSize() << llendl; + LL_WARNS() << "createFont unrecognized size " << norm_desc.getSize() << LL_ENDL; return NULL; } - llinfos << "createFont " << norm_desc.getName() << " size " << norm_desc.getSize() << " style " << ((S32) norm_desc.getStyle()) << llendl; + LL_INFOS() << "createFont " << norm_desc.getName() << " size " << norm_desc.getSize() << " style " << ((S32) norm_desc.getStyle()) << LL_ENDL; F32 fallback_scale = 1.0; // Find corresponding font template (based on same descriptor with no size specified) @@ -363,8 +365,8 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) const LLFontDescriptor *match_desc = getClosestFontTemplate(template_desc); if (!match_desc) { - llwarns << "createFont failed, no template found for " - << norm_desc.getName() << " style [" << ((S32)norm_desc.getStyle()) << "]" << llendl; + LL_WARNS() << "createFont failed, no template found for " + << norm_desc.getName() << " style [" << ((S32)norm_desc.getStyle()) << "]" << LL_ENDL; return NULL; } @@ -377,7 +379,7 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) // This may not be the best solution, but it at least prevents a crash. if (it != mFontMap.end() && it->second != NULL) { - llinfos << "-- matching font exists: " << nearest_exact_desc.getName() << " size " << nearest_exact_desc.getSize() << " style " << ((S32) nearest_exact_desc.getStyle()) << llendl; + LL_INFOS() << "-- matching font exists: " << nearest_exact_desc.getName() << " size " << nearest_exact_desc.getSize() << " style " << ((S32) nearest_exact_desc.getStyle()) << LL_ENDL; // copying underlying Freetype font, and storing in LLFontGL with requested font descriptor LLFontGL *font = new LLFontGL; @@ -410,7 +412,7 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) // Load fonts based on names. if (file_names.empty()) { - llwarns << "createFont failed, no file names specified" << llendl; + LL_WARNS() << "createFont failed, no file names specified" << LL_ENDL; return NULL; } @@ -478,7 +480,7 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) } else { - llwarns << "createFont failed in some way" << llendl; + LL_WARNS() << "createFont failed in some way" << LL_ENDL; } mFontMap[desc] = result; @@ -531,9 +533,9 @@ LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& desc) LLFontGL *fontp = createFont(desc); if (!fontp) { - llwarns << "getFont failed, name " << desc.getName() + LL_WARNS() << "getFont failed, name " << desc.getName() <<" style=[" << ((S32) desc.getStyle()) << "]" - << " size=[" << desc.getSize() << "]" << llendl; + << " size=[" << desc.getSize() << "]" << LL_ENDL; } return fontp; } @@ -636,28 +638,28 @@ const LLFontDescriptor *LLFontRegistry::getClosestFontTemplate(const LLFontDescr void LLFontRegistry::dump() { - llinfos << "LLFontRegistry dump: " << llendl; + LL_INFOS() << "LLFontRegistry dump: " << LL_ENDL; for (font_size_map_t::iterator size_it = mFontSizes.begin(); size_it != mFontSizes.end(); ++size_it) { - llinfos << "Size: " << size_it->first << " => " << size_it->second << llendl; + LL_INFOS() << "Size: " << size_it->first << " => " << size_it->second << LL_ENDL; } for (font_reg_map_t::iterator font_it = mFontMap.begin(); font_it != mFontMap.end(); ++font_it) { const LLFontDescriptor& desc = font_it->first; - llinfos << "Font: name=" << desc.getName() + LL_INFOS() << "Font: name=" << desc.getName() << " style=[" << ((S32)desc.getStyle()) << "]" << " size=[" << desc.getSize() << "]" << " fileNames=" - << llendl; + << LL_ENDL; for (string_vec_t::const_iterator file_it=desc.getFileNames().begin(); file_it != desc.getFileNames().end(); ++file_it) { - llinfos << " file: " << *file_it <<llendl; + LL_INFOS() << " file: " << *file_it <<LL_ENDL; } } } diff --git a/indra/llrender/llfontregistry.h b/indra/llrender/llfontregistry.h index 059248fbbd..177eb6c8a5 100755 --- a/indra/llrender/llfontregistry.h +++ b/indra/llrender/llfontregistry.h @@ -28,7 +28,7 @@ #ifndef LL_LLFONTREGISTRY_H #define LL_LLFONTREGISTRY_H -#include "llxmlnode.h" +#include "llpointer.h" class LLFontGL; @@ -65,6 +65,7 @@ private: class LLFontRegistry { public: + friend bool init_from_xml(LLFontRegistry*, LLPointer<class LLXMLNode>); // create_gl_textures - set to false for test apps with no OpenGL window, // such as llui_libtest LLFontRegistry(bool create_gl_textures); @@ -72,7 +73,6 @@ public: // Load standard font info from XML file(s). bool parseFontInfo(const std::string& xml_filename); - bool initFromXML(LLXMLNodePtr node); // Clear cached glyphs for all fonts. void reset(); @@ -94,6 +94,7 @@ public: const string_vec_t& getUltimateFallbackList() const; private: + LLFontRegistry(const LLFontRegistry& other); // no-copy LLFontGL *createFont(const LLFontDescriptor& desc); typedef std::map<LLFontDescriptor,LLFontGL*> font_reg_map_t; typedef std::map<std::string,F32> font_size_map_t; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index acfb3c085a..44e6b97b31 100755 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -85,20 +85,20 @@ void APIENTRY gl_debug_callback(GLenum source, { if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) { - llwarns << "----- GL ERROR --------" << llendl; + LL_WARNS() << "----- GL ERROR --------" << LL_ENDL; } else { - llwarns << "----- GL WARNING -------" << llendl; + LL_WARNS() << "----- GL WARNING -------" << LL_ENDL; } - llwarns << "Type: " << std::hex << type << llendl; - llwarns << "ID: " << std::hex << id << llendl; - llwarns << "Severity: " << std::hex << severity << llendl; - llwarns << "Message: " << message << llendl; - llwarns << "-----------------------" << llendl; + LL_WARNS() << "Type: " << std::hex << type << LL_ENDL; + LL_WARNS() << "ID: " << std::hex << id << LL_ENDL; + LL_WARNS() << "Severity: " << std::hex << severity << LL_ENDL; + LL_WARNS() << "Message: " << message << LL_ENDL; + LL_WARNS() << "-----------------------" << LL_ENDL; if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) { - llerrs << "Halting on GL Error" << llendl; + LL_ERRS() << "Halting on GL Error" << LL_ENDL; } } } @@ -546,7 +546,7 @@ bool LLGLManager::initGL() { std::string ext((const char*) glGetStringi(GL_EXTENSIONS, i)); str << ext << " "; - LL_DEBUGS("GLExtensions") << ext << llendl; + LL_DEBUGS("GLExtensions") << ext << LL_ENDL; } { @@ -1015,7 +1015,7 @@ void LLGLManager::initExtensions() #endif #if LL_LINUX || LL_SOLARIS - llinfos << "initExtensions() checking shell variables to adjust features..." << llendl; + LL_INFOS() << "initExtensions() checking shell variables to adjust features..." << LL_ENDL; // Our extension support for the Linux Client is very young with some // potential driver gotchas, so offer a semi-secret way to turn it off. if (getenv("LL_GL_NOEXT")) @@ -1209,7 +1209,7 @@ void LLGLManager::initExtensions() } if (mHasFramebufferObject) { - llinfos << "initExtensions() FramebufferObject-related procs..." << llendl; + LL_INFOS() << "initExtensions() FramebufferObject-related procs..." << LL_ENDL; glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glIsRenderbuffer"); glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) GLH_EXT_GET_PROC_ADDRESS("glBindRenderbuffer"); glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteRenderbuffers"); @@ -1278,7 +1278,7 @@ void LLGLManager::initExtensions() if (mHasOcclusionQuery) { - llinfos << "initExtensions() OcclusionQuery-related procs..." << llendl; + LL_INFOS() << "initExtensions() OcclusionQuery-related procs..." << LL_ENDL; glGenQueriesARB = (PFNGLGENQUERIESARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGenQueriesARB"); glDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC)GLH_EXT_GET_PROC_ADDRESS("glDeleteQueriesARB"); glIsQueryARB = (PFNGLISQUERYARBPROC)GLH_EXT_GET_PROC_ADDRESS("glIsQueryARB"); @@ -1290,14 +1290,14 @@ void LLGLManager::initExtensions() } if (mHasTimerQuery) { - llinfos << "initExtensions() TimerQuery-related procs..." << llendl; + LL_INFOS() << "initExtensions() TimerQuery-related procs..." << LL_ENDL; glQueryCounter = (PFNGLQUERYCOUNTERPROC) GLH_EXT_GET_PROC_ADDRESS("glQueryCounter"); glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjecti64v"); glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectui64v"); } if (mHasPointParameters) { - llinfos << "initExtensions() PointParameters-related procs..." << llendl; + LL_INFOS() << "initExtensions() PointParameters-related procs..." << LL_ENDL; glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfARB"); glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfvARB"); } @@ -1345,7 +1345,7 @@ void LLGLManager::initExtensions() } if (mHasVertexShader) { - llinfos << "initExtensions() VertexShader-related procs..." << llendl; + LL_INFOS() << "initExtensions() VertexShader-related procs..." << LL_ENDL; glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetAttribLocationARB"); glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) GLH_EXT_GET_PROC_ADDRESS("glBindAttribLocationARB"); glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetActiveAttribARB"); @@ -1446,13 +1446,13 @@ void log_glerror() GLubyte const * gl_error_msg = gluErrorString(error); if (NULL != gl_error_msg) { - llwarns << "GL Error: " << error << " GL Error String: " << gl_error_msg << llendl ; + LL_WARNS() << "GL Error: " << error << " GL Error String: " << gl_error_msg << LL_ENDL ; } else { // gluErrorString returns NULL for some extensions' error codes. // you'll probably have to grep for the number in glext.h. - llwarns << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << llendl; + LL_WARNS() << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << LL_ENDL; } error = glGetError(); } @@ -1500,7 +1500,7 @@ void do_assert_glerror() } else { - llerrs << "One or more unhandled GL errors." << llendl; + LL_ERRS() << "One or more unhandled GL errors." << LL_ENDL; } } } @@ -1509,7 +1509,7 @@ void assert_glerror() { /* if (!gGLActive) { - //llwarns << "GL used while not active!" << llendl; + //LL_WARNS() << "GL used while not active!" << LL_ENDL; if (gDebugSession) { @@ -1798,7 +1798,7 @@ void LLGLState::checkTextureChannels(const std::string& msg) if (tex != 0) { error = TRUE; - LL_WARNS("RenderState") << "Texture channel " << i << " still has texture " << tex << " bound." << llendl; + LL_WARNS("RenderState") << "Texture channel " << i << " still has texture " << tex << " bound." << LL_ENDL; if (gDebugSession) { @@ -1842,7 +1842,7 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask) if (active_texture != GL_TEXTURE0_ARB) { - llwarns << "Client active texture corrupted: " << active_texture << llendl; + LL_WARNS() << "Client active texture corrupted: " << active_texture << LL_ENDL; if (gDebugSession) { gFailLog << "Client active texture corrupted: " << active_texture << std::endl; @@ -1853,7 +1853,7 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask) /*glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &active_texture); if (active_texture != GL_TEXTURE0_ARB) { - llwarns << "Active texture corrupted: " << active_texture << llendl; + LL_WARNS() << "Active texture corrupted: " << active_texture << LL_ENDL; if (gDebugSession) { gFailLog << "Active texture corrupted: " << active_texture << std::endl; @@ -2350,11 +2350,11 @@ void LLGLNamePool::release(GLuint name) } else { - llerrs << "Attempted to release a pooled name that is not in use!" << llendl; + LL_ERRS() << "Attempted to release a pooled name that is not in use!" << LL_ENDL; } } } - llerrs << "Attempted to release a non pooled name!" << llendl; + LL_ERRS() << "Attempted to release a non pooled name!" << LL_ENDL; #else releaseName(name); #endif diff --git a/indra/llrender/llgldbg.cpp b/indra/llrender/llgldbg.cpp index 4b68194db3..0f1d4ae742 100755 --- a/indra/llrender/llgldbg.cpp +++ b/indra/llrender/llgldbg.cpp @@ -112,112 +112,112 @@ void llgl_dump() F32 fv[16]; GLboolean b; - llinfos << "==========================" << llendl; - llinfos << "OpenGL State" << llendl; - llinfos << "==========================" << llendl; + LL_INFOS() << "==========================" << LL_ENDL; + LL_INFOS() << "OpenGL State" << LL_ENDL; + LL_INFOS() << "==========================" << LL_ENDL; - llinfos << "-----------------------------------" << llendl; - llinfos << "Current Values" << llendl; - llinfos << "-----------------------------------" << llendl; + LL_INFOS() << "-----------------------------------" << LL_ENDL; + LL_INFOS() << "Current Values" << LL_ENDL; + LL_INFOS() << "-----------------------------------" << LL_ENDL; glGetFloatv(GL_CURRENT_COLOR, fv); - llinfos << "GL_CURRENT_COLOR : " << fv4(fv) << llendl; + LL_INFOS() << "GL_CURRENT_COLOR : " << fv4(fv) << LL_ENDL; glGetFloatv(GL_CURRENT_NORMAL, fv); - llinfos << "GL_CURRENT_NORMAL : " << fv3(fv) << llendl; + LL_INFOS() << "GL_CURRENT_NORMAL : " << fv3(fv) << LL_ENDL; - llinfos << "-----------------------------------" << llendl; - llinfos << "Lighting" << llendl; - llinfos << "-----------------------------------" << llendl; + LL_INFOS() << "-----------------------------------" << LL_ENDL; + LL_INFOS() << "Lighting" << LL_ENDL; + LL_INFOS() << "-----------------------------------" << LL_ENDL; - llinfos << "GL_LIGHTING : " << boolstr(glIsEnabled(GL_LIGHTING)) << llendl; + LL_INFOS() << "GL_LIGHTING : " << boolstr(glIsEnabled(GL_LIGHTING)) << LL_ENDL; - llinfos << "GL_COLOR_MATERIAL : " << boolstr(glIsEnabled(GL_COLOR_MATERIAL)) << llendl; + LL_INFOS() << "GL_COLOR_MATERIAL : " << boolstr(glIsEnabled(GL_COLOR_MATERIAL)) << LL_ENDL; glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER, (GLint*)&i); - llinfos << "GL_COLOR_MATERIAL_PARAMETER: " << cmstr(i) << llendl; + LL_INFOS() << "GL_COLOR_MATERIAL_PARAMETER: " << cmstr(i) << LL_ENDL; glGetIntegerv(GL_COLOR_MATERIAL_FACE, (GLint*)&i); - llinfos << "GL_COLOR_MATERIAL_FACE : " << facestr(i) << llendl; + LL_INFOS() << "GL_COLOR_MATERIAL_FACE : " << facestr(i) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_AMBIENT, fv); - llinfos << "GL_AMBIENT material : " << fv4(fv) << llendl; + LL_INFOS() << "GL_AMBIENT material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_DIFFUSE, fv); - llinfos << "GL_DIFFUSE material : " << fv4(fv) << llendl; + LL_INFOS() << "GL_DIFFUSE material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_SPECULAR, fv); - llinfos << "GL_SPECULAR material : " << fv4(fv) << llendl; + LL_INFOS() << "GL_SPECULAR material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_EMISSION, fv); - llinfos << "GL_EMISSION material : " << fv4(fv) << llendl; + LL_INFOS() << "GL_EMISSION material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_SHININESS, fv); - llinfos << "GL_SHININESS material : " << fv1(fv) << llendl; + LL_INFOS() << "GL_SHININESS material : " << fv1(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetFloatv(GL_LIGHT_MODEL_AMBIENT, fv); - llinfos << "GL_LIGHT_MODEL_AMBIENT : " << fv4(fv) << llendl; + LL_INFOS() << "GL_LIGHT_MODEL_AMBIENT : " << fv4(fv) << LL_ENDL; glGetBooleanv(GL_LIGHT_MODEL_LOCAL_VIEWER, &b); - llinfos << "GL_LIGHT_MODEL_LOCAL_VIEWER: " << boolstr(b) << llendl; + LL_INFOS() << "GL_LIGHT_MODEL_LOCAL_VIEWER: " << boolstr(b) << LL_ENDL; glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE, &b); - llinfos << "GL_LIGHT_MODEL_TWO_SIDE : " << boolstr(b) << llendl; + LL_INFOS() << "GL_LIGHT_MODEL_TWO_SIDE : " << boolstr(b) << LL_ENDL; for (int l=0; l<8; l++) { b = glIsEnabled(GL_LIGHT0+l); - llinfos << "GL_LIGHT" << l << " : " << boolstr(b) << llendl; + LL_INFOS() << "GL_LIGHT" << l << " : " << boolstr(b) << LL_ENDL; if (!b) continue; glGetLightfv(GL_LIGHT0+l, GL_AMBIENT, fv); - llinfos << " GL_AMBIENT light : " << fv4(fv) << llendl; + LL_INFOS() << " GL_AMBIENT light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_DIFFUSE, fv); - llinfos << " GL_DIFFUSE light : " << fv4(fv) << llendl; + LL_INFOS() << " GL_DIFFUSE light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPECULAR, fv); - llinfos << " GL_SPECULAR light : " << fv4(fv) << llendl; + LL_INFOS() << " GL_SPECULAR light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_POSITION, fv); - llinfos << " GL_POSITION light : " << fv4(fv) << llendl; + LL_INFOS() << " GL_POSITION light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_CONSTANT_ATTENUATION, fv); - llinfos << " GL_CONSTANT_ATTENUATION : " << fv1(fv) << llendl; + LL_INFOS() << " GL_CONSTANT_ATTENUATION : " << fv1(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_QUADRATIC_ATTENUATION, fv); - llinfos << " GL_QUADRATIC_ATTENUATION : " << fv1(fv) << llendl; + LL_INFOS() << " GL_QUADRATIC_ATTENUATION : " << fv1(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPOT_DIRECTION, fv); - llinfos << " GL_SPOT_DIRECTION : " << fv4(fv) << llendl; + LL_INFOS() << " GL_SPOT_DIRECTION : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPOT_EXPONENT, fv); - llinfos << " GL_SPOT_EXPONENT : " << fv1(fv) << llendl; + LL_INFOS() << " GL_SPOT_EXPONENT : " << fv1(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPOT_CUTOFF, fv); - llinfos << " GL_SPOT_CUTOFF : " << fv1(fv) << llendl; + LL_INFOS() << " GL_SPOT_CUTOFF : " << fv1(fv) << LL_ENDL; } - llinfos << "-----------------------------------" << llendl; - llinfos << "Pixel Operations" << llendl; - llinfos << "-----------------------------------" << llendl; + LL_INFOS() << "-----------------------------------" << LL_ENDL; + LL_INFOS() << "Pixel Operations" << LL_ENDL; + LL_INFOS() << "-----------------------------------" << LL_ENDL; - llinfos << "GL_ALPHA_TEST : " << boolstr(glIsEnabled(GL_ALPHA_TEST)) << llendl; - llinfos << "GL_DEPTH_TEST : " << boolstr(glIsEnabled(GL_DEPTH_TEST)) << llendl; + LL_INFOS() << "GL_ALPHA_TEST : " << boolstr(glIsEnabled(GL_ALPHA_TEST)) << LL_ENDL; + LL_INFOS() << "GL_DEPTH_TEST : " << boolstr(glIsEnabled(GL_DEPTH_TEST)) << LL_ENDL; glGetBooleanv(GL_DEPTH_WRITEMASK, &b); - llinfos << "GL_DEPTH_WRITEMASK : " << boolstr(b) << llendl; + LL_INFOS() << "GL_DEPTH_WRITEMASK : " << boolstr(b) << LL_ENDL; - llinfos << "GL_BLEND : " << boolstr(glIsEnabled(GL_BLEND)) << llendl; - llinfos << "GL_DITHER : " << boolstr(glIsEnabled(GL_DITHER)) << llendl; + LL_INFOS() << "GL_BLEND : " << boolstr(glIsEnabled(GL_BLEND)) << LL_ENDL; + LL_INFOS() << "GL_DITHER : " << boolstr(glIsEnabled(GL_DITHER)) << LL_ENDL; } // End diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 5a80a8faa4..a95872e883 100755 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -551,9 +551,7 @@ extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; // LL_WINDOWS // windows gl headers depend on things like APIENTRY, so include windows. -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> +#include "llwin32headerslean.h" //---------------------------------------------------------------------------- #include <GL/gl.h> diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 1c50a51d02..9fae63385d 100755 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -137,10 +137,10 @@ void LLGLSLShader::finishProfile() (*iter)->dumpStats(); } - llinfos << "-----------------------------------" << llendl; - llinfos << "Total rendering time: " << llformat("%.4f ms", sTotalTimeElapsed/1000000.f) << llendl; - llinfos << "Total samples drawn: " << llformat("%.4f million", sTotalSamplesDrawn/1000000.f) << llendl; - llinfos << "Total triangles drawn: " << llformat("%.3f million", sTotalTrianglesDrawn/1000000.f) << llendl; + LL_INFOS() << "-----------------------------------" << LL_ENDL; + LL_INFOS() << "Total rendering time: " << llformat("%.4f ms", sTotalTimeElapsed/1000000.f) << LL_ENDL; + LL_INFOS() << "Total samples drawn: " << llformat("%.4f million", sTotalSamplesDrawn/1000000.f) << LL_ENDL; + LL_INFOS() << "Total triangles drawn: " << llformat("%.3f million", sTotalTrianglesDrawn/1000000.f) << LL_ENDL; } void LLGLSLShader::clearStats() @@ -158,11 +158,11 @@ void LLGLSLShader::dumpStats() { if (mDrawCalls > 0) { - llinfos << "=============================================" << llendl; - llinfos << mName << llendl; + LL_INFOS() << "=============================================" << LL_ENDL; + LL_INFOS() << mName << LL_ENDL; for (U32 i = 0; i < mShaderFiles.size(); ++i) { - llinfos << mShaderFiles[i].first << llendl; + LL_INFOS() << mShaderFiles[i].first << LL_ENDL; } for (U32 i = 0; i < mTexture.size(); ++i) { @@ -171,10 +171,10 @@ void LLGLSLShader::dumpStats() if (idx >= 0) { GLint uniform_idx = getUniformLocation(i); - llinfos << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << llendl; + LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << LL_ENDL; } } - llinfos << "=============================================" << llendl; + LL_INFOS() << "=============================================" << LL_ENDL; F32 ms = mTimeElapsed/1000000.f; F32 seconds = ms/1000.f; @@ -190,10 +190,10 @@ void LLGLSLShader::dumpStats() F32 pct_calls = (F32) mDrawCalls/(F32)sTotalDrawCalls*100.f; U32 avg_batch = mTrianglesDrawn/mDrawCalls; - llinfos << "Triangles Drawn: " << mTrianglesDrawn << " " << llformat("(%.2f pct of total, %.3f million/sec)", pct_tris, tris_sec ) << llendl; - llinfos << "Draw Calls: " << mDrawCalls << " " << llformat("(%.2f pct of total, avg %d tris/call)", pct_calls, avg_batch) << llendl; - llinfos << "SamplesDrawn: " << mSamplesDrawn << " " << llformat("(%.2f pct of total, %.3f billion/sec)", pct_samples, samples_sec) << llendl; - llinfos << "Time Elapsed: " << mTimeElapsed << " " << llformat("(%.2f pct of total, %.5f ms)\n", (F32) ((F64)mTimeElapsed/(F64)sTotalTimeElapsed)*100.f, ms) << llendl; + LL_INFOS() << "Triangles Drawn: " << mTrianglesDrawn << " " << llformat("(%.2f pct of total, %.3f million/sec)", pct_tris, tris_sec ) << LL_ENDL; + LL_INFOS() << "Draw Calls: " << mDrawCalls << " " << llformat("(%.2f pct of total, avg %d tris/call)", pct_calls, avg_batch) << LL_ENDL; + LL_INFOS() << "SamplesDrawn: " << mSamplesDrawn << " " << llformat("(%.2f pct of total, %.3f billion/sec)", pct_samples, samples_sec) << LL_ENDL; + LL_INFOS() << "Time Elapsed: " << mTimeElapsed << " " << llformat("(%.2f pct of total, %.5f ms)\n", (F32) ((F64)mTimeElapsed/(F64)sTotalTimeElapsed)*100.f, ms) << LL_ENDL; } } @@ -711,7 +711,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms) unbind(); - LL_DEBUGS("ShaderLoading") << "Total Uniform Size: " << mTotalUniformSize << llendl; + LL_DEBUGS("ShaderLoading") << "Total Uniform Size: " << mTotalUniformSize << LL_ENDL; return res; } @@ -864,7 +864,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) } else { - llerrs << "Texture channel " << index << " texture type corrupted." << llendl; + LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL; } } gGL.getTexUnit(index)->disable(); @@ -1164,7 +1164,7 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform) stop_glerror(); if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str())) { - llerrs << "Uniform does not match." << llendl; + LL_ERRS() << "Uniform does not match." << LL_ENDL; } stop_glerror(); } diff --git a/indra/llrender/llgltexture.cpp b/indra/llrender/llgltexture.cpp index d06ed5e57b..56e263c5f1 100644 --- a/indra/llrender/llgltexture.cpp +++ b/indra/llrender/llgltexture.cpp @@ -294,7 +294,7 @@ LLTexUnit::eTextureAddressMode LLGLTexture::getAddressMode(void) const return mGLTexturep->getAddressMode() ; } -S32 LLGLTexture::getTextureMemory() const +S32Bytes LLGLTexture::getTextureMemory() const { llassert(mGLTexturep.notNull()) ; diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index e69b322d60..45592ee077 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -101,7 +101,7 @@ public: LLGLTexture(const LLImageRaw* raw, BOOL usemipmaps) ; LLGLTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps) ; - virtual void dump(); // debug info to llinfos + virtual void dump(); // debug info to LL_INFOS() virtual const LLUUID& getID() const = 0; @@ -138,7 +138,7 @@ public: S32 getDiscardLevel() const; S8 getComponents() const; BOOL getBoundRecently() const; - S32 getTextureMemory() const ; + S32Bytes getTextureMemory() const ; LLGLenum getPrimaryFormat() const; BOOL getIsAlphaMask() const ; LLTexUnit::eTextureType getTarget(void) const ; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index ab875141c5..ddf38c6745 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -32,6 +32,7 @@ #include "llimagegl.h" #include "llerror.h" +#include "llfasttimer.h" #include "llimage.h" #include "llmath.h" @@ -50,9 +51,9 @@ U32 wpo2(U32 i); U32 LLImageGL::sUniqueCount = 0; U32 LLImageGL::sBindCount = 0; -S32 LLImageGL::sGlobalTextureMemoryInBytes = 0; -S32 LLImageGL::sBoundTextureMemoryInBytes = 0; -S32 LLImageGL::sCurBoundTextureMemory = 0; +S32Bytes LLImageGL::sGlobalTextureMemory(0); +S32Bytes LLImageGL::sBoundTextureMemory(0); +S32Bytes LLImageGL::sCurBoundTextureMemory(0); S32 LLImageGL::sCount = 0; BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; @@ -114,7 +115,7 @@ void LLImageGL::checkTexSize(bool forced) const BOOL error = FALSE; if (texname != mTexName) { - llinfos << "Bound: " << texname << " Should bind: " << mTexName << " Default: " << LLImageGL::sDefaultGLTexture->getTexName() << llendl; + LL_INFOS() << "Bound: " << texname << " Should bind: " << mTexName << " Default: " << LLImageGL::sDefaultGLTexture->getTexName() << LL_ENDL; error = TRUE; if (gDebugSession) @@ -123,7 +124,7 @@ void LLImageGL::checkTexSize(bool forced) const } else { - llerrs << "Invalid texture bound!" << llendl; + LL_ERRS() << "Invalid texture bound!" << LL_ENDL; } } stop_glerror() ; @@ -147,8 +148,8 @@ void LLImageGL::checkTexSize(bool forced) const } else { - llerrs << "wrong texture size and discard level: width: " << - mWidth << " Height: " << mHeight << " Current Level: " << (S32)mCurrentDiscardLevel << llendl ; + LL_ERRS() << "wrong texture size and discard level: width: " << + mWidth << " Height: " << mHeight << " Current Level: " << (S32)mCurrentDiscardLevel << LL_ENDL ; } } @@ -197,7 +198,7 @@ S32 LLImageGL::dataFormatBits(S32 dataformat) case GL_RGBA: return 32; case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac default: - llerrs << "LLImageGL::Unknown format: " << dataformat << llendl; + LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL; return 0; } } @@ -232,28 +233,28 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat) case GL_RGBA: return 4; case GL_BGRA: return 4; // Used for QuickTime media textures on the Mac default: - llerrs << "LLImageGL::Unknown format: " << dataformat << llendl; + LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL; return 0; } } //---------------------------------------------------------------------------- -static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_STATS("Image Stats"); +static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_STATS("Image Stats"); // static void LLImageGL::updateStats(F32 current_time) { - LLFastTimer t(FTM_IMAGE_UPDATE_STATS); + LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_STATS); sLastFrameTime = current_time; - sBoundTextureMemoryInBytes = sCurBoundTextureMemory; - sCurBoundTextureMemory = 0; + sBoundTextureMemory = sCurBoundTextureMemory; + sCurBoundTextureMemory = S32Bytes(0); } //static -S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) +S32 LLImageGL::updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) { LLImageGL::sCurBoundTextureMemory += mem ; - return LLImageGL::sCurBoundTextureMemory; + return LLImageGL::sCurBoundTextureMemory.value(); } //---------------------------------------------------------------------------- @@ -276,8 +277,10 @@ void LLImageGL::destroyGL(BOOL save_state) if (save_state && glimage->isGLTextureCreated() && glimage->mComponents) { glimage->mSaveData = new LLImageRaw; + glimage->claimMem(glimage->mSaveData); if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it. { + glimage->disclaimMem(glimage->mSaveData); glimage->mSaveData = NULL ; } } @@ -298,7 +301,7 @@ void LLImageGL::restoreGL() LLImageGL* glimage = *iter; if(glimage->getTexName()) { - llerrs << "tex name is not 0." << llendl ; + LL_ERRS() << "tex name is not 0." << LL_ENDL ; } if (glimage->mSaveData.notNull()) { @@ -351,7 +354,8 @@ BOOL LLImageGL::create(LLPointer<LLImageGL>& dest, const LLImageRaw* imageraw, B //---------------------------------------------------------------------------- LLImageGL::LLImageGL(BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -360,7 +364,8 @@ LLImageGL::LLImageGL(BOOL usemipmaps) } LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { llassert( components <= 4 ); init(usemipmaps); @@ -370,7 +375,8 @@ LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) } LLImageGL::LLImageGL(const LLImageRaw* imageraw, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -384,6 +390,7 @@ LLImageGL::~LLImageGL() { LLImageGL::cleanup(); sImageList.erase(this); + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; sCount--; @@ -395,7 +402,7 @@ void LLImageGL::init(BOOL usemipmaps) // so that it is obvious by visual inspection if we forgot to // init a field. - mTextureMemory = 0; + mTextureMemory = (S32Bytes)0; mLastBindTime = 0.f; mPickMask = NULL; @@ -487,16 +494,17 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents, S32 discard_leve // Check if dimensions are a power of two! if (!checkSize(width,height)) { - llerrs << llformat("Texture has non power of two dimension: %dx%d",width,height) << llendl; + LL_ERRS() << llformat("Texture has non power of two dimension: %dx%d",width,height) << LL_ENDL; } if (mTexName) { -// llwarns << "Setting Size of LLImageGL with existing mTexName = " << mTexName << llendl; +// LL_WARNS() << "Setting Size of LLImageGL with existing mTexName = " << mTexName << LL_ENDL; destroyGLTexture(); } // pickmask validity depends on old image size, delete it + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -531,7 +539,7 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents, S32 discard_leve // virtual void LLImageGL::dump() { - llinfos << "mMaxDiscardLevel " << S32(mMaxDiscardLevel) + LL_INFOS() << "mMaxDiscardLevel " << S32(mMaxDiscardLevel) << " mLastBindTime " << mLastBindTime << " mTarget " << S32(mTarget) << " mBindTarget " << S32(mBindTarget) @@ -546,12 +554,12 @@ void LLImageGL::dump() #if DEBUG_MISS << " mMissed " << mMissed #endif - << llendl; + << LL_ENDL; - llinfos << " mTextureMemory " << mTextureMemory + LL_INFOS() << " mTextureMemory " << mTextureMemory << " mTexNames " << mTexName << " mIsResident " << S32(mIsResident) - << llendl; + << LL_ENDL; } //---------------------------------------------------------------------------- @@ -560,7 +568,7 @@ void LLImageGL::forceUpdateBindStats(void) const mLastBindTime = sLastFrameTime; } -BOOL LLImageGL::updateBindStats(S32 tex_mem) const +BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const { if (mTexName != 0) { @@ -613,10 +621,10 @@ void LLImageGL::setImage(const LLImageRaw* imageraw) setImage(rawdata, FALSE); } -static LLFastTimer::DeclareTimer FTM_SET_IMAGE("setImage"); +static LLTrace::BlockTimerStatHandle FTM_SET_IMAGE("setImage"); void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) { - LLFastTimer t(FTM_SET_IMAGE); + LL_RECORD_BLOCK_TIME(FTM_SET_IMAGE); bool is_compressed = false; if (mFormatPrimary >= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && mFormatPrimary <= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) { @@ -668,7 +676,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } else { -// LLFastTimer t2(FTM_TEMP4); +// LL_RECORD_BLOCK_TIME(FTM_TEMP4); if(mFormatSwapBytes) { @@ -700,7 +708,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) { stop_glerror(); { -// LLFastTimer t2(FTM_TEMP4); +// LL_RECORD_BLOCK_TIME(FTM_TEMP4); if(mFormatSwapBytes) { @@ -797,7 +805,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) llassert(w > 0 && h > 0 && cur_mip_data); (void)cur_mip_data; { -// LLFastTimer t1(FTM_TEMP4); +// LL_RECORD_BLOCK_TIME(FTM_TEMP4); if(mFormatSwapBytes) { glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); @@ -838,7 +846,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } else { - llerrs << "Compressed Image has mipmaps but data does not (can not auto generate compressed mips)" << llendl; + LL_ERRS() << "Compressed Image has mipmaps but data does not (can not auto generate compressed mips)" << LL_ENDL; } } else @@ -887,7 +895,7 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image) if (gGLManager.mIsDisabled) { - llwarns << "Trying to create a texture while GL is disabled!" << llendl; + LL_WARNS() << "Trying to create a texture while GL is disabled!" << LL_ENDL; return FALSE; } llassert(gGLManager.mInited); @@ -933,7 +941,7 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image) mFormatType = GL_UNSIGNED_BYTE; break; default: - llerrs << "Bad number of components for texture: " << (U32)getComponents() << llendl; + LL_ERRS() << "Bad number of components for texture: " << (U32)getComponents() << LL_ENDL; } } @@ -977,13 +985,13 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 if (mTexName == 0) { // *TODO: Re-enable warning? Ran into thread locking issues? DK 2011-02-18 - //llwarns << "Setting subimage on image without GL texture" << llendl; + //LL_WARNS() << "Setting subimage on image without GL texture" << LL_ENDL; return FALSE; } if (datap == NULL) { // *TODO: Re-enable warning? Ran into thread locking issues? DK 2011-02-18 - //llwarns << "Setting subimage on image with NULL datap" << llendl; + //LL_WARNS() << "Setting subimage on image with NULL datap" << LL_ENDL; return FALSE; } @@ -997,7 +1005,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 if (mUseMipMaps) { dump(); - llerrs << "setSubImage called with mipmapped image (not supported)" << llendl; + LL_ERRS() << "setSubImage called with mipmapped image (not supported)" << LL_ENDL; } llassert_always(mCurrentDiscardLevel == 0); llassert_always(x_pos >= 0 && y_pos >= 0); @@ -1006,28 +1014,28 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 (y_pos + height) > getHeight()) { dump(); - llerrs << "Subimage not wholly in target image!" + LL_ERRS() << "Subimage not wholly in target image!" << " x_pos " << x_pos << " y_pos " << y_pos << " width " << width << " height " << height << " getWidth() " << getWidth() << " getHeight() " << getHeight() - << llendl; + << LL_ENDL; } if ((x_pos + width) > data_width || (y_pos + height) > data_height) { dump(); - llerrs << "Subimage not wholly in source image!" + LL_ERRS() << "Subimage not wholly in source image!" << " x_pos " << x_pos << " y_pos " << y_pos << " width " << width << " height " << height << " source_width " << data_width << " source_height " << data_height - << llendl; + << LL_ENDL; } @@ -1043,7 +1051,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 datap += (y_pos * data_width + x_pos) * getComponents(); // Update the GL texture BOOL res = gGL.getTexUnit(0)->bindManual(mBindTarget, mTexName); - if (!res) llerrs << "LLImageGL::setSubImage(): bindTexture failed" << llendl; + if (!res) LL_ERRS() << "LLImageGL::setSubImage(): bindTexture failed" << LL_ENDL; stop_glerror(); glTexSubImage2D(mTarget, 0, x_pos, y_pos, @@ -1086,10 +1094,10 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_ } // static -static LLFastTimer::DeclareTimer FTM_GENERATE_TEXTURES("generate textures"); +static LLTrace::BlockTimerStatHandle FTM_GENERATE_TEXTURES("generate textures"); void LLImageGL::generateTextures(S32 numTextures, U32 *textures) { - LLFastTimer t(FTM_GENERATE_TEXTURES); + LL_RECORD_BLOCK_TIME(FTM_GENERATE_TEXTURES); glGenTextures(numTextures, textures); } @@ -1103,10 +1111,10 @@ void LLImageGL::deleteTextures(S32 numTextures, U32 *textures) } // static -static LLFastTimer::DeclareTimer FTM_SET_MANUAL_IMAGE("setManualImage"); +static LLTrace::BlockTimerStatHandle FTM_SET_MANUAL_IMAGE("setManualImage"); void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels, bool allow_compression) { - LLFastTimer t(FTM_SET_MANUAL_IMAGE); + LL_RECORD_BLOCK_TIME(FTM_SET_MANUAL_IMAGE); bool use_scratch = false; U32* scratch = NULL; if (LLRender::sGLCoreProfile) @@ -1193,7 +1201,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt intformat = GL_COMPRESSED_ALPHA; break; default: - llwarns << "Could not compress format: " << std::hex << intformat << llendl; + LL_WARNS() << "Could not compress format: " << std::hex << intformat << LL_ENDL; break; } } @@ -1210,13 +1218,13 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt //create an empty GL texture: just create a texture name //the texture is assiciate with some image by calling glTexImage outside LLImageGL -static LLFastTimer::DeclareTimer FTM_CREATE_GL_TEXTURE1("createGLTexture()"); +static LLTrace::BlockTimerStatHandle FTM_CREATE_GL_TEXTURE1("createGLTexture()"); BOOL LLImageGL::createGLTexture() { - LLFastTimer t(FTM_CREATE_GL_TEXTURE1); + LL_RECORD_BLOCK_TIME(FTM_CREATE_GL_TEXTURE1); if (gGLManager.mIsDisabled) { - llwarns << "Trying to create a texture while GL is disabled!" << llendl; + LL_WARNS() << "Trying to create a texture while GL is disabled!" << LL_ENDL; return FALSE; } @@ -1235,19 +1243,19 @@ BOOL LLImageGL::createGLTexture() stop_glerror(); if (!mTexName) { - llerrs << "LLImageGL::createGLTexture failed to make an empty texture" << llendl; + LL_ERRS() << "LLImageGL::createGLTexture failed to make an empty texture" << LL_ENDL; } return TRUE ; } -static LLFastTimer::DeclareTimer FTM_CREATE_GL_TEXTURE2("createGLTexture(raw)"); +static LLTrace::BlockTimerStatHandle FTM_CREATE_GL_TEXTURE2("createGLTexture(raw)"); BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/, BOOL to_create, S32 category) { - LLFastTimer t(FTM_CREATE_GL_TEXTURE2); + LL_RECORD_BLOCK_TIME(FTM_CREATE_GL_TEXTURE2); if (gGLManager.mIsDisabled) { - llwarns << "Trying to create a texture while GL is disabled!" << llendl; + LL_WARNS() << "Trying to create a texture while GL is disabled!" << LL_ENDL; return FALSE; } @@ -1297,7 +1305,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S mFormatType = GL_UNSIGNED_BYTE; break; default: - llerrs << "Bad number of components for texture: " << (U32)getComponents() << llendl; + LL_ERRS() << "Bad number of components for texture: " << (U32)getComponents() << LL_ENDL; } calcAlphaChannelOffsetAndStride() ; @@ -1316,10 +1324,10 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S return createGLTexture(discard_level, rawdata, FALSE, usename); } -static LLFastTimer::DeclareTimer FTM_CREATE_GL_TEXTURE3("createGLTexture3(data)"); +static LLTrace::BlockTimerStatHandle FTM_CREATE_GL_TEXTURE3("createGLTexture3(data)"); BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_hasmips, S32 usename) { - LLFastTimer t(FTM_CREATE_GL_TEXTURE3); + LL_RECORD_BLOCK_TIME(FTM_CREATE_GL_TEXTURE3); llassert(data_in); stop_glerror(); @@ -1359,7 +1367,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ } if (!mTexName) { - llerrs << "LLImageGL::createGLTexture failed to make texture" << llendl; + LL_ERRS() << "LLImageGL::createGLTexture failed to make texture" << LL_ENDL; } if (mUseMipMaps) @@ -1389,15 +1397,17 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ if (old_name != 0) { - sGlobalTextureMemoryInBytes -= mTextureMemory; + sGlobalTextureMemory -= mTextureMemory; LLImageGL::deleteTextures(1, &old_name); stop_glerror(); } - mTextureMemory = getMipBytes(discard_level); - sGlobalTextureMemoryInBytes += mTextureMemory; + disclaimMem(mTextureMemory); + mTextureMemory = (S32Bytes)getMipBytes(discard_level); + claimMem(mTextureMemory); + sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight() ; // mark this as bound at this point, so we don't throw it out immediately @@ -1408,7 +1418,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) const { llassert_always(sAllowReadBackRaw) ; - //llerrs << "should not call this function!" << llendl ; + //LL_ERRS() << "should not call this function!" << LL_ENDL ; if (discard_level < 0) { @@ -1446,15 +1456,15 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre } if(width < glwidth) { - llwarns << "texture size is smaller than it should be." << llendl ; - llwarns << "width: " << width << " glwidth: " << glwidth << " mWidth: " << mWidth << - " mCurrentDiscardLevel: " << (S32)mCurrentDiscardLevel << " discard_level: " << (S32)discard_level << llendl ; + LL_WARNS() << "texture size is smaller than it should be." << LL_ENDL ; + LL_WARNS() << "width: " << width << " glwidth: " << glwidth << " mWidth: " << mWidth << + " mCurrentDiscardLevel: " << (S32)mCurrentDiscardLevel << " discard_level: " << (S32)discard_level << LL_ENDL ; return FALSE ; } if (width <= 0 || width > 2048 || height <= 0 || height > 2048 || ncomponents < 1 || ncomponents > 4) { - llerrs << llformat("LLImageGL::readBackRaw: bogus params: %d x %d x %d",width,height,ncomponents) << llendl; + LL_ERRS() << llformat("LLImageGL::readBackRaw: bogus params: %d x %d x %d",width,height,ncomponents) << LL_ENDL; } LLGLint is_compressed = 0; @@ -1467,7 +1477,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre GLenum error ; while((error = glGetError()) != GL_NO_ERROR) { - llwarns << "GL Error happens before reading back texture. Error code: " << error << llendl ; + LL_WARNS() << "GL Error happens before reading back texture. Error code: " << error << LL_ENDL ; } //----------------------------------------------------------------------------------------------- @@ -1477,8 +1487,8 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, (GLint*)&glbytes); if(!imageraw->allocateDataSize(width, height, ncomponents, glbytes)) { - llwarns << "Memory allocation failed for reading back texture. Size is: " << glbytes << llendl ; - llwarns << "width: " << width << "height: " << height << "components: " << ncomponents << llendl ; + LL_WARNS() << "Memory allocation failed for reading back texture. Size is: " << glbytes << LL_ENDL ; + LL_WARNS() << "width: " << width << "height: " << height << "components: " << ncomponents << LL_ENDL ; return FALSE ; } @@ -1489,8 +1499,8 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre { if(!imageraw->allocateDataSize(width, height, ncomponents)) { - llwarns << "Memory allocation failed for reading back texture." << llendl ; - llwarns << "width: " << width << "height: " << height << "components: " << ncomponents << llendl ; + LL_WARNS() << "Memory allocation failed for reading back texture." << LL_ENDL ; + LL_WARNS() << "width: " << width << "height: " << height << "components: " << ncomponents << LL_ENDL ; return FALSE ; } @@ -1501,12 +1511,12 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre //----------------------------------------------------------------------------------------------- if((error = glGetError()) != GL_NO_ERROR) { - llwarns << "GL Error happens after reading back texture. Error code: " << error << llendl ; + LL_WARNS() << "GL Error happens after reading back texture. Error code: " << error << LL_ENDL ; imageraw->deleteData() ; while((error = glGetError()) != GL_NO_ERROR) { - llwarns << "GL Error happens after reading back texture. Error code: " << error << llendl ; + LL_WARNS() << "GL Error happens after reading back texture. Error code: " << error << LL_ENDL ; } return FALSE ; @@ -1530,10 +1540,11 @@ void LLImageGL::destroyGLTexture() { if (mTexName != 0) { - if(mTextureMemory) + if(mTextureMemory != S32Bytes(0)) { - sGlobalTextureMemoryInBytes -= mTextureMemory; - mTextureMemory = 0; + sGlobalTextureMemory -= mTextureMemory; + disclaimMem(mTextureMemory); + mTextureMemory = (S32Bytes)0; } LLImageGL::deleteTextures(1, &mTexName); @@ -1766,7 +1777,7 @@ void LLImageGL::calcAlphaChannelOffsetAndStride() mAlphaOffset < 0 || //unsupported type (mFormatPrimary == GL_BGRA_EXT && mFormatType != GL_UNSIGNED_BYTE)) //unknown situation { - llwarns << "Cannot analyze alpha for image with format type " << std::hex << mFormatType << std::dec << llendl; + LL_WARNS() << "Cannot analyze alpha for image with format type " << std::hex << mFormatType << std::dec << LL_ENDL; mNeedsAlphaAndPickMask = FALSE ; mIsMask = FALSE; @@ -1882,6 +1893,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) return ; } + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -1899,6 +1911,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) U32 size = pick_width * pick_height; size = (size + 7) / 8; // pixelcount-to-bits mPickMask = new U8[size]; + claimMem(size); mPickMaskWidth = pick_width - 1; mPickMaskHeight = pick_height - 1; diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 0c62dd0d33..6ca814af6f 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -34,6 +34,7 @@ #include "llpointer.h" #include "llrefcount.h" #include "v2math.h" +#include "llunits.h" #include "llrender.h" class LLTextureAtlas ; @@ -41,7 +42,7 @@ class LLTextureAtlas ; #define MEGA_BYTES_TO_BYTES(x) ((x) << 20) //============================================================================ -class LLImageGL : public LLRefCount +class LLImageGL : public LLRefCount, public LLTrace::MemTrackable<LLImageGL> { friend class LLTexUnit; public: @@ -55,7 +56,7 @@ public: static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); static S32 dataFormatComponents(S32 dataformat); - BOOL updateBindStats(S32 tex_mem) const ; + BOOL updateBindStats(S32Bytes tex_mem) const ; F32 getTimePassedSinceLastBound(); void forceUpdateBindStats(void) const; @@ -68,7 +69,7 @@ public: static void dirtyTexOptions(); // Sometimes called externally for textures not using LLImageGL (should go away...) - static S32 updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) ; + static S32 updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) ; static bool checkSize(S32 width, S32 height); @@ -91,7 +92,7 @@ protected: void calcAlphaChannelOffsetAndStride(); public: - virtual void dump(); // debugging info to llinfos + virtual void dump(); // debugging info to LL_INFOS() void setSize(S32 width, S32 height, S32 ncomponents, S32 discard_level = -1); void setComponents(S32 ncomponents) { mComponents = (S8)ncomponents ;} @@ -181,7 +182,7 @@ public: public: // Various GL/Rendering options - S32 mTextureMemory; + S32Bytes mTextureMemory; mutable F32 mLastBindTime; // last time this was bound, by discard level private: @@ -238,9 +239,9 @@ public: static F32 sLastFrameTime; // Global memory statistics - static S32 sGlobalTextureMemoryInBytes; // Tracks main memory texmem - static S32 sBoundTextureMemoryInBytes; // Tracks bound texmem for last completed frame - static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame + static S32Bytes sGlobalTextureMemory; // Tracks main memory texmem + static S32Bytes sBoundTextureMemory; // Tracks bound texmem for last completed frame + static S32Bytes sCurBoundTextureMemory; // Tracks bound texmem for current frame static U32 sBindCount; // Tracks number of texture binds for current frame static U32 sUniqueCount; // Tracks number of unique texture binds for current frame static BOOL sGlobalUseAnisotropic; diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 4c36185b08..a95bb7027b 100755 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -73,7 +73,7 @@ LLPostProcess::LLPostProcess(void) : /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; + LL_DEBUGS("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; llifstream effectsXML(pathName); @@ -160,7 +160,7 @@ void LLPostProcess::saveEffect(std::string const & effectName) mAllEffects[effectName] = tweaks; std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); - //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl; + //LL_INFOS() << "Saving PostProcess Effects settings to " << pathName << LL_ENDL; llofstream effectsXML(pathName); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index b481cf7095..388d3a4f1a 100755 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -266,7 +266,7 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) } else { - llwarns << "NULL LLTexUnit::bind texture" << llendl; + LL_WARNS() << "NULL LLTexUnit::bind texture" << LL_ENDL; return false; } } @@ -285,7 +285,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind) if(!texture) { - llwarns << "NULL LLTexUnit::bind texture" << llendl; + LL_WARNS() << "NULL LLTexUnit::bind texture" << LL_ENDL; return false; } @@ -335,7 +335,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) if (cubeMap == NULL) { - llwarns << "NULL LLTexUnit::bind cubemap" << llendl; + LL_WARNS() << "NULL LLTexUnit::bind cubemap" << LL_ENDL; return false; } @@ -359,7 +359,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) } else { - llwarns << "Using cube map without extension!" << llendl; + LL_WARNS() << "Using cube map without extension!" << LL_ENDL; return false; } } @@ -377,7 +377,7 @@ bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth) { if (renderTarget->hasStencil()) { - llerrs << "Cannot bind a render buffer for sampling. Allocate render target without a stencil buffer if sampling of depth buffer is required." << llendl; + LL_ERRS() << "Cannot bind a render buffer for sampling. Allocate render target without a stencil buffer if sampling of depth buffer is required." << LL_ENDL; } bindManual(renderTarget->getUsage(), renderTarget->getDepth()); @@ -503,7 +503,7 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio { glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gGL.mMaxAnisotropy); - llinfos << "gGL.mMaxAnisotropy: " << gGL.mMaxAnisotropy << llendl ; + LL_INFOS() << "gGL.mMaxAnisotropy: " << gGL.mMaxAnisotropy << LL_ENDL ; gGL.mMaxAnisotropy = llmax(1.f, gGL.mMaxAnisotropy) ; } glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, gGL.mMaxAnisotropy); @@ -557,7 +557,7 @@ void LLTexUnit::setTextureBlendType(eTextureBlendType type) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); break; default: - llerrs << "Unknown Texture Blend Type: " << type << llendl; + LL_ERRS() << "Unknown Texture Blend Type: " << type << LL_ENDL; break; } setColorScale(scale_amount); @@ -597,7 +597,7 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src) return GL_CONSTANT_ARB; default: - llwarns << "Unknown eTextureBlendSrc: " << src << ". Using Vertex Color instead." << llendl; + LL_WARNS() << "Unknown eTextureBlendSrc: " << src << ". Using Vertex Color instead." << LL_ENDL; return GL_PRIMARY_COLOR_ARB; } } @@ -635,7 +635,7 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha) return GL_ONE_MINUS_SRC_ALPHA; default: - llwarns << "Unknown eTextureBlendSrc: " << src << ". Using Source Color or Alpha instead." << llendl; + LL_WARNS() << "Unknown eTextureBlendSrc: " << src << ". Using Source Color or Alpha instead." << LL_ENDL; return (isAlpha) ? GL_SRC_ALPHA: GL_SRC_COLOR; } } @@ -776,7 +776,7 @@ void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eT break; default: - llwarns << "Unknown eTextureBlendOp: " << op << ". Setting op to replace." << llendl; + LL_WARNS() << "Unknown eTextureBlendOp: " << op << ". Setting op to replace." << LL_ENDL; // Slightly special syntax (no second sources), just set all and return. glTexEnvi(GL_TEXTURE_ENV, comb_enum, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, src0_enum, source1); @@ -824,7 +824,7 @@ void LLTexUnit::debugTextureUnit(void) if ((GL_TEXTURE0_ARB + mIndex) != activeTexture) { U32 set_unit = (activeTexture - GL_TEXTURE0_ARB); - llwarns << "Incorrect Texture Unit! Expected: " << set_unit << " Actual: " << mIndex << llendl; + LL_WARNS() << "Incorrect Texture Unit! Expected: " << set_unit << " Actual: " << mIndex << LL_ENDL; } } @@ -1403,7 +1403,7 @@ void LLRender::pushMatrix() } else { - llwarns << "Matrix stack overflow." << llendl; + LL_WARNS() << "Matrix stack overflow." << LL_ENDL; } } } @@ -1419,7 +1419,7 @@ void LLRender::popMatrix() } else { - llwarns << "Matrix stack underflow." << llendl; + LL_WARNS() << "Matrix stack underflow." << LL_ENDL; } } } @@ -1492,7 +1492,7 @@ void LLRender::translateUI(F32 x, F32 y, F32 z) { if (mUIOffset.empty()) { - llerrs << "Need to push a UI translation frame before offsetting" << llendl; + LL_ERRS() << "Need to push a UI translation frame before offsetting" << LL_ENDL; } mUIOffset.back().mV[0] += x; @@ -1504,7 +1504,7 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z) { if (mUIScale.empty()) { - llerrs << "Need to push a UI transformation frame before scaling." << llendl; + LL_ERRS() << "Need to push a UI transformation frame before scaling." << LL_ENDL; } mUIScale.back().scaleVec(LLVector3(x,y,z)); @@ -1535,7 +1535,7 @@ void LLRender::popUIMatrix() { if (mUIOffset.empty()) { - llerrs << "UI offset stack blown." << llendl; + LL_ERRS() << "UI offset stack blown." << LL_ENDL; } mUIOffset.pop_back(); mUIScale.pop_back(); @@ -1564,7 +1564,7 @@ void LLRender::loadUIIdentity() { if (mUIOffset.empty()) { - llerrs << "Need to push UI translation frame before clearing offset." << llendl; + LL_ERRS() << "Need to push UI translation frame before clearing offset." << LL_ENDL; } mUIOffset.back().setVec(0,0,0); mUIScale.back().setVec(1,1,1); @@ -1622,7 +1622,7 @@ void LLRender::setSceneBlendType(eBlendType type) blendFunc(BF_ONE, BF_ZERO); break; default: - llerrs << "Unknown Scene Blend Type: " << type << llendl; + LL_ERRS() << "Unknown Scene Blend Type: " << type << LL_ENDL; break; } } @@ -1663,7 +1663,7 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value) if (cur_func != sGLCompareFunc[func]) { - llerrs << "Alpha test function corrupted!" << llendl; + LL_ERRS() << "Alpha test function corrupted!" << LL_ENDL; } F32 ref = 0.f; @@ -1671,7 +1671,7 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value) if (ref != value) { - llerrs << "Alpha test value corrupted!" << llendl; + LL_ERRS() << "Alpha test value corrupted!" << LL_ENDL; } } } @@ -1701,7 +1701,7 @@ void LLRender::blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor, llassert(alpha_dfactor < BF_UNDEF); if (!gGLManager.mHasBlendFuncSeparate) { - LL_WARNS_ONCE("render") << "no glBlendFuncSeparateEXT(), using color-only blend func" << llendl; + LL_WARNS_ONCE("render") << "no glBlendFuncSeparateEXT(), using color-only blend func" << LL_ENDL; blendFunc(color_sfactor, color_dfactor); return; } @@ -1726,7 +1726,7 @@ LLTexUnit* LLRender::getTexUnit(U32 index) } else { - lldebugs << "Non-existing texture unit layer requested: " << index << llendl; + LL_DEBUGS() << "Non-existing texture unit layer requested: " << index << LL_ENDL; return mDummyTexUnit; } } @@ -1762,7 +1762,7 @@ bool LLRender::verifyTexUnitActive(U32 unitToVerify) } else { - llwarns << "TexUnit currently active: " << mCurrTextureUnitIndex << " (expecting " << unitToVerify << ")" << llendl; + LL_WARNS() << "TexUnit currently active: " << mCurrTextureUnitIndex << " (expecting " << unitToVerify << ")" << LL_ENDL; return false; } } @@ -1793,7 +1793,7 @@ void LLRender::begin(const GLuint& mode) } else if (mCount != 0) { - llerrs << "gGL.begin() called redundantly." << llendl; + LL_ERRS() << "gGL.begin() called redundantly." << LL_ENDL; } mMode = mode; @@ -1805,7 +1805,7 @@ void LLRender::end() if (mCount == 0) { return; - //IMM_ERRS << "GL begin and end called with no vertices specified." << llendl; + //IMM_ERRS << "GL begin and end called with no vertices specified." << LL_ENDL; } if ((mMode != LLRender::QUADS && @@ -1824,22 +1824,22 @@ void LLRender::flush() #if 0 if (!glIsEnabled(GL_VERTEX_ARRAY)) { - llerrs << "foo 1" << llendl; + LL_ERRS() << "foo 1" << LL_ENDL; } if (!glIsEnabled(GL_COLOR_ARRAY)) { - llerrs << "foo 2" << llendl; + LL_ERRS() << "foo 2" << LL_ENDL; } if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY)) { - llerrs << "foo 3" << llendl; + LL_ERRS() << "foo 3" << LL_ENDL; } if (glIsEnabled(GL_NORMAL_ARRAY)) { - llerrs << "foo 7" << llendl; + LL_ERRS() << "foo 7" << LL_ENDL; } GLvoid* pointer; @@ -1847,19 +1847,19 @@ void LLRender::flush() glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer); if (pointer != &(mBuffer[0].v)) { - llerrs << "foo 4" << llendl; + LL_ERRS() << "foo 4" << LL_ENDL; } glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer); if (pointer != &(mBuffer[0].c)) { - llerrs << "foo 5" << llendl; + LL_ERRS() << "foo 5" << LL_ENDL; } glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer); if (pointer != &(mBuffer[0].uv)) { - llerrs << "foo 6" << llendl; + LL_ERRS() << "foo 6" << LL_ENDL; } #endif @@ -1877,7 +1877,7 @@ void LLRender::flush() if (mCount%4 != 0) { count -= (mCount % 4); - llwarns << "Incomplete quad requested." << llendl; + LL_WARNS() << "Incomplete quad requested." << LL_ENDL; } } @@ -1886,7 +1886,7 @@ void LLRender::flush() if (mCount%3 != 0) { count -= (mCount % 3); - llwarns << "Incomplete triangle requested." << llendl; + LL_WARNS() << "Incomplete triangle requested." << LL_ENDL; } } @@ -1895,7 +1895,7 @@ void LLRender::flush() if (mCount%2 != 0) { count -= (mCount % 2); - llwarns << "Incomplete line requested." << llendl; + LL_WARNS() << "Incomplete line requested." << LL_ENDL; } } @@ -1945,7 +1945,7 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) if (mCount > 4094) { - // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl; + // LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL; return; } @@ -1988,7 +1988,7 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count) { if (mCount + vert_count > 4094) { - // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl; + // LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL; return; } @@ -2045,7 +2045,7 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 v { if (mCount + vert_count > 4094) { - // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl; + // LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL; return; } @@ -2103,7 +2103,7 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLCol { if (mCount + vert_count > 4094) { - // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl; + // LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL; return; } diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp index d3cfbaf03a..df5d79a436 100644 --- a/indra/llrender/llrender2dutils.cpp +++ b/indra/llrender/llrender2dutils.cpp @@ -35,6 +35,7 @@ #include "llrect.h" #include "llgl.h" #include "lltexture.h" +#include "llfasttimer.h" // Project includes #include "llrender2dutils.h" @@ -347,27 +348,32 @@ void gl_draw_image( S32 x, S32 y, LLTexture* image, const LLColor4& color, const { if (NULL == image) { - llwarns << "image == NULL; aborting function" << llendl; + LL_WARNS() << "image == NULL; aborting function" << LL_ENDL; return; } gl_draw_scaled_rotated_image( x, y, image->getWidth(0), image->getHeight(0), 0.f, image, color, uv_rect ); } +void gl_draw_scaled_target(S32 x, S32 y, S32 width, S32 height, LLRenderTarget* target, const LLColor4& color, const LLRectf& uv_rect) +{ + gl_draw_scaled_rotated_image(x, y, width, height, 0.f, NULL, color, uv_rect, target); +} + void gl_draw_scaled_image(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, const LLRectf& uv_rect) { if (NULL == image) { - llwarns << "image == NULL; aborting function" << llendl; + LL_WARNS() << "image == NULL; aborting function" << LL_ENDL; return; } gl_draw_scaled_rotated_image( x, y, width, height, 0.f, image, color, uv_rect ); } -void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border_height, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_rect) +void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border_height, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_rect, bool scale_inner) { if (NULL == image) { - llwarns << "image == NULL; aborting function" << llendl; + LL_WARNS() << "image == NULL; aborting function" << LL_ENDL; return; } @@ -376,250 +382,273 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border F32 border_height_fraction = (F32)border_height / (F32)image->getHeight(0); LLRectf scale_rect(border_width_fraction, 1.f - border_height_fraction, 1.f - border_width_fraction, border_height_fraction); - gl_draw_scaled_image_with_border(x, y, width, height, image, color, solid_color, uv_rect, scale_rect); + gl_draw_scaled_image_with_border(x, y, width, height, image, color, solid_color, uv_rect, scale_rect, scale_inner); } -void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_outer_rect, const LLRectf& center_rect) +void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_outer_rect, const LLRectf& center_rect, bool scale_inner) { stop_glerror(); if (NULL == image) { - llwarns << "image == NULL; aborting function" << llendl; + LL_WARNS() << "image == NULL; aborting function" << LL_ENDL; return; } - // add in offset of current image to current UI translation - const LLVector3 ui_scale = gGL.getUIScale(); - const LLVector3 ui_translation = (gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale); - - F32 uv_width = uv_outer_rect.getWidth(); - F32 uv_height = uv_outer_rect.getHeight(); - - // shrink scaling region to be proportional to clipped image region - LLRectf uv_center_rect( - uv_outer_rect.mLeft + (center_rect.mLeft * uv_width), - uv_outer_rect.mBottom + (center_rect.mTop * uv_height), - uv_outer_rect.mLeft + (center_rect.mRight * uv_width), - uv_outer_rect.mBottom + (center_rect.mBottom * uv_height)); - - F32 image_width = image->getWidth(0); - F32 image_height = image->getHeight(0); + if (solid_color) + { + if (LLGLSLShader::sNoFixedFunction) + { + gSolidColorProgram.bind(); + } + else + { + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); + gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); + } + } - S32 image_natural_width = llround(image_width * uv_width); - S32 image_natural_height = llround(image_height * uv_height); + if (center_rect.mLeft == 0.f + && center_rect.mRight == 1.f + && center_rect.mBottom == 0.f + && center_rect.mTop == 1.f) + { + gl_draw_scaled_image(x, y, width, height, image, color, uv_outer_rect); + } + else + { + // add in offset of current image to current UI translation + const LLVector3 ui_scale = gGL.getUIScale(); + const LLVector3 ui_translation = (gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale); - LLRectf draw_center_rect( uv_center_rect.mLeft * image_width, - uv_center_rect.mTop * image_height, - uv_center_rect.mRight * image_width, - uv_center_rect.mBottom * image_height); + F32 uv_width = uv_outer_rect.getWidth(); + F32 uv_height = uv_outer_rect.getHeight(); - { // scale fixed region of image to drawn region - draw_center_rect.mRight += width - image_natural_width; - draw_center_rect.mTop += height - image_natural_height; + // shrink scaling region to be proportional to clipped image region + LLRectf uv_center_rect( uv_outer_rect.mLeft + (center_rect.mLeft * uv_width), + uv_outer_rect.mBottom + (center_rect.mTop * uv_height), + uv_outer_rect.mLeft + (center_rect.mRight * uv_width), + uv_outer_rect.mBottom + (center_rect.mBottom * uv_height)); - F32 border_shrink_width = llmax(0.f, draw_center_rect.mLeft - draw_center_rect.mRight); - F32 border_shrink_height = llmax(0.f, draw_center_rect.mBottom - draw_center_rect.mTop); + F32 image_width = image->getWidth(0); + F32 image_height = image->getHeight(0); - F32 shrink_width_ratio = center_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image_natural_width * (1.f - center_rect.getWidth())); - F32 shrink_height_ratio = center_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image_natural_height * (1.f - center_rect.getHeight())); + S32 image_natural_width = llround(image_width * uv_width); + S32 image_natural_height = llround(image_height * uv_height); - F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio); + LLRectf draw_center_rect( uv_center_rect.mLeft * image_width, + uv_center_rect.mTop * image_height, + uv_center_rect.mRight * image_width, + uv_center_rect.mBottom * image_height); + + if (scale_inner) + { + // scale center region of image to drawn region + draw_center_rect.mRight += width - image_natural_width; + draw_center_rect.mTop += height - image_natural_height; - draw_center_rect.mLeft = llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]); - draw_center_rect.mTop = llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale) * ui_scale.mV[VY]); - draw_center_rect.mRight = llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale) * ui_scale.mV[VX]); - draw_center_rect.mBottom = llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]); - } + const F32 border_shrink_width = llmax(0.f, draw_center_rect.mLeft - draw_center_rect.mRight); + const F32 border_shrink_height = llmax(0.f, draw_center_rect.mBottom - draw_center_rect.mTop); - LLRectf draw_outer_rect(ui_translation.mV[VX], - ui_translation.mV[VY] + height * ui_scale.mV[VY], - ui_translation.mV[VX] + width * ui_scale.mV[VX], - ui_translation.mV[VY]); + const F32 shrink_width_ratio = center_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image_natural_width * (1.f - center_rect.getWidth())); + const F32 shrink_height_ratio = center_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image_natural_height * (1.f - center_rect.getHeight())); - LLGLSUIDefault gls_ui; - - if (solid_color) - { - if (LLGLSLShader::sNoFixedFunction) - { - gSolidColorProgram.bind(); + const F32 border_shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio); + draw_center_rect.mLeft *= border_shrink_scale; + draw_center_rect.mTop = lerp((F32)height, (F32)draw_center_rect.mTop, border_shrink_scale); + draw_center_rect.mRight = lerp((F32)width, (F32)draw_center_rect.mRight, border_shrink_scale); + draw_center_rect.mBottom *= border_shrink_scale; } else { - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); + // keep center region of image at fixed scale, but in same relative position + F32 scale_factor = llmin((F32)width / draw_center_rect.getWidth(), (F32)height / draw_center_rect.getHeight(), 1.f); + F32 scaled_width = draw_center_rect.getWidth() * scale_factor; + F32 scaled_height = draw_center_rect.getHeight() * scale_factor; + draw_center_rect.setCenterAndSize(uv_center_rect.getCenterX() * width, uv_center_rect.getCenterY() * height, scaled_width, scaled_height); } - } - gGL.getTexUnit(0)->bind(image, true); + draw_center_rect.mLeft = llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * ui_scale.mV[VX]); + draw_center_rect.mTop = llround(ui_translation.mV[VY] + (F32)draw_center_rect.mTop * ui_scale.mV[VY]); + draw_center_rect.mRight = llround(ui_translation.mV[VX] + (F32)draw_center_rect.mRight * ui_scale.mV[VX]); + draw_center_rect.mBottom = llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * ui_scale.mV[VY]); - gGL.color4fv(color.mV); + LLRectf draw_outer_rect(ui_translation.mV[VX], + ui_translation.mV[VY] + height * ui_scale.mV[VY], + ui_translation.mV[VX] + width * ui_scale.mV[VX], + ui_translation.mV[VY]); + + LLGLSUIDefault gls_ui; + + gGL.getTexUnit(0)->bind(image, true); + + gGL.color4fv(color.mV); - const S32 NUM_VERTICES = 9 * 4; // 9 quads - LLVector2 uv[NUM_VERTICES]; - LLVector3 pos[NUM_VERTICES]; + const S32 NUM_VERTICES = 9 * 4; // 9 quads + LLVector2 uv[NUM_VERTICES]; + LLVector3 pos[NUM_VERTICES]; - S32 index = 0; + S32 index = 0; - gGL.begin(LLRender::QUADS); - { - // draw bottom left - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mBottom, 0.f); - index++; + gGL.begin(LLRender::QUADS); + { + // draw bottom left + uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mBottom); + pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); + index++; - // draw bottom middle - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); - index++; + // draw bottom middle + uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + index++; - // draw bottom right - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); - index++; + // draw bottom right + uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mBottom); + pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + index++; - // draw left - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); - index++; + // draw left + uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop); + pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; - // draw middle - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); - index++; + // draw middle + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; - // draw right - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); - index++; + // draw right + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom); + pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop); + pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; - // draw top left - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); - index++; + // draw top left + uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop); + pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mTop); + pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mTop, 0.f); + index++; - // draw top middle - uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); - index++; + // draw top middle + uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f); + index++; - // draw top right - uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); - index++; + // draw top right + uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop); + pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mTop); + pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mTop, 0.f); + index++; - uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop); - pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); - index++; + uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop); + pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f); + index++; - gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES); + gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES); + } + gGL.end(); } - gGL.end(); if (solid_color) { @@ -639,18 +668,24 @@ void gl_draw_rotated_image(S32 x, S32 y, F32 degrees, LLTexture* image, const LL gl_draw_scaled_rotated_image( x, y, image->getWidth(0), image->getHeight(0), degrees, image, color, uv_rect ); } -void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degrees, LLTexture* image, const LLColor4& color, const LLRectf& uv_rect) +void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degrees, LLTexture* image, const LLColor4& color, const LLRectf& uv_rect, LLRenderTarget* target) { - if (NULL == image) + if (!image && !target) { - llwarns << "image == NULL; aborting function" << llendl; + LL_WARNS() << "image == NULL; aborting function" << LL_ENDL; return; } LLGLSUIDefault gls_ui; - - gGL.getTexUnit(0)->bind(image, true); + if(image != NULL) + { + gGL.getTexUnit(0)->bind(image, true); + } + else + { + gGL.getTexUnit(0)->bind(target); + } gGL.color4fv(color.mV); @@ -695,18 +730,25 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre { gGL.pushUIMatrix(); gGL.translateUI((F32)x, (F32)y, 0.f); - + F32 offset_x = F32(width/2); F32 offset_y = F32(height/2); gGL.translateUI(offset_x, offset_y, 0.f); LLMatrix3 quat(0.f, 0.f, degrees*DEG_TO_RAD); - - gGL.getTexUnit(0)->bind(image, true); + + if(image != NULL) + { + gGL.getTexUnit(0)->bind(image, true); + } + else + { + gGL.getTexUnit(0)->bind(target); + } gGL.color4fv(color.mV); - + gGL.begin(LLRender::QUADS); { LLVector3 v; @@ -732,7 +774,6 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre } } - void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LLColor4& color, F32 phase ) { phase = fmod(phase, 1.f); @@ -1044,6 +1085,8 @@ void gl_rect_2d_simple( S32 width, S32 height ) gGL.end(); } +static LLTrace::BlockTimerStatHandle FTM_RENDER_SEGMENTED_RECT ("Render segmented rectangle"); + void gl_segmented_rect_2d_tex(const S32 left, const S32 top, const S32 right, @@ -1053,6 +1096,8 @@ void gl_segmented_rect_2d_tex(const S32 left, const S32 border_size, const U32 edges) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_SEGMENTED_RECT); + S32 width = llabs(right - left); S32 height = llabs(top - bottom); @@ -1202,18 +1247,19 @@ void gl_segmented_rect_2d_tex(const S32 left, gGL.popUIMatrix(); } -//FIXME: rewrite to use scissor? -void gl_segmented_rect_2d_fragment_tex(const S32 left, - const S32 top, - const S32 right, - const S32 bottom, - const S32 texture_width, - const S32 texture_height, - const S32 border_size, - const F32 start_fragment, - const F32 end_fragment, - const U32 edges) +void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, + const S32 texture_width, + const S32 texture_height, + const S32 border_size, + const F32 start_fragment, + const F32 end_fragment, + const U32 edges) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_SEGMENTED_RECT); + const S32 left = rect.mLeft; + const S32 right = rect.mRight; + const S32 top = rect.mTop; + const S32 bottom = rect.mBottom; S32 width = llabs(right - left); S32 height = llabs(top - bottom); @@ -1251,9 +1297,9 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left, { if (start_fragment < middle_start) { - u_min = (start_fragment / middle_start) * border_uv_scale.mV[VX]; + u_min = (start_fragment / middle_start) * border_uv_scale.mV[VX]; u_max = llmin(end_fragment / middle_start, 1.f) * border_uv_scale.mV[VX]; - x_min = (start_fragment / middle_start) * border_width_left; + x_min = (start_fragment / middle_start) * border_width_left; x_max = llmin(end_fragment / middle_start, 1.f) * border_width_left; // draw bottom left @@ -1281,7 +1327,7 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left, gGL.texCoord2f(u_min, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + height_vec - border_height_top).mV); - + // draw top left gGL.texCoord2f(u_min, 1.f - border_uv_scale.mV[VY]); gGL.vertex2fv((x_min + height_vec - border_height_top).mV); @@ -1343,10 +1389,10 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left, if (end_fragment > middle_end) { - u_min = (1.f - llmax(0.f, ((start_fragment - middle_end) / middle_start))) * border_uv_scale.mV[VX]; - u_max = (1.f - ((end_fragment - middle_end) / middle_start)) * border_uv_scale.mV[VX]; - x_min = width_vec - ((1.f - llmax(0.f, ((start_fragment - middle_end) / middle_start))) * border_width_right); - x_max = width_vec - ((1.f - ((end_fragment - middle_end) / middle_start)) * border_width_right); + u_min = 1.f - ((1.f - llmax(0.f, (start_fragment - middle_end) / middle_start)) * border_uv_scale.mV[VX]); + u_max = 1.f - ((1.f - ((end_fragment - middle_end) / middle_start)) * border_uv_scale.mV[VX]); + x_min = width_vec - ((1.f - llmax(0.f, (start_fragment - middle_end) / middle_start)) * border_width_right); + x_max = width_vec - ((1.f - ((end_fragment - middle_end) / middle_start)) * border_width_right); // draw bottom right gGL.texCoord2f(u_min, 0.f); @@ -1396,6 +1442,8 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left, void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv_rect, const LLRectf& center_draw_rect, const LLVector3& width_vec, const LLVector3& height_vec) { + LL_RECORD_BLOCK_TIME(FTM_RENDER_SEGMENTED_RECT); + gGL.begin(LLRender::QUADS); { // draw bottom left diff --git a/indra/llrender/llrender2dutils.h b/indra/llrender/llrender2dutils.h index 4884422c58..cce3b4ed51 100644 --- a/indra/llrender/llrender2dutils.h +++ b/indra/llrender/llrender2dutils.h @@ -71,11 +71,12 @@ void gl_washer_2d(F32 outer_radius, F32 inner_radius, S32 steps, const LLColor4& void gl_washer_segment_2d(F32 outer_radius, F32 inner_radius, F32 start_radians, F32 end_radians, S32 steps, const LLColor4& inner_color, const LLColor4& outer_color); void gl_draw_image(S32 x, S32 y, LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f)); +void gl_draw_scaled_target(S32 x, S32 y, S32 width, S32 height, LLRenderTarget* target, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f)); void gl_draw_scaled_image(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f)); void gl_draw_rotated_image(S32 x, S32 y, F32 degrees, LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f)); -void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degrees,LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f)); -void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border_height, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f)); -void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f), const LLRectf& scale_rect = LLRectf(0.f, 1.f, 1.f, 0.f)); +void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degrees, LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f), LLRenderTarget* target = NULL); +void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border_height, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f), bool scale_inner = true); +void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f), const LLRectf& scale_rect = LLRectf(0.f, 1.f, 1.f, 0.f), bool scale_inner = true); void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LLColor4& color, F32 phase = 0.f ); @@ -105,7 +106,7 @@ typedef enum e_rounded_edge void gl_segmented_rect_2d_tex(const S32 left, const S32 top, const S32 right, const S32 bottom, const S32 texture_width, const S32 texture_height, const S32 border_size, const U32 edges = ROUNDED_RECT_ALL); -void gl_segmented_rect_2d_fragment_tex(const S32 left, const S32 top, const S32 right, const S32 bottom, const S32 texture_width, const S32 texture_height, const S32 border_size, const F32 start_fragment, const F32 end_fragment, const U32 edges = ROUNDED_RECT_ALL); +void gl_segmented_rect_2d_fragment_tex(const LLRect& rect, const S32 texture_width, const S32 texture_height, const S32 border_size, const F32 start_fragment, const F32 end_fragment, const U32 edges = ROUNDED_RECT_ALL); void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv_rect, const LLRectf& center_draw_rect, const LLVector3& width_vec, const LLVector3& height_vec); inline void gl_rect_2d( const LLRect& rect, BOOL filled ) diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index fe8110904d..955ea450c1 100755 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -43,7 +43,7 @@ void check_framebuffer_status() case GL_FRAMEBUFFER_COMPLETE: break; default: - llwarns << "check_framebuffer_status failed -- " << std::hex << status << llendl; + LL_WARNS() << "check_framebuffer_status failed -- " << std::hex << status << LL_ENDL; ll_fail("check_framebuffer_status failed"); break; } @@ -139,7 +139,7 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo { if (!allocateDepth()) { - llwarns << "Failed to allocate depth buffer for render target." << llendl; + LL_WARNS() << "Failed to allocate depth buffer for render target." << LL_ENDL; return false; } } @@ -181,13 +181,13 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) if( offset >= 4 ) { - llwarns << "Too many color attachments" << llendl; + LL_WARNS() << "Too many color attachments" << LL_ENDL; llassert( offset < 4 ); return false; } if( offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers) ) { - llwarns << "FBO not used or no drawbuffers available; mFBO=" << (U32)mFBO << " gGLManager.mHasDrawBuffers=" << (U32)gGLManager.mHasDrawBuffers << llendl; + LL_WARNS() << "FBO not used or no drawbuffers available; mFBO=" << (U32)mFBO << " gGLManager.mHasDrawBuffers=" << (U32)gGLManager.mHasDrawBuffers << LL_ENDL; llassert( mFBO != 0 ); llassert( gGLManager.mHasDrawBuffers ); return false; @@ -205,7 +205,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false); if (glGetError() != GL_NO_ERROR) { - llwarns << "Could not allocate color buffer for render target." << llendl; + LL_WARNS() << "Could not allocate color buffer for render target." << LL_ENDL; return false; } } @@ -294,7 +294,7 @@ bool LLRenderTarget::allocateDepth() if (glGetError() != GL_NO_ERROR) { - llwarns << "Unable to allocate depth buffer for render target." << llendl; + LL_WARNS() << "Unable to allocate depth buffer for render target." << LL_ENDL; return false; } @@ -305,17 +305,17 @@ void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target) { if (!mFBO || !target.mFBO) { - llerrs << "Cannot share depth buffer between non FBO render targets." << llendl; + LL_ERRS() << "Cannot share depth buffer between non FBO render targets." << LL_ENDL; } if (target.mDepth) { - llerrs << "Attempting to override existing depth buffer. Detach existing buffer first." << llendl; + LL_ERRS() << "Attempting to override existing depth buffer. Detach existing buffer first." << LL_ENDL; } if (target.mUseDepth) { - llerrs << "Attempting to override existing shared depth buffer. Detach existing buffer first." << llendl; + LL_ERRS() << "Attempting to override existing shared depth buffer. Detach existing buffer first." << LL_ENDL; } if (mDepth) @@ -486,7 +486,7 @@ U32 LLRenderTarget::getTexture(U32 attachment) const { if (attachment > mTex.size()-1) { - llerrs << "Invalid attachment index." << llendl; + LL_ERRS() << "Invalid attachment index." << LL_ENDL; } if (mTex.empty()) { @@ -560,7 +560,7 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, gGL.flush(); if (!source.mFBO || !mFBO) { - llwarns << "Cannot copy framebuffer contents for non FBO render targets." << llendl; + LL_WARNS() << "Cannot copy framebuffer contents for non FBO render targets." << LL_ENDL; return; } @@ -603,7 +603,7 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0 { if (!source.mFBO) { - llwarns << "Cannot copy framebuffer contents for non FBO render targets." << llendl; + LL_WARNS() << "Cannot copy framebuffer contents for non FBO render targets." << LL_ENDL; return; } diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6e04fc82df..95a2c8b589 100755 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -600,7 +600,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade { //should NEVER get here -- if major version is 1 and minor version is less than 10, // viewer should never attempt to use shaders, continuing will result in undefined behavior - llerrs << "Unsupported GLSL Version." << llendl; + LL_ERRS() << "Unsupported GLSL Version." << LL_ENDL; } if (minor_version <= 19) @@ -767,7 +767,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade else { //should never get here. Indexed texture rendering requires GLSL 1.30 or later // (for passing integers between vertex and fragment shaders) - llerrs << "Indexed texture rendering requires GLSL 1.30 or later." << llendl; + LL_ERRS() << "Indexed texture rendering requires GLSL 1.30 or later." << LL_ENDL; } } else @@ -840,13 +840,13 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (i % 128 == 0) { //dump every 128 lines - LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl; + LL_WARNS("ShaderLoading") << "\n" << ostr.str() << LL_ENDL; ostr = std::stringstream(); } } - LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl; + LL_WARNS("ShaderLoading") << "\n" << ostr.str() << LL_ENDL; #else std::string str; @@ -855,7 +855,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (i % 128 == 0) { - LL_WARNS("ShaderLoading") << str << llendl; + LL_WARNS("ShaderLoading") << str << LL_ENDL; str = ""; } } @@ -1205,7 +1205,7 @@ void LLShaderMgr::initAttribsAndUniforms() { if (dupe_check.find(mReservedUniforms[i]) != dupe_check.end()) { - llerrs << "Duplicate reserved uniform name found: " << mReservedUniforms[i] << llendl; + LL_ERRS() << "Duplicate reserved uniform name found: " << mReservedUniforms[i] << LL_ENDL; } dupe_check.insert(mReservedUniforms[i]); } diff --git a/indra/llrender/lltexture.h b/indra/llrender/lltexture.h index 093bac20d1..9fca8b8cd3 100755 --- a/indra/llrender/lltexture.h +++ b/indra/llrender/lltexture.h @@ -33,6 +33,8 @@ #define LL_TEXTURE_H #include "llrefcount.h" +#include "lltrace.h" + class LLImageGL ; class LLTexUnit ; class LLFontGL ; @@ -40,7 +42,7 @@ class LLFontGL ; // //this is an abstract class as the parent for the class LLGLTexture // -class LLTexture : public virtual LLRefCount +class LLTexture : public virtual LLRefCount, public LLTrace::MemTrackable<LLTexture> { friend class LLTexUnit ; friend class LLFontGL ; @@ -49,7 +51,9 @@ protected: virtual ~LLTexture(); public: - LLTexture(){} + LLTexture() + : LLTrace::MemTrackable<LLTexture>("LLTexture") + {} // //interfaces to access LLGLTexture @@ -57,10 +61,12 @@ public: virtual S8 getType() const = 0 ; virtual void setKnownDrawSize(S32 width, S32 height) = 0 ; virtual bool bindDefaultImage(const S32 stage = 0) = 0 ; + virtual bool bindDebugImage(const S32 stage = 0) = 0; virtual void forceImmediateUpdate() = 0 ; virtual void setActive() = 0 ; virtual S32 getWidth(S32 discard_level = -1) const = 0 ; virtual S32 getHeight(S32 discard_level = -1) const = 0 ; + virtual bool isActiveFetching() = 0; private: //note: do not make this function public. diff --git a/indra/llrender/lluiimage.cpp b/indra/llrender/lluiimage.cpp index b954b66350..6f1fae92cd 100644 --- a/indra/llrender/lluiimage.cpp +++ b/indra/llrender/lluiimage.cpp @@ -38,11 +38,9 @@ LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image) mImage(image), mScaleRegion(0.f, 1.f, 1.f, 0.f), mClipRegion(0.f, 1.f, 1.f, 0.f), - mUniformScaling(TRUE), - mNoClip(TRUE), - mImageLoaded(NULL) -{ -} + mImageLoaded(NULL), + mScaleStyle(SCALE_INNER) +{} LLUIImage::~LLUIImage() { @@ -52,44 +50,35 @@ LLUIImage::~LLUIImage() void LLUIImage::setClipRegion(const LLRectf& region) { mClipRegion = region; - mNoClip = mClipRegion.mLeft == 0.f - && mClipRegion.mRight == 1.f - && mClipRegion.mBottom == 0.f - && mClipRegion.mTop == 1.f; } void LLUIImage::setScaleRegion(const LLRectf& region) { mScaleRegion = region; - mUniformScaling = mScaleRegion.mLeft == 0.f - && mScaleRegion.mRight == 1.f - && mScaleRegion.mBottom == 0.f - && mScaleRegion.mTop == 1.f; +} + +void LLUIImage::setScaleStyle(LLUIImage::EScaleStyle style) +{ + mScaleStyle = style; } //TODO: move drawing implementation inside class void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const { - gl_draw_scaled_image(x, y, getWidth(), getHeight(), mImage, color, mClipRegion); + draw(x, y, getWidth(), getHeight(), color); } void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const { - if (mUniformScaling) - { - gl_draw_scaled_image(x, y, width, height, mImage, color, mClipRegion); - } - else - { - gl_draw_scaled_image_with_border( - x, y, - width, height, - mImage, - color, - FALSE, - mClipRegion, - mScaleRegion); - } + gl_draw_scaled_image_with_border( + x, y, + width, height, + mImage, + color, + FALSE, + mClipRegion, + mScaleRegion, + mScaleStyle == SCALE_INNER); } void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const @@ -101,7 +90,8 @@ void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& c color, TRUE, mClipRegion, - mScaleRegion); + mScaleRegion, + mScaleStyle == SCALE_INNER); } void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const diff --git a/indra/llrender/lluiimage.h b/indra/llrender/lluiimage.h index 7817ba1c7b..6f47385eb0 100644 --- a/indra/llrender/lluiimage.h +++ b/indra/llrender/lluiimage.h @@ -42,6 +42,12 @@ extern const LLColor4 UI_VERTEX_COLOR; class LLUIImage : public LLRefCount { public: + enum EScaleStyle + { + SCALE_INNER, + SCALE_OUTER + }; + typedef boost::signals2::signal<void (void)> image_loaded_signal_t; LLUIImage(const std::string& name, LLPointer<LLTexture> image); @@ -49,6 +55,7 @@ public: void setClipRegion(const LLRectf& region); void setScaleRegion(const LLRectf& region); + void setScaleStyle(EScaleStyle style); LLPointer<LLTexture> getImage() { return mImage; } const LLPointer<LLTexture>& getImage() const { return mImage; } @@ -83,12 +90,11 @@ public: protected: image_loaded_signal_t* mImageLoaded; - std::string mName; - LLRectf mScaleRegion; - LLRectf mClipRegion; - LLPointer<LLTexture> mImage; - BOOL mUniformScaling; - BOOL mNoClip; + std::string mName; + LLRectf mScaleRegion; + LLRectf mClipRegion; + LLPointer<LLTexture> mImage; + EScaleStyle mScaleStyle; }; namespace LLInitParam diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index e6f20cd40e..d06564df36 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -26,7 +26,7 @@ #include "linden_common.h" -#include <boost/static_assert.hpp> +#include "llfasttimer.h" #include "llsys.h" #include "llvertexbuffer.h" // #include "llrender.h" @@ -190,7 +190,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) glBufferDataARB(mType, size, 0, mUsage); if (mUsage != GL_DYNAMIC_COPY_ARB) { //data will be provided by application - ret = (U8*) ll_aligned_malloc(size, 64); + ret = (U8*) ll_aligned_malloc<64>(size); } } else @@ -244,7 +244,7 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) llassert(vbo_block_size(size) == size); deleteBuffer(name); - ll_aligned_free((U8*) buffer); + ll_aligned_free_fallback((U8*) buffer); if (mType == GL_ARRAY_BUFFER_ARB) { @@ -298,7 +298,7 @@ void LLVBOPool::cleanup() if (r.mClientData) { - ll_aligned_free((void*) r.mClientData); + ll_aligned_free<64>((void*) r.mClientData); } l.pop_front(); @@ -484,7 +484,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) } else { - llerrs << "Bad client state! " << array[i] << " disabled." << llendl; + LL_ERRS() << "Bad client state! " << array[i] << " disabled." << LL_ENDL; } } } @@ -503,7 +503,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) } else { - llerrs << "Bad client state! " << array[i] << " enabled." << llendl; + LL_ERRS() << "Bad client state! " << array[i] << " enabled." << LL_ENDL; } } } @@ -557,10 +557,10 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask) } //static -static LLFastTimer::DeclareTimer FTM_VB_DRAW_ARRAYS("drawArrays"); +static LLTrace::BlockTimerStatHandle FTM_VB_DRAW_ARRAYS("drawArrays"); void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm) { - LLFastTimer t(FTM_VB_DRAW_ARRAYS); + LL_RECORD_BLOCK_TIME(FTM_VB_DRAW_ARRAYS); llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); gGL.syncMatrices(); @@ -571,13 +571,13 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, con if( count == 0 ) { - llwarns << "Called drawArrays with 0 vertices" << llendl; + LL_WARNS() << "Called drawArrays with 0 vertices" << LL_ENDL; return; } if( norm.size() < pos.size() ) { - llwarns << "Called drawArrays with #" << norm.size() << " normals and #" << pos.size() << " vertices" << llendl; + LL_WARNS() << "Called drawArrays with #" << norm.size() << " normals and #" << pos.size() << " vertices" << LL_ENDL; return; } @@ -654,7 +654,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of if (start >= (U32) mNumVerts || end >= (U32) mNumVerts) { - llerrs << "Bad vertex buffer draw range: [" << start << ", " << end << "] vs " << mNumVerts << llendl; + LL_ERRS() << "Bad vertex buffer draw range: [" << start << ", " << end << "] vs " << mNumVerts << LL_ENDL; } llassert(mNumIndices >= 0); @@ -662,7 +662,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of if (indices_offset >= (U32) mNumIndices || indices_offset + count > (U32) mNumIndices) { - llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; + LL_ERRS() << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << LL_ENDL; } if (gDebugGL && !useVBOs()) @@ -672,7 +672,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of { if (idx[i] < start || idx[i] > end) { - llerrs << "Index out of range: " << idx[i] << " not in [" << start << ", " << end << "]" << llendl; + LL_ERRS() << "Index out of range: " << idx[i] << " not in [" << start << ", " << end << "]" << LL_ENDL; } } @@ -690,7 +690,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of S32 idx = (S32) (v[i][3]+0.25f); if (idx < 0 || idx >= shader->mFeatures.mIndexedTextureChannels) { - llerrs << "Bad texture index found in vertex data stream." << llendl; + LL_ERRS() << "Bad texture index found in vertex data stream." << LL_ENDL; } } } @@ -710,19 +710,19 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi { if (mGLArray != sGLRenderArray) { - llerrs << "Wrong vertex array bound." << llendl; + LL_ERRS() << "Wrong vertex array bound." << LL_ENDL; } } else { if (mGLIndices != sGLRenderIndices) { - llerrs << "Wrong index buffer bound." << llendl; + LL_ERRS() << "Wrong index buffer bound." << LL_ENDL; } if (mGLBuffer != sGLRenderBuffer) { - llerrs << "Wrong vertex buffer bound." << llendl; + LL_ERRS() << "Wrong vertex buffer bound." << LL_ENDL; } } @@ -733,13 +733,13 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi if (elem != mGLIndices) { - llerrs << "Wrong index buffer bound!" << llendl; + LL_ERRS() << "Wrong index buffer bound!" << LL_ENDL; } } if (mode >= LLRender::NUM_MODES) { - llerrs << "Invalid draw mode: " << mode << llendl; + LL_ERRS() << "Invalid draw mode: " << mode << LL_ENDL; return; } @@ -767,32 +767,32 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const if (indices_offset >= (U32) mNumIndices || indices_offset + count > (U32) mNumIndices) { - llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; + LL_ERRS() << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << LL_ENDL; } if (mGLArray) { if (mGLArray != sGLRenderArray) { - llerrs << "Wrong vertex array bound." << llendl; + LL_ERRS() << "Wrong vertex array bound." << LL_ENDL; } } else { if (mGLIndices != sGLRenderIndices) { - llerrs << "Wrong index buffer bound." << llendl; + LL_ERRS() << "Wrong index buffer bound." << LL_ENDL; } if (mGLBuffer != sGLRenderBuffer) { - llerrs << "Wrong vertex buffer bound." << llendl; + LL_ERRS() << "Wrong vertex buffer bound." << LL_ENDL; } } if (mode >= LLRender::NUM_MODES) { - llerrs << "Invalid draw mode: " << mode << llendl; + LL_ERRS() << "Invalid draw mode: " << mode << LL_ENDL; return; } @@ -805,7 +805,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const placeFence(); } -static LLFastTimer::DeclareTimer FTM_GL_DRAW_ARRAYS("GL draw arrays"); +static LLTrace::BlockTimerStatHandle FTM_GL_DRAW_ARRAYS("GL draw arrays"); void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const { llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShaderPtr != NULL); @@ -816,37 +816,37 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const if (first >= (U32) mNumVerts || first + count > (U32) mNumVerts) { - llerrs << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << llendl; + LL_ERRS() << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << LL_ENDL; } if (mGLArray) { if (mGLArray != sGLRenderArray) { - llerrs << "Wrong vertex array bound." << llendl; + LL_ERRS() << "Wrong vertex array bound." << LL_ENDL; } } else { if (mGLBuffer != sGLRenderBuffer || useVBOs() != sVBOActive) { - llerrs << "Wrong vertex buffer bound." << llendl; + LL_ERRS() << "Wrong vertex buffer bound." << LL_ENDL; } } if (mode >= LLRender::NUM_MODES) { - llerrs << "Invalid draw mode: " << mode << llendl; + LL_ERRS() << "Invalid draw mode: " << mode << LL_ENDL; return; } { - LLFastTimer t2(FTM_GL_DRAW_ARRAYS); - stop_glerror(); + LL_RECORD_BLOCK_TIME(FTM_GL_DRAW_ARRAYS); + stop_glerror(); LLGLSLShader::startProfile(); - glDrawArrays(sGLMode[mode], first, count); + glDrawArrays(sGLMode[mode], first, count); LLGLSLShader::stopProfile(count, mode); - } + } stop_glerror(); placeFence(); @@ -956,7 +956,8 @@ S32 LLVertexBuffer::determineUsage(S32 usage) return ret_usage; } -LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : +LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) +: LLTrace::MemTrackable<LLVertexBuffer>("LLVertexBuffer"), LLRefCount(), mNumVerts(0), @@ -1093,7 +1094,9 @@ void LLVertexBuffer::waitFence() const void LLVertexBuffer::genBuffer(U32 size) { + disclaimMem(mSize); mSize = vbo_block_size(size); + claimMem(mSize); if (mUsage == GL_STREAM_DRAW_ARB) { @@ -1187,7 +1190,9 @@ void LLVertexBuffer::createGLBuffer(U32 size) static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); + disclaimMem(mSize); mSize = size; + claimMem(mSize); } } @@ -1271,7 +1276,7 @@ void LLVertexBuffer::updateNumVerts(S32 nverts) if (nverts > 65536) { - llwarns << "Vertex buffer overflow!" << llendl; + LL_WARNS() << "Vertex buffer overflow!" << LL_ENDL; nverts = 65536; } @@ -1310,7 +1315,7 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) if (nverts < 0 || nindices < 0 || nverts > 65536) { - llerrs << "Bad vertex buffer allocation: " << nverts << " : " << nindices << llendl; + LL_ERRS() << "Bad vertex buffer allocation: " << nverts << " : " << nindices << LL_ENDL; } updateNumVerts(nverts); @@ -1331,7 +1336,7 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) } } -static LLFastTimer::DeclareTimer FTM_SETUP_VERTEX_ARRAY("Setup VAO"); +static LLTrace::BlockTimerStatHandle FTM_SETUP_VERTEX_ARRAY("Setup VAO"); void LLVertexBuffer::setupVertexArray() { @@ -1340,7 +1345,7 @@ void LLVertexBuffer::setupVertexArray() return; } - LLFastTimer t(FTM_SETUP_VERTEX_ARRAY); + LL_RECORD_BLOCK_TIME(FTM_SETUP_VERTEX_ARRAY); #if GL_ARB_vertex_array_object glBindVertexArray(mGLArray); #endif @@ -1495,8 +1500,8 @@ bool expand_region(LLVertexBuffer::MappedRegion& region, S32 index, S32 count) return true; } -static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER_RANGE("VBO Map Range"); -static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map"); +static LLTrace::BlockTimerStatHandle FTM_VBO_MAP_BUFFER_RANGE("VBO Map Range"); +static LLTrace::BlockTimerStatHandle FTM_VBO_MAP_BUFFER("VBO Map"); // Map for data access volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) @@ -1504,11 +1509,11 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo bindGLBuffer(true); if (mFinal) { - llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl; + LL_ERRS() << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << LL_ENDL; } if (!useVBOs() && !mMappedData && !mMappedIndexData) { - llerrs << "LLVertexBuffer::mapVertexBuffer() called on unallocated buffer." << llendl; + LL_ERRS() << "LLVertexBuffer::mapVertexBuffer() called on unallocated buffer." << LL_ENDL; } if (useVBOs()) @@ -1545,7 +1550,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo if (mVertexLocked && map_range) { - llerrs << "Attempted to map a specific range of a buffer that was already mapped." << llendl; + LL_ERRS() << "Attempted to map a specific range of a buffer that was already mapped." << LL_ENDL; } if (!mVertexLocked) @@ -1567,7 +1572,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo if (map_range) { #ifdef GL_ARB_map_buffer_range - LLFastTimer t(FTM_VBO_MAP_BUFFER_RANGE); + LL_RECORD_BLOCK_TIME(FTM_VBO_MAP_BUFFER_RANGE); S32 offset = mOffsets[type] + sTypeSize[type]*index; S32 length = (sTypeSize[type]*count+0xF) & ~0xF; src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER_ARB, offset, length, @@ -1587,11 +1592,11 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo if (size < mSize) { - llerrs << "Invalid buffer size." << llendl; + LL_ERRS() << "Invalid buffer size." << LL_ENDL; } } - LLFastTimer t(FTM_VBO_MAP_BUFFER); + LL_RECORD_BLOCK_TIME(FTM_VBO_MAP_BUFFER); src = (U8*) glMapBufferRange(GL_ARRAY_BUFFER_ARB, 0, mSize, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); @@ -1638,25 +1643,25 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo { //-------------------- //print out more debug info before crash - llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl; + LL_INFOS() << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << LL_ENDL; GLint size; glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); - llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl; + LL_INFOS() << "GL_ARRAY_BUFFER_ARB size is " << size << LL_ENDL; //-------------------- GLint buff; glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); if ((GLuint)buff != mGLBuffer) { - llerrs << "Invalid GL vertex buffer bound: " << buff << llendl; + LL_ERRS() << "Invalid GL vertex buffer bound: " << buff << LL_ENDL; } - llerrs << "glMapBuffer returned NULL (no vertex data)" << llendl; + LL_ERRS() << "glMapBuffer returned NULL (no vertex data)" << LL_ENDL; } else { - llerrs << "memory allocation for vertex data failed." << llendl; + LL_ERRS() << "memory allocation for vertex data failed." << LL_ENDL; } } } @@ -1677,19 +1682,19 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo } -static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX_RANGE("IBO Map Range"); -static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX("IBO Map"); +static LLTrace::BlockTimerStatHandle FTM_VBO_MAP_INDEX_RANGE("IBO Map Range"); +static LLTrace::BlockTimerStatHandle FTM_VBO_MAP_INDEX("IBO Map"); volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) { bindGLIndices(true); if (mFinal) { - llerrs << "LLVertexBuffer::mapIndexBuffer() called on a finalized buffer." << llendl; + LL_ERRS() << "LLVertexBuffer::mapIndexBuffer() called on a finalized buffer." << LL_ENDL; } if (!useVBOs() && !mMappedData && !mMappedIndexData) { - llerrs << "LLVertexBuffer::mapIndexBuffer() called on unallocated buffer." << llendl; + LL_ERRS() << "LLVertexBuffer::mapIndexBuffer() called on unallocated buffer." << LL_ENDL; } if (useVBOs()) @@ -1723,7 +1728,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (mIndexLocked && map_range) { - llerrs << "Attempted to map a specific range of a buffer that was already mapped." << llendl; + LL_ERRS() << "Attempted to map a specific range of a buffer that was already mapped." << LL_ENDL; } if (!mIndexLocked) @@ -1739,7 +1744,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (elem != mGLIndices) { - llerrs << "Wrong index buffer bound!" << llendl; + LL_ERRS() << "Wrong index buffer bound!" << LL_ENDL; } } @@ -1756,7 +1761,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (map_range) { #ifdef GL_ARB_map_buffer_range - LLFastTimer t(FTM_VBO_MAP_INDEX_RANGE); + LL_RECORD_BLOCK_TIME(FTM_VBO_MAP_INDEX_RANGE); S32 offset = sizeof(U16)*index; S32 length = sizeof(U16)*count; src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, @@ -1768,7 +1773,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range else { #ifdef GL_ARB_map_buffer_range - LLFastTimer t(FTM_VBO_MAP_INDEX); + LL_RECORD_BLOCK_TIME(FTM_VBO_MAP_INDEX); src = (U8*) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, sizeof(U16)*mNumIndices, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); @@ -1792,7 +1797,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range } else { - LLFastTimer t(FTM_VBO_MAP_INDEX); + LL_RECORD_BLOCK_TIME(FTM_VBO_MAP_INDEX); map_range = false; src = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); } @@ -1817,14 +1822,14 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); if ((GLuint)buff != mGLIndices) { - llerrs << "Invalid GL index buffer bound: " << buff << llendl; + LL_ERRS() << "Invalid GL index buffer bound: " << buff << LL_ENDL; } - llerrs << "glMapBuffer returned NULL (no index data)" << llendl; + LL_ERRS() << "glMapBuffer returned NULL (no index data)" << LL_ENDL; } else { - llerrs << "memory allocation for Index data failed. " << llendl; + LL_ERRS() << "memory allocation for Index data failed. " << LL_ENDL; } } } @@ -1843,12 +1848,12 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range } } -static LLFastTimer::DeclareTimer FTM_VBO_UNMAP("VBO Unmap"); -static LLFastTimer::DeclareTimer FTM_VBO_FLUSH_RANGE("Flush VBO Range"); +static LLTrace::BlockTimerStatHandle FTM_VBO_UNMAP("VBO Unmap"); +static LLTrace::BlockTimerStatHandle FTM_VBO_FLUSH_RANGE("Flush VBO Range"); -static LLFastTimer::DeclareTimer FTM_IBO_UNMAP("IBO Unmap"); -static LLFastTimer::DeclareTimer FTM_IBO_FLUSH_RANGE("Flush IBO Range"); +static LLTrace::BlockTimerStatHandle FTM_IBO_UNMAP("IBO Unmap"); +static LLTrace::BlockTimerStatHandle FTM_IBO_FLUSH_RANGE("Flush IBO Range"); void LLVertexBuffer::unmapBuffer() { @@ -1861,7 +1866,7 @@ void LLVertexBuffer::unmapBuffer() if (mMappedData && mVertexLocked) { - LLFastTimer t(FTM_VBO_UNMAP); + LL_RECORD_BLOCK_TIME(FTM_VBO_UNMAP); bindGLBuffer(true); updated_all = mIndexLocked; //both vertex and index buffers done updating @@ -1902,7 +1907,7 @@ void LLVertexBuffer::unmapBuffer() S32 length = sTypeSize[region.mType]*region.mCount; if (gGLManager.mHasMapBufferRange) { - LLFastTimer t(FTM_VBO_FLUSH_RANGE); + LL_RECORD_BLOCK_TIME(FTM_VBO_FLUSH_RANGE); #ifdef GL_ARB_map_buffer_range glFlushMappedBufferRange(GL_ARRAY_BUFFER_ARB, offset, length); #endif @@ -1932,7 +1937,7 @@ void LLVertexBuffer::unmapBuffer() if (mMappedIndexData && mIndexLocked) { - LLFastTimer t(FTM_IBO_UNMAP); + LL_RECORD_BLOCK_TIME(FTM_IBO_UNMAP); bindGLIndices(); if(!mMappable) { @@ -1969,7 +1974,7 @@ void LLVertexBuffer::unmapBuffer() S32 length = sizeof(U16)*region.mCount; if (gGLManager.mHasMapBufferRange) { - LLFastTimer t(FTM_IBO_FLUSH_RANGE); + LL_RECORD_BLOCK_TIME(FTM_IBO_FLUSH_RANGE); #ifdef GL_ARB_map_buffer_range glFlushMappedBufferRange(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length); #endif @@ -2020,7 +2025,7 @@ template <class T,S32 type> struct VertexBufferStrider if (ptr == NULL) { - llwarns << "mapIndexBuffer failed!" << llendl; + LL_WARNS() << "mapIndexBuffer failed!" << LL_ENDL; return false; } @@ -2036,7 +2041,7 @@ template <class T,S32 type> struct VertexBufferStrider if (ptr == NULL) { - llwarns << "mapVertexBuffer failed!" << llendl; + LL_WARNS() << "mapVertexBuffer failed!" << LL_ENDL; return false; } @@ -2046,7 +2051,7 @@ template <class T,S32 type> struct VertexBufferStrider } else { - llerrs << "VertexBufferStrider could not find valid vertex data." << llendl; + LL_ERRS() << "VertexBufferStrider could not find valid vertex data." << LL_ENDL; } return false; } @@ -2113,13 +2118,13 @@ bool LLVertexBuffer::getClothWeightStrider(LLStrider<LLVector4>& strider, S32 in //---------------------------------------------------------------------------- -static LLFastTimer::DeclareTimer FTM_BIND_GL_ARRAY("Bind Array"); +static LLTrace::BlockTimerStatHandle FTM_BIND_GL_ARRAY("Bind Array"); bool LLVertexBuffer::bindGLArray() { if (mGLArray && sGLRenderArray != mGLArray) { { - LLFastTimer t(FTM_BIND_GL_ARRAY); + LL_RECORD_BLOCK_TIME(FTM_BIND_GL_ARRAY); #if GL_ARB_vertex_array_object glBindVertexArray(mGLArray); #endif @@ -2136,7 +2141,7 @@ bool LLVertexBuffer::bindGLArray() return false; } -static LLFastTimer::DeclareTimer FTM_BIND_GL_BUFFER("Bind Buffer"); +static LLTrace::BlockTimerStatHandle FTM_BIND_GL_BUFFER("Bind Buffer"); bool LLVertexBuffer::bindGLBuffer(bool force_bind) { @@ -2146,7 +2151,7 @@ bool LLVertexBuffer::bindGLBuffer(bool force_bind) if (useVBOs() && (force_bind || (mGLBuffer && (mGLBuffer != sGLRenderBuffer || !sVBOActive)))) { - //LLFastTimer t(FTM_BIND_GL_BUFFER); <-- this timer is showing up as a hotspot (irony) + //LL_RECORD_BLOCK_TIME(FTM_BIND_GL_BUFFER); glBindBufferARB(GL_ARRAY_BUFFER_ARB, mGLBuffer); sGLRenderBuffer = mGLBuffer; @@ -2161,7 +2166,7 @@ bool LLVertexBuffer::bindGLBuffer(bool force_bind) return ret; } -static LLFastTimer::DeclareTimer FTM_BIND_GL_INDICES("Bind Indices"); +static LLTrace::BlockTimerStatHandle FTM_BIND_GL_INDICES("Bind Indices"); bool LLVertexBuffer::bindGLIndices(bool force_bind) { @@ -2170,10 +2175,10 @@ bool LLVertexBuffer::bindGLIndices(bool force_bind) bool ret = false; if (useVBOs() && (force_bind || (mGLIndices && (mGLIndices != sGLRenderIndices || !sIBOActive)))) { - LLFastTimer t(FTM_BIND_GL_INDICES); + LL_RECORD_BLOCK_TIME(FTM_BIND_GL_INDICES); /*if (sMapped) { - llerrs << "VBO bound while another VBO mapped!" << llendl; + LL_ERRS() << "VBO bound while another VBO mapped!" << LL_ENDL; }*/ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mGLIndices); sGLRenderIndices = mGLIndices; @@ -2225,7 +2230,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) U32 required = 1 << i; if ((data_mask & required) == 0) { - llwarns << "Missing attribute: " << LLShaderMgr::instance()->mReservedAttribs[i] << llendl; + LL_WARNS() << "Missing attribute: " << LLShaderMgr::instance()->mReservedAttribs[i] << LL_ENDL; } required_mask |= required; @@ -2243,29 +2248,29 @@ void LLVertexBuffer::setBuffer(U32 data_mask) U32 unsatisfied_flag = unsatisfied_mask & (1 << i); switch (unsatisfied_flag) { - case MAP_VERTEX: llinfos << "Missing vert pos" << llendl; break; - case MAP_NORMAL: llinfos << "Missing normals" << llendl; break; - case MAP_TEXCOORD0: llinfos << "Missing TC 0" << llendl; break; - case MAP_TEXCOORD1: llinfos << "Missing TC 1" << llendl; break; - case MAP_TEXCOORD2: llinfos << "Missing TC 2" << llendl; break; - case MAP_TEXCOORD3: llinfos << "Missing TC 3" << llendl; break; - case MAP_COLOR: llinfos << "Missing vert color" << llendl; break; - case MAP_EMISSIVE: llinfos << "Missing emissive" << llendl; break; - case MAP_TANGENT: llinfos << "Missing tangent" << llendl; break; - case MAP_WEIGHT: llinfos << "Missing weight" << llendl; break; - case MAP_WEIGHT4: llinfos << "Missing weightx4" << llendl; break; - case MAP_CLOTHWEIGHT: llinfos << "Missing clothweight" << llendl; break; - case MAP_TEXTURE_INDEX: llinfos << "Missing tex index" << llendl; break; - default: llinfos << "Missing who effin knows: " << unsatisfied_flag << llendl; + case MAP_VERTEX: LL_INFOS() << "Missing vert pos" << LL_ENDL; break; + case MAP_NORMAL: LL_INFOS() << "Missing normals" << LL_ENDL; break; + case MAP_TEXCOORD0: LL_INFOS() << "Missing TC 0" << LL_ENDL; break; + case MAP_TEXCOORD1: LL_INFOS() << "Missing TC 1" << LL_ENDL; break; + case MAP_TEXCOORD2: LL_INFOS() << "Missing TC 2" << LL_ENDL; break; + case MAP_TEXCOORD3: LL_INFOS() << "Missing TC 3" << LL_ENDL; break; + case MAP_COLOR: LL_INFOS() << "Missing vert color" << LL_ENDL; break; + case MAP_EMISSIVE: LL_INFOS() << "Missing emissive" << LL_ENDL; break; + case MAP_TANGENT: LL_INFOS() << "Missing tangent" << LL_ENDL; break; + case MAP_WEIGHT: LL_INFOS() << "Missing weight" << LL_ENDL; break; + case MAP_WEIGHT4: LL_INFOS() << "Missing weightx4" << LL_ENDL; break; + case MAP_CLOTHWEIGHT: LL_INFOS() << "Missing clothweight" << LL_ENDL; break; + case MAP_TEXTURE_INDEX: LL_INFOS() << "Missing tex index" << LL_ENDL; break; + default: LL_INFOS() << "Missing who effin knows: " << unsatisfied_flag << LL_ENDL; } } if (unsatisfied_mask & (1 << TYPE_INDEX)) { - llinfos << "Missing indices" << llendl; + LL_INFOS() << "Missing indices" << LL_ENDL; } - llerrs << "Shader consumption mismatches data provision." << llendl; + LL_ERRS() << "Shader consumption mismatches data provision." << LL_ENDL; } } } @@ -2297,7 +2302,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) } else { - llerrs << "Invalid GL vertex buffer bound: " << buff << llendl; + LL_ERRS() << "Invalid GL vertex buffer bound: " << buff << LL_ENDL; } } @@ -2312,7 +2317,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) } else { - llerrs << "Invalid GL index buffer bound: " << buff << llendl; + LL_ERRS() << "Invalid GL index buffer bound: " << buff << LL_ENDL; } } } @@ -2388,10 +2393,10 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) U32 mask = 1 << i; if (mask & data_mask && !(mask & mTypeMask)) { //bit set in data_mask, but not set in mTypeMask - llwarns << "Missing required component " << vb_type_name[i] << llendl; + LL_WARNS() << "Missing required component " << vb_type_name[i] << LL_ENDL; } } - llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl; + LL_ERRS() << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << LL_ENDL; } if (LLGLSLShader::sNoFixedFunction) diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 619a0cec46..c05fd01595 100755 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -34,6 +34,7 @@ #include "v4coloru.h" #include "llstrider.h" #include "llrender.h" +#include "lltrace.h" #include <set> #include <vector> #include <list> @@ -94,7 +95,7 @@ public: //============================================================================ // base class class LLPrivateMemoryPool; -class LLVertexBuffer : public LLRefCount +class LLVertexBuffer : public LLRefCount, public LLTrace::MemTrackable<LLVertexBuffer> { public: class MappedRegion @@ -109,14 +110,15 @@ public: }; LLVertexBuffer(const LLVertexBuffer& rhs) - : mUsage(rhs.mUsage) + : LLTrace::MemTrackable<LLVertexBuffer>("LLVertexBuffer"), + mUsage(rhs.mUsage) { *this = rhs; } const LLVertexBuffer& operator=(const LLVertexBuffer& rhs) { - llerrs << "Illegal operation!" << llendl; + LL_ERRS() << "Illegal operation!" << LL_ENDL; return *this; } |