Wrap mode affects NPOT texture completeness

TRAC #11861 If mipmapping is enabled, then each side of a texture must be a power-of-two or using CLAMP_TO_EDGE wrapping in that direction. Correct the mipmap size calculation to match the spec. Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Andrew Lewycky git-svn-id: https://angleproject.googlecode.com/svn/trunk@179 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e7e43fb9
...@@ -630,6 +630,12 @@ bool Texture2D::isComplete() const ...@@ -630,6 +630,12 @@ bool Texture2D::isComplete() const
if (mipmapping) if (mipmapping)
{ {
if ((getWrapS() != GL_CLAMP_TO_EDGE && !isPow2(width))
|| (getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(height)))
{
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++)
...@@ -639,12 +645,12 @@ bool Texture2D::isComplete() const ...@@ -639,12 +645,12 @@ bool Texture2D::isComplete() const
return false; return false;
} }
if (mImageArray[level].width != (mImageArray[level - 1].width + 1) / 2) if (mImageArray[level].width != std::max(1, width >> level))
{ {
return false; return false;
} }
if (mImageArray[level].height != (mImageArray[level - 1].height + 1) / 2) if (mImageArray[level].height != std::max(1, height >> level))
{ {
return false; return false;
} }
...@@ -998,6 +1004,11 @@ bool TextureCubeMap::isComplete() const ...@@ -998,6 +1004,11 @@ bool TextureCubeMap::isComplete() const
if (mipmapping) if (mipmapping)
{ {
if (!isPow2(size) && (getWrapS() != GL_CLAMP_TO_EDGE || getWrapT() != GL_CLAMP_TO_EDGE))
{
return false;
}
int q = log2(size); int q = log2(size);
for (int face = 0; face < 6; face++) for (int face = 0; face < 6; face++)
...@@ -1009,15 +1020,12 @@ bool TextureCubeMap::isComplete() const ...@@ -1009,15 +1020,12 @@ bool TextureCubeMap::isComplete() const
return false; return false;
} }
if (mImageArray[face][level].width != (mImageArray[0][level - 1].width + 1) / 2) if (mImageArray[face][level].width != std::max(1, size >> level))
{ {
return false; return false;
} }
if (mImageArray[face][level].height != (mImageArray[0][level - 1].height + 1) / 2) ASSERT(mImageArray[face][level].height == mImageArray[face][level].width);
{
return false;
}
} }
} }
} }
......
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