Commit c1f8b16b by Jamie Madill

Move validation of API errors out of Texture*::generateMipmaps() to the API.

TRAC #23959 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods
parent 35d1501b
......@@ -843,14 +843,6 @@ void Texture2D::convertToRenderTarget()
void Texture2D::generateMipmaps()
{
if (!mRenderer->getNonPower2TextureSupport())
{
if (!isPow2(getBaseLevelWidth()) || !isPow2(getBaseLevelHeight()))
{
return gl::error(GL_INVALID_OPERATION);
}
}
// Purge array levels 1 through q and reset them to represent the generated mipmap levels.
unsigned int q = log2(std::max(getBaseLevelWidth(), getBaseLevelHeight()));
for (unsigned int i = 1; i <= q; i++)
......@@ -1132,16 +1124,22 @@ bool TextureCubeMap::isSamplerComplete(const SamplerState &samplerState) const
// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool TextureCubeMap::isCubeComplete() const
{
if (getBaseLevelWidth() <= 0 || getBaseLevelHeight() != getBaseLevelWidth())
int baseWidth = getBaseLevelWidth();
int baseHeight = getBaseLevelHeight();
GLenum baseFormat = getBaseLevelInternalFormat();
if (baseWidth <= 0 || baseWidth != baseHeight)
{
return false;
}
for (unsigned int face = 1; face < 6; face++)
{
if (mImageArray[face][0]->getWidth() != getBaseLevelWidth() ||
mImageArray[face][0]->getWidth() != getBaseLevelHeight() ||
mImageArray[face][0]->getInternalFormat() != getBaseLevelInternalFormat())
const rx::Image &faceBaseImage = *mImageArray[face][0];
if (faceBaseImage.getWidth() != baseWidth ||
faceBaseImage.getHeight() != baseHeight ||
faceBaseImage.getInternalFormat() != baseFormat )
{
return false;
}
......@@ -1489,19 +1487,6 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size
void TextureCubeMap::generateMipmaps()
{
if (!isCubeComplete())
{
return gl::error(GL_INVALID_OPERATION);
}
if (!mRenderer->getNonPower2TextureSupport())
{
if (!isPow2(getBaseLevelWidth()))
{
return gl::error(GL_INVALID_OPERATION);
}
}
// Purge array levels 1 through q and reset them to represent the generated mipmap levels.
unsigned int q = log2(getBaseLevelWidth());
for (unsigned int f = 0; f < 6; f++)
......
......@@ -243,6 +243,7 @@ class TextureCubeMap : public Texture
void storage(GLsizei levels, GLenum internalformat, GLsizei size);
virtual bool isSamplerComplete(const SamplerState &samplerState) const;
bool isCubeComplete() const;
virtual void generateMipmaps();
......@@ -266,7 +267,6 @@ class TextureCubeMap : public Texture
virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
virtual const rx::Image *getBaseLevelImage() const;
bool isCubeComplete() const;
bool isMipmapCubeComplete() const;
bool isFaceLevelComplete(int face, int level) const;
void updateTextureFaceLevel(int face, int level);
......
......@@ -2223,6 +2223,23 @@ void __stdcall glGenerateMipmap(GLenum target)
return gl::error(GL_INVALID_OPERATION);
}
// Non-power of 2 ES2 check
if (!context->supportsNonPower2Texture() && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
{
ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
return gl::error(GL_INVALID_OPERATION);
}
// Cube completeness check
if (target == GL_TEXTURE_CUBE_MAP)
{
gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
if (!textureCube->isCubeComplete())
{
return gl::error(GL_INVALID_OPERATION);
}
}
texture->generateMipmaps();
}
}
......
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