Transplanet: Bug 724094 - Use fTexImage2D instead of TexSubImage2D when uploading full width. r=ajuma

--HG--
extra : rebase_source : 94595465a2b3eb3140f11e932a32575629a266dc
This commit is contained in:
Benoit Girard 2012-02-06 15:15:36 -05:00
Родитель 13bc9d7ea3
Коммит 6a6764ec7b
1 изменённых файлов: 71 добавлений и 84 удалений

Просмотреть файл

@ -2182,10 +2182,25 @@ GLContext::TexSubImage2D(GLenum target, GLint level,
GLenum type, const GLvoid* pixels)
{
#ifdef USE_GLES2
if (IsExtensionSupported(EXT_unpack_subimage)) {
if (stride == width * pixelsize) {
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
fTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
pixels);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
} else if (IsExtensionSupported(EXT_unpack_subimage)) {
TexSubImage2DWithUnpackSubimageGLES(target, level, xoffset, yoffset,
width, height, stride,
pixelsize, format, type, pixels);
} else {
TexSubImage2DWithoutUnpackSubimage(target, level, xoffset, yoffset,
width, height, stride,
@ -2222,18 +2237,6 @@ GLContext::TexSubImage2DWithUnpackSubimageGLES(GLenum target, GLint level,
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
if (stride == width * pixelsize) {
// No need to use GL_UNPACK_ROW_LENGTH.
fTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
pixels);
} else {
// When using GL_UNPACK_ROW_LENGTH, we need to work around a Tegra
// driver crash where the driver apparently tries to read
// (stride - width * pixelsize) bytes past the end of the last input
@ -2260,7 +2263,6 @@ GLContext::TexSubImage2DWithUnpackSubimageGLES(GLenum target, GLint level,
format,
type,
(const unsigned char *)pixels+(height-1)*stride);
}
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
}
@ -2272,20 +2274,6 @@ GLContext::TexSubImage2DWithoutUnpackSubimage(GLenum target, GLint level,
GLenum format, GLenum type,
const GLvoid* pixels)
{
if (stride == width * pixelsize) {
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
fTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
pixels);
} else {
// Not using the whole row of texture data and GL_UNPACK_ROW_LENGTH
// isn't supported. We make a copy of the texture data we're using,
// such that we're using the whole row of data in the copy. This turns
@ -2313,7 +2301,6 @@ GLContext::TexSubImage2DWithoutUnpackSubimage(GLenum target, GLint level,
type,
newPixels);
delete [] newPixels;
}
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
}