Xiaohong Bao 2010-10-13 20:12:28 -06:00
commit dedc78431f
5 changed files with 36 additions and 2 deletions

View File

@ -1047,6 +1047,33 @@ void flush_glerror()
glGetError();
}
//this function outputs gl error to the log file, does not crash the code.
void log_glerror()
{
if (LL_UNLIKELY(!gGLManager.mInited))
{
return ;
}
// Create or update texture to be used with this data
GLenum error;
error = glGetError();
while (LL_UNLIKELY(error))
{
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
llwarns << "GL Error: " << error << " GL Error String: " << gl_error_msg << llendl ;
}
else
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
llwarns << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << llendl;
}
error = glGetError();
}
}
void do_assert_glerror()
{
if (LL_UNLIKELY(!gGLManager.mInited))

View File

@ -157,6 +157,7 @@ void rotate_quat(LLQuaternion& rotation);
void flush_glerror(); // Flush GL errors when we know we're handling them correctly.
void log_glerror();
void assert_glerror();
void clear_glerror();

View File

@ -1057,6 +1057,8 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_
checkTexSize(true) ;
llcallstacks << fb_x << " : " << fb_y << " : " << x_pos << " : " << y_pos << " : " << width << " : " << height <<
" : " << (S32)mComponents << llcallstacksendl ;
log_glerror() ;
}
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height);

View File

@ -854,6 +854,8 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
if (!mMappedData)
{
log_glerror();
//--------------------
//print out more debug info before crash
llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl ;
@ -875,6 +877,8 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
if (!mMappedIndexData)
{
log_glerror();
GLint buff;
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
if ((GLuint)buff != mGLIndices)

View File

@ -1130,7 +1130,7 @@ void LLViewerFetchedTexture::init(bool firstinit)
// does not contain this image.
mIsMissingAsset = FALSE;
mLoadedCallbackDesiredDiscardLevel = 0;
mLoadedCallbackDesiredDiscardLevel = S8_MAX;
mPauseLoadedCallBacks = TRUE ;
mNeedsCreateTexture = FALSE;
@ -1507,7 +1507,7 @@ void LLViewerFetchedTexture::processTextureStats()
}
else if(!mFullWidth || !mFullHeight)
{
mDesiredDiscardLevel = getMaxDiscardLevel() ;
mDesiredDiscardLevel = llmin(getMaxDiscardLevel(), (S32)mLoadedCallbackDesiredDiscardLevel) ;
}
else
{