Split completeness tests into sampler and mipmap completeness.

TRAC #18730 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@882 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 45b888ad
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 881 #define BUILD_REVISION 882
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -1528,7 +1528,7 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -1528,7 +1528,7 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL
IDirect3DBaseTexture9 *Texture::getTexture() IDirect3DBaseTexture9 *Texture::getTexture()
{ {
if (!isComplete()) if (!isSamplerComplete())
{ {
return NULL; return NULL;
} }
...@@ -1913,7 +1913,7 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -1913,7 +1913,7 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo
return error(GL_OUT_OF_MEMORY); return error(GL_OUT_OF_MEMORY);
} }
if (!mImageArray[level].isRenderable() || (!mTexture && !isComplete())) if (!mImageArray[level].isRenderable() || (!mTexture && !isSamplerComplete()))
{ {
mImageArray[level].copy(xoffset, yoffset, x, y, width, height, renderTarget); mImageArray[level].copy(xoffset, yoffset, x, y, width, height, renderTarget);
mDirtyImages = true; mDirtyImages = true;
...@@ -1972,8 +1972,8 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL ...@@ -1972,8 +1972,8 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL
} }
} }
// Tests for GL texture object completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. // Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85.
bool Texture2D::isComplete() const bool Texture2D::isSamplerComplete() const
{ {
GLsizei width = mImageArray[0].getWidth(); GLsizei width = mImageArray[0].getWidth();
GLsizei height = mImageArray[0].getHeight(); GLsizei height = mImageArray[0].getHeight();
...@@ -2009,9 +2009,9 @@ bool Texture2D::isComplete() const ...@@ -2009,9 +2009,9 @@ bool Texture2D::isComplete() const
} }
} }
bool npot = getContext()->supportsNonPower2Texture(); bool npotSupport = getContext()->supportsNonPower2Texture();
if (!npot) if (!npotSupport)
{ {
if ((getWrapS() != GL_CLAMP_TO_EDGE && !isPow2(width)) || if ((getWrapS() != GL_CLAMP_TO_EDGE && !isPow2(width)) ||
(getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(height))) (getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(height)))
...@@ -2022,7 +2022,7 @@ bool Texture2D::isComplete() const ...@@ -2022,7 +2022,7 @@ bool Texture2D::isComplete() const
if (mipmapping) if (mipmapping)
{ {
if (!npot) if (!npotSupport)
{ {
if (!isPow2(width) || !isPow2(height)) if (!isPow2(width) || !isPow2(height))
{ {
...@@ -2030,6 +2030,26 @@ bool Texture2D::isComplete() const ...@@ -2030,6 +2030,26 @@ bool Texture2D::isComplete() const
} }
} }
if (!isMipmapComplete())
{
return false;
}
}
return true;
}
// Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool Texture2D::isMipmapComplete() const
{
GLsizei width = mImageArray[0].getWidth();
GLsizei height = mImageArray[0].getHeight();
if (width <= 0 || height <= 0)
{
return false;
}
int q = log2(std::max(width, height)); int q = log2(std::max(width, height));
for (int level = 1; level <= q; level++) for (int level = 1; level <= q; level++)
...@@ -2054,7 +2074,6 @@ bool Texture2D::isComplete() const ...@@ -2054,7 +2074,6 @@ bool Texture2D::isComplete() const
return false; return false;
} }
} }
}
return true; return true;
} }
...@@ -2409,16 +2428,11 @@ void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffse ...@@ -2409,16 +2428,11 @@ void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffse
} }
} }
// Tests for GL texture object completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. // Tests for cube map sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 86.
bool TextureCubeMap::isComplete() const bool TextureCubeMap::isSamplerComplete() const
{ {
int size = mImageArray[0][0].getWidth(); int size = mImageArray[0][0].getWidth();
if (size <= 0)
{
return false;
}
bool mipmapping; bool mipmapping;
switch (mMinFilter) switch (mMinFilter)
...@@ -2436,43 +2450,72 @@ bool TextureCubeMap::isComplete() const ...@@ -2436,43 +2450,72 @@ bool TextureCubeMap::isComplete() const
default: UNREACHABLE(); default: UNREACHABLE();
} }
for (int face = 0; face < 6; face++) if ((getInternalFormat() == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) ||
(getInternalFormat() == GL_HALF_FLOAT_OES && !getContext()->supportsFloat16LinearFilter()))
{ {
if (mImageArray[face][0].getWidth() != size || mImageArray[face][0].getHeight() != size) if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST))
{ {
return false; return false;
} }
} }
if ((getInternalFormat() == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) || if (!isPow2(size) && !getContext()->supportsNonPower2Texture())
(getInternalFormat() == GL_HALF_FLOAT_OES && !getContext()->supportsFloat16LinearFilter()))
{ {
if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST)) if (getWrapS() != GL_CLAMP_TO_EDGE || getWrapT() != GL_CLAMP_TO_EDGE || mipmapping)
{ {
return false; return false;
} }
} }
bool npot = getContext()->supportsNonPower2Texture(); if (!mipmapping)
{
if (!npot) if (!isCubeComplete())
{
return false;
}
}
else
{ {
if ((getWrapS() != GL_CLAMP_TO_EDGE || getWrapT() != GL_CLAMP_TO_EDGE) && !isPow2(size)) if (!isMipmapCubeComplete()) // Also tests for isCubeComplete()
{ {
return false; return false;
} }
} }
if (mipmapping) return true;
}
// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool TextureCubeMap::isCubeComplete() const
{
if (mImageArray[0][0].getWidth() <= 0 || mImageArray[0][0].getHeight() != mImageArray[0][0].getWidth())
{ {
if (!npot) return false;
}
for (unsigned int face = 1; face < 6; face++)
{ {
if (!isPow2(size)) if (mImageArray[face][0].getWidth() != mImageArray[0][0].getWidth() ||
mImageArray[face][0].getWidth() != mImageArray[0][0].getHeight() ||
mImageArray[face][0].getFormat() != mImageArray[0][0].getFormat() ||
mImageArray[face][0].getType() != mImageArray[0][0].getType())
{ {
return false; return false;
} }
} }
return true;
}
bool TextureCubeMap::isMipmapCubeComplete() const
{
if (!isCubeComplete())
{
return false;
}
GLsizei size = mImageArray[0][0].getWidth();
int q = log2(size); int q = log2(size);
for (int face = 0; face < 6; face++) for (int face = 0; face < 6; face++)
...@@ -2493,9 +2536,6 @@ bool TextureCubeMap::isComplete() const ...@@ -2493,9 +2536,6 @@ bool TextureCubeMap::isComplete() const
{ {
return false; return false;
} }
ASSERT(mImageArray[face][level].getHeight() == mImageArray[face][level].getWidth());
}
} }
} }
...@@ -2713,7 +2753,7 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi ...@@ -2713,7 +2753,7 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi
unsigned int faceindex = faceIndex(target); unsigned int faceindex = faceIndex(target);
if (!mImageArray[faceindex][level].isRenderable() || (!mTexture && !isComplete())) if (!mImageArray[faceindex][level].isRenderable() || (!mTexture && !isSamplerComplete()))
{ {
mImageArray[faceindex][level].copy(0, 0, x, y, width, height, renderTarget); mImageArray[faceindex][level].copy(0, 0, x, y, width, height, renderTarget);
mDirtyImages = true; mDirtyImages = true;
...@@ -2777,25 +2817,6 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size ...@@ -2777,25 +2817,6 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size
} }
} }
bool TextureCubeMap::isCubeComplete() const
{
if (mImageArray[0][0].getWidth() == 0)
{
return false;
}
for (unsigned int f = 1; f < 6; f++)
{
if (mImageArray[f][0].getWidth() != mImageArray[0][0].getWidth()
|| mImageArray[f][0].getFormat() != mImageArray[0][0].getFormat())
{
return false;
}
}
return true;
}
void TextureCubeMap::generateMipmaps() void TextureCubeMap::generateMipmaps()
{ {
if (!isCubeComplete()) if (!isCubeComplete())
......
...@@ -190,7 +190,7 @@ class Texture : public RefCountObject ...@@ -190,7 +190,7 @@ class Texture : public RefCountObject
virtual GLenum getType() const = 0; virtual GLenum getType() const = 0;
virtual D3DFORMAT getD3DFormat() const = 0; virtual D3DFORMAT getD3DFormat() const = 0;
virtual bool isComplete() const = 0; virtual bool isSamplerComplete() const = 0;
virtual bool isCompressed() const = 0; virtual bool isCompressed() const = 0;
IDirect3DBaseTexture9 *getTexture(); IDirect3DBaseTexture9 *getTexture();
...@@ -291,7 +291,7 @@ class Texture2D : public Texture ...@@ -291,7 +291,7 @@ class Texture2D : public Texture
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
virtual bool isComplete() const; virtual bool isSamplerComplete() const;
virtual bool isCompressed() const; virtual bool isCompressed() const;
virtual void bindTexImage(egl::Surface *surface); virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage(); virtual void releaseTexImage();
...@@ -310,6 +310,8 @@ class Texture2D : public Texture ...@@ -310,6 +310,8 @@ class Texture2D : public Texture
virtual IDirect3DSurface9 *getRenderTarget(GLenum target); virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual TextureStorage *getStorage() const; virtual TextureStorage *getStorage() const;
bool isMipmapComplete() const;
void redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type); void redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
...@@ -370,7 +372,7 @@ class TextureCubeMap : public Texture ...@@ -370,7 +372,7 @@ class TextureCubeMap : public Texture
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei size); void storage(GLsizei levels, GLenum internalformat, GLsizei size);
virtual bool isComplete() const; virtual bool isSamplerComplete() const;
virtual bool isCompressed() const; virtual bool isCompressed() const;
virtual void generateMipmaps(); virtual void generateMipmaps();
...@@ -390,6 +392,7 @@ class TextureCubeMap : public Texture ...@@ -390,6 +392,7 @@ class TextureCubeMap : public Texture
virtual TextureStorage *getStorage() const; virtual TextureStorage *getStorage() const;
bool isCubeComplete() const; 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, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
......
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