Texture::setImage methods now have an internal format parameter, if the internal format is unsized, a sized one is computed so that Texture classes always store sized internal formats.
TRAC #22972
Signed-off-by: Jamie Madill
Signed-off-by: Nicolas Capens
Author: Geoff Lang
git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2314 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 4a6b271..b249811 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2715,7 +2715,7 @@
case TEXTURE_2D:
{
Texture2D *incomplete2d = new Texture2D(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
- incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
+ incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
t = incomplete2d;
}
break;
@@ -2724,12 +2724,12 @@
{
TextureCubeMap *incompleteCube = new TextureCubeMap(mRenderer, Texture::INCOMPLETE_TEXTURE_ID);
- incompleteCube->setImagePosX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
- incompleteCube->setImageNegX(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
- incompleteCube->setImagePosY(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
- incompleteCube->setImageNegY(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
- incompleteCube->setImagePosZ(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
- incompleteCube->setImageNegZ(0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
+ incompleteCube->setImagePosX(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
+ incompleteCube->setImageNegX(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
+ incompleteCube->setImagePosY(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
+ incompleteCube->setImageNegY(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
+ incompleteCube->setImagePosZ(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
+ incompleteCube->setImageNegZ(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, color);
t = incompleteCube;
}
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index f580127..929f8af 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -14,6 +14,7 @@
#include "libGLESv2/main.h"
#include "libGLESv2/mathutil.h"
#include "libGLESv2/utilities.h"
+#include "libGLESv2/formatutils.h"
#include "libGLESv2/renderer/Blit.h"
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/renderer/Image.h"
@@ -439,10 +440,12 @@
}
}
-void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- GLint internalformat = ConvertSizedInternalFormat(format, type);
- redefineImage(level, internalformat, width, height);
+ GLuint clientVersion = mRenderer->getCurrentClientVersion();
+ GLint sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+ : GetSizedInternalFormat(format, type, clientVersion);
+ redefineImage(level, sizedInternalFormat, width, height);
Texture::setImage(unpackAlignment, pixels, mImageArray[level]);
}
@@ -1004,34 +1007,34 @@
return D3DFMT_UNKNOWN;
}
-void TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- setImage(0, level, width, height, format, type, unpackAlignment, pixels);
+ setImage(0, level, width, height, internalFormat, format, type, unpackAlignment, pixels);
}
-void TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- setImage(1, level, width, height, format, type, unpackAlignment, pixels);
+ setImage(1, level, width, height, internalFormat, format, type, unpackAlignment, pixels);
}
-void TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- setImage(2, level, width, height, format, type, unpackAlignment, pixels);
+ setImage(2, level, width, height, internalFormat, format, type, unpackAlignment, pixels);
}
-void TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- setImage(3, level, width, height, format, type, unpackAlignment, pixels);
+ setImage(3, level, width, height, internalFormat, format, type, unpackAlignment, pixels);
}
-void TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- setImage(4, level, width, height, format, type, unpackAlignment, pixels);
+ setImage(4, level, width, height, internalFormat, format, type, unpackAlignment, pixels);
}
-void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- setImage(5, level, width, height, format, type, unpackAlignment, pixels);
+ setImage(5, level, width, height, internalFormat, format, type, unpackAlignment, pixels);
}
void TextureCubeMap::setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
@@ -1250,10 +1253,13 @@
mDirtyImages = true;
}
-void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- GLint internalformat = ConvertSizedInternalFormat(format, type);
- redefineImage(faceIndex, level, internalformat, width, height);
+ GLuint clientVersion = mRenderer->getCurrentClientVersion();
+ GLint sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+ : GetSizedInternalFormat(format, type, clientVersion);
+
+ redefineImage(faceIndex, level, sizedInternalFormat, width, height);
Texture::setImage(unpackAlignment, pixels, mImageArray[faceIndex][level]);
}
@@ -1598,10 +1604,12 @@
return IsDepthTexture(getInternalFormat(level));
}
-void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- GLint internalformat = ConvertSizedInternalFormat(format, type);
- redefineImage(level, internalformat, width, height, depth);
+ GLuint clientVersion = mRenderer->getCurrentClientVersion();
+ GLint sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+ : GetSizedInternalFormat(format, type, clientVersion);
+ redefineImage(level, sizedInternalFormat, width, height, depth);
Texture::setImage(unpackAlignment, pixels, mImageArray[level]);
}
@@ -2038,12 +2046,14 @@
return IsDepthTexture(getInternalFormat(level));
}
-void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
+void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
- GLint internalformat = ConvertSizedInternalFormat(format, type);
- redefineImage(level, internalformat, width, height, depth);
+ GLuint clientVersion = mRenderer->getCurrentClientVersion();
+ GLint sizedInternalFormat = IsSizedInternalFormat(internalFormat, clientVersion) ? internalFormat
+ : GetSizedInternalFormat(format, type, clientVersion);
+ redefineImage(level, sizedInternalFormat, width, height, depth);
- GLsizei inputDepthPitch = gl::ComputeDepthPitch(width, height, internalformat, unpackAlignment);
+ GLsizei inputDepthPitch = gl::ComputeDepthPitch(width, height, sizedInternalFormat, unpackAlignment);
for (int i = 0; i < depth; i++)
{
diff --git a/src/libGLESv2/Texture.h b/src/libGLESv2/Texture.h
index c7264dc..562ad32 100644
--- a/src/libGLESv2/Texture.h
+++ b/src/libGLESv2/Texture.h
@@ -158,7 +158,7 @@
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
- void setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImage(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
@@ -225,12 +225,12 @@
GLenum getActualFormat(GLenum target, GLint level) const;
bool isCompressed(GLenum target, GLint level) const;
- void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
- void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
- void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
- void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
- void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
- void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImagePosX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImageNegX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImagePosY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImageNegY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
@@ -264,7 +264,7 @@
bool isCubeComplete() const;
bool isMipmapCubeComplete() const;
- void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height);
@@ -301,7 +301,7 @@
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
- void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
@@ -364,7 +364,7 @@
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
- void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
+ void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 6d0305a..5ab406f 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -6122,7 +6122,7 @@
return gl::error(GL_INVALID_OPERATION);
}
- texture->setImage(level, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
}
else
{
@@ -6141,22 +6141,22 @@
switch (target)
{
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- texture->setImagePosX(level, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- texture->setImageNegX(level, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- texture->setImagePosY(level, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- texture->setImageNegY(level, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- texture->setImagePosZ(level, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- texture->setImageNegZ(level, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
break;
default: UNREACHABLE();
}
@@ -7597,14 +7597,14 @@
case GL_TEXTURE_3D:
{
gl::Texture3D *texture = context->getTexture3D();
- texture->setImage(level, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
}
break;
case GL_TEXTURE_2D_ARRAY:
{
gl::Texture2DArray *texture = context->getTexture2DArray();
- texture->setImage(level, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
}
break;