summaryrefslogtreecommitdiff
path: root/indra/llrender/llimagegl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llimagegl.cpp')
-rw-r--r--indra/llrender/llimagegl.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 0146ed3119..bc80bd9556 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -357,7 +357,10 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac
#endif
case GL_DEPTH_COMPONENT: return 24;
+ case GL_DEPTH_COMPONENT16: return 16;
case GL_DEPTH_COMPONENT24: return 24;
+ case GL_DEPTH_COMPONENT32: return 32;
+ case GL_RGBA16: return 64;
case GL_R16F: return 16;
case GL_RG16F: return 32;
case GL_RGB16F: return 48;
@@ -1149,6 +1152,8 @@ void sub_image_lines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 w
// full width texture, do 32 lines at a time
for (U32 y_pos = y_offset; y_pos < y_offset_end; y_pos += batch_size)
{
+ // If this keeps crashing, pass down data_size, looks like it is using
+ // imageraw->getData(); for data, but goes way over allocated size limit
glTexSubImage2D(target, miplevel, x_offset, y_pos, width, batch_size, pixformat, pixtype, src);
src += line_width * batch_size;
}
@@ -1158,6 +1163,8 @@ void sub_image_lines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 w
// partial width or strange height
for (U32 y_pos = y_offset; y_pos < y_offset_end; y_pos += 1)
{
+ // If this keeps crashing, pass down data_size, looks like it is using
+ // imageraw->getData(); for data, but goes way over allocated size limit
glTexSubImage2D(target, miplevel, x_offset, y_pos, width, 1, pixformat, pixtype, src);
src += line_width;
}
@@ -1290,7 +1297,7 @@ bool LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_
{
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height);
mGLTextureCreated = true;
- stop_glerror();
+ LOG_GLERROR("LLImageGL::setSubImageFromFrameBuffer()");
return true;
}
else
@@ -1632,6 +1639,7 @@ bool LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
llassert(mCurrentDiscardLevel >= 0);
discard_level = mCurrentDiscardLevel;
}
+ discard_level = llmin(discard_level, MAX_DISCARD_LEVEL);
// Actual image width/height = raw image width/height * 2^discard_level
S32 raw_w = imageraw->getWidth() ;
@@ -1738,6 +1746,7 @@ bool LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, bool data_
discard_level = mCurrentDiscardLevel;
}
discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel);
+ discard_level = llmin(discard_level, MAX_DISCARD_LEVEL);
if (main_thread // <--- always force creation of new_texname when not on main thread ...
&& !defer_copy // <--- ... or defer copy is set
@@ -1966,8 +1975,17 @@ bool LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, (GLint*)&glbytes);
if(!imageraw->allocateDataSize(width, height, ncomponents, glbytes))
{
- LL_WARNS() << "Memory allocation failed for reading back texture. Size is: " << glbytes << LL_ENDL ;
- LL_WARNS() << "width: " << width << "height: " << height << "components: " << ncomponents << LL_ENDL ;
+ constexpr S64 MAX_GL_BYTES = 2048 * 2048;
+ if (glbytes > 0 && glbytes <= MAX_GL_BYTES)
+ {
+ LLError::LLUserWarningMsg::showOutOfMemory();
+ LL_ERRS() << "Memory allocation failed for reading back texture. Data size: " << glbytes << LL_ENDL;
+ }
+ else
+ {
+ LL_WARNS() << "Memory allocation failed for reading back texture. Data size is: " << glbytes << LL_ENDL;
+ LL_WARNS() << "width: " << width << "height: " << height << "components: " << ncomponents << LL_ENDL;
+ }
return false ;
}
@@ -1978,8 +1996,18 @@ bool LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
{
if(!imageraw->allocateDataSize(width, height, ncomponents))
{
- LL_WARNS() << "Memory allocation failed for reading back texture." << LL_ENDL ;
- LL_WARNS() << "width: " << width << "height: " << height << "components: " << ncomponents << LL_ENDL ;
+ constexpr F32 MAX_IMAGE_SIZE = 2048 * 2048;
+ F32 size = (F32)width * (F32)height * (F32)ncomponents;
+ if (size > 0 && size <= MAX_IMAGE_SIZE)
+ {
+ LLError::LLUserWarningMsg::showOutOfMemory();
+ LL_ERRS() << "Memory allocation failed for reading back texture. Data size: " << size << LL_ENDL;
+ }
+ else
+ {
+ LL_WARNS() << "Memory allocation failed for reading back texture." << LL_ENDL;
+ LL_WARNS() << "width: " << width << "height: " << height << "components: " << ncomponents << LL_ENDL;
+ }
return false ;
}
@@ -2564,6 +2592,8 @@ bool LLImageGL::scaleDown(S32 desired_discard)
return false;
}
+ //LL_WARNS() << "scaleDown" << LL_ENDL;
+
S32 mip = desired_discard - mCurrentDiscardLevel;
S32 desired_width = getWidth(desired_discard);
@@ -2581,6 +2611,7 @@ bool LLImageGL::scaleDown(S32 desired_discard)
free_tex_image(mTexName);
glTexImage2D(mTarget, 0, mFormatInternal, desired_width, desired_height, 0, mFormatPrimary, mFormatType, nullptr);
glCopyTexSubImage2D(mTarget, 0, 0, 0, 0, 0, desired_width, desired_height);
+ LOG_GLERROR("LLImageGL::scaleDown() - glCopyTexSubImage2D");
alloc_tex_image(desired_width, desired_height, mFormatInternal, 1);
mTexOptionsDirty = true;
@@ -2590,6 +2621,7 @@ bool LLImageGL::scaleDown(S32 desired_discard)
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glGenerateMipmap");
gGL.getTexUnit(0)->bind(this);
glGenerateMipmap(mTarget);
+ LOG_GLERROR("LLImageGL::scaleDown() - glGenerateMipmap");
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}
}