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 MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 881
#define BUILD_REVISION 882
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -1528,7 +1528,7 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL
IDirect3DBaseTexture9 *Texture::getTexture()
{
if (!isComplete())
if (!isSamplerComplete())
{
return NULL;
}
......@@ -1913,7 +1913,7 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo
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);
mDirtyImages = true;
......@@ -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.
bool Texture2D::isComplete() const
// Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85.
bool Texture2D::isSamplerComplete() const
{
GLsizei width = mImageArray[0].getWidth();
GLsizei height = mImageArray[0].getHeight();
......@@ -1997,7 +1997,7 @@ bool Texture2D::isComplete() const
case GL_LINEAR_MIPMAP_LINEAR:
mipmapping = true;
break;
default: UNREACHABLE();
default: UNREACHABLE();
}
if ((getInternalFormat() == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) ||
......@@ -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)) ||
(getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(height)))
......@@ -2022,7 +2022,7 @@ bool Texture2D::isComplete() const
if (mipmapping)
{
if (!npot)
if (!npotSupport)
{
if (!isPow2(width) || !isPow2(height))
{
......@@ -2030,29 +2030,48 @@ bool Texture2D::isComplete() const
}
}
int q = log2(std::max(width, height));
if (!isMipmapComplete())
{
return false;
}
}
for (int level = 1; level <= q; level++)
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));
for (int level = 1; level <= q; level++)
{
if (mImageArray[level].getFormat() != mImageArray[0].getFormat())
{
if (mImageArray[level].getFormat() != mImageArray[0].getFormat())
{
return false;
}
return false;
}
if (mImageArray[level].getType() != mImageArray[0].getType())
{
return false;
}
if (mImageArray[level].getType() != mImageArray[0].getType())
{
return false;
}
if (mImageArray[level].getWidth() != std::max(1, width >> level))
{
return false;
}
if (mImageArray[level].getWidth() != std::max(1, width >> level))
{
return false;
}
if (mImageArray[level].getHeight() != std::max(1, height >> level))
{
return false;
}
if (mImageArray[level].getHeight() != std::max(1, height >> level))
{
return false;
}
}
......@@ -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.
bool TextureCubeMap::isComplete() const
// Tests for cube map sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 86.
bool TextureCubeMap::isSamplerComplete() const
{
int size = mImageArray[0][0].getWidth();
if (size <= 0)
{
return false;
}
bool mipmapping;
switch (mMinFilter)
......@@ -2436,65 +2450,91 @@ bool TextureCubeMap::isComplete() const
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;
}
}
if ((getInternalFormat() == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) ||
(getInternalFormat() == GL_HALF_FLOAT_OES && !getContext()->supportsFloat16LinearFilter()))
if (!isPow2(size) && !getContext()->supportsNonPower2Texture())
{
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;
}
}
bool npot = getContext()->supportsNonPower2Texture();
if (!npot)
if (!mipmapping)
{
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;
}
}
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 (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())
{
if (!isPow2(size))
{
return false;
}
return false;
}
}
int q = log2(size);
return true;
}
for (int face = 0; face < 6; face++)
bool TextureCubeMap::isMipmapCubeComplete() const
{
if (!isCubeComplete())
{
return false;
}
GLsizei size = mImageArray[0][0].getWidth();
int q = log2(size);
for (int face = 0; face < 6; face++)
{
for (int level = 1; level <= q; level++)
{
for (int level = 1; level <= q; level++)
if (mImageArray[face][level].getFormat() != mImageArray[0][0].getFormat())
{
if (mImageArray[face][level].getFormat() != mImageArray[0][0].getFormat())
{
return false;
}
if (mImageArray[face][level].getType() != mImageArray[0][0].getType())
{
return false;
}
return false;
}
if (mImageArray[face][level].getWidth() != std::max(1, size >> level))
{
return false;
}
if (mImageArray[face][level].getType() != mImageArray[0][0].getType())
{
return false;
}
ASSERT(mImageArray[face][level].getHeight() == mImageArray[face][level].getWidth());
if (mImageArray[face][level].getWidth() != std::max(1, size >> level))
{
return false;
}
}
}
......@@ -2713,7 +2753,7 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi
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);
mDirtyImages = true;
......@@ -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()
{
if (!isCubeComplete())
......
......@@ -190,7 +190,7 @@ class Texture : public RefCountObject
virtual GLenum getType() const = 0;
virtual D3DFORMAT getD3DFormat() const = 0;
virtual bool isComplete() const = 0;
virtual bool isSamplerComplete() const = 0;
virtual bool isCompressed() const = 0;
IDirect3DBaseTexture9 *getTexture();
......@@ -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);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
virtual bool isComplete() const;
virtual bool isSamplerComplete() const;
virtual bool isCompressed() const;
virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage();
......@@ -310,6 +310,8 @@ class Texture2D : public Texture
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual TextureStorage *getStorage() const;
bool isMipmapComplete() const;
void redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
......@@ -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);
void storage(GLsizei levels, GLenum internalformat, GLsizei size);
virtual bool isComplete() const;
virtual bool isSamplerComplete() const;
virtual bool isCompressed() const;
virtual void generateMipmaps();
......@@ -390,6 +392,7 @@ class TextureCubeMap : public Texture
virtual TextureStorage *getStorage() 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 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