Commit 6cad5667 by Brandon Jones Committed by Commit Bot

Improve Debugging Strings

This change replaces common string literals used for error messages with const string variables mapped in a new header file. Additionally, more validation for WebGL naming scenarios has been added, along with unit tests. BUG=:angleproject:1644 Change-Id: Icff44a456aa78221c6df12b0454a7cc147a7d26e Reviewed-on: https://chromium-review.googlesource.com/535974 Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent fa36c330
...@@ -71,6 +71,7 @@ Intel Corporation ...@@ -71,6 +71,7 @@ Intel Corporation
Bryan Bernhart Bryan Bernhart
Yunchao He Yunchao He
Xinghua Cao Xinghua Cao
Brandon Jones
Klarälvdalens Datakonsult AB Klarälvdalens Datakonsult AB
Milian Wolff Milian Wolff
......
//
// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ErrorStrings.h: Contains mapping of commonly used error messages
#ifndef LIBANGLE_ERRORSTRINGS_H_
#define LIBANGLE_ERRORSTRINGS_H_
#define ERRMSG(name, message) \
static const constexpr char *kError##name = static_cast<const char *>(message);
#define ANGLE_VALIDATION_ERR(context, error, errorName) \
context->handleError(error << kError##errorName)
namespace gl
{
ERRMSG(ActiveTextureRange, "Cannot be less than 0 or greater than maximum number of textures.");
ERRMSG(BufferNotBound, "A buffer must be bound.");
ERRMSG(ClearInvalidMask, "Invalid mask bits.");
ERRMSG(CubemapFacesEqualDimensions, "Each cubemap face must have equal width and height.");
ERRMSG(CubemapIncomplete,
"Texture is not cubemap complete. All cubemaps faces must be defined and be the same size.");
ERRMSG(DefaultFramebufferTarget, "It is invalid to change default FBO's attachments");
ERRMSG(EnumNotSupported, "Enum is not currently supported.");
ERRMSG(EnumRequiresGLES31, "Enum requires GLES 3.1");
ERRMSG(ExceedsMaxElement, "Element value exceeds maximum element index.");
ERRMSG(ExpectedProgramName, "Expected a program name, but found a shader name.");
ERRMSG(ExpectedShaderName, "Expected a shader name, but found a program name.");
ERRMSG(ExtensionNotEnabled, "Extension is not enabled.");
ERRMSG(FramebufferIncompleteAttachment,
"Attachment type must be compatible with attachment object.");
ERRMSG(FramebufferInvalidAttachment, "Invalid Attachment Type");
ERRMSG(GenerateMipmapNotAllowed, "Compressed textures do not support mipmap generation.");
ERRMSG(IndexExceedsMax, "Index exceeds MAX_VERTEX_ATTRIBS");
ERRMSG(InsufficientBufferSize, "Insufficient buffer size.");
ERRMSG(IntegerOverflow, "Integer overflow.");
ERRMSG(InvalidBlendEquation, "Invalid blend equation.");
ERRMSG(InvalidBlendFunction, "Invalid blend function.");
ERRMSG(InvalidBorder, "Border must be 0.");
ERRMSG(InvalidBufferTypes, "Invalid buffer target enum.");
ERRMSG(InvalidBufferUsage, "Invalid buffer usage enum.");
ERRMSG(InvalidClearMask, "Invalid mask bits.");
ERRMSG(InvalidConstantColor,
"CONSTANT_COLOR (or ONE_MINUS_CONSTANT_COLOR) and CONSTANT_ALPHA (or "
"ONE_MINUS_CONSTANT_ALPHA) cannot be used together as source and destination factors in the "
"blend function.");
ERRMSG(InvalidCullMode, "Cull mode not recognized.");
ERRMSG(InvalidDepthRange, "Near value cannot be greater than far.");
ERRMSG(InvalidDrawMode, "Invalid draw mode.");
ERRMSG(InvalidDrawModeTransformFeedback,
"Draw mode must match current transform feedback object's draw mode.");
ERRMSG(InvalidFormat, "Invalid format.");
ERRMSG(InvalidFramebufferTarget, "Invalid framebuffer target.");
ERRMSG(InvalidFramebufferTextureLevel, "Mipmap level must be 0 when attaching a texture.");
ERRMSG(InvalidInternalFormat, "Invalid internal format.");
ERRMSG(InvalidMipLevel, "Level of detail outside of range.");
ERRMSG(InvalidNameCharacters, "Name contains invalid characters.");
ERRMSG(InvalidPrecision, "Invalid or unsupported precision type.");
ERRMSG(InvalidProgramName, "Program object expected.");
ERRMSG(InvalidRenderbufferInternalFormat, "Invalid renderbuffer internalformat.");
ERRMSG(InvalidRenderbufferTarget, "Invalid renderbuffer target.");
ERRMSG(InvalidRenderbufferTextureParameter, "Invalid parameter name for renderbuffer attachment.");
ERRMSG(InvalidRenderbufferWidthHeight,
"Renderbuffer width and height cannot be negative and cannot exceed maximum texture size.");
ERRMSG(InvalidShaderName, "Shader object expected.");
ERRMSG(InvalidShaderType, "Invalid shader type.");
ERRMSG(InvalidStencil, "Invalid stencil.");
ERRMSG(InvalidTextureFilterParam, "Texture filter not recognized.");
ERRMSG(InvalidTextureTarget, "Invalid or unsupported texture target.");
ERRMSG(InvalidType, "Invalid type.");
ERRMSG(InvalidTypePureInt, "Invalid type, should be integer");
ERRMSG(InvalidUnpackAlignment, "Unpack alignment must be 1, 2, 4, or 8.");
ERRMSG(InvalidVertexAttrSize, "Vertex attribute size must be 1, 2, 3, or 4.");
ERRMSG(MismatchedFormat, "Format must match internal format.");
ERRMSG(MismatchedTypeAndFormat, "Invalid format and type combination.");
ERRMSG(MismatchedVariableProgram, "Variable is not part of the current program.");
ERRMSG(MissingReadAttachment, "Missing read attachment.");
ERRMSG(MustHaveElementArrayBinding, "Must have element array buffer binding.");
ERRMSG(NameBeginsWithGL, "Attributes that begin with 'gl_' are not allowed.");
ERRMSG(NegativeBufferSize, "Negative buffer size.");
ERRMSG(NegativeCount, "Negative count.");
ERRMSG(NegativeLength, "Negative length.");
ERRMSG(NegativeOffset, "Negative offset.");
ERRMSG(NegativeSize, "Cannot have negative height or width.");
ERRMSG(NegativeStart, "Cannot have negative start.");
ERRMSG(NegativeStride, "Cannot have negative stride.");
ERRMSG(ObjectNotGenerated, "Object cannot be used because it has not been generated.");
ERRMSG(OffsetMustBeMultipleOfType, "Offset must be a multiple of the passed in datatype.");
ERRMSG(OutsideOfBounds, "Parameter outside of bounds.");
ERRMSG(ParamOverflow, "The provided parameters overflow with the provided buffer.");
ERRMSG(ProgramDoesNotExist, "Program doesn't exist.");
ERRMSG(ProgramNotBound, "A program must be bound.");
ERRMSG(ProgramNotLinked, "Program not linked.");
ERRMSG(RenderbufferNotBound, "A renderbuffer must be bound.");
ERRMSG(ResourceMaxTextureSize, "Desired resource size is greater than max texture size.");
ERRMSG(ShaderAttachmentHasShader, "Shader attachment already has a shader.");
ERRMSG(ShaderSourceInvalidCharacters, "Shader source contains invalid characters.");
ERRMSG(ShaderToDetachMustBeAttached,
"Shader to be detached must be currently attached to the program.");
ERRMSG(SourceTextureTooSmall, "The specified dimensions are outside of the bounds of the texture.");
ERRMSG(StencilReferenceMaskOrMismatch,
"Stencil reference and mask values must be the same for front facing and back facing "
"triangles.");
ERRMSG(StrideMustBeMultipleOfType, "Stride must be a multiple of the passed in datatype.");
ERRMSG(TextureNotBound, "A texture must be bound.");
ERRMSG(TextureNotPow2, "The texture is a non-power-of-two texture.");
ERRMSG(TypeMustMatchOriginalType,
"Passed in texture target and format must match the one originally used to define the "
"texture.");
ERRMSG(TypeNotUnsignedShortByte, "Only UNSIGNED_SHORT and UNSIGNED_BYTE types are supported.");
ERRMSG(UniformSizeDoesNotMatchMethod, "Uniform size does not match uniform method.");
ERRMSG(ViewportNegativeSize, "Viewport size cannot be negative.");
ERRMSG(WebglBindAttribLocationReservedPrefix,
"Attributes that begin with 'webgl_', or '_webgl_' are not allowed.");
}
#undef ERRMSG
#endif // LIBANGLE_ERRORSTRINGS_H_
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/ErrorStrings.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Image.h" #include "libANGLE/Image.h"
...@@ -30,8 +31,6 @@ using namespace angle; ...@@ -30,8 +31,6 @@ using namespace angle;
namespace gl namespace gl
{ {
const char *g_ExceedsMaxElementErrorMessage = "Element value exceeds maximum element index.";
namespace namespace
{ {
bool ValidateDrawAttribs(ValidationContext *context, bool ValidateDrawAttribs(ValidationContext *context,
...@@ -238,7 +237,7 @@ bool ValidateTextureMinFilterValue(Context *context, ...@@ -238,7 +237,7 @@ bool ValidateTextureMinFilterValue(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown param value."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureFilterParam);
return false; return false;
} }
...@@ -255,7 +254,7 @@ bool ValidateTextureMagFilterValue(Context *context, ParamType *params) ...@@ -255,7 +254,7 @@ bool ValidateTextureMagFilterValue(Context *context, ParamType *params)
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown param value."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureFilterParam);
return false; return false;
} }
...@@ -309,7 +308,7 @@ bool ValidateTextureSRGBDecodeValue(Context *context, ParamType *params) ...@@ -309,7 +308,7 @@ bool ValidateTextureSRGBDecodeValue(Context *context, ParamType *params)
{ {
if (!context->getExtensions().textureSRGBDecode) if (!context->getExtensions().textureSRGBDecode)
{ {
context->handleError(InvalidEnum() << "GL_EXT_texture_sRGB_decode is not enabled."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -405,7 +404,7 @@ bool ValidateSamplerParameterBase(Context *context, ...@@ -405,7 +404,7 @@ bool ValidateSamplerParameterBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -456,7 +455,7 @@ bool ValidateGetSamplerParameterBase(Context *context, ...@@ -456,7 +455,7 @@ bool ValidateGetSamplerParameterBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -509,7 +508,7 @@ bool ValidateGetActiveUniformBlockivBase(Context *context, ...@@ -509,7 +508,7 @@ bool ValidateGetActiveUniformBlockivBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -576,7 +575,7 @@ bool ValidateGetInternalFormativBase(Context *context, ...@@ -576,7 +575,7 @@ bool ValidateGetInternalFormativBase(Context *context,
if (bufSize < 0) if (bufSize < 0)
{ {
context->handleError(InvalidValue() << "bufSize cannot be negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), InsufficientBufferSize);
return false; return false;
} }
...@@ -592,7 +591,7 @@ bool ValidateGetInternalFormativBase(Context *context, ...@@ -592,7 +591,7 @@ bool ValidateGetInternalFormativBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -614,13 +613,19 @@ bool ValidateUniformCommonBase(ValidationContext *context, ...@@ -614,13 +613,19 @@ bool ValidateUniformCommonBase(ValidationContext *context,
// TODO(Jiajia): Add image uniform check in future. // TODO(Jiajia): Add image uniform check in future.
if (count < 0) if (count < 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeCount);
return false; return false;
} }
if (!program || !program->isLinked()) if (!program)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidProgramName);
return false;
}
if (!program->isLinked())
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked);
return false; return false;
} }
...@@ -705,7 +710,7 @@ bool ValidateUniformValue(ValidationContext *context, GLenum valueType, GLenum u ...@@ -705,7 +710,7 @@ bool ValidateUniformValue(ValidationContext *context, GLenum valueType, GLenum u
return true; return true;
} }
context->handleError(InvalidOperation() << "wrong type of value for uniform"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), UniformSizeDoesNotMatchMethod);
return false; return false;
} }
...@@ -1026,10 +1031,10 @@ bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level) ...@@ -1026,10 +1031,10 @@ bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level)
UNREACHABLE(); UNREACHABLE();
} }
return level <= gl::log2(static_cast<int>(maxDimension)); return level <= gl::log2(static_cast<int>(maxDimension)) && level >= 0;
} }
bool ValidImageSizeParameters(const ValidationContext *context, bool ValidImageSizeParameters(ValidationContext *context,
GLenum target, GLenum target,
GLint level, GLint level,
GLsizei width, GLsizei width,
...@@ -1037,11 +1042,11 @@ bool ValidImageSizeParameters(const ValidationContext *context, ...@@ -1037,11 +1042,11 @@ bool ValidImageSizeParameters(const ValidationContext *context,
GLsizei depth, GLsizei depth,
bool isSubImage) bool isSubImage)
{ {
if (level < 0 || width < 0 || height < 0 || depth < 0) if (width < 0 || height < 0 || depth < 0)
{ {
ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
return false; return false;
} }
// TexSubImage parameters can be NPOT without textureNPOT extension, // TexSubImage parameters can be NPOT without textureNPOT extension,
// as long as the destination texture is POT. // as long as the destination texture is POT.
bool hasNPOTSupport = bool hasNPOTSupport =
...@@ -1049,11 +1054,13 @@ bool ValidImageSizeParameters(const ValidationContext *context, ...@@ -1049,11 +1054,13 @@ bool ValidImageSizeParameters(const ValidationContext *context,
if (!isSubImage && !hasNPOTSupport && if (!isSubImage && !hasNPOTSupport &&
(level != 0 && (!gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth)))) (level != 0 && (!gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth))))
{ {
ANGLE_VALIDATION_ERR(context, InvalidValue(), TextureNotPow2);
return false; return false;
} }
if (!ValidMipLevel(context, target, level)) if (!ValidMipLevel(context, target, level))
{ {
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel);
return false; return false;
} }
...@@ -1273,7 +1280,6 @@ bool ValidateWebGLVertexAttribPointer(ValidationContext *context, ...@@ -1273,7 +1280,6 @@ bool ValidateWebGLVertexAttribPointer(ValidationContext *context,
bool pureInteger) bool pureInteger)
{ {
ASSERT(context->getExtensions().webglCompatibility); ASSERT(context->getExtensions().webglCompatibility);
// WebGL 1.0 [Section 6.11] Vertex Attribute Data Stride // WebGL 1.0 [Section 6.11] Vertex Attribute Data Stride
// The WebGL API supports vertex attribute data strides up to 255 bytes. A call to // The WebGL API supports vertex attribute data strides up to 255 bytes. A call to
// vertexAttribPointer will generate an INVALID_VALUE error if the value for the stride // vertexAttribPointer will generate an INVALID_VALUE error if the value for the stride
...@@ -1297,13 +1303,13 @@ bool ValidateWebGLVertexAttribPointer(ValidationContext *context, ...@@ -1297,13 +1303,13 @@ bool ValidateWebGLVertexAttribPointer(ValidationContext *context,
size_t sizeMask = (typeSize - 1); size_t sizeMask = (typeSize - 1);
if ((reinterpret_cast<intptr_t>(ptr) & sizeMask) != 0) if ((reinterpret_cast<intptr_t>(ptr) & sizeMask) != 0)
{ {
context->handleError(InvalidOperation() << "Offset is not a multiple of the type size."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), OffsetMustBeMultipleOfType);
return false; return false;
} }
if ((stride & sizeMask) != 0) if ((stride & sizeMask) != 0)
{ {
context->handleError(InvalidOperation() << "Stride is not a multiple of the type size."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), StrideMustBeMultipleOfType);
return false; return false;
} }
...@@ -1323,12 +1329,11 @@ Program *GetValidProgram(ValidationContext *context, GLuint id) ...@@ -1323,12 +1329,11 @@ Program *GetValidProgram(ValidationContext *context, GLuint id)
{ {
if (context->getShader(id)) if (context->getShader(id))
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExpectedProgramName);
<< "Expected a program name, but found a shader name");
} }
else else
{ {
context->handleError(InvalidValue() << "Program name is not valid"); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProgramName);
} }
} }
...@@ -1345,12 +1350,11 @@ Shader *GetValidShader(ValidationContext *context, GLuint id) ...@@ -1345,12 +1350,11 @@ Shader *GetValidShader(ValidationContext *context, GLuint id)
{ {
if (context->getProgram(id)) if (context->getProgram(id))
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExpectedShaderName);
<< "Expected a shader name, but found a program name");
} }
else else
{ {
context->handleError(InvalidValue() << "Shader name is invalid"); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidShaderName);
} }
} }
...@@ -1381,13 +1385,13 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment) ...@@ -1381,13 +1385,13 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment)
if (!context->getExtensions().webglCompatibility && if (!context->getExtensions().webglCompatibility &&
context->getClientMajorVersion() < 3) context->getClientMajorVersion() < 3)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
} }
...@@ -1407,13 +1411,13 @@ bool ValidateRenderbufferStorageParametersBase(ValidationContext *context, ...@@ -1407,13 +1411,13 @@ bool ValidateRenderbufferStorageParametersBase(ValidationContext *context,
case GL_RENDERBUFFER: case GL_RENDERBUFFER:
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidRenderbufferTarget);
return false; return false;
} }
if (width < 0 || height < 0 || samples < 0) if (width < 0 || height < 0 || samples < 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidRenderbufferWidthHeight);
return false; return false;
} }
...@@ -1433,7 +1437,7 @@ bool ValidateRenderbufferStorageParametersBase(ValidationContext *context, ...@@ -1433,7 +1437,7 @@ bool ValidateRenderbufferStorageParametersBase(ValidationContext *context,
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(convertedInternalFormat); const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(convertedInternalFormat);
if (formatInfo.internalFormat == GL_NONE) if (formatInfo.internalFormat == GL_NONE)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidRenderbufferInternalFormat);
return false; return false;
} }
...@@ -1446,7 +1450,7 @@ bool ValidateRenderbufferStorageParametersBase(ValidationContext *context, ...@@ -1446,7 +1450,7 @@ bool ValidateRenderbufferStorageParametersBase(ValidationContext *context,
GLuint handle = context->getGLState().getRenderbufferId(); GLuint handle = context->getGLState().getRenderbufferId();
if (handle == 0) if (handle == 0)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidRenderbufferTarget);
return false; return false;
} }
...@@ -1470,7 +1474,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, ...@@ -1470,7 +1474,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context,
ASSERT(framebuffer); ASSERT(framebuffer);
if (framebuffer->id() == 0) if (framebuffer->id() == 0)
{ {
context->handleError(InvalidOperation() << "Cannot change default FBO's attachments"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), DefaultFramebufferTarget);
return false; return false;
} }
...@@ -1487,7 +1491,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, ...@@ -1487,7 +1491,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context,
{ {
if (!context->getRenderbuffer(renderbuffer)) if (!context->getRenderbuffer(renderbuffer))
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidRenderbufferTarget);
return false; return false;
} }
} }
...@@ -1773,7 +1777,7 @@ bool ValidateReadnPixelsEXT(Context *context, ...@@ -1773,7 +1777,7 @@ bool ValidateReadnPixelsEXT(Context *context,
{ {
if (bufSize < 0) if (bufSize < 0)
{ {
context->handleError(InvalidValue() << "bufSize must be a positive number"); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -2014,7 +2018,7 @@ bool ValidateGetQueryivEXT(Context *context, GLenum target, GLenum pname, GLint ...@@ -2014,7 +2018,7 @@ bool ValidateGetQueryivEXT(Context *context, GLenum target, GLenum pname, GLint
if (!context->getExtensions().occlusionQueryBoolean && if (!context->getExtensions().occlusionQueryBoolean &&
!context->getExtensions().disjointTimerQuery && !context->getExtensions().syncQuery) !context->getExtensions().disjointTimerQuery && !context->getExtensions().syncQuery)
{ {
context->handleError(InvalidOperation() << "Query extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2074,7 +2078,7 @@ bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname, ...@@ -2074,7 +2078,7 @@ bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname,
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid pname enum"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -2132,7 +2136,7 @@ bool ValidateGetQueryObjectuivEXT(Context *context, GLuint id, GLenum pname, GLu ...@@ -2132,7 +2136,7 @@ bool ValidateGetQueryObjectuivEXT(Context *context, GLuint id, GLenum pname, GLu
if (!context->getExtensions().disjointTimerQuery && if (!context->getExtensions().disjointTimerQuery &&
!context->getExtensions().occlusionQueryBoolean && !context->getExtensions().syncQuery) !context->getExtensions().occlusionQueryBoolean && !context->getExtensions().syncQuery)
{ {
context->handleError(InvalidOperation() << "Query extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); return ValidateGetQueryObjectValueBase(context, id, pname, nullptr);
...@@ -2148,7 +2152,7 @@ bool ValidateGetQueryObjectuivRobustANGLE(Context *context, ...@@ -2148,7 +2152,7 @@ bool ValidateGetQueryObjectuivRobustANGLE(Context *context,
if (!context->getExtensions().disjointTimerQuery && if (!context->getExtensions().disjointTimerQuery &&
!context->getExtensions().occlusionQueryBoolean && !context->getExtensions().syncQuery) !context->getExtensions().occlusionQueryBoolean && !context->getExtensions().syncQuery)
{ {
context->handleError(InvalidOperation() << "Query extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2174,7 +2178,7 @@ bool ValidateGetQueryObjecti64vEXT(Context *context, GLuint id, GLenum pname, GL ...@@ -2174,7 +2178,7 @@ bool ValidateGetQueryObjecti64vEXT(Context *context, GLuint id, GLenum pname, GL
{ {
if (!context->getExtensions().disjointTimerQuery) if (!context->getExtensions().disjointTimerQuery)
{ {
context->handleError(InvalidOperation() << "Timer query extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); return ValidateGetQueryObjectValueBase(context, id, pname, nullptr);
...@@ -2189,7 +2193,7 @@ bool ValidateGetQueryObjecti64vRobustANGLE(Context *context, ...@@ -2189,7 +2193,7 @@ bool ValidateGetQueryObjecti64vRobustANGLE(Context *context,
{ {
if (!context->getExtensions().disjointTimerQuery) if (!context->getExtensions().disjointTimerQuery)
{ {
context->handleError(InvalidOperation() << "Timer query extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2215,7 +2219,7 @@ bool ValidateGetQueryObjectui64vEXT(Context *context, GLuint id, GLenum pname, G ...@@ -2215,7 +2219,7 @@ bool ValidateGetQueryObjectui64vEXT(Context *context, GLuint id, GLenum pname, G
{ {
if (!context->getExtensions().disjointTimerQuery) if (!context->getExtensions().disjointTimerQuery)
{ {
context->handleError(InvalidOperation() << "Timer query extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); return ValidateGetQueryObjectValueBase(context, id, pname, nullptr);
...@@ -2230,7 +2234,7 @@ bool ValidateGetQueryObjectui64vRobustANGLE(Context *context, ...@@ -2230,7 +2234,7 @@ bool ValidateGetQueryObjectui64vRobustANGLE(Context *context,
{ {
if (!context->getExtensions().disjointTimerQuery) if (!context->getExtensions().disjointTimerQuery)
{ {
context->handleError(InvalidOperation() << "Timer query extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2485,9 +2489,15 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, ...@@ -2485,9 +2489,15 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
GLint border, GLint border,
Format *textureFormatOut) Format *textureFormatOut)
{ {
if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) if (xoffset < 0 || yoffset < 0 || zoffset < 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
return false;
}
if (width < 0 || height < 0)
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
return false; return false;
} }
...@@ -2500,13 +2510,13 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, ...@@ -2500,13 +2510,13 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
if (border != 0) if (border != 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidBorder);
return false; return false;
} }
if (!ValidMipLevel(context, target, level)) if (!ValidMipLevel(context, target, level))
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel);
return false; return false;
} }
...@@ -2536,7 +2546,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, ...@@ -2536,7 +2546,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
// situation is an application error that would lead to a crash in ANGLE. // situation is an application error that would lead to a crash in ANGLE.
if (readFramebuffer->getReadColorbuffer() == nullptr) if (readFramebuffer->getReadColorbuffer() == nullptr)
{ {
context->handleError(InvalidOperation() << "Missing read attachment"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MissingReadAttachment);
return false; return false;
} }
...@@ -2575,7 +2585,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, ...@@ -2575,7 +2585,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
state.getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); state.getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
if (!texture) if (!texture)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), TextureNotBound);
return false; return false;
} }
...@@ -2608,13 +2618,13 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, ...@@ -2608,13 +2618,13 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
{ {
if (IsCubeMapTextureTarget(target) && width != height) if (IsCubeMapTextureTarget(target) && width != height)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), CubemapIncomplete);
return false; return false;
} }
if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -2622,7 +2632,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context, ...@@ -2622,7 +2632,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
if (static_cast<int>(width) > maxLevelDimension || if (static_cast<int>(width) > maxLevelDimension ||
static_cast<int>(height) > maxLevelDimension) static_cast<int>(height) > maxLevelDimension)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), ResourceMaxTextureSize);
return false; return false;
} }
} }
...@@ -2660,13 +2670,13 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2660,13 +2670,13 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
case GL_TRIANGLE_FAN: case GL_TRIANGLE_FAN:
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidDrawMode);
return false; return false;
} }
if (count < 0) if (count < 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeCount);
return false; return false;
} }
...@@ -2705,7 +2715,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2705,7 +2715,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
ERR() << "This ANGLE implementation does not support separate front/back stencil " ERR() << "This ANGLE implementation does not support separate front/back stencil "
"writemasks, reference values, or stencil mask values."; "writemasks, reference values, or stencil mask values.";
} }
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), StencilReferenceMaskOrMismatch);
return false; return false;
} }
} }
...@@ -2719,7 +2729,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2719,7 +2729,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
gl::Program *program = state.getProgram(); gl::Program *program = state.getProgram();
if (!program) if (!program)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotBound);
return false; return false;
} }
...@@ -2801,7 +2811,7 @@ bool ValidateDrawArraysCommon(ValidationContext *context, ...@@ -2801,7 +2811,7 @@ bool ValidateDrawArraysCommon(ValidationContext *context,
{ {
if (first < 0) if (first < 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeStart);
return false; return false;
} }
...@@ -2814,7 +2824,7 @@ bool ValidateDrawArraysCommon(ValidationContext *context, ...@@ -2814,7 +2824,7 @@ bool ValidateDrawArraysCommon(ValidationContext *context,
// that does not match the current transform feedback object's draw mode (if transform // that does not match the current transform feedback object's draw mode (if transform
// feedback // feedback
// is active), (3.0.2, section 2.14, pg 86) // is active), (3.0.2, section 2.14, pg 86)
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidDrawModeTransformFeedback);
return false; return false;
} }
...@@ -2831,7 +2841,7 @@ bool ValidateDrawArraysCommon(ValidationContext *context, ...@@ -2831,7 +2841,7 @@ bool ValidateDrawArraysCommon(ValidationContext *context,
int64_t maxVertex = static_cast<int64_t>(first) + static_cast<int64_t>(count) - 1; int64_t maxVertex = static_cast<int64_t>(first) + static_cast<int64_t>(count) - 1;
if (maxVertex > static_cast<int64_t>(std::numeric_limits<GLint>::max())) if (maxVertex > static_cast<int64_t>(std::numeric_limits<GLint>::max()))
{ {
context->handleError(InvalidOperation() << "Integer overflow."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
...@@ -2876,12 +2886,12 @@ bool ValidateDrawElementsBase(ValidationContext *context, GLenum type) ...@@ -2876,12 +2886,12 @@ bool ValidateDrawElementsBase(ValidationContext *context, GLenum type)
case GL_UNSIGNED_INT: case GL_UNSIGNED_INT:
if (context->getClientMajorVersion() < 3 && !context->getExtensions().elementIndexUint) if (context->getClientMajorVersion() < 3 && !context->getExtensions().elementIndexUint)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), TypeNotUnsignedShortByte);
return false; return false;
} }
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), TypeNotUnsignedShortByte);
return false; return false;
} }
...@@ -2938,8 +2948,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context, ...@@ -2938,8 +2948,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context,
// [WebGL 1.0] Section 6.4 Buffer Offset and Stride Requirements // [WebGL 1.0] Section 6.4 Buffer Offset and Stride Requirements
// The offset arguments to drawElements and [...], must be a multiple of the size of the // The offset arguments to drawElements and [...], must be a multiple of the size of the
// data type passed to the call, or an INVALID_OPERATION error is generated. // data type passed to the call, or an INVALID_OPERATION error is generated.
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), OffsetMustBeMultipleOfType);
<< "indices must be a multiple of the element type size.");
return false; return false;
} }
...@@ -2948,7 +2957,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context, ...@@ -2948,7 +2957,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context,
// error is generated. // error is generated.
if (reinterpret_cast<intptr_t>(indices) < 0) if (reinterpret_cast<intptr_t>(indices) < 0)
{ {
context->handleError(InvalidValue() << "Offset < 0."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
return false; return false;
} }
} }
...@@ -2961,8 +2970,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context, ...@@ -2961,8 +2970,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context,
// [WebGL 1.0] Section 6.2 No Client Side Arrays // [WebGL 1.0] Section 6.2 No Client Side Arrays
// If drawElements is called with a count greater than zero, and no WebGLBuffer is bound // If drawElements is called with a count greater than zero, and no WebGLBuffer is bound
// to the ELEMENT_ARRAY_BUFFER binding point, an INVALID_OPERATION error is generated. // to the ELEMENT_ARRAY_BUFFER binding point, an INVALID_OPERATION error is generated.
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), MustHaveElementArrayBinding);
<< "There is no element array buffer bound and count > 0.");
return false; return false;
} }
} }
...@@ -2990,15 +2998,14 @@ bool ValidateDrawElementsCommon(ValidationContext *context, ...@@ -2990,15 +2998,14 @@ bool ValidateDrawElementsCommon(ValidationContext *context,
uint64_t offset = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(indices)); uint64_t offset = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(indices));
if (elementDataSizeNoOffset > kUint64Max - offset) if (elementDataSizeNoOffset > kUint64Max - offset)
{ {
context->handleError(InvalidOperation() << "Integer overflow."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
uint64_t elementDataSizeWithOffset = elementDataSizeNoOffset + offset; uint64_t elementDataSizeWithOffset = elementDataSizeNoOffset + offset;
if (elementDataSizeWithOffset > static_cast<uint64_t>(elementArrayBuffer->getSize())) if (elementDataSizeWithOffset > static_cast<uint64_t>(elementArrayBuffer->getSize()))
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), InsufficientBufferSize);
<< "Index buffer is not big enough for the draw.");
return false; return false;
} }
} }
...@@ -3027,7 +3034,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context, ...@@ -3027,7 +3034,7 @@ bool ValidateDrawElementsCommon(ValidationContext *context,
// return an error if possible here. // return an error if possible here.
if (static_cast<GLuint64>(indexRangeOpt.value().end) >= context->getCaps().maxElementIndex) if (static_cast<GLuint64>(indexRangeOpt.value().end) >= context->getCaps().maxElementIndex)
{ {
context->handleError(InvalidOperation() << g_ExceedsMaxElementErrorMessage); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExceedsMaxElement);
return false; return false;
} }
...@@ -3074,7 +3081,7 @@ bool ValidateFramebufferTextureBase(Context *context, ...@@ -3074,7 +3081,7 @@ bool ValidateFramebufferTextureBase(Context *context,
{ {
if (!ValidFramebufferTarget(target)) if (!ValidFramebufferTarget(target))
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget);
return false; return false;
} }
...@@ -3105,7 +3112,7 @@ bool ValidateFramebufferTextureBase(Context *context, ...@@ -3105,7 +3112,7 @@ bool ValidateFramebufferTextureBase(Context *context,
if (framebuffer->id() == 0) if (framebuffer->id() == 0)
{ {
context->handleError(InvalidOperation() << "Cannot change default FBO's attachments"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), DefaultFramebufferTarget);
return false; return false;
} }
...@@ -3128,7 +3135,7 @@ bool ValidateGetUniformBase(Context *context, GLuint program, GLint location) ...@@ -3128,7 +3135,7 @@ bool ValidateGetUniformBase(Context *context, GLuint program, GLint location)
if (!programObject || !programObject->isLinked()) if (!programObject || !programObject->isLinked())
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked);
return false; return false;
} }
...@@ -3386,7 +3393,7 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context, ...@@ -3386,7 +3393,7 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "invalid texture target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
...@@ -3515,7 +3522,7 @@ bool ValidateGetProgramBinaryBase(Context *context, ...@@ -3515,7 +3522,7 @@ bool ValidateGetProgramBinaryBase(Context *context,
if (!programObject->isLinked()) if (!programObject->isLinked())
{ {
context->handleError(InvalidOperation() << "Program is not linked."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked);
return false; return false;
} }
...@@ -3633,7 +3640,7 @@ bool ValidateGetBufferPointervBase(Context *context, ...@@ -3633,7 +3640,7 @@ bool ValidateGetBufferPointervBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -3659,7 +3666,7 @@ bool ValidateUnmapBufferBase(Context *context, GLenum target) ...@@ -3659,7 +3666,7 @@ bool ValidateUnmapBufferBase(Context *context, GLenum target)
{ {
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid buffer target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
...@@ -3682,13 +3689,19 @@ bool ValidateMapBufferRangeBase(Context *context, ...@@ -3682,13 +3689,19 @@ bool ValidateMapBufferRangeBase(Context *context,
{ {
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid buffer target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
if (offset < 0 || length < 0) if (offset < 0)
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
return false;
}
if (length < 0)
{ {
context->handleError(InvalidValue() << "Invalid offset or length."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeLength);
return false; return false;
} }
...@@ -3768,15 +3781,21 @@ bool ValidateFlushMappedBufferRangeBase(Context *context, ...@@ -3768,15 +3781,21 @@ bool ValidateFlushMappedBufferRangeBase(Context *context,
GLintptr offset, GLintptr offset,
GLsizeiptr length) GLsizeiptr length)
{ {
if (offset < 0 || length < 0) if (offset < 0)
{ {
context->handleError(InvalidValue() << "Invalid offset/length parameters."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
return false;
}
if (length < 0)
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeLength);
return false; return false;
} }
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid buffer target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
...@@ -3814,7 +3833,7 @@ bool ValidateGenOrDelete(Context *context, GLint n) ...@@ -3814,7 +3833,7 @@ bool ValidateGenOrDelete(Context *context, GLint n)
{ {
if (n < 0) if (n < 0)
{ {
context->handleError(InvalidValue() << "n < 0"); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeCount);
return false; return false;
} }
return true; return true;
...@@ -3831,7 +3850,7 @@ bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize) ...@@ -3831,7 +3850,7 @@ bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize)
if (bufSize < 0) if (bufSize < 0)
{ {
context->handleError(InvalidValue() << "bufSize cannot be negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -3942,7 +3961,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -3942,7 +3961,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
{ {
if (clientVersion < 3) if (clientVersion < 3)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), DefaultFramebufferTarget);
return false; return false;
} }
...@@ -3954,7 +3973,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -3954,7 +3973,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), FramebufferInvalidAttachment);
return false; return false;
} }
} }
...@@ -3981,7 +4000,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -3981,7 +4000,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), FramebufferInvalidAttachment);
return false; return false;
} }
} }
...@@ -4000,7 +4019,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4000,7 +4019,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
if (attachmentObject->type() != GL_RENDERBUFFER && if (attachmentObject->type() != GL_RENDERBUFFER &&
attachmentObject->type() != GL_TEXTURE) attachmentObject->type() != GL_TEXTURE)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), FramebufferIncompleteAttachment);
return false; return false;
} }
break; break;
...@@ -4008,7 +4027,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4008,7 +4027,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
if (attachmentObject->type() != GL_TEXTURE) if (attachmentObject->type() != GL_TEXTURE)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), FramebufferIncompleteAttachment);
return false; return false;
} }
break; break;
...@@ -4016,7 +4035,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4016,7 +4035,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
if (attachmentObject->type() != GL_TEXTURE) if (attachmentObject->type() != GL_TEXTURE)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), FramebufferIncompleteAttachment);
return false; return false;
} }
break; break;
...@@ -4024,7 +4043,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4024,7 +4043,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), FramebufferInvalidAttachment);
return false; return false;
} }
break; break;
...@@ -4032,7 +4051,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4032,7 +4051,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
if (attachmentObject->type() != GL_TEXTURE) if (attachmentObject->type() != GL_TEXTURE)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), FramebufferIncompleteAttachment);
return false; return false;
} }
break; break;
...@@ -4058,7 +4077,8 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4058,7 +4077,8 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
if (clientVersion < 3) if (clientVersion < 3)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(),
InvalidRenderbufferTextureParameter);
return false; return false;
} }
break; break;
...@@ -4066,12 +4086,14 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4066,12 +4086,14 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
default: default:
if (clientVersion < 3) if (clientVersion < 3)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(),
InvalidRenderbufferTextureParameter);
return false; return false;
} }
else else
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(),
InvalidRenderbufferTextureParameter);
return false; return false;
} }
} }
...@@ -4226,7 +4248,7 @@ bool ValidateGetProgramivBase(ValidationContext *context, ...@@ -4226,7 +4248,7 @@ bool ValidateGetProgramivBase(ValidationContext *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown parameter name."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -4712,14 +4734,13 @@ bool ValidateVertexFormatBase(ValidationContext *context, ...@@ -4712,14 +4734,13 @@ bool ValidateVertexFormatBase(ValidationContext *context,
const Caps &caps = context->getCaps(); const Caps &caps = context->getCaps();
if (attribIndex >= caps.maxVertexAttributes) if (attribIndex >= caps.maxVertexAttributes)
{ {
context->handleError(InvalidValue() ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMax);
<< "attribindex must be smaller than MAX_VERTEX_ATTRIBS.");
return false; return false;
} }
if (size < 1 || size > 4) if (size < 1 || size > 4)
{ {
context->handleError(InvalidValue() << "size must be between one and four."); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidVertexAttrSize);
return false; return false;
} }
...@@ -4745,7 +4766,7 @@ bool ValidateVertexFormatBase(ValidationContext *context, ...@@ -4745,7 +4766,7 @@ bool ValidateVertexFormatBase(ValidationContext *context,
case GL_FLOAT: case GL_FLOAT:
if (pureInteger) if (pureInteger)
{ {
context->handleError(InvalidEnum() << "Type is not integer."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTypePureInt);
return false; return false;
} }
break; break;
...@@ -4759,7 +4780,7 @@ bool ValidateVertexFormatBase(ValidationContext *context, ...@@ -4759,7 +4780,7 @@ bool ValidateVertexFormatBase(ValidationContext *context,
} }
if (pureInteger) if (pureInteger)
{ {
context->handleError(InvalidEnum() << "Type is not integer."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTypePureInt);
return false; return false;
} }
break; break;
...@@ -4774,7 +4795,7 @@ bool ValidateVertexFormatBase(ValidationContext *context, ...@@ -4774,7 +4795,7 @@ bool ValidateVertexFormatBase(ValidationContext *context,
} }
if (pureInteger) if (pureInteger)
{ {
context->handleError(InvalidEnum() << "Type is not integer."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTypePureInt);
return false; return false;
} }
if (size != 4) if (size != 4)
...@@ -4787,7 +4808,7 @@ bool ValidateVertexFormatBase(ValidationContext *context, ...@@ -4787,7 +4808,7 @@ bool ValidateVertexFormatBase(ValidationContext *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid vertex type."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidType);
return false; return false;
} }
...@@ -4854,7 +4875,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context, ...@@ -4854,7 +4875,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context,
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid buffer target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
...@@ -4862,7 +4883,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context, ...@@ -4862,7 +4883,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context,
if (!buffer) if (!buffer)
{ {
// A null buffer means that "0" is bound to the requested buffer target // A null buffer means that "0" is bound to the requested buffer target
context->handleError(InvalidOperation() << "No buffer bound."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), BufferNotBound);
return false; return false;
} }
...@@ -4917,7 +4938,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context, ...@@ -4917,7 +4938,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -4942,14 +4963,14 @@ bool ValidateGetRenderbufferParameterivBase(Context *context, ...@@ -4942,14 +4963,14 @@ bool ValidateGetRenderbufferParameterivBase(Context *context,
if (target != GL_RENDERBUFFER) if (target != GL_RENDERBUFFER)
{ {
context->handleError(InvalidEnum() << "Invalid target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidRenderbufferTarget);
return false; return false;
} }
Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer();
if (renderbuffer == nullptr) if (renderbuffer == nullptr)
{ {
context->handleError(InvalidOperation() << "No renderbuffer bound."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), RenderbufferNotBound);
return false; return false;
} }
...@@ -4969,14 +4990,13 @@ bool ValidateGetRenderbufferParameterivBase(Context *context, ...@@ -4969,14 +4990,13 @@ bool ValidateGetRenderbufferParameterivBase(Context *context,
case GL_RENDERBUFFER_SAMPLES_ANGLE: case GL_RENDERBUFFER_SAMPLES_ANGLE:
if (!context->getExtensions().framebufferMultisample) if (!context->getExtensions().framebufferMultisample)
{ {
context->handleError(InvalidEnum() ANGLE_VALIDATION_ERR(context, InvalidEnum(), ExtensionNotEnabled);
<< "GL_ANGLE_framebuffer_multisample is not enabled.");
return false; return false;
} }
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5011,14 +5031,13 @@ bool ValidateGetShaderivBase(Context *context, GLuint shader, GLenum pname, GLsi ...@@ -5011,14 +5031,13 @@ bool ValidateGetShaderivBase(Context *context, GLuint shader, GLenum pname, GLsi
case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
if (!context->getExtensions().translatedShaderSource) if (!context->getExtensions().translatedShaderSource)
{ {
context->handleError(InvalidEnum() ANGLE_VALIDATION_ERR(context, InvalidEnum(), ExtensionNotEnabled);
<< "GL_ANGLE_translated_shader_source is not enabled.");
return false; return false;
} }
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5038,14 +5057,14 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname, ...@@ -5038,14 +5057,14 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname,
if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid texture target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
if (context->getTargetTexture(target) == nullptr) if (context->getTargetTexture(target) == nullptr)
{ {
// Should only be possible for external textures // Should only be possible for external textures
context->handleError(InvalidEnum() << "No texture bound."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), TextureNotBound);
return false; return false;
} }
...@@ -5060,7 +5079,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname, ...@@ -5060,7 +5079,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname,
case GL_TEXTURE_USAGE_ANGLE: case GL_TEXTURE_USAGE_ANGLE:
if (!context->getExtensions().textureUsage) if (!context->getExtensions().textureUsage)
{ {
context->handleError(InvalidEnum() << "GL_ANGLE_texture_usage is not enabled."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), ExtensionNotEnabled);
return false; return false;
} }
break; break;
...@@ -5068,8 +5087,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname, ...@@ -5068,8 +5087,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname,
case GL_TEXTURE_MAX_ANISOTROPY_EXT: case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (!context->getExtensions().textureFilterAnisotropic) if (!context->getExtensions().textureFilterAnisotropic)
{ {
context->handleError(InvalidEnum() ANGLE_VALIDATION_ERR(context, InvalidEnum(), ExtensionNotEnabled);
<< "GL_EXT_texture_filter_anisotropic is not enabled.");
return false; return false;
} }
break; break;
...@@ -5077,7 +5095,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname, ...@@ -5077,7 +5095,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname,
case GL_TEXTURE_IMMUTABLE_FORMAT: case GL_TEXTURE_IMMUTABLE_FORMAT:
if (context->getClientMajorVersion() < 3 && !context->getExtensions().textureStorage) if (context->getClientMajorVersion() < 3 && !context->getExtensions().textureStorage)
{ {
context->handleError(InvalidEnum() << "GL_EXT_texture_storage is not enabled."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), ExtensionNotEnabled);
return false; return false;
} }
break; break;
...@@ -5110,7 +5128,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname, ...@@ -5110,7 +5128,7 @@ bool ValidateGetTexParameterBase(Context *context, GLenum target, GLenum pname,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5141,8 +5159,7 @@ bool ValidateGetVertexAttribBase(Context *context, ...@@ -5141,8 +5159,7 @@ bool ValidateGetVertexAttribBase(Context *context,
if (index >= context->getCaps().maxVertexAttributes) if (index >= context->getCaps().maxVertexAttributes)
{ {
context->handleError(InvalidValue() ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMax);
<< "index must be less than the value of GL_MAX_VERTEX_ATTRIBUTES.");
return false; return false;
} }
...@@ -5150,7 +5167,7 @@ bool ValidateGetVertexAttribBase(Context *context, ...@@ -5150,7 +5167,7 @@ bool ValidateGetVertexAttribBase(Context *context,
{ {
if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
{ {
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
} }
...@@ -5201,7 +5218,7 @@ bool ValidateGetVertexAttribBase(Context *context, ...@@ -5201,7 +5218,7 @@ bool ValidateGetVertexAttribBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
} }
...@@ -5249,7 +5266,7 @@ bool ValidateReadPixelsBase(Context *context, ...@@ -5249,7 +5266,7 @@ bool ValidateReadPixelsBase(Context *context,
if (width < 0 || height < 0) if (width < 0 || height < 0)
{ {
context->handleError(InvalidValue() << "width and height must be positive"); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
return false; return false;
} }
...@@ -5283,7 +5300,7 @@ bool ValidateReadPixelsBase(Context *context, ...@@ -5283,7 +5300,7 @@ bool ValidateReadPixelsBase(Context *context,
// situation is an application error that would lead to a crash in ANGLE. // situation is an application error that would lead to a crash in ANGLE.
if (readBuffer == nullptr) if (readBuffer == nullptr)
{ {
context->handleError(InvalidOperation() << "Missing read attachment"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MissingReadAttachment);
return false; return false;
} }
...@@ -5296,7 +5313,7 @@ bool ValidateReadPixelsBase(Context *context, ...@@ -5296,7 +5313,7 @@ bool ValidateReadPixelsBase(Context *context,
if (!(currentFormat == format && currentType == type) && !validFormatTypeCombination) if (!(currentFormat == format && currentType == type) && !validFormatTypeCombination)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
...@@ -5342,8 +5359,7 @@ bool ValidateReadPixelsBase(Context *context, ...@@ -5342,8 +5359,7 @@ bool ValidateReadPixelsBase(Context *context,
if (checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelPackBuffer->getSize())) if (checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelPackBuffer->getSize()))
{ {
// Overflow past the end of the buffer // Overflow past the end of the buffer
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), ParamOverflow);
<< "Writes would overflow the pixel pack buffer.");
return false; return false;
} }
} }
...@@ -5352,7 +5368,7 @@ bool ValidateReadPixelsBase(Context *context, ...@@ -5352,7 +5368,7 @@ bool ValidateReadPixelsBase(Context *context,
{ {
if (endByte > static_cast<size_t>(std::numeric_limits<GLsizei>::max())) if (endByte > static_cast<size_t>(std::numeric_limits<GLsizei>::max()))
{ {
context->handleError(InvalidOperation() << "length would overflow GLsizei."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
...@@ -5404,21 +5420,21 @@ bool ValidateTexParameterBase(Context *context, ...@@ -5404,21 +5420,21 @@ bool ValidateTexParameterBase(Context *context,
{ {
if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target)) if (!ValidTextureTarget(context, target) && !ValidTextureExternalTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid texture target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
if (context->getTargetTexture(target) == nullptr) if (context->getTargetTexture(target) == nullptr)
{ {
// Should only be possible for external textures // Should only be possible for external textures
context->handleError(InvalidEnum() << "No texture bound."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), TextureNotBound);
return false; return false;
} }
const GLsizei minBufSize = 1; const GLsizei minBufSize = 1;
if (bufSize >= 0 && bufSize < minBufSize) if (bufSize >= 0 && bufSize < minBufSize)
{ {
context->handleError(InvalidOperation() << "bufSize must be at least " << minBufSize); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InsufficientBufferSize);
return false; return false;
} }
...@@ -5487,7 +5503,7 @@ bool ValidateTexParameterBase(Context *context, ...@@ -5487,7 +5503,7 @@ bool ValidateTexParameterBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown param value."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
break; break;
...@@ -5541,7 +5557,7 @@ bool ValidateTexParameterBase(Context *context, ...@@ -5541,7 +5557,7 @@ bool ValidateTexParameterBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown param value."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
break; break;
...@@ -5563,7 +5579,7 @@ bool ValidateTexParameterBase(Context *context, ...@@ -5563,7 +5579,7 @@ bool ValidateTexParameterBase(Context *context,
case GL_TEXTURE_MAX_LEVEL: case GL_TEXTURE_MAX_LEVEL:
if (params[0] < 0) if (params[0] < 0)
{ {
context->handleError(InvalidValue() << "Max level must be at least 0."); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel);
return false; return false;
} }
break; break;
...@@ -5571,7 +5587,7 @@ bool ValidateTexParameterBase(Context *context, ...@@ -5571,7 +5587,7 @@ bool ValidateTexParameterBase(Context *context,
case GL_DEPTH_STENCIL_TEXTURE_MODE: case GL_DEPTH_STENCIL_TEXTURE_MODE:
if (context->getClientVersion() < Version(3, 1)) if (context->getClientVersion() < Version(3, 1))
{ {
context->handleError(InvalidEnum() << "pname requires OpenGL ES 3.1."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumRequiresGLES31);
return false; return false;
} }
switch (ConvertToGLenum(params[0])) switch (ConvertToGLenum(params[0]))
...@@ -5581,7 +5597,7 @@ bool ValidateTexParameterBase(Context *context, ...@@ -5581,7 +5597,7 @@ bool ValidateTexParameterBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown param value."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
break; break;
...@@ -5594,7 +5610,7 @@ bool ValidateTexParameterBase(Context *context, ...@@ -5594,7 +5610,7 @@ bool ValidateTexParameterBase(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
......
...@@ -40,7 +40,7 @@ bool ValidFramebufferTarget(GLenum target); ...@@ -40,7 +40,7 @@ bool ValidFramebufferTarget(GLenum target);
bool ValidBufferTarget(const ValidationContext *context, GLenum target); bool ValidBufferTarget(const ValidationContext *context, GLenum target);
bool ValidBufferParameter(const ValidationContext *context, GLenum pname, GLsizei *numParams); bool ValidBufferParameter(const ValidationContext *context, GLenum pname, GLsizei *numParams);
bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level); bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level);
bool ValidImageSizeParameters(const ValidationContext *context, bool ValidImageSizeParameters(ValidationContext *context,
GLenum target, GLenum target,
GLint level, GLint level,
GLsizei width, GLsizei width,
...@@ -602,8 +602,6 @@ bool ValidateRobustCompressedTexImageBase(ValidationContext *context, ...@@ -602,8 +602,6 @@ bool ValidateRobustCompressedTexImageBase(ValidationContext *context,
GLsizei imageSize, GLsizei imageSize,
GLsizei dataSize); GLsizei dataSize);
// Error messages shared here for use in testing.
extern const char *g_ExceedsMaxElementErrorMessage;
} // namespace gl } // namespace gl
#endif // LIBANGLE_VALIDATION_ES_H_ #endif // LIBANGLE_VALIDATION_ES_H_
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "common/string_utils.h" #include "common/string_utils.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/ErrorStrings.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
...@@ -110,7 +111,7 @@ bool ValidateInstancedPathParameters(gl::Context *context, ...@@ -110,7 +111,7 @@ bool ValidateInstancedPathParameters(gl::Context *context,
if (!angle::IsValueInRangeForNumericType<std::uint32_t>(numPaths)) if (!angle::IsValueInRangeForNumericType<std::uint32_t>(numPaths))
{ {
context->handleError(InvalidOperation() << "Overflow in numPaths."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
...@@ -198,7 +199,7 @@ bool ValidateInstancedPathParameters(gl::Context *context, ...@@ -198,7 +199,7 @@ bool ValidateInstancedPathParameters(gl::Context *context,
checkedSize += (numPaths * sizeof(GLfloat) * componentCount); checkedSize += (numPaths * sizeof(GLfloat) * componentCount);
if (!checkedSize.IsValid()) if (!checkedSize.IsValid())
{ {
context->handleError(InvalidOperation() << "Overflow in num paths."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
...@@ -450,7 +451,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -450,7 +451,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
{ {
if (!ValidTexture2DDestinationTarget(context, target)) if (!ValidTexture2DDestinationTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid texture target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
...@@ -483,7 +484,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -483,7 +484,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES &&
colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -494,7 +495,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -494,7 +495,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -507,7 +508,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -507,7 +508,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -519,7 +520,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -519,7 +520,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -530,7 +531,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -530,7 +531,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -540,7 +541,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -540,7 +541,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGBA32F &&
colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -554,20 +555,20 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -554,20 +555,20 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE: case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT:
case GL_DEPTH_STENCIL_OES: case GL_DEPTH_STENCIL_OES:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
if (formatInfo.type == GL_FLOAT && !context->getExtensions().textureFloat) if (formatInfo.type == GL_FLOAT && !context->getExtensions().textureFloat)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
} }
...@@ -580,7 +581,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -580,7 +581,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT &&
colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -591,7 +592,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -591,7 +592,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -602,7 +603,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -602,7 +603,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -612,7 +613,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -612,7 +613,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT &&
colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -622,7 +623,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -622,7 +623,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -632,7 +633,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -632,7 +633,7 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES &&
colorbufferFormat != GL_BGR5_A1_ANGLEX) colorbufferFormat != GL_BGR5_A1_ANGLEX)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
break; break;
...@@ -640,36 +641,36 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context, ...@@ -640,36 +641,36 @@ bool ValidateES2CopyTexImageParameters(ValidationContext *context,
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (context->getExtensions().textureCompressionDXT1) if (context->getExtensions().textureCompressionDXT1)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
else else
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (context->getExtensions().textureCompressionDXT3) if (context->getExtensions().textureCompressionDXT3)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
else else
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (context->getExtensions().textureCompressionDXT5) if (context->getExtensions().textureCompressionDXT5)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false; return false;
} }
else else
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
break; break;
...@@ -829,7 +830,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -829,7 +830,7 @@ bool ValidateES2TexImageParameters(Context *context,
{ {
if (!ValidTexture2DDestinationTarget(context, target)) if (!ValidTexture2DDestinationTarget(context, target))
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
...@@ -839,10 +840,16 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -839,10 +840,16 @@ bool ValidateES2TexImageParameters(Context *context,
return false; return false;
} }
if (level < 0 || xoffset < 0 || std::numeric_limits<GLsizei>::max() - xoffset < width || if (!ValidMipLevel(context, target, level))
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel);
return false;
}
if (xoffset < 0 || std::numeric_limits<GLsizei>::max() - xoffset < width ||
std::numeric_limits<GLsizei>::max() - yoffset < height) std::numeric_limits<GLsizei>::max() - yoffset < height)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), ResourceMaxTextureSize);
return false; return false;
} }
...@@ -876,7 +883,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -876,7 +883,7 @@ bool ValidateES2TexImageParameters(Context *context,
{ {
if (!isSubImage && width != height) if (!isSubImage && width != height)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), CubemapFacesEqualDimensions);
return false; return false;
} }
...@@ -897,7 +904,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -897,7 +904,7 @@ bool ValidateES2TexImageParameters(Context *context,
context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
if (!texture) if (!texture)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), BufferNotBound);
return false; return false;
} }
...@@ -915,7 +922,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -915,7 +922,7 @@ bool ValidateES2TexImageParameters(Context *context,
if (GetInternalFormatInfo(format, type).sizedInternalFormat != if (GetInternalFormatInfo(format, type).sizedInternalFormat !=
textureInternalFormat.sizedInternalFormat) textureInternalFormat.sizedInternalFormat)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), TypeMustMatchOriginalType);
return false; return false;
} }
} }
...@@ -939,7 +946,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -939,7 +946,7 @@ bool ValidateES2TexImageParameters(Context *context,
// Verify zero border // Verify zero border
if (border != 0) if (border != 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidBorder);
return false; return false;
} }
...@@ -954,21 +961,21 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -954,21 +961,21 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (!context->getExtensions().textureCompressionDXT1) if (!context->getExtensions().textureCompressionDXT1)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidInternalFormat);
return false; return false;
} }
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (!context->getExtensions().textureCompressionDXT1) if (!context->getExtensions().textureCompressionDXT1)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidInternalFormat);
return false; return false;
} }
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (!context->getExtensions().textureCompressionDXT5) if (!context->getExtensions().textureCompressionDXT5)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidInternalFormat);
return false; return false;
} }
break; break;
...@@ -978,14 +985,14 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -978,14 +985,14 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
if (!context->getExtensions().textureCompressionS3TCsRGB) if (!context->getExtensions().textureCompressionS3TCsRGB)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidInternalFormat);
return false; return false;
} }
break; break;
case GL_ETC1_RGB8_OES: case GL_ETC1_RGB8_OES:
if (!context->getExtensions().compressedETC1RGB8Texture) if (!context->getExtensions().compressedETC1RGB8Texture)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidInternalFormat);
return false; return false;
} }
break; break;
...@@ -1002,9 +1009,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1002,9 +1009,7 @@ bool ValidateES2TexImageParameters(Context *context,
} }
break; break;
default: default:
context->handleError( ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidInternalFormat);
InvalidEnum()
<< "internalformat is not a supported compressed internal format");
return false; return false;
} }
...@@ -1020,8 +1025,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1020,8 +1025,7 @@ bool ValidateES2TexImageParameters(Context *context,
if (format != actualInternalFormat) if (format != actualInternalFormat)
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
<< "Format must match the internal format of the texture.");
return false; return false;
} }
} }
...@@ -1050,7 +1054,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1050,7 +1054,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_FLOAT: case GL_FLOAT:
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidType);
return false; return false;
} }
...@@ -1069,7 +1073,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1069,7 +1073,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_HALF_FLOAT_OES: case GL_HALF_FLOAT_OES:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1087,7 +1091,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1087,7 +1091,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_HALF_FLOAT_OES: case GL_HALF_FLOAT_OES:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1100,7 +1104,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1100,7 +1104,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_HALF_FLOAT_OES: case GL_HALF_FLOAT_OES:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1114,7 +1118,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1114,7 +1118,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_HALF_FLOAT_OES: case GL_HALF_FLOAT_OES:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1124,7 +1128,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1124,7 +1128,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1140,7 +1144,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1140,7 +1144,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1157,7 +1161,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1157,7 +1161,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_UNSIGNED_INT: case GL_UNSIGNED_INT:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1167,7 +1171,7 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1167,7 +1171,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_UNSIGNED_INT_24_8_OES: case GL_UNSIGNED_INT_24_8_OES:
break; break;
default: default:
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
return false; return false;
} }
break; break;
...@@ -1283,14 +1287,12 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1283,14 +1287,12 @@ bool ValidateES2TexImageParameters(Context *context,
} }
if (type != GL_FLOAT) if (type != GL_FLOAT)
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
<< "Invalid internal format/type combination");
return false; return false;
} }
if (format != GL_RGBA) if (format != GL_RGBA)
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
<< "Invalid internal format/format combination");
return false; return false;
} }
break; break;
...@@ -1305,14 +1307,12 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1305,14 +1307,12 @@ bool ValidateES2TexImageParameters(Context *context,
} }
if (type != GL_FLOAT) if (type != GL_FLOAT)
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
<< "Invalid internal format/type combination");
return false; return false;
} }
if (format != GL_RGB) if (format != GL_RGB)
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
<< "Invalid internal format/format combination");
return false; return false;
} }
break; break;
...@@ -1558,7 +1558,7 @@ bool ValidateDiscardFramebufferEXT(Context *context, ...@@ -1558,7 +1558,7 @@ bool ValidateDiscardFramebufferEXT(Context *context,
{ {
if (!context->getExtensions().discardFramebuffer) if (!context->getExtensions().discardFramebuffer)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1571,7 +1571,7 @@ bool ValidateDiscardFramebufferEXT(Context *context, ...@@ -1571,7 +1571,7 @@ bool ValidateDiscardFramebufferEXT(Context *context,
(context->getGLState().getTargetFramebuffer(GL_FRAMEBUFFER)->id() == 0); (context->getGLState().getTargetFramebuffer(GL_FRAMEBUFFER)->id() == 0);
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid framebuffer target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget);
return false; return false;
} }
...@@ -1583,7 +1583,7 @@ bool ValidateBindVertexArrayOES(Context *context, GLuint array) ...@@ -1583,7 +1583,7 @@ bool ValidateBindVertexArrayOES(Context *context, GLuint array)
{ {
if (!context->getExtensions().vertexArrayObject) if (!context->getExtensions().vertexArrayObject)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1594,7 +1594,7 @@ bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n) ...@@ -1594,7 +1594,7 @@ bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n)
{ {
if (!context->getExtensions().vertexArrayObject) if (!context->getExtensions().vertexArrayObject)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1605,7 +1605,7 @@ bool ValidateGenVertexArraysOES(Context *context, GLsizei n) ...@@ -1605,7 +1605,7 @@ bool ValidateGenVertexArraysOES(Context *context, GLsizei n)
{ {
if (!context->getExtensions().vertexArrayObject) if (!context->getExtensions().vertexArrayObject)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1616,7 +1616,7 @@ bool ValidateIsVertexArrayOES(Context *context) ...@@ -1616,7 +1616,7 @@ bool ValidateIsVertexArrayOES(Context *context)
{ {
if (!context->getExtensions().vertexArrayObject) if (!context->getExtensions().vertexArrayObject)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1631,7 +1631,7 @@ bool ValidateProgramBinaryOES(Context *context, ...@@ -1631,7 +1631,7 @@ bool ValidateProgramBinaryOES(Context *context,
{ {
if (!context->getExtensions().getProgramBinary) if (!context->getExtensions().getProgramBinary)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1647,7 +1647,7 @@ bool ValidateGetProgramBinaryOES(Context *context, ...@@ -1647,7 +1647,7 @@ bool ValidateGetProgramBinaryOES(Context *context,
{ {
if (!context->getExtensions().getProgramBinary) if (!context->getExtensions().getProgramBinary)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1719,7 +1719,7 @@ bool ValidateDebugMessageControlKHR(Context *context, ...@@ -1719,7 +1719,7 @@ bool ValidateDebugMessageControlKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1773,7 +1773,7 @@ bool ValidateDebugMessageInsertKHR(Context *context, ...@@ -1773,7 +1773,7 @@ bool ValidateDebugMessageInsertKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1819,7 +1819,7 @@ bool ValidateDebugMessageCallbackKHR(Context *context, ...@@ -1819,7 +1819,7 @@ bool ValidateDebugMessageCallbackKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1838,14 +1838,13 @@ bool ValidateGetDebugMessageLogKHR(Context *context, ...@@ -1838,14 +1838,13 @@ bool ValidateGetDebugMessageLogKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
if (bufSize < 0 && messageLog != nullptr) if (bufSize < 0 && messageLog != nullptr)
{ {
context->handleError(InvalidValue() ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
<< "bufSize must be positive if messageLog is not null.");
return false; return false;
} }
...@@ -1860,7 +1859,7 @@ bool ValidatePushDebugGroupKHR(Context *context, ...@@ -1860,7 +1859,7 @@ bool ValidatePushDebugGroupKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -1894,7 +1893,7 @@ bool ValidatePopDebugGroupKHR(Context *context) ...@@ -1894,7 +1893,7 @@ bool ValidatePopDebugGroupKHR(Context *context)
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2031,7 +2030,7 @@ bool ValidateObjectLabelKHR(Context *context, ...@@ -2031,7 +2030,7 @@ bool ValidateObjectLabelKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2057,13 +2056,13 @@ bool ValidateGetObjectLabelKHR(Context *context, ...@@ -2057,13 +2056,13 @@ bool ValidateGetObjectLabelKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
if (bufSize < 0) if (bufSize < 0)
{ {
context->handleError(InvalidValue() << "bufSize cannot be negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -2093,7 +2092,7 @@ bool ValidateObjectPtrLabelKHR(Context *context, ...@@ -2093,7 +2092,7 @@ bool ValidateObjectPtrLabelKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2118,13 +2117,13 @@ bool ValidateGetObjectPtrLabelKHR(Context *context, ...@@ -2118,13 +2117,13 @@ bool ValidateGetObjectPtrLabelKHR(Context *context,
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
if (bufSize < 0) if (bufSize < 0)
{ {
context->handleError(InvalidValue() << "bufSize cannot be negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -2140,7 +2139,7 @@ bool ValidateGetPointervKHR(Context *context, GLenum pname, void **params) ...@@ -2140,7 +2139,7 @@ bool ValidateGetPointervKHR(Context *context, GLenum pname, void **params)
{ {
if (!context->getExtensions().debug) if (!context->getExtensions().debug)
{ {
context->handleError(InvalidOperation() << "Extension not enabled"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false; return false;
} }
...@@ -2152,7 +2151,7 @@ bool ValidateGetPointervKHR(Context *context, GLenum pname, void **params) ...@@ -2152,7 +2151,7 @@ bool ValidateGetPointervKHR(Context *context, GLenum pname, void **params)
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid pname."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -2294,7 +2293,7 @@ bool ValidateClear(ValidationContext *context, GLbitfield mask) ...@@ -2294,7 +2293,7 @@ bool ValidateClear(ValidationContext *context, GLbitfield mask)
if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidClearMask);
return false; return false;
} }
...@@ -2585,7 +2584,7 @@ bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access) ...@@ -2585,7 +2584,7 @@ bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access)
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid buffer target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
...@@ -2657,7 +2656,7 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture) ...@@ -2657,7 +2656,7 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture)
Texture *textureObject = context->getTexture(texture); Texture *textureObject = context->getTexture(texture);
if (textureObject && textureObject->getTarget() != target && texture != 0) if (textureObject && textureObject->getTarget() != target && texture != 0)
{ {
context->handleError(InvalidOperation() << "Invalid texture"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), TypeMustMatchOriginalType);
return false; return false;
} }
...@@ -2700,7 +2699,7 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture) ...@@ -2700,7 +2699,7 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture)
} }
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
...@@ -2746,14 +2745,13 @@ bool ValidateBindUniformLocationCHROMIUM(Context *context, ...@@ -2746,14 +2745,13 @@ bool ValidateBindUniformLocationCHROMIUM(Context *context,
if (context->getExtensions().webglCompatibility && if (context->getExtensions().webglCompatibility &&
!IsValidESSLString(name, strlen(name), false)) !IsValidESSLString(name, strlen(name), false))
{ {
context->handleError(InvalidValue() << "Uniform name contains invalid characters"); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidNameCharacters);
return false; return false;
} }
if (strncmp(name, "gl_", 3) == 0) if (strncmp(name, "gl_", 3) == 0)
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidValue(), NameBeginsWithGL);
<< "Name cannot start with the reserved \"gl_\" prefix.");
return false; return false;
} }
...@@ -2840,7 +2838,7 @@ bool ValidateGenPaths(Context *context, GLsizei range) ...@@ -2840,7 +2838,7 @@ bool ValidateGenPaths(Context *context, GLsizei range)
if (!angle::IsValueInRangeForNumericType<std::uint32_t>(range)) if (!angle::IsValueInRangeForNumericType<std::uint32_t>(range))
{ {
context->handleError(InvalidOperation() << "Range overflow."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
...@@ -2868,7 +2866,7 @@ bool ValidateDeletePaths(Context *context, GLuint path, GLsizei range) ...@@ -2868,7 +2866,7 @@ bool ValidateDeletePaths(Context *context, GLuint path, GLsizei range)
if (!angle::IsValueInRangeForNumericType<std::uint32_t>(range) || !checkedRange.IsValid()) if (!angle::IsValueInRangeForNumericType<std::uint32_t>(range) || !checkedRange.IsValid())
{ {
context->handleError(InvalidOperation() << "Range overflow."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
return true; return true;
...@@ -2953,7 +2951,7 @@ bool ValidatePathCommands(Context *context, ...@@ -2953,7 +2951,7 @@ bool ValidatePathCommands(Context *context,
checkedSize += (coordTypeSize * numCoords); checkedSize += (coordTypeSize * numCoords);
if (!checkedSize.IsValid()) if (!checkedSize.IsValid())
{ {
context->handleError(InvalidOperation() << "Coord size overflow."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), IntegerOverflow);
return false; return false;
} }
...@@ -3115,7 +3113,7 @@ bool ValidatePathStencilFunc(Context *context, GLenum func, GLint ref, GLuint ma ...@@ -3115,7 +3113,7 @@ bool ValidatePathStencilFunc(Context *context, GLenum func, GLint ref, GLuint ma
case GL_NOTEQUAL: case GL_NOTEQUAL:
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid stencil function."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
...@@ -3430,7 +3428,7 @@ bool ValidateBindFragmentInputLocation(Context *context, ...@@ -3430,7 +3428,7 @@ bool ValidateBindFragmentInputLocation(Context *context,
const auto *programObject = context->getProgram(program); const auto *programObject = context->getProgram(program);
if (!programObject) if (!programObject)
{ {
context->handleError(InvalidOperation() << "No such program."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotBound);
return false; return false;
} }
...@@ -3465,13 +3463,13 @@ bool ValidateProgramPathFragmentInputGen(Context *context, ...@@ -3465,13 +3463,13 @@ bool ValidateProgramPathFragmentInputGen(Context *context,
const auto *programObject = context->getProgram(program); const auto *programObject = context->getProgram(program);
if (!programObject || programObject->isFlaggedForDeletion()) if (!programObject || programObject->isFlaggedForDeletion())
{ {
context->handleError(InvalidOperation() << "No such program."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramDoesNotExist);
return false; return false;
} }
if (!programObject->isLinked()) if (!programObject->isLinked())
{ {
context->handleError(InvalidOperation() << "Program is not linked."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked);
return false; return false;
} }
...@@ -3595,8 +3593,7 @@ bool ValidateCopyTextureCHROMIUM(Context *context, ...@@ -3595,8 +3593,7 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
GLsizei sourceHeight = static_cast<GLsizei>(source->getHeight(sourceTarget, sourceLevel)); GLsizei sourceHeight = static_cast<GLsizei>(source->getHeight(sourceTarget, sourceLevel));
if (sourceWidth == 0 || sourceHeight == 0) if (sourceWidth == 0 || sourceHeight == 0)
{ {
context->handleError(InvalidValue() ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidInternalFormat);
<< "The source level of the source texture must be defined.");
return false; return false;
} }
...@@ -3624,14 +3621,13 @@ bool ValidateCopyTextureCHROMIUM(Context *context, ...@@ -3624,14 +3621,13 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
if (!IsValidCopyTextureDestinationLevel(context, destTarget, destLevel, sourceWidth, if (!IsValidCopyTextureDestinationLevel(context, destTarget, destLevel, sourceWidth,
sourceHeight)) sourceHeight))
{ {
context->handleError(InvalidValue() << "Destination texture level is not valid."); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel);
return false; return false;
} }
if (!IsValidCopyTextureDestinationFormatType(context, internalFormat, destType)) if (!IsValidCopyTextureDestinationFormatType(context, internalFormat, destType))
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
<< "Destination internal format and type combination is not valid.");
return false; return false;
} }
...@@ -3692,7 +3688,7 @@ bool ValidateCopySubTextureCHROMIUM(Context *context, ...@@ -3692,7 +3688,7 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
if (!IsValidCopyTextureSourceLevel(context, source->getTarget(), sourceLevel)) if (!IsValidCopyTextureSourceLevel(context, source->getTarget(), sourceLevel))
{ {
context->handleError(InvalidValue() << "Source texture level is not valid."); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel);
return false; return false;
} }
...@@ -3712,21 +3708,21 @@ bool ValidateCopySubTextureCHROMIUM(Context *context, ...@@ -3712,21 +3708,21 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
if (width < 0 || height < 0) if (width < 0 || height < 0)
{ {
context->handleError(InvalidValue() << "width and height cannot be negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
return false; return false;
} }
if (static_cast<size_t>(x + width) > source->getWidth(sourceTarget, sourceLevel) || if (static_cast<size_t>(x + width) > source->getWidth(sourceTarget, sourceLevel) ||
static_cast<size_t>(y + height) > source->getHeight(sourceTarget, sourceLevel)) static_cast<size_t>(y + height) > source->getHeight(sourceTarget, sourceLevel))
{ {
context->handleError(InvalidValue() << "Source texture not large enough to copy from."); ANGLE_VALIDATION_ERR(context, InvalidValue(), SourceTextureTooSmall);
return false; return false;
} }
const Format &sourceFormat = source->getFormat(sourceTarget, sourceLevel); const Format &sourceFormat = source->getFormat(sourceTarget, sourceLevel);
if (!IsValidCopySubTextureSourceInternalFormat(sourceFormat.info->internalFormat)) if (!IsValidCopySubTextureSourceInternalFormat(sourceFormat.info->internalFormat))
{ {
context->handleError(InvalidOperation() << "Source texture internal format is invalid."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidInternalFormat);
return false; return false;
} }
...@@ -3768,7 +3764,7 @@ bool ValidateCopySubTextureCHROMIUM(Context *context, ...@@ -3768,7 +3764,7 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
if (xoffset < 0 || yoffset < 0) if (xoffset < 0 || yoffset < 0)
{ {
context->handleError(InvalidValue() << "xoffset and yoffset cannot be negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
return false; return false;
} }
...@@ -3859,7 +3855,7 @@ bool ValidateCreateShader(Context *context, GLenum type) ...@@ -3859,7 +3855,7 @@ bool ValidateCreateShader(Context *context, GLenum type)
break; break;
default: default:
context->handleError(InvalidEnum() << "Unknown shader type."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidShaderType);
return false; return false;
} }
...@@ -3874,7 +3870,7 @@ bool ValidateBufferData(ValidationContext *context, ...@@ -3874,7 +3870,7 @@ bool ValidateBufferData(ValidationContext *context,
{ {
if (size < 0) if (size < 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
return false; return false;
} }
...@@ -3893,19 +3889,19 @@ bool ValidateBufferData(ValidationContext *context, ...@@ -3893,19 +3889,19 @@ bool ValidateBufferData(ValidationContext *context,
case GL_DYNAMIC_COPY: case GL_DYNAMIC_COPY:
if (context->getClientMajorVersion() < 3) if (context->getClientMajorVersion() < 3)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferUsage);
return false; return false;
} }
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferUsage);
return false; return false;
} }
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
...@@ -3913,7 +3909,7 @@ bool ValidateBufferData(ValidationContext *context, ...@@ -3913,7 +3909,7 @@ bool ValidateBufferData(ValidationContext *context,
if (!buffer) if (!buffer)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), BufferNotBound);
return false; return false;
} }
...@@ -3926,15 +3922,21 @@ bool ValidateBufferSubData(ValidationContext *context, ...@@ -3926,15 +3922,21 @@ bool ValidateBufferSubData(ValidationContext *context,
GLsizeiptr size, GLsizeiptr size,
const void *data) const void *data)
{ {
if (size < 0 || offset < 0) if (size < 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
return false;
}
if (offset < 0)
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
return false; return false;
} }
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
...@@ -3942,7 +3944,7 @@ bool ValidateBufferSubData(ValidationContext *context, ...@@ -3942,7 +3944,7 @@ bool ValidateBufferSubData(ValidationContext *context,
if (!buffer) if (!buffer)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), BufferNotBound);
return false; return false;
} }
...@@ -3963,7 +3965,7 @@ bool ValidateBufferSubData(ValidationContext *context, ...@@ -3963,7 +3965,7 @@ bool ValidateBufferSubData(ValidationContext *context,
if (size + offset > buffer->getSize()) if (size + offset > buffer->getSize())
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InsufficientBufferSize);
return false; return false;
} }
...@@ -4021,7 +4023,7 @@ bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint sha ...@@ -4021,7 +4023,7 @@ bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint sha
{ {
if (programObject->getAttachedVertexShader()) if (programObject->getAttachedVertexShader())
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ShaderAttachmentHasShader);
return false; return false;
} }
break; break;
...@@ -4030,7 +4032,7 @@ bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint sha ...@@ -4030,7 +4032,7 @@ bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint sha
{ {
if (programObject->getAttachedFragmentShader()) if (programObject->getAttachedFragmentShader())
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ShaderAttachmentHasShader);
return false; return false;
} }
break; break;
...@@ -4039,7 +4041,7 @@ bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint sha ...@@ -4039,7 +4041,7 @@ bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint sha
{ {
if (programObject->getAttachedComputeShader()) if (programObject->getAttachedComputeShader())
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ShaderAttachmentHasShader);
return false; return false;
} }
break; break;
...@@ -4059,13 +4061,13 @@ bool ValidateBindAttribLocation(ValidationContext *context, ...@@ -4059,13 +4061,13 @@ bool ValidateBindAttribLocation(ValidationContext *context,
{ {
if (index >= MAX_VERTEX_ATTRIBS) if (index >= MAX_VERTEX_ATTRIBS)
{ {
context->handleError(InvalidValue() << "Index exceeds MAX_VERTEX_ATTRIBS"); ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMax);
return false; return false;
} }
if (strncmp(name, "gl_", 3) == 0) if (strncmp(name, "gl_", 3) == 0)
{ {
context->handleError(InvalidOperation() << "Cannot Bind built-in attributes"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), NameBeginsWithGL);
return false; return false;
} }
...@@ -4074,7 +4076,7 @@ bool ValidateBindAttribLocation(ValidationContext *context, ...@@ -4074,7 +4076,7 @@ bool ValidateBindAttribLocation(ValidationContext *context,
if (context->getExtensions().webglCompatibility && if (context->getExtensions().webglCompatibility &&
!IsValidESSLString(name, strlen(name), false)) !IsValidESSLString(name, strlen(name), false))
{ {
context->handleError(InvalidValue() << "Attribute name contains invalid characters"); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidNameCharacters);
return false; return false;
} }
...@@ -4085,14 +4087,14 @@ bool ValidateBindBuffer(ValidationContext *context, GLenum target, GLuint buffer ...@@ -4085,14 +4087,14 @@ bool ValidateBindBuffer(ValidationContext *context, GLenum target, GLuint buffer
{ {
if (!ValidBufferTarget(context, target)) if (!ValidBufferTarget(context, target))
{ {
context->handleError(InvalidEnum() << "Invalid Buffer target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
} }
if (!context->getGLState().isBindGeneratesResourceEnabled() && if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isBufferGenerated(buffer)) !context->isBufferGenerated(buffer))
{ {
context->handleError(InvalidOperation() << "Buffer was not generated"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ObjectNotGenerated);
return false; return false;
} }
...@@ -4103,14 +4105,14 @@ bool ValidateBindFramebuffer(ValidationContext *context, GLenum target, GLuint f ...@@ -4103,14 +4105,14 @@ bool ValidateBindFramebuffer(ValidationContext *context, GLenum target, GLuint f
{ {
if (!ValidFramebufferTarget(target)) if (!ValidFramebufferTarget(target))
{ {
context->handleError(InvalidEnum() << "Invalid Framebuffer target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget);
return false; return false;
} }
if (!context->getGLState().isBindGeneratesResourceEnabled() && if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isFramebufferGenerated(framebuffer)) !context->isFramebufferGenerated(framebuffer))
{ {
context->handleError(InvalidOperation() << "Framebuffer was not generated"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ObjectNotGenerated);
return false; return false;
} }
...@@ -4121,14 +4123,14 @@ bool ValidateBindRenderbuffer(ValidationContext *context, GLenum target, GLuint ...@@ -4121,14 +4123,14 @@ bool ValidateBindRenderbuffer(ValidationContext *context, GLenum target, GLuint
{ {
if (target != GL_RENDERBUFFER) if (target != GL_RENDERBUFFER)
{ {
context->handleError(InvalidEnum() << "Invalid Renderbuffer target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidRenderbufferTarget);
return false; return false;
} }
if (!context->getGLState().isBindGeneratesResourceEnabled() && if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isRenderbufferGenerated(renderbuffer)) !context->isRenderbufferGenerated(renderbuffer))
{ {
context->handleError(InvalidOperation() << "Renderbuffer was not generated"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ObjectNotGenerated);
return false; return false;
} }
...@@ -4164,7 +4166,7 @@ bool ValidateBlendEquation(ValidationContext *context, GLenum mode) ...@@ -4164,7 +4166,7 @@ bool ValidateBlendEquation(ValidationContext *context, GLenum mode)
{ {
if (!ValidBlendEquationMode(mode)) if (!ValidBlendEquationMode(mode))
{ {
context->handleError(InvalidEnum() << "Invalid blend equation"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBlendEquation);
return false; return false;
} }
...@@ -4175,13 +4177,13 @@ bool ValidateBlendEquationSeparate(ValidationContext *context, GLenum modeRGB, G ...@@ -4175,13 +4177,13 @@ bool ValidateBlendEquationSeparate(ValidationContext *context, GLenum modeRGB, G
{ {
if (!ValidBlendEquationMode(modeRGB)) if (!ValidBlendEquationMode(modeRGB))
{ {
context->handleError(InvalidEnum() << "Invalid RGB blend equation"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBlendEquation);
return false; return false;
} }
if (!ValidBlendEquationMode(modeAlpha)) if (!ValidBlendEquationMode(modeAlpha))
{ {
context->handleError(InvalidEnum() << "Invalid alpha blend equation"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBlendEquation);
return false; return false;
} }
...@@ -4255,25 +4257,25 @@ bool ValidateBlendFuncSeparate(ValidationContext *context, ...@@ -4255,25 +4257,25 @@ bool ValidateBlendFuncSeparate(ValidationContext *context,
{ {
if (!ValidSrcBlendFunc(srcRGB)) if (!ValidSrcBlendFunc(srcRGB))
{ {
context->handleError(InvalidEnum() << "Invalid blend function"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBlendFunction);
return false; return false;
} }
if (!ValidDstBlendFunc(dstRGB, context->getClientMajorVersion())) if (!ValidDstBlendFunc(dstRGB, context->getClientMajorVersion()))
{ {
context->handleError(InvalidEnum() << "Invalid blend function"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBlendFunction);
return false; return false;
} }
if (!ValidSrcBlendFunc(srcAlpha)) if (!ValidSrcBlendFunc(srcAlpha))
{ {
context->handleError(InvalidEnum() << "Invalid blend function"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBlendFunction);
return false; return false;
} }
if (!ValidDstBlendFunc(dstAlpha, context->getClientMajorVersion())) if (!ValidDstBlendFunc(dstAlpha, context->getClientMajorVersion()))
{ {
context->handleError(InvalidEnum() << "Invalid blend function"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBlendFunction);
return false; return false;
} }
...@@ -4293,9 +4295,7 @@ bool ValidateBlendFuncSeparate(ValidationContext *context, ...@@ -4293,9 +4295,7 @@ bool ValidateBlendFuncSeparate(ValidationContext *context,
const char *msg; const char *msg;
if (context->getExtensions().webglCompatibility) if (context->getExtensions().webglCompatibility)
{ {
msg = msg = kErrorInvalidConstantColor;
"Invalid simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and "
"GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR.";
} }
else else
{ {
...@@ -4366,7 +4366,7 @@ bool ValidateVertexAttribPointer(ValidationContext *context, ...@@ -4366,7 +4366,7 @@ bool ValidateVertexAttribPointer(ValidationContext *context,
if (stride < 0) if (stride < 0)
{ {
context->handleError(InvalidValue() << "stride cannot be negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeStride);
return false; return false;
} }
...@@ -4425,7 +4425,7 @@ bool ValidateDepthRangef(ValidationContext *context, GLfloat zNear, GLfloat zFar ...@@ -4425,7 +4425,7 @@ bool ValidateDepthRangef(ValidationContext *context, GLfloat zNear, GLfloat zFar
{ {
if (context->getExtensions().webglCompatibility && zNear > zFar) if (context->getExtensions().webglCompatibility && zNear > zFar)
{ {
context->handleError(InvalidOperation() << "Depth near > far."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidDepthRange);
return false; return false;
} }
...@@ -4487,7 +4487,7 @@ bool ValidateCheckFramebufferStatus(ValidationContext *context, GLenum target) ...@@ -4487,7 +4487,7 @@ bool ValidateCheckFramebufferStatus(ValidationContext *context, GLenum target)
{ {
if (!ValidFramebufferTarget(target)) if (!ValidFramebufferTarget(target))
{ {
context->handleError(InvalidEnum() << "Invalid Framebuffer target"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget);
return false; return false;
} }
...@@ -4542,7 +4542,7 @@ bool ValidateCullFace(ValidationContext *context, GLenum mode) ...@@ -4542,7 +4542,7 @@ bool ValidateCullFace(ValidationContext *context, GLenum mode)
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid cull face parameter"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidCullMode);
return false; return false;
} }
...@@ -4560,12 +4560,12 @@ bool ValidateDeleteProgram(ValidationContext *context, GLuint program) ...@@ -4560,12 +4560,12 @@ bool ValidateDeleteProgram(ValidationContext *context, GLuint program)
{ {
if (context->getShader(program)) if (context->getShader(program))
{ {
context->handleError(InvalidOperation() << "Shader handle passed to DeleteProgram"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExpectedProgramName);
return false; return false;
} }
else else
{ {
context->handleError(InvalidValue() << "Invalid program handle"); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProgramName);
return false; return false;
} }
} }
...@@ -4584,12 +4584,12 @@ bool ValidateDeleteShader(ValidationContext *context, GLuint shader) ...@@ -4584,12 +4584,12 @@ bool ValidateDeleteShader(ValidationContext *context, GLuint shader)
{ {
if (context->getProgram(shader)) if (context->getProgram(shader))
{ {
context->handleError(InvalidOperation() << "Program handle passed to DeleteShader"); ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidShaderName);
return false; return false;
} }
else else
{ {
context->handleError(InvalidValue() << "Invalid shader handle"); ANGLE_VALIDATION_ERR(context, InvalidValue(), ExpectedShaderName);
return false; return false;
} }
} }
...@@ -4612,7 +4612,7 @@ bool ValidateDepthFunc(ValidationContext *context, GLenum func) ...@@ -4612,7 +4612,7 @@ bool ValidateDepthFunc(ValidationContext *context, GLenum func)
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid depth function"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -4664,7 +4664,7 @@ bool ValidateDetachShader(ValidationContext *context, GLuint program, GLuint sha ...@@ -4664,7 +4664,7 @@ bool ValidateDetachShader(ValidationContext *context, GLuint program, GLuint sha
if (attachedShader != shaderObject) if (attachedShader != shaderObject)
{ {
context->handleError(InvalidOperation() << "Cannot detach non-attached shader."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ShaderToDetachMustBeAttached);
return false; return false;
} }
...@@ -4675,7 +4675,7 @@ bool ValidateDisableVertexAttribArray(ValidationContext *context, GLuint index) ...@@ -4675,7 +4675,7 @@ bool ValidateDisableVertexAttribArray(ValidationContext *context, GLuint index)
{ {
if (index >= MAX_VERTEX_ATTRIBS) if (index >= MAX_VERTEX_ATTRIBS)
{ {
context->handleError(InvalidValue() << "Attrib array index out of range"); ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMax);
return false; return false;
} }
...@@ -4686,7 +4686,7 @@ bool ValidateEnableVertexAttribArray(ValidationContext *context, GLuint index) ...@@ -4686,7 +4686,7 @@ bool ValidateEnableVertexAttribArray(ValidationContext *context, GLuint index)
{ {
if (index >= MAX_VERTEX_ATTRIBS) if (index >= MAX_VERTEX_ATTRIBS)
{ {
context->handleError(InvalidValue() << "Attrib array index out of range"); ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMax);
return false; return false;
} }
...@@ -4711,7 +4711,7 @@ bool ValidateFrontFace(ValidationContext *context, GLenum mode) ...@@ -4711,7 +4711,7 @@ bool ValidateFrontFace(ValidationContext *context, GLenum mode)
case GL_CCW: case GL_CCW:
break; break;
default: default:
context->handleError(InvalidEnum() << "Invalid mode for FrontFace"); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -4729,7 +4729,7 @@ bool ValidateGetActiveAttrib(ValidationContext *context, ...@@ -4729,7 +4729,7 @@ bool ValidateGetActiveAttrib(ValidationContext *context,
{ {
if (bufsize < 0) if (bufsize < 0)
{ {
context->handleError(InvalidValue() << "bufsize must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -4760,7 +4760,7 @@ bool ValidateGetActiveUniform(ValidationContext *context, ...@@ -4760,7 +4760,7 @@ bool ValidateGetActiveUniform(ValidationContext *context,
{ {
if (bufsize < 0) if (bufsize < 0)
{ {
context->handleError(InvalidValue() << "bufsize must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -4809,7 +4809,7 @@ bool ValidateGetAttribLocation(ValidationContext *context, GLuint program, const ...@@ -4809,7 +4809,7 @@ bool ValidateGetAttribLocation(ValidationContext *context, GLuint program, const
if (context->getExtensions().webglCompatibility && if (context->getExtensions().webglCompatibility &&
!IsValidESSLString(name, strlen(name), false)) !IsValidESSLString(name, strlen(name), false))
{ {
context->handleError(InvalidValue() << "Attribute name contains invalid characters"); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidNameCharacters);
return false; return false;
} }
...@@ -4817,12 +4817,13 @@ bool ValidateGetAttribLocation(ValidationContext *context, GLuint program, const ...@@ -4817,12 +4817,13 @@ bool ValidateGetAttribLocation(ValidationContext *context, GLuint program, const
if (!programObject) if (!programObject)
{ {
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotBound);
return false; return false;
} }
if (!programObject->isLinked()) if (!programObject->isLinked())
{ {
context->handleError(InvalidOperation() << "program not linked."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked);
return false; return false;
} }
...@@ -4863,7 +4864,7 @@ bool ValidateGetProgramInfoLog(ValidationContext *context, ...@@ -4863,7 +4864,7 @@ bool ValidateGetProgramInfoLog(ValidationContext *context,
{ {
if (bufsize < 0) if (bufsize < 0)
{ {
context->handleError(InvalidValue() << "bufsize must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -4884,7 +4885,7 @@ bool ValidateGetShaderInfoLog(ValidationContext *context, ...@@ -4884,7 +4885,7 @@ bool ValidateGetShaderInfoLog(ValidationContext *context,
{ {
if (bufsize < 0) if (bufsize < 0)
{ {
context->handleError(InvalidValue() << "bufsize must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -4913,7 +4914,7 @@ bool ValidateGetShaderPrecisionFormat(ValidationContext *context, ...@@ -4913,7 +4914,7 @@ bool ValidateGetShaderPrecisionFormat(ValidationContext *context,
<< "compute shader precision not yet implemented."); << "compute shader precision not yet implemented.");
return false; return false;
default: default:
context->handleError(InvalidEnum() << "invalid shader type."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidShaderType);
return false; return false;
} }
...@@ -4928,7 +4929,7 @@ bool ValidateGetShaderPrecisionFormat(ValidationContext *context, ...@@ -4928,7 +4929,7 @@ bool ValidateGetShaderPrecisionFormat(ValidationContext *context,
break; break;
default: default:
context->handleError(InvalidEnum() << "invalid precision type."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPrecision);
return false; return false;
} }
...@@ -4943,7 +4944,7 @@ bool ValidateGetShaderSource(ValidationContext *context, ...@@ -4943,7 +4944,7 @@ bool ValidateGetShaderSource(ValidationContext *context,
{ {
if (bufsize < 0) if (bufsize < 0)
{ {
context->handleError(InvalidValue() << "bufsize must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
return false; return false;
} }
...@@ -4968,7 +4969,7 @@ bool ValidateGetUniformLocation(ValidationContext *context, GLuint program, cons ...@@ -4968,7 +4969,7 @@ bool ValidateGetUniformLocation(ValidationContext *context, GLuint program, cons
if (context->getExtensions().webglCompatibility && if (context->getExtensions().webglCompatibility &&
!IsValidESSLString(name, strlen(name), false)) !IsValidESSLString(name, strlen(name), false))
{ {
context->handleError(InvalidValue() << "Uniform name contains invalid characters"); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidNameCharacters);
return false; return false;
} }
...@@ -4981,7 +4982,7 @@ bool ValidateGetUniformLocation(ValidationContext *context, GLuint program, cons ...@@ -4981,7 +4982,7 @@ bool ValidateGetUniformLocation(ValidationContext *context, GLuint program, cons
if (!programObject->isLinked()) if (!programObject->isLinked())
{ {
context->handleError(InvalidOperation() << "program is not linked."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked);
return false; return false;
} }
...@@ -4998,7 +4999,7 @@ bool ValidateHint(ValidationContext *context, GLenum target, GLenum mode) ...@@ -4998,7 +4999,7 @@ bool ValidateHint(ValidationContext *context, GLenum target, GLenum mode)
break; break;
default: default:
context->handleError(InvalidEnum() << "invalid hint mode."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5018,7 +5019,7 @@ bool ValidateHint(ValidationContext *context, GLenum target, GLenum mode) ...@@ -5018,7 +5019,7 @@ bool ValidateHint(ValidationContext *context, GLenum target, GLenum mode)
break; break;
default: default:
context->handleError(InvalidEnum() << "invalid hint target."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5099,7 +5100,7 @@ bool ValidatePixelStorei(ValidationContext *context, GLenum pname, GLint param) ...@@ -5099,7 +5100,7 @@ bool ValidatePixelStorei(ValidationContext *context, GLenum pname, GLint param)
case GL_UNPACK_ALIGNMENT: case GL_UNPACK_ALIGNMENT:
if (param != 1 && param != 2 && param != 4 && param != 8) if (param != 1 && param != 2 && param != 4 && param != 8)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidUnpackAlignment);
return false; return false;
} }
break; break;
...@@ -5107,7 +5108,7 @@ bool ValidatePixelStorei(ValidationContext *context, GLenum pname, GLint param) ...@@ -5107,7 +5108,7 @@ bool ValidatePixelStorei(ValidationContext *context, GLenum pname, GLint param)
case GL_PACK_ALIGNMENT: case GL_PACK_ALIGNMENT:
if (param != 1 && param != 2 && param != 4 && param != 8) if (param != 1 && param != 2 && param != 4 && param != 8)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidUnpackAlignment);
return false; return false;
} }
break; break;
...@@ -5124,7 +5125,7 @@ bool ValidatePixelStorei(ValidationContext *context, GLenum pname, GLint param) ...@@ -5124,7 +5125,7 @@ bool ValidatePixelStorei(ValidationContext *context, GLenum pname, GLint param)
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5150,7 +5151,7 @@ bool ValidateScissor(ValidationContext *context, GLint x, GLint y, GLsizei width ...@@ -5150,7 +5151,7 @@ bool ValidateScissor(ValidationContext *context, GLint x, GLint y, GLsizei width
{ {
if (width < 0 || height < 0) if (width < 0 || height < 0)
{ {
context->handleError(InvalidValue() << "Scissor width and height must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
return false; return false;
} }
...@@ -5183,7 +5184,7 @@ bool ValidateShaderSource(ValidationContext *context, ...@@ -5183,7 +5184,7 @@ bool ValidateShaderSource(ValidationContext *context,
{ {
if (count < 0) if (count < 0)
{ {
context->handleError(InvalidValue() << "Count must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeCount);
return false; return false;
} }
...@@ -5198,7 +5199,7 @@ bool ValidateShaderSource(ValidationContext *context, ...@@ -5198,7 +5199,7 @@ bool ValidateShaderSource(ValidationContext *context,
// Backslash as line-continuation is allowed in WebGL 2.0. // Backslash as line-continuation is allowed in WebGL 2.0.
if (!IsValidESSLString(string[i], len, context->getClientVersion() >= ES_3_0)) if (!IsValidESSLString(string[i], len, context->getClientVersion() >= ES_3_0))
{ {
context->handleError(InvalidValue() << "Shader source contains invalid characters"); ANGLE_VALIDATION_ERR(context, InvalidValue(), ShaderSourceInvalidCharacters);
return false; return false;
} }
} }
...@@ -5217,7 +5218,7 @@ bool ValidateStencilFunc(ValidationContext *context, GLenum func, GLint ref, GLu ...@@ -5217,7 +5218,7 @@ bool ValidateStencilFunc(ValidationContext *context, GLenum func, GLint ref, GLu
{ {
if (!IsValidStencilFunc(func)) if (!IsValidStencilFunc(func))
{ {
context->handleError(InvalidEnum() << "Invalid stencil function."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
...@@ -5232,13 +5233,13 @@ bool ValidateStencilFuncSeparate(ValidationContext *context, ...@@ -5232,13 +5233,13 @@ bool ValidateStencilFuncSeparate(ValidationContext *context,
{ {
if (!IsValidStencilFace(face)) if (!IsValidStencilFace(face))
{ {
context->handleError(InvalidEnum() << "Invalid stencil face."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
if (!IsValidStencilFunc(func)) if (!IsValidStencilFunc(func))
{ {
context->handleError(InvalidEnum() << "Invalid stencil function."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
...@@ -5254,7 +5255,7 @@ bool ValidateStencilMaskSeparate(ValidationContext *context, GLenum face, GLuint ...@@ -5254,7 +5255,7 @@ bool ValidateStencilMaskSeparate(ValidationContext *context, GLenum face, GLuint
{ {
if (!IsValidStencilFace(face)) if (!IsValidStencilFace(face))
{ {
context->handleError(InvalidEnum() << "Invalid stencil face."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
...@@ -5265,19 +5266,19 @@ bool ValidateStencilOp(ValidationContext *context, GLenum fail, GLenum zfail, GL ...@@ -5265,19 +5266,19 @@ bool ValidateStencilOp(ValidationContext *context, GLenum fail, GLenum zfail, GL
{ {
if (!IsValidStencilOp(fail)) if (!IsValidStencilOp(fail))
{ {
context->handleError(InvalidEnum() << "Invalid stencil fail op."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
if (!IsValidStencilOp(zfail)) if (!IsValidStencilOp(zfail))
{ {
context->handleError(InvalidEnum() << "Invalid stencil z fail op."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
if (!IsValidStencilOp(zpass)) if (!IsValidStencilOp(zpass))
{ {
context->handleError(InvalidEnum() << "Invalid stencil z pass op."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
...@@ -5292,7 +5293,7 @@ bool ValidateStencilOpSeparate(ValidationContext *context, ...@@ -5292,7 +5293,7 @@ bool ValidateStencilOpSeparate(ValidationContext *context,
{ {
if (!IsValidStencilFace(face)) if (!IsValidStencilFace(face))
{ {
context->handleError(InvalidEnum() << "Invalid stencil face."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidStencil);
return false; return false;
} }
...@@ -5427,7 +5428,7 @@ bool ValidateVertexAttribIndex(ValidationContext *context, GLuint index) ...@@ -5427,7 +5428,7 @@ bool ValidateVertexAttribIndex(ValidationContext *context, GLuint index)
{ {
if (index >= MAX_VERTEX_ATTRIBS) if (index >= MAX_VERTEX_ATTRIBS)
{ {
context->handleError(InvalidValue() << "Vertex attrib index out of range."); ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMax);
return false; return false;
} }
...@@ -5487,7 +5488,7 @@ bool ValidateViewport(ValidationContext *context, GLint x, GLint y, GLsizei widt ...@@ -5487,7 +5488,7 @@ bool ValidateViewport(ValidationContext *context, GLint x, GLint y, GLsizei widt
{ {
if (width < 0 || height < 0) if (width < 0 || height < 0)
{ {
context->handleError(InvalidValue() << "Viewport width and height must be non-negative."); ANGLE_VALIDATION_ERR(context, InvalidValue(), ViewportNegativeSize);
return false; return false;
} }
...@@ -5588,7 +5589,7 @@ bool ValidateDisable(Context *context, GLenum cap) ...@@ -5588,7 +5589,7 @@ bool ValidateDisable(Context *context, GLenum cap)
{ {
if (!ValidCap(context, cap, false)) if (!ValidCap(context, cap, false))
{ {
context->handleError(InvalidEnum() << "Invalid cap."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5599,7 +5600,7 @@ bool ValidateEnable(Context *context, GLenum cap) ...@@ -5599,7 +5600,7 @@ bool ValidateEnable(Context *context, GLenum cap)
{ {
if (!ValidCap(context, cap, false)) if (!ValidCap(context, cap, false))
{ {
context->handleError(InvalidEnum() << "Invalid cap."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5624,10 +5625,15 @@ bool ValidateFramebufferRenderbuffer(Context *context, ...@@ -5624,10 +5625,15 @@ bool ValidateFramebufferRenderbuffer(Context *context,
GLenum renderbuffertarget, GLenum renderbuffertarget,
GLuint renderbuffer) GLuint renderbuffer)
{ {
if (!ValidFramebufferTarget(target) || if (!ValidFramebufferTarget(target))
(renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget);
return false;
}
if (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)
{
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidRenderbufferTarget);
return false; return false;
} }
...@@ -5647,7 +5653,7 @@ bool ValidateFramebufferTexture2D(Context *context, ...@@ -5647,7 +5653,7 @@ bool ValidateFramebufferTexture2D(Context *context,
if (context->getClientMajorVersion() < 3 && !context->getExtensions().fboRenderMipmap && if (context->getClientMajorVersion() < 3 && !context->getExtensions().fboRenderMipmap &&
level != 0) level != 0)
{ {
context->handleError(InvalidValue()); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidFramebufferTextureLevel);
return false; return false;
} }
...@@ -5674,8 +5680,7 @@ bool ValidateFramebufferTexture2D(Context *context, ...@@ -5674,8 +5680,7 @@ bool ValidateFramebufferTexture2D(Context *context,
} }
if (tex->getTarget() != GL_TEXTURE_2D) if (tex->getTarget() != GL_TEXTURE_2D)
{ {
context->handleError(InvalidOperation() ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidTextureTarget);
<< "Textarget must match the texture target type.");
return false; return false;
} }
} }
...@@ -5727,7 +5732,7 @@ bool ValidateFramebufferTexture2D(Context *context, ...@@ -5727,7 +5732,7 @@ bool ValidateFramebufferTexture2D(Context *context,
break; break;
default: default:
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
...@@ -5766,7 +5771,7 @@ bool ValidateGenerateMipmap(Context *context, GLenum target) ...@@ -5766,7 +5771,7 @@ bool ValidateGenerateMipmap(Context *context, GLenum target)
{ {
if (!ValidTextureTarget(context, target)) if (!ValidTextureTarget(context, target))
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
return false; return false;
} }
...@@ -5774,7 +5779,7 @@ bool ValidateGenerateMipmap(Context *context, GLenum target) ...@@ -5774,7 +5779,7 @@ bool ValidateGenerateMipmap(Context *context, GLenum target)
if (texture == nullptr) if (texture == nullptr)
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), TextureNotBound);
return false; return false;
} }
...@@ -5792,8 +5797,14 @@ bool ValidateGenerateMipmap(Context *context, GLenum target) ...@@ -5792,8 +5797,14 @@ bool ValidateGenerateMipmap(Context *context, GLenum target)
const auto &format = texture->getFormat(baseTarget, effectiveBaseLevel); const auto &format = texture->getFormat(baseTarget, effectiveBaseLevel);
const TextureCaps &formatCaps = context->getTextureCaps().get(format.info->sizedInternalFormat); const TextureCaps &formatCaps = context->getTextureCaps().get(format.info->sizedInternalFormat);
if (format.info->compressed)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), GenerateMipmapNotAllowed);
return false;
}
// GenerateMipmap should not generate an INVALID_OPERATION for textures created with // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
// unsized formats or that are color renderable and filterable. Since we do not track if // unsized formats or that are color renderable and filterable. Since we do not track if
// the texture was created with sized or unsized format (only sized formats are stored), // the texture was created with sized or unsized format (only sized formats are stored),
// it is not possible to make sure the the LUMA formats can generate mipmaps (they should // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
// be able to) because they aren't color renderable. Simply do a special case for LUMA // be able to) because they aren't color renderable. Simply do a special case for LUMA
...@@ -5801,7 +5812,7 @@ bool ValidateGenerateMipmap(Context *context, GLenum target) ...@@ -5801,7 +5812,7 @@ bool ValidateGenerateMipmap(Context *context, GLenum target)
// that is not color renderable. New unsized formats are unlikely to be added, since ES2 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
// was the last version to use add them. // was the last version to use add them.
if (format.info->depthBits > 0 || format.info->stencilBits > 0 || !formatCaps.filterable || if (format.info->depthBits > 0 || format.info->stencilBits > 0 || !formatCaps.filterable ||
(!formatCaps.renderable && !format.info->isLUMA()) || format.info->compressed) (!formatCaps.renderable && !format.info->isLUMA()))
{ {
context->handleError(InvalidOperation()); context->handleError(InvalidOperation());
return false; return false;
...@@ -5823,14 +5834,14 @@ bool ValidateGenerateMipmap(Context *context, GLenum target) ...@@ -5823,14 +5834,14 @@ bool ValidateGenerateMipmap(Context *context, GLenum target)
!isPow2(static_cast<int>(texture->getHeight(baseTarget, 0))))) !isPow2(static_cast<int>(texture->getHeight(baseTarget, 0)))))
{ {
ASSERT(target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP); ASSERT(target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP);
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), TextureNotPow2);
return false; return false;
} }
// Cube completeness check // Cube completeness check
if (target == GL_TEXTURE_CUBE_MAP && !texture->getTextureState().isCubeComplete()) if (target == GL_TEXTURE_CUBE_MAP && !texture->getTextureState().isCubeComplete())
{ {
context->handleError(InvalidOperation()); ANGLE_VALIDATION_ERR(context, InvalidOperation(), CubemapIncomplete);
return false; return false;
} }
...@@ -5897,7 +5908,7 @@ bool ValidateIsEnabled(Context *context, GLenum cap) ...@@ -5897,7 +5908,7 @@ bool ValidateIsEnabled(Context *context, GLenum cap)
{ {
if (!ValidCap(context, cap, true)) if (!ValidCap(context, cap, true))
{ {
context->handleError(InvalidEnum() << "Invalid cap."); ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
return false; return false;
} }
...@@ -5967,20 +5978,18 @@ bool ValidateUseProgram(Context *context, GLuint program) ...@@ -5967,20 +5978,18 @@ bool ValidateUseProgram(Context *context, GLuint program)
// ES 3.1.0 section 7.3 page 72 // ES 3.1.0 section 7.3 page 72
if (context->getShader(program)) if (context->getShader(program))
{ {
context->handleError( ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExpectedProgramName);
InvalidOperation()
<< "Attempted to use a single shader instead of a shader program.");
return false; return false;
} }
else else
{ {
context->handleError(InvalidValue() << "Program invalid."); ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProgramName);
return false; return false;
} }
} }
if (!programObject->isLinked()) if (!programObject->isLinked())
{ {
context->handleError(InvalidOperation() << "Program not linked."); ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked);
return false; return false;
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "libANGLE/ContextState.h" #include "libANGLE/ContextState.h"
#include "libANGLE/ErrorStrings.h"
#include "libANGLE/VaryingPacking.h" #include "libANGLE/VaryingPacking.h"
#include "libANGLE/renderer/FramebufferImpl_mock.h" #include "libANGLE/renderer/FramebufferImpl_mock.h"
#include "libANGLE/renderer/ProgramImpl_mock.h" #include "libANGLE/renderer/ProgramImpl_mock.h"
...@@ -106,7 +107,8 @@ TEST(ValidationESTest, DISABLED_DrawElementsWithMaxIndexGivesError) ...@@ -106,7 +107,8 @@ TEST(ValidationESTest, DISABLED_DrawElementsWithMaxIndexGivesError)
textureCaps, extensions, limitations, false); textureCaps, extensions, limitations, false);
// Set the expectation for the validation error here. // Set the expectation for the validation error here.
Error expectedError(gl::InvalidOperation() << g_ExceedsMaxElementErrorMessage);
Error expectedError(gl::InvalidOperation() << kErrorExceedsMaxElement);
EXPECT_CALL(testContext, handleError(expectedError)).Times(1); EXPECT_CALL(testContext, handleError(expectedError)).Times(1);
// Call once with maximum index, and once with an excessive index. // Call once with maximum index, and once with an excessive index.
......
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