diff options
| author | Oz Linden <oz@lindenlab.com> | 2013-06-28 13:29:11 -0400 | 
|---|---|---|
| committer | Oz Linden <oz@lindenlab.com> | 2013-06-28 13:29:11 -0400 | 
| commit | 5f397fa58352fb58d79b72148904f925416f4978 (patch) | |
| tree | 96d35a660b4cd9227a51d7cc92f642a31ce01c23 | |
| parent | 743b6ca6177f46d7d7f964993ee226ef6706d408 (diff) | |
NORSPEC-206: read RenderMaterialsCapability throttle rate per second from simulator
| -rw-r--r-- | indra/newview/llmaterialmgr.cpp | 24 | ||||
| -rw-r--r-- | indra/newview/llmaterialmgr.h | 3 | ||||
| -rwxr-xr-x | indra/newview/llviewerregion.cpp | 32 | ||||
| -rwxr-xr-x | indra/newview/llviewerregion.h | 8 | 
4 files changed, 56 insertions, 11 deletions
diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index ad9958546c..96dd402d84 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -543,11 +543,9 @@ void LLMaterialMgr::onIdle(void*)  		instancep->processGetAllQueue();  	} -	static LLFrameTimer mPutTimer; -	if ( (!instancep->mPutQueue.empty()) && (mPutTimer.hasExpired()) ) +	if (!instancep->mPutQueue.empty())  	{  		instancep->processPutQueue(); -		mPutTimer.resetWithExpiry(MATERIALS_PUT_THROTTLE_SECS);  	}  } @@ -564,14 +562,14 @@ void LLMaterialMgr::processGetQueue()  			continue;  		} -		const LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); +		LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id);  		if (!regionp)  		{  			LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL;  			mGetQueue.erase(itRegionQueue);  			continue;  		} -		else if (!regionp->capabilitiesReceived()) +		else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled())  		{  			continue;  		} @@ -628,6 +626,7 @@ void LLMaterialMgr::processGetQueue()  		LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << " for " << materialsData.size() << " materials."   			<< "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL;  		LLHTTPClient::post(capURL, postData, materialsResponder); +		regionp->resetMaterialsCapThrottle();  	}  } @@ -646,7 +645,7 @@ void LLMaterialMgr::processGetAllQueue()  			clearGetQueues(region_id);		// Invalidates region_id  			continue;  		} -		else if (!regionp->capabilitiesReceived()) +		else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled())  		{  			continue;  		} @@ -663,6 +662,7 @@ void LLMaterialMgr::processGetAllQueue()  		LL_DEBUGS("Materials") << "GET all for region " << region_id << "url " << capURL << LL_ENDL;  		LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion));  		LLHTTPClient::get(capURL, materialsResponder); +		regionp->resetMaterialsCapThrottle();  		mGetAllPending.insert(std::pair<LLUUID, F64>(region_id, LLFrameTimer::getTotalSeconds()));  		mGetAllQueue.erase(itRegion);	// Invalidates region_id  	} @@ -670,7 +670,7 @@ void LLMaterialMgr::processGetAllQueue()  void LLMaterialMgr::processPutQueue()  { -	typedef std::map<const LLViewerRegion*, LLSD> regionput_request_map; +	typedef std::map<LLViewerRegion*, LLSD> regionput_request_map;  	regionput_request_map requests;  	put_queue_t::iterator loopQueue = mPutQueue.begin(); @@ -687,13 +687,13 @@ void LLMaterialMgr::processPutQueue()  		}  		else  		{ -			const LLViewerRegion* regionp = objectp->getRegion(); +			LLViewerRegion* regionp = objectp->getRegion();  			if ( !regionp )  			{  				LL_WARNS("Materials") << "Object region is NULL" << LL_ENDL;  				mPutQueue.erase(itQueue);  			} -			else if ( regionp->capabilitiesReceived()) +			else if ( regionp->capabilitiesReceived() && !regionp->materialsCapThrottled())  			{  				LLSD& facesData = requests[regionp]; @@ -722,11 +722,12 @@ void LLMaterialMgr::processPutQueue()  	for (regionput_request_map::const_iterator itRequest = requests.begin(); itRequest != requests.end(); ++itRequest)  	{ -		std::string capURL = itRequest->first->getCapability(MATERIALS_CAPABILITY_NAME); +		LLViewerRegion* regionp = itRequest->first; +		std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME);  		if (capURL.empty())  		{  			LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME -				<< "' is not defined on region '" << itRequest->first->getName() << "'" << LL_ENDL; +				<< "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL;  			continue;  		} @@ -749,6 +750,7 @@ void LLMaterialMgr::processPutQueue()  			LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces to region " << itRequest->first->getName() << LL_ENDL;  			LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2));  			LLHTTPClient::put(capURL, putData, materialsResponder); +			regionp->resetMaterialsCapThrottle();  		}  		else  		{ diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index e83f1f4e01..2836019c27 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -126,6 +126,9 @@ protected:  	material_map_t mMaterials;  	U32 getMaxEntries(const LLViewerRegion* regionp); + +	LLFrameTimer mCapThrottleTimer; +	F32 getThrottleIntervalSecs(const LLUUID& region_id);  };  #endif // LL_LLMATERIALMGR_H diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index a4f6340d9e..0f8decc643 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1944,3 +1944,35 @@ bool LLViewerRegion::dynamicPathfindingEnabled() const  			 mSimulatorFeatures["DynamicPathfindingEnabled"].asBoolean());  } +void LLViewerRegion::resetMaterialsCapThrottle() +{ +	F32 requests_per_sec = 	1.0f; // original default; +	if (   mSimulatorFeatures.has("RenderMaterialsCapability") +		&& mSimulatorFeatures["RenderMaterialsCapability"].isReal() ) +	{ +		requests_per_sec = mSimulatorFeatures["RenderMaterialsCapability"].asReal(); +		if ( requests_per_sec != 0.0f ) +		{ +			requests_per_sec = 1.0f; +			LL_WARNS("Materials") +				<< "region '" << getName() +				<< "' returned zero for RenderMaterialsCapability; using default " +				<< requests_per_sec << " per second" +				<< LL_ENDL; +		} +		LL_DEBUGS_ONCE("Materials") << "region '" << getName() +									<< "' RenderMaterialsCapability " << requests_per_sec +									<< LL_ENDL; +	} +	else +	{ +		LL_DEBUGS("Materials") +			<< "region '" << getName() +			<< "' did not return RenderMaterialsCapability, using default " +			<< requests_per_sec << " per second" +			<< LL_ENDL; +	} +	 +	mMaterialsCapThrottleTimer.resetWithExpiry( 1.0f / requests_per_sec ); +} + diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 031159183b..a3db7f5ac7 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -43,6 +43,7 @@  #include "llcapabilityprovider.h"  #include "m4math.h"					// LLMatrix4  #include "llhttpclient.h" +#include "llframetimer.h"  // Surface id's  #define LAND  1 @@ -342,6 +343,10 @@ public:  	void getNeighboringRegionsStatus( std::vector<S32>& regions );  	const LLViewerRegionImpl * getRegionImpl() const { return mImpl; }  	LLViewerRegionImpl * getRegionImplNC() { return mImpl; } + +	// implements the materials capability throttle +	bool materialsCapThrottled() const { return !mMaterialsCapThrottleTimer.hasExpired(); } +	void resetMaterialsCapThrottle();  public:  	struct CompareDistance @@ -434,6 +439,9 @@ private:  	BOOL mReleaseNotesRequested;  	LLSD mSimulatorFeatures; + +	// the materials capability throttle +	LLFrameTimer mMaterialsCapThrottleTimer;  };  inline BOOL LLViewerRegion::getRegionProtocol(U64 protocol) const  | 
