diff options
| author | Oz Linden <oz@lindenlab.com> | 2013-01-17 13:54:39 -0500 | 
|---|---|---|
| committer | Oz Linden <oz@lindenlab.com> | 2013-01-17 13:54:39 -0500 | 
| commit | 841dc5da2ef9626fa4ab9255681d217df62a6b0b (patch) | |
| tree | 2c5bacebcb27b78d318b6e162334488f6e515974 /indra/llrender | |
| parent | b7f8a2479249646c7fb38ead195d5197ab733c94 (diff) | |
| parent | d16757545c91d4f7dac3c52a311ad0f0239052e1 (diff) | |
merge up to 3.4.4
Diffstat (limited to 'indra/llrender')
| -rw-r--r-- | indra/llrender/llfontgl.cpp | 4 | ||||
| -rw-r--r-- | indra/llrender/llfontgl.h | 2 | ||||
| -rw-r--r-- | indra/llrender/llfontregistry.cpp | 30 | ||||
| -rw-r--r-- | indra/llrender/llfontregistry.h | 4 | ||||
| -rw-r--r-- | indra/llrender/llgl.h | 4 | ||||
| -rw-r--r-- | indra/llrender/llglheaders.h | 5 | ||||
| -rw-r--r-- | indra/llrender/llglstates.h | 5 | ||||
| -rwxr-xr-x[-rw-r--r--] | indra/llrender/llimagegl.cpp | 17 | ||||
| -rwxr-xr-x[-rw-r--r--] | indra/llrender/llimagegl.h | 2 | ||||
| -rw-r--r-- | indra/llrender/llrender.cpp | 13 | ||||
| -rw-r--r-- | indra/llrender/llrender.h | 1 | ||||
| -rw-r--r-- | indra/llrender/llrendertarget.cpp | 49 | ||||
| -rw-r--r-- | indra/llrender/llrendertarget.h | 5 | ||||
| -rw-r--r-- | indra/llrender/llshadermgr.cpp | 2 | ||||
| -rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 22 | 
15 files changed, 99 insertions, 66 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 4dc2fcd714..647512eb2e 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -789,7 +789,7 @@ const LLFontDescriptor& LLFontGL::getFontDesc() const  }  // static -void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, const std::vector<std::string>& xui_paths, bool create_gl_textures) +void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, bool create_gl_textures)  {  	sVertDPI = (F32)llfloor(screen_dpi * y_scale);  	sHorizDPI = (F32)llfloor(screen_dpi * x_scale); @@ -800,7 +800,7 @@ void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::st  	// Font registry init  	if (!sFontRegistry)  	{ -		sFontRegistry = new LLFontRegistry(xui_paths, create_gl_textures); +		sFontRegistry = new LLFontRegistry(create_gl_textures);  		sFontRegistry->parseFontInfo("fonts.xml");  	}  	else diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index 5ed5d2c4eb..0988e99deb 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -150,7 +150,7 @@ public:  	const LLFontDescriptor& getFontDesc() const; -	static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, const std::vector<std::string>& xui_paths, bool create_gl_textures = true); +	static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, bool create_gl_textures = true);  	// Load sans-serif, sans-serif-small, etc.  	// Slow, requires multiple seconds to load fonts. diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp index 4d22eba3d9..b5bdba996f 100644 --- a/indra/llrender/llfontregistry.cpp +++ b/indra/llrender/llfontregistry.cpp @@ -163,14 +163,9 @@ LLFontDescriptor LLFontDescriptor::normalize() const  	return LLFontDescriptor(new_name,new_size,new_style,getFileNames());  } -LLFontRegistry::LLFontRegistry(const string_vec_t& xui_paths, -							   bool create_gl_textures) +LLFontRegistry::LLFontRegistry(bool create_gl_textures)  :	mCreateGLTextures(create_gl_textures)  { -	// Propagate this down from LLUICtrlFactory so LLRender doesn't -	// need an upstream dependency on LLUI. -	mXUIPaths = xui_paths; -	  	// This is potentially a slow directory traversal, so we want to  	// cache the result.  	mUltimateFallbackList = LLWindow::getDynamicFallbackFontList(); @@ -183,27 +178,30 @@ LLFontRegistry::~LLFontRegistry()  bool LLFontRegistry::parseFontInfo(const std::string& xml_filename)  { -	bool success = false;  // Succeed if we find at least one XUI file -	const string_vec_t& xml_paths = mXUIPaths; +	bool success = false;  // Succeed if we find and read at least one XUI file +	const string_vec_t xml_paths = gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename); +	if (xml_paths.empty()) +	{ +		// We didn't even find one single XUI file +		return false; +	} +  	for (string_vec_t::const_iterator path_it = xml_paths.begin();  		 path_it != xml_paths.end();  		 ++path_it)  	{ -	  		LLXMLNodePtr root; -		std::string full_filename = gDirUtilp->findSkinnedFilename(*path_it, xml_filename); -		bool parsed_file = LLXMLNode::parseFile(full_filename, root, NULL); +		bool parsed_file = LLXMLNode::parseFile(*path_it, root, NULL);  		if (!parsed_file)  			continue; -		 +  		if ( root.isNull() || ! root->hasName( "fonts" ) )  		{ -			llwarns << "Bad font info file: " -					<< full_filename << llendl; +			llwarns << "Bad font info file: " << *path_it << llendl;  			continue;  		} -		 +  		std::string root_name;  		root->getAttributeString("name",root_name);  		if (root->hasName("fonts")) @@ -215,7 +213,7 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename)  	}  	//if (success)  	//	dump(); -	 +  	return success;  } diff --git a/indra/llrender/llfontregistry.h b/indra/llrender/llfontregistry.h index 8b06191c56..059248fbbd 100644 --- a/indra/llrender/llfontregistry.h +++ b/indra/llrender/llfontregistry.h @@ -67,8 +67,7 @@ class LLFontRegistry  public:  	// create_gl_textures - set to false for test apps with no OpenGL window,  	// such as llui_libtest -	LLFontRegistry(const string_vec_t& xui_paths, -		bool create_gl_textures); +	LLFontRegistry(bool create_gl_textures);  	~LLFontRegistry();  	// Load standard font info from XML file(s). @@ -105,7 +104,6 @@ private:  	font_size_map_t mFontSizes;  	string_vec_t mUltimateFallbackList; -	string_vec_t mXUIPaths;  	bool mCreateGLTextures;  }; diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 964495a3ab..d70e764769 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -424,6 +424,10 @@ const U32 FENCE_WAIT_TIME_NANOSECONDS = 1000;  //1 ms  class LLGLFence  {  public: +	virtual ~LLGLFence() +	{ +	} +  	virtual void placeFence() = 0;  	virtual bool isCompleted() = 0;  	virtual void wait() = 0; diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index a0727b8686..509de51f4d 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -993,7 +993,12 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);  }  #endif +#if __MAC_OS_X_VERSION_MAX_ALLOWED <= 1070 +#include <OpenGL/gl.h> +#else  #include <AGL/gl.h> +#endif +  #endif // LL_MESA / LL_WINDOWS / LL_DARWIN diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h index e26aead676..0e2c3bcb44 100644 --- a/indra/llrender/llglstates.h +++ b/indra/llrender/llglstates.h @@ -59,7 +59,6 @@ protected:  	LLGLEnable mColorMaterial;  	LLGLDisable mAlphaTest, mBlend, mCullFace, mDither, mFog,   		mLineSmooth, mLineStipple, mNormalize, mPolygonSmooth, -		mTextureGenQ, mTextureGenR, mTextureGenS, mTextureGenT,  		mGLMultisample;  public:  	LLGLSDefault() @@ -76,10 +75,6 @@ public:  		mLineStipple(GL_LINE_STIPPLE),  		mNormalize(GL_NORMALIZE),  		mPolygonSmooth(GL_POLYGON_SMOOTH), -		mTextureGenQ(GL_TEXTURE_GEN_Q),  -		mTextureGenR(GL_TEXTURE_GEN_R), -		mTextureGenS(GL_TEXTURE_GEN_S),  -		mTextureGenT(GL_TEXTURE_GEN_T),  		mGLMultisample(GL_MULTISAMPLE_ARB)  	{ }  }; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index a842211764..a4d7872ec2 100644..100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -478,7 +478,7 @@ bool LLImageGL::checkSize(S32 width, S32 height)  	return check_power_of_two(width) && check_power_of_two(height);  } -void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents) +void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents, S32 discard_level)  {  	if (width != mWidth || height != mHeight || ncomponents != mComponents)  	{ @@ -511,6 +511,11 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents)  				width >>= 1;  				height >>= 1;  			} + +			if(discard_level > 0) +			{ +				mMaxDiscardLevel = llmax(mMaxDiscardLevel, (S8)discard_level); +			}  		}  		else  		{ @@ -860,14 +865,13 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image)  		llassert(mCurrentDiscardLevel >= 0);  		discard_level = mCurrentDiscardLevel;  	} -	discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel); - +	  	// Actual image width/height = raw image width/height * 2^discard_level  	S32 w = raw_image->getWidth() << discard_level;  	S32 h = raw_image->getHeight() << discard_level;  	// setSize may call destroyGLTexture if the size does not match -	setSize(w, h, raw_image->getComponents()); +	setSize(w, h, raw_image->getComponents(), discard_level);  	if( !mHasExplicitFormat )  	{ @@ -1264,8 +1268,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S  		llassert(mCurrentDiscardLevel >= 0);  		discard_level = mCurrentDiscardLevel;  	} -	discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel); - +	  	// Actual image width/height = raw image width/height * 2^discard_level  	S32 raw_w = imageraw->getWidth() ;  	S32 raw_h = imageraw->getHeight() ; @@ -1273,7 +1276,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S  	S32 h = raw_h << discard_level;  	// setSize may call destroyGLTexture if the size does not match -	setSize(w, h, imageraw->getComponents()); +	setSize(w, h, imageraw->getComponents(), discard_level);  	if( !mHasExplicitFormat )  	{ diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index e118c28c1b..cf3c484c79 100644..100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -100,7 +100,7 @@ protected:  public:  	virtual void dump();	// debugging info to llinfos -	void setSize(S32 width, S32 height, S32 ncomponents); +	void setSize(S32 width, S32 height, S32 ncomponents, S32 discard_level = -1);  	void setComponents(S32 ncomponents) { mComponents = (S8)ncomponents ;}  	void setAllowCompression(bool allow) { mAllowCompression = allow; } diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 348c1eb1b7..4597d06260 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -648,7 +648,7 @@ void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eT  		gGL.flush();  		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);  	} - +	  	// We want an early out, because this function does a LOT of stuff.  	if ( ( (isAlpha && (mCurrAlphaOp == op) && (mCurrAlphaSrc1 == src1) && (mCurrAlphaSrc2 == src2))  			|| (!isAlpha && (mCurrColorOp == op) && (mCurrColorSrc1 == src1) && (mCurrColorSrc2 == src2)) ) && !gGL.mDirty) @@ -1437,6 +1437,17 @@ void LLRender::matrixMode(U32 mode)  	mMatrixMode = mode;  } +U32 LLRender::getMatrixMode() +{ +	if (mMatrixMode >= MM_TEXTURE0 && mMatrixMode <= MM_TEXTURE3) +	{ //always return MM_TEXTURE if current matrix mode points at any texture matrix +		return MM_TEXTURE; +	} + +	return mMatrixMode; +} + +  void LLRender::loadIdentity()  {  	flush(); diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index fa5f7f311d..78a310e525 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -346,6 +346,7 @@ public:  	void loadIdentity();  	void multMatrix(const GLfloat* m);  	void matrixMode(U32 mode);	 +	U32 getMatrixMode();  	const glh::matrix4f& getModelviewMatrix();  	const glh::matrix4f& getProjectionMatrix(); diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index cc5c232380..c1b96a43da 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -51,11 +51,13 @@ void check_framebuffer_status()  }  bool LLRenderTarget::sUseFBO = false; +U32 LLRenderTarget::sCurFBO = 0;  LLRenderTarget::LLRenderTarget() :  	mResX(0),  	mResY(0),  	mFBO(0), +	mPreviousFBO(0),  	mDepth(0),  	mStencil(0),  	mUseDepth(false), @@ -107,6 +109,9 @@ void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt)  bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples)  { +	resx = llmin(resx, (U32) 4096); +	resy = llmin(resy, (U32) 4096); +  	stop_glerror();  	release();  	stop_glerror(); @@ -146,7 +151,7 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo  				glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), mDepth, 0);  				stop_glerror();  			} -			glBindFramebuffer(GL_FRAMEBUFFER, 0); +			glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);  		}  		stop_glerror(); @@ -163,10 +168,19 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)  	}  	U32 offset = mTex.size(); -	if (offset >= 4 || -		(offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers))) + +	if( offset >= 4 )  	{ -		llerrs << "Too many color attachments!" << llendl; +		llwarns << "Too many color attachments" << llendl; +		llassert( offset < 4 ); +		return false; +	} +	if( offset > 0 && (mFBO == 0 || !gGLManager.mHasDrawBuffers) ) +	{ +		llwarns << "FBO not used or no drawbuffers available; mFBO=" << (U32)mFBO << " gGLManager.mHasDrawBuffers=" << (U32)gGLManager.mHasDrawBuffers << llendl; +		llassert(  mFBO != 0 ); +		llassert( gGLManager.mHasDrawBuffers ); +		return false;  	}  	U32 tex; @@ -224,7 +238,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)  		check_framebuffer_status(); -		glBindFramebuffer(GL_FRAMEBUFFER, 0); +		glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);  	}  	mTex.push_back(tex); @@ -313,7 +327,7 @@ void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target)  		check_framebuffer_status(); -		glBindFramebuffer(GL_FRAMEBUFFER, 0); +		glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);  		target.mUseDepth = true;  	} @@ -376,9 +390,13 @@ void LLRenderTarget::bindTarget()  {  	if (mFBO)  	{ +		mPreviousFBO = sCurFBO; +  		stop_glerror();  		glBindFramebuffer(GL_FRAMEBUFFER, mFBO); +		sCurFBO = mFBO; +  		stop_glerror();  		if (gGLManager.mHasDrawBuffers)  		{ //setup multiple render targets @@ -404,16 +422,6 @@ void LLRenderTarget::bindTarget()  	sBoundTarget = this;  } -// static -void LLRenderTarget::unbindTarget() -{ -	if (gGLManager.mHasFramebufferObject) -	{ -		glBindFramebuffer(GL_FRAMEBUFFER, 0); -	} -	sBoundTarget = NULL; -} -  void LLRenderTarget::clear(U32 mask_in)  {  	U32 mask = GL_COLOR_BUFFER_BIT; @@ -479,7 +487,8 @@ void LLRenderTarget::flush(bool fetch_depth)  	else  	{  		stop_glerror(); -		glBindFramebuffer(GL_FRAMEBUFFER, 0); +		glBindFramebuffer(GL_FRAMEBUFFER, mPreviousFBO); +		sCurFBO = mPreviousFBO;  		stop_glerror();  	}  } @@ -509,7 +518,7 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0,  		stop_glerror();  		glCopyTexSubImage2D(LLTexUnit::getInternalType(mUsage), 0, srcX0, srcY0, dstX0, dstY0, dstX1, dstY1);  		stop_glerror(); -		glBindFramebuffer(GL_FRAMEBUFFER, 0); +		glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);  		stop_glerror();  	}  	else @@ -526,7 +535,7 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0,  		stop_glerror();  		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);  		stop_glerror(); -		glBindFramebuffer(GL_FRAMEBUFFER, 0); +		glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);  		stop_glerror();  	}  } @@ -552,7 +561,7 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0  		stop_glerror();  		glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);  		stop_glerror(); -		glBindFramebuffer(GL_FRAMEBUFFER, 0); +		glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);  		stop_glerror();  	}  } diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index e1a51304f1..cf15f66d31 100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -63,6 +63,7 @@ public:  	//whether or not to use FBO implementation  	static bool sUseFBO;   	static U32 sBytesAllocated; +	static U32 sCurFBO;  	LLRenderTarget();  	~LLRenderTarget(); @@ -96,9 +97,6 @@ public:  	//applies appropriate viewport  	void bindTarget(); -	//unbind target for rendering -	static void unbindTarget(); -	  	//clear render targer, clears depth buffer if present,  	//uses scissor rect if in copy-to-texture mode  	void clear(U32 mask = 0xFFFFFFFF); @@ -148,6 +146,7 @@ protected:  	std::vector<U32> mTex;  	std::vector<U32> mInternalFormat;  	U32 mFBO; +	U32 mPreviousFBO;  	U32 mDepth;  	bool mStencil;  	bool mUseDepth; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index a9248d4d73..b6a9a6b653 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -643,7 +643,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade  		text[count++] = strdup("#define textureCube texture\n");  		text[count++] = strdup("#define texture2DLod textureLod\n");  		text[count++] = strdup("#define	shadow2D(a,b) vec2(texture(a,b))\n"); - +		  		if (major_version > 1 || minor_version >= 40)  		{ //GLSL 1.40 replaces texture2DRect et al with texture  			text[count++] = strdup("#define texture2DRect texture\n"); diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 80752231d7..2fe0aa0b72 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -38,10 +38,6 @@  #include "llglslshader.h"  #include "llmemory.h" -#if LL_DARWIN -#define LL_VBO_POOLING 1 -#else -#endif  //Next Highest Power Of Two  //helper function, returns first number > v that is a power of 2, or v if v is already a power of 2  U32 nhpo2(U32 v) @@ -294,6 +290,7 @@ void LLVBOPool::seedPool()  } +  void LLVBOPool::cleanup()  {  	U32 size = LL_VBO_BLOCK_SIZE; @@ -558,8 +555,21 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, con  	gGL.syncMatrices();  	U32 count = pos.size(); -	llassert_always(norm.size() >= pos.size()); -	llassert_always(count > 0); +	 +	llassert(norm.size() >= pos.size()); +	llassert(count > 0); + +	if( count == 0 ) +	{ +		llwarns << "Called drawArrays with 0 vertices" << llendl; +		return; +	} + +	if( norm.size() < pos.size() ) +	{ +		llwarns << "Called drawArrays with #" << norm.size() << " normals and #" << pos.size() << " vertices" << llendl; +		return; +	}  	unbind();  | 
