diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llimage/llimage.cpp | 5 | ||||
| -rw-r--r-- | indra/llimage/llimage.h | 1 | ||||
| -rw-r--r-- | indra/llrender/llimagegl.cpp | 74 | ||||
| -rw-r--r-- | indra/llrender/llimagegl.h | 16 | ||||
| -rw-r--r-- | indra/llrender/llrender.cpp | 6 | ||||
| -rw-r--r-- | indra/llwindow/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | indra/llwindow/llwindow.h | 3 | ||||
| -rw-r--r-- | indra/llwindow/llwindowheadless.h | 2 | ||||
| -rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 136 | ||||
| -rw-r--r-- | indra/llwindow/llwindowwin32.h | 4 | ||||
| -rw-r--r-- | indra/newview/llfloaterlagmeter.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/lltextureview.cpp | 15 | ||||
| -rw-r--r-- | indra/newview/llviewerdisplay.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llviewerstats.cpp | 5 | ||||
| -rw-r--r-- | indra/newview/llviewerstats.h | 6 | ||||
| -rw-r--r-- | indra/newview/llviewertexture.cpp | 50 | ||||
| -rw-r--r-- | indra/newview/llviewertexture.h | 8 | ||||
| -rw-r--r-- | indra/newview/llviewertexturelist.cpp | 3 | ||||
| -rw-r--r-- | indra/newview/llviewerwindow.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llvoavatarself.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 2 | 
21 files changed, 167 insertions, 178 deletions
| diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 0fa027c9c3..3a3011d99b 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -798,7 +798,6 @@ U8* LLImageBase::allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 si  // LLImageRaw  //--------------------------------------------------------------------------- -S32 LLImageRaw::sGlobalRawMemory = 0;  S32 LLImageRaw::sRawImageCount = 0;  LLImageRaw::LLImageRaw() @@ -847,16 +846,13 @@ LLImageRaw::~LLImageRaw()  U8* LLImageRaw::allocateData(S32 size)  {  	U8* res = LLImageBase::allocateData(size); -	sGlobalRawMemory += getDataSize();  	return res;  }  // virtual  U8* LLImageRaw::reallocateData(S32 size)  { -	sGlobalRawMemory -= getDataSize();  	U8* res = LLImageBase::reallocateData(size); -	sGlobalRawMemory += getDataSize();  	return res;  } @@ -869,7 +865,6 @@ void LLImageRaw::releaseData()  // virtual  void LLImageRaw::deleteData()  { -	sGlobalRawMemory -= getDataSize();  	LLImageBase::deleteData();  } diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 7a588cfb03..460d5e0f5b 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -275,7 +275,6 @@ protected:  	void setDataAndSize(U8 *data, S32 width, S32 height, S8 components) ;  public: -	static S32 sGlobalRawMemory;  	static S32 sRawImageCount;  private: diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 9bd3a0a6b0..0a5d258b3a 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -57,9 +57,6 @@ U32 wpo2(U32 i);  U32 LLImageGL::sUniqueCount				= 0;  U32 LLImageGL::sBindCount				= 0; -S32Bytes LLImageGL::sGlobalTextureMemory(0); -S32Bytes LLImageGL::sBoundTextureMemory(0); -S32Bytes LLImageGL::sCurBoundTextureMemory(0);  S32 LLImageGL::sCount					= 0;  BOOL LLImageGL::sGlobalUseAnisotropic	= FALSE; @@ -282,15 +279,6 @@ void LLImageGL::updateStats(F32 current_time)  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;  	sLastFrameTime = current_time; -	sBoundTextureMemory = sCurBoundTextureMemory; -	sCurBoundTextureMemory = S32Bytes(0); -} - -//static -S32 LLImageGL::updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) -{ -	LLImageGL::sCurBoundTextureMemory += mem ; -	return LLImageGL::sCurBoundTextureMemory.value();  }  //---------------------------------------------------------------------------- @@ -623,7 +611,7 @@ void LLImageGL::forceUpdateBindStats(void) const  	mLastBindTime = sLastFrameTime;  } -BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const +BOOL LLImageGL::updateBindStats() const  {	  	if (mTexName != 0)  	{ @@ -635,7 +623,6 @@ BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const  		{  			// we haven't accounted for this texture yet this frame  			sUniqueCount++; -			updateBoundTexMem(tex_mem, mComponents, mCategory);  			mLastBindTime = sLastFrameTime;  			return TRUE ; @@ -1599,11 +1586,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_      // things will break if we don't unbind after creation      gGL.getTexUnit(0)->unbind(mBindTarget); -    if (old_texname != 0) -    { -        sGlobalTextureMemory -= mTextureMemory; -    } -      //if we're on the image loading thread, be sure to delete old_texname and update mTexName on the main thread      if (!defer_copy)      { @@ -1624,7 +1606,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_      mTextureMemory = (S32Bytes)getMipBytes(mCurrentDiscardLevel); -    sGlobalTextureMemory += mTextureMemory;      mTexelsInGLTexture = getWidth() * getHeight();      // mark this as bound at this point, so we don't throw it out immediately @@ -1634,51 +1615,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_      return TRUE;  } -void LLImageGLThread::updateClass() -{ -    LL_PROFILE_ZONE_SCOPED; - -    // update available vram one per second -    static LLFrameTimer sTimer; - -    if (sTimer.getElapsedSeconds() < 1.f) -    { -        return; -    } -     -    sTimer.reset(); - -    auto func = []() -    { -        if (gGLManager.mHasATIMemInfo) -        { -            S32 meminfo[4]; -            glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo); -            LLImageGLThread::sFreeVRAMMegabytes = meminfo[0]; - -        } -        else if (gGLManager.mHasNVXMemInfo) -        { -            S32 free_memory; -            glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &free_memory); -            LLImageGLThread::sFreeVRAMMegabytes = free_memory / 1024; -        } -    }; - -     -    // post update to background thread if available, otherwise execute immediately -    auto queue = LL::WorkQueue::getInstance("LLImageGL"); -    if (sEnabled) -    { -        queue->post(func); -    } -    else -    { -        llassert(queue == nullptr); -        func(); -    } -} -  void LLImageGL::syncToMainThread(LLGLuint new_tex_name)  {      LL_PROFILE_ZONE_SCOPED; @@ -1857,7 +1793,6 @@ void LLImageGL::destroyGLTexture()  	{  		if(mTextureMemory != S32Bytes(0))  		{ -			sGlobalTextureMemory -= mTextureMemory;  			mTextureMemory = (S32Bytes)0;  		} @@ -2409,8 +2344,6 @@ void LLImageGL::checkActiveThread()  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL,  nummips);  */   -std::atomic<S32> LLImageGLThread::sFreeVRAMMegabytes(4096); //if free vram is unknown, default to 4GB -  LLImageGLThread::LLImageGLThread(LLWindow* window)      // We want exactly one thread, but a very large capacity: we never want      // anyone, especially inner-loop render code, to have to block on post() @@ -2438,8 +2371,3 @@ void LLImageGLThread::run()      mWindow->destroySharedContext(mContext);  } -S32 LLImageGLThread::getFreeVRAMMegabytes() -{ -    return sFreeVRAMMegabytes; -} - diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 4d5b60d6bc..1716338c0b 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -61,7 +61,7 @@ public:  	static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height);  	static S32 dataFormatComponents(S32 dataformat); -	BOOL updateBindStats(S32Bytes tex_mem) const ; +	BOOL updateBindStats() const ;  	F32 getTimePassedSinceLastBound();  	void forceUpdateBindStats(void) const; @@ -73,9 +73,6 @@ public:  	static void restoreGL();  	static void dirtyTexOptions(); -	// Sometimes called externally for textures not using LLImageGL (should go away...)	 -	static S32 updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) ; -	  	static bool checkSize(S32 width, S32 height);  	//for server side use only. @@ -265,9 +262,6 @@ public:  	static F32 sLastFrameTime;  	// Global memory statistics -	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; @@ -327,12 +321,6 @@ public:      // follows gSavedSettings "RenderGLMultiThreaded"      static bool sEnabled; -    // app should call this function periodically -    static void updateClass(); - -    // free video memory in megabytes -    static std::atomic<S32> sFreeVRAMMegabytes; -      LLImageGLThread(LLWindow* window);      // post a function to be executed on the LLImageGL background thread @@ -344,8 +332,6 @@ public:      void run() override; -    static S32 getFreeVRAMMegabytes(); -  private:      LLWindow* mWindow;      void* mContext = nullptr; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a03a27cf94..15c509dbfb 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -223,7 +223,7 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind)  					enable(gl_tex->getTarget());  					mCurrTexture = gl_tex->getTexName();  					glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); -					if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) +					if(gl_tex->updateBindStats())  					{  						texture->setActive() ;  						texture->updateBindStatsForTester() ; @@ -302,7 +302,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind, S32  		mCurrTexture = texname;  		glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture);  		stop_glerror(); -		texture->updateBindStats(texture->mTextureMemory);		 +        texture->updateBindStats();  		mHasMipMaps = texture->mHasMipMaps;  		if (texture->mTexOptionsDirty)  		{ @@ -341,7 +341,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)              mCurrTexture = cubeMap->mImages[0]->getTexName();  			glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture);  			mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps; -			cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory); +			cubeMap->mImages[0]->updateBindStats();  			if (cubeMap->mImages[0]->mTexOptionsDirty)  			{  				cubeMap->mImages[0]->mTexOptionsDirty = false; diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 70eb99c86c..32f0fa14c4 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -145,6 +145,8 @@ if (WINDOWS)    list(APPEND llwindow_LINK_LIBRARIES         comdlg32     # Common Dialogs for ChooseColor         ole32 +       dxgi +       d3d9         )  endif (WINDOWS) diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 0edf39f6ef..507e6076d6 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -163,6 +163,9 @@ public:  	virtual F32 getPixelAspectRatio() = 0;  	virtual void setNativeAspectRatio(F32 aspect) = 0; +    // query VRAM usage +    virtual U32 getAvailableVRAMMegabytes() = 0; +  	virtual void beforeDialog() {};	// prepare to put up an OS dialog (if special measures are required, such as in fullscreen mode)  	virtual void afterDialog() {};	// undo whatever was done in beforeDialog() diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index 410da79623..0e1f603db7 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -96,6 +96,8 @@ public:  	/*virtual*/ F32 getPixelAspectRatio() { return 1.0f; };  	/*virtual*/ void setNativeAspectRatio(F32 ratio) {} +    U32 getAvailableVRAMMegabytes() override { return 4096; } +  	/*virtual*/ void *getPlatformWindow() { return 0; };  	/*virtual*/ void bringToFront() {}; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 26e624c6ec..e38c43bc63 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -47,6 +47,7 @@  #include "llglslshader.h"  #include "llthreadsafequeue.h"  #include "stringize.h" +#include "llframetimer.h"  // System includes  #include <commdlg.h> @@ -61,6 +62,10 @@  #include <sstream>  #include <utility>                  // std::pair +#include <d3d9.h> +#include <dxgi1_4.h> + +  // Require DirectInput version 8  #define DIRECTINPUT_VERSION 0x0800 @@ -347,6 +352,20 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool      void run() override; +    // initialzie DXGI adapter (for querying available VRAM) +    void initDX(); +     +    // initialize D3D (if DXGI cannot be used) +    void initD3D(); + +    // call periodically to update available VRAM +    void updateVRAMUsage(); + +    U32 getAvailableVRAMMegabytes() +    { +        return mAvailableVRAM; +    } +      /// called by main thread to post work to this window thread      template <typename CALLABLE>      void post(CALLABLE&& func) @@ -395,6 +414,12 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool      void gatherInput();      HWND mWindowHandle = NULL;      HDC mhDC = 0; + +    std::atomic<U32> mAvailableVRAM; + +    IDXGIAdapter3* mDXGIAdapter = nullptr; +    LPDIRECT3D9 mD3D = nullptr; +    LPDIRECT3DDEVICE9 mD3DDevice = nullptr;  }; @@ -4510,6 +4535,10 @@ std::vector<std::string> LLWindowWin32::getDynamicFallbackFontList()  	return std::vector<std::string>();  } +U32 LLWindowWin32::getAvailableVRAMMegabytes() +{ +    return mWindowThread ? mWindowThread->getAvailableVRAMMegabytes() : 0; +}  #endif // LL_WINDOWS @@ -4565,17 +4594,97 @@ private:      std::string mPrev;  }; +void LLWindowWin32::LLWindowWin32Thread::initDX() +{ +    if (mDXGIAdapter == NULL) +    { +        IDXGIFactory4* pFactory = nullptr; + +        HRESULT res = CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&pFactory); + +        if (FAILED(res)) +        { +            LL_WARNS() << "CreateDXGIFactory1 failed: 0x" << std::hex << res << LL_ENDL; +        } +        else +        { +            res = pFactory->EnumAdapters(0, reinterpret_cast<IDXGIAdapter**>(&mDXGIAdapter)); +            if (FAILED(res)) +            { +                LL_WARNS() << "EnumAdapters failed: 0x" << std::hex << res << LL_ENDL; +            } +        } + +        pFactory->Release(); +    } +} + +void LLWindowWin32::LLWindowWin32Thread::initD3D() +{ +    if (mDXGIAdapter == NULL && mD3DDevice == NULL && mWindowHandle != 0) +    { +        mD3D = Direct3DCreate9(D3D_SDK_VERSION); +         +        D3DPRESENT_PARAMETERS d3dpp; + +        ZeroMemory(&d3dpp, sizeof(d3dpp)); +        d3dpp.Windowed = TRUE; +        d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + +        mD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mWindowHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &mD3DDevice); +    } +} + +void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() +{ +    LL_PROFILE_ZONE_SCOPED; +    if (mDXGIAdapter != nullptr) +    { +        DXGI_QUERY_VIDEO_MEMORY_INFO info; +        mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info); + +        // try to use no more than the available reserve minus 10% +        U32 target = info.AvailableForReservation / 1024 / 1024; +        target -= target / 10; + +        U32 used_vram = info.CurrentUsage / 1024 / 1024; + +        mAvailableVRAM = used_vram < target ? target - used_vram : 0; + +        /*LL_INFOS() << "\nLocal\nAFR: " << info.AvailableForReservation / 1024 / 1024 +            << "\nBudget: " << info.Budget / 1024 / 1024 +            << "\nCR: " << info.CurrentReservation / 1024 / 1024 +            << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL; + +        mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &info); +        LL_INFOS() << "\nNon-Local\nAFR: " << info.AvailableForReservation / 1024 / 1024 +            << "\nBudget: " << info.Budget / 1024 / 1024 +            << "\nCR: " << info.CurrentReservation / 1024 / 1024 +            << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL;*/ +    } +    else if (mD3DDevice != NULL) +    { // fallback to D3D9 +        mAvailableVRAM = mD3DDevice->GetAvailableTextureMem() / 1024 / 1024; +    } + +} +  void LLWindowWin32::LLWindowWin32Thread::run()  {      sWindowThreadId = std::this_thread::get_id();      LogChange logger("Window"); +    initDX(); +      while (! getQueue().done())      {          LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32;          if (mWindowHandle != 0)          { +            // lazily call initD3D inside this loop to catch when mWindowHandle has been set +            initD3D(); +              MSG msg;              BOOL status;              if (mhDC == 0) @@ -4608,6 +4717,13 @@ void LLWindowWin32::LLWindowWin32Thread::run()              getQueue().runPending();          } +        // update available vram once every 3 seconds +        static LLFrameTimer vramTimer; +        if (vramTimer.getElapsedTimeF32() > 3.f) +        { +            updateVRAMUsage(); +            vramTimer.reset(); +        }  #if 0          {              LL_PROFILE_ZONE_NAMED_CATEGORY_WIN32("w32t - Sleep"); @@ -4616,6 +4732,26 @@ void LLWindowWin32::LLWindowWin32Thread::run()          }  #endif      } + +    //clean up DXGI/D3D resources +    if (mDXGIAdapter) +    { +        mDXGIAdapter->Release(); +        mDXGIAdapter = nullptr; +    } + +    if (mD3DDevice) +    { +        mD3DDevice->Release(); +        mD3DDevice = nullptr; +    } + +    if (mD3D) +    { +        mD3D->Release(); +        mD3D = nullptr; +    } +  }  void LLWindowWin32::post(const std::function<void()>& func) diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index b391acc12d..bd53b3e92a 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -108,7 +108,9 @@ public:  	/*virtual*/ F32 getPixelAspectRatio();  	/*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; } -	/*virtual*/	BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b ); +    U32 getAvailableVRAMMegabytes() override; +	 +    /*virtual*/	BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b );  	/*virtual*/ void *getPlatformWindow();  	/*virtual*/ void bringToFront(); diff --git a/indra/newview/llfloaterlagmeter.cpp b/indra/newview/llfloaterlagmeter.cpp index f72f2631a1..db00f69f03 100644 --- a/indra/newview/llfloaterlagmeter.cpp +++ b/indra/newview/llfloaterlagmeter.cpp @@ -179,7 +179,7 @@ void LLFloaterLagMeter::determineClient()  		{  			mClientCause->setText( getString("client_texture_loading_cause_msg", mStringArgs) );  		} -		else if(LLViewerTexture::sBoundTextureMemory > LLViewerTexture::sMaxBoundTextureMemory) +		else if(LLViewerTexture::isMemoryForTextureLow())  		{  			mClientCause->setText( getString("client_texture_memory_cause_msg", mStringArgs) );  		} diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index b74577315e..99ab854293 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -49,6 +49,8 @@  #include "llviewerobjectlist.h"  #include "llviewertexture.h"  #include "llviewertexturelist.h" +#include "llviewerwindow.h" +#include "llwindow.h"  #include "llvovolume.h"  #include "llviewerstats.h"  #include "llworld.h" @@ -500,10 +502,6 @@ private:  void LLGLTexMemBar::draw()  { -	S32Megabytes bound_mem = LLViewerTexture::sBoundTextureMemory; - 	S32Megabytes max_bound_mem = LLViewerTexture::sMaxBoundTextureMemory; -	S32Megabytes total_mem = LLViewerTexture::sTotalTextureMemory; -	S32Megabytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem;  	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;  	F32 cache_usage = LLAppViewer::getTextureCache()->getUsage().valueInUnits<LLUnits::Megabytes>();  	F32 cache_max_usage = LLAppViewer::getTextureCache()->getMaxUsage().valueInUnits<LLUnits::Megabytes>(); @@ -549,15 +547,10 @@ void LLGLTexMemBar::draw()      U32 texFetchLatMed = U32(recording.getMean(LLTextureFetch::sTexFetchLatency).value() * 1000.0f);      U32 texFetchLatMax = U32(recording.getMax(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); -	text = llformat("GL Tot: %d/%d MB GL Free: %d Sys Free: %d MB Bound: %4d/%4d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB", -					total_mem.value(), -					max_total_mem.value(), -                    LLImageGLThread::getFreeVRAMMegabytes(), +    text = llformat("GL Free: %d Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", +                    gViewerWindow->getWindow()->getAvailableVRAMMegabytes(),                      LLMemory::getAvailableMemKB()/1024, -					bound_mem.value(), -					max_bound_mem.value(),  					LLRenderTarget::sBytesAllocated/(1024*1024), -					LLImageRaw::sGlobalRawMemory >> 20,  					discard_bias,  					cache_usage,  					cache_max_usage); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 6a2b06d9b5..4fc1bdbec3 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -788,8 +788,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)  				LLViewerTexture::updateClass();  			} -            LLImageGLThread::updateClass(); -  			{  				LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_BUMP);  				gBumpImageList.updateImages();  // must be called before gTextureList version so that it's textures are thrown out first. diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 9d6cfbce7c..71526e5e8c 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -155,10 +155,7 @@ LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> >  static LLTrace::SampleStatHandle<bool>   							CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"); -LLTrace::SampleStatHandle<F64Megabytes >	GL_TEX_MEM("gltexmemstat"), -															GL_BOUND_MEM("glboundmemstat"), -															RAW_MEM("rawmemstat"), -															FORMATTED_MEM("formattedmemstat"); +LLTrace::SampleStatHandle<F64Megabytes > FORMATTED_MEM("formattedmemstat");  LLTrace::SampleStatHandle<F64Kilobytes >	DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),  															MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"); diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 017c79b2e3..8d1182d054 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -191,10 +191,8 @@ extern LLTrace::SampleStatHandle<>		FPS_SAMPLE,  extern LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > PACKETS_LOST_PERCENT; -extern LLTrace::SampleStatHandle<F64Megabytes >	GL_TEX_MEM, -																	GL_BOUND_MEM, -																	RAW_MEM, -																	FORMATTED_MEM; +extern LLTrace::SampleStatHandle<F64Megabytes > FORMATTED_MEM; +  extern LLTrace::SampleStatHandle<F64Kilobytes >	DELTA_BANDWIDTH,  																	MAX_BANDWIDTH;  extern SimMeasurement<F64Milliseconds >	SIM_FRAME_TIME, diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index e3ac56d0d3..ac6c86d9c6 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -58,6 +58,8 @@  #include "llvovolume.h"  #include "llviewermedia.h"  #include "lltexturecache.h" +#include "llviewerwindow.h" +#include "llwindow.h"  ///////////////////////////////////////////////////////////////////////////////  // extern @@ -84,11 +86,6 @@ S32 LLViewerTexture::sAuxCount = 0;  LLFrameTimer LLViewerTexture::sEvaluationTimer;  F32 LLViewerTexture::sDesiredDiscardBias = 0.f;  F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -S32Bytes LLViewerTexture::sBoundTextureMemory; -S32Bytes LLViewerTexture::sTotalTextureMemory; -S32Megabytes LLViewerTexture::sMaxBoundTextureMemory; -S32Megabytes LLViewerTexture::sMaxTotalTextureMem; -S32Bytes LLViewerTexture::sMaxDesiredTextureMem;  S8  LLViewerTexture::sCameraMovingDiscardBias = 0;  F32 LLViewerTexture::sCameraMovingBias = 0.0f;  S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size @@ -528,7 +525,7 @@ void LLViewerTexture::getGPUMemoryForTextures(S32Megabytes &gpu, S32Megabytes &p      timer.reset();      { -        gpu_res = (S32Megabytes) LLImageGLThread::getFreeVRAMMegabytes(); +        gpu_res = (S32Megabytes)gViewerWindow->getWindow()->getAvailableVRAMMegabytes();          //check main memory, only works for windows.          LLMemory::updateMemoryInfo(); @@ -553,27 +550,7 @@ void LLViewerTexture::updateClass()  	LLViewerMediaTexture::updateClass(); -	sBoundTextureMemory = LLImageGL::sBoundTextureMemory; -	sTotalTextureMemory = LLImageGL::sGlobalTextureMemory; -	sMaxBoundTextureMemory = gTextureList.getMaxResidentTexMem(); -	sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem(); -	sMaxDesiredTextureMem = sMaxTotalTextureMem; //in Bytes, by default and when total used texture memory is small. - -	if (sBoundTextureMemory >= sMaxBoundTextureMemory || -		sTotalTextureMemory >= sMaxTotalTextureMem) -	{ -		//when texture memory overflows, lower down the threshold to release the textures more aggressively. -		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, F32Bytes(gMaxVideoRam)); -	 -		// If we are using more texture memory than we should, -		// scale up the desired discard level -		if (sEvaluationTimer.getElapsedTimeF32() > discard_delta_time) -		{ -			sDesiredDiscardBias += discard_bias_delta; -			sEvaluationTimer.reset(); -		} -	} -	else if(isMemoryForTextureLow()) +	if(isMemoryForTextureLow())  	{  		// Note: isMemoryForTextureLow() uses 1s delay, make sure we waited enough for it to recheck  		if (sEvaluationTimer.getElapsedTimeF32() > GPU_MEMORY_CHECK_WAIT_TIME) @@ -583,8 +560,6 @@ void LLViewerTexture::updateClass()  		}  	}  	else if (sDesiredDiscardBias > 0.0f -			 && sBoundTextureMemory < sMaxBoundTextureMemory * texmem_lower_bound_scale -			 && sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale  			 && isMemoryForTextureSuficientlyFree())  	{  		// If we are using less texture memory than we should, @@ -1352,10 +1327,7 @@ void LLViewerFetchedTexture::dump()  void LLViewerFetchedTexture::destroyTexture()   {      LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; -	if(LLImageGL::sGlobalTextureMemory < sMaxDesiredTextureMem * 0.95f)//not ready to release unused memory. -	{ -		return ; -	} +  	if (mNeedsCreateTexture)//return if in the process of generating a new texture.  	{  		return; @@ -3400,18 +3372,6 @@ void LLViewerLODTexture::processTextureStats()  				//needs to release texture memory urgently  				scaleDown();  			} -			// Limit the amount of GL memory bound each frame -			else if ( sBoundTextureMemory > sMaxBoundTextureMemory * texmem_middle_bound_scale && -				(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) -			{ -				scaleDown(); -			} -			// Only allow GL to have 2x the video card memory -			else if ( sTotalTextureMemory > sMaxTotalTextureMem * texmem_middle_bound_scale && -				(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) -			{ -				scaleDown(); -			}  		}  		if (isUpdateFrozen() // we are out of memory and nearing max allowed bias diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index b953d7006b..0640efe6df 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -188,10 +188,11 @@ private:  	virtual void switchToCachedImage(); -	static bool isMemoryForTextureLow() ;  	static bool isMemoryForTextureSuficientlyFree();  	static void getGPUMemoryForTextures(S32Megabytes &gpu, S32Megabytes &physical); +public: +    static bool isMemoryForTextureLow();  protected:  	LLUUID mID;  	S32 mTextureListType; // along with mID identifies where to search for this texture in TextureList @@ -226,11 +227,6 @@ public:  	static LLFrameTimer sEvaluationTimer;  	static F32 sDesiredDiscardBias;  	static F32 sDesiredDiscardScale; -	static S32Bytes sBoundTextureMemory; -	static S32Bytes sTotalTextureMemory; -	static S32Megabytes sMaxBoundTextureMemory; -	static S32Megabytes sMaxTotalTextureMem; -	static S32Bytes sMaxDesiredTextureMem ;  	static S8  sCameraMovingDiscardBias;  	static F32 sCameraMovingBias;  	static S32 sMaxSculptRez ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index e0b778af59..2a88d9314b 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -784,9 +784,6 @@ void LLViewerTextureList::updateImages(F32 max_time)  		using namespace LLStatViewer;  		sample(NUM_IMAGES, sNumImages);  		sample(NUM_RAW_IMAGES, LLImageRaw::sRawImageCount); -		sample(GL_TEX_MEM, LLImageGL::sGlobalTextureMemory); -		sample(GL_BOUND_MEM, LLImageGL::sBoundTextureMemory); -		sample(RAW_MEM, F64Bytes(LLImageRaw::sGlobalRawMemory));  		sample(FORMATTED_MEM, F64Bytes(LLImageFormatted::sGlobalFormattedMemory));  	} diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index a54c29a404..47d612ab9a 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5532,8 +5532,6 @@ void LLViewerWindow::stopGL(BOOL save_state)  			LLGLSLShader* shader = *(LLGLSLShader::sInstances.begin());  			shader->unload();  		} -		 -		LL_INFOS() << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemory.value() << " bytes" << LL_ENDL;  	}  } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 60a69a4ac4..49f5f40f03 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2823,7 +2823,6 @@ void LLVOAvatarSelf::deleteScratchTextures()  		LL_DEBUGS() << "Clearing Scratch Textures " << (S32Kilobytes)sScratchTexBytes << LL_ENDL;  		delete_and_clear(sScratchTexNames); -		LLImageGL::sGlobalTextureMemory -= sScratchTexBytes;  		sScratchTexBytes = S32Bytes(0);  	}  } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ccf5b69ea0..a5ae52af93 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3712,7 +3712,7 @@ void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize)      if (tex)      {          LLImageGL* gl_tex = tex->getGLTexture(); -        if (gl_tex && gl_tex->updateBindStats(gl_tex->mTextureMemory)) +        if (gl_tex && gl_tex->updateBindStats())          {              tex->setActive();              tex->addTextureStats(vsize); | 
