Commit c3e3731c by Jamie Madill Committed by Commit Bot

Give every validation error a constant.

Makes the code more consistent and organized. Also reduces binary size by about 4k. Also refactors validation for GetBufferPointerv. Bug: angleproject:2957 Change-Id: Ib076ce936193e9840eef2499bf815489cdb48479 Reviewed-on: https://chromium-review.googlesource.com/c/1350489 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent ec06305b
......@@ -18,6 +18,10 @@ namespace err
// clang-format off
MSG k3DDepthStencil = "Format cannot be GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL if target is GL_TEXTURE_3D";
MSG kANGLECopyTexture3DUnavailable = "GL_ANGLE_copy_texture_3d extension not available.";
MSG kAtomicCounterResourceName = "Active atomic counter resources are not assigned name strings.";
MSG kAttributeZeroRequiresDivisorLimitation = "The current context doesn't support setting a non-zero divisor on the attribute with index zero. Please reorder the attributes in your vertex shader so that attribute zero can have a zero divisor.";
MSG kBaseLevelNegative = "Base level must be at least 0.";
MSG kBaseLevelNonZero = "Base level must be 0.";
MSG kBaseLevelOutOfRange = "Texture base level out of range";
MSG kBlitDepthOrStencilFormatMismatch = "Depth/stencil buffer format combination not allowed for blit.";
MSG kBlitDimensionsOutOfRange = "BlitFramebuffer dimensions out of 32-bit integer range.";
......@@ -48,18 +52,30 @@ MSG kBlitTypeMismatchFixedOrFloat = "If the read buffer contains fixed-point or
MSG kBlitTypeMismatchFixedPoint = "If the read buffer contains fixed-point values = the draw buffer must as well.";
MSG kBlitTypeMismatchSignedInteger = "If the read buffer contains signed integer values the draw buffer must as well.";
MSG kBlitTypeMismatchUnsignedInteger = "If the read buffer contains unsigned integer values the draw buffer must as well.";
MSG kBufferAlreadyMapped = "Buffer is already mapped.";
MSG kBufferBoundForTransformFeedback = "Buffer is bound for transform feedback.";
MSG kBufferMapped = "An active buffer is mapped";
MSG kBufferNotBound = "A buffer must be bound.";
MSG kBufferNotMappable = "Attempted to map buffer object zero.";
MSG kBufferNotMapped = "Buffer is not mapped.";
MSG kBufferOffsetOverflow = "Buffer offset overflow.";
MSG kBufferPointerNotAvailable = "Can not get pointer for reserved buffer name zero.";
MSG kCannotPopDefaultDebugGroup = "Cannot pop the default debug group.";
MSG kClientDataInVertexArray = "Client data cannot be used with a non-default vertex array object.";
MSG kColorNumberGreaterThanMaxDrawBuffers = "Color number for primary color greater than or equal to MAX_DRAW_BUFFERS";
MSG kColorNumberGreaterThanMaxDualSourceDrawBuffers = "Color number for secondary color greater than or equal to MAX_DUAL_SOURCE_DRAW_BUFFERS";
MSG kCompressedDataSizeTooSmall = "dataSize is too small";
MSG kCompressedMismatch = "Compressed data is valid if-and-only-if the texture is compressed.";
MSG kCompressedTextureDimensionsMustMatchData = "Compressed texture dimensions must exactly match the dimensions of the data passed in.";
MSG kCompressedTexturesNotAttachable = "Compressed textures cannot be attached to a framebuffer.";
MSG kConstantColorAlphaLimitation = "Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not supported by this implementation.";
MSG kCopyAlias = "The read and write copy regions alias memory.";
MSG kCubemapFacesEqualDimensions = "Each cubemap face must have equal width and height.";
MSG kCubemapIncomplete = "Texture is not cubemap complete. All cubemaps faces must be defined and be the same size.";
MSG kDataTypeNotAligned = "Data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.";
MSG kDefaultFramebuffer = "Default framebuffer is bound.";
MSG kDefaultFramebufferInvalidAttachment = "Invalid attachment when the default framebuffer is bound.";
MSG kDefaultFramebufferInvalidDrawBuffer = "Only NONE or BACK are valid draw buffers for the default framebuffer";
MSG kDefaultFramebufferTarget = "It is invalid to change default FBO's attachments";
MSG kDefaultVertexArray = "Default vertex array object is bound.";
MSG kDestinationImmutable = "Destination texture cannot be immutable.";
......@@ -70,28 +86,59 @@ MSG kDispatchIndirectBufferNotBound = "Dispatch indirect buffer must be bound.";
MSG kDrawBufferTypeMismatch = "Fragment shader output type does not match the bound framebuffer attachment type.";
MSG kDrawFramebufferIncomplete = "Draw framebuffer is incomplete";
MSG kDrawIndirectBufferNotBound = "Draw indirect buffer must be bound.";
MSG kES31Required = "OpenGL ES 3.1 Required";
MSG kES3Required = "OpenGL ES 3.0 Required.";
MSG kEGLImageCannotCreate2DMultisampled = "Cannot create a 2D texture from a multisampled EGL image.";
MSG kEGLImageRenderbufferFormatNotSupported = "EGL image internal format is not supported as a renderbuffer.";
MSG kEGLImageTextureFormatNotSupported = "EGL image internal format is not supported as a texture.";
MSG kElementArrayBufferBoundForTransformFeedback = "It is undefined behavior to use an element array buffer that is bound for transform feedback.";
MSG kElementArrayNoBufferOrPointer = "No element array buffer and no pointer.";
MSG kEnumNotSupported = "Enum is not currently supported.";
MSG kEnumRequiresGLES30 = "Enum requires GLES 3.0";
MSG kEnumRequiresGLES31 = "Enum requires GLES 3.1";
MSG kES31Required = "OpenGL ES 3.1 Required";
MSG kES3Required = "OpenGL ES 3.0 Required.";
MSG kExceedsComputeWorkGroupCountX = "num_groups_x cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[0]";
MSG kExceedsComputeWorkGroupCountY = "num_groups_y cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[1]";
MSG kExceedsComputeWorkGroupCountZ = "num_groups_z cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[2]";
MSG kExceedsElementRange = "Element value exceeds element range.";
MSG kExceedsFramebufferHeight = "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_HEIGHT.";
MSG kExceedsFramebufferSamples = "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_SAMPLES.";
MSG kExceedsFramebufferWidth = "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_WIDTH.";
MSG kExceedsMaxColorAttachments = "Index is greater than the maximum supported color attachments";
MSG kExceedsMaxDebugGroupStackDepth = "Cannot push more than GL_MAX_DEBUG_GROUP_STACK_DEPTH debug groups.";
MSG kExceedsMaxDebugMessageLength = "Message length is larger than GL_MAX_DEBUG_MESSAGE_LENGTH.";
MSG kExceedsMaxDrawBuffers = "Draw buffer greater than MAX_DRAW_BUFFERS.";
MSG kExceedsMaxElement = "Element value exceeds maximum element index.";
MSG kExceedsMaxImageUnits = "Index must be within [0, MAX_IMAGE_UNITS).";
MSG kExceedsMaxLabelLength = "Label length is larger than GL_MAX_LABEL_LENGTH.";
MSG kExceedsMaxShaderStorageBufferBindings = "Index must be within [0, MAX_SHADER_STORAGE_BUFFER_BINDINGS).";
MSG kExceedsMaxVertexAttribBindings = "Index must be within [0, MAX_VERTEX_ATTRIB_BINDINGS).";
MSG kExceedsMaxVertexAttribStride = "Stride must be within [0, MAX_VERTEX_ATTRIB_STRIDE).";
MSG kExceedsNumExtensions = "Index must be within [0, NUM_EXTENSIONS).";
MSG kExceedsNumRequestableExtensions = "Index must be within [0, NUM_REQUESTABLE_EXTENSIONS_ANGLE).";
MSG kExpectedProgramName = "Expected a program name = but found a shader name.";
MSG kExpectedShaderName = "Expected a shader name = but found a program name.";
MSG kExtensionNotEnabled = "Extension is not enabled.";
MSG kExtensionNotRequestable = "Extension is not requestable.";
MSG kExternalTextureNotSupported = "External texture extension not enabled";
MSG kFeedbackLoop = "Feedback loop formed between Framebuffer and active Texture.";
MSG kFixedNotInWebGL = "GL_FIXED is not supported in WebGL.";
MSG kFormatNotRenderable = "Internal format is not renderable.";
MSG kFragDataBindingIndexOutOfRange = "Fragment output color index must be zero or one.";
MSG kFragmentInputTypeNotFloatingPoint = "Fragment input type is not a floating point scalar or vector.";
MSG kFramebufferIncomplete = "Framebuffer is incomplete.";
MSG kFramebufferIncompleteAttachment = "Attachment type must be compatible with attachment object.";
MSG kFramebufferTextureInvalidLayer = "Layer invalid for framebuffer texture attachment.";
MSG kFramebufferTextureInvalidMipLevel = "Mip level invalid for framebuffer texture attachment.";
MSG kFramebufferTextureLayerIncorrectTextureType = "Texture is not a three-dimensional or two-dimensionsal array texture.";
MSG kGLES1Only = "GLES1-only function.";
MSG kGenerateMipmapNotAllowed = "Texture format does not support mipmap generation.";
MSG kGenerateMipmapZeroSize = "Cannot generate mipmaps for a zero-size texture in a WebGL context.";
MSG kGeometryShaderExtensionNotEnabled = "GL_EXT_geometry_shader extension not enabled.";
MSG kGLES1Only = "GLES1-only function.";
MSG kImageSizeMustBeZero = "imageSize must be 0 if no texture data is provided.";
MSG kImageSizeTooSmall = "imageSize is too small.";
MSG kImmutableTextureBound = "The value of TEXTURE_IMMUTABLE_FORMAT for the texture currently bound to target on the active texture unit is true.";
MSG kIncompatibleDrawModeAgainstGeometryShader = "Primitive mode is incompatible with the input primitive type of the geometry shader.";
MSG kIndexExceedsActiveUniformBlockCount = "Index exceeds active uniform block count.";
MSG kIndexExceedsMaxActiveUniform = "Index must be less than program active uniform count.";
MSG kIndexExceedsMaxActiveUniformBlock = "Index must be less than program active uniform block count.";
MSG kIndexExceedsMaxAtomicCounterBufferBindings = "Index must be less than MAX_ATOMIC_COUNTER_BUFFER_BINDINGS.";
......@@ -101,58 +148,84 @@ MSG kIndexExceedsMaxUniformBufferBindings = "Index must be less than MAX_UNIFORM
MSG kIndexExceedsMaxVertexAttribute = "Index must be less than MAX_VERTEX_ATTRIBS.";
MSG kIndexExceedsMaxWorkgroupDimensions = "Index must be less than the number of workgroup dimensions (3).";
MSG kIndexExceedsSamples = "Index must be less than the value of SAMPLES.";
MSG kIndexExceedsTransformFeedbackBufferBindings = "Index is greater than or equal to the number of TRANSFORM_FEEDBACK_BUFFER indexed binding points.";
MSG kInsufficientBufferSize = "Insufficient buffer size.";
MSG kInsufficientParams = "More parameters are required than were provided.";
MSG kInsufficientVertexBufferSize = "Vertex buffer is not big enough for the draw call";
MSG kIntegerOverflow = "Integer overflow.";
MSG kInternalFormatRequiresTexture2DArray = "internalformat is an ETC2/EAC format and target is not GL_TEXTURE_2D_ARRAY.";
MSG kInvalidAccessBits = "Invalid access bits.";
MSG kInvalidAccessBitsFlush = "The explicit flushing bit may only be set if the buffer is mapped for writing.";
MSG kInvalidAccessBitsRead = "Invalid access bits when mapping buffer for reading";
MSG kInvalidAccessBitsReadWrite = "Need to map buffer for either reading or writing.";
MSG kInvalidAttachment = "Invalid Attachment Type.";
MSG kInvalidBindBufferSize = "Invalid buffer binding size.";
MSG kInvalidBindUniformLocation = "Location must be less than (MAX_VERTEX_UNIFORM_VECTORS + MAX_FRAGMENT_UNIFORM_VECTORS) * 4";
MSG kInvalidBlendEquation = "Invalid blend equation.";
MSG kInvalidBlendFunction = "Invalid blend function.";
MSG kInvalidBooleanValue = "Invalid boolean value. Must be GL_FALSE or GL_TRUE.";
MSG kInvalidBorder = "Border must be 0.";
MSG kInvalidBufferName = "name is not a valid buffer.";
MSG kInvalidBufferTypes = "Invalid buffer target.";
MSG kInvalidBufferUsage = "Invalid buffer usage enum.";
MSG kInvalidClearMask = "Invalid mask bits.";
MSG kInvalidClientState = "Invalid client vertex array type.";
MSG kInvalidClipPlane = "Invalid clip plane.";
MSG kInvalidCombinedImageUnit = "Specified unit must be in [GL_TEXTURE0 = GL_TEXTURE0 + GL_MAX_COMBINED_IMAGE_UNITS)";
MSG kInvalidComponents = "Invalid components.";
MSG kInvalidCompressedFormat = "Not a valid compressed texture format.";
MSG kInvalidCompressedImageSize = "Invalid compressed image size.";
MSG kInvalidConstantColor = "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.";
MSG kInvalidCopyCombination = "Invalid copy texture format combination.";
MSG kInvalidCoverageComponents = "components is not one of GL_RGB, GL_RGBA, GL_ALPHA or GL_NONE.";
MSG kInvalidCoverMode = "Invalid cover mode.";
MSG kInvalidCullMode = "Cull mode not recognized.";
MSG kInvalidDebugSeverity = "Invalid debug severity.";
MSG kInvalidDebugSource = "Invalid debug source.";
MSG kInvalidDebugSourceType = "If count is greater than zero, source and type cannot be GL_DONT_CARE.";
MSG kInvalidDebugType = "Invalid debug type.";
MSG kInvalidDefaultReadBuffer = "Read buffer must be GL_NONE or GL_BACK when reading from the default framebuffer.";
MSG kInvalidDepthRange = "Near value cannot be greater than far.";
MSG kInvalidDepthStencilDrawBuffer = "Draw buffer must be zero when using depth or stencil.";
MSG kInvalidDestinationTexture = "Destination texture is not a valid texture object.";
MSG kInvalidDestinationTextureType = "Invalid destination texture type.";
MSG kInvalidDrawBuffer = "Invalid draw buffer.";
MSG kInvalidDrawBufferCountForDefault = "The default framebuffer must have exactly one draw buffer.";
MSG kInvalidDrawBufferValue = "Ith value does not match COLOR_ATTACHMENTi or NONE.";
MSG kInvalidDrawMode = "Invalid draw mode.";
MSG kInvalidDrawModeTransformFeedback = "Draw mode must match current transform feedback object's draw mode.";
MSG kInvalidEGLImage = "EGL image is not valid.";
MSG kInvalidElementRange = "Invalid element range.";
MSG kInvalidFence = "Invalid fence object.";
MSG kInvalidFenceCondition = "Invalid value for condition.";
MSG kInvalidFenceState = "Fence must be set.";
MSG kInvalidFillMode = "Invalid fill mode.";
MSG kInvalidFilterTexture = "Texture only supports NEAREST and LINEAR filtering.";
MSG kInvalidFlags = "Invalid value for flags.";
MSG kInvalidFlushOutOfRange = "Flushed range does not fit into buffer mapping dimensions.";
MSG kInvalidFlushTarget = "Attempted to flush a buffer not mapped for explicit flushing.";
MSG kInvalidFlushZero = "Attempted to flush buffer object zero.";
MSG kInvalidFogDensity = "Invalid fog density (must be nonnegative).";
MSG kInvalidFogMode = "Invalid fog mode.";
MSG kInvalidFogParameter = "Invalid fog parameter.";
MSG kInvalidFormat = "Invalid format.";
MSG kInvalidFormatCombination = "Invalid combination of format = type and internalFormat.";
MSG kInvalidFragmentInputBinding = "No such binding.";
MSG kInvalidFramebufferAttachmentParameter = "Invalid parameter name for framebuffer attachment.";
MSG kInvalidFramebufferLayer = "Framebuffer layer cannot be less than 0 or greater than GL_MAX_FRAMEBUFFER_LAYERS_EXT.";
MSG kInvalidFramebufferName = "name is not a valid framebuffer.";
MSG kInvalidFramebufferTarget = "Invalid framebuffer target.";
MSG kInvalidFramebufferTextureLevel = "Mipmap level must be 0 when attaching a texture.";
MSG kInvalidImageUnit = "Image unit cannot be greater than or equal to the value of MAX_IMAGE_UNITS.";
MSG kInvalidImageAccess = "access is not one of the supported tokens.";
MSG kInvalidImageFormat = "format is not one of supported image unit formats.";
MSG kInvalidIndentifier = "Invalid identifier.";
MSG kInvalidIndirectOffset = "indirect must be a multiple of the size of uint in basic machine units.";
MSG kInvalidInternalFormat = "Invalid internal format.";
MSG kInvalidLight = "Invalid light.";
MSG kInvalidLightModelParameter = "Invalid light model parameter.";
MSG kInvalidLightParameter = "Invalid light parameter.";
MSG kInvalidLogicOp = "Invalid logical operation.";
MSG kInvalidMapPointerQuery = "GL_BUFFER_MAP_POINTER can only be queried with GetBufferPointerv.";
MSG kInvalidMaterialFace = "Invalid material face.";
MSG kInvalidMaterialParameter = "Invalid material parameter.";
MSG kInvalidMatrixMode = "Invalid matrix mode.";
......@@ -163,32 +236,66 @@ MSG kInvalidMultisampledFramebufferOperation = "Invalid operation on multisample
MSG kInvalidMultitextureUnit = "Specified unit must be in [GL_TEXTURE0 = GL_TEXTURE0 + GL_MAX_TEXTURE_UNITS)";
MSG kInvalidName = "Invalid name.";
MSG kInvalidNameCharacters = "Name contains invalid characters.";
MSG kInvalidPathCoefficientsArray = "No coefficients array given.";
MSG kInvalidPathCommand = "Invalid command.";
MSG kInvalidPathCommandsArray = "No commands array given.";
MSG kInvalidPathComponents = "Unexpected number of components";
MSG kInvalidPathCoordinateType = "Invalid coordinate type.";
MSG kInvalidPathEndCaps = "Invalid end caps.";
MSG kInvalidPathGenMode = "Invalid gen mode.";
MSG kInvalidPathJoinStyle = "Invalid join style.";
MSG kInvalidPathMatrix = "Invalid matrix.";
MSG kInvalidPathMiterLimit = "Invalid miter limit.";
MSG kInvalidPathNameArray = "No path name array.";
MSG kInvalidPathNameType = "Invalid path name type.";
MSG kInvalidPathNumCommands = "Invalid number of commands.";
MSG kInvalidPathNumCoords = "Invalid number of coordinates.";
MSG kInvalidPathNumCoordsArray = "No coordinate array given.";
MSG kInvalidPathNumPaths = "Invalid (negative) numPaths.";
MSG kInvalidPathParameter = "Invalid path parameter.";
MSG kInvalidPathStrokeWidth = "Invalid stroke width.";
MSG kInvalidPathValueArray = "No value array.";
MSG kInvalidPname = "Invalid pname.";
MSG kInvalidPointerQuery = "Invalid pointer query.";
MSG kInvalidPointParameter = "Invalid point parameter.";
MSG kInvalidPointParameterValue = "Invalid point parameter value (must be non-negative).";
MSG kInvalidPointSizeValue = "Invalid point size (must be positive).";
MSG kInvalidPointerQuery = "Invalid pointer query.";
MSG kInvalidPrecision = "Invalid or unsupported precision type.";
MSG kInvalidPrimitiveMode = "Invalid primitive mode.";
MSG kInvalidProgramBinaryFormat = "Program binary format is not valid.";
MSG kInvalidProgramInterface = "Invalid program interface.";
MSG kInvalidProgramName = "Program object expected.";
MSG kInvalidProgramResourceIndex = "Invalid program resource index.";
MSG kInvalidProgramResourceProperty = "Invalid program resource property.";
MSG kInvalidProjectionMatrix = "Invalid projection matrix. Left/right = top/bottom = near/far intervals cannot be zero = and near/far cannot be less than zero.";
MSG kInvalidPropCount = "Invalid propCount.";
MSG kInvalidPropertyForProgramInterface = "Not an allowed program resource property for this program interface";
MSG kInvalidQueryId = "Invalid query Id.";
MSG kInvalidQueryName = "name is not a valid query.";
MSG kInvalidQueryTarget = "Invalid query target.";
MSG kInvalidQueryType = "Invalid query type.";
MSG kInvalidRange = "Invalid range.";
MSG kInvalidReadBuffer = "Invalid read buffer";
MSG kInvalidRenderbufferInternalFormat = "Invalid renderbuffer internalformat.";
MSG kInvalidRenderbufferName = "name is not a valid renderbuffer.";
MSG kInvalidRenderbufferTarget = "Invalid renderbuffer target.";
MSG kInvalidRenderbufferTextureParameter = "Invalid parameter name for renderbuffer attachment.";
MSG kInvalidRenderbufferWidthHeight = "Renderbuffer width and height cannot be negative and cannot exceed maximum texture size.";
MSG kInvalidSampleMaskNumber = "MaskNumber cannot be greater than or equal to the value of MAX_SAMPLE_MASK_WORDS.";
MSG kInvalidSampler = "Sampler is not valid";
MSG kInvalidSamplerName = "name is not a valid sampler.";
MSG kInvalidShaderBinaryFormat = "Invalid shader binary format.";
MSG kInvalidShaderName = "Shader object expected.";
MSG kInvalidShaderType = "Invalid shader type.";
MSG kInvalidShadingModel = "Invalid shading model.";
MSG kInvalidSourceTexture = "Source texture is not a valid texture object.";
MSG kInvalidSourceTextureInternalFormat = "Source texture internal format is invalid.";
MSG kInvalidSourceTextureLevel = "Invalid source texture level.";
MSG kInvalidSourceTextureSize = "Invalid source texture height or width.";
MSG kInvalidSourceTextureType = "Source texture must be a valid texture type.";
MSG kInvalidStencil = "Invalid stencil.";
MSG kInvalidStencilBitMask = "Invalid stencil bit mask.";
MSG kInvalidSyncPointer = "Not a valid sync pointer.";
MSG kInvalidTarget = "Invalid target.";
MSG kInvalidTextureCombine = "Invalid texture combine mode.";
MSG kInvalidTextureCombineOp = "Invalid texture combine operand.";
......@@ -198,57 +305,74 @@ MSG kInvalidTextureEnvParameter = "Invalid texture environment parameter.";
MSG kInvalidTextureEnvScale = "Invalid texture environment scale.";
MSG kInvalidTextureEnvTarget = "Invalid texture environment target.";
MSG kInvalidTextureFilterParam = "Texture filter not recognized.";
MSG kInvalidTextureLevel = "Texture level does not exist.";
MSG kInvalidTextureName = "Not a valid texture object name.";
MSG kInvalidTextureRange = "Cannot be less than 0 or greater than maximum number of textures.";
MSG kInvalidTextureTarget = "Invalid or unsupported texture target.";
MSG kInvalidTextureType = "Texture has incompatible target.";
MSG kInvalidTextureWrap = "Texture wrap mode not recognized.";
MSG kInvalidTimeout = "Invalid value for timeout.";
MSG kInvalidTransformFeedbackAttribsCount = "Count exeeds MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.";
MSG kInvalidTransformation = "Invalid transformation.";
MSG kInvalidTransformFeedbackAttribsCount = "Count exceeds MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.";
MSG kInvalidTransformFeedbackName = "name is not a valid transform feedback.";
MSG kInvalidType = "Invalid type.";
MSG kInvalidTypePureInt = "Invalid type = should be integer";
MSG kInvalidUniformCount = "Only array uniforms may have count > 1.";
MSG kInvalidUniformLocation = "Invalid uniform location";
MSG kInvalidUnpackAlignment = "Unpack alignment must be 1 = 2 = 4 = or 8.";
MSG kInvalidVaryingLocation = "Location exceeds max varying.";
MSG kInvalidVertexArray = "Vertex array does not exist.";
MSG kInvalidVertexArrayName = "name is not a valid vertex array.";
MSG kInvalidVertexAttribSize2101010 = "Type is INT_2_10_10_10_REV or UNSIGNED_INT_2_10_10_10_REV and size is not 4.";
MSG kInvalidVertexAttrSize = "Vertex attribute size must be 1 = 2 = 3 = or 4.";
MSG kInvalidVertexPointerSize = "Size for built-in vertex attribute is outside allowed range.";
MSG kInvalidVertexPointerStride = "Invalid stride for built-in vertex attribute.";
MSG kInvalidVertexPointerType = "Invalid type for built-in vertex attribute.";
MSG kInvalidWidth = "Invalid width.";
MSG kInvalidWrapModeTexture = "Invalid wrap mode for texture type.";
MSG kLengthZero = "Length must not be zero.";
MSG kLevelNotZero = "Texture level must be zero.";
MSG kLightParameterOutOfRange = "Light parameter out of range.";
MSG kMapOutOfRange = "Mapped range does not fit into buffer dimensions.";
MSG kMaterialParameterOutOfRange = "Material parameter out of range.";
MSG kMatrixStackOverflow = "Current matrix stack is full.";
MSG kMatrixStackUnderflow = "Current matrix stack has only a single matrix.";
MSG kMaxActiveVariablesInterface = "MAX_NUM_ACTIVE_VARIABLES requires a buffer or block interface.";
MSG kMismatchedFormat = "Format must match internal format.";
MSG kMismatchedTargetAndFormat = "Invalid texture target and format combination.";
MSG kMismatchedTypeAndFormat = "Invalid format and type combination.";
MSG kMismatchedVariableProgram = "Variable is not part of the current program.";
MSG kMissingName = "No name given.";
MSG kMissingReadAttachment = "Missing read attachment.";
MSG kMissingTexture = "No Texture is bound to the specified target.";
MSG kMissingTextureName = "texture is not the name of an existing texture object.";
MSG kMultisampleArrayExtensionRequired = "GL_ANGLE_texture_multisample_array not enabled.";
MSG kMultisampleTextureExtensionOrES31Required = "GL_ANGLE_texture_multisample or GLES 3.1 required.";
MSG kMultiviewActive = "The number of views in the active draw framebuffer is greater than 1.";
MSG kMultiviewMismatch = "The number of views in the active program and draw framebuffer does not match.";
MSG kMultiviewNotAvailable = "ANGLE_multiview is not available.";
MSG kMultiviewReadFramebuffer = "The active read framebuffer object has multiview attachments.";
MSG kMultiviewTimerQuery = "There is an active query for target GL_TIME_ELAPSED_EXT when the number of views in the active draw framebuffer is greater than 1.";
MSG kMultiviewTransformFeedback = "There is an active transform feedback object when the number of views in the active draw framebuffer is greater than 1.";
MSG kMultiviewViewsTooLarge = "numViews cannot be greater than GL_MAX_VIEWS_ANGLE.";
MSG kMultiviewViewsTooSmall = "numViews cannot be less than 1.";
MSG kMustHaveElementArrayBinding = "Must have element array buffer bound.";
MSG kNVFenceNotSupported = "GL_NV_fence is not supported";
MSG kNameBeginsWithGL = "Attributes that begin with 'gl_' are not allowed.";
MSG kNegativeAttachments = "Negative number of attachments.";
MSG kNegativeBaseViewIndex = "Negative baseViewIndex.";
MSG kNegativeBufferSize = "Negative buffer size.";
MSG kNegativeBufSize = "Invalid bufSize.";
MSG kNegativeCount = "Negative count.";
MSG kNegativeHeightWidthDepth = "Cannot have negative height = width = or depth.";
MSG kNegativeLayer = "Negative layer.";
MSG kNegativeLength = "Negative length.";
MSG kNegativeLevel = "Level is negative.";
MSG kNegativeLocation = "Location cannot be less than 0.";
MSG kNegativeMaxCount = "Negative maxcount.";
MSG kNegativeOffset = "Negative offset.";
MSG kNegativeParam = "param is negative.";
MSG kNegativePrimcount = "Primcount must be greater than or equal to zero.";
MSG kNegativeSize = "Cannot have negative height or width.";
MSG kNegativeSize = "Negative size.";
MSG kNegativeStart = "Cannot have negative start.";
MSG kNegativeStride = "Cannot have negative stride.";
MSG kNegativeXYZ = "x = y = or z cannot be negative.";
......@@ -256,14 +380,24 @@ MSG kNoActiveComputeShaderStage = "No active compute shader stage in this progra
MSG kNoActiveGeometryShaderStage = "No active geometry shader stage in this program.";
MSG kNoActiveGraphicsShaderStage = "It is a undefined behaviour to render without vertex shader stage or fragment shader stage.";
MSG kNoActiveProgramWithComputeShader = "No active program for the compute shader stage.";
MSG kNoDefinedClearConversion = "No defined conversion between clear value and attachment format.";
MSG kNonPositiveDrawTextureDimension = "Both width and height argument of drawn texture must be positive.";
MSG kNoPathOrNoPathData = "No such path or path has no data.";
MSG kNoProgramBinaryFormats = "No program binary formats supported.";
MSG kNoReadFramebuffer = "No active read framebuffer.";
MSG kNoSampleAlphaToCoveragesLimitation = "Current renderer doesn't support alpha-to-coverage.";
MSG kNoSuchPath = "No such path object.";
MSG kNoTransformArray = "No transform array given.";
MSG kNoTransformFeedbackOutputVariables = "The active program has specified no output variables to record.";
MSG kNoZeroDivisor = "At least one enabled attribute must have a divisor of zero.";
MSG kNonPositiveDrawTextureDimension = "Both width and height argument of drawn texture must be positive.";
MSG kNVFenceNotSupported = "GL_NV_fence is not supported";
MSG kObjectNotGenerated = "Object cannot be used because it has not been generated.";
MSG kOffsetAlignment = "offset must be a multiple of 4.";
MSG kOffsetAndSizeAlignment = "Offset and size must be multiple of 4.";
MSG kOffsetMustBeMultipleOfType = "Offset must be a multiple of the passed in datatype.";
MSG kOffsetMustBeMultipleOfUint = "Offset must be a multiple of the size = in basic machine units = of uint";
MSG kOffsetOverflow = "Offset overflows texture dimensions.";
MSG kOtherQueryActive = "Other query is active.";
MSG kOutsideOfBounds = "Parameter outside of bounds.";
MSG kParamOverflow = "The provided parameters overflow with the provided buffer.";
MSG kPixelDataNotNull = "Pixel data must be null.";
......@@ -277,6 +411,8 @@ MSG kProgramNotBound = "A program must be bound.";
MSG kProgramNotLinked = "Program not linked.";
MSG kQueryActive = "Query is active.";
MSG kQueryExtensionNotEnabled = "Query extension not enabled.";
MSG kQueryInactive = "Query is not active.";
MSG kQueryTargetMismatch = "Query type does not match target.";
MSG kReadBufferNone = "Read buffer is GL_NONE.";
MSG kReadBufferNotAttached = "Read buffer has no attachment.";
MSG kRectangleTextureCompressed = "Rectangle texture cannot have a compressed format.";
......@@ -285,24 +421,35 @@ MSG kRenderableInternalFormat = "SizedInternalformat must be color-renderable =
MSG kRenderbufferNotBound = "A renderbuffer must be bound.";
MSG kResourceMaxRenderbufferSize = "Desired resource size is greater than max renderbuffer size.";
MSG kResourceMaxTextureSize = "Desired resource size is greater than max texture size.";
MSG kSamplerUniformValueOutOfRange = "Sampler uniform value out of range.";
MSG kSamplesOutOfRange = "Samples must not be greater than maximum supported value for the format.";
MSG kSamplesZero = "Samples may not be zero.";
MSG kShaderAttachmentHasShader = "Shader attachment already has a shader.";
MSG kShaderSourceInvalidCharacters = "Shader source contains invalid characters.";
MSG kShaderStorageBufferOffsetAlignment = "Offset must be multiple of value of SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT.";
MSG kShaderToDetachMustBeAttached = "Shader to be detached must be currently attached to the program.";
MSG kSourceLevelNotDefined = "The source level of the source texture must be defined.";
MSG kSourceTextureLevelZeroDefined = "Source texture must level 0 defined.";
MSG kSourceTextureMustBeCompressed = "Source texture must have a compressed internal format.";
MSG kSourceTextureTooSmall = "The specified dimensions are outside of the bounds of the texture.";
MSG kStencilReferenceMaskOrMismatch = "Stencil reference and mask values must be the same for front facing and back facing triangles.";
MSG kStrideExceedsWebGLLimit = "Stride is over the maximum stride allowed by WebGL.";
MSG kStrideMustBeMultipleOfType = "Stride must be a multiple of the passed in datatype.";
MSG kSyncMissing = "Sync object does not exist.";
MSG kTargetMustBeTexture2DMultisampleArrayOES = "Target must be TEXTURE_2D_MULTISAMPLE_ARRAY_OES.";
MSG kTextureIsImmutable = "Texture is immutable.";
MSG kTextureIsNotImmutable = "Texture is not immutable.";
MSG kTextureNotBound = "A texture must be bound.";
MSG kTextureNotPow2 = "The texture is a non-power-of-two texture.";
MSG kTextureRectangleNotSupported = "Context does not support GL_ANGLE_texture_rectangle";
MSG kTextureSizeTooSmall = "Texture dimensions must all be greater than zero.";
MSG kTextureTargetMismatch = "Textarget must match the texture target type.";
MSG kTextureTargetRequiresES31 = "Texture target requires at least OpenGL ES 3.1.";
MSG kTextureTypeConflict = "Two textures of different types use the same sampler location.";
MSG kTextureWidthOrHeightOutOfRange = "Width and height must be less than or equal to GL_MAX_TEXTURE_SIZE.";
MSG kTransfomFeedbackAlreadyActive = "Transform feedback is already active.";
MSG kTransformFeedbackActiveDelete = "Attempt to delete an active transform feedback.";
MSG kTransformFeedbackActiveDuringLink = "Cannot link program while program is associated with an active transform feedback object.";
MSG kTransformFeedbackBufferDoubleBound = "A transform feedback buffer that would be written to is also bound to a non-transform-feedback target = which would cause undefined behavior.";
MSG kTransformFeedbackBufferMultipleOutputs = "Transform feedback has a buffer bound to multiple outputs.";
MSG kTransformFeedbackBufferTooSmall = "Not enough space in bound transform feedback buffers.";
......@@ -310,13 +457,19 @@ MSG kTransformFeedbackDoesNotExist = "Transform feedback object that does not ex
MSG kTransformFeedbackNotActive = "No Transform Feedback object is active.";
MSG kTransformFeedbackNotPaused = "The active Transform Feedback object is not paused.";
MSG kTransformFeedbackPaused = "The active Transform Feedback object is paused.";
MSG kTransformFeedbackProgramBinary = "Cannot change program binary while program is associated with an active transform feedback object.";
MSG kTransformFeedbackTargetActive = "Target is TRANSFORM_FEEDBACK_BUFFER and transform feedback is currently active.";
MSG kTransformFeedbackUseProgram = "Cannot change active program while transform feedback is unpaused.";
MSG kTransformFeedbackVaryingIndexOutOfRange = "Index must be less than the transform feedback varying count in the program.";
MSG kTypeMismatch = "Passed in texture target and format must match the one originally used to define the texture.";
MSG kTypeNotUnsignedShortByte = "Only UNSIGNED_SHORT and UNSIGNED_BYTE types are supported.";
MSG kUniformBufferBoundForTransformFeedback = "It is undefined behavior to use an uniform buffer that is bound for transform feedback.";
MSG kUniformBufferOffsetAlignment = "Offset must be multiple of value of UNIFORM_BUFFER_OFFSET_ALIGNMENT.";
MSG kUniformBufferTooSmall = "It is undefined behaviour to use a uniform buffer that is too small.";
MSG kUniformBufferUnbound = "It is undefined behaviour to have a used but unbound uniform buffer.";
MSG kUniformSizeMismatch = "Uniform size does not match uniform method.";
MSG kUniformTypeMismatch = "Uniform type does not match uniform method.";
MSG kUnimplementedComputeShaderPrecision = "Compute shader precision not yet implemented.";
MSG kUnknownParameter = "Unknown parameter value.";
MSG kUnsizedInternalFormatUnsupported = "Internalformat is one of the unsupported unsized base internalformats.";
MSG kUnsupportedDrawModeForTransformFeedback = "The draw command is unsupported when transform feedback is active and not paused.";
......@@ -325,6 +478,7 @@ MSG kVertexArrayNoBufferPointer = "An enabled vertex array has no buffer and no
MSG kVertexBufferBoundForTransformFeedback = "It is undefined behavior to use a vertex buffer that is bound for transform feedback.";
MSG kVertexShaderTypeMismatch = "Vertex shader input type does not match the type of the bound vertex attribute.";
MSG kViewportNegativeSize = "Viewport size cannot be negative.";
MSG kViewsExceedMaxArrayLayers = "baseViewIndex+numViews cannot be greater than GL_MAX_ARRAY_TEXTURE_LAYERS.";
MSG kWebgl2NameLengthLimitExceeded = "Location lengths must not be greater than 1024 characters.";
MSG kWebglBindAttribLocationReservedPrefix = "Attributes that begin with 'webgl_' = or '_webgl_' are not allowed.";
MSG kWebglNameLengthLimitExceeded = "Location name lengths must not be greater than 256 characters.";
......
......@@ -952,14 +952,13 @@ bool ValidImageDataSize(Context *context,
ASSERT(imageSize >= 0);
if (pixels == nullptr && imageSize != 0)
{
context->validationError(GL_INVALID_OPERATION,
"imageSize must be 0 if no texture data is provided.");
context->validationError(GL_INVALID_OPERATION, kImageSizeMustBeZero);
return false;
}
if (pixels != nullptr && endByte > static_cast<GLuint>(imageSize))
{
context->validationError(GL_INVALID_OPERATION, "imageSize is too small");
context->validationError(GL_INVALID_OPERATION, kImageSizeTooSmall);
return false;
}
}
......@@ -1003,8 +1002,7 @@ bool ValidateWebGLVertexAttribPointer(Context *context,
constexpr GLsizei kMaxWebGLStride = 255;
if (stride > kMaxWebGLStride)
{
context->validationError(GL_INVALID_VALUE,
"Stride is over the maximum stride allowed by WebGL.");
context->validationError(GL_INVALID_VALUE, kStrideExceedsWebGLLimit);
return false;
}
......@@ -1619,7 +1617,7 @@ bool ValidateBeginQueryBase(Context *context, QueryType target, GLuint id)
if (id == 0)
{
context->validationError(GL_INVALID_OPERATION, "Query id is 0");
context->validationError(GL_INVALID_OPERATION, kInvalidQueryId);
return false;
}
......@@ -1641,7 +1639,7 @@ bool ValidateBeginQueryBase(Context *context, QueryType target, GLuint id)
if (context->getGLState().isQueryActive(target))
{
context->validationError(GL_INVALID_OPERATION, "Other query is active");
context->validationError(GL_INVALID_OPERATION, kOtherQueryActive);
return false;
}
......@@ -1657,7 +1655,7 @@ bool ValidateBeginQueryBase(Context *context, QueryType target, GLuint id)
// check for type mismatch
if (queryObject->getType() != target)
{
context->validationError(GL_INVALID_OPERATION, "Query type does not match target");
context->validationError(GL_INVALID_OPERATION, kQueryTargetMismatch);
return false;
}
......@@ -1688,7 +1686,7 @@ bool ValidateEndQueryBase(Context *context, QueryType target)
if (queryObject == nullptr)
{
context->validationError(GL_INVALID_OPERATION, "Query target not active");
context->validationError(GL_INVALID_OPERATION, kQueryInactive);
return false;
}
......@@ -1711,7 +1709,7 @@ bool ValidateQueryCounterEXT(Context *context, GLuint id, QueryType target)
{
if (!context->getExtensions().disjointTimerQuery)
{
context->validationError(GL_INVALID_OPERATION, "Disjoint timer query not enabled");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -1755,7 +1753,7 @@ bool ValidateGetQueryivBase(Context *context, QueryType target, GLenum pname, GL
case GL_CURRENT_QUERY_EXT:
if (target == QueryType::Timestamp)
{
context->validationError(GL_INVALID_ENUM, "Cannot use current query for timestamp");
context->validationError(GL_INVALID_ENUM, kInvalidQueryTarget);
return false;
}
break;
......@@ -1866,7 +1864,7 @@ bool ValidateGetQueryObjectivEXT(Context *context, GLuint id, GLenum pname, GLin
{
if (!context->getExtensions().disjointTimerQuery)
{
context->validationError(GL_INVALID_OPERATION, "Timer query extension not enabled");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGetQueryObjectValueBase(context, id, pname, nullptr);
......@@ -1881,7 +1879,7 @@ bool ValidateGetQueryObjectivRobustANGLE(Context *context,
{
if (!context->getExtensions().disjointTimerQuery)
{
context->validationError(GL_INVALID_OPERATION, "Timer query extension not enabled");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -2130,14 +2128,14 @@ bool ValidateUniform1ivValue(Context *context,
{
if (value[i] < 0 || value[i] >= max)
{
context->validationError(GL_INVALID_VALUE, "sampler uniform value out of range");
context->validationError(GL_INVALID_VALUE, kSamplerUniformValueOutOfRange);
return false;
}
}
return true;
}
context->validationError(GL_INVALID_OPERATION, "wrong type of value for uniform");
context->validationError(GL_INVALID_OPERATION, kUniformTypeMismatch);
return false;
}
......@@ -2149,7 +2147,7 @@ bool ValidateUniformMatrixValue(Context *context, GLenum valueType, GLenum unifo
return true;
}
context->validationError(GL_INVALID_OPERATION, "wrong type of value for uniform");
context->validationError(GL_INVALID_OPERATION, kUniformTypeMismatch);
return false;
}
......@@ -2226,8 +2224,7 @@ bool ValidateStateQuery(Context *context, GLenum pname, GLenum *nativeType, unsi
case GL_TEXTURE_BINDING_RECTANGLE_ANGLE:
if (!context->getExtensions().textureRectangle)
{
context->validationError(GL_INVALID_ENUM,
"ANGLE_texture_rectangle extension not present");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -2235,10 +2232,7 @@ bool ValidateStateQuery(Context *context, GLenum pname, GLenum *nativeType, unsi
if (!context->getExtensions().eglStreamConsumerExternal &&
!context->getExtensions().eglImageExternal)
{
context->validationError(GL_INVALID_ENUM,
"Neither NV_EGL_stream_consumer_external "
"nor GL_OES_EGL_image_external "
"extensions enabled");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -2471,8 +2465,7 @@ bool ValidateCopyTexImageParametersBase(Context *context,
// framebuffer is more than one.
if (readFramebuffer->readDisallowedByMultiview())
{
context->validationError(GL_INVALID_FRAMEBUFFER_OPERATION,
"The active read framebuffer object has multiview attachments.");
context->validationError(GL_INVALID_FRAMEBUFFER_OPERATION, kMultiviewReadFramebuffer);
return false;
}
......@@ -3073,7 +3066,7 @@ bool ValidateDrawElementsCommon(Context *context,
// WebGL buffers cannot be mapped/unmapped because the MapBufferRange,
// FlushMappedBufferRange, and UnmapBuffer entry points are removed from the
// WebGL 2.0 API. https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.14
context->validationError(GL_INVALID_OPERATION, "Index buffer is mapped.");
context->validationError(GL_INVALID_OPERATION, kBufferMapped);
return false;
}
}
......@@ -3092,8 +3085,7 @@ bool ValidateDrawElementsCommon(Context *context,
{
// This is an application error that would normally result in a crash, but we catch
// it and return an error
context->validationError(GL_INVALID_OPERATION,
"No element array buffer and no pointer.");
context->validationError(GL_INVALID_OPERATION, kElementArrayNoBufferOrPointer);
return false;
}
}
......@@ -3462,10 +3454,7 @@ bool ValidateDiscardFramebufferBase(Context *context,
if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getCaps().maxColorAttachments)
{
context->validationError(GL_INVALID_OPERATION,
"Requested color attachment is "
"greater than the maximum supported "
"color attachments");
context->validationError(GL_INVALID_OPERATION, kExceedsMaxColorAttachments);
return false;
}
}
......@@ -3564,17 +3553,14 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context, TextureType type, GLeg
case TextureType::_2D:
if (!context->getExtensions().eglImage)
{
context->validationError(GL_INVALID_ENUM,
"GL_TEXTURE_2D texture target requires GL_OES_EGL_image.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
}
break;
case TextureType::External:
if (!context->getExtensions().eglImageExternal)
{
context->validationError(GL_INVALID_ENUM,
"GL_TEXTURE_EXTERNAL_OES texture target "
"requires GL_OES_EGL_image_external.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
}
break;
......@@ -3588,21 +3574,19 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context, TextureType type, GLeg
ASSERT(context->getCurrentDisplay());
if (!context->getCurrentDisplay()->isValidImage(imageObject))
{
context->validationError(GL_INVALID_VALUE, "EGL image is not valid.");
context->validationError(GL_INVALID_VALUE, kInvalidEGLImage);
return false;
}
if (imageObject->getSamples() > 0)
{
context->validationError(GL_INVALID_OPERATION,
"cannot create a 2D texture from a multisampled EGL image.");
context->validationError(GL_INVALID_OPERATION, kEGLImageCannotCreate2DMultisampled);
return false;
}
if (!imageObject->isTexturable(context))
{
context->validationError(GL_INVALID_OPERATION,
"EGL image internal format is not supported as a texture.");
context->validationError(GL_INVALID_OPERATION, kEGLImageTextureFormatNotSupported);
return false;
}
......@@ -3634,14 +3618,13 @@ bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context,
ASSERT(context->getCurrentDisplay());
if (!context->getCurrentDisplay()->isValidImage(imageObject))
{
context->validationError(GL_INVALID_VALUE, "EGL image is not valid.");
context->validationError(GL_INVALID_VALUE, kInvalidEGLImage);
return false;
}
if (!imageObject->isRenderable(context))
{
context->validationError(GL_INVALID_OPERATION,
"EGL image internal format is not supported as a renderbuffer.");
context->validationError(GL_INVALID_OPERATION, kEGLImageRenderbufferFormatNotSupported);
return false;
}
......@@ -3677,17 +3660,14 @@ bool ValidateProgramBinaryBase(Context *context,
if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) ==
programBinaryFormats.end())
{
context->validationError(GL_INVALID_ENUM, "Program binary format is not valid.");
context->validationError(GL_INVALID_ENUM, kInvalidProgramBinaryFormat);
return false;
}
if (context->hasActiveTransformFeedback(program))
{
// ES 3.0.4 section 2.15 page 91
context->validationError(GL_INVALID_OPERATION,
"Cannot change program binary while program "
"is associated with an active transform "
"feedback object.");
context->validationError(GL_INVALID_OPERATION, kTransformFeedbackProgramBinary);
return false;
}
......@@ -3715,7 +3695,7 @@ bool ValidateGetProgramBinaryBase(Context *context,
if (context->getCaps().programBinaryFormats.empty())
{
context->validationError(GL_INVALID_OPERATION, "No program binary formats supported.");
context->validationError(GL_INVALID_OPERATION, kNoProgramBinaryFormats);
return false;
}
......@@ -3756,13 +3736,12 @@ bool ValidateDrawBuffersBase(Context *context, GLsizei n, const GLenum *bufs)
// was changed to GL_INVALID_ENUM in 3.1, which dEQP also expects.
// 3.1 is still a bit ambiguous about the error, but future specs are
// expected to clarify that GL_INVALID_ENUM is the correct error.
context->validationError(GL_INVALID_ENUM, "Invalid buffer value");
context->validationError(GL_INVALID_ENUM, kInvalidDrawBuffer);
return false;
}
else if (bufs[colorAttachment] >= maxColorAttachment)
{
context->validationError(GL_INVALID_OPERATION,
"Buffer value is greater than MAX_DRAW_BUFFERS");
context->validationError(GL_INVALID_OPERATION, kExceedsMaxColorAttachments);
return false;
}
else if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment &&
......@@ -3770,8 +3749,7 @@ bool ValidateDrawBuffersBase(Context *context, GLsizei n, const GLenum *bufs)
{
// INVALID_OPERATION-GL is bound to buffer and ith argument
// is not COLOR_ATTACHMENTi or NONE
context->validationError(GL_INVALID_OPERATION,
"Ith value does not match COLOR_ATTACHMENTi or NONE");
context->validationError(GL_INVALID_OPERATION, kInvalidDrawBufferValue);
return false;
}
}
......@@ -3782,16 +3760,13 @@ bool ValidateDrawBuffersBase(Context *context, GLsizei n, const GLenum *bufs)
{
if (n != 1)
{
context->validationError(GL_INVALID_OPERATION,
"n must be 1 when GL is bound to the default framebuffer");
context->validationError(GL_INVALID_OPERATION, kInvalidDrawBufferCountForDefault);
return false;
}
if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
{
context->validationError(
GL_INVALID_OPERATION,
"Only NONE or BACK are valid values when drawing to the default framebuffer");
context->validationError(GL_INVALID_OPERATION, kDefaultFramebufferInvalidDrawBuffer);
return false;
}
}
......@@ -3810,17 +3785,9 @@ bool ValidateGetBufferPointervBase(Context *context,
*length = 0;
}
if (context->getClientMajorVersion() < 3 && !context->getExtensions().mapBuffer)
{
context->validationError(
GL_INVALID_OPERATION,
"Context does not support OpenGL ES 3.0 or GL_OES_mapbuffer is not enabled.");
return false;
}
if (!context->isValidBufferBinding(target))
{
context->validationError(GL_INVALID_ENUM, "Buffer target not valid");
context->validationError(GL_INVALID_ENUM, kInvalidBufferTypes);
return false;
}
......@@ -3839,8 +3806,7 @@ bool ValidateGetBufferPointervBase(Context *context,
// GLES 3.1 section 6.6 explicitly specifies this error.
if (context->getGLState().getTargetBuffer(target) == nullptr)
{
context->validationError(GL_INVALID_OPERATION,
"Can not get pointer for reserved buffer name zero.");
context->validationError(GL_INVALID_OPERATION, kBufferPointerNotAvailable);
return false;
}
......@@ -3864,7 +3830,7 @@ bool ValidateUnmapBufferBase(Context *context, BufferBinding target)
if (buffer == nullptr || !buffer->isMapped())
{
context->validationError(GL_INVALID_OPERATION, "Buffer not mapped.");
context->validationError(GL_INVALID_OPERATION, kBufferNotMapped);
return false;
}
......@@ -3899,7 +3865,7 @@ bool ValidateMapBufferRangeBase(Context *context,
if (!buffer)
{
context->validationError(GL_INVALID_OPERATION, "Attempted to map buffer object zero.");
context->validationError(GL_INVALID_OPERATION, kBufferNotMappable);
return false;
}
......@@ -3909,8 +3875,7 @@ bool ValidateMapBufferRangeBase(Context *context,
if (!checkedSize.IsValid() || checkedSize.ValueOrDie() > static_cast<size_t>(buffer->getSize()))
{
context->validationError(GL_INVALID_VALUE,
"Mapped range does not fit into buffer dimensions.");
context->validationError(GL_INVALID_VALUE, kMapOutOfRange);
return false;
}
......@@ -3921,27 +3886,26 @@ bool ValidateMapBufferRangeBase(Context *context,
if (access & ~(allAccessBits))
{
context->validationError(GL_INVALID_VALUE, "Invalid access bits");
context->validationError(GL_INVALID_VALUE, kInvalidAccessBits);
return false;
}
if (length == 0)
{
context->validationError(GL_INVALID_OPERATION, "Buffer mapping length is zero.");
context->validationError(GL_INVALID_OPERATION, kLengthZero);
return false;
}
if (buffer->isMapped())
{
context->validationError(GL_INVALID_OPERATION, "Buffer is already mapped.");
context->validationError(GL_INVALID_OPERATION, kBufferAlreadyMapped);
return false;
}
// Check for invalid bit combinations
if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
{
context->validationError(GL_INVALID_OPERATION,
"Need to map buffer for either reading or writing.");
context->validationError(GL_INVALID_OPERATION, kInvalidAccessBitsReadWrite);
return false;
}
......@@ -3950,16 +3914,13 @@ bool ValidateMapBufferRangeBase(Context *context,
if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
{
context->validationError(GL_INVALID_OPERATION,
"Invalid access bits when mapping buffer for reading");
context->validationError(GL_INVALID_OPERATION, kInvalidAccessBitsRead);
return false;
}
if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
{
context->validationError(
GL_INVALID_OPERATION,
"The explicit flushing bit may only be set if the buffer is mapped for writing.");
context->validationError(GL_INVALID_OPERATION, kInvalidAccessBitsFlush);
return false;
}
......@@ -3993,14 +3954,13 @@ bool ValidateFlushMappedBufferRangeBase(Context *context,
if (buffer == nullptr)
{
context->validationError(GL_INVALID_OPERATION, "Attempted to flush buffer object zero.");
context->validationError(GL_INVALID_OPERATION, kInvalidFlushZero);
return false;
}
if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
{
context->validationError(GL_INVALID_OPERATION,
"Attempted to flush a buffer not mapped for explicit flushing.");
context->validationError(GL_INVALID_OPERATION, kInvalidFlushTarget);
return false;
}
......@@ -4011,8 +3971,7 @@ bool ValidateFlushMappedBufferRangeBase(Context *context,
if (!checkedSize.IsValid() ||
checkedSize.ValueOrDie() > static_cast<size_t>(buffer->getMapLength()))
{
context->validationError(GL_INVALID_VALUE,
"Flushed range does not fit into buffer mapping dimensions.");
context->validationError(GL_INVALID_VALUE, kInvalidFlushOutOfRange);
return false;
}
......@@ -4033,8 +3992,7 @@ bool ValidateRobustEntryPoint(Context *context, GLsizei bufSize)
{
if (!context->getExtensions().robustClientMemory)
{
context->validationError(GL_INVALID_OPERATION,
"GL_ANGLE_robust_client_memory is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -4051,8 +4009,7 @@ bool ValidateRobustBufferSize(Context *context, GLsizei bufSize, GLsizei numPara
{
if (bufSize < numParams)
{
context->validationError(GL_INVALID_OPERATION,
"More parameters are required than were provided.");
context->validationError(GL_INVALID_OPERATION, kInsufficientParams);
return false;
}
......@@ -4449,10 +4406,7 @@ bool ValidateGetProgramivBase(Context *context, GLuint program, GLenum pname, GL
case GL_PROGRAM_BINARY_LENGTH:
if (context->getClientMajorVersion() < 3 && !context->getExtensions().getProgramBinary)
{
context->validationError(GL_INVALID_ENUM,
"Querying GL_PROGRAM_BINARY_LENGTH "
"requires GL_OES_get_program_binary or "
"ES 3.0.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -4465,7 +4419,7 @@ bool ValidateGetProgramivBase(Context *context, GLuint program, GLenum pname, GL
case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM, kES3Required);
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);
return false;
}
break;
......@@ -4474,7 +4428,7 @@ bool ValidateGetProgramivBase(Context *context, GLuint program, GLenum pname, GL
case GL_ACTIVE_ATOMIC_COUNTER_BUFFERS:
if (context->getClientVersion() < Version(3, 1))
{
context->validationError(GL_INVALID_ENUM, kES31Required);
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES31);
return false;
}
break;
......@@ -4482,7 +4436,7 @@ bool ValidateGetProgramivBase(Context *context, GLuint program, GLenum pname, GL
case GL_COMPUTE_WORK_GROUP_SIZE:
if (context->getClientVersion() < Version(3, 1))
{
context->validationError(GL_INVALID_ENUM, kES31Required);
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES31);
return false;
}
......@@ -5121,8 +5075,7 @@ bool ValidateVertexFormatBase(Context *context,
case GL_UNSIGNED_INT:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM,
"Vertex type not supported before OpenGL ES 3.0.");
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);
return false;
}
break;
......@@ -5139,8 +5092,7 @@ bool ValidateVertexFormatBase(Context *context,
case GL_HALF_FLOAT:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM,
"Vertex type not supported before OpenGL ES 3.0.");
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);
return false;
}
if (pureInteger)
......@@ -5154,8 +5106,7 @@ bool ValidateVertexFormatBase(Context *context,
case GL_UNSIGNED_INT_2_10_10_10_REV:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM,
"Vertex type not supported before OpenGL ES 3.0.");
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);
return false;
}
if (pureInteger)
......@@ -5165,10 +5116,7 @@ bool ValidateVertexFormatBase(Context *context,
}
if (size != 4)
{
context->validationError(GL_INVALID_OPERATION,
"Type is INT_2_10_10_10_REV or "
"UNSIGNED_INT_2_10_10_10_REV and "
"size is not 4.");
context->validationError(GL_INVALID_OPERATION, kInvalidVertexAttribSize2101010);
return false;
}
break;
......@@ -5198,9 +5146,7 @@ bool ValidateWebGLFramebufferAttachmentClearType(Context *context,
const GLenum *end = validComponentTypes + validComponentTypeCount;
if (std::find(validComponentTypes, end, componentType) == end)
{
context->validationError(
GL_INVALID_OPERATION,
"No defined conversion between clear value and attachment format.");
context->validationError(GL_INVALID_OPERATION, kNoDefinedClearConversion);
return false;
}
}
......@@ -5220,7 +5166,7 @@ bool ValidateRobustCompressedTexImageBase(Context *context, GLsizei imageSize, G
{
if (dataSize < imageSize)
{
context->validationError(GL_INVALID_OPERATION, "dataSize is too small");
context->validationError(GL_INVALID_OPERATION, kCompressedDataSizeTooSmall);
}
}
return true;
......@@ -5262,8 +5208,7 @@ bool ValidateGetBufferParameterBase(Context *context,
case GL_BUFFER_ACCESS_OES:
if (!extensions.mapBuffer)
{
context->validationError(GL_INVALID_ENUM,
"pname requires OpenGL ES 3.0 or GL_OES_mapbuffer.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5273,10 +5218,7 @@ bool ValidateGetBufferParameterBase(Context *context,
if (context->getClientMajorVersion() < 3 && !extensions.mapBuffer &&
!extensions.mapBufferRange)
{
context->validationError(GL_INVALID_ENUM,
"pname requires OpenGL ES 3.0, "
"GL_OES_mapbuffer or "
"GL_EXT_map_buffer_range.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5284,9 +5226,7 @@ bool ValidateGetBufferParameterBase(Context *context,
case GL_BUFFER_MAP_POINTER:
if (!pointerVersion)
{
context->validationError(
GL_INVALID_ENUM,
"GL_BUFFER_MAP_POINTER can only be queried with GetBufferPointerv.");
context->validationError(GL_INVALID_ENUM, kInvalidMapPointerQuery);
return false;
}
break;
......@@ -5296,8 +5236,7 @@ bool ValidateGetBufferParameterBase(Context *context,
case GL_BUFFER_MAP_LENGTH:
if (context->getClientMajorVersion() < 3 && !extensions.mapBufferRange)
{
context->validationError(
GL_INVALID_ENUM, "pname requires OpenGL ES 3.0 or GL_EXT_map_buffer_range.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5477,7 +5416,7 @@ bool ValidateGetTexParameterBase(Context *context,
case GL_TEXTURE_USAGE_ANGLE:
if (!context->getExtensions().textureUsage)
{
context->validationError(GL_INVALID_ENUM, kExtensionNotEnabled);
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5492,7 +5431,7 @@ bool ValidateGetTexParameterBase(Context *context,
case GL_TEXTURE_IMMUTABLE_FORMAT:
if (context->getClientMajorVersion() < 3 && !context->getExtensions().textureStorage)
{
context->validationError(GL_INVALID_ENUM, kExtensionNotEnabled);
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5511,7 +5450,7 @@ bool ValidateGetTexParameterBase(Context *context,
case GL_TEXTURE_COMPARE_FUNC:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM, "pname requires OpenGL ES 3.0.");
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);
return false;
}
break;
......@@ -5519,8 +5458,7 @@ bool ValidateGetTexParameterBase(Context *context,
case GL_TEXTURE_SRGB_DECODE_EXT:
if (!context->getExtensions().textureSRGBDecode)
{
context->validationError(GL_INVALID_ENUM,
"GL_EXT_texture_sRGB_decode is not enabled.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5547,7 +5485,7 @@ bool ValidateGetTexParameterBase(Context *context,
case GL_MEMORY_SIZE_ANGLE:
if (!context->getExtensions().memorySize)
{
context->validationError(GL_INVALID_ENUM, kExtensionNotEnabled);
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5586,7 +5524,7 @@ bool ValidateGetVertexAttribBase(Context *context,
if (pureIntegerEntryPoint && context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_OPERATION, "Context does not support OpenGL ES 3.0.");
context->validationError(GL_INVALID_OPERATION, kES3Required);
return false;
}
......@@ -5624,10 +5562,7 @@ bool ValidateGetVertexAttribBase(Context *context,
if (context->getClientMajorVersion() < 3 &&
!context->getExtensions().instancedArrays)
{
context->validationError(GL_INVALID_ENUM,
"GL_VERTEX_ATTRIB_ARRAY_DIVISOR "
"requires OpenGL ES 3.0 or "
"GL_ANGLE_instanced_arrays.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5635,8 +5570,7 @@ bool ValidateGetVertexAttribBase(Context *context,
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
if (context->getClientMajorVersion() < 3)
{
context->validationError(
GL_INVALID_ENUM, "GL_VERTEX_ATTRIB_ARRAY_INTEGER requires OpenGL ES 3.0.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5645,8 +5579,7 @@ bool ValidateGetVertexAttribBase(Context *context,
case GL_VERTEX_ATTRIB_RELATIVE_OFFSET:
if (context->getClientVersion() < ES_3_1)
{
context->validationError(GL_INVALID_ENUM,
"Vertex Attrib Bindings require OpenGL ES 3.1.");
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES31);
return false;
}
break;
......@@ -5742,8 +5675,7 @@ bool ValidateReadPixelsBase(Context *context,
// in the current read framebuffer is more than one.
if (framebuffer->readDisallowedByMultiview())
{
context->validationError(GL_INVALID_FRAMEBUFFER_OPERATION,
"Attempting to read from a multi-view framebuffer.");
context->validationError(GL_INVALID_FRAMEBUFFER_OPERATION, kMultiviewReadFramebuffer);
return false;
}
......@@ -5791,7 +5723,7 @@ bool ValidateReadPixelsBase(Context *context,
if (pixelPackBuffer != nullptr && pixelPackBuffer->isMapped())
{
// ...the buffer object's data store is currently mapped.
context->validationError(GL_INVALID_OPERATION, "Pixel pack buffer is mapped.");
context->validationError(GL_INVALID_OPERATION, kBufferMapped);
return false;
}
if (context->getExtensions().webglCompatibility && pixelPackBuffer != nullptr &&
......@@ -5959,10 +5891,7 @@ bool ValidateTexParameterBase(Context *context,
}
if (target == TextureType::External && !context->getExtensions().eglImageExternalEssl3)
{
context->validationError(GL_INVALID_ENUM,
"ES3 texture parameters are not "
"available without "
"GL_OES_EGL_image_external_essl3.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5993,8 +5922,7 @@ bool ValidateTexParameterBase(Context *context,
case GL_TEXTURE_COMPARE_MODE:
case GL_TEXTURE_COMPARE_FUNC:
case GL_TEXTURE_BORDER_COLOR:
context->validationError(GL_INVALID_ENUM,
"Invalid parameter for 2D multisampled textures.");
context->validationError(GL_INVALID_ENUM, kInvalidPname);
return false;
}
}
......@@ -6104,27 +6032,24 @@ bool ValidateTexParameterBase(Context *context,
case GL_TEXTURE_BASE_LEVEL:
if (ConvertToGLint(params[0]) < 0)
{
context->validationError(GL_INVALID_VALUE, "Base level must be at least 0.");
context->validationError(GL_INVALID_VALUE, kBaseLevelNegative);
return false;
}
if (target == TextureType::External && static_cast<GLuint>(params[0]) != 0)
{
context->validationError(GL_INVALID_OPERATION,
"Base level must be 0 for external textures.");
context->validationError(GL_INVALID_OPERATION, kBaseLevelNonZero);
return false;
}
if ((target == TextureType::_2DMultisample ||
target == TextureType::_2DMultisampleArray) &&
static_cast<GLuint>(params[0]) != 0)
{
context->validationError(GL_INVALID_OPERATION,
"Base level must be 0 for multisampled textures.");
context->validationError(GL_INVALID_OPERATION, kBaseLevelNonZero);
return false;
}
if (target == TextureType::Rectangle && static_cast<GLuint>(params[0]) != 0)
{
context->validationError(GL_INVALID_OPERATION,
"Base level must be 0 for rectangle textures.");
context->validationError(GL_INVALID_OPERATION, kBaseLevelNonZero);
return false;
}
break;
......@@ -6259,8 +6184,7 @@ bool ValidateGetActiveUniformBlockivBase(Context *context,
if (uniformBlockIndex >= programObject->getActiveUniformBlockCount())
{
context->validationError(GL_INVALID_VALUE,
"uniformBlockIndex exceeds active uniform block count.");
context->validationError(GL_INVALID_VALUE, kIndexExceedsActiveUniformBlockCount);
return false;
}
......@@ -6460,8 +6384,7 @@ bool ValidateGetSamplerParameterBase(Context *context,
case GL_TEXTURE_SRGB_DECODE_EXT:
if (!context->getExtensions().textureSRGBDecode)
{
context->validationError(GL_INVALID_ENUM,
"GL_EXT_texture_sRGB_decode is not enabled.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -6507,7 +6430,7 @@ bool ValidateGetInternalFormativBase(Context *context,
const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
if (!formatCaps.renderbuffer)
{
context->validationError(GL_INVALID_ENUM, "Internal format is not renderable.");
context->validationError(GL_INVALID_ENUM, kFormatNotRenderable);
return false;
}
......@@ -6690,7 +6613,7 @@ bool ValidateGetTexLevelParameterBase(Context *context,
if (context->getTargetTexture(type) == nullptr)
{
context->validationError(GL_INVALID_ENUM, "No texture bound.");
context->validationError(GL_INVALID_ENUM, kTextureNotBound);
return false;
}
......
......@@ -96,20 +96,19 @@ bool ValidateInstancedPathParameters(gl::Context *context,
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (paths == nullptr)
{
context->validationError(GL_INVALID_VALUE, "No path name array.");
context->validationError(GL_INVALID_VALUE, kInvalidPathNameArray);
return false;
}
if (numPaths < 0)
{
context->validationError(GL_INVALID_VALUE, "Invalid (negative) numPaths.");
context->validationError(GL_INVALID_VALUE, kInvalidPathNumPaths);
return false;
}
......@@ -161,7 +160,7 @@ bool ValidateInstancedPathParameters(gl::Context *context,
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid path name type.");
context->validationError(GL_INVALID_ENUM, kInvalidPathNameType);
return false;
}
......@@ -189,12 +188,12 @@ bool ValidateInstancedPathParameters(gl::Context *context,
componentCount = 12;
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid transformation.");
context->validationError(GL_INVALID_ENUM, kInvalidTransformation);
return false;
}
if (componentCount != 0 && transformValues == nullptr)
{
context->validationError(GL_INVALID_VALUE, "No transform array given.");
context->validationError(GL_INVALID_VALUE, kNoTransformArray);
return false;
}
......@@ -481,7 +480,7 @@ bool ValidateES2CopyTexImageParameters(Context *context,
TextureType texType = TextureTargetToType(target);
if (!ValidImageSizeParameters(context, texType, level, width, height, 1, isSubImage))
{
context->validationError(GL_INVALID_VALUE, "Invalid texture dimensions.");
// Error is already handled.
return false;
}
......@@ -721,14 +720,12 @@ bool ValidateES2CopyTexImageParameters(Context *context,
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
if (context->getExtensions().lossyETCDecode)
{
context->validationError(GL_INVALID_OPERATION,
"ETC lossy decode formats can't be copied to.");
context->validationError(GL_INVALID_OPERATION, kInvalidFormat);
return false;
}
else
{
context->validationError(GL_INVALID_ENUM,
"ANGLE_lossy_etc_decode extension is not supported.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -1044,8 +1041,7 @@ bool ValidateMatrixMode(Context *context, GLenum matrixMode)
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -1126,8 +1122,7 @@ void RecordBindTextureTypeError(Context *context, TextureType target)
{
case TextureType::Rectangle:
ASSERT(!context->getExtensions().textureRectangle);
context->validationError(GL_INVALID_ENUM,
"Context does not support GL_ANGLE_texture_rectangle");
context->validationError(GL_INVALID_ENUM, kTextureRectangleNotSupported);
break;
case TextureType::_3D:
......@@ -1150,7 +1145,7 @@ void RecordBindTextureTypeError(Context *context, TextureType target)
case TextureType::External:
ASSERT(!context->getExtensions().eglImageExternal &&
!context->getExtensions().eglStreamConsumerExternal);
context->validationError(GL_INVALID_ENUM, "External texture extension not enabled");
context->validationError(GL_INVALID_ENUM, kExternalTextureNotSupported);
break;
default:
......@@ -1239,8 +1234,7 @@ bool ValidateES2TexImageParameters(Context *context,
}
if (isCompressed)
{
context->validationError(GL_INVALID_ENUM,
"Rectangle texture cannot have a compressed format.");
context->validationError(GL_INVALID_ENUM, kRectangleTextureCompressed);
return false;
}
break;
......@@ -1277,7 +1271,7 @@ bool ValidateES2TexImageParameters(Context *context,
const InternalFormat &textureInternalFormat = *texture->getFormat(target, level).info;
if (textureInternalFormat.internalFormat == GL_NONE)
{
context->validationError(GL_INVALID_OPERATION, "Texture level does not exist.");
context->validationError(GL_INVALID_OPERATION, kInvalidTextureLevel);
return false;
}
......@@ -1358,8 +1352,7 @@ bool ValidateES2TexImageParameters(Context *context,
height, texture->getWidth(target, level),
texture->getHeight(target, level)))
{
context->validationError(GL_INVALID_OPERATION,
"Invalid compressed format dimension.");
context->validationError(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
return false;
}
......@@ -1373,8 +1366,7 @@ bool ValidateES2TexImageParameters(Context *context,
{
if (!ValidCompressedImageSize(context, actualInternalFormat, level, width, height))
{
context->validationError(GL_INVALID_OPERATION,
"Invalid compressed format dimension.");
context->validationError(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
return false;
}
}
......@@ -1590,14 +1582,12 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
if (context->getExtensions().lossyETCDecode)
{
context->validationError(GL_INVALID_OPERATION,
"ETC lossy decode formats can't work with this type.");
context->validationError(GL_INVALID_OPERATION, kInvalidFormat);
return false;
}
else
{
context->validationError(GL_INVALID_ENUM,
"ANGLE_lossy_etc_decode extension is not supported.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -1637,9 +1627,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_RGBA32F:
if (!context->getExtensions().colorBufferFloatRGBA)
{
context->validationError(GL_INVALID_ENUM,
"Sized GL_RGBA32F internal format requires "
"GL_CHROMIUM_color_buffer_float_rgba");
context->validationError(GL_INVALID_ENUM, kInvalidFormat);
return false;
}
if (type != GL_FLOAT)
......@@ -1657,9 +1645,7 @@ bool ValidateES2TexImageParameters(Context *context,
case GL_RGB32F:
if (!context->getExtensions().colorBufferFloatRGB)
{
context->validationError(GL_INVALID_ENUM,
"Sized GL_RGB32F internal format requires "
"GL_CHROMIUM_color_buffer_float_rgb");
context->validationError(GL_INVALID_ENUM, kInvalidFormat);
return false;
}
if (type != GL_FLOAT)
......@@ -1837,8 +1823,7 @@ bool ValidateES2TexStorageParameters(Context *context,
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
if (!context->getExtensions().lossyETCDecode)
{
context->validationError(GL_INVALID_ENUM,
"ANGLE_lossy_etc_decode extension is not supported.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -2122,17 +2107,13 @@ bool ValidateDebugMessageControlKHR(Context *context,
{
if (source == GL_DONT_CARE || type == GL_DONT_CARE)
{
context->validationError(
GL_INVALID_OPERATION,
"If count is greater than zero, source and severity cannot be GL_DONT_CARE.");
context->validationError(GL_INVALID_OPERATION, kInvalidDebugSourceType);
return false;
}
if (severity != GL_DONT_CARE)
{
context->validationError(
GL_INVALID_OPERATION,
"If count is greater than zero, severity must be GL_DONT_CARE.");
context->validationError(GL_INVALID_OPERATION, kInvalidDebugSeverity);
return false;
}
}
......@@ -2182,8 +2163,7 @@ bool ValidateDebugMessageInsertKHR(Context *context,
size_t messageLength = (length < 0) ? strlen(buf) : length;
if (messageLength > context->getExtensions().maxDebugMessageLength)
{
context->validationError(GL_INVALID_VALUE,
"Message length is larger than GL_MAX_DEBUG_MESSAGE_LENGTH.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxDebugMessageLength);
return false;
}
......@@ -2249,17 +2229,14 @@ bool ValidatePushDebugGroupKHR(Context *context,
size_t messageLength = (length < 0) ? strlen(message) : length;
if (messageLength > context->getExtensions().maxDebugMessageLength)
{
context->validationError(GL_INVALID_VALUE,
"Message length is larger than GL_MAX_DEBUG_MESSAGE_LENGTH.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxDebugMessageLength);
return false;
}
size_t currentStackSize = context->getGLState().getDebug().getGroupStackDepth();
if (currentStackSize >= context->getExtensions().maxDebugGroupStackDepth)
{
context->validationError(
GL_STACK_OVERFLOW,
"Cannot push more than GL_MAX_DEBUG_GROUP_STACK_DEPTH debug groups.");
context->validationError(GL_STACK_OVERFLOW, kExceedsMaxDebugGroupStackDepth);
return false;
}
......@@ -2277,7 +2254,7 @@ bool ValidatePopDebugGroupKHR(Context *context)
size_t currentStackSize = context->getGLState().getDebug().getGroupStackDepth();
if (currentStackSize <= 1)
{
context->validationError(GL_STACK_UNDERFLOW, "Cannot pop the default debug group.");
context->validationError(GL_STACK_UNDERFLOW, kCannotPopDefaultDebugGroup);
return false;
}
......@@ -2291,7 +2268,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_BUFFER:
if (context->getBuffer(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid buffer.");
context->validationError(GL_INVALID_VALUE, kInvalidBufferName);
return false;
}
return true;
......@@ -2299,7 +2276,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_SHADER:
if (context->getShader(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid shader.");
context->validationError(GL_INVALID_VALUE, kInvalidShaderName);
return false;
}
return true;
......@@ -2307,7 +2284,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_PROGRAM:
if (context->getProgramNoResolveLink(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid program.");
context->validationError(GL_INVALID_VALUE, kInvalidProgramName);
return false;
}
return true;
......@@ -2315,7 +2292,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_VERTEX_ARRAY:
if (context->getVertexArray(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid vertex array.");
context->validationError(GL_INVALID_VALUE, kInvalidVertexArrayName);
return false;
}
return true;
......@@ -2323,7 +2300,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_QUERY:
if (context->getQuery(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid query.");
context->validationError(GL_INVALID_VALUE, kInvalidQueryName);
return false;
}
return true;
......@@ -2331,8 +2308,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_TRANSFORM_FEEDBACK:
if (context->getTransformFeedback(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE,
"name is not a valid transform feedback.");
context->validationError(GL_INVALID_VALUE, kInvalidTransformFeedbackName);
return false;
}
return true;
......@@ -2340,7 +2316,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_SAMPLER:
if (context->getSampler(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid sampler.");
context->validationError(GL_INVALID_VALUE, kInvalidSamplerName);
return false;
}
return true;
......@@ -2348,7 +2324,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_TEXTURE:
if (context->getTexture(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid texture.");
context->validationError(GL_INVALID_VALUE, kInvalidTextureName);
return false;
}
return true;
......@@ -2356,7 +2332,7 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_RENDERBUFFER:
if (context->getRenderbuffer(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid renderbuffer.");
context->validationError(GL_INVALID_VALUE, kInvalidRenderbufferName);
return false;
}
return true;
......@@ -2364,13 +2340,13 @@ static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier,
case GL_FRAMEBUFFER:
if (context->getFramebuffer(name) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid framebuffer.");
context->validationError(GL_INVALID_VALUE, kInvalidFramebufferName);
return false;
}
return true;
default:
context->validationError(GL_INVALID_ENUM, "Invalid identifier.");
context->validationError(GL_INVALID_ENUM, kInvalidIndentifier);
return false;
}
}
......@@ -2393,8 +2369,7 @@ static bool ValidateLabelLength(Context *context, GLsizei length, const GLchar *
if (labelLength > context->getExtensions().maxLabelLength)
{
context->validationError(GL_INVALID_VALUE,
"Label length is larger than GL_MAX_LABEL_LENGTH.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxLabelLength);
return false;
}
......@@ -2457,7 +2432,7 @@ static bool ValidateObjectPtrName(Context *context, const void *ptr)
{
if (context->getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))) == nullptr)
{
context->validationError(GL_INVALID_VALUE, "name is not a valid sync.");
context->validationError(GL_INVALID_VALUE, kInvalidSyncPointer);
return false;
}
......@@ -2712,11 +2687,7 @@ bool ValidateClear(Context *context, GLbitfield mask)
Framebuffer *framebuffer = state.getDrawFramebuffer();
if (framebuffer->getNumViews() > 1 && state.isQueryActive(QueryType::TimeElapsed))
{
context->validationError(GL_INVALID_OPERATION,
"There is an active query for target "
"GL_TIME_ELAPSED_EXT when the number of "
"views in the active draw framebuffer is "
"greater than 1.");
context->validationError(GL_INVALID_OPERATION, kMultiviewTimerQuery);
return false;
}
}
......@@ -2728,7 +2699,7 @@ bool ValidateDrawBuffersEXT(Context *context, GLsizei n, const GLenum *bufs)
{
if (!context->getExtensions().drawBuffers)
{
context->validationError(GL_INVALID_OPERATION, "Extension not supported.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -2888,8 +2859,7 @@ bool ValidateCompressedTexImage2D(Context *context,
if (target == TextureTarget::Rectangle)
{
context->validationError(GL_INVALID_ENUM,
"Rectangle texture cannot have a compressed format.");
context->validationError(GL_INVALID_ENUM, kRectangleTextureCompressed);
return false;
}
......@@ -2989,6 +2959,12 @@ bool ValidateGetBufferPointervOES(Context *context,
GLenum pname,
void **params)
{
if (!context->getExtensions().mapBuffer)
{
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGetBufferPointervBase(context, target, pname, nullptr, params);
}
......@@ -2996,7 +2972,7 @@ bool ValidateMapBufferOES(Context *context, BufferBinding target, GLenum access)
{
if (!context->getExtensions().mapBuffer)
{
context->validationError(GL_INVALID_OPERATION, "Map buffer extension not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3010,19 +2986,19 @@ bool ValidateMapBufferOES(Context *context, BufferBinding target, GLenum access)
if (buffer == nullptr)
{
context->validationError(GL_INVALID_OPERATION, "Attempted to map buffer object zero.");
context->validationError(GL_INVALID_OPERATION, kBufferNotMappable);
return false;
}
if (access != GL_WRITE_ONLY_OES)
{
context->validationError(GL_INVALID_ENUM, "Non-write buffer mapping not supported.");
context->validationError(GL_INVALID_ENUM, kInvalidAccessBits);
return false;
}
if (buffer->isMapped())
{
context->validationError(GL_INVALID_OPERATION, "Buffer is already mapped.");
context->validationError(GL_INVALID_OPERATION, kBufferAlreadyMapped);
return false;
}
......@@ -3033,7 +3009,7 @@ bool ValidateUnmapBufferOES(Context *context, BufferBinding target)
{
if (!context->getExtensions().mapBuffer)
{
context->validationError(GL_INVALID_OPERATION, "Map buffer extension not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3048,7 +3024,7 @@ bool ValidateMapBufferRangeEXT(Context *context,
{
if (!context->getExtensions().mapBufferRange)
{
context->validationError(GL_INVALID_OPERATION, "Map buffer range extension not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3069,8 +3045,7 @@ bool ValidateMapBufferBase(Context *context, BufferBinding target)
const auto &transformFeedbackBuffer = transformFeedback->getIndexedBuffer(i);
if (transformFeedbackBuffer.get() == buffer)
{
context->validationError(GL_INVALID_OPERATION,
"Buffer is currently bound for transform feedback.");
context->validationError(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback);
return false;
}
}
......@@ -3093,7 +3068,7 @@ bool ValidateFlushMappedBufferRangeEXT(Context *context,
{
if (!context->getExtensions().mapBufferRange)
{
context->validationError(GL_INVALID_OPERATION, "Map buffer range extension not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3123,7 +3098,7 @@ bool ValidateBindTexture(Context *context, TextureType target, GLuint texture)
if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isTextureGenerated(texture))
{
context->validationError(GL_INVALID_OPERATION, "Texture was not generated");
context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated);
return false;
}
......@@ -3137,8 +3112,7 @@ bool ValidateBindUniformLocationCHROMIUM(Context *context,
{
if (!context->getExtensions().bindUniformLocation)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_bind_uniform_location is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3150,7 +3124,7 @@ bool ValidateBindUniformLocationCHROMIUM(Context *context,
if (location < 0)
{
context->validationError(GL_INVALID_VALUE, "Location cannot be less than 0.");
context->validationError(GL_INVALID_VALUE, kNegativeLocation);
return false;
}
......@@ -3158,10 +3132,7 @@ bool ValidateBindUniformLocationCHROMIUM(Context *context,
if (static_cast<size_t>(location) >=
(caps.maxVertexUniformVectors + caps.maxFragmentUniformVectors) * 4)
{
context->validationError(GL_INVALID_VALUE,
"Location must be less than "
"(MAX_VERTEX_UNIFORM_VECTORS + "
"MAX_FRAGMENT_UNIFORM_VECTORS) * 4");
context->validationError(GL_INVALID_VALUE, kInvalidBindUniformLocation);
return false;
}
......@@ -3186,8 +3157,7 @@ bool ValidateCoverageModulationCHROMIUM(Context *context, GLenum components)
{
if (!context->getExtensions().framebufferMixedSamples)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_framebuffer_mixed_samples is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
switch (components)
......@@ -3198,9 +3168,7 @@ bool ValidateCoverageModulationCHROMIUM(Context *context, GLenum components)
case GL_NONE:
break;
default:
context->validationError(
GL_INVALID_ENUM,
"GLenum components is not one of GL_RGB, GL_RGBA, GL_ALPHA or GL_NONE.");
context->validationError(GL_INVALID_ENUM, kInvalidCoverageComponents);
return false;
}
......@@ -3218,7 +3186,7 @@ bool ValidateMatrixLoadfCHROMIUM(Context *context, GLenum matrixMode, const GLfl
if (matrix == nullptr)
{
context->validationError(GL_INVALID_OPERATION, "Invalid matrix.");
context->validationError(GL_INVALID_OPERATION, kInvalidPathMatrix);
return false;
}
......@@ -3234,8 +3202,7 @@ bool ValidateGenPathsCHROMIUM(Context *context, GLsizei range)
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3260,8 +3227,7 @@ bool ValidateDeletePathsCHROMIUM(Context *context, GLuint path, GLsizei range)
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3294,8 +3260,7 @@ bool ValidatePathCommandsCHROMIUM(Context *context,
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (!context->isPathGenerated(path))
......@@ -3306,28 +3271,28 @@ bool ValidatePathCommandsCHROMIUM(Context *context,
if (numCommands < 0)
{
context->validationError(GL_INVALID_VALUE, "Invalid number of commands.");
context->validationError(GL_INVALID_VALUE, kInvalidPathNumCommands);
return false;
}
else if (numCommands > 0)
{
if (!commands)
{
context->validationError(GL_INVALID_VALUE, "No commands array given.");
context->validationError(GL_INVALID_VALUE, kInvalidPathCommandsArray);
return false;
}
}
if (numCoords < 0)
{
context->validationError(GL_INVALID_VALUE, "Invalid number of coordinates.");
context->validationError(GL_INVALID_VALUE, kInvalidPathNumCoords);
return false;
}
else if (numCoords > 0)
{
if (!coords)
{
context->validationError(GL_INVALID_VALUE, "No coordinate array given.");
context->validationError(GL_INVALID_VALUE, kInvalidPathNumCoordsArray);
return false;
}
}
......@@ -3356,7 +3321,7 @@ bool ValidatePathCommandsCHROMIUM(Context *context,
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid coordinate type.");
context->validationError(GL_INVALID_ENUM, kInvalidPathCoordinateType);
return false;
}
......@@ -3393,13 +3358,14 @@ bool ValidatePathCommandsCHROMIUM(Context *context,
expectedNumCoords += 5;
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid command.");
context->validationError(GL_INVALID_ENUM, kInvalidPathCommand);
return false;
}
}
if (expectedNumCoords != numCoords)
{
context->validationError(GL_INVALID_VALUE, "Invalid number of coordinates.");
context->validationError(GL_INVALID_VALUE, kInvalidPathNumCoords);
return false;
}
......@@ -3410,8 +3376,7 @@ bool ValidatePathParameterfCHROMIUM(Context *context, GLuint path, GLenum pname,
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (!context->isPathGenerated(path))
......@@ -3425,7 +3390,7 @@ bool ValidatePathParameterfCHROMIUM(Context *context, GLuint path, GLenum pname,
case GL_PATH_STROKE_WIDTH_CHROMIUM:
if (value < 0.0f)
{
context->validationError(GL_INVALID_VALUE, "Invalid stroke width.");
context->validationError(GL_INVALID_VALUE, kInvalidPathStrokeWidth);
return false;
}
break;
......@@ -3437,7 +3402,7 @@ bool ValidatePathParameterfCHROMIUM(Context *context, GLuint path, GLenum pname,
case GL_ROUND_CHROMIUM:
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid end caps.");
context->validationError(GL_INVALID_ENUM, kInvalidPathEndCaps);
return false;
}
break;
......@@ -3449,14 +3414,14 @@ bool ValidatePathParameterfCHROMIUM(Context *context, GLuint path, GLenum pname,
case GL_ROUND_CHROMIUM:
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid join style.");
context->validationError(GL_INVALID_ENUM, kInvalidPathJoinStyle);
return false;
}
break;
case GL_PATH_MITER_LIMIT_CHROMIUM:
if (value < 0.0f)
{
context->validationError(GL_INVALID_VALUE, "Invalid miter limit.");
context->validationError(GL_INVALID_VALUE, kInvalidPathMiterLimit);
return false;
}
break;
......@@ -3466,7 +3431,7 @@ bool ValidatePathParameterfCHROMIUM(Context *context, GLuint path, GLenum pname,
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid path parameter.");
context->validationError(GL_INVALID_ENUM, kInvalidPathParameter);
return false;
}
return true;
......@@ -3482,8 +3447,7 @@ bool ValidateGetPathParameterfvCHROMIUM(Context *context, GLuint path, GLenum pn
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3492,9 +3456,10 @@ bool ValidateGetPathParameterfvCHROMIUM(Context *context, GLuint path, GLenum pn
context->validationError(GL_INVALID_OPERATION, kNoSuchPath);
return false;
}
if (!value)
{
context->validationError(GL_INVALID_VALUE, "No value array.");
context->validationError(GL_INVALID_VALUE, kInvalidPathValueArray);
return false;
}
......@@ -3508,7 +3473,7 @@ bool ValidateGetPathParameterfvCHROMIUM(Context *context, GLuint path, GLenum pn
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid path parameter.");
context->validationError(GL_INVALID_ENUM, kInvalidPathParameter);
return false;
}
......@@ -3525,8 +3490,7 @@ bool ValidatePathStencilFuncCHROMIUM(Context *context, GLenum func, GLint ref, G
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3559,8 +3523,7 @@ bool ValidateStencilFillPathCHROMIUM(Context *context, GLuint path, GLenum fillM
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (context->isPathGenerated(path) && !context->isPath(path))
......@@ -3592,13 +3555,13 @@ bool ValidateStencilStrokePathCHROMIUM(Context *context, GLuint path, GLint refe
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (context->isPathGenerated(path) && !context->isPath(path))
{
context->validationError(GL_INVALID_OPERATION, "No such path or path has no data.");
context->validationError(GL_INVALID_OPERATION, kNoPathOrNoPathData);
return false;
}
......@@ -3609,8 +3572,7 @@ bool ValidateCoverPathCHROMIUM(Context *context, GLuint path, GLenum coverMode)
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (context->isPathGenerated(path) && !context->isPath(path))
......@@ -3665,8 +3627,7 @@ bool ValidateIsPathCHROMIUM(Context *context, GLuint path)
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return true;
......@@ -3857,15 +3818,14 @@ bool ValidateBindFragmentInputLocationCHROMIUM(Context *context,
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
const GLint MaxLocation = context->getCaps().maxVaryingVectors * 4;
if (location >= MaxLocation)
{
context->validationError(GL_INVALID_VALUE, "Location exceeds max varying.");
context->validationError(GL_INVALID_VALUE, kInvalidVaryingLocation);
return false;
}
......@@ -3878,7 +3838,7 @@ bool ValidateBindFragmentInputLocationCHROMIUM(Context *context,
if (!name)
{
context->validationError(GL_INVALID_VALUE, "No name given.");
context->validationError(GL_INVALID_VALUE, kMissingName);
return false;
}
......@@ -3900,8 +3860,7 @@ bool ValidateProgramPathFragmentInputGenCHROMIUM(Context *context,
{
if (!context->getExtensions().pathRendering)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_path_rendering is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -3923,7 +3882,7 @@ bool ValidateProgramPathFragmentInputGenCHROMIUM(Context *context,
case GL_NONE:
if (components != 0)
{
context->validationError(GL_INVALID_VALUE, "Invalid components.");
context->validationError(GL_INVALID_VALUE, kInvalidComponents);
return false;
}
break;
......@@ -3933,18 +3892,18 @@ bool ValidateProgramPathFragmentInputGenCHROMIUM(Context *context,
case GL_CONSTANT_CHROMIUM:
if (components < 1 || components > 4)
{
context->validationError(GL_INVALID_VALUE, "Invalid components.");
context->validationError(GL_INVALID_VALUE, kInvalidComponents);
return false;
}
if (!coeffs)
{
context->validationError(GL_INVALID_VALUE, "No coefficients array given.");
context->validationError(GL_INVALID_VALUE, kInvalidPathCoefficientsArray);
return false;
}
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid gen mode.");
context->validationError(GL_INVALID_ENUM, kInvalidPathGenMode);
return false;
}
......@@ -3957,7 +3916,7 @@ bool ValidateProgramPathFragmentInputGenCHROMIUM(Context *context,
if (!binding.valid)
{
context->validationError(GL_INVALID_OPERATION, "No such binding.");
context->validationError(GL_INVALID_OPERATION, kInvalidFragmentInputBinding);
return false;
}
......@@ -3979,14 +3938,12 @@ bool ValidateProgramPathFragmentInputGenCHROMIUM(Context *context,
expectedComponents = 4;
break;
default:
context->validationError(
GL_INVALID_OPERATION,
"Fragment input type is not a floating point scalar or vector.");
context->validationError(GL_INVALID_OPERATION, kFragmentInputTypeNotFloatingPoint);
return false;
}
if (expectedComponents != components && genMode != GL_NONE)
{
context->validationError(GL_INVALID_OPERATION, "Unexpected number of components");
context->validationError(GL_INVALID_OPERATION, kInvalidPathComponents);
return false;
}
}
......@@ -4007,15 +3964,14 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
{
if (!context->getExtensions().copyTexture)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_copy_texture extension not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
const Texture *source = context->getTexture(sourceId);
if (source == nullptr)
{
context->validationError(GL_INVALID_VALUE, "Source texture is not a valid texture object.");
context->validationError(GL_INVALID_VALUE, kInvalidSourceTexture);
return false;
}
......@@ -4031,7 +3987,7 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
if (!IsValidCopyTextureSourceLevel(context, sourceType, sourceLevel))
{
context->validationError(GL_INVALID_VALUE, "Source texture level is not valid.");
context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureLevel);
return false;
}
......@@ -4046,8 +4002,7 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
const InternalFormat &sourceFormat = *source->getFormat(sourceTarget, sourceLevel).info;
if (!IsValidCopyTextureSourceInternalFormatEnum(sourceFormat.internalFormat))
{
context->validationError(GL_INVALID_OPERATION,
"Source texture internal format is invalid.");
context->validationError(GL_INVALID_OPERATION, kInvalidSourceTextureInternalFormat);
return false;
}
......@@ -4060,14 +4015,13 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
const Texture *dest = context->getTexture(destId);
if (dest == nullptr)
{
context->validationError(GL_INVALID_VALUE,
"Destination texture is not a valid texture object.");
context->validationError(GL_INVALID_VALUE, kInvalidDestinationTexture);
return false;
}
if (!IsValidCopyTextureDestinationTarget(context, dest->getType(), destTarget))
{
context->validationError(GL_INVALID_VALUE, "Destination texture a valid texture type.");
context->validationError(GL_INVALID_VALUE, kInvalidDestinationTextureType);
return false;
}
......@@ -4085,14 +4039,13 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
if (dest->getType() == TextureType::CubeMap && sourceWidth != sourceHeight)
{
context->validationError(
GL_INVALID_VALUE, "Destination width and height must be equal for cube map textures.");
context->validationError(GL_INVALID_VALUE, kCubemapFacesEqualDimensions);
return false;
}
if (dest->getImmutableFormat())
{
context->validationError(GL_INVALID_OPERATION, "Destination texture is immutable.");
context->validationError(GL_INVALID_OPERATION, kDestinationImmutable);
return false;
}
......@@ -4117,21 +4070,20 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
{
if (!context->getExtensions().copyTexture)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_copy_texture extension not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
const Texture *source = context->getTexture(sourceId);
if (source == nullptr)
{
context->validationError(GL_INVALID_VALUE, "Source texture is not a valid texture object.");
context->validationError(GL_INVALID_VALUE, kInvalidSourceTexture);
return false;
}
if (!IsValidCopyTextureSourceTarget(context, source->getType()))
{
context->validationError(GL_INVALID_VALUE, "Source texture a valid texture type.");
context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureType);
return false;
}
......@@ -4148,14 +4100,13 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
if (source->getWidth(sourceTarget, sourceLevel) == 0 ||
source->getHeight(sourceTarget, sourceLevel) == 0)
{
context->validationError(GL_INVALID_VALUE,
"The source level of the source texture must be defined.");
context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureLevel);
return false;
}
if (x < 0 || y < 0)
{
context->validationError(GL_INVALID_VALUE, "x and y cannot be negative.");
context->validationError(GL_INVALID_VALUE, kNegativeOffset);
return false;
}
......@@ -4188,37 +4139,33 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
const Texture *dest = context->getTexture(destId);
if (dest == nullptr)
{
context->validationError(GL_INVALID_VALUE,
"Destination texture is not a valid texture object.");
context->validationError(GL_INVALID_VALUE, kInvalidDestinationTexture);
return false;
}
if (!IsValidCopyTextureDestinationTarget(context, dest->getType(), destTarget))
{
context->validationError(GL_INVALID_VALUE, "Destination texture a valid texture type.");
context->validationError(GL_INVALID_VALUE, kInvalidDestinationTextureType);
return false;
}
if (!IsValidCopyTextureDestinationLevel(context, dest->getType(), destLevel, width, height,
true))
{
context->validationError(GL_INVALID_VALUE, "Destination texture level is not valid.");
context->validationError(GL_INVALID_VALUE, kInvalidMipLevel);
return false;
}
if (dest->getWidth(destTarget, destLevel) == 0 || dest->getHeight(destTarget, destLevel) == 0)
{
context->validationError(
GL_INVALID_OPERATION,
"The destination level of the destination texture must be defined.");
context->validationError(GL_INVALID_OPERATION, kDestinationLevelNotDefined);
return false;
}
const InternalFormat &destFormat = *dest->getFormat(destTarget, destLevel).info;
if (!IsValidCopySubTextureDestionationInternalFormat(destFormat.internalFormat))
{
context->validationError(GL_INVALID_OPERATION,
"Destination internal format and type combination is not valid.");
context->validationError(GL_INVALID_OPERATION, kInvalidFormatCombination);
return false;
}
......@@ -4231,8 +4178,7 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
if (static_cast<size_t>(xoffset + width) > dest->getWidth(destTarget, destLevel) ||
static_cast<size_t>(yoffset + height) > dest->getHeight(destTarget, destLevel))
{
context->validationError(GL_INVALID_VALUE,
"Destination texture not large enough to copy to.");
context->validationError(GL_INVALID_VALUE, kOffsetOverflow);
return false;
}
......@@ -4243,57 +4189,53 @@ bool ValidateCompressedCopyTextureCHROMIUM(Context *context, GLuint sourceId, GL
{
if (!context->getExtensions().copyCompressedTexture)
{
context->validationError(GL_INVALID_OPERATION,
"GL_CHROMIUM_copy_compressed_texture extension not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
const gl::Texture *source = context->getTexture(sourceId);
if (source == nullptr)
{
context->validationError(GL_INVALID_VALUE, "Source texture is not a valid texture object.");
context->validationError(GL_INVALID_VALUE, kInvalidSourceTexture);
return false;
}
if (source->getType() != TextureType::_2D)
{
context->validationError(GL_INVALID_VALUE, "Source texture must be of type GL_TEXTURE_2D.");
context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureType);
return false;
}
if (source->getWidth(TextureTarget::_2D, 0) == 0 ||
source->getHeight(TextureTarget::_2D, 0) == 0)
{
context->validationError(GL_INVALID_VALUE, "Source texture must level 0 defined.");
context->validationError(GL_INVALID_VALUE, kSourceTextureLevelZeroDefined);
return false;
}
const gl::Format &sourceFormat = source->getFormat(TextureTarget::_2D, 0);
if (!sourceFormat.info->compressed)
{
context->validationError(GL_INVALID_OPERATION,
"Source texture must have a compressed internal format.");
context->validationError(GL_INVALID_OPERATION, kSourceTextureMustBeCompressed);
return false;
}
const gl::Texture *dest = context->getTexture(destId);
if (dest == nullptr)
{
context->validationError(GL_INVALID_VALUE,
"Destination texture is not a valid texture object.");
context->validationError(GL_INVALID_VALUE, kInvalidDestinationTexture);
return false;
}
if (dest->getType() != TextureType::_2D)
{
context->validationError(GL_INVALID_VALUE,
"Destination texture must be of type GL_TEXTURE_2D.");
context->validationError(GL_INVALID_VALUE, kInvalidDestinationTextureType);
return false;
}
if (dest->getImmutableFormat())
{
context->validationError(GL_INVALID_OPERATION, "Destination cannot be immutable.");
context->validationError(GL_INVALID_OPERATION, kDestinationImmutable);
return false;
}
......@@ -4459,14 +4401,13 @@ bool ValidateRequestExtensionANGLE(Context *context, const GLchar *name)
{
if (!context->getExtensions().requestExtension)
{
context->validationError(GL_INVALID_OPERATION,
"GL_ANGLE_request_extension is not available.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (!context->isExtensionRequestable(name))
{
context->validationError(GL_INVALID_OPERATION, "Extension is not requestable.");
context->validationError(GL_INVALID_OPERATION, kExtensionNotRequestable);
return false;
}
......@@ -4683,20 +4624,14 @@ bool ValidateBlendFuncSeparate(Context *context,
if (constantColorUsed && constantAlphaUsed)
{
const char *msg;
if (context->getExtensions().webglCompatibility)
{
msg = kInvalidConstantColor;
}
else
{
msg =
"Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and "
"GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not supported by this "
"implementation.";
WARN() << msg;
context->validationError(GL_INVALID_OPERATION, kInvalidConstantColor);
return false;
}
context->validationError(GL_INVALID_OPERATION, msg);
WARN() << kConstantColorAlphaLimitation;
context->validationError(GL_INVALID_OPERATION, kConstantColorAlphaLimitation);
return false;
}
}
......@@ -4766,15 +4701,13 @@ bool ValidateVertexAttribPointer(Context *context,
{
if (stride > caps.maxVertexAttribStride)
{
context->validationError(GL_INVALID_VALUE,
"stride cannot be greater than MAX_VERTEX_ATTRIB_STRIDE.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribStride);
return false;
}
if (index >= caps.maxVertexAttribBindings)
{
context->validationError(GL_INVALID_VALUE,
"index must be smaller than MAX_VERTEX_ATTRIB_BINDINGS.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribBindings);
return false;
}
}
......@@ -4788,9 +4721,7 @@ bool ValidateVertexAttribPointer(Context *context,
if (!nullBufferAllowed && context->getGLState().getTargetBuffer(BufferBinding::Array) == 0 &&
ptr != nullptr)
{
context->validationError(
GL_INVALID_OPERATION,
"Client data cannot be used with a non-default vertex array object.");
context->validationError(GL_INVALID_OPERATION, kClientDataInVertexArray);
return false;
}
......@@ -4800,7 +4731,7 @@ bool ValidateVertexAttribPointer(Context *context,
// The WebGL API does not support the GL_FIXED data type.
if (type == GL_FIXED)
{
context->validationError(GL_INVALID_ENUM, "GL_FIXED is not supported in WebGL.");
context->validationError(GL_INVALID_ENUM, kFixedNotInWebGL);
return false;
}
......@@ -4843,8 +4774,7 @@ bool ValidateRenderbufferStorageMultisampleANGLE(Context *context,
{
if (!context->getExtensions().framebufferMultisample)
{
context->validationError(GL_INVALID_OPERATION,
"GL_ANGLE_framebuffer_multisample not available");
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
......@@ -5274,8 +5204,7 @@ bool ValidateGetShaderPrecisionFormat(Context *context,
case GL_FRAGMENT_SHADER:
break;
case GL_COMPUTE_SHADER:
context->validationError(GL_INVALID_OPERATION,
"compute shader precision not yet implemented.");
context->validationError(GL_INVALID_OPERATION, kUnimplementedComputeShaderPrecision);
return false;
default:
context->validationError(GL_INVALID_ENUM, kInvalidShaderType);
......@@ -5375,8 +5304,7 @@ bool ValidateHint(Context *context, GLenum target, GLenum mode)
if (context->getClientVersion() < ES_3_0 &&
!context->getExtensions().standardDerivatives)
{
context->validationError(GL_INVALID_ENUM,
"hint requires OES_standard_derivatives.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
......@@ -5465,7 +5393,7 @@ bool ValidatePixelStorei(Context *context, GLenum pname, GLint param)
if (param < 0)
{
context->validationError(GL_INVALID_VALUE, "Cannot use negative values in PixelStorei");
context->validationError(GL_INVALID_VALUE, kNegativeParam);
return false;
}
......@@ -5549,7 +5477,7 @@ bool ValidateShaderBinary(Context *context,
if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) ==
shaderBinaryFormats.end())
{
context->validationError(GL_INVALID_ENUM, "Invalid shader binary format.");
context->validationError(GL_INVALID_ENUM, kInvalidShaderBinaryFormat);
return false;
}
......@@ -5950,12 +5878,11 @@ bool ValidateEnable(Context *context, GLenum cap)
if (context->getLimitations().noSampleAlphaToCoverageSupport &&
cap == GL_SAMPLE_ALPHA_TO_COVERAGE)
{
const char *errorMessage = "Current renderer doesn't support alpha-to-coverage";
context->validationError(GL_INVALID_OPERATION, errorMessage);
context->validationError(GL_INVALID_OPERATION, kNoSampleAlphaToCoveragesLimitation);
// We also output an error message to the debugger window if tracing is active, so that
// developers can see the error message.
ERR() << errorMessage;
ERR() << kNoSampleAlphaToCoveragesLimitation;
return false;
}
......@@ -6038,8 +5965,7 @@ bool ValidateFramebufferTexture2D(Context *context,
}
if (tex->getType() != TextureType::Rectangle)
{
context->validationError(GL_INVALID_OPERATION,
"Textarget must match the texture target type.");
context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch);
return false;
}
}
......@@ -6059,8 +5985,7 @@ bool ValidateFramebufferTexture2D(Context *context,
}
if (tex->getType() != TextureType::CubeMap)
{
context->validationError(GL_INVALID_OPERATION,
"Textarget must match the texture target type.");
context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch);
return false;
}
}
......@@ -6083,8 +6008,7 @@ bool ValidateFramebufferTexture2D(Context *context,
}
if (tex->getType() != TextureType::_2DMultisample)
{
context->validationError(GL_INVALID_OPERATION,
"Textarget must match the texture target type.");
context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch);
return false;
}
}
......@@ -6310,10 +6234,7 @@ bool ValidateLinkProgram(Context *context, GLuint program)
if (context->hasActiveTransformFeedback(program))
{
// ES 3.0.4 section 2.15 page 91
context->validationError(GL_INVALID_OPERATION,
"Cannot link program while program is "
"associated with an active transform "
"feedback object.");
context->validationError(GL_INVALID_OPERATION, kTransformFeedbackActiveDuringLink);
return false;
}
......@@ -6416,9 +6337,7 @@ bool ValidateUseProgram(Context *context, GLuint program)
if (context->getGLState().isTransformFeedbackActiveUnpaused())
{
// ES 3.0.4 section 2.15 page 91
context->validationError(
GL_INVALID_OPERATION,
"Cannot change active program while transform feedback is unpaused.");
context->validationError(GL_INVALID_OPERATION, kTransformFeedbackUseProgram);
return false;
}
......@@ -6663,16 +6582,11 @@ bool ValidateVertexAttribDivisorANGLE(Context *context, GLuint index, GLuint div
{
if (index == 0 && divisor != 0)
{
const char *errorMessage =
"The current context doesn't support setting a non-zero divisor on the "
"attribute with index zero. "
"Please reorder the attributes in your vertex shader so that attribute zero "
"can have a zero divisor.";
context->validationError(GL_INVALID_OPERATION, errorMessage);
context->validationError(GL_INVALID_OPERATION, kAttributeZeroRequiresDivisorLimitation);
// We also output an error message to the debugger window if tracing is active, so
// that developers can see the error message.
ERR() << errorMessage;
ERR() << kAttributeZeroRequiresDivisorLimitation;
return false;
}
}
......
......@@ -449,7 +449,7 @@ bool ValidateES3TexImageParametersBase(Context *context,
isSubImage ? texture->getFormat(target, level).info->internalFormat : internalformat;
if (isSubImage && actualInternalFormat == GL_NONE)
{
context->validationError(GL_INVALID_OPERATION, "Texture level does not exist.");
context->validationError(GL_INVALID_OPERATION, kInvalidMipLevel);
return false;
}
......@@ -460,8 +460,7 @@ bool ValidateES3TexImageParametersBase(Context *context,
{
if (!actualFormatInfo.compressed)
{
context->validationError(
GL_INVALID_ENUM, "internalformat is not a supported compressed internal format.");
context->validationError(GL_INVALID_ENUM, kCompressedMismatch);
return false;
}
......@@ -471,15 +470,13 @@ bool ValidateES3TexImageParametersBase(Context *context,
context, actualFormatInfo.internalFormat, xoffset, yoffset, width, height,
texture->getWidth(target, level), texture->getHeight(target, level)))
{
context->validationError(GL_INVALID_OPERATION,
"Invalid compressed format dimension.");
context->validationError(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
return false;
}
if (format != actualInternalFormat)
{
context->validationError(GL_INVALID_OPERATION,
"Format must match the internal format of the texture.");
context->validationError(GL_INVALID_OPERATION, kMismatchedFormat);
return false;
}
......@@ -493,8 +490,7 @@ bool ValidateES3TexImageParametersBase(Context *context,
{
if (!ValidCompressedImageSize(context, actualInternalFormat, level, width, height))
{
context->validationError(GL_INVALID_OPERATION,
"Invalid compressed format dimension.");
context->validationError(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
return false;
}
}
......@@ -581,8 +577,7 @@ bool ValidateES3TexImageParametersBase(Context *context,
if ((offset % dataBytesPerPixel) != 0)
{
context->validationError(GL_INVALID_OPERATION,
"Reads would overflow the pixel unpack buffer.");
context->validationError(GL_INVALID_OPERATION, kDataTypeNotAligned);
return false;
}
}
......@@ -590,7 +585,7 @@ bool ValidateES3TexImageParametersBase(Context *context,
// ...the buffer object's data store is currently mapped.
if (pixelUnpackBuffer->isMapped())
{
context->validationError(GL_INVALID_OPERATION, "Pixel unpack buffer is mapped.");
context->validationError(GL_INVALID_OPERATION, kBufferMapped);
return false;
}
}
......@@ -1424,7 +1419,7 @@ bool ValidateDrawRangeElements(Context *context,
if (end < start)
{
context->validationError(GL_INVALID_VALUE, "end < start");
context->validationError(GL_INVALID_VALUE, kInvalidElementRange);
return false;
}
......@@ -1447,7 +1442,7 @@ bool ValidateDrawRangeElements(Context *context,
if (indexRange.end > end || indexRange.start < start)
{
// GL spec says that behavior in this case is undefined - generating an error is fine.
context->validationError(GL_INVALID_OPERATION, "Indices are out of the start, end range.");
context->validationError(GL_INVALID_OPERATION, kExceedsElementRange);
return false;
}
return true;
......@@ -1476,7 +1471,7 @@ bool ValidateReadBuffer(Context *context, GLenum src)
if (readFBO == nullptr)
{
context->validationError(GL_INVALID_OPERATION, "No active read framebuffer.");
context->validationError(GL_INVALID_OPERATION, kNoReadFramebuffer);
return false;
}
......@@ -1487,7 +1482,7 @@ bool ValidateReadBuffer(Context *context, GLenum src)
if (src != GL_BACK && (src < GL_COLOR_ATTACHMENT0 || src > GL_COLOR_ATTACHMENT31))
{
context->validationError(GL_INVALID_ENUM, "Unknown enum for 'src' in ReadBuffer");
context->validationError(GL_INVALID_ENUM, kInvalidReadBuffer);
return false;
}
......@@ -1495,9 +1490,7 @@ bool ValidateReadBuffer(Context *context, GLenum src)
{
if (src != GL_BACK)
{
context->validationError(
GL_INVALID_OPERATION,
"'src' must be GL_NONE or GL_BACK when reading from the default framebuffer.");
context->validationError(GL_INVALID_OPERATION, kInvalidDefaultReadBuffer);
return false;
}
}
......@@ -1507,8 +1500,7 @@ bool ValidateReadBuffer(Context *context, GLenum src)
if (drawBuffer >= context->getCaps().maxDrawBuffers)
{
context->validationError(GL_INVALID_OPERATION,
"'src' is greater than MAX_DRAW_BUFFERS.");
context->validationError(GL_INVALID_OPERATION, kExceedsMaxDrawBuffers);
return false;
}
}
......@@ -1569,8 +1561,7 @@ bool ValidateCompressedTexImage3D(Context *context,
// 3D texture target validation
if (target != TextureType::_3D && target != TextureType::_2DArray)
{
context->validationError(GL_INVALID_ENUM,
"Must specify a valid 3D texture destination target");
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
return false;
}
......@@ -1643,14 +1634,14 @@ static bool ValidateBindBufferCommon(Context *context,
if (buffer != 0 && offset < 0)
{
context->validationError(GL_INVALID_VALUE, "buffer is non-zero and offset is negative.");
context->validationError(GL_INVALID_VALUE, kNegativeOffset);
return false;
}
if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isBufferGenerated(buffer))
{
context->validationError(GL_INVALID_OPERATION, "Buffer was not generated.");
context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated);
return false;
}
......@@ -1662,15 +1653,12 @@ static bool ValidateBindBufferCommon(Context *context,
if (index >= caps.maxTransformFeedbackSeparateAttributes)
{
context->validationError(GL_INVALID_VALUE,
"index is greater than or equal to the "
"number of TRANSFORM_FEEDBACK_BUFFER "
"indexed binding points.");
kIndexExceedsTransformFeedbackBufferBindings);
return false;
}
if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
{
context->validationError(GL_INVALID_VALUE,
"offset and size must be multiple of 4.");
context->validationError(GL_INVALID_VALUE, kOffsetAndSizeAlignment);
return false;
}
......@@ -1678,9 +1666,7 @@ static bool ValidateBindBufferCommon(Context *context,
context->getGLState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive())
{
context->validationError(GL_INVALID_OPERATION,
"target is TRANSFORM_FEEDBACK_BUFFER and transform "
"feedback is currently active.");
context->validationError(GL_INVALID_OPERATION, kTransformFeedbackTargetActive);
return false;
}
break;
......@@ -1689,19 +1675,14 @@ static bool ValidateBindBufferCommon(Context *context,
{
if (index >= caps.maxUniformBufferBindings)
{
context->validationError(GL_INVALID_VALUE,
"index is greater than or equal to the "
"number of UNIFORM_BUFFER indexed "
"binding points.");
context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxUniformBufferBindings);
return false;
}
ASSERT(caps.uniformBufferOffsetAlignment);
if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
{
context->validationError(
GL_INVALID_VALUE,
"offset must be multiple of value of UNIFORM_BUFFER_OFFSET_ALIGNMENT.");
context->validationError(GL_INVALID_VALUE, kUniformBufferOffsetAlignment);
return false;
}
break;
......@@ -1710,21 +1691,18 @@ static bool ValidateBindBufferCommon(Context *context,
{
if (context->getClientVersion() < ES_3_1)
{
context->validationError(GL_INVALID_ENUM,
"ATOMIC_COUNTER_BUFFER is not supported before GLES 3.1");
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES31);
return false;
}
if (index >= caps.maxAtomicCounterBufferBindings)
{
context->validationError(GL_INVALID_VALUE,
"index is greater than or equal to the "
"number of ATOMIC_COUNTER_BUFFER "
"indexed binding points.");
kIndexExceedsMaxAtomicCounterBufferBindings);
return false;
}
if (buffer != 0 && (offset % 4) != 0)
{
context->validationError(GL_INVALID_VALUE, "offset must be a multiple of 4.");
context->validationError(GL_INVALID_VALUE, kOffsetAlignment);
return false;
}
break;
......@@ -1733,31 +1711,24 @@ static bool ValidateBindBufferCommon(Context *context,
{
if (context->getClientVersion() < ES_3_1)
{
context->validationError(GL_INVALID_ENUM,
"SHADER_STORAGE_BUFFER is not supported in GLES3.");
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES31);
return false;
}
if (index >= caps.maxShaderStorageBufferBindings)
{
context->validationError(GL_INVALID_VALUE,
"index is greater than or equal to the "
"number of SHADER_STORAGE_BUFFER "
"indexed binding points.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxShaderStorageBufferBindings);
return false;
}
ASSERT(caps.shaderStorageBufferOffsetAlignment);
if (buffer != 0 && (offset % caps.shaderStorageBufferOffsetAlignment) != 0)
{
context->validationError(GL_INVALID_VALUE,
"offset must be multiple of value of "
"SHADER_STORAGE_BUFFER_OFFSET_"
"ALIGNMENT.");
context->validationError(GL_INVALID_VALUE, kShaderStorageBufferOffsetAlignment);
return false;
}
break;
}
default:
context->validationError(GL_INVALID_ENUM, "the target is not supported.");
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
......@@ -1778,8 +1749,7 @@ bool ValidateBindBufferRange(Context *context,
{
if (buffer != 0 && size <= 0)
{
context->validationError(GL_INVALID_VALUE,
"buffer is non-zero and size is less than or equal to zero.");
context->validationError(GL_INVALID_VALUE, kInvalidBindBufferSize);
return false;
}
return ValidateBindBufferCommon(context, target, index, buffer, offset, size);
......@@ -2418,8 +2388,7 @@ bool ValidateDeleteTransformFeedbacks(Context *context, GLint n, const GLuint *i
if (transformFeedback != nullptr && transformFeedback->isActive())
{
// ES 3.0.4 section 2.15.1 page 86
context->validationError(GL_INVALID_OPERATION,
"Attempt to delete active transform feedback.");
context->validationError(GL_INVALID_OPERATION, kTransformFeedbackActiveDelete);
return false;
}
}
......@@ -2451,7 +2420,7 @@ bool ValidateBeginTransformFeedback(Context *context, PrimitiveMode primitiveMod
break;
default:
context->validationError(GL_INVALID_ENUM, "Invalid primitive mode.");
context->validationError(GL_INVALID_ENUM, kInvalidPrimitiveMode);
return false;
}
......@@ -2460,7 +2429,7 @@ bool ValidateBeginTransformFeedback(Context *context, PrimitiveMode primitiveMod
if (transformFeedback->isActive())
{
context->validationError(GL_INVALID_OPERATION, "Transform feedback is already active.");
context->validationError(GL_INVALID_OPERATION, kTransfomFeedbackAlreadyActive);
return false;
}
......@@ -2471,8 +2440,7 @@ bool ValidateBeginTransformFeedback(Context *context, PrimitiveMode primitiveMod
{
if (buffer->isMapped())
{
context->validationError(GL_INVALID_OPERATION,
"Transform feedback has a mapped buffer.");
context->validationError(GL_INVALID_OPERATION, kBufferMapped);
return false;
}
if ((context->getLimitations().noDoubleBoundTransformFeedbackBuffers ||
......@@ -2505,6 +2473,12 @@ bool ValidateBeginTransformFeedback(Context *context, PrimitiveMode primitiveMod
bool ValidateGetBufferPointerv(Context *context, BufferBinding target, GLenum pname, void **params)
{
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_OPERATION, kES3Required);
return false;
}
return ValidateGetBufferPointervBase(context, target, pname, nullptr, params);
}
......@@ -2522,6 +2496,12 @@ bool ValidateGetBufferPointervRobustANGLE(Context *context,
GLsizei numParams = 0;
if (context->getClientMajorVersion() < 3 && !context->getExtensions().mapBuffer)
{
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (!ValidateGetBufferPointervBase(context, target, pname, &numParams, params))
{
return false;
......@@ -2651,9 +2631,7 @@ bool ValidateIndexedStateQuery(Context *context, GLenum pname, GLuint index, GLs
}
if (index >= caps.maxShaderStorageBufferBindings)
{
context->validationError(
GL_INVALID_VALUE,
"index is outside the valid range for GL_SHADER_STORAGE_BUFFER_BINDING");
context->validationError(GL_INVALID_VALUE, kExceedsMaxShaderStorageBufferBindings);
return false;
}
break;
......@@ -2669,9 +2647,7 @@ bool ValidateIndexedStateQuery(Context *context, GLenum pname, GLuint index, GLs
}
if (index >= caps.maxVertexAttribBindings)
{
context->validationError(
GL_INVALID_VALUE,
"bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribBindings);
return false;
}
break;
......@@ -2700,7 +2676,7 @@ bool ValidateIndexedStateQuery(Context *context, GLenum pname, GLuint index, GLs
}
if (index >= caps.maxImageUnits)
{
context->validationError(GL_INVALID_VALUE, kInvalidImageUnit);
context->validationError(GL_INVALID_VALUE, kExceedsMaxImageUnits);
return false;
}
break;
......@@ -2831,15 +2807,14 @@ bool ValidateCopyBufferSubData(Context *context,
if (!readBuffer || !writeBuffer)
{
context->validationError(GL_INVALID_OPERATION, "No buffer bound to target");
context->validationError(GL_INVALID_OPERATION, kBufferNotBound);
return false;
}
// Verify that readBuffer and writeBuffer are not currently mapped
if (readBuffer->isMapped() || writeBuffer->isMapped())
{
context->validationError(GL_INVALID_OPERATION,
"Cannot call CopyBufferSubData on a mapped buffer");
context->validationError(GL_INVALID_OPERATION, kBufferMapped);
return false;
}
......@@ -2866,17 +2841,22 @@ bool ValidateCopyBufferSubData(Context *context,
return false;
}
if (readOffset < 0 || writeOffset < 0 || size < 0)
if (readOffset < 0 || writeOffset < 0)
{
context->validationError(GL_INVALID_VALUE, kNegativeOffset);
return false;
}
if (size < 0)
{
context->validationError(GL_INVALID_VALUE,
"readOffset, writeOffset and size must all be non-negative");
context->validationError(GL_INVALID_VALUE, kNegativeSize);
return false;
}
if (checkedReadSum.ValueOrDie() > readBuffer->getSize() ||
checkedWriteSum.ValueOrDie() > writeBuffer->getSize())
{
context->validationError(GL_INVALID_VALUE, "Buffer offset overflow in CopyBufferSubData");
context->validationError(GL_INVALID_VALUE, kBufferOffsetOverflow);
return false;
}
......@@ -2914,8 +2894,7 @@ bool ValidateGetStringi(Context *context, GLenum name, GLuint index)
case GL_EXTENSIONS:
if (index >= context->getExtensionStringCount())
{
context->validationError(
GL_INVALID_VALUE, "index must be less than the number of extension strings.");
context->validationError(GL_INVALID_VALUE, kExceedsNumExtensions);
return false;
}
break;
......@@ -2928,9 +2907,7 @@ bool ValidateGetStringi(Context *context, GLenum name, GLuint index)
}
if (index >= context->getRequestableExtensionStringCount())
{
context->validationError(
GL_INVALID_VALUE,
"index must be less than the number of requestable extension strings.");
context->validationError(GL_INVALID_VALUE, kExceedsNumRequestableExtensions);
return false;
}
break;
......@@ -3016,8 +2993,7 @@ bool ValidateVertexAttribIPointer(Context *context,
{
if (stride > caps.maxVertexAttribStride)
{
context->validationError(GL_INVALID_VALUE,
"stride cannot be greater than MAX_VERTEX_ATTRIB_STRIDE.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribStride);
return false;
}
......@@ -3026,8 +3002,7 @@ bool ValidateVertexAttribIPointer(Context *context,
// validation should be inherited.
if (index >= caps.maxVertexAttribBindings)
{
context->validationError(GL_INVALID_VALUE,
"index must be smaller than MAX_VERTEX_ATTRIB_BINDINGS.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribBindings);
return false;
}
}
......@@ -3039,9 +3014,7 @@ bool ValidateVertexAttribIPointer(Context *context,
if (context->getGLState().getVertexArrayId() != 0 &&
context->getGLState().getTargetBuffer(BufferBinding::Array) == 0 && pointer != nullptr)
{
context->validationError(
GL_INVALID_OPERATION,
"Client data cannot be used with a non-default vertex array object.");
context->validationError(GL_INVALID_OPERATION, kClientDataInVertexArray);
return false;
}
......@@ -3078,7 +3051,7 @@ bool ValidateGetSynciv(Context *context,
Sync *syncObject = context->getSync(sync);
if (!syncObject)
{
context->validationError(GL_INVALID_VALUE, "Invalid sync object.");
context->validationError(GL_INVALID_VALUE, kSyncMissing);
return false;
}
......@@ -3203,7 +3176,7 @@ bool ValidateFramebufferTextureMultiviewLayeredANGLE(Context *context,
{
if (baseViewIndex < 0)
{
context->validationError(GL_INVALID_VALUE, "baseViewIndex cannot be less than 0.");
context->validationError(GL_INVALID_VALUE, kNegativeBaseViewIndex);
return false;
}
......@@ -3219,8 +3192,7 @@ bool ValidateFramebufferTextureMultiviewLayeredANGLE(Context *context,
{
if (!context->getExtensions().multiviewMultisample)
{
context->validationError(GL_INVALID_OPERATION,
"Texture's target must be GL_TEXTURE_2D_ARRAY.");
context->validationError(GL_INVALID_OPERATION, kInvalidTextureType);
return false;
}
}
......@@ -3228,18 +3200,14 @@ bool ValidateFramebufferTextureMultiviewLayeredANGLE(Context *context,
const Caps &caps = context->getCaps();
if (static_cast<GLuint>(baseViewIndex + numViews) > caps.maxArrayTextureLayers)
{
context->validationError(GL_INVALID_VALUE,
"baseViewIndex+numViews cannot be "
"greater than "
"GL_MAX_ARRAY_TEXTURE_LAYERS.");
context->validationError(GL_INVALID_VALUE, kViewsExceedMaxArrayLayers);
return false;
}
break;
}
default:
context->validationError(GL_INVALID_OPERATION,
"Texture's target must be GL_TEXTURE_2D_ARRAY.");
context->validationError(GL_INVALID_OPERATION, kInvalidTextureType);
return false;
}
......@@ -3273,8 +3241,7 @@ bool ValidateFramebufferTextureMultiviewSideBySideANGLE(Context *context,
{
if (viewportOffsets[i] < 0)
{
context->validationError(GL_INVALID_VALUE,
"viewportOffsets cannot contain negative values.");
context->validationError(GL_INVALID_VALUE, kNegativeOffset);
return false;
}
}
......@@ -3287,8 +3254,7 @@ bool ValidateFramebufferTextureMultiviewSideBySideANGLE(Context *context,
case TextureType::_2D:
break;
default:
context->validationError(GL_INVALID_OPERATION,
"Texture's target must be GL_TEXTURE_2D.");
context->validationError(GL_INVALID_OPERATION, kInvalidTextureType);
return false;
}
......
......@@ -548,9 +548,7 @@ bool ValidateDrawElementsIndirect(Context *context,
if (!checkedSum.IsValid() ||
checkedSum.ValueOrDie() > static_cast<size_t>(drawIndirectBuffer->getSize()))
{
context->validationError(
GL_INVALID_OPERATION,
"the command would source data beyond the end of the buffer object.");
context->validationError(GL_INVALID_OPERATION, kParamOverflow);
return false;
}
......@@ -999,9 +997,7 @@ bool ValidateFramebufferParameteri(Context *context, GLenum target, GLenum pname
GLint maxWidth = context->getCaps().maxFramebufferWidth;
if (param < 0 || param > maxWidth)
{
context->validationError(
GL_INVALID_VALUE,
"Params less than 0 or greater than GL_MAX_FRAMEBUFFER_WIDTH.");
context->validationError(GL_INVALID_VALUE, kExceedsFramebufferWidth);
return false;
}
break;
......@@ -1011,9 +1007,7 @@ bool ValidateFramebufferParameteri(Context *context, GLenum target, GLenum pname
GLint maxHeight = context->getCaps().maxFramebufferHeight;
if (param < 0 || param > maxHeight)
{
context->validationError(
GL_INVALID_VALUE,
"Params less than 0 or greater than GL_MAX_FRAMEBUFFER_HEIGHT.");
context->validationError(GL_INVALID_VALUE, kExceedsFramebufferHeight);
return false;
}
break;
......@@ -1023,9 +1017,7 @@ bool ValidateFramebufferParameteri(Context *context, GLenum target, GLenum pname
GLint maxSamples = context->getCaps().maxFramebufferSamples;
if (param < 0 || param > maxSamples)
{
context->validationError(
GL_INVALID_VALUE,
"Params less than 0 or greater than GL_MAX_FRAMEBUFFER_SAMPLES.");
context->validationError(GL_INVALID_VALUE, kExceedsFramebufferSamples);
return false;
}
break;
......@@ -1060,7 +1052,7 @@ bool ValidateFramebufferParameteri(Context *context, GLenum target, GLenum pname
ASSERT(framebuffer);
if (framebuffer->id() == 0)
{
context->validationError(GL_INVALID_OPERATION, "Default framebuffer is bound to target.");
context->validationError(GL_INVALID_OPERATION, kDefaultFramebuffer);
return false;
}
return true;
......@@ -1104,7 +1096,7 @@ bool ValidateGetFramebufferParameteriv(Context *context, GLenum target, GLenum p
if (framebuffer->id() == 0)
{
context->validationError(GL_INVALID_OPERATION, "Default framebuffer is bound to target.");
context->validationError(GL_INVALID_OPERATION, kDefaultFramebuffer);
return false;
}
return true;
......@@ -1140,7 +1132,7 @@ bool ValidateGetProgramResourceIndex(Context *context,
if (!ValidateNamedProgramInterface(programInterface))
{
context->validationError(GL_INVALID_ENUM, "Invalid program interface");
context->validationError(GL_INVALID_ENUM, kInvalidProgramInterface);
return false;
}
......@@ -1161,15 +1153,14 @@ bool ValidateBindVertexBuffer(Context *context,
if (!context->isBufferGenerated(buffer))
{
context->validationError(GL_INVALID_OPERATION, "Buffer is not generated.");
context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated);
return false;
}
const Caps &caps = context->getCaps();
if (bindingIndex >= caps.maxVertexAttribBindings)
{
context->validationError(GL_INVALID_VALUE,
"bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribBindings);
return false;
}
......@@ -1181,8 +1172,7 @@ bool ValidateBindVertexBuffer(Context *context,
if (stride < 0 || stride > caps.maxVertexAttribStride)
{
context->validationError(GL_INVALID_VALUE,
"stride must be between 0 and MAX_VERTEX_ATTRIB_STRIDE.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribStride);
return false;
}
......@@ -1190,7 +1180,7 @@ bool ValidateBindVertexBuffer(Context *context,
// An INVALID_OPERATION error is generated if the default vertex array object is bound.
if (context->getGLState().getVertexArrayId() == 0)
{
context->validationError(GL_INVALID_OPERATION, "Default vertex array buffer is bound.");
context->validationError(GL_INVALID_OPERATION, kDefaultVertexArray);
return false;
}
......@@ -1208,8 +1198,7 @@ bool ValidateVertexBindingDivisor(Context *context, GLuint bindingIndex, GLuint
const Caps &caps = context->getCaps();
if (bindingIndex >= caps.maxVertexAttribBindings)
{
context->validationError(GL_INVALID_VALUE,
"bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS.");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribBindings);
return false;
}
......@@ -1217,7 +1206,7 @@ bool ValidateVertexBindingDivisor(Context *context, GLuint bindingIndex, GLuint
// An INVALID_OPERATION error is generated if the default vertex array object is bound.
if (context->getGLState().getVertexArrayId() == 0)
{
context->validationError(GL_INVALID_OPERATION, "Default vertex array object is bound.");
context->validationError(GL_INVALID_OPERATION, kDefaultVertexArray);
return false;
}
......@@ -1256,7 +1245,7 @@ bool ValidateVertexAttribBinding(Context *context, GLuint attribIndex, GLuint bi
// An INVALID_OPERATION error is generated if the default vertex array object is bound.
if (context->getGLState().getVertexArrayId() == 0)
{
context->validationError(GL_INVALID_OPERATION, "Default vertex array object is bound.");
context->validationError(GL_INVALID_OPERATION, kDefaultVertexArray);
return false;
}
......@@ -1269,8 +1258,7 @@ bool ValidateVertexAttribBinding(Context *context, GLuint attribIndex, GLuint bi
if (bindingIndex >= caps.maxVertexAttribBindings)
{
context->validationError(GL_INVALID_VALUE,
"bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS");
context->validationError(GL_INVALID_VALUE, kExceedsMaxVertexAttribBindings);
return false;
}
......@@ -1299,13 +1287,13 @@ bool ValidateGetProgramResourceName(Context *context,
if (!ValidateNamedProgramInterface(programInterface))
{
context->validationError(GL_INVALID_ENUM, "Invalid program interface");
context->validationError(GL_INVALID_ENUM, kInvalidProgramInterface);
return false;
}
if (!ValidateProgramResourceIndex(programObject, programInterface, index))
{
context->validationError(GL_INVALID_VALUE, "Invalid index");
context->validationError(GL_INVALID_VALUE, kInvalidProgramResourceIndex);
return false;
}
......@@ -1341,23 +1329,17 @@ bool ValidateDispatchCompute(Context *context,
const Caps &caps = context->getCaps();
if (numGroupsX > caps.maxComputeWorkGroupCount[0])
{
context->validationError(
GL_INVALID_VALUE,
"num_groups_x cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[0]");
context->validationError(GL_INVALID_VALUE, kExceedsComputeWorkGroupCountX);
return false;
}
if (numGroupsY > caps.maxComputeWorkGroupCount[1])
{
context->validationError(
GL_INVALID_VALUE,
"num_groups_y cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[1]");
context->validationError(GL_INVALID_VALUE, kExceedsComputeWorkGroupCountY);
return false;
}
if (numGroupsZ > caps.maxComputeWorkGroupCount[2])
{
context->validationError(
GL_INVALID_VALUE,
"num_groups_z cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[2]");
context->validationError(GL_INVALID_VALUE, kExceedsComputeWorkGroupCountZ);
return false;
}
......@@ -1424,26 +1406,25 @@ bool ValidateBindImageTexture(Context *context,
GLuint maxImageUnits = context->getCaps().maxImageUnits;
if (unit >= maxImageUnits)
{
context->validationError(GL_INVALID_VALUE,
"unit cannot be greater than or equal than MAX_IMAGE_UNITS");
context->validationError(GL_INVALID_VALUE, kExceedsMaxImageUnits);
return false;
}
if (level < 0)
{
context->validationError(GL_INVALID_VALUE, "level is negative.");
context->validationError(GL_INVALID_VALUE, kNegativeLevel);
return false;
}
if (layer < 0)
{
context->validationError(GL_INVALID_VALUE, "layer is negative.");
context->validationError(GL_INVALID_VALUE, kNegativeLayer);
return false;
}
if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE)
{
context->validationError(GL_INVALID_ENUM, "access is not one of the supported tokens.");
context->validationError(GL_INVALID_ENUM, kInvalidImageAccess);
return false;
}
......@@ -1464,8 +1445,7 @@ bool ValidateBindImageTexture(Context *context,
case GL_RGBA8_SNORM:
break;
default:
context->validationError(GL_INVALID_VALUE,
"format is not one of supported image unit formats.");
context->validationError(GL_INVALID_VALUE, kInvalidImageFormat);
return false;
}
......@@ -1475,15 +1455,13 @@ bool ValidateBindImageTexture(Context *context,
if (tex == nullptr)
{
context->validationError(GL_INVALID_VALUE,
"texture is not the name of an existing texture object.");
context->validationError(GL_INVALID_VALUE, kMissingTextureName);
return false;
}
if (!tex->getImmutableFormat())
{
context->validationError(GL_INVALID_OPERATION,
"texture is not the name of an immutable texture object.");
context->validationError(GL_INVALID_OPERATION, kTextureIsNotImmutable);
return false;
}
}
......@@ -1510,13 +1488,13 @@ bool ValidateGetProgramResourceLocation(Context *context,
if (!programObject->isLinked())
{
context->validationError(GL_INVALID_OPERATION, "Program is not successfully linked.");
context->validationError(GL_INVALID_OPERATION, kProgramNotLinked);
return false;
}
if (!ValidateLocationProgramInterface(programInterface))
{
context->validationError(GL_INVALID_ENUM, "Invalid program interface.");
context->validationError(GL_INVALID_ENUM, kInvalidProgramInterface);
return false;
}
return true;
......@@ -1545,34 +1523,34 @@ bool ValidateGetProgramResourceiv(Context *context,
}
if (!ValidateProgramInterface(programInterface))
{
context->validationError(GL_INVALID_ENUM, "Invalid program interface.");
context->validationError(GL_INVALID_ENUM, kInvalidProgramInterface);
return false;
}
if (propCount <= 0)
{
context->validationError(GL_INVALID_VALUE, "Invalid propCount.");
context->validationError(GL_INVALID_VALUE, kInvalidPropCount);
return false;
}
if (bufSize < 0)
{
context->validationError(GL_INVALID_VALUE, "Invalid bufSize.");
context->validationError(GL_INVALID_VALUE, kNegativeBufSize);
return false;
}
if (!ValidateProgramResourceIndex(programObject, programInterface, index))
{
context->validationError(GL_INVALID_VALUE, "Invalid index");
context->validationError(GL_INVALID_VALUE, kInvalidProgramResourceIndex);
return false;
}
for (GLsizei i = 0; i < propCount; i++)
{
if (!ValidateProgramResourceProperty(context, props[i]))
{
context->validationError(GL_INVALID_ENUM, "Invalid prop.");
context->validationError(GL_INVALID_ENUM, kInvalidProgramResourceProperty);
return false;
}
if (!ValidateProgramResourcePropertyByInterface(props[i], programInterface))
{
context->validationError(GL_INVALID_OPERATION, "Not an allowed prop for interface");
context->validationError(GL_INVALID_OPERATION, kInvalidPropertyForProgramInterface);
return false;
}
}
......@@ -1599,7 +1577,7 @@ bool ValidateGetProgramInterfaceiv(Context *context,
if (!ValidateProgramInterface(programInterface))
{
context->validationError(GL_INVALID_ENUM, "Invalid program interface.");
context->validationError(GL_INVALID_ENUM, kInvalidProgramInterface);
return false;
}
......@@ -1611,14 +1589,13 @@ bool ValidateGetProgramInterfaceiv(Context *context,
break;
default:
context->validationError(GL_INVALID_ENUM, "Unknown property of program interface.");
context->validationError(GL_INVALID_ENUM, kInvalidPname);
return false;
}
if (pname == GL_MAX_NAME_LENGTH && programInterface == GL_ATOMIC_COUNTER_BUFFER)
{
context->validationError(GL_INVALID_OPERATION,
"Active atomic counter resources are not assigned name strings.");
context->validationError(GL_INVALID_OPERATION, kAtomicCounterResourceName);
return false;
}
......@@ -1632,9 +1609,7 @@ bool ValidateGetProgramInterfaceiv(Context *context,
break;
default:
context->validationError(
GL_INVALID_OPERATION,
"MAX_NUM_ACTIVE_VARIABLES requires a buffer or block interface.");
context->validationError(GL_INVALID_OPERATION, kMaxActiveVariablesInterface);
return false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment