Commit fc7cf8e9 by Ian Ewell

Fixed validation errors in teximage3d and friends.

BUG=angleproject:1169 BUG=angleproject:1101 Change-Id: I3770335d04cafd652c2f3839afca3e4a854e6e76 Reviewed-on: https://chromium-review.googlesource.com/322381Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarIan Ewell <ewell@google.com>
parent b9deac1c
...@@ -123,7 +123,7 @@ bool ValidCap(const Context *context, GLenum cap) ...@@ -123,7 +123,7 @@ bool ValidCap(const Context *context, GLenum cap)
} }
} }
bool ValidTextureTarget(const Context *context, GLenum target) bool ValidTextureTarget(const ValidationContext *context, GLenum target)
{ {
switch (target) switch (target)
{ {
...@@ -140,6 +140,32 @@ bool ValidTextureTarget(const Context *context, GLenum target) ...@@ -140,6 +140,32 @@ bool ValidTextureTarget(const Context *context, GLenum target)
} }
} }
bool ValidTexture2DTarget(const ValidationContext *context, GLenum target)
{
switch (target)
{
case GL_TEXTURE_2D:
case GL_TEXTURE_CUBE_MAP:
return true;
default:
return false;
}
}
bool ValidTexture3DTarget(const ValidationContext *context, GLenum target)
{
switch (target)
{
case GL_TEXTURE_3D:
case GL_TEXTURE_2D_ARRAY:
return (context->getClientVersion() >= 3);
default:
return false;
}
}
// This function differs from ValidTextureTarget in that the target must be // This function differs from ValidTextureTarget in that the target must be
// usable as the destination of a 2D operation-- so a cube face is valid, but // usable as the destination of a 2D operation-- so a cube face is valid, but
// GL_TEXTURE_CUBE_MAP is not. // GL_TEXTURE_CUBE_MAP is not.
...@@ -156,9 +182,18 @@ bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum ta ...@@ -156,9 +182,18 @@ bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum ta
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
return true; return true;
case GL_TEXTURE_2D_ARRAY: default:
return false;
}
}
bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target)
{
switch (target)
{
case GL_TEXTURE_3D: case GL_TEXTURE_3D:
return (context->getClientVersion() >= 3); case GL_TEXTURE_2D_ARRAY:
return true;
default: default:
return false; return false;
} }
...@@ -1315,13 +1350,6 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, ...@@ -1315,13 +1350,6 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
GLint border, GLint border,
GLenum *textureFormatOut) GLenum *textureFormatOut)
{ {
if (!ValidTexture2DDestinationTarget(context, target))
{
context->recordError(Error(GL_INVALID_ENUM));
return false;
}
if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0)
{ {
context->recordError(Error(GL_INVALID_VALUE)); context->recordError(Error(GL_INVALID_VALUE));
...@@ -2272,8 +2300,8 @@ bool ValidateCopyTexImage2D(ValidationContext *context, ...@@ -2272,8 +2300,8 @@ bool ValidateCopyTexImage2D(ValidationContext *context,
} }
ASSERT(context->getClientVersion() == 3); ASSERT(context->getClientVersion() == 3);
return ValidateES3CopyTexImageParameters(context, target, level, internalformat, false, 0, 0, 0, return ValidateES3CopyTexImage2DParameters(context, target, level, internalformat, false, 0, 0,
x, y, width, height, border); 0, x, y, width, height, border);
} }
bool ValidateFramebufferRenderbuffer(Context *context, bool ValidateFramebufferRenderbuffer(Context *context,
...@@ -2374,8 +2402,8 @@ bool ValidateCopyTexSubImage2D(Context *context, ...@@ -2374,8 +2402,8 @@ bool ValidateCopyTexSubImage2D(Context *context,
yoffset, x, y, width, height, 0); yoffset, x, y, width, height, 0);
} }
return ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, return ValidateES3CopyTexImage2DParameters(context, target, level, GL_NONE, true, xoffset,
yoffset, 0, x, y, width, height, 0); yoffset, 0, x, y, width, height, 0);
} }
} // namespace gl } // namespace gl
...@@ -28,8 +28,11 @@ class Shader; ...@@ -28,8 +28,11 @@ class Shader;
class ValidationContext; class ValidationContext;
bool ValidCap(const Context *context, GLenum cap); bool ValidCap(const Context *context, GLenum cap);
bool ValidTextureTarget(const Context *context, GLenum target); bool ValidTextureTarget(const ValidationContext *context, GLenum target);
bool ValidTexture2DTarget(const ValidationContext *context, GLenum target);
bool ValidTexture3DTarget(const ValidationContext *context, GLenum target);
bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum target); bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum target);
bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target);
bool ValidFramebufferTarget(GLenum target); bool ValidFramebufferTarget(GLenum target);
bool ValidBufferTarget(const Context *context, GLenum target); bool ValidBufferTarget(const Context *context, GLenum target);
bool ValidBufferParameter(const Context *context, GLenum pname); bool ValidBufferParameter(const Context *context, GLenum pname);
......
...@@ -458,6 +458,12 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -458,6 +458,12 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
{ {
GLenum textureInternalFormat = GL_NONE; GLenum textureInternalFormat = GL_NONE;
if (!ValidTexture2DDestinationTarget(context, target))
{
context->recordError(Error(GL_INVALID_ENUM, "Invalid texture target"));
return false;
}
if (!ValidateCopyTexImageParametersBase(context, target, level, internalformat, isSubImage, if (!ValidateCopyTexImageParametersBase(context, target, level, internalformat, isSubImage,
xoffset, yoffset, 0, x, y, width, height, border, &textureInternalFormat)) xoffset, yoffset, 0, x, y, width, height, border, &textureInternalFormat))
{ {
......
...@@ -16,26 +16,130 @@ namespace gl ...@@ -16,26 +16,130 @@ namespace gl
class Context; class Context;
class ValidationContext; class ValidationContext;
bool ValidateES3TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage, bool ValidateES3TexImageParametersBase(ValidationContext *context,
GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type, const GLvoid *pixels);
bool ValidateES3CopyTexImageParameters(ValidationContext *context,
GLenum target, GLenum target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
bool isCompressed,
bool isSubImage, bool isSubImage,
GLint xoffset, GLint xoffset,
GLint yoffset, GLint yoffset,
GLint zoffset, GLint zoffset,
GLint x,
GLint y,
GLsizei width, GLsizei width,
GLsizei height, GLsizei height,
GLint border); GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels);
bool ValidateES3TexStorageParameters(Context *context,
GLenum target,
GLsizei levels,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth);
bool ValidateES3TexImage2DParameters(Context *context,
GLenum target,
GLint level,
GLenum internalformat,
bool isCompressed,
bool isSubImage,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels);
bool ValidateES3TexImage3DParameters(Context *context,
GLenum target,
GLint level,
GLenum internalformat,
bool isCompressed,
bool isSubImage,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels);
bool ValidateES3CopyTexImageParametersBase(ValidationContext *context,
GLenum target,
GLint level,
GLenum internalformat,
bool isSubImage,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLint border);
bool ValidateES3CopyTexImage2DParameters(ValidationContext *context,
GLenum target,
GLint level,
GLenum internalformat,
bool isSubImage,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLint border);
bool ValidateES3CopyTexImage3DParameters(ValidationContext *context,
GLenum target,
GLint level,
GLenum internalformat,
bool isSubImage,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLint border);
bool ValidateES3TexStorageParametersBase(Context *context,
GLenum target,
GLsizei levels,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth);
bool ValidateES3TexStorage2DParameters(Context *context,
GLenum target,
GLsizei levels,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth);
bool ValidateES3TexStorageParameters(Context *context, GLenum target, GLsizei levels, GLenum internalformat, bool ValidateES3TexStorage3DParameters(Context *context,
GLsizei width, GLsizei height, GLsizei depth); GLenum target,
GLsizei levels,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth);
bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment, bool ValidateFramebufferTextureLayer(Context *context, GLenum target, GLenum attachment,
GLuint texture, GLint level, GLint layer); GLuint texture, GLint level, GLint layer);
......
...@@ -682,8 +682,9 @@ void GL_APIENTRY CompressedTexImage2D(GLenum target, GLint level, GLenum interna ...@@ -682,8 +682,9 @@ void GL_APIENTRY CompressedTexImage2D(GLenum target, GLint level, GLenum interna
} }
if (context->getClientVersion() >= 3 && if (context->getClientVersion() >= 3 &&
!ValidateES3TexImageParameters(context, target, level, internalformat, true, false, !ValidateES3TexImage2DParameters(context, target, level, internalformat, true, false, 0,
0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data)) 0, 0, width, height, 1, border, GL_NONE, GL_NONE,
data))
{ {
return; return;
} }
...@@ -727,8 +728,9 @@ void GL_APIENTRY CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -727,8 +728,9 @@ void GL_APIENTRY CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
} }
if (context->getClientVersion() >= 3 && if (context->getClientVersion() >= 3 &&
!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, !ValidateES3TexImage2DParameters(context, target, level, GL_NONE, true, true, xoffset,
xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data)) yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE,
data))
{ {
return; return;
} }
...@@ -3446,8 +3448,9 @@ void GL_APIENTRY TexImage2D(GLenum target, GLint level, GLint internalformat, GL ...@@ -3446,8 +3448,9 @@ void GL_APIENTRY TexImage2D(GLenum target, GLint level, GLint internalformat, GL
} }
if (context->getClientVersion() >= 3 && if (context->getClientVersion() >= 3 &&
!ValidateES3TexImageParameters(context, target, level, internalformat, false, false, !ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false,
0, 0, 0, width, height, 1, border, format, type, pixels)) 0, 0, 0, width, height, 1, border, format, type,
pixels))
{ {
return; return;
} }
...@@ -3597,8 +3600,8 @@ void GL_APIENTRY TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -3597,8 +3600,8 @@ void GL_APIENTRY TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
} }
if (context->getClientVersion() >= 3 && if (context->getClientVersion() >= 3 &&
!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, !ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset,
xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels)) yoffset, 0, width, height, 1, 0, format, type, pixels))
{ {
return; return;
} }
......
...@@ -600,7 +600,8 @@ void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf ...@@ -600,7 +600,8 @@ void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf
} }
if (context->getClientVersion() >= 3 && if (context->getClientVersion() >= 3 &&
!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) !ValidateES3TexStorage2DParameters(context, target, levels, internalformat, width,
height, 1))
{ {
return; return;
} }
......
...@@ -101,8 +101,9 @@ void GL_APIENTRY TexImage3D(GLenum target, GLint level, GLint internalformat, GL ...@@ -101,8 +101,9 @@ void GL_APIENTRY TexImage3D(GLenum target, GLint level, GLint internalformat, GL
} }
// validateES3TexImageFormat sets the error code if there is an error // validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false, if (!ValidateES3TexImage3DParameters(context, target, level, internalformat, false, false,
0, 0, 0, width, height, depth, border, format, type, pixels)) 0, 0, 0, width, height, depth, border, format, type,
pixels))
{ {
return; return;
} }
...@@ -136,9 +137,9 @@ void GL_APIENTRY TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -136,9 +137,9 @@ void GL_APIENTRY TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint
} }
// validateES3TexImageFormat sets the error code if there is an error // validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, if (!ValidateES3TexImage3DParameters(context, target, level, GL_NONE, false, true, xoffset,
xoffset, yoffset, zoffset, width, height, depth, 0, yoffset, zoffset, width, height, depth, 0, format,
format, type, pixels)) type, pixels))
{ {
return; return;
} }
...@@ -240,8 +241,8 @@ void GL_APIENTRY CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffs ...@@ -240,8 +241,8 @@ void GL_APIENTRY CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffs
} }
// validateES3TexImageFormat sets the error code if there is an error // validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, if (!ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, 0, 0, 0,
0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data)) width, height, depth, 0, GL_NONE, GL_NONE, data))
{ {
return; return;
} }
...@@ -3022,7 +3023,8 @@ void GL_APIENTRY TexStorage2D(GLenum target, GLsizei levels, GLenum internalform ...@@ -3022,7 +3023,8 @@ void GL_APIENTRY TexStorage2D(GLenum target, GLsizei levels, GLenum internalform
return; return;
} }
if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) if (!ValidateES3TexStorage2DParameters(context, target, levels, internalformat, width,
height, 1))
{ {
return; return;
} }
...@@ -3053,7 +3055,8 @@ void GL_APIENTRY TexStorage3D(GLenum target, GLsizei levels, GLenum internalform ...@@ -3053,7 +3055,8 @@ void GL_APIENTRY TexStorage3D(GLenum target, GLsizei levels, GLenum internalform
return; return;
} }
if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) if (!ValidateES3TexStorage3DParameters(context, target, levels, internalformat, width,
height, depth))
{ {
return; return;
} }
......
...@@ -562,14 +562,10 @@ ...@@ -562,14 +562,10 @@
1101 WIN : dEQP-GLES3.functional.negative_api.buffer.draw_buffers = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.buffer.draw_buffers = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.buffer.renderbuffer_storage = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.buffer.renderbuffer_storage = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.buffer.renderbuffer_storage_multisample = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.buffer.renderbuffer_storage_multisample = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.bindtexture = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage2d = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage2d = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage2d_invalid_size = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage2d_invalid_size = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.texsubimage3d = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage3d = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage3d = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage3d_invalid_buffer_target = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage3d_invalid_buffer_target = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.texstorage2d = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.texture.texstorage3d = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.shader.link_program = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.shader.link_program = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.shader.use_program = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.shader.use_program = FAIL
1101 WIN : dEQP-GLES3.functional.negative_api.shader.sampler_parameterfv = FAIL 1101 WIN : dEQP-GLES3.functional.negative_api.shader.sampler_parameterfv = FAIL
......
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