Context now returns maximum texture levels per texture type, updated validation to validate mip level based on the texture target.
TRAC #23630
Signed-off-by: Jamie Madill
Signed-off-by: Shannon Woods
diff --git a/src/libGLESv2/validationES3.cpp b/src/libGLESv2/validationES3.cpp
index e8df0ac..9e58ddc 100644
--- a/src/libGLESv2/validationES3.cpp
+++ b/src/libGLESv2/validationES3.cpp
@@ -8,6 +8,7 @@
// validationES3.cpp: Validation functions for OpenGL ES 3.0 entry point parameters
#include "libGLESv2/validationES3.h"
+#include "libGLESv2/validationES.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/Texture.h"
#include "libGLESv2/Framebuffer.h"
@@ -20,31 +21,6 @@
namespace gl
{
-static bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth)
-{
- if (level < 0 || width < 0 || height < 0 || depth < 0)
- {
- return false;
- }
-
- if (context->supportsNonPower2Texture())
- {
- return true;
- }
-
- if (level == 0)
- {
- return true;
- }
-
- if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth))
- {
- return true;
- }
-
- return false;
-}
-
static bool validCompressedImageSize(GLsizei width, GLsizei height)
{
if (width != 1 && width != 2 && width % 4 != 0)
@@ -65,7 +41,7 @@
GLint border, GLenum format, GLenum type, const GLvoid *pixels)
{
// Validate image size
- if (!validImageSize(context, level, width, height, depth))
+ if (!ValidImageSize(context, target, level, width, height, depth))
{
return gl::error(GL_INVALID_VALUE, false);
}
@@ -81,12 +57,6 @@
return gl::error(GL_INVALID_VALUE, false);
}
- // Validate dimensions based on Context limits and validate the texture
- if (level > context->getMaximumTextureLevel())
- {
- return gl::error(GL_INVALID_VALUE, false);
- }
-
gl::Texture *texture = NULL;
bool textureCompressed = false;
GLenum textureInternalFormat = GL_NONE;
@@ -342,7 +312,7 @@
return gl::error(GL_INVALID_VALUE, false);
}
- if (level > context->getMaximumTextureLevel())
+ if (!ValidMipLevel(context, target, level))
{
return gl::error(GL_INVALID_VALUE, false);
}