Commit ce635695 by Geoff Lang Committed by Geoff Lang

Context now returns maximum texture levels per texture type, updated validation…

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
parent 784a8fd5
......@@ -317,12 +317,17 @@ void Context::makeCurrent(egl::Surface *surface)
(int)gl::IMPLEMENTATION_MAX_3D_TEXTURE_SIZE);
mMax2DArrayTextureLayers = mRenderer->getMaxTextureArrayLayers();
mMaxRenderbufferDimension = mMax2DTextureDimension;
mMaxTextureLevel = log2(mMax2DTextureDimension) + 1;
mMax2DTextureLevel = log2(mMax2DTextureDimension) + 1;
mMaxCubeTextureLevel = log2(mMaxCubeTextureDimension) + 1;
mMax3DTextureLevel = log2(mMax3DTextureDimension) + 1;
mMax2DArrayTextureLevel = log2(mMax2DTextureDimension) + 1;
mMaxTextureAnisotropy = mRenderer->getTextureMaxAnisotropy();
TRACE("Max2DTextureDimension=%d, MaxCubeTextureDimension=%d, Max3DTextureDimension=%d, Max2DArrayTextureLayers = %d, "
"MaxRenderbufferDimension=%d, MaxTextureLevel=%d, MaxTextureAnisotropy=%f",
"Max2DTextureLevel=%d, MaxCubeTextureLevel=%d, Max3DTextureLevel=%d, Max2DArrayTextureLevel=%d, "
"MaxRenderbufferDimension=%d, MaxTextureAnisotropy=%f",
mMax2DTextureDimension, mMaxCubeTextureDimension, mMax3DTextureDimension, mMax2DArrayTextureLayers,
mMaxRenderbufferDimension, mMaxTextureLevel, mMaxTextureAnisotropy);
mMax2DTextureLevel, mMaxCubeTextureLevel, mMax3DTextureLevel, mMax2DArrayTextureLevel,
mMaxRenderbufferDimension, mMaxTextureAnisotropy);
mSupportsEventQueries = mRenderer->getEventQuerySupport();
mSupportsOcclusionQueries = mRenderer->getOcclusionQuerySupport();
......@@ -3069,9 +3074,24 @@ int Context::getMaximum2DArrayTextureLayers() const
return mMax2DArrayTextureLayers;
}
int Context::getMaximumTextureLevel() const
int Context::getMaximum2DTextureLevel() const
{
return mMaxTextureLevel;
return mMax2DTextureLevel;
}
int Context::getMaximumCubeTextureLevel() const
{
return mMaxCubeTextureLevel;
}
int Context::getMaximum3DTextureLevel() const
{
return mMax3DTextureLevel;
}
int Context::getMaximum2DArrayTextureLevel() const
{
return mMax2DArrayTextureLevel;
}
bool Context::supportsLuminanceTextures() const
......
......@@ -394,7 +394,10 @@ class Context
int getMaximumCubeTextureDimension() const;
int getMaximum3DTextureDimension() const;
int getMaximum2DArrayTextureLayers() const;
int getMaximumTextureLevel() const;
int getMaximum2DTextureLevel() const;
int getMaximumCubeTextureLevel() const;
int getMaximum3DTextureLevel() const;
int getMaximum2DArrayTextureLevel() const;
unsigned int getMaximumRenderTargets() const;
GLsizei getMaxSupportedSamples() const;
GLsizei getMaxSupportedFormatSamples(GLint internalFormat) const;
......@@ -521,7 +524,10 @@ class Context
int mMaxCubeTextureDimension;
int mMax3DTextureDimension;
int mMax2DArrayTextureLayers;
int mMaxTextureLevel;
int mMax2DTextureLevel;
int mMaxCubeTextureLevel;
int mMax3DTextureLevel;
int mMax2DArrayTextureLevel;
float mMaxTextureAnisotropy;
bool mSupportsEventQueries;
bool mSupportsOcclusionQueries;
......
......@@ -21,6 +21,47 @@
namespace gl
{
bool ValidMipLevel(const gl::Context *context, GLenum target, GLint level)
{
int maxLevel = 0;
switch (target)
{
case GL_TEXTURE_2D: maxLevel = context->getMaximum2DTextureLevel(); break;
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: maxLevel = context->getMaximumCubeTextureLevel(); break;
case GL_TEXTURE_3D: maxLevel = context->getMaximum3DTextureLevel(); break;
case GL_TEXTURE_2D_ARRAY: maxLevel = context->getMaximum2DArrayTextureLevel(); break;
default: UNREACHABLE();
}
return level < maxLevel;
}
bool ValidImageSize(const gl::Context *context, GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth)
{
if (level < 0 || width < 0 || height < 0 || depth < 0)
{
return false;
}
if (!context->supportsNonPower2Texture() && (level != 0 || !gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth)))
{
return false;
}
if (!ValidMipLevel(context, target, level))
{
return false;
}
return true;
}
bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height,
bool angleExtension)
......
......@@ -14,6 +14,9 @@ namespace gl
class Context;
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 ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height,
bool angleExtension);
......
......@@ -8,6 +8,7 @@
// validationES2.cpp: Validation functions for OpenGL ES 2.0 entry point parameters
#include "libGLESv2/validationES2.h"
#include "libGLESv2/validationES.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/Texture.h"
#include "libGLESv2/Framebuffer.h"
......@@ -21,31 +22,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)
......@@ -147,7 +123,7 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le
GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLint border, GLenum format, GLenum type, const GLvoid *pixels)
{
if (!validImageSize(context, level, width, height, 1))
if (!ValidImageSize(context, target, level, width, height, 1))
{
return gl::error(GL_INVALID_VALUE, false);
}
......@@ -260,12 +236,6 @@ bool ValidateES2TexImageParameters(gl::Context *context, GLenum target, GLint le
return gl::error(GL_INVALID_VALUE, false);
}
// Verify texture is not requesting more mip levels than are available.
if (level > context->getMaximumTextureLevel())
{
return gl::error(GL_INVALID_VALUE, false);
}
GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
if (isCompressed)
{
......@@ -494,7 +464,7 @@ bool ValidateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLin
}
// Validate dimensions based on Context limits and validate the texture
if (level > context->getMaximumTextureLevel())
if (!ValidMipLevel(context, target, level))
{
return gl::error(GL_INVALID_VALUE, false);
}
......
......@@ -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 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le
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 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le
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 @@ bool ValidateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
return gl::error(GL_INVALID_VALUE, false);
}
if (level > context->getMaximumTextureLevel())
if (!ValidMipLevel(context, target, level))
{
return gl::error(GL_INVALID_VALUE, 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