Properly release OpenGL textures.

meow-7.2.2
Nicky 2013-08-18 00:06:11 +02:00
parent 94e1880dfb
commit a12d3c4f95
1 changed files with 44 additions and 37 deletions

View File

@ -1125,47 +1125,54 @@ void LLImageGL::deleteTextures(LLTexUnit::eTextureType type, U32 format, S32 mip
{
if (gGLManager.mInited)
{
switch (format)
{
case 0:
// <FS:ND> user-defined names was deprecated with OpenGL 3.1. Just generate/delete using OpenGL function.
// We get ARB errors in debug when attempting to use glTexImage2D with these deprecated pix formats
//
case GL_LUMINANCE8:
case GL_INTENSITY8:
case GL_ALPHA8:
glDeleteTextures(numTextures, textures);
break;
// switch (format)
// {
// case 0:
//
// // We get ARB errors in debug when attempting to use glTexImage2D with these deprecated pix formats
// //
// case GL_LUMINANCE8:
// case GL_INTENSITY8:
// case GL_ALPHA8:
// glDeleteTextures(numTextures, textures);
// break;
//
// default:
// {
// if (type == LLTexUnit::TT_CUBE_MAP || mip_levels == -1)
// { //unknown internal format or unknown number of mip levels, not safe to reuse
// glDeleteTextures(numTextures, textures);
// }
// else
// {
// for (S32 i = 0; i < numTextures; ++i)
// { //remove texture from VRAM by setting its size to zero
//
// for (S32 j = 0; j <= mip_levels; j++)
// {
// gGL.getTexUnit(0)->bindManual(type, textures[i]);
// U32 internal_type = LLTexUnit::getInternalType(type);
// glTexImage2D(internal_type, j, format, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
// stop_glerror();
// }
//
// llassert(std::find(sDeadTextureList[type][format].begin(),
// sDeadTextureList[type][format].end(), textures[i]) ==
// sDeadTextureList[type][format].end());
//
// sDeadTextureList[type][format].push_back(textures[i]);
// }
// }
// }
// break;
// }
default:
{
if (type == LLTexUnit::TT_CUBE_MAP || mip_levels == -1)
{ //unknown internal format or unknown number of mip levels, not safe to reuse
glDeleteTextures(numTextures, textures);
}
else
{
for (S32 i = 0; i < numTextures; ++i)
{ //remove texture from VRAM by setting its size to zero
glDeleteTextures(numTextures, textures);
for (S32 j = 0; j <= mip_levels; j++)
{
gGL.getTexUnit(0)->bindManual(type, textures[i]);
U32 internal_type = LLTexUnit::getInternalType(type);
glTexImage2D(internal_type, j, format, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
stop_glerror();
}
// </FS:ND>
llassert(std::find(sDeadTextureList[type][format].begin(),
sDeadTextureList[type][format].end(), textures[i]) ==
sDeadTextureList[type][format].end());
sDeadTextureList[type][format].push_back(textures[i]);
}
}
}
break;
}
}
/*if (immediate)