summaryrefslogtreecommitdiff
path: root/indra/llrender/llimagegl.cpp
diff options
context:
space:
mode:
authorsimon <none@none>2013-04-11 16:18:34 -0700
committersimon <none@none>2013-04-11 16:18:34 -0700
commitb42b7897233df17eb0f37af2ada9070dbb075eeb (patch)
tree5d83e305bf3afac18dec414335fe248be3aaedef /indra/llrender/llimagegl.cpp
parentc262cb15d38cdf344b6e1ca755e611b02d3db79d (diff)
parentc7bab8ab8b25249d1f8f87746b50fce4820f542a (diff)
Merge in downstream code (chui fixes, materials)
Diffstat (limited to 'indra/llrender/llimagegl.cpp')
-rwxr-xr-xindra/llrender/llimagegl.cpp42
1 files changed, 34 insertions, 8 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index ef2648ae98..28b7830b0e 100755
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -74,6 +74,9 @@ S32 LLImageGL::sCurTexSizeBar = -1 ;
S32 LLImageGL::sCurTexPickSize = -1 ;
S32 LLImageGL::sMaxCategories = 1 ;
+//optimization for when we don't need to calculate mIsMask
+BOOL LLImageGL::sSkipAnalyzeAlpha;
+
//------------------------
//****************************************************************************************************
//End for texture auditing use only
@@ -169,8 +172,9 @@ BOOL is_little_endian()
return (*c == 0x78) ;
}
//static
-void LLImageGL::initClass(S32 num_catagories)
+void LLImageGL::initClass(S32 num_catagories, BOOL skip_analyze_alpha /* = false */)
{
+ sSkipAnalyzeAlpha = skip_analyze_alpha;
}
//static
@@ -611,14 +615,16 @@ void LLImageGL::setImage(const LLImageRaw* imageraw)
setImage(rawdata, FALSE);
}
+static LLFastTimer::DeclareTimer FTM_SET_IMAGE("setImage");
void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
{
+ LLFastTimer t(FTM_SET_IMAGE);
bool is_compressed = false;
if (mFormatPrimary >= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && mFormatPrimary <= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
{
is_compressed = true;
}
-
+
if (mUseMipMaps)
@@ -746,8 +752,9 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
S32 w = width, h = height;
const U8* prev_mip_data = 0;
const U8* cur_mip_data = 0;
- S32 prev_mip_size = 0;
+#ifdef SHOW_ASSERT
S32 cur_mip_size = 0;
+#endif
mMipLevels = nummips;
@@ -756,18 +763,24 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
if (m==0)
{
cur_mip_data = data_in;
+#ifdef SHOW_ASSERT
cur_mip_size = width * height * mComponents;
+#endif
}
else
{
S32 bytes = w * h * mComponents;
+#ifdef SHOW_ASSERT
llassert(prev_mip_data);
- llassert(prev_mip_size == bytes*4);
+ llassert(cur_mip_size == bytes*4);
+#endif
U8* new_data = new U8[bytes];
llassert_always(new_data);
LLImageBase::generateMip(prev_mip_data, new_data, w, h, mComponents);
cur_mip_data = new_data;
+#ifdef SHOW_ASSERT
cur_mip_size = bytes;
+#endif
}
llassert(w > 0 && h > 0 && cur_mip_data);
{
@@ -800,7 +813,6 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
delete[] prev_mip_data;
}
prev_mip_data = cur_mip_data;
- prev_mip_size = cur_mip_size;
w >>= 1;
h >>= 1;
}
@@ -1061,8 +1073,10 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_
}
// static
+static LLFastTimer::DeclareTimer FTM_GENERATE_TEXTURES("generate textures");
void LLImageGL::generateTextures(LLTexUnit::eTextureType type, U32 format, S32 numTextures, U32 *textures)
{
+ LLFastTimer t(FTM_GENERATE_TEXTURES);
bool empty = true;
if (LLRender::sGLCoreProfile)
@@ -1143,8 +1157,10 @@ void LLImageGL::deleteTextures(LLTexUnit::eTextureType type, U32 format, S32 mip
}
// static
+static LLFastTimer::DeclareTimer FTM_SET_MANUAL_IMAGE("setManualImage");
void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels, bool allow_compression)
{
+ LLFastTimer t(FTM_SET_MANUAL_IMAGE);
bool use_scratch = false;
U32* scratch = NULL;
if (LLRender::sGLCoreProfile)
@@ -1248,9 +1264,10 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt
//create an empty GL texture: just create a texture name
//the texture is assiciate with some image by calling glTexImage outside LLImageGL
+static LLFastTimer::DeclareTimer FTM_CREATE_GL_TEXTURE1("createGLTexture()");
BOOL LLImageGL::createGLTexture()
{
- if (gHeadlessClient) return FALSE;
+ LLFastTimer t(FTM_CREATE_GL_TEXTURE1);
if (gGLManager.mIsDisabled)
{
llwarns << "Trying to create a texture while GL is disabled!" << llendl;
@@ -1278,9 +1295,10 @@ BOOL LLImageGL::createGLTexture()
return TRUE ;
}
+static LLFastTimer::DeclareTimer FTM_CREATE_GL_TEXTURE2("createGLTexture(raw)");
BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/, BOOL to_create, S32 category)
{
- if (gHeadlessClient) return FALSE;
+ LLFastTimer t(FTM_CREATE_GL_TEXTURE2);
if (gGLManager.mIsDisabled)
{
llwarns << "Trying to create a texture while GL is disabled!" << llendl;
@@ -1352,8 +1370,10 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
return createGLTexture(discard_level, rawdata, FALSE, usename);
}
+static LLFastTimer::DeclareTimer FTM_CREATE_GL_TEXTURE3("createGLTexture3(data)");
BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_hasmips, S32 usename)
{
+ LLFastTimer t(FTM_CREATE_GL_TEXTURE3);
llassert(data_in);
stop_glerror();
@@ -1730,6 +1750,12 @@ BOOL LLImageGL::getBoundRecently() const
return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME);
}
+BOOL LLImageGL::getIsAlphaMask() const
+{
+ llassert_always(!sSkipAnalyzeAlpha);
+ return mIsMask;
+}
+
void LLImageGL::setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target)
{
mTarget = target;
@@ -1827,7 +1853,7 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h)
{
- if(!mNeedsAlphaAndPickMask)
+ if(sSkipAnalyzeAlpha || !mNeedsAlphaAndPickMask)
{
return ;
}