diff options
Diffstat (limited to 'indra/newview/lltextureview.cpp')
-rw-r--r-- | indra/newview/lltextureview.cpp | 876 |
1 files changed, 703 insertions, 173 deletions
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 50b73bfbc7..c87aff022f 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -2,31 +2,25 @@ * @file lltextureview.cpp * @brief LLTextureView class implementation * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -43,33 +37,44 @@ #include "llimageworker.h" #include "llrender.h" -#include "llhoverview.h" +#include "lltooltip.h" +#include "llappviewer.h" #include "llselectmgr.h" #include "lltexlayer.h" #include "lltexturecache.h" #include "lltexturefetch.h" +#include "llviewercontrol.h" #include "llviewerobject.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" -#include "llappviewer.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" +#include "llvovolume.h" +#include "llviewerstats.h" + +// For avatar texture view +#include "llvoavatarself.h" +#include "lltexlayer.h" extern F32 texmem_lower_bound_scale; LLTextureView *gTextureView = NULL; +LLTextureSizeView *gTextureSizeView = NULL; +LLTextureSizeView *gTextureCategoryView = NULL; + +#define HIGH_PRIORITY 100000000.f //static -std::set<LLViewerImage*> LLTextureView::sDebugImages; +std::set<LLViewerFetchedTexture*> LLTextureView::sDebugImages; //////////////////////////////////////////////////////////////////////////// -static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max"); -static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max"); +static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max"); +static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max"); static std::string title_string2("State"); static std::string title_string3("Pkt Bnd"); static std::string title_string4(" W x H (Dis) Mem"); static S32 title_x1 = 0; -static S32 title_x2 = 440; +static S32 title_x2 = 460; static S32 title_x3 = title_x2 + 40; static S32 title_x4 = title_x3 + 50; static S32 texture_bar_height = 8; @@ -79,7 +84,7 @@ static S32 texture_bar_height = 8; class LLTextureBar : public LLView { public: - LLPointer<LLViewerImage> mImagep; + LLPointer<LLViewerFetchedTexture> mImagep; S32 mHilite; public: @@ -109,8 +114,8 @@ public: { LLTextureBar* bar1p = (LLTextureBar*)i1; LLTextureBar* bar2p = (LLTextureBar*)i2; - LLViewerImage *i1p = bar1p->mImagep; - LLViewerImage *i2p = bar2p->mImagep; + LLViewerFetchedTexture *i1p = bar1p->mImagep; + LLViewerFetchedTexture *i2p = bar2p->mImagep; F32 pri1 = i1p->getDecodePriority(); // i1p->mRequestedDownloadPriority F32 pri2 = i2p->getDecodePriority(); // i2p->mRequestedDownloadPriority if (pri1 > pri2) @@ -128,10 +133,10 @@ public: { LLTextureBar* bar1p = (LLTextureBar*)i1; LLTextureBar* bar2p = (LLTextureBar*)i2; - LLViewerImage *i1p = bar1p->mImagep; - LLViewerImage *i2p = bar2p->mImagep; - U32 pri1 = i1p->mFetchPriority; - U32 pri2 = i2p->mFetchPriority; + LLViewerFetchedTexture *i1p = bar1p->mImagep; + LLViewerFetchedTexture *i2p = bar2p->mImagep; + U32 pri1 = i1p->getFetchPriority() ; + U32 pri2 = i2p->getFetchPriority() ; if (pri1 > pri2) return true; else if (pri2 > pri1) @@ -167,7 +172,7 @@ void LLTextureBar::draw() { color = LLColor4::green4; } - else if (mImagep->getBoostLevel()) + else if (mImagep->getBoostLevel() > LLViewerTexture::BOOST_NONE) { color = LLColor4::magenta; } @@ -229,10 +234,10 @@ void LLTextureBar::draw() { "DSK", LLColor4::blue }, // CACHE_POST { "NET", LLColor4::green }, // LOAD_FROM_NETWORK { "SIM", LLColor4::green }, // LOAD_FROM_SIMULATOR - { "URL", LLColor4::green2 },// LOAD_FROM_HTTP_GET_URL - { "HTP", LLColor4::green }, // LOAD_FROM_HTTP_GET_DATA + { "REQ", LLColor4::yellow },// SEND_HTTP_REQ + { "HTP", LLColor4::green }, // WAIT_HTTP_REQ { "DEC", LLColor4::yellow },// DECODE_IMAGE - { "DEC", LLColor4::yellow },// DECODE_IMAGE_UPDATE + { "DEC", LLColor4::green }, // DECODE_IMAGE_UPDATE { "WRT", LLColor4::purple },// WRITE_TO_CACHE { "WRT", LLColor4::orange },// WAIT_ON_WRITE { "END", LLColor4::red }, // DONE @@ -260,7 +265,7 @@ void LLTextureBar::draw() // Draw the progress bar. S32 bar_width = 100; - S32 bar_left = 280; + S32 bar_left = 260; left = bar_left; right = left + bar_width; @@ -285,40 +290,41 @@ void LLTextureBar::draw() S32 pip_x = title_x3 + pip_space/2; // Draw the packet pip + const F32 pip_max_time = 5.f; F32 last_event = mImagep->mLastPacketTimer.getElapsedTimeF32(); - if (last_event < 1.f) + if (last_event < pip_max_time) { clr = LLColor4::white; } else { last_event = mImagep->mRequestDeltaTime; - if (last_event < 1.f) + if (last_event < pip_max_time) { clr = LLColor4::green; } else { last_event = mImagep->mFetchDeltaTime; - if (last_event < 1.f) + if (last_event < pip_max_time) { clr = LLColor4::yellow; } } } - if (last_event < 1.f) + if (last_event < pip_max_time) { - clr.setAlpha(1.f - last_event); + clr.setAlpha(1.f - last_event/pip_max_time); gGL.color4fv(clr.mV); gl_rect_2d(pip_x, top, pip_x + pip_width, bottom); } pip_x += pip_width + pip_space; // we don't want to show bind/resident pips for textures using the default texture - if (mImagep->getHasGLTexture()) + if (mImagep->hasGLTexture()) { // Draw the bound pip - last_event = mImagep->sLastFrameTime - mImagep->mLastBindTime; + last_event = mImagep->getTimePassedSinceLastBound(); if (last_event < 1.f) { clr = mImagep->getMissed() ? LLColor4::red : LLColor4::magenta1; @@ -342,7 +348,7 @@ void LLTextureBar::draw() // draw the image size at the end { std::string num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), - mImagep->getDiscardLevel(), mImagep->mTextureMemory); + mImagep->getDiscardLevel(), mImagep->hasGLTexture() ? mImagep->getTextureMemory() : 0); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color, LLFontGL::LEFT, LLFontGL::TOP); } @@ -371,6 +377,105 @@ LLRect LLTextureBar::getRequiredRect() //////////////////////////////////////////////////////////////////////////// +class LLAvatarTexBar : public LLView +{ +public: + struct Params : public LLInitParam::Block<Params, LLView::Params> + { + Mandatory<LLTextureView*> texture_view; + Params() + : texture_view("texture_view") + { + S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + rect(LLRect(0,0,100,line_height * 4)); + } + }; + + LLAvatarTexBar(const Params& p) + : LLView(p), + mTextureView(p.texture_view) + {} + + virtual void draw(); + virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual LLRect getRequiredRect(); // Return the height of this object, given the set options. + +private: + LLTextureView* mTextureView; +}; + +void LLAvatarTexBar::draw() +{ + if (!gSavedSettings.getBOOL("DebugAvatarRezTime")) return; + + LLVOAvatarSelf* avatarp = gAgentAvatarp; + if (!avatarp) return; + + const S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + const S32 v_offset = 0; + const S32 l_offset = 3; + + //---------------------------------------------------------------------------- + LLGLSUIDefault gls_ui; + LLColor4 color; + + U32 line_num = 1; + for (LLVOAvatarDefines::LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDefines::LLVOAvatarDictionary::getInstance()->getBakedTextures().begin(); + baked_iter != LLVOAvatarDefines::LLVOAvatarDictionary::getInstance()->getBakedTextures().end(); + ++baked_iter) + { + const LLVOAvatarDefines::EBakedTextureIndex baked_index = baked_iter->first; + const LLTexLayerSet *layerset = avatarp->debugGetLayerSet(baked_index); + if (!layerset) continue; + const LLTexLayerSetBuffer *layerset_buffer = layerset->getComposite(); + if (!layerset_buffer) continue; + + LLColor4 text_color = LLColor4::white; + + if (layerset_buffer->uploadNeeded()) + { + text_color = LLColor4::red; + } + if (layerset_buffer->uploadInProgress()) + { + text_color = LLColor4::magenta; + } + std::string text = layerset_buffer->dumpTextureInfo(); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, l_offset, v_offset + line_height*line_num, + text_color, LLFontGL::LEFT, LLFontGL::TOP); //, LLFontGL::BOLD, LLFontGL::DROP_SHADOW_SOFT); + line_num++; + } + const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedTextureUploadTimeout"); + const U32 override_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); + + LLColor4 header_color(1.f, 1.f, 1.f, 0.9f); + + const std::string texture_timeout_str = texture_timeout ? llformat("%d",texture_timeout) : "Disabled"; + const std::string override_tex_discard_level_str = override_tex_discard_level ? llformat("%d",override_tex_discard_level) : "Disabled"; + std::string header_text = llformat("[ Timeout('AvatarBakedTextureUploadTimeout'):%s ] [ LOD_Override('TextureDiscardLevel'):%s ]", texture_timeout_str.c_str(), override_tex_discard_level_str.c_str()); + LLFontGL::getFontMonospace()->renderUTF8(header_text, 0, l_offset, v_offset + line_height*line_num, + header_color, LLFontGL::LEFT, LLFontGL::TOP); //, LLFontGL::BOLD, LLFontGL::DROP_SHADOW_SOFT); + line_num++; + std::string section_text = "Avatar Textures Information:"; + LLFontGL::getFontMonospace()->renderUTF8(section_text, 0, 0, v_offset + line_height*line_num, + header_color, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::BOLD, LLFontGL::DROP_SHADOW_SOFT); +} + +BOOL LLAvatarTexBar::handleMouseDown(S32 x, S32 y, MASK mask) +{ + return FALSE; +} + +LLRect LLAvatarTexBar::getRequiredRect() +{ + LLRect rect; + rect.mTop = 100; + if (!gSavedSettings.getBOOL("DebugAvatarRezTime")) rect.mTop = 0; + return rect; +} + +//////////////////////////////////////////////////////////////////////////// + class LLGLTexMemBar : public LLView { public: @@ -400,126 +505,156 @@ private: void LLGLTexMemBar::draw() { - S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sBoundTextureMemoryInBytes); - S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMemInMegaBytes; - S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sTotalTextureMemoryInBytes); - S32 max_total_mem = LLViewerImage::sMaxTotalTextureMemInMegaBytes; - F32 discard_bias = LLViewerImage::sDesiredDiscardBias; + S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes); + S32 max_bound_mem = LLViewerTexture::sMaxBoundTextureMemInMegaBytes; + S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sTotalTextureMemoryInBytes); + S32 max_total_mem = LLViewerTexture::sMaxTotalTextureMemInMegaBytes; + F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; + F32 cache_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getUsage()) ; + F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ; S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); - + S32 v_offset = (S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); + S32 total_downloaded = BYTES_TO_MEGA_BYTES(gTotalTextureBytes); //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; - F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; + LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); + LLColor4 color; - std::string text; - text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Discard Bias: %.2f", + std::string text = ""; + + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + + text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot: %d MB", total_mem, max_total_mem, bound_mem, max_bound_mem, - discard_bias); + LLImageRaw::sGlobalRawMemory >> 20, discard_bias, + cache_usage, cache_max_usage, total_downloaded); + //, cache_entries, cache_max_entries - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*3, - text_color, LLFontGL::LEFT, LLFontGL::TOP); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3, + text_color, LLFontGL::LEFT, LLFontGL::TOP); //---------------------------------------------------------------------------- - S32 bar_left = 380; +#if 0 + S32 bar_left = 400; S32 bar_width = 200; - S32 top = line_height*3 - 2; + S32 top = line_height*3 - 2 + v_offset; S32 bottom = top - 6; S32 left = bar_left; S32 right = left + bar_width; - - F32 bar_scale = (F32)bar_width / (max_bound_mem * 1.5f); + F32 bar_scale; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - gGL.color4f(0.5f, 0.5f, 0.5f, 0.75f); - gl_rect_2d(left, top, right, bottom); - + // GL Mem Bar + left = bar_left; - right = left + llfloor(bound_mem * bar_scale); - if (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale)) - { - gGL.color4f(0.f, 1.f, 0.f, 0.75f); - } - else if (bound_mem < max_bound_mem) - { - gGL.color4f(1.f, 1.f, 0.f, 0.75f); - } - else - { - gGL.color4f(1.f, 0.f, 0.f, 0.75f); - } + text = "GL"; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, line_height*3, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + + left = bar_left+20; + right = left + bar_width; + + gGL.color4f(0.5f, 0.5f, 0.5f, 0.75f); // grey gl_rect_2d(left, top, right, bottom); bar_scale = (F32)bar_width / (max_total_mem * 1.5f); + right = left + llfloor(total_mem * bar_scale); + right = llclamp(right, bar_left, bar_left + bar_width); - top = bottom - 2; - bottom = top - 6; + color = (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale)) ? LLColor4::green : + (total_mem < max_total_mem) ? LLColor4::yellow : LLColor4::red; + color[VALPHA] = .75f; + glColor4fv(color.mV); + + gl_rect_2d(left, top, right, bottom); // red/yellow/green + + // + bar_left += bar_width + bar_space; + //top = bottom - 2; bottom = top - 6; + + // Bound Mem Bar + left = bar_left; - right = left + llfloor(total_mem * bar_scale); - if (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale)) - { - gGL.color4f(0.f, 1.f, 0.f, 0.75f); - } - else if (total_mem < max_total_mem) - { - gGL.color4f(1.f, 1.f, 0.f, 0.75f); - } - else - { - gGL.color4f(1.f, 0.f, 0.f, 0.75f); - } + text = "GL"; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, line_height*3, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + left = bar_left + 20; + right = left + bar_width; + + gGL.color4f(0.5f, 0.5f, 0.5f, 0.75f); gl_rect_2d(left, top, right, bottom); + color = (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale)) ? LLColor4::green : + (bound_mem < max_bound_mem) ? LLColor4::yellow : LLColor4::red; + color[VALPHA] = .75f; + glColor4fv(color.mV); + + gl_rect_2d(left, top, right, bottom); +#else + S32 left = 0 ; +#endif //---------------------------------------------------------------------------- - text = llformat("Textures: Count: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d(%d) RAW:%d mRaw:%d mAux:%d CB:%d", - gImageList.getNumImages(), + text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d RAW:%d HTP:%d DEC:%d CRE:%d", + gTextureList.getNumImages(), LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(), LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(), LLLFSThread::sLocal->getPending(), - LLImageWorker::sCount, LLImageWorker::getWorkerThread()->getNumDeletes(), - LLImageRaw::sRawImageCount, LLViewerImage::sRawCount, LLViewerImage::sAuxCount, - gImageList.mCallbackList.size()); + LLImageRaw::sRawImageCount, + LLAppViewer::getTextureFetch()->getNumHTTPRequests(), + LLAppViewer::getImageDecodeThread()->getPending(), + gTextureList.mCreateTextureList.size()); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2, + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*2, text_color, LLFontGL::LEFT, LLFontGL::TOP); + + + left = 550; + F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth(); + F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS"); + color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; + color[VALPHA] = text_color[VALPHA]; + text = llformat("BW:%.0f/%.0f",bandwidth, max_bandwidth); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, v_offset + line_height*2, + color, LLFontGL::LEFT, LLFontGL::TOP); S32 dx1 = 0; if (LLAppViewer::getTextureFetch()->mDebugPause) { - LLFontGL::getFontMonospace()->renderUTF8(std::string("!"), 0, title_x1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(std::string("!"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mFreezeView) { - LLFontGL::getFontMonospace()->renderUTF8(std::string("*"), 0, title_x1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(std::string("*"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mOrderFetch) { - LLFontGL::getFontMonospace()->renderUTF8(title_string1b, 0, title_x1+dx1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string1b, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } else { - LLFontGL::getFontMonospace()->renderUTF8(title_string1a, 0, title_x1+dx1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string1a, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } - LLFontGL::getFontMonospace()->renderUTF8(title_string2, 0, title_x2, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string2, 0, title_x2, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); - LLFontGL::getFontMonospace()->renderUTF8(title_string3, 0, title_x3, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string3, 0, title_x3, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); - LLFontGL::getFontMonospace()->renderUTF8(title_string4, 0, title_x4, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string4, 0, title_x4, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } @@ -531,11 +666,75 @@ BOOL LLGLTexMemBar::handleMouseDown(S32 x, S32 y, MASK mask) LLRect LLGLTexMemBar::getRequiredRect() { LLRect rect; - rect.mTop = 8; + //rect.mTop = 50; + rect.mTop = 0; return rect; } //////////////////////////////////////////////////////////////////////////// +class LLGLTexSizeBar +{ +public: + LLGLTexSizeBar(S32 index, S32 left, S32 bottom, S32 right, S32 line_height) + { + mIndex = index ; + mLeft = left ; + mBottom = bottom ; + mRight = right ; + mLineHeight = line_height ; + mTopLoaded = 0 ; + mTopBound = 0 ; + mScale = 1.0f ; + } + + void setTop(S32 loaded, S32 bound, F32 scale) {mTopLoaded = loaded ; mTopBound = bound; mScale = scale ;} + + void draw(); + BOOL handleHover(S32 x, S32 y, MASK mask, BOOL set_pick_size) ; + +private: + S32 mIndex ; + S32 mLeft ; + S32 mBottom ; + S32 mRight ; + S32 mTopLoaded ; + S32 mTopBound ; + S32 mLineHeight ; + F32 mScale ; +}; + +BOOL LLGLTexSizeBar::handleHover(S32 x, S32 y, MASK mask, BOOL set_pick_size) +{ + if(y > mBottom && (y < mBottom + (S32)(mTopLoaded * mScale) || y < mBottom + (S32)(mTopBound * mScale))) + { + LLImageGL::setCurTexSizebar(mIndex, set_pick_size); + } + return TRUE ; +} +void LLGLTexSizeBar::draw() +{ + LLGLSUIDefault gls_ui; + + if(LLImageGL::sCurTexSizeBar == mIndex) + { + F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; + std::string text; + + text = llformat("%d", mTopLoaded) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, mLeft, mBottom + (S32)(mTopLoaded * mScale) + mLineHeight, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + + text = llformat("%d", mTopBound) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, (mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale) + mLineHeight, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + } + + F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f}; + F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; + gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ; + gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ; +} +//////////////////////////////////////////////////////////////////////////// LLTextureView::LLTextureView(const LLTextureView::Params& p) : LLContainerView(p), @@ -548,6 +747,7 @@ LLTextureView::LLTextureView(const LLTextureView::Params& p) setDisplayChildren(TRUE); mGLTexMemBar = 0; + mAvatarTexBar = 0; } LLTextureView::~LLTextureView() @@ -555,9 +755,12 @@ LLTextureView::~LLTextureView() // Children all cleaned up by default view destructor. delete mGLTexMemBar; mGLTexMemBar = 0; + + delete mAvatarTexBar; + mAvatarTexBar = 0; } -typedef std::pair<F32,LLViewerImage*> decode_pair_t; +typedef std::pair<F32,LLViewerFetchedTexture*> decode_pair_t; struct compare_decode_pair { bool operator()(const decode_pair_t& a, const decode_pair_t& b) @@ -566,6 +769,15 @@ struct compare_decode_pair } }; +struct KillView +{ + void operator()(LLView* viewp) + { + viewp->getParent()->removeChild(viewp); + viewp->die(); + } +}; + void LLTextureView::draw() { if (!mFreezeView) @@ -573,12 +785,23 @@ void LLTextureView::draw() // LLViewerObject *objectp; // S32 te; - for_each(mTextureBars.begin(), mTextureBars.end(), DeletePointer()); + for_each(mTextureBars.begin(), mTextureBars.end(), KillView()); mTextureBars.clear(); - - delete mGLTexMemBar; - mGLTexMemBar = 0; - + + if (mGLTexMemBar) + { + removeChild(mGLTexMemBar); + mGLTexMemBar->die(); + mGLTexMemBar = 0; + } + + if (mAvatarTexBar) + { + removeChild(mAvatarTexBar); + mAvatarTexBar->die(); + mAvatarTexBar = 0; + } + typedef std::multiset<decode_pair_t, compare_decode_pair > display_list_t; display_list_t display_image_list; @@ -587,18 +810,23 @@ void LLTextureView::draw() llinfos << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << llendl; } - for (LLViewerImageList::image_priority_list_t::iterator iter = gImageList.mImageList.begin(); - iter != gImageList.mImageList.end(); ) + for (LLViewerTextureList::image_priority_list_t::iterator iter = gTextureList.mImageList.begin(); + iter != gTextureList.mImageList.end(); ) { - LLPointer<LLViewerImage> imagep = *iter++; + LLPointer<LLViewerFetchedTexture> imagep = *iter++; + if(!imagep->hasFetcher()) + { + continue ; + } S32 cur_discard = imagep->getDiscardLevel(); S32 desired_discard = imagep->mDesiredDiscardLevel; if (mPrintList) { + S32 tex_mem = imagep->hasGLTexture() ? imagep->getTextureMemory() : 0 ; llinfos << imagep->getID() - << "\t" << imagep->mTextureMemory + << "\t" << tex_mem << "\t" << imagep->getBoostLevel() << "\t" << imagep->getDecodePriority() << "\t" << imagep->getWidth() @@ -606,20 +834,13 @@ void LLTextureView::draw() << "\t" << cur_discard << llendl; } - -#if 0 - if (imagep->getDontDiscard()) - { - continue; - } - if (imagep->isMissingAsset()) + if (imagep->getID() == LLAppViewer::getTextureFetch()->mDebugID) { - continue; + static S32 debug_count = 0; + ++debug_count; // for breakpoints } -#endif - -#define HIGH_PRIORITY 100000000.f + F32 pri; if (mOrderFetch) { @@ -638,55 +859,55 @@ void LLTextureView::draw() if (!mOrderFetch) { -#if 1 - if (pri < HIGH_PRIORITY && LLSelectMgr::getInstance()) - { - struct f : public LLSelectedTEFunctor + if (pri < HIGH_PRIORITY && LLSelectMgr::getInstance()) { - LLViewerImage* mImage; - f(LLViewerImage* image) : mImage(image) {} - virtual bool apply(LLViewerObject* object, S32 te) + struct f : public LLSelectedTEFunctor { - return (mImage == object->getTEImage(te)); + LLViewerFetchedTexture* mImage; + f(LLViewerFetchedTexture* image) : mImage(image) {} + virtual bool apply(LLViewerObject* object, S32 te) + { + return (mImage == object->getTEImage(te)); + } + } func(imagep); + const bool firstonly = true; + bool match = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, firstonly); + if (match) + { + pri += 3*HIGH_PRIORITY; } - } func(imagep); - const bool firstonly = true; - bool match = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, firstonly); - if (match) - { - pri += 3*HIGH_PRIORITY; } - } -#endif -#if 1 - if (pri < HIGH_PRIORITY && (cur_discard< 0 || desired_discard < cur_discard)) - { - LLViewerObject *objectp = gHoverView->getLastHoverObject(); - if (objectp) + + if (pri < HIGH_PRIORITY && (cur_discard< 0 || desired_discard < cur_discard)) { - S32 tex_count = objectp->getNumTEs(); - for (S32 i = 0; i < tex_count; i++) + LLSelectNode* hover_node = LLSelectMgr::instance().getHoverNode(); + if (hover_node) { - if (imagep == objectp->getTEImage(i)) + LLViewerObject *objectp = hover_node->getObject(); + if (objectp) { - pri += 2*HIGH_PRIORITY; - break; + S32 tex_count = objectp->getNumTEs(); + for (S32 i = 0; i < tex_count; i++) + { + if (imagep == objectp->getTEImage(i)) + { + pri += 2*HIGH_PRIORITY; + break; + } + } } } } - } -#endif -#if 1 - if (pri > 0.f && pri < HIGH_PRIORITY) - { - if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f || - imagep->mFetchDeltaTime < 0.25f) + + if (pri > 0.f && pri < HIGH_PRIORITY) { - pri += 1*HIGH_PRIORITY; + if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f || + imagep->mFetchDeltaTime < 0.25f) + { + pri += 1*HIGH_PRIORITY; + } } } -#endif - } if (pri > 0.0f) { @@ -701,10 +922,11 @@ void LLTextureView::draw() static S32 max_count = 50; S32 count = 0; + mNumTextureBars = 0 ; for (display_list_t::iterator iter = display_image_list.begin(); iter != display_image_list.end(); iter++) { - LLViewerImage* imagep = iter->second; + LLViewerFetchedTexture* imagep = iter->second; S32 hilite = 0; F32 pri = iter->first; if (pri >= 1 * HIGH_PRIORITY) @@ -726,15 +948,25 @@ void LLTextureView::draw() sortChildren(LLTextureBar::sort()); LLGLTexMemBar::Params tmbp; + LLRect tmbr; tmbp.name("gl texmem bar"); + tmbp.rect(tmbr); tmbp.texture_view(this); mGLTexMemBar = LLUICtrlFactory::create<LLGLTexMemBar>(tmbp); - addChild(mGLTexMemBar); - + addChildInBack(mGLTexMemBar); + + LLAvatarTexBar::Params atbp; + LLRect atbr; + atbp.name("gl avatartex bar"); + atbp.texture_view(this); + atbp.rect(atbr); + mAvatarTexBar = LLUICtrlFactory::create<LLAvatarTexBar>(atbp); + addChild(mAvatarTexBar); + reshape(getRect().getWidth(), getRect().getHeight(), TRUE); /* - count = gImageList.getNumImages(); + count = gTextureList.getNumImages(); std::string info_string; info_string = llformat("Global Info:\nTexture Count: %d", count); mInfoTextp->setText(info_string); @@ -756,7 +988,7 @@ void LLTextureView::draw() } -BOOL LLTextureView::addBar(LLViewerImage *imagep, S32 hilite) +BOOL LLTextureView::addBar(LLViewerFetchedTexture *imagep, S32 hilite) { llassert(imagep); @@ -814,4 +1046,302 @@ BOOL LLTextureView::handleKey(KEY key, MASK mask, BOOL called_from_parent) return FALSE; } +//----------------------------------------------------------------- +LLTextureSizeView::LLTextureSizeView(const LLTextureSizeView::Params& p) : LLContainerView(p) +{ + setVisible(FALSE) ; + mTextureSizeBarWidth = 30 ; +} + +LLTextureSizeView::~LLTextureSizeView() +{ + if(mTextureSizeBar.size()) + { + for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++) + { + delete mTextureSizeBar[i] ; + } + mTextureSizeBar.clear() ; + } +} +void LLTextureSizeView::draw() +{ + if(mType == TEXTURE_MEM_OVER_SIZE) + { + drawTextureSizeGraph(); + } + else + { + drawTextureCategoryGraph() ; + } + + LLView::draw(); +} + +BOOL LLTextureSizeView::handleHover(S32 x, S32 y, MASK mask) +{ + if(x > mTextureSizeBarRect.mLeft && x < mTextureSizeBarRect.mRight) + { + mTextureSizeBar[(x - mTextureSizeBarRect.mLeft) / mTextureSizeBarWidth]->handleHover(x, y, mask, (mType == TEXTURE_MEM_OVER_SIZE)) ; + } + + return TRUE ; +} + +//draw real-time texture mem bar over size +void LLTextureSizeView::drawTextureSizeGraph() +{ + if(mTextureSizeBar.size() == 0) + { + S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + mTextureSizeBar.resize(LLImageGL::sTextureLoadedCounter.size()) ; + mTextureSizeBarRect.set(700, line_height * 2 + 400, 700 + mTextureSizeBar.size() * mTextureSizeBarWidth, line_height * 2) ; + + for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++) + { + mTextureSizeBar[i] = new LLGLTexSizeBar(i, mTextureSizeBarRect.mLeft + i * mTextureSizeBarWidth , + line_height * 2, mTextureSizeBarRect.mLeft + (i + 1) * mTextureSizeBarWidth, line_height) ; + } + } + + F32 size_bar_scale = drawTextureSizeDistributionGraph() ; + for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++) + { + mTextureSizeBar[i]->setTop(LLImageGL::sTextureLoadedCounter[i], LLImageGL::sTextureBoundCounter[i], size_bar_scale) ; + mTextureSizeBar[i]->draw() ; + } + LLImageGL::resetCurTexSizebar(); +} + +//draw background of texture size bar graph +F32 LLTextureSizeView::drawTextureSizeDistributionGraph() +{ + //scale + F32 scale = 1.0f ; + + LLGLSUIDefault gls_ui; + + { + S32 count = 0 ; + for(U32 i = 0 ; i < LLImageGL::sTextureLoadedCounter.size() ; i++) + { + if(LLImageGL::sTextureLoadedCounter[i] > count) + { + count = LLImageGL::sTextureLoadedCounter[i] ; + } + } + if(count > mTextureSizeBarRect.getHeight()) + { + scale = (F32)mTextureSizeBarRect.getHeight() / count ; + } + } + + S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + S32 left = mTextureSizeBarRect.mLeft ; + S32 bottom = mTextureSizeBarRect.mBottom ; + S32 right = mTextureSizeBarRect.mRight ; + S32 top = mTextureSizeBarRect.mTop ; + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + //background rect + gl_rect_2d(left - 25, top + 30, right + 100, bottom - 25, LLColor4(0.0f, 0.0f, 0.0f, 0.25f)) ; + + //-------------------------------------------------- + gGL.color4f(1.0f, 0.5f, 0.5f, 0.75f); + gl_line_2d(left, bottom, right, bottom) ; //x axis + gl_line_2d(left, bottom, left, top) ; //y axis + + //ruler + //-------------------------------------------------- + gGL.color4f(1.0f, 0.5f, 0.5f, 0.5f); + for(S32 i = bottom + 50 ; i <= top ; i += 50) + { + gl_line_2d(left, i, right, i) ; + } + + //texts + //-------------------------------------------------- + F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; + std::string text; + + //------- + //x axis: size label + text = llformat("%d", 0) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 12, bottom - line_height / 2, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + for(U32 i = 1 ; i < mTextureSizeBar.size() ; i++) + { + text = llformat("%d", (1 << (i / 2)) + ((i & 1) ? ((1 << (i / 2)) >> 1) : 0)) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + i * mTextureSizeBarWidth + 12, bottom - line_height / 2, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + } + text = llformat("(w + h)/2") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, right + 10, bottom - line_height / 2, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + //------- + + //y axis: number label + for(S32 i = bottom + 50 ; i <= top ; i += 50) + { + text = llformat("%d", (S32)((i - bottom) / scale)) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left - 20, i + line_height / 2 , + text_color, LLFontGL::LEFT, LLFontGL::TOP); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, right + 5, i + line_height / 2 , + text_color, LLFontGL::LEFT, LLFontGL::TOP); + } + + //-------------------------------------------------- + F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f}; + gl_rect_2d(left + 70, top + line_height * 2, left + 90, top + line_height, loaded_color) ; + text = llformat("Loaded") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 100, top + line_height * 2, + loaded_color, LLFontGL::LEFT, LLFontGL::TOP); + + F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; + gl_rect_2d(left + 170, top + line_height * 2, left + 190, top + line_height, bound_color) ; + text = llformat("Bound") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 200, top + line_height * 2, + bound_color, LLFontGL::LEFT, LLFontGL::TOP); + + //-------------------------------------------------- + + //title + text = llformat("Texture Size Distribution") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + return scale ; +} + +//draw real-time texture mem bar over category +void LLTextureSizeView::drawTextureCategoryGraph() +{ + if(mTextureSizeBar.size() == 0) + { + S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + mTextureSizeBar.resize(LLViewerTexture::getTotalNumOfCategories()) ; + mTextureSizeBarRect.set(700, line_height * 2 + 400, 700 + mTextureSizeBar.size() * mTextureSizeBarWidth, line_height * 2) ; + + for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++) + { + mTextureSizeBar[i] = new LLGLTexSizeBar(i, mTextureSizeBarRect.mLeft + i * mTextureSizeBarWidth , + line_height * 2, mTextureSizeBarRect.mLeft + (i + 1) * mTextureSizeBarWidth, line_height) ; + } + } + + F32 size_bar_scale = drawTextureCategoryDistributionGraph() ; + for(U32 i = 0 ; i < mTextureSizeBar.size() ; i++) + { + U32 k = LLViewerTexture::getIndexFromCategory(i) ; + mTextureSizeBar[i]->setTop(LLImageGL::sTextureMemByCategory[k] >> 20, LLImageGL::sTextureMemByCategoryBound[k] >> 20, size_bar_scale) ; + mTextureSizeBar[i]->draw() ; + } + LLImageGL::resetCurTexSizebar(); +} + +//draw background for TEXTURE_MEM_OVER_CATEGORY +F32 LLTextureSizeView::drawTextureCategoryDistributionGraph() +{ + //scale + F32 scale = 4.0f ; + + LLGLSUIDefault gls_ui; + + { + S32 count = 0 ; + for(U32 i = 0 ; i < LLImageGL::sTextureMemByCategory.size() ; i++) + { + S32 tmp = LLImageGL::sTextureMemByCategory[i] >> 20 ; + if(tmp > count) + { + count = tmp ; + } + } + if(count > mTextureSizeBarRect.getHeight() * 0.25f) + { + scale = (F32)mTextureSizeBarRect.getHeight() * 0.25f / count ; + } + } + + S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + S32 left = mTextureSizeBarRect.mLeft ; + S32 bottom = mTextureSizeBarRect.mBottom ; + S32 right = mTextureSizeBarRect.mRight ; + S32 top = mTextureSizeBarRect.mTop ; + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + //background rect + gl_rect_2d(left - 25, top + 30, right + 100, bottom - 25, LLColor4(0.0f, 0.0f, 0.0f, 0.25f)) ; + + //-------------------------------------------------- + gGL.color4f(1.0f, 0.5f, 0.5f, 0.75f); + gl_line_2d(left, bottom, right, bottom) ; //x axis + gl_line_2d(left, bottom, left, top) ; //y axis + + //ruler + //-------------------------------------------------- + gGL.color4f(1.0f, 0.5f, 0.5f, 0.5f); + for(S32 i = bottom + 50 ; i <= top ; i += 50) + { + gl_line_2d(left, i, right, i) ; + } + + //texts + //-------------------------------------------------- + F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; + std::string text; + + //------- + //x axis: size label + static char category[LLViewerTexture::MAX_GL_IMAGE_CATEGORY][4] = + {"Non", "Bak", "Av", "Cld", "Scp", "Hi", "Trn", "Slt", "Hud", "Bsf", "UI", "Pvw", "Map", "Mvs", "Slf", "Loc", "Scr", "Dyn", "Mdi", "ALT", "Oth" } ; + + text = llformat("%s", category[0]) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 12, bottom - line_height / 2, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + for(U32 i = 1 ; i < mTextureSizeBar.size() ; i++) + { + text = llformat("%s", category[i]) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + i * mTextureSizeBarWidth + 12, bottom - line_height / 2, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + } + //------- + + //y axis: number label + for(S32 i = bottom + 50 ; i <= top ; i += 50) + { + text = llformat("%d", (S32)((i - bottom) / scale)) ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left - 20, i + line_height / 2 , + text_color, LLFontGL::LEFT, LLFontGL::TOP); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, right + 5, i + line_height / 2 , + text_color, LLFontGL::LEFT, LLFontGL::TOP); + } + + text = llformat("MB") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left - 20, top + line_height * 2 , + text_color, LLFontGL::LEFT, LLFontGL::TOP); + //-------------------------------------------------- + F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f}; + gl_rect_2d(left + 70, top + line_height * 2, left + 90, top + line_height, loaded_color) ; + text = llformat("Loaded") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 100, top + line_height * 2, + loaded_color, + LLFontGL::LEFT, LLFontGL::TOP); + + F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; + gl_rect_2d(left + 170, top + line_height * 2, left + 190, top + line_height, bound_color) ; + text = llformat("Bound") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 200, top + line_height * 2, + bound_color, LLFontGL::LEFT, LLFontGL::TOP); + + //-------------------------------------------------- + + //title + text = llformat("Texture Category Distribution") ; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left + 250, top + line_height * 3, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + + return scale ; +} |