diff options
Diffstat (limited to 'indra/llrender')
| -rw-r--r-- | indra/llrender/llgl.cpp | 13 | ||||
| -rw-r--r-- | indra/llrender/llimagegl.cpp | 43 | ||||
| -rw-r--r-- | indra/llrender/llimagegl.h | 7 | ||||
| -rw-r--r-- | indra/llrender/llrendertarget.cpp | 4 | 
4 files changed, 58 insertions, 9 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 197bc2b422..b99465ee47 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -94,6 +94,10 @@ void APIENTRY gl_debug_callback(GLenum source,  	llwarns << "Severity: " << std::hex << severity << llendl;  	llwarns << "Message: " << message << llendl;  	llwarns << "-----------------------" << llendl; +	if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) +	{ +		llerrs << "Halting on GL Error" << llendl; +	}  }  #endif @@ -572,6 +576,15 @@ bool LLGLManager::initGL()  #endif  	} +	if (mGLVersion >= 3.f && LLImageGL::sCompressTextures) +	{ //use texture compression +		glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); +	} +	else +	{ //GL version is < 3.0, always disable texture compression +		LLImageGL::sCompressTextures = false; +	} +	  	// Trailing space necessary to keep "nVidia Corpor_ati_on" cards  	// from being recognized as ATI.  	if (mGLVendor.substr(0,4) == "ATI ") diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 78591ddd38..17131c9d8a 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -57,6 +57,7 @@ BOOL LLImageGL::sGlobalUseAnisotropic	= FALSE;  F32 LLImageGL::sLastFrameTime			= 0.f;  BOOL LLImageGL::sAllowReadBackRaw       = FALSE ;  LLImageGL* LLImageGL::sDefaultGLTexture = NULL ; +bool LLImageGL::sCompressTextures = false;  std::set<LLImageGL*> LLImageGL::sImageList; @@ -477,6 +478,8 @@ void LLImageGL::init(BOOL usemipmaps)  	mDiscardLevelInAtlas = -1 ;  	mTexelsInAtlas = 0 ;  	mTexelsInGLTexture = 0 ; + +	mAllowCompression = true;  	mTarget = GL_TEXTURE_2D;  	mBindTarget = LLTexUnit::TT_TEXTURE; @@ -705,7 +708,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)  						stop_glerror();  					} -					LLImageGL::setManualImage(mTarget, gl_level, mFormatInternal, w, h, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in); +					LLImageGL::setManualImage(mTarget, gl_level, mFormatInternal, w, h, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in, mAllowCompression);  					if (gl_level == 0)  					{  						analyzeAlpha(data_in, w, h); @@ -747,7 +750,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)  					LLImageGL::setManualImage(mTarget, 0, mFormatInternal,  								 w, h,   								 mFormatPrimary, mFormatType, -								 data_in); +								 data_in, mAllowCompression);  					analyzeAlpha(data_in, w, h);  					stop_glerror(); @@ -805,7 +808,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)  							stop_glerror();  						} -						LLImageGL::setManualImage(mTarget, m, mFormatInternal, w, h, mFormatPrimary, mFormatType, cur_mip_data); +						LLImageGL::setManualImage(mTarget, m, mFormatInternal, w, h, mFormatPrimary, mFormatType, cur_mip_data, mAllowCompression);  						if (m == 0)  						{  							analyzeAlpha(data_in, w, h); @@ -863,7 +866,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)  			}  			LLImageGL::setManualImage(mTarget, 0, mFormatInternal, w, h, -						 mFormatPrimary, mFormatType, (GLvoid *)data_in); +						 mFormatPrimary, mFormatType, (GLvoid *)data_in, mAllowCompression);  			analyzeAlpha(data_in, w, h);  			updatePickMask(w, h, data_in); @@ -1110,7 +1113,7 @@ void LLImageGL::deleteTextures(S32 numTextures, U32 *textures, bool immediate)  }  // static -void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels) +void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels, bool allow_compression)  {  	bool use_scratch = false;  	U32* scratch = NULL; @@ -1173,6 +1176,36 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt  		}  	} +	if (LLImageGL::sCompressTextures && allow_compression) +	{ +		switch (intformat) +		{ +			case GL_RGB:  +			case GL_RGB8: +				intformat = GL_COMPRESSED_RGB;  +				break; +			case GL_RGBA: +			case GL_RGBA8: +				intformat = GL_COMPRESSED_RGBA;  +				break; +			case GL_LUMINANCE: +			case GL_LUMINANCE8: +				intformat = GL_COMPRESSED_LUMINANCE; +				break; +			case GL_LUMINANCE_ALPHA: +			case GL_LUMINANCE8_ALPHA8: +				intformat = GL_COMPRESSED_LUMINANCE_ALPHA; +				break; +			case GL_ALPHA: +			case GL_ALPHA8: +				intformat = GL_COMPRESSED_ALPHA; +				break; +			default: +				llwarns << "Could not compress format: " << std::hex << intformat << llendl; +				break; +		} +	} +  	stop_glerror();  	glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, use_scratch ? scratch : pixels);  	stop_glerror(); diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 2cfb15b0d9..e23005fe29 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -94,12 +94,13 @@ public:  	void setSize(S32 width, S32 height, S32 ncomponents);  	void setComponents(S32 ncomponents) { mComponents = (S8)ncomponents ;} +	void setAllowCompression(bool allow) { mAllowCompression = allow; }  	// These 3 functions currently wrap glGenTextures(), glDeleteTextures(), and glTexImage2D()   	// for tracking purposes and will be deprecated in the future  	static void generateTextures(S32 numTextures, U32 *textures);  	static void deleteTextures(S32 numTextures, U32 *textures, bool immediate = false); -	static void setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels); +	static void setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels, bool allow_compression = true);  	BOOL createGLTexture() ;  	BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0, BOOL to_create = TRUE,  @@ -209,6 +210,8 @@ private:  	U32      mTexelsInAtlas ;  	U32      mTexelsInGLTexture; +	bool mAllowCompression; +  protected:  	LLGLenum mTarget;		// Normally GL_TEXTURE2D, sometimes something else (ex. cube maps)  	LLTexUnit::eTextureType mBindTarget;	// Normally TT_TEXTURE, sometimes something else (ex. cube maps) @@ -246,7 +249,7 @@ public:  	static BOOL sGlobalUseAnisotropic;  	static LLImageGL* sDefaultGLTexture ;	  	static BOOL sAutomatedTest; - +	static bool sCompressTextures;			//use GL texture compression  #if DEBUG_MISS  	BOOL mMissed; // Missed on last bind?  	BOOL getMissed() const { return mMissed; }; diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index ef2a7395da..780f1dc484 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -143,7 +143,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)  	{  		clear_glerror(); -		LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL); +		LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);  		if (glGetError() != GL_NO_ERROR)  		{  			llwarns << "Could not allocate color buffer for render target." << llendl; @@ -223,7 +223,7 @@ bool LLRenderTarget::allocateDepth()  		U32 internal_type = LLTexUnit::getInternalType(mUsage);  		stop_glerror();  		clear_glerror(); -		LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); +		LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL, false);  		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);  	}  | 
