Fixes and optimization backports from V3 via Henri Beauchamp (Cool VL)

Sun, 18 Dec 2011 13:22:35 +0100

author
Ansariel
date
Sun, 18 Dec 2011 13:22:35 +0100
changeset 1608
d95fae20e46b
parent 1607
bf6ce4770b56
child 1609
0a3680990a34

Fixes and optimization backports from V3 via Henri Beauchamp (Cool VL)

indra/llcommon/llprocessor.cpp file | annotate | diff | revisions
indra/llcommon/llprocessor.h file | annotate | diff | revisions
indra/llcommon/llqueuedthread.cpp file | annotate | diff | revisions
indra/llcommon/llqueuedthread.h file | annotate | diff | revisions
indra/llcommon/llworkerthread.cpp file | annotate | diff | revisions
indra/llcommon/llworkerthread.h file | annotate | diff | revisions
indra/llimage/llimageworker.cpp file | annotate | diff | revisions
indra/llimage/llimageworker.h file | annotate | diff | revisions
indra/llmath/v4coloru.cpp file | annotate | diff | revisions
indra/llrender/llrendertarget.cpp file | annotate | diff | revisions
indra/llrender/llvertexbuffer.cpp file | annotate | diff | revisions
indra/newview/lldrawable.cpp file | annotate | diff | revisions
indra/newview/llspatialpartition.cpp file | annotate | diff | revisions
indra/newview/llspatialpartition.h file | annotate | diff | revisions
indra/newview/lltexturecache.cpp file | annotate | diff | revisions
indra/newview/lltexturecache.h file | annotate | diff | revisions
indra/newview/lltexturefetch.cpp file | annotate | diff | revisions
indra/newview/lltexturefetch.h file | annotate | diff | revisions
indra/newview/llviewercontrol.cpp file | annotate | diff | revisions
indra/newview/llviewerdisplay.cpp file | annotate | diff | revisions
indra/newview/llviewerdisplay.h file | annotate | diff | revisions
     1.1 --- a/indra/llcommon/llprocessor.cpp	Sun Dec 18 13:16:12 2011 +0100
     1.2 +++ b/indra/llcommon/llprocessor.cpp	Sun Dec 18 13:22:35 2011 +0100
     1.3 @@ -44,20 +44,6 @@
     1.4  
     1.5  #include "llsd.h"
     1.6  
     1.7 -#if LL_MSVC && _M_X64
     1.8 -#      define LL_X86_64 1
     1.9 -#      define LL_X86 1
    1.10 -#elif LL_MSVC && _M_IX86
    1.11 -#      define LL_X86 1
    1.12 -#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
    1.13 -#      define LL_X86_64 1
    1.14 -#      define LL_X86 1
    1.15 -#elif LL_GNUC && ( defined(__i386__) )
    1.16 -#      define LL_X86 1
    1.17 -#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
    1.18 -#      define LL_PPC 1
    1.19 -#endif
    1.20 -
    1.21  class LLProcessorInfoImpl; // foward declaration for the mImpl;
    1.22  
    1.23  namespace 
     2.1 --- a/indra/llcommon/llprocessor.h	Sun Dec 18 13:16:12 2011 +0100
     2.2 +++ b/indra/llcommon/llprocessor.h	Sun Dec 18 13:22:35 2011 +0100
     2.3 @@ -27,6 +27,21 @@
     2.4  
     2.5  #ifndef LLPROCESSOR_H
     2.6  #define LLPROCESSOR_H
     2.7 +
     2.8 +#if LL_MSVC && _M_X64
     2.9 +#      define LL_X86_64 1
    2.10 +#      define LL_X86 1
    2.11 +#elif LL_MSVC && _M_IX86
    2.12 +#      define LL_X86 1
    2.13 +#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
    2.14 +#      define LL_X86_64 1
    2.15 +#      define LL_X86 1
    2.16 +#elif LL_GNUC && ( defined(__i386__) )
    2.17 +#      define LL_X86 1
    2.18 +#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
    2.19 +#      define LL_PPC 1
    2.20 +#endif
    2.21 +
    2.22  class LLProcessorInfoImpl;
    2.23  
    2.24  class LL_COMMON_API LLProcessorInfo
     3.1 --- a/indra/llcommon/llqueuedthread.cpp	Sun Dec 18 13:16:12 2011 +0100
     3.2 +++ b/indra/llcommon/llqueuedthread.cpp	Sun Dec 18 13:22:35 2011 +0100
     3.3 @@ -115,7 +115,7 @@
     3.4  
     3.5  // MAIN THREAD
     3.6  // virtual
     3.7 -S32 LLQueuedThread::update(U32 max_time_ms)
     3.8 +S32 LLQueuedThread::update(F32 max_time_ms)
     3.9  {
    3.10  	if (!mStarted)
    3.11  	{
    3.12 @@ -128,7 +128,7 @@
    3.13  	return updateQueue(max_time_ms);
    3.14  }
    3.15  
    3.16 -S32 LLQueuedThread::updateQueue(U32 max_time_ms)
    3.17 +S32 LLQueuedThread::updateQueue(F32 max_time_ms)
    3.18  {
    3.19  	F64 max_time = (F64)max_time_ms * .001;
    3.20  	LLTimer timer;
     4.1 --- a/indra/llcommon/llqueuedthread.h	Sun Dec 18 13:16:12 2011 +0100
     4.2 +++ b/indra/llcommon/llqueuedthread.h	Sun Dec 18 13:22:35 2011 +0100
     4.3 @@ -180,8 +180,8 @@
     4.4  public:
     4.5  	bool waitForResult(handle_t handle, bool auto_complete = true);
     4.6  
     4.7 -	virtual S32 update(U32 max_time_ms);
     4.8 -	S32 updateQueue(U32 max_time_ms);
     4.9 +	virtual S32 update(F32 max_time_ms);
    4.10 +	S32 updateQueue(F32 max_time_ms);
    4.11  	
    4.12  	void waitOnPending();
    4.13  	void printQueueStats();
     5.1 --- a/indra/llcommon/llworkerthread.cpp	Sun Dec 18 13:16:12 2011 +0100
     5.2 +++ b/indra/llcommon/llworkerthread.cpp	Sun Dec 18 13:22:35 2011 +0100
     5.3 @@ -84,7 +84,7 @@
     5.4  }
     5.5  
     5.6  // virtual
     5.7 -S32 LLWorkerThread::update(U32 max_time_ms)
     5.8 +S32 LLWorkerThread::update(F32 max_time_ms)
     5.9  {
    5.10  	S32 res = LLQueuedThread::update(max_time_ms);
    5.11  	// Delete scheduled workers
     6.1 --- a/indra/llcommon/llworkerthread.h	Sun Dec 18 13:16:12 2011 +0100
     6.2 +++ b/indra/llcommon/llworkerthread.h	Sun Dec 18 13:22:35 2011 +0100
     6.3 @@ -94,7 +94,7 @@
     6.4  				   bool should_pause = false);
     6.5  	~LLWorkerThread();
     6.6  
     6.7 -	/*virtual*/ S32 update(U32 max_time_ms);
     6.8 +	/*virtual*/ S32 update(F32 max_time_ms);
     6.9  	
    6.10  	handle_t addWorkRequest(LLWorkerClass* workerclass, S32 param, U32 priority = PRIORITY_NORMAL);
    6.11  	
     7.1 --- a/indra/llimage/llimageworker.cpp	Sun Dec 18 13:16:12 2011 +0100
     7.2 +++ b/indra/llimage/llimageworker.cpp	Sun Dec 18 13:22:35 2011 +0100
     7.3 @@ -50,7 +50,7 @@
     7.4  
     7.5  // MAIN THREAD
     7.6  // virtual
     7.7 -S32 LLImageDecodeThread::update(U32 max_time_ms)
     7.8 +S32 LLImageDecodeThread::update(F32 max_time_ms)
     7.9  {
    7.10  	LLMutexLock lock(&mCreationMutex);
    7.11  	for (creation_list_t::iterator iter = mCreationList.begin();
     8.1 --- a/indra/llimage/llimageworker.h	Sun Dec 18 13:16:12 2011 +0100
     8.2 +++ b/indra/llimage/llimageworker.h	Sun Dec 18 13:22:35 2011 +0100
     8.3 @@ -84,7 +84,7 @@
     8.4  	handle_t decodeImage(LLImageFormatted* image,
     8.5  						 U32 priority, S32 discard, BOOL needs_aux,
     8.6  						 Responder* responder);
     8.7 -	S32 update(U32 max_time_ms);
     8.8 +	S32 update(F32 max_time_ms);
     8.9  
    8.10  	// Used by unit tests to check the consistency of the thread instance
    8.11  	S32 tut_size();
     9.1 --- a/indra/llmath/v4coloru.cpp	Sun Dec 18 13:16:12 2011 +0100
     9.2 +++ b/indra/llmath/v4coloru.cpp	Sun Dec 18 13:22:35 2011 +0100
     9.3 @@ -126,13 +126,11 @@
     9.4  # define LL_X86_64 1
     9.5  #elif LL_GNUC && (defined(__amd64__) || defined(__x86_64__))
     9.6  # define LL_X86_64 1
     9.7 -#else
     9.8 -# define LL_X86_64 0
     9.9  #endif
    9.10  
    9.11  U32 LLColor4U::asRGBA() const
    9.12  {
    9.13 -#if LL_X86_64
    9.14 +#ifdef LL_X86_64
    9.15  	U32 rgba(0);
    9.16  
    9.17  	// Little endian: values are swapped in memory. The original code access
    9.18 @@ -153,7 +151,7 @@
    9.19  
    9.20  void LLColor4U::fromRGBA(U32 rgba)
    9.21  {
    9.22 -#if LL_X86_64
    9.23 +#ifdef LL_X86_64
    9.24  	// Little endian: values are swapped in memory. The original code access
    9.25  	// the array like a U32, so we need to swap here
    9.26  	mV[0] = rgba & 0xFF;
    10.1 --- a/indra/llrender/llrendertarget.cpp	Sun Dec 18 13:16:12 2011 +0100
    10.2 +++ b/indra/llrender/llrendertarget.cpp	Sun Dec 18 13:22:35 2011 +0100
    10.3 @@ -465,7 +465,8 @@
    10.4  	gGL.flush();
    10.5  	if (!source.mFBO || !mFBO)
    10.6  	{
    10.7 -		llerrs << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
    10.8 +		llwarns << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
    10.9 +		return;
   10.10  	}
   10.11  
   10.12  	if (mSampleBuffer)
    11.1 --- a/indra/llrender/llvertexbuffer.cpp	Sun Dec 18 13:16:12 2011 +0100
    11.2 +++ b/indra/llrender/llvertexbuffer.cpp	Sun Dec 18 13:22:35 2011 +0100
    11.3 @@ -937,8 +937,8 @@
    11.4  			//check the availability of memory
    11.5  			U32 avail_phy_mem, avail_vir_mem;
    11.6  			LLMemoryInfo::getAvailableMemoryKB(avail_phy_mem, avail_vir_mem);
    11.7 -			llinfos << "Available physical mwmory(KB): " << avail_phy_mem << llendl; 
    11.8 -			llinfos << "Available virtual memory(KB): " << avail_vir_mem << llendl;
    11.9 +			llinfos << "Available physical memory: " << avail_phy_mem << "KB" << llendl; 
   11.10 +			llinfos << "Available virtual memory: " << avail_vir_mem << "KB" << llendl;
   11.11  
   11.12  			if (!sDisableVBOMapping)
   11.13  			{
    12.1 --- a/indra/newview/lldrawable.cpp	Sun Dec 18 13:16:12 2011 +0100
    12.2 +++ b/indra/newview/lldrawable.cpp	Sun Dec 18 13:22:35 2011 +0100
    12.3 @@ -124,16 +124,16 @@
    12.4  		gPipeline.checkReferences(this);
    12.5  	}
    12.6  
    12.7 +	if (LLSpatialGroup::sNoDelete)
    12.8 +	{
    12.9 +		llerrs << "Illegal deletion of LLDrawable!" << llendl;
   12.10 +	}
   12.11 +
   12.12  	if (isDead())
   12.13  	{
   12.14  		sNumZombieDrawables--;
   12.15  	}
   12.16  
   12.17 -	if (LLSpatialGroup::sNoDelete)
   12.18 -	{
   12.19 -		llerrs << "Illegal deletion of LLDrawable!" << llendl;
   12.20 -	}
   12.21 -
   12.22  	std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
   12.23  	mFaces.clear();
   12.24  		
    13.1 --- a/indra/newview/llspatialpartition.cpp	Sun Dec 18 13:16:12 2011 +0100
    13.2 +++ b/indra/newview/llspatialpartition.cpp	Sun Dec 18 13:22:35 2011 +0100
    13.3 @@ -34,22 +34,27 @@
    13.4  
    13.5  #include "llspatialpartition.h"
    13.6  
    13.7 -#include "llviewerwindow.h"
    13.8 -#include "llviewerobjectlist.h"
    13.9 -#include "llvovolume.h"
   13.10 +#include "llimageworker.h"
   13.11 +#include "lloctree.h"
   13.12 +#include "llrender.h"
   13.13  #include "llvolume.h"
   13.14  #include "llvolumeoctree.h"
   13.15 +
   13.16 +#include "llappviewer.h"
   13.17 +#include "llcamera.h"
   13.18  #include "llface.h"
   13.19 +#include "llmeshrepository.h"
   13.20 +#include "llphysicsshapebuilderutil.h"
   13.21 +#include "lltexturecache.h"
   13.22 +#include "lltexturefetch.h"
   13.23  #include "llviewercontrol.h"
   13.24 +#include "llviewerobjectlist.h"
   13.25  #include "llviewerregion.h"
   13.26 -#include "llcamera.h"
   13.27 -#include "pipeline.h"
   13.28 -#include "llmeshrepository.h"
   13.29 -#include "llrender.h"
   13.30 -#include "lloctree.h"
   13.31 -#include "llphysicsshapebuilderutil.h"
   13.32 +#include "llviewerwindow.h"
   13.33  #include "llvoavatar.h"
   13.34  #include "llvolumemgr.h"
   13.35 +#include "llvovolume.h"
   13.36 +#include "pipeline.h"
   13.37  
   13.38  const F32 SG_OCCLUSION_FUDGE = 0.25f;
   13.39  #define SG_DISCARD_TOLERANCE 0.01f
   13.40 @@ -1083,6 +1088,7 @@
   13.41  	for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
   13.42  	{
   13.43  		mOcclusionQuery[i] = 0;
   13.44 +		mOcclusionIssued[i] = 0;
   13.45  		mOcclusionState[i] = parent ? SG_STATE_INHERIT_MASK & parent->mOcclusionState[i] : 0;
   13.46  		mVisible[i] = 0;
   13.47  	}
   13.48 @@ -1420,7 +1426,24 @@
   13.49  			GLuint available = 0;
   13.50  			if (mOcclusionQuery[LLViewerCamera::sCurCameraID])
   13.51  			{
   13.52 -				glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available);
   13.53 +				glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID],
   13.54 +									   GL_QUERY_RESULT_AVAILABLE_ARB, &available);
   13.55 +				if (mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount)
   13.56 +				{	//query was issued last frame, wait until it's available
   13.57 +					S32 max_loop = 1024;
   13.58 +					LLFastTimer t2(LLFastTimer::FTM_OCCLUSION_WAIT);
   13.59 +					while (!available && max_loop-- > 0)
   13.60 +					{
   13.61 +						// Do some useful work while we wait
   13.62 +						F32 max_time = llmin(gFrameIntervalSeconds * 10.f, 1.f);
   13.63 +						LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
   13.64 +						LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
   13.65 +						LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread
   13.66 +
   13.67 +						glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID],
   13.68 +											   GL_QUERY_RESULT_AVAILABLE_ARB, &available);
   13.69 +					}
   13.70 +				}
   13.71  			}
   13.72  			else
   13.73  			{
   13.74 @@ -1516,6 +1539,10 @@
   13.75  #endif
   13.76  					{
   13.77  						LLFastTimer t2(LLFastTimer::FTM_PUSH_OCCLUSION_VERTS);
   13.78 +
   13.79 +						// Store which frame this query was issued on
   13.80 +						mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount;
   13.81 +
   13.82  						glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]);
   13.83  
   13.84  						mOcclusionVerts->setBuffer(LLVertexBuffer::MAP_VERTEX);
    14.1 --- a/indra/newview/llspatialpartition.h	Sun Dec 18 13:16:12 2011 +0100
    14.2 +++ b/indra/newview/llspatialpartition.h	Sun Dec 18 13:22:35 2011 +0100
    14.3 @@ -364,6 +364,7 @@
    14.4  
    14.5  	U32 mState;
    14.6  	U32 mOcclusionState[LLViewerCamera::NUM_CAMERAS];
    14.7 +	U32 mOcclusionIssued[LLViewerCamera::NUM_CAMERAS];
    14.8  	S32 mLODHash;
    14.9  	static S32 sLODSeed;
   14.10  
    15.1 --- a/indra/newview/lltexturecache.cpp	Sun Dec 18 13:16:12 2011 +0100
    15.2 +++ b/indra/newview/lltexturecache.cpp	Sun Dec 18 13:22:35 2011 +0100
    15.3 @@ -769,7 +769,7 @@
    15.4  //////////////////////////////////////////////////////////////////////////////
    15.5  
    15.6  //virtual
    15.7 -S32 LLTextureCache::update(U32 max_time_ms)
    15.8 +S32 LLTextureCache::update(F32 max_time_ms)
    15.9  {
   15.10  	static LLFrameTimer timer ;
   15.11  	static const F32 MAX_TIME_INTERVAL = 300.f ; //seconds.
    16.1 --- a/indra/newview/lltexturecache.h	Sun Dec 18 13:16:12 2011 +0100
    16.2 +++ b/indra/newview/lltexturecache.h	Sun Dec 18 13:22:35 2011 +0100
    16.3 @@ -108,7 +108,7 @@
    16.4  	LLTextureCache(bool threaded);
    16.5  	~LLTextureCache();
    16.6  
    16.7 -	/*virtual*/ S32 update(U32 max_time_ms);	
    16.8 +	/*virtual*/ S32 update(F32 max_time_ms);	
    16.9  	
   16.10  	void purgeCache(ELLPath location);
   16.11  	void setReadOnly(BOOL read_only) ;
    17.1 --- a/indra/newview/lltexturefetch.cpp	Sun Dec 18 13:16:12 2011 +0100
    17.2 +++ b/indra/newview/lltexturefetch.cpp	Sun Dec 18 13:22:35 2011 +0100
    17.3 @@ -1820,7 +1820,7 @@
    17.4  
    17.5  // MAIN THREAD
    17.6  //virtual
    17.7 -S32 LLTextureFetch::update(U32 max_time_ms)
    17.8 +S32 LLTextureFetch::update(F32 max_time_ms)
    17.9  {
   17.10  	{
   17.11  		mNetworkQueueMutex.lock();
    18.1 --- a/indra/newview/lltexturefetch.h	Sun Dec 18 13:16:12 2011 +0100
    18.2 +++ b/indra/newview/lltexturefetch.h	Sun Dec 18 13:22:35 2011 +0100
    18.3 @@ -57,7 +57,7 @@
    18.4  	LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* imagedecodethread, bool threaded);
    18.5  	~LLTextureFetch();
    18.6  
    18.7 -	/*virtual*/ S32 update(U32 max_time_ms);	
    18.8 +	/*virtual*/ S32 update(F32 max_time_ms);	
    18.9  	void shutDownTextureCacheThread() ; //called in the main thread after the TextureCacheThread shuts down.
   18.10  	void shutDownImageDecodeThread() ;  //called in the main thread after the ImageDecodeThread shuts down.
   18.11  
    19.1 --- a/indra/newview/llviewercontrol.cpp	Sun Dec 18 13:16:12 2011 +0100
    19.2 +++ b/indra/newview/llviewercontrol.cpp	Sun Dec 18 13:22:35 2011 +0100
    19.3 @@ -95,6 +95,7 @@
    19.4  extern BOOL gResizeScreenTexture;
    19.5  extern BOOL gDebugGL;
    19.6  extern BOOL gAuditTexture;
    19.7 +extern bool gUpdateDrawDistance;
    19.8  ////////////////////////////////////////////////////////////////////////////
    19.9  // Listeners
   19.10  
   19.11 @@ -106,9 +107,7 @@
   19.12  
   19.13  static bool handleRenderFarClipChanged(const LLSD& newvalue)
   19.14  {
   19.15 -	F32 draw_distance = (F32) newvalue.asReal();
   19.16 -	gAgent.mDrawDistance = draw_distance;
   19.17 -	LLWorld::getInstance()->setLandFarClip(draw_distance);
   19.18 +	gUpdateDrawDistance = true;	// updated in llviewerdisplay.cpp
   19.19  	return true;
   19.20  }
   19.21  
    20.1 --- a/indra/newview/llviewerdisplay.cpp	Sun Dec 18 13:16:12 2011 +0100
    20.2 +++ b/indra/newview/llviewerdisplay.cpp	Sun Dec 18 13:22:35 2011 +0100
    20.3 @@ -97,7 +97,8 @@
    20.4  LLFrameTimer gTeleportDisplayTimer;
    20.5  LLFrameTimer gTeleportArrivalTimer;
    20.6  F32			 gSavedDrawDistance = 0.0f;
    20.7 -const F32		RESTORE_GL_TIME = 5.f;	// Wait this long while reloading textures before we raise the curtain
    20.8 +bool		 gUpdateDrawDistance = false;
    20.9 +const F32	 RESTORE_GL_TIME = 5.f;	// Wait this long while reloading textures before we raise the curtain
   20.10  
   20.11  BOOL gForceRenderLandFence = FALSE;
   20.12  BOOL gDisplaySwapBuffers = FALSE;
   20.13 @@ -512,6 +513,18 @@
   20.14  		}
   20.15  	}
   20.16  
   20.17 +	// We do this here instead of inside of handleRenderFarClipChanged() in
   20.18 +	// llviewercontrol.cpp to ensure this is not done during rendering, which
   20.19 +	// would cause drawables to get destroyed while LLSpatialGroup::sNoDelete
   20.20 +	// is true and would therefore cause a crash.
   20.21 +	if (gUpdateDrawDistance)
   20.22 +	{
   20.23 +		gUpdateDrawDistance = false;
   20.24 +		F32 draw_distance = gSavedSettings.getF32("RenderFarClip");
   20.25 +		gAgent.mDrawDistance = draw_distance;
   20.26 +		LLWorld::getInstance()->setLandFarClip(draw_distance);
   20.27 +	}
   20.28 +
   20.29  	//////////////////////////
   20.30  	//
   20.31  	// Prepare for the next frame
    21.1 --- a/indra/newview/llviewerdisplay.h	Sun Dec 18 13:16:12 2011 +0100
    21.2 +++ b/indra/newview/llviewerdisplay.h	Sun Dec 18 13:22:35 2011 +0100
    21.3 @@ -48,5 +48,6 @@
    21.4  extern BOOL gResizeScreenTexture;
    21.5  extern BOOL gWindowResized;
    21.6  extern F32  gSavedDrawDistance;
    21.7 +extern bool gUpdateDrawDistance;
    21.8  
    21.9  #endif // LL_LLVIEWERDISPLAY_H

mercurial