Avoids uploading levels other than 0 for incomplete textures.

TRAC #21815 Fixes compressed texture test assertion in WebGL top-of-tree conformance suite when running with debug build Signed-off-by: Daniel Koch Signed-off-by: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1323 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent bef72cee
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1318 #define BUILD_REVISION 1323
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -1476,6 +1476,23 @@ GLenum Texture::getUsage() const ...@@ -1476,6 +1476,23 @@ GLenum Texture::getUsage() const
return mUsage; return mUsage;
} }
bool Texture::isMipmapFiltered() const
{
switch (mMinFilter)
{
case GL_NEAREST:
case GL_LINEAR:
return false;
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
return true;
default: UNREACHABLE();
return false;
}
}
void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image) void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image)
{ {
if (pixels != NULL) if (pixels != NULL)
...@@ -2045,22 +2062,7 @@ bool Texture2D::isSamplerComplete() const ...@@ -2045,22 +2062,7 @@ bool Texture2D::isSamplerComplete() const
return false; return false;
} }
bool mipmapping = false; bool mipmapping = isMipmapFiltered();
switch (mMinFilter)
{
case GL_NEAREST:
case GL_LINEAR:
mipmapping = false;
break;
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
mipmapping = true;
break;
default: UNREACHABLE();
}
if ((IsFloat32Format(getInternalFormat(0)) && !getContext()->supportsFloat32LinearFilter()) || if ((IsFloat32Format(getInternalFormat(0)) && !getContext()->supportsFloat32LinearFilter()) ||
(IsFloat16Format(getInternalFormat(0)) && !getContext()->supportsFloat16LinearFilter())) (IsFloat16Format(getInternalFormat(0)) && !getContext()->supportsFloat16LinearFilter()))
...@@ -2187,7 +2189,9 @@ void Texture2D::createTexture() ...@@ -2187,7 +2189,9 @@ void Texture2D::createTexture()
void Texture2D::updateTexture() void Texture2D::updateTexture()
{ {
int levels = levelCount(); bool mipmapping = (isMipmapFiltered() && isMipmapComplete());
int levels = (mipmapping ? levelCount() : 1);
for (int level = 0; level < levels; level++) for (int level = 0; level < levels; level++)
{ {
...@@ -2598,24 +2602,7 @@ bool TextureCubeMap::isSamplerComplete() const ...@@ -2598,24 +2602,7 @@ bool TextureCubeMap::isSamplerComplete() const
{ {
int size = mImageArray[0][0].getWidth(); int size = mImageArray[0][0].getWidth();
bool mipmapping; bool mipmapping = isMipmapFiltered();
switch (mMinFilter)
{
case GL_NEAREST:
case GL_LINEAR:
mipmapping = false;
break;
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
mipmapping = true;
break;
default:
UNREACHABLE();
return false;
}
if ((gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) || if ((gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) ||
(gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_HALF_FLOAT_OES) && !getContext()->supportsFloat16LinearFilter())) (gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_HALF_FLOAT_OES) && !getContext()->supportsFloat16LinearFilter()))
...@@ -2752,9 +2739,12 @@ void TextureCubeMap::createTexture() ...@@ -2752,9 +2739,12 @@ void TextureCubeMap::createTexture()
void TextureCubeMap::updateTexture() void TextureCubeMap::updateTexture()
{ {
bool mipmapping = isMipmapFiltered() && isMipmapCubeComplete();
for (int face = 0; face < 6; face++) for (int face = 0; face < 6; face++)
{ {
int levels = levelCount(); int levels = (mipmapping ? levelCount() : 1);
for (int level = 0; level < levels; level++) for (int level = 0; level < levels; level++)
{ {
Image *image = &mImageArray[face][level]; Image *image = &mImageArray[face][level];
......
...@@ -190,6 +190,7 @@ class Texture : public RefCountObject ...@@ -190,6 +190,7 @@ class Texture : public RefCountObject
GLenum getWrapT() const; GLenum getWrapT() const;
float getMaxAnisotropy() const; float getMaxAnisotropy() const;
GLenum getUsage() const; GLenum getUsage() const;
bool isMipmapFiltered() const;
virtual bool isSamplerComplete() const = 0; virtual bool isSamplerComplete() const = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment