Commit 35d1501b by Jamie Madill

Clean up the validation logic in glGenerateMipmap by using the generic base…

Clean up the validation logic in glGenerateMipmap by using the generic base format property methods. TRAC #23959 Signed-off-by: Shannon Woods Signed-off-by: Geoff Lang
parent 33f9c2ef
...@@ -27,15 +27,11 @@ ...@@ -27,15 +27,11 @@
#include "libGLESv2/validationES2.h" #include "libGLESv2/validationES2.h"
#include "libGLESv2/validationES3.h" #include "libGLESv2/validationES3.h"
gl::Texture *GetTargetTexture(gl::Context *context, GLenum target)
gl::Texture *getTargetTexture(gl::Context *context, GLenum target)
{ {
if (context->getClientVersion() < 3) if (!ValidTextureTarget(context, target))
{ {
if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) return NULL;
{
return NULL;
}
} }
switch (target) switch (target)
...@@ -48,7 +44,6 @@ gl::Texture *getTargetTexture(gl::Context *context, GLenum target) ...@@ -48,7 +44,6 @@ gl::Texture *getTargetTexture(gl::Context *context, GLenum target)
} }
} }
extern "C" extern "C"
{ {
...@@ -2204,74 +2199,20 @@ void __stdcall glGenerateMipmap(GLenum target) ...@@ -2204,74 +2199,20 @@ void __stdcall glGenerateMipmap(GLenum target)
if (context) if (context)
{ {
gl::Texture *texture = NULL; if (!ValidTextureTarget(context, target))
GLint internalFormat = GL_NONE;
switch (target)
{ {
case GL_TEXTURE_2D:
{
gl::Texture2D *tex2d = context->getTexture2D();
if (tex2d)
{
internalFormat = tex2d->getInternalFormat(0);
texture = tex2d;
}
break;
}
case GL_TEXTURE_CUBE_MAP:
{
gl::TextureCubeMap *texcube = context->getTextureCubeMap();
if (texcube)
{
internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
texture = texcube;
}
break;
}
case GL_TEXTURE_3D:
{
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM);
}
gl::Texture3D *tex3D = context->getTexture3D();
if (tex3D)
{
internalFormat = tex3D->getInternalFormat(0);
texture = tex3D;
}
break;
}
case GL_TEXTURE_2D_ARRAY:
{
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM);
}
gl::Texture2DArray *tex2darr = context->getTexture2DArray();
if (tex2darr)
{
internalFormat = tex2darr->getInternalFormat(0);
texture = tex2darr;
}
break;
}
default:
return gl::error(GL_INVALID_ENUM); return gl::error(GL_INVALID_ENUM);
} }
if (!texture) gl::Texture *texture = GetTargetTexture(context, target);
if (texture == NULL)
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
GLint internalFormat = texture->getBaseLevelInternalFormat();
// Internally, all texture formats are sized so checking if the format // Internally, all texture formats are sized so checking if the format
// is color renderable and filterable will not fail. // is color renderable and filterable will not fail.
if (gl::IsDepthRenderingSupported(internalFormat, context) || if (gl::IsDepthRenderingSupported(internalFormat, context) ||
...@@ -3744,7 +3685,7 @@ void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) ...@@ -3744,7 +3685,7 @@ void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
if (context) if (context)
{ {
gl::Texture *texture = getTargetTexture(context, target); gl::Texture *texture = GetTargetTexture(context, target);
if (!texture) if (!texture)
{ {
...@@ -3814,7 +3755,7 @@ void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) ...@@ -3814,7 +3755,7 @@ void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
if (context) if (context)
{ {
gl::Texture *texture = getTargetTexture(context, target); gl::Texture *texture = GetTargetTexture(context, target);
if (!texture) if (!texture)
{ {
...@@ -5207,7 +5148,7 @@ void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) ...@@ -5207,7 +5148,7 @@ void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
return; return;
} }
gl::Texture *texture = getTargetTexture(context, target); gl::Texture *texture = GetTargetTexture(context, target);
if (!texture) if (!texture)
{ {
...@@ -5267,7 +5208,7 @@ void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) ...@@ -5267,7 +5208,7 @@ void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
return; return;
} }
gl::Texture *texture = getTargetTexture(context, target); gl::Texture *texture = GetTargetTexture(context, target);
if (!texture) if (!texture)
{ {
......
...@@ -21,6 +21,19 @@ ...@@ -21,6 +21,19 @@
namespace gl namespace gl
{ {
bool ValidTextureTarget(gl::Context *context, GLenum target)
{
if (context->getClientVersion() < 3)
{
if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY)
{
return false;
}
}
return true;
}
bool ValidMipLevel(const gl::Context *context, GLenum target, GLint level) bool ValidMipLevel(const gl::Context *context, GLenum target, GLint level)
{ {
int maxLevel = 0; int maxLevel = 0;
......
...@@ -14,6 +14,7 @@ namespace gl ...@@ -14,6 +14,7 @@ namespace gl
class Context; class Context;
bool ValidTextureTarget(gl::Context *context, GLenum target);
bool ValidMipLevel(const gl::Context *context, GLenum target, GLint level); bool ValidMipLevel(const gl::Context *context, GLenum target, GLint level);
bool ValidImageSize(const gl::Context *context, GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth); bool ValidImageSize(const gl::Context *context, GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth);
bool ValidCompressedImageSize(const gl::Context *context, GLint internalFormat, GLsizei width, GLsizei height); bool ValidCompressedImageSize(const gl::Context *context, GLint internalFormat, 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