xref: /aosp_15_r20/external/angle/src/libANGLE/validationES2.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2013 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker 
7*8975f5c5SAndroid Build Coastguard Worker // validationES2.cpp: Validation functions for OpenGL ES 2.0 entry point parameters
8*8975f5c5SAndroid Build Coastguard Worker 
9*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationES2_autogen.h"
10*8975f5c5SAndroid Build Coastguard Worker 
11*8975f5c5SAndroid Build Coastguard Worker #include <cstdint>
12*8975f5c5SAndroid Build Coastguard Worker 
13*8975f5c5SAndroid Build Coastguard Worker #include "common/BinaryStream.h"
14*8975f5c5SAndroid Build Coastguard Worker #include "common/angle_version_info.h"
15*8975f5c5SAndroid Build Coastguard Worker #include "common/mathutil.h"
16*8975f5c5SAndroid Build Coastguard Worker #include "common/string_utils.h"
17*8975f5c5SAndroid Build Coastguard Worker #include "common/utilities.h"
18*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Context.h"
19*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/ErrorStrings.h"
20*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Fence.h"
21*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Framebuffer.h"
22*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/FramebufferAttachment.h"
23*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/MemoryObject.h"
24*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Renderbuffer.h"
25*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Shader.h"
26*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Texture.h"
27*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Uniform.h"
28*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/VertexArray.h"
29*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/formatutils.h"
30*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationES.h"
31*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationES2.h"
32*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationES32.h"
33*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationES3_autogen.h"
34*8975f5c5SAndroid Build Coastguard Worker 
35*8975f5c5SAndroid Build Coastguard Worker namespace gl
36*8975f5c5SAndroid Build Coastguard Worker {
37*8975f5c5SAndroid Build Coastguard Worker using namespace err;
38*8975f5c5SAndroid Build Coastguard Worker 
39*8975f5c5SAndroid Build Coastguard Worker namespace
40*8975f5c5SAndroid Build Coastguard Worker {
41*8975f5c5SAndroid Build Coastguard Worker 
IsPartialBlit(const Context * context,const FramebufferAttachment * readBuffer,const FramebufferAttachment * writeBuffer,GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1)42*8975f5c5SAndroid Build Coastguard Worker bool IsPartialBlit(const Context *context,
43*8975f5c5SAndroid Build Coastguard Worker                    const FramebufferAttachment *readBuffer,
44*8975f5c5SAndroid Build Coastguard Worker                    const FramebufferAttachment *writeBuffer,
45*8975f5c5SAndroid Build Coastguard Worker                    GLint srcX0,
46*8975f5c5SAndroid Build Coastguard Worker                    GLint srcY0,
47*8975f5c5SAndroid Build Coastguard Worker                    GLint srcX1,
48*8975f5c5SAndroid Build Coastguard Worker                    GLint srcY1,
49*8975f5c5SAndroid Build Coastguard Worker                    GLint dstX0,
50*8975f5c5SAndroid Build Coastguard Worker                    GLint dstY0,
51*8975f5c5SAndroid Build Coastguard Worker                    GLint dstX1,
52*8975f5c5SAndroid Build Coastguard Worker                    GLint dstY1)
53*8975f5c5SAndroid Build Coastguard Worker {
54*8975f5c5SAndroid Build Coastguard Worker     const Extents &writeSize = writeBuffer->getSize();
55*8975f5c5SAndroid Build Coastguard Worker     const Extents &readSize  = readBuffer->getSize();
56*8975f5c5SAndroid Build Coastguard Worker 
57*8975f5c5SAndroid Build Coastguard Worker     if (srcX0 != 0 || srcY0 != 0 || dstX0 != 0 || dstY0 != 0 || dstX1 != writeSize.width ||
58*8975f5c5SAndroid Build Coastguard Worker         dstY1 != writeSize.height || srcX1 != readSize.width || srcY1 != readSize.height)
59*8975f5c5SAndroid Build Coastguard Worker     {
60*8975f5c5SAndroid Build Coastguard Worker         return true;
61*8975f5c5SAndroid Build Coastguard Worker     }
62*8975f5c5SAndroid Build Coastguard Worker 
63*8975f5c5SAndroid Build Coastguard Worker     if (context->getState().isScissorTestEnabled())
64*8975f5c5SAndroid Build Coastguard Worker     {
65*8975f5c5SAndroid Build Coastguard Worker         const Rectangle &scissor = context->getState().getScissor();
66*8975f5c5SAndroid Build Coastguard Worker         return scissor.x > 0 || scissor.y > 0 || scissor.width < writeSize.width ||
67*8975f5c5SAndroid Build Coastguard Worker                scissor.height < writeSize.height;
68*8975f5c5SAndroid Build Coastguard Worker     }
69*8975f5c5SAndroid Build Coastguard Worker 
70*8975f5c5SAndroid Build Coastguard Worker     return false;
71*8975f5c5SAndroid Build Coastguard Worker }
72*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureSourceInternalFormatEnum(GLenum internalFormat)73*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureSourceInternalFormatEnum(GLenum internalFormat)
74*8975f5c5SAndroid Build Coastguard Worker {
75*8975f5c5SAndroid Build Coastguard Worker     // Table 1.1 from the CHROMIUM_copy_texture spec
76*8975f5c5SAndroid Build Coastguard Worker     switch (GetUnsizedFormat(internalFormat))
77*8975f5c5SAndroid Build Coastguard Worker     {
78*8975f5c5SAndroid Build Coastguard Worker         case GL_RED:
79*8975f5c5SAndroid Build Coastguard Worker         case GL_ALPHA:
80*8975f5c5SAndroid Build Coastguard Worker         case GL_LUMINANCE:
81*8975f5c5SAndroid Build Coastguard Worker         case GL_LUMINANCE_ALPHA:
82*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB:
83*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA:
84*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB8:
85*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA8:
86*8975f5c5SAndroid Build Coastguard Worker         case GL_BGRA_EXT:
87*8975f5c5SAndroid Build Coastguard Worker         case GL_BGRA8_EXT:
88*8975f5c5SAndroid Build Coastguard Worker         case GL_SRGB_ALPHA_EXT:
89*8975f5c5SAndroid Build Coastguard Worker             return true;
90*8975f5c5SAndroid Build Coastguard Worker 
91*8975f5c5SAndroid Build Coastguard Worker         default:
92*8975f5c5SAndroid Build Coastguard Worker             return false;
93*8975f5c5SAndroid Build Coastguard Worker     }
94*8975f5c5SAndroid Build Coastguard Worker }
95*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopySubTextureSourceInternalFormat(GLenum internalFormat)96*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopySubTextureSourceInternalFormat(GLenum internalFormat)
97*8975f5c5SAndroid Build Coastguard Worker {
98*8975f5c5SAndroid Build Coastguard Worker     return IsValidCopyTextureSourceInternalFormatEnum(internalFormat);
99*8975f5c5SAndroid Build Coastguard Worker }
100*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureDestinationInternalFormatEnum(GLint internalFormat)101*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureDestinationInternalFormatEnum(GLint internalFormat)
102*8975f5c5SAndroid Build Coastguard Worker {
103*8975f5c5SAndroid Build Coastguard Worker     // Table 1.0 from the CHROMIUM_copy_texture spec
104*8975f5c5SAndroid Build Coastguard Worker     switch (internalFormat)
105*8975f5c5SAndroid Build Coastguard Worker     {
106*8975f5c5SAndroid Build Coastguard Worker         case GL_ALPHA:
107*8975f5c5SAndroid Build Coastguard Worker         case GL_BGRA8_EXT:
108*8975f5c5SAndroid Build Coastguard Worker         case GL_BGRA_EXT:
109*8975f5c5SAndroid Build Coastguard Worker         case GL_LUMINANCE:
110*8975f5c5SAndroid Build Coastguard Worker         case GL_LUMINANCE_ALPHA:
111*8975f5c5SAndroid Build Coastguard Worker         case GL_R11F_G11F_B10F:
112*8975f5c5SAndroid Build Coastguard Worker         case GL_R16F:
113*8975f5c5SAndroid Build Coastguard Worker         case GL_R32F:
114*8975f5c5SAndroid Build Coastguard Worker         case GL_R8:
115*8975f5c5SAndroid Build Coastguard Worker         case GL_R8UI:
116*8975f5c5SAndroid Build Coastguard Worker         case GL_RG16F:
117*8975f5c5SAndroid Build Coastguard Worker         case GL_RG32F:
118*8975f5c5SAndroid Build Coastguard Worker         case GL_RG8:
119*8975f5c5SAndroid Build Coastguard Worker         case GL_RG8UI:
120*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB:
121*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB10_A2:
122*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB16F:
123*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB32F:
124*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB565:
125*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB5_A1:
126*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB8:
127*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB8UI:
128*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB9_E5:
129*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA:
130*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA16F:
131*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA32F:
132*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA4:
133*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA8:
134*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA8UI:
135*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBX8_ANGLE:
136*8975f5c5SAndroid Build Coastguard Worker         case GL_SRGB8:
137*8975f5c5SAndroid Build Coastguard Worker         case GL_SRGB8_ALPHA8:
138*8975f5c5SAndroid Build Coastguard Worker         case GL_SRGB_ALPHA_EXT:
139*8975f5c5SAndroid Build Coastguard Worker         case GL_SRGB_EXT:
140*8975f5c5SAndroid Build Coastguard Worker             return true;
141*8975f5c5SAndroid Build Coastguard Worker 
142*8975f5c5SAndroid Build Coastguard Worker         default:
143*8975f5c5SAndroid Build Coastguard Worker             return false;
144*8975f5c5SAndroid Build Coastguard Worker     }
145*8975f5c5SAndroid Build Coastguard Worker }
146*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopySubTextureDestionationInternalFormat(GLenum internalFormat)147*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopySubTextureDestionationInternalFormat(GLenum internalFormat)
148*8975f5c5SAndroid Build Coastguard Worker {
149*8975f5c5SAndroid Build Coastguard Worker     return IsValidCopyTextureDestinationInternalFormatEnum(internalFormat);
150*8975f5c5SAndroid Build Coastguard Worker }
151*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureDestinationFormatType(const Context * context,angle::EntryPoint entryPoint,GLint internalFormat,GLenum type)152*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureDestinationFormatType(const Context *context,
153*8975f5c5SAndroid Build Coastguard Worker                                              angle::EntryPoint entryPoint,
154*8975f5c5SAndroid Build Coastguard Worker                                              GLint internalFormat,
155*8975f5c5SAndroid Build Coastguard Worker                                              GLenum type)
156*8975f5c5SAndroid Build Coastguard Worker {
157*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationInternalFormatEnum(internalFormat))
158*8975f5c5SAndroid Build Coastguard Worker     {
159*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERRORF(GL_INVALID_OPERATION, kInvalidInternalFormat, internalFormat);
160*8975f5c5SAndroid Build Coastguard Worker         return false;
161*8975f5c5SAndroid Build Coastguard Worker     }
162*8975f5c5SAndroid Build Coastguard Worker 
163*8975f5c5SAndroid Build Coastguard Worker     if (!ValidES3FormatCombination(GetUnsizedFormat(internalFormat), type, internalFormat))
164*8975f5c5SAndroid Build Coastguard Worker     {
165*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
166*8975f5c5SAndroid Build Coastguard Worker         return false;
167*8975f5c5SAndroid Build Coastguard Worker     }
168*8975f5c5SAndroid Build Coastguard Worker 
169*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &internalFormatInfo = GetInternalFormatInfo(internalFormat, type);
170*8975f5c5SAndroid Build Coastguard Worker     if (!internalFormatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
171*8975f5c5SAndroid Build Coastguard Worker     {
172*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERRORF(GL_INVALID_OPERATION, kInvalidInternalFormat, internalFormat);
173*8975f5c5SAndroid Build Coastguard Worker         return false;
174*8975f5c5SAndroid Build Coastguard Worker     }
175*8975f5c5SAndroid Build Coastguard Worker 
176*8975f5c5SAndroid Build Coastguard Worker     return true;
177*8975f5c5SAndroid Build Coastguard Worker }
178*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureDestinationTargetEnum(const Context * context,TextureTarget target)179*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureDestinationTargetEnum(const Context *context, TextureTarget target)
180*8975f5c5SAndroid Build Coastguard Worker {
181*8975f5c5SAndroid Build Coastguard Worker     switch (target)
182*8975f5c5SAndroid Build Coastguard Worker     {
183*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::_2D:
184*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::CubeMapNegativeX:
185*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::CubeMapNegativeY:
186*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::CubeMapNegativeZ:
187*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::CubeMapPositiveX:
188*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::CubeMapPositiveY:
189*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::CubeMapPositiveZ:
190*8975f5c5SAndroid Build Coastguard Worker             return true;
191*8975f5c5SAndroid Build Coastguard Worker 
192*8975f5c5SAndroid Build Coastguard Worker         case TextureTarget::Rectangle:
193*8975f5c5SAndroid Build Coastguard Worker             return context->getExtensions().textureRectangleANGLE;
194*8975f5c5SAndroid Build Coastguard Worker 
195*8975f5c5SAndroid Build Coastguard Worker         default:
196*8975f5c5SAndroid Build Coastguard Worker             return false;
197*8975f5c5SAndroid Build Coastguard Worker     }
198*8975f5c5SAndroid Build Coastguard Worker }
199*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureDestinationTarget(const Context * context,TextureType textureType,TextureTarget target)200*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureDestinationTarget(const Context *context,
201*8975f5c5SAndroid Build Coastguard Worker                                          TextureType textureType,
202*8975f5c5SAndroid Build Coastguard Worker                                          TextureTarget target)
203*8975f5c5SAndroid Build Coastguard Worker {
204*8975f5c5SAndroid Build Coastguard Worker     return TextureTargetToType(target) == textureType;
205*8975f5c5SAndroid Build Coastguard Worker }
206*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureSourceTarget(const Context * context,TextureType type)207*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureSourceTarget(const Context *context, TextureType type)
208*8975f5c5SAndroid Build Coastguard Worker {
209*8975f5c5SAndroid Build Coastguard Worker     switch (type)
210*8975f5c5SAndroid Build Coastguard Worker     {
211*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_2D:
212*8975f5c5SAndroid Build Coastguard Worker             return true;
213*8975f5c5SAndroid Build Coastguard Worker         case TextureType::Rectangle:
214*8975f5c5SAndroid Build Coastguard Worker             return context->getExtensions().textureRectangleANGLE;
215*8975f5c5SAndroid Build Coastguard Worker         case TextureType::External:
216*8975f5c5SAndroid Build Coastguard Worker             return context->getExtensions().EGLImageExternalOES;
217*8975f5c5SAndroid Build Coastguard Worker         case TextureType::VideoImage:
218*8975f5c5SAndroid Build Coastguard Worker             return context->getExtensions().videoTextureWEBGL;
219*8975f5c5SAndroid Build Coastguard Worker         default:
220*8975f5c5SAndroid Build Coastguard Worker             return false;
221*8975f5c5SAndroid Build Coastguard Worker     }
222*8975f5c5SAndroid Build Coastguard Worker }
223*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureSourceLevel(const Context * context,TextureType type,GLint level)224*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureSourceLevel(const Context *context, TextureType type, GLint level)
225*8975f5c5SAndroid Build Coastguard Worker {
226*8975f5c5SAndroid Build Coastguard Worker     if (!ValidMipLevel(context, type, level))
227*8975f5c5SAndroid Build Coastguard Worker     {
228*8975f5c5SAndroid Build Coastguard Worker         return false;
229*8975f5c5SAndroid Build Coastguard Worker     }
230*8975f5c5SAndroid Build Coastguard Worker 
231*8975f5c5SAndroid Build Coastguard Worker     if (level > 0 && context->getClientVersion() < ES_3_0)
232*8975f5c5SAndroid Build Coastguard Worker     {
233*8975f5c5SAndroid Build Coastguard Worker         return false;
234*8975f5c5SAndroid Build Coastguard Worker     }
235*8975f5c5SAndroid Build Coastguard Worker 
236*8975f5c5SAndroid Build Coastguard Worker     return true;
237*8975f5c5SAndroid Build Coastguard Worker }
238*8975f5c5SAndroid Build Coastguard Worker 
IsValidCopyTextureDestinationLevel(const Context * context,angle::EntryPoint entryPoint,TextureType type,GLint level,GLsizei width,GLsizei height,bool isSubImage)239*8975f5c5SAndroid Build Coastguard Worker bool IsValidCopyTextureDestinationLevel(const Context *context,
240*8975f5c5SAndroid Build Coastguard Worker                                         angle::EntryPoint entryPoint,
241*8975f5c5SAndroid Build Coastguard Worker                                         TextureType type,
242*8975f5c5SAndroid Build Coastguard Worker                                         GLint level,
243*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei width,
244*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei height,
245*8975f5c5SAndroid Build Coastguard Worker                                         bool isSubImage)
246*8975f5c5SAndroid Build Coastguard Worker {
247*8975f5c5SAndroid Build Coastguard Worker     if (!ValidImageSizeParameters(context, entryPoint, type, level, width, height, 1, isSubImage))
248*8975f5c5SAndroid Build Coastguard Worker     {
249*8975f5c5SAndroid Build Coastguard Worker         return false;
250*8975f5c5SAndroid Build Coastguard Worker     }
251*8975f5c5SAndroid Build Coastguard Worker 
252*8975f5c5SAndroid Build Coastguard Worker     const Caps &caps = context->getCaps();
253*8975f5c5SAndroid Build Coastguard Worker     switch (type)
254*8975f5c5SAndroid Build Coastguard Worker     {
255*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_2D:
256*8975f5c5SAndroid Build Coastguard Worker             return width <= (caps.max2DTextureSize >> level) &&
257*8975f5c5SAndroid Build Coastguard Worker                    height <= (caps.max2DTextureSize >> level);
258*8975f5c5SAndroid Build Coastguard Worker         case TextureType::Rectangle:
259*8975f5c5SAndroid Build Coastguard Worker             ASSERT(level == 0);
260*8975f5c5SAndroid Build Coastguard Worker             return width <= (caps.max2DTextureSize >> level) &&
261*8975f5c5SAndroid Build Coastguard Worker                    height <= (caps.max2DTextureSize >> level);
262*8975f5c5SAndroid Build Coastguard Worker 
263*8975f5c5SAndroid Build Coastguard Worker         case TextureType::CubeMap:
264*8975f5c5SAndroid Build Coastguard Worker             return width <= (caps.maxCubeMapTextureSize >> level) &&
265*8975f5c5SAndroid Build Coastguard Worker                    height <= (caps.maxCubeMapTextureSize >> level);
266*8975f5c5SAndroid Build Coastguard Worker         default:
267*8975f5c5SAndroid Build Coastguard Worker             return true;
268*8975f5c5SAndroid Build Coastguard Worker     }
269*8975f5c5SAndroid Build Coastguard Worker }
270*8975f5c5SAndroid Build Coastguard Worker 
IsValidStencilFunc(GLenum func)271*8975f5c5SAndroid Build Coastguard Worker bool IsValidStencilFunc(GLenum func)
272*8975f5c5SAndroid Build Coastguard Worker {
273*8975f5c5SAndroid Build Coastguard Worker     switch (func)
274*8975f5c5SAndroid Build Coastguard Worker     {
275*8975f5c5SAndroid Build Coastguard Worker         case GL_NEVER:
276*8975f5c5SAndroid Build Coastguard Worker         case GL_ALWAYS:
277*8975f5c5SAndroid Build Coastguard Worker         case GL_LESS:
278*8975f5c5SAndroid Build Coastguard Worker         case GL_LEQUAL:
279*8975f5c5SAndroid Build Coastguard Worker         case GL_EQUAL:
280*8975f5c5SAndroid Build Coastguard Worker         case GL_GEQUAL:
281*8975f5c5SAndroid Build Coastguard Worker         case GL_GREATER:
282*8975f5c5SAndroid Build Coastguard Worker         case GL_NOTEQUAL:
283*8975f5c5SAndroid Build Coastguard Worker             return true;
284*8975f5c5SAndroid Build Coastguard Worker 
285*8975f5c5SAndroid Build Coastguard Worker         default:
286*8975f5c5SAndroid Build Coastguard Worker             return false;
287*8975f5c5SAndroid Build Coastguard Worker     }
288*8975f5c5SAndroid Build Coastguard Worker }
289*8975f5c5SAndroid Build Coastguard Worker 
IsValidStencilFace(GLenum face)290*8975f5c5SAndroid Build Coastguard Worker bool IsValidStencilFace(GLenum face)
291*8975f5c5SAndroid Build Coastguard Worker {
292*8975f5c5SAndroid Build Coastguard Worker     switch (face)
293*8975f5c5SAndroid Build Coastguard Worker     {
294*8975f5c5SAndroid Build Coastguard Worker         case GL_FRONT:
295*8975f5c5SAndroid Build Coastguard Worker         case GL_BACK:
296*8975f5c5SAndroid Build Coastguard Worker         case GL_FRONT_AND_BACK:
297*8975f5c5SAndroid Build Coastguard Worker             return true;
298*8975f5c5SAndroid Build Coastguard Worker 
299*8975f5c5SAndroid Build Coastguard Worker         default:
300*8975f5c5SAndroid Build Coastguard Worker             return false;
301*8975f5c5SAndroid Build Coastguard Worker     }
302*8975f5c5SAndroid Build Coastguard Worker }
303*8975f5c5SAndroid Build Coastguard Worker 
IsValidStencilOp(GLenum op)304*8975f5c5SAndroid Build Coastguard Worker bool IsValidStencilOp(GLenum op)
305*8975f5c5SAndroid Build Coastguard Worker {
306*8975f5c5SAndroid Build Coastguard Worker     switch (op)
307*8975f5c5SAndroid Build Coastguard Worker     {
308*8975f5c5SAndroid Build Coastguard Worker         case GL_ZERO:
309*8975f5c5SAndroid Build Coastguard Worker         case GL_KEEP:
310*8975f5c5SAndroid Build Coastguard Worker         case GL_REPLACE:
311*8975f5c5SAndroid Build Coastguard Worker         case GL_INCR:
312*8975f5c5SAndroid Build Coastguard Worker         case GL_DECR:
313*8975f5c5SAndroid Build Coastguard Worker         case GL_INVERT:
314*8975f5c5SAndroid Build Coastguard Worker         case GL_INCR_WRAP:
315*8975f5c5SAndroid Build Coastguard Worker         case GL_DECR_WRAP:
316*8975f5c5SAndroid Build Coastguard Worker             return true;
317*8975f5c5SAndroid Build Coastguard Worker 
318*8975f5c5SAndroid Build Coastguard Worker         default:
319*8975f5c5SAndroid Build Coastguard Worker             return false;
320*8975f5c5SAndroid Build Coastguard Worker     }
321*8975f5c5SAndroid Build Coastguard Worker }
322*8975f5c5SAndroid Build Coastguard Worker 
Valid1to4ComponentFloatColorBufferFormat(const Context * context,GLenum format)323*8975f5c5SAndroid Build Coastguard Worker static inline bool Valid1to4ComponentFloatColorBufferFormat(const Context *context, GLenum format)
324*8975f5c5SAndroid Build Coastguard Worker {
325*8975f5c5SAndroid Build Coastguard Worker     return (context->getExtensions().textureFloatOES &&
326*8975f5c5SAndroid Build Coastguard Worker             (format == GL_RGBA32F || format == GL_RGB32F || format == GL_RG32F ||
327*8975f5c5SAndroid Build Coastguard Worker              format == GL_R32F)) ||
328*8975f5c5SAndroid Build Coastguard Worker            (context->getExtensions().textureHalfFloatOES &&
329*8975f5c5SAndroid Build Coastguard Worker             (format == GL_RGBA16F || format == GL_RGB16F || format == GL_RG16F ||
330*8975f5c5SAndroid Build Coastguard Worker              format == GL_R16F));
331*8975f5c5SAndroid Build Coastguard Worker }
332*8975f5c5SAndroid Build Coastguard Worker 
Valid2to4ComponentFloatColorBufferFormat(const Context * context,GLenum format)333*8975f5c5SAndroid Build Coastguard Worker static inline bool Valid2to4ComponentFloatColorBufferFormat(const Context *context, GLenum format)
334*8975f5c5SAndroid Build Coastguard Worker {
335*8975f5c5SAndroid Build Coastguard Worker     return (context->getExtensions().textureFloatOES &&
336*8975f5c5SAndroid Build Coastguard Worker             (format == GL_RGBA32F || format == GL_RGB32F || format == GL_RG32F)) ||
337*8975f5c5SAndroid Build Coastguard Worker            (context->getExtensions().textureHalfFloatOES &&
338*8975f5c5SAndroid Build Coastguard Worker             (format == GL_RGBA16F || format == GL_RGB16F || format == GL_RG16F));
339*8975f5c5SAndroid Build Coastguard Worker }
340*8975f5c5SAndroid Build Coastguard Worker 
Valid3to4ComponentFloatColorBufferFormat(const Context * context,GLenum format)341*8975f5c5SAndroid Build Coastguard Worker static inline bool Valid3to4ComponentFloatColorBufferFormat(const Context *context, GLenum format)
342*8975f5c5SAndroid Build Coastguard Worker {
343*8975f5c5SAndroid Build Coastguard Worker     return (context->getExtensions().textureFloatOES &&
344*8975f5c5SAndroid Build Coastguard Worker             (format == GL_RGBA32F || format == GL_RGB32F)) ||
345*8975f5c5SAndroid Build Coastguard Worker            (context->getExtensions().textureHalfFloatOES &&
346*8975f5c5SAndroid Build Coastguard Worker             (format == GL_RGBA16F || format == GL_RGB16F));
347*8975f5c5SAndroid Build Coastguard Worker }
348*8975f5c5SAndroid Build Coastguard Worker 
Valid4ComponentFloatColorBufferFormat(const Context * context,GLenum format)349*8975f5c5SAndroid Build Coastguard Worker static inline bool Valid4ComponentFloatColorBufferFormat(const Context *context, GLenum format)
350*8975f5c5SAndroid Build Coastguard Worker {
351*8975f5c5SAndroid Build Coastguard Worker     return (context->getExtensions().textureFloatOES && format == GL_RGBA32F) ||
352*8975f5c5SAndroid Build Coastguard Worker            (context->getExtensions().textureHalfFloatOES && format == GL_RGBA16F);
353*8975f5c5SAndroid Build Coastguard Worker }
354*8975f5c5SAndroid Build Coastguard Worker 
ValidateES2CopyTexImageParameters(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,bool isSubImage,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)355*8975f5c5SAndroid Build Coastguard Worker bool ValidateES2CopyTexImageParameters(const Context *context,
356*8975f5c5SAndroid Build Coastguard Worker                                        angle::EntryPoint entryPoint,
357*8975f5c5SAndroid Build Coastguard Worker                                        TextureTarget target,
358*8975f5c5SAndroid Build Coastguard Worker                                        GLint level,
359*8975f5c5SAndroid Build Coastguard Worker                                        GLenum internalformat,
360*8975f5c5SAndroid Build Coastguard Worker                                        bool isSubImage,
361*8975f5c5SAndroid Build Coastguard Worker                                        GLint xoffset,
362*8975f5c5SAndroid Build Coastguard Worker                                        GLint yoffset,
363*8975f5c5SAndroid Build Coastguard Worker                                        GLint x,
364*8975f5c5SAndroid Build Coastguard Worker                                        GLint y,
365*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei width,
366*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei height,
367*8975f5c5SAndroid Build Coastguard Worker                                        GLint border)
368*8975f5c5SAndroid Build Coastguard Worker {
369*8975f5c5SAndroid Build Coastguard Worker     if (!ValidTexture2DDestinationTarget(context, target))
370*8975f5c5SAndroid Build Coastguard Worker     {
371*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
372*8975f5c5SAndroid Build Coastguard Worker         return false;
373*8975f5c5SAndroid Build Coastguard Worker     }
374*8975f5c5SAndroid Build Coastguard Worker 
375*8975f5c5SAndroid Build Coastguard Worker     TextureType texType = TextureTargetToType(target);
376*8975f5c5SAndroid Build Coastguard Worker     if (!ValidImageSizeParameters(context, entryPoint, texType, level, width, height, 1,
377*8975f5c5SAndroid Build Coastguard Worker                                   isSubImage))
378*8975f5c5SAndroid Build Coastguard Worker     {
379*8975f5c5SAndroid Build Coastguard Worker         // Error is already handled.
380*8975f5c5SAndroid Build Coastguard Worker         return false;
381*8975f5c5SAndroid Build Coastguard Worker     }
382*8975f5c5SAndroid Build Coastguard Worker 
383*8975f5c5SAndroid Build Coastguard Worker     Format textureFormat = Format::Invalid();
384*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateCopyTexImageParametersBase(context, entryPoint, target, level, internalformat,
385*8975f5c5SAndroid Build Coastguard Worker                                             isSubImage, xoffset, yoffset, 0, x, y, width, height,
386*8975f5c5SAndroid Build Coastguard Worker                                             border, &textureFormat))
387*8975f5c5SAndroid Build Coastguard Worker     {
388*8975f5c5SAndroid Build Coastguard Worker         return false;
389*8975f5c5SAndroid Build Coastguard Worker     }
390*8975f5c5SAndroid Build Coastguard Worker 
391*8975f5c5SAndroid Build Coastguard Worker     ASSERT(textureFormat.valid() || !isSubImage);
392*8975f5c5SAndroid Build Coastguard Worker 
393*8975f5c5SAndroid Build Coastguard Worker     const Framebuffer *framebuffer = context->getState().getReadFramebuffer();
394*8975f5c5SAndroid Build Coastguard Worker     GLenum colorbufferFormat =
395*8975f5c5SAndroid Build Coastguard Worker         framebuffer->getReadColorAttachment()->getFormat().info->sizedInternalFormat;
396*8975f5c5SAndroid Build Coastguard Worker     const auto &formatInfo = *textureFormat.info;
397*8975f5c5SAndroid Build Coastguard Worker 
398*8975f5c5SAndroid Build Coastguard Worker     // ValidateCopyTexImageParametersBase rejects compressed formats with GL_INVALID_OPERATION.
399*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!formatInfo.compressed);
400*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!GetInternalFormatInfo(internalformat, GL_UNSIGNED_BYTE).compressed);
401*8975f5c5SAndroid Build Coastguard Worker 
402*8975f5c5SAndroid Build Coastguard Worker     // ValidateCopyTexImageParametersBase rejects depth formats with GL_INVALID_OPERATION.
403*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!formatInfo.depthBits);
404*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!GetInternalFormatInfo(internalformat, GL_UNSIGNED_BYTE).depthBits);
405*8975f5c5SAndroid Build Coastguard Worker 
406*8975f5c5SAndroid Build Coastguard Worker     // [OpenGL ES 2.0.24] table 3.9
407*8975f5c5SAndroid Build Coastguard Worker     if (isSubImage)
408*8975f5c5SAndroid Build Coastguard Worker     {
409*8975f5c5SAndroid Build Coastguard Worker         switch (formatInfo.format)
410*8975f5c5SAndroid Build Coastguard Worker         {
411*8975f5c5SAndroid Build Coastguard Worker             case GL_ALPHA:
412*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_ALPHA8_EXT && colorbufferFormat != GL_RGBA4 &&
413*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES &&
414*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX &&
415*8975f5c5SAndroid Build Coastguard Worker                     !Valid4ComponentFloatColorBufferFormat(context, colorbufferFormat))
416*8975f5c5SAndroid Build Coastguard Worker                 {
417*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
418*8975f5c5SAndroid Build Coastguard Worker                     return false;
419*8975f5c5SAndroid Build Coastguard Worker                 }
420*8975f5c5SAndroid Build Coastguard Worker                 break;
421*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE:
422*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_R8_EXT && colorbufferFormat != GL_RG8_EXT &&
423*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES &&
424*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 &&
425*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT &&
426*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGR5_A1_ANGLEX &&
427*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRX8_ANGLEX && colorbufferFormat != GL_RGBX8_ANGLE &&
428*8975f5c5SAndroid Build Coastguard Worker                     !Valid1to4ComponentFloatColorBufferFormat(context, colorbufferFormat))
429*8975f5c5SAndroid Build Coastguard Worker                 {
430*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
431*8975f5c5SAndroid Build Coastguard Worker                     return false;
432*8975f5c5SAndroid Build Coastguard Worker                 }
433*8975f5c5SAndroid Build Coastguard Worker                 break;
434*8975f5c5SAndroid Build Coastguard Worker             case GL_RED_EXT:
435*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_R8_EXT && colorbufferFormat != GL_RG8_EXT &&
436*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES &&
437*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 &&
438*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_R32F &&
439*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RG32F && colorbufferFormat != GL_RGB32F &&
440*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT &&
441*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGR5_A1_ANGLEX &&
442*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRX8_ANGLEX && colorbufferFormat != GL_RGBX8_ANGLE &&
443*8975f5c5SAndroid Build Coastguard Worker                     !Valid1to4ComponentFloatColorBufferFormat(context, colorbufferFormat))
444*8975f5c5SAndroid Build Coastguard Worker                 {
445*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
446*8975f5c5SAndroid Build Coastguard Worker                     return false;
447*8975f5c5SAndroid Build Coastguard Worker                 }
448*8975f5c5SAndroid Build Coastguard Worker                 break;
449*8975f5c5SAndroid Build Coastguard Worker             case GL_RG_EXT:
450*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_RG8_EXT && colorbufferFormat != GL_RGB565 &&
451*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB8_OES && colorbufferFormat != GL_RGBA4 &&
452*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES &&
453*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RG32F && colorbufferFormat != GL_RGB32F &&
454*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT &&
455*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGR5_A1_ANGLEX &&
456*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRX8_ANGLEX && colorbufferFormat != GL_RGBX8_ANGLE &&
457*8975f5c5SAndroid Build Coastguard Worker                     !Valid2to4ComponentFloatColorBufferFormat(context, colorbufferFormat))
458*8975f5c5SAndroid Build Coastguard Worker                 {
459*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
460*8975f5c5SAndroid Build Coastguard Worker                     return false;
461*8975f5c5SAndroid Build Coastguard Worker                 }
462*8975f5c5SAndroid Build Coastguard Worker                 break;
463*8975f5c5SAndroid Build Coastguard Worker             case GL_RGB:
464*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES &&
465*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 &&
466*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGB32F &&
467*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT &&
468*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGR5_A1_ANGLEX &&
469*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRX8_ANGLEX && colorbufferFormat != GL_RGBX8_ANGLE &&
470*8975f5c5SAndroid Build Coastguard Worker                     !Valid3to4ComponentFloatColorBufferFormat(context, colorbufferFormat))
471*8975f5c5SAndroid Build Coastguard Worker                 {
472*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
473*8975f5c5SAndroid Build Coastguard Worker                     return false;
474*8975f5c5SAndroid Build Coastguard Worker                 }
475*8975f5c5SAndroid Build Coastguard Worker                 break;
476*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE_ALPHA:
477*8975f5c5SAndroid Build Coastguard Worker             case GL_RGBA:
478*8975f5c5SAndroid Build Coastguard Worker             case GL_BGRA_EXT:
479*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 &&
480*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGBA32F &&
481*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX &&
482*8975f5c5SAndroid Build Coastguard Worker                     !Valid4ComponentFloatColorBufferFormat(context, colorbufferFormat))
483*8975f5c5SAndroid Build Coastguard Worker                 {
484*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
485*8975f5c5SAndroid Build Coastguard Worker                     return false;
486*8975f5c5SAndroid Build Coastguard Worker                 }
487*8975f5c5SAndroid Build Coastguard Worker                 break;
488*8975f5c5SAndroid Build Coastguard Worker             default:
489*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
490*8975f5c5SAndroid Build Coastguard Worker                 return false;
491*8975f5c5SAndroid Build Coastguard Worker         }
492*8975f5c5SAndroid Build Coastguard Worker 
493*8975f5c5SAndroid Build Coastguard Worker         if (formatInfo.type == GL_FLOAT && !context->getExtensions().textureFloatOES)
494*8975f5c5SAndroid Build Coastguard Worker         {
495*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
496*8975f5c5SAndroid Build Coastguard Worker             return false;
497*8975f5c5SAndroid Build Coastguard Worker         }
498*8975f5c5SAndroid Build Coastguard Worker     }
499*8975f5c5SAndroid Build Coastguard Worker     else
500*8975f5c5SAndroid Build Coastguard Worker     {
501*8975f5c5SAndroid Build Coastguard Worker         switch (internalformat)
502*8975f5c5SAndroid Build Coastguard Worker         {
503*8975f5c5SAndroid Build Coastguard Worker             case GL_ALPHA:
504*8975f5c5SAndroid Build Coastguard Worker             case GL_ALPHA8_OES:
505*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_ALPHA8_EXT && colorbufferFormat != GL_RGBA4 &&
506*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT &&
507*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX &&
508*8975f5c5SAndroid Build Coastguard Worker                     !Valid4ComponentFloatColorBufferFormat(context, colorbufferFormat))
509*8975f5c5SAndroid Build Coastguard Worker                 {
510*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
511*8975f5c5SAndroid Build Coastguard Worker                     return false;
512*8975f5c5SAndroid Build Coastguard Worker                 }
513*8975f5c5SAndroid Build Coastguard Worker                 break;
514*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE:
515*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE8_OES:
516*8975f5c5SAndroid Build Coastguard Worker             case GL_RED_EXT:
517*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_R8_EXT && colorbufferFormat != GL_RG8_EXT &&
518*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES &&
519*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 &&
520*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES &&
521*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGR5_A1_ANGLEX &&
522*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRX8_ANGLEX && colorbufferFormat != GL_RGBX8_ANGLE &&
523*8975f5c5SAndroid Build Coastguard Worker                     !Valid1to4ComponentFloatColorBufferFormat(context, colorbufferFormat))
524*8975f5c5SAndroid Build Coastguard Worker                 {
525*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
526*8975f5c5SAndroid Build Coastguard Worker                     return false;
527*8975f5c5SAndroid Build Coastguard Worker                 }
528*8975f5c5SAndroid Build Coastguard Worker                 break;
529*8975f5c5SAndroid Build Coastguard Worker             case GL_RG_EXT:
530*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_RG8_EXT && colorbufferFormat != GL_RGB565 &&
531*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB8_OES && colorbufferFormat != GL_RGBA4 &&
532*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT &&
533*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX &&
534*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRX8_ANGLEX && colorbufferFormat != GL_RGBX8_ANGLE &&
535*8975f5c5SAndroid Build Coastguard Worker                     !Valid2to4ComponentFloatColorBufferFormat(context, colorbufferFormat))
536*8975f5c5SAndroid Build Coastguard Worker                 {
537*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
538*8975f5c5SAndroid Build Coastguard Worker                     return false;
539*8975f5c5SAndroid Build Coastguard Worker                 }
540*8975f5c5SAndroid Build Coastguard Worker                 break;
541*8975f5c5SAndroid Build Coastguard Worker             case GL_RGB:
542*8975f5c5SAndroid Build Coastguard Worker             case GL_RGB565_OES:
543*8975f5c5SAndroid Build Coastguard Worker             case GL_RGB8_OES:
544*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES &&
545*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 &&
546*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES &&
547*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGR5_A1_ANGLEX &&
548*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRX8_ANGLEX && colorbufferFormat != GL_RGBX8_ANGLE &&
549*8975f5c5SAndroid Build Coastguard Worker                     !Valid3to4ComponentFloatColorBufferFormat(context, colorbufferFormat))
550*8975f5c5SAndroid Build Coastguard Worker                 {
551*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
552*8975f5c5SAndroid Build Coastguard Worker                     return false;
553*8975f5c5SAndroid Build Coastguard Worker                 }
554*8975f5c5SAndroid Build Coastguard Worker                 break;
555*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE_ALPHA:
556*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE4_ALPHA4_OES:
557*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE8_ALPHA8_OES:
558*8975f5c5SAndroid Build Coastguard Worker             case GL_RGBA:
559*8975f5c5SAndroid Build Coastguard Worker             case GL_BGRA_EXT:
560*8975f5c5SAndroid Build Coastguard Worker             case GL_RGBA4_OES:
561*8975f5c5SAndroid Build Coastguard Worker             case GL_RGB5_A1_OES:
562*8975f5c5SAndroid Build Coastguard Worker             case GL_RGBA8_OES:
563*8975f5c5SAndroid Build Coastguard Worker                 if (colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 &&
564*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES &&
565*8975f5c5SAndroid Build Coastguard Worker                     colorbufferFormat != GL_BGR5_A1_ANGLEX && colorbufferFormat != GL_RGBA16F &&
566*8975f5c5SAndroid Build Coastguard Worker                     !Valid4ComponentFloatColorBufferFormat(context, colorbufferFormat))
567*8975f5c5SAndroid Build Coastguard Worker                 {
568*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
569*8975f5c5SAndroid Build Coastguard Worker                     return false;
570*8975f5c5SAndroid Build Coastguard Worker                 }
571*8975f5c5SAndroid Build Coastguard Worker                 break;
572*8975f5c5SAndroid Build Coastguard Worker             default:
573*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, internalformat);
574*8975f5c5SAndroid Build Coastguard Worker                 return false;
575*8975f5c5SAndroid Build Coastguard Worker         }
576*8975f5c5SAndroid Build Coastguard Worker     }
577*8975f5c5SAndroid Build Coastguard Worker 
578*8975f5c5SAndroid Build Coastguard Worker     // If width or height is zero, it is a no-op.  Return false without setting an error.
579*8975f5c5SAndroid Build Coastguard Worker     return (width > 0 && height > 0);
580*8975f5c5SAndroid Build Coastguard Worker }
581*8975f5c5SAndroid Build Coastguard Worker 
582*8975f5c5SAndroid Build Coastguard Worker // ANGLE_shader_pixel_local_storage: INVALID_OPERATION is generated by Enable(), Disable() if <cap>
583*8975f5c5SAndroid Build Coastguard Worker // is not one of: CULL_FACE, DEBUG_OUTPUT, DEBUG_OUTPUT_SYNCHRONOUS, DEPTH_CLAMP_EXT, DEPTH_TEST,
584*8975f5c5SAndroid Build Coastguard Worker // POLYGON_OFFSET_FILL, PRIMITIVE_RESTART_FIXED_INDEX, SCISSOR_TEST, SCISSOR_TEST_EXCLUSIVE_NV,
585*8975f5c5SAndroid Build Coastguard Worker // STENCIL_TEST, CLIP_DISTANCE[0..7]_EXT
IsCapBannedWithActivePLS(GLenum cap)586*8975f5c5SAndroid Build Coastguard Worker static bool IsCapBannedWithActivePLS(GLenum cap)
587*8975f5c5SAndroid Build Coastguard Worker {
588*8975f5c5SAndroid Build Coastguard Worker     switch (cap)
589*8975f5c5SAndroid Build Coastguard Worker     {
590*8975f5c5SAndroid Build Coastguard Worker         case GL_BLEND:
591*8975f5c5SAndroid Build Coastguard Worker         case GL_CULL_FACE:
592*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_OUTPUT:
593*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_OUTPUT_SYNCHRONOUS:
594*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH_CLAMP_EXT:
595*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH_TEST:
596*8975f5c5SAndroid Build Coastguard Worker         case GL_POLYGON_OFFSET_POINT_NV:
597*8975f5c5SAndroid Build Coastguard Worker         case GL_POLYGON_OFFSET_LINE_NV:  // = GL_POLYGON_OFFSET_LINE_ANGLE
598*8975f5c5SAndroid Build Coastguard Worker         case GL_POLYGON_OFFSET_FILL:
599*8975f5c5SAndroid Build Coastguard Worker         case GL_PRIMITIVE_RESTART_FIXED_INDEX:
600*8975f5c5SAndroid Build Coastguard Worker         case GL_SCISSOR_TEST:
601*8975f5c5SAndroid Build Coastguard Worker         case GL_SCISSOR_TEST_EXCLUSIVE_NV:
602*8975f5c5SAndroid Build Coastguard Worker         case GL_STENCIL_TEST:
603*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE0_EXT:
604*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE1_EXT:
605*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE2_EXT:
606*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE3_EXT:
607*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE4_EXT:
608*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE5_EXT:
609*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE6_EXT:
610*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE7_EXT:
611*8975f5c5SAndroid Build Coastguard Worker             return false;
612*8975f5c5SAndroid Build Coastguard Worker         default:
613*8975f5c5SAndroid Build Coastguard Worker             return true;
614*8975f5c5SAndroid Build Coastguard Worker     }
615*8975f5c5SAndroid Build Coastguard Worker }
616*8975f5c5SAndroid Build Coastguard Worker 
ValidCap(const PrivateState & state,ErrorSet * errors,GLenum cap,bool queryOnly)617*8975f5c5SAndroid Build Coastguard Worker bool ValidCap(const PrivateState &state, ErrorSet *errors, GLenum cap, bool queryOnly)
618*8975f5c5SAndroid Build Coastguard Worker {
619*8975f5c5SAndroid Build Coastguard Worker     switch (cap)
620*8975f5c5SAndroid Build Coastguard Worker     {
621*8975f5c5SAndroid Build Coastguard Worker         // EXT_multisample_compatibility
622*8975f5c5SAndroid Build Coastguard Worker         case GL_MULTISAMPLE_EXT:
623*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLE_ALPHA_TO_ONE_EXT:
624*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().multisampleCompatibilityEXT;
625*8975f5c5SAndroid Build Coastguard Worker 
626*8975f5c5SAndroid Build Coastguard Worker         case GL_CULL_FACE:
627*8975f5c5SAndroid Build Coastguard Worker         case GL_POLYGON_OFFSET_FILL:
628*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLE_ALPHA_TO_COVERAGE:
629*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLE_COVERAGE:
630*8975f5c5SAndroid Build Coastguard Worker         case GL_SCISSOR_TEST:
631*8975f5c5SAndroid Build Coastguard Worker         case GL_STENCIL_TEST:
632*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH_TEST:
633*8975f5c5SAndroid Build Coastguard Worker         case GL_BLEND:
634*8975f5c5SAndroid Build Coastguard Worker         case GL_DITHER:
635*8975f5c5SAndroid Build Coastguard Worker             return true;
636*8975f5c5SAndroid Build Coastguard Worker 
637*8975f5c5SAndroid Build Coastguard Worker         case GL_POLYGON_OFFSET_POINT_NV:
638*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().polygonModeNV;
639*8975f5c5SAndroid Build Coastguard Worker         case GL_POLYGON_OFFSET_LINE_NV:  // = GL_POLYGON_OFFSET_LINE_ANGLE
640*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().polygonModeAny();
641*8975f5c5SAndroid Build Coastguard Worker 
642*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH_CLAMP_EXT:
643*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().depthClampEXT;
644*8975f5c5SAndroid Build Coastguard Worker 
645*8975f5c5SAndroid Build Coastguard Worker         case GL_PRIMITIVE_RESTART_FIXED_INDEX:
646*8975f5c5SAndroid Build Coastguard Worker         case GL_RASTERIZER_DISCARD:
647*8975f5c5SAndroid Build Coastguard Worker             return (state.getClientMajorVersion() >= 3);
648*8975f5c5SAndroid Build Coastguard Worker 
649*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_OUTPUT_SYNCHRONOUS:
650*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_OUTPUT:
651*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().debugKHR;
652*8975f5c5SAndroid Build Coastguard Worker 
653*8975f5c5SAndroid Build Coastguard Worker         case GL_BIND_GENERATES_RESOURCE_CHROMIUM:
654*8975f5c5SAndroid Build Coastguard Worker             return queryOnly && state.getExtensions().bindGeneratesResourceCHROMIUM;
655*8975f5c5SAndroid Build Coastguard Worker 
656*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIENT_ARRAYS_ANGLE:
657*8975f5c5SAndroid Build Coastguard Worker             return queryOnly && state.getExtensions().clientArraysANGLE;
658*8975f5c5SAndroid Build Coastguard Worker 
659*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAMEBUFFER_SRGB_EXT:
660*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().sRGBWriteControlEXT;
661*8975f5c5SAndroid Build Coastguard Worker 
662*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLE_MASK:
663*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() >= Version(3, 1) ||
664*8975f5c5SAndroid Build Coastguard Worker                    state.getExtensions().textureMultisampleANGLE;
665*8975f5c5SAndroid Build Coastguard Worker 
666*8975f5c5SAndroid Build Coastguard Worker         case GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE:
667*8975f5c5SAndroid Build Coastguard Worker             return queryOnly && state.getExtensions().robustResourceInitializationANGLE;
668*8975f5c5SAndroid Build Coastguard Worker 
669*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_RECTANGLE_ANGLE:
670*8975f5c5SAndroid Build Coastguard Worker             return state.isWebGL();
671*8975f5c5SAndroid Build Coastguard Worker 
672*8975f5c5SAndroid Build Coastguard Worker         // GL_APPLE_clip_distance / GL_EXT_clip_cull_distance / GL_ANGLE_clip_cull_distance
673*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE0_EXT:
674*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE1_EXT:
675*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE2_EXT:
676*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE3_EXT:
677*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE4_EXT:
678*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE5_EXT:
679*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE6_EXT:
680*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_DISTANCE7_EXT:
681*8975f5c5SAndroid Build Coastguard Worker             if (state.getExtensions().clipDistanceAPPLE ||
682*8975f5c5SAndroid Build Coastguard Worker                 state.getExtensions().clipCullDistanceAny())
683*8975f5c5SAndroid Build Coastguard Worker             {
684*8975f5c5SAndroid Build Coastguard Worker                 return true;
685*8975f5c5SAndroid Build Coastguard Worker             }
686*8975f5c5SAndroid Build Coastguard Worker             break;
687*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLE_SHADING:
688*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().sampleShadingOES;
689*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADING_RATE_PRESERVE_ASPECT_RATIO_QCOM:
690*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().shadingRateQCOM;
691*8975f5c5SAndroid Build Coastguard Worker 
692*8975f5c5SAndroid Build Coastguard Worker         // COLOR_LOGIC_OP is in GLES1, but exposed through an ANGLE extension.
693*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR_LOGIC_OP:
694*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() < Version(2, 0) || state.getExtensions().logicOpANGLE;
695*8975f5c5SAndroid Build Coastguard Worker 
696*8975f5c5SAndroid Build Coastguard Worker         case GL_FETCH_PER_SAMPLE_ARM:
697*8975f5c5SAndroid Build Coastguard Worker             return state.getExtensions().shaderFramebufferFetchARM;
698*8975f5c5SAndroid Build Coastguard Worker 
699*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM:
700*8975f5c5SAndroid Build Coastguard Worker             return queryOnly && state.getExtensions().shaderFramebufferFetchARM;
701*8975f5c5SAndroid Build Coastguard Worker 
702*8975f5c5SAndroid Build Coastguard Worker         case GL_BLEND_ADVANCED_COHERENT_KHR:
703*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() >= Version(2, 0) &&
704*8975f5c5SAndroid Build Coastguard Worker                    state.getExtensions().blendEquationAdvancedCoherentKHR;
705*8975f5c5SAndroid Build Coastguard Worker 
706*8975f5c5SAndroid Build Coastguard Worker         default:
707*8975f5c5SAndroid Build Coastguard Worker             break;
708*8975f5c5SAndroid Build Coastguard Worker     }
709*8975f5c5SAndroid Build Coastguard Worker 
710*8975f5c5SAndroid Build Coastguard Worker     // GLES1 emulation: GLES1-specific caps after this point
711*8975f5c5SAndroid Build Coastguard Worker     if (state.getClientVersion().major != 1)
712*8975f5c5SAndroid Build Coastguard Worker     {
713*8975f5c5SAndroid Build Coastguard Worker         return false;
714*8975f5c5SAndroid Build Coastguard Worker     }
715*8975f5c5SAndroid Build Coastguard Worker 
716*8975f5c5SAndroid Build Coastguard Worker     switch (cap)
717*8975f5c5SAndroid Build Coastguard Worker     {
718*8975f5c5SAndroid Build Coastguard Worker         case GL_ALPHA_TEST:
719*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY:
720*8975f5c5SAndroid Build Coastguard Worker         case GL_NORMAL_ARRAY:
721*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR_ARRAY:
722*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_COORD_ARRAY:
723*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_2D:
724*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHTING:
725*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT0:
726*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT1:
727*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT2:
728*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT3:
729*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT4:
730*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT5:
731*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT6:
732*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHT7:
733*8975f5c5SAndroid Build Coastguard Worker         case GL_NORMALIZE:
734*8975f5c5SAndroid Build Coastguard Worker         case GL_RESCALE_NORMAL:
735*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR_MATERIAL:
736*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_PLANE0:
737*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_PLANE1:
738*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_PLANE2:
739*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_PLANE3:
740*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_PLANE4:
741*8975f5c5SAndroid Build Coastguard Worker         case GL_CLIP_PLANE5:
742*8975f5c5SAndroid Build Coastguard Worker         case GL_FOG:
743*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SMOOTH:
744*8975f5c5SAndroid Build Coastguard Worker         case GL_LINE_SMOOTH:
745*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() < Version(2, 0);
746*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SIZE_ARRAY_OES:
747*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() < Version(2, 0) &&
748*8975f5c5SAndroid Build Coastguard Worker                    state.getExtensions().pointSizeArrayOES;
749*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_CUBE_MAP:
750*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() < Version(2, 0) &&
751*8975f5c5SAndroid Build Coastguard Worker                    state.getExtensions().textureCubeMapOES;
752*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SPRITE_OES:
753*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() < Version(2, 0) && state.getExtensions().pointSpriteOES;
754*8975f5c5SAndroid Build Coastguard Worker         default:
755*8975f5c5SAndroid Build Coastguard Worker             return false;
756*8975f5c5SAndroid Build Coastguard Worker     }
757*8975f5c5SAndroid Build Coastguard Worker }
758*8975f5c5SAndroid Build Coastguard Worker 
759*8975f5c5SAndroid Build Coastguard Worker // Return true if a character belongs to the ASCII subset as defined in GLSL ES 1.0 spec section
760*8975f5c5SAndroid Build Coastguard Worker // 3.1.
IsValidESSLCharacter(unsigned char c)761*8975f5c5SAndroid Build Coastguard Worker bool IsValidESSLCharacter(unsigned char c)
762*8975f5c5SAndroid Build Coastguard Worker {
763*8975f5c5SAndroid Build Coastguard Worker     // Printing characters are valid except " $ ` @ \ ' DEL.
764*8975f5c5SAndroid Build Coastguard Worker     if (c >= 32 && c <= 126 && c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' &&
765*8975f5c5SAndroid Build Coastguard Worker         c != '\'')
766*8975f5c5SAndroid Build Coastguard Worker     {
767*8975f5c5SAndroid Build Coastguard Worker         return true;
768*8975f5c5SAndroid Build Coastguard Worker     }
769*8975f5c5SAndroid Build Coastguard Worker 
770*8975f5c5SAndroid Build Coastguard Worker     // Horizontal tab, line feed, vertical tab, form feed, carriage return are also valid.
771*8975f5c5SAndroid Build Coastguard Worker     if (c >= 9 && c <= 13)
772*8975f5c5SAndroid Build Coastguard Worker     {
773*8975f5c5SAndroid Build Coastguard Worker         return true;
774*8975f5c5SAndroid Build Coastguard Worker     }
775*8975f5c5SAndroid Build Coastguard Worker 
776*8975f5c5SAndroid Build Coastguard Worker     return false;
777*8975f5c5SAndroid Build Coastguard Worker }
778*8975f5c5SAndroid Build Coastguard Worker 
IsValidESSLString(const char * str,size_t len)779*8975f5c5SAndroid Build Coastguard Worker bool IsValidESSLString(const char *str, size_t len)
780*8975f5c5SAndroid Build Coastguard Worker {
781*8975f5c5SAndroid Build Coastguard Worker     for (size_t i = 0; i < len; i++)
782*8975f5c5SAndroid Build Coastguard Worker     {
783*8975f5c5SAndroid Build Coastguard Worker         if (!IsValidESSLCharacter(str[i]))
784*8975f5c5SAndroid Build Coastguard Worker         {
785*8975f5c5SAndroid Build Coastguard Worker             return false;
786*8975f5c5SAndroid Build Coastguard Worker         }
787*8975f5c5SAndroid Build Coastguard Worker     }
788*8975f5c5SAndroid Build Coastguard Worker 
789*8975f5c5SAndroid Build Coastguard Worker     return true;
790*8975f5c5SAndroid Build Coastguard Worker }
791*8975f5c5SAndroid Build Coastguard Worker 
ValidateWebGLNamePrefix(const Context * context,angle::EntryPoint entryPoint,const GLchar * name)792*8975f5c5SAndroid Build Coastguard Worker bool ValidateWebGLNamePrefix(const Context *context,
793*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
794*8975f5c5SAndroid Build Coastguard Worker                              const GLchar *name)
795*8975f5c5SAndroid Build Coastguard Worker {
796*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->isWebGL());
797*8975f5c5SAndroid Build Coastguard Worker 
798*8975f5c5SAndroid Build Coastguard Worker     // WebGL 1.0 [Section 6.16] GLSL Constructs
799*8975f5c5SAndroid Build Coastguard Worker     // Identifiers starting with "webgl_" and "_webgl_" are reserved for use by WebGL.
800*8975f5c5SAndroid Build Coastguard Worker     if (strncmp(name, "webgl_", 6) == 0 || strncmp(name, "_webgl_", 7) == 0)
801*8975f5c5SAndroid Build Coastguard Worker     {
802*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kWebglBindAttribLocationReservedPrefix);
803*8975f5c5SAndroid Build Coastguard Worker         return false;
804*8975f5c5SAndroid Build Coastguard Worker     }
805*8975f5c5SAndroid Build Coastguard Worker 
806*8975f5c5SAndroid Build Coastguard Worker     return true;
807*8975f5c5SAndroid Build Coastguard Worker }
808*8975f5c5SAndroid Build Coastguard Worker 
ValidateWebGLNameLength(const Context * context,angle::EntryPoint entryPoint,size_t length)809*8975f5c5SAndroid Build Coastguard Worker bool ValidateWebGLNameLength(const Context *context, angle::EntryPoint entryPoint, size_t length)
810*8975f5c5SAndroid Build Coastguard Worker {
811*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->isWebGL());
812*8975f5c5SAndroid Build Coastguard Worker 
813*8975f5c5SAndroid Build Coastguard Worker     if (context->isWebGL1() && length > 256)
814*8975f5c5SAndroid Build Coastguard Worker     {
815*8975f5c5SAndroid Build Coastguard Worker         // WebGL 1.0 [Section 6.21] Maxmimum Uniform and Attribute Location Lengths
816*8975f5c5SAndroid Build Coastguard Worker         // WebGL imposes a limit of 256 characters on the lengths of uniform and attribute
817*8975f5c5SAndroid Build Coastguard Worker         // locations.
818*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kWebglNameLengthLimitExceeded);
819*8975f5c5SAndroid Build Coastguard Worker 
820*8975f5c5SAndroid Build Coastguard Worker         return false;
821*8975f5c5SAndroid Build Coastguard Worker     }
822*8975f5c5SAndroid Build Coastguard Worker     else if (length > 1024)
823*8975f5c5SAndroid Build Coastguard Worker     {
824*8975f5c5SAndroid Build Coastguard Worker         // WebGL 2.0 [Section 4.3.2] WebGL 2.0 imposes a limit of 1024 characters on the lengths of
825*8975f5c5SAndroid Build Coastguard Worker         // uniform and attribute locations.
826*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kWebgl2NameLengthLimitExceeded);
827*8975f5c5SAndroid Build Coastguard Worker         return false;
828*8975f5c5SAndroid Build Coastguard Worker     }
829*8975f5c5SAndroid Build Coastguard Worker 
830*8975f5c5SAndroid Build Coastguard Worker     return true;
831*8975f5c5SAndroid Build Coastguard Worker }
832*8975f5c5SAndroid Build Coastguard Worker 
ValidateSrcBlendFunc(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum val)833*8975f5c5SAndroid Build Coastguard Worker bool ValidateSrcBlendFunc(const PrivateState &state,
834*8975f5c5SAndroid Build Coastguard Worker                           ErrorSet *errors,
835*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
836*8975f5c5SAndroid Build Coastguard Worker                           GLenum val)
837*8975f5c5SAndroid Build Coastguard Worker {
838*8975f5c5SAndroid Build Coastguard Worker     switch (val)
839*8975f5c5SAndroid Build Coastguard Worker     {
840*8975f5c5SAndroid Build Coastguard Worker         case GL_ZERO:
841*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE:
842*8975f5c5SAndroid Build Coastguard Worker         case GL_SRC_COLOR:
843*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_SRC_COLOR:
844*8975f5c5SAndroid Build Coastguard Worker         case GL_DST_COLOR:
845*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_DST_COLOR:
846*8975f5c5SAndroid Build Coastguard Worker         case GL_SRC_ALPHA:
847*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_SRC_ALPHA:
848*8975f5c5SAndroid Build Coastguard Worker         case GL_DST_ALPHA:
849*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_DST_ALPHA:
850*8975f5c5SAndroid Build Coastguard Worker         case GL_CONSTANT_COLOR:
851*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_CONSTANT_COLOR:
852*8975f5c5SAndroid Build Coastguard Worker         case GL_CONSTANT_ALPHA:
853*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_CONSTANT_ALPHA:
854*8975f5c5SAndroid Build Coastguard Worker         case GL_SRC_ALPHA_SATURATE:
855*8975f5c5SAndroid Build Coastguard Worker             return true;
856*8975f5c5SAndroid Build Coastguard Worker 
857*8975f5c5SAndroid Build Coastguard Worker         // EXT_blend_func_extended, excluding GL_SRC_ALPHA_SATURATE_EXT, which equals
858*8975f5c5SAndroid Build Coastguard Worker         // GL_SRC_ALPHA_SATURATE and is handled above.
859*8975f5c5SAndroid Build Coastguard Worker         case GL_SRC1_COLOR_EXT:
860*8975f5c5SAndroid Build Coastguard Worker         case GL_SRC1_ALPHA_EXT:
861*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_SRC1_COLOR_EXT:
862*8975f5c5SAndroid Build Coastguard Worker         case GL_ONE_MINUS_SRC1_ALPHA_EXT:
863*8975f5c5SAndroid Build Coastguard Worker             if (!state.getExtensions().blendFuncExtendedEXT)
864*8975f5c5SAndroid Build Coastguard Worker             {
865*8975f5c5SAndroid Build Coastguard Worker                 break;
866*8975f5c5SAndroid Build Coastguard Worker             }
867*8975f5c5SAndroid Build Coastguard Worker             if (state.getPixelLocalStorageActivePlanes() != 0)
868*8975f5c5SAndroid Build Coastguard Worker             {
869*8975f5c5SAndroid Build Coastguard Worker                 // INVALID_OPERATION is generated by BlendFunc*() if <srcRGB>, <dstRGB>, <srcAlpha>,
870*8975f5c5SAndroid Build Coastguard Worker                 // or <dstAlpha> is a blend function requiring the secondary color input, as
871*8975f5c5SAndroid Build Coastguard Worker                 // specified in EXT_blend_func_extended (SRC1_COLOR_EXT, ONE_MINUS_SRC1_COLOR_EXT,
872*8975f5c5SAndroid Build Coastguard Worker                 // SRC1_ALPHA_EXT, ONE_MINUS_SRC1_ALPHA_EXT).
873*8975f5c5SAndroid Build Coastguard Worker                 errors->validationError(entryPoint, GL_INVALID_OPERATION,
874*8975f5c5SAndroid Build Coastguard Worker                                         kPLSSecondaryBlendNotSupported);
875*8975f5c5SAndroid Build Coastguard Worker                 return false;
876*8975f5c5SAndroid Build Coastguard Worker             }
877*8975f5c5SAndroid Build Coastguard Worker             return true;
878*8975f5c5SAndroid Build Coastguard Worker     }
879*8975f5c5SAndroid Build Coastguard Worker 
880*8975f5c5SAndroid Build Coastguard Worker     errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidBlendFunction);
881*8975f5c5SAndroid Build Coastguard Worker     return false;
882*8975f5c5SAndroid Build Coastguard Worker }
883*8975f5c5SAndroid Build Coastguard Worker 
ValidateDstBlendFunc(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum val)884*8975f5c5SAndroid Build Coastguard Worker bool ValidateDstBlendFunc(const PrivateState &state,
885*8975f5c5SAndroid Build Coastguard Worker                           ErrorSet *errors,
886*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
887*8975f5c5SAndroid Build Coastguard Worker                           GLenum val)
888*8975f5c5SAndroid Build Coastguard Worker {
889*8975f5c5SAndroid Build Coastguard Worker     if (val == GL_SRC_ALPHA_SATURATE)
890*8975f5c5SAndroid Build Coastguard Worker     {
891*8975f5c5SAndroid Build Coastguard Worker         // Unextended ES2 does not allow GL_SRC_ALPHA_SATURATE as a dst blend func.
892*8975f5c5SAndroid Build Coastguard Worker         if (state.getClientMajorVersion() < 3 && !state.getExtensions().blendFuncExtendedEXT)
893*8975f5c5SAndroid Build Coastguard Worker         {
894*8975f5c5SAndroid Build Coastguard Worker             errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidBlendFunction);
895*8975f5c5SAndroid Build Coastguard Worker             return false;
896*8975f5c5SAndroid Build Coastguard Worker         }
897*8975f5c5SAndroid Build Coastguard Worker     }
898*8975f5c5SAndroid Build Coastguard Worker 
899*8975f5c5SAndroid Build Coastguard Worker     return ValidateSrcBlendFunc(state, errors, entryPoint, val);
900*8975f5c5SAndroid Build Coastguard Worker }
901*8975f5c5SAndroid Build Coastguard Worker 
ValidateES2TexImageParameters(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,bool isCompressed,bool isSubImage,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,GLsizei imageSize,const void * pixels)902*8975f5c5SAndroid Build Coastguard Worker bool ValidateES2TexImageParameters(const Context *context,
903*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
904*8975f5c5SAndroid Build Coastguard Worker                                    TextureTarget target,
905*8975f5c5SAndroid Build Coastguard Worker                                    GLint level,
906*8975f5c5SAndroid Build Coastguard Worker                                    GLenum internalformat,
907*8975f5c5SAndroid Build Coastguard Worker                                    bool isCompressed,
908*8975f5c5SAndroid Build Coastguard Worker                                    bool isSubImage,
909*8975f5c5SAndroid Build Coastguard Worker                                    GLint xoffset,
910*8975f5c5SAndroid Build Coastguard Worker                                    GLint yoffset,
911*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei width,
912*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei height,
913*8975f5c5SAndroid Build Coastguard Worker                                    GLint border,
914*8975f5c5SAndroid Build Coastguard Worker                                    GLenum format,
915*8975f5c5SAndroid Build Coastguard Worker                                    GLenum type,
916*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei imageSize,
917*8975f5c5SAndroid Build Coastguard Worker                                    const void *pixels)
918*8975f5c5SAndroid Build Coastguard Worker {
919*8975f5c5SAndroid Build Coastguard Worker     if (!ValidTexture2DDestinationTarget(context, target))
920*8975f5c5SAndroid Build Coastguard Worker     {
921*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
922*8975f5c5SAndroid Build Coastguard Worker         return false;
923*8975f5c5SAndroid Build Coastguard Worker     }
924*8975f5c5SAndroid Build Coastguard Worker 
925*8975f5c5SAndroid Build Coastguard Worker     return ValidateES2TexImageParametersBase(context, entryPoint, target, level, internalformat,
926*8975f5c5SAndroid Build Coastguard Worker                                              isCompressed, isSubImage, xoffset, yoffset, width,
927*8975f5c5SAndroid Build Coastguard Worker                                              height, border, format, type, imageSize, pixels);
928*8975f5c5SAndroid Build Coastguard Worker }
929*8975f5c5SAndroid Build Coastguard Worker 
930*8975f5c5SAndroid Build Coastguard Worker }  // anonymous namespace
931*8975f5c5SAndroid Build Coastguard Worker 
ValidateES2TexImageParametersBase(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,bool isCompressed,bool isSubImage,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,GLsizei imageSize,const void * pixels)932*8975f5c5SAndroid Build Coastguard Worker bool ValidateES2TexImageParametersBase(const Context *context,
933*8975f5c5SAndroid Build Coastguard Worker                                        angle::EntryPoint entryPoint,
934*8975f5c5SAndroid Build Coastguard Worker                                        TextureTarget target,
935*8975f5c5SAndroid Build Coastguard Worker                                        GLint level,
936*8975f5c5SAndroid Build Coastguard Worker                                        GLenum internalformat,
937*8975f5c5SAndroid Build Coastguard Worker                                        bool isCompressed,
938*8975f5c5SAndroid Build Coastguard Worker                                        bool isSubImage,
939*8975f5c5SAndroid Build Coastguard Worker                                        GLint xoffset,
940*8975f5c5SAndroid Build Coastguard Worker                                        GLint yoffset,
941*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei width,
942*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei height,
943*8975f5c5SAndroid Build Coastguard Worker                                        GLint border,
944*8975f5c5SAndroid Build Coastguard Worker                                        GLenum format,
945*8975f5c5SAndroid Build Coastguard Worker                                        GLenum type,
946*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei imageSize,
947*8975f5c5SAndroid Build Coastguard Worker                                        const void *pixels)
948*8975f5c5SAndroid Build Coastguard Worker {
949*8975f5c5SAndroid Build Coastguard Worker 
950*8975f5c5SAndroid Build Coastguard Worker     TextureType texType = TextureTargetToType(target);
951*8975f5c5SAndroid Build Coastguard Worker     if (!ValidImageSizeParameters(context, entryPoint, texType, level, width, height, 1,
952*8975f5c5SAndroid Build Coastguard Worker                                   isSubImage))
953*8975f5c5SAndroid Build Coastguard Worker     {
954*8975f5c5SAndroid Build Coastguard Worker         // Error already handled.
955*8975f5c5SAndroid Build Coastguard Worker         return false;
956*8975f5c5SAndroid Build Coastguard Worker     }
957*8975f5c5SAndroid Build Coastguard Worker 
958*8975f5c5SAndroid Build Coastguard Worker     if ((xoffset < 0 || std::numeric_limits<GLsizei>::max() - xoffset < width) ||
959*8975f5c5SAndroid Build Coastguard Worker         (yoffset < 0 || std::numeric_limits<GLsizei>::max() - yoffset < height))
960*8975f5c5SAndroid Build Coastguard Worker     {
961*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kResourceMaxTextureSize);
962*8975f5c5SAndroid Build Coastguard Worker         return false;
963*8975f5c5SAndroid Build Coastguard Worker     }
964*8975f5c5SAndroid Build Coastguard Worker 
965*8975f5c5SAndroid Build Coastguard Worker     const Caps &caps = context->getCaps();
966*8975f5c5SAndroid Build Coastguard Worker 
967*8975f5c5SAndroid Build Coastguard Worker     switch (texType)
968*8975f5c5SAndroid Build Coastguard Worker     {
969*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_2D:
970*8975f5c5SAndroid Build Coastguard Worker         case TextureType::External:
971*8975f5c5SAndroid Build Coastguard Worker         case TextureType::VideoImage:
972*8975f5c5SAndroid Build Coastguard Worker             if (width > (caps.max2DTextureSize >> level) ||
973*8975f5c5SAndroid Build Coastguard Worker                 height > (caps.max2DTextureSize >> level))
974*8975f5c5SAndroid Build Coastguard Worker             {
975*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kResourceMaxTextureSize);
976*8975f5c5SAndroid Build Coastguard Worker                 return false;
977*8975f5c5SAndroid Build Coastguard Worker             }
978*8975f5c5SAndroid Build Coastguard Worker             break;
979*8975f5c5SAndroid Build Coastguard Worker 
980*8975f5c5SAndroid Build Coastguard Worker         case TextureType::Rectangle:
981*8975f5c5SAndroid Build Coastguard Worker             ASSERT(level == 0);
982*8975f5c5SAndroid Build Coastguard Worker             if (width > caps.maxRectangleTextureSize || height > caps.maxRectangleTextureSize)
983*8975f5c5SAndroid Build Coastguard Worker             {
984*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kResourceMaxTextureSize);
985*8975f5c5SAndroid Build Coastguard Worker                 return false;
986*8975f5c5SAndroid Build Coastguard Worker             }
987*8975f5c5SAndroid Build Coastguard Worker             if (isCompressed)
988*8975f5c5SAndroid Build Coastguard Worker             {
989*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kRectangleTextureCompressed);
990*8975f5c5SAndroid Build Coastguard Worker                 return false;
991*8975f5c5SAndroid Build Coastguard Worker             }
992*8975f5c5SAndroid Build Coastguard Worker             break;
993*8975f5c5SAndroid Build Coastguard Worker 
994*8975f5c5SAndroid Build Coastguard Worker         case TextureType::CubeMap:
995*8975f5c5SAndroid Build Coastguard Worker             if (!isSubImage && width != height)
996*8975f5c5SAndroid Build Coastguard Worker             {
997*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kCubemapFacesEqualDimensions);
998*8975f5c5SAndroid Build Coastguard Worker                 return false;
999*8975f5c5SAndroid Build Coastguard Worker             }
1000*8975f5c5SAndroid Build Coastguard Worker 
1001*8975f5c5SAndroid Build Coastguard Worker             if (width > (caps.maxCubeMapTextureSize >> level) ||
1002*8975f5c5SAndroid Build Coastguard Worker                 height > (caps.maxCubeMapTextureSize >> level))
1003*8975f5c5SAndroid Build Coastguard Worker             {
1004*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kResourceMaxTextureSize);
1005*8975f5c5SAndroid Build Coastguard Worker                 return false;
1006*8975f5c5SAndroid Build Coastguard Worker             }
1007*8975f5c5SAndroid Build Coastguard Worker             break;
1008*8975f5c5SAndroid Build Coastguard Worker 
1009*8975f5c5SAndroid Build Coastguard Worker         default:
1010*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
1011*8975f5c5SAndroid Build Coastguard Worker             return false;
1012*8975f5c5SAndroid Build Coastguard Worker     }
1013*8975f5c5SAndroid Build Coastguard Worker 
1014*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = context->getTextureByType(texType);
1015*8975f5c5SAndroid Build Coastguard Worker     if (!texture)
1016*8975f5c5SAndroid Build Coastguard Worker     {
1017*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferNotBound);
1018*8975f5c5SAndroid Build Coastguard Worker         return false;
1019*8975f5c5SAndroid Build Coastguard Worker     }
1020*8975f5c5SAndroid Build Coastguard Worker 
1021*8975f5c5SAndroid Build Coastguard Worker     // Verify zero border
1022*8975f5c5SAndroid Build Coastguard Worker     if (border != 0)
1023*8975f5c5SAndroid Build Coastguard Worker     {
1024*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidBorder);
1025*8975f5c5SAndroid Build Coastguard Worker         return false;
1026*8975f5c5SAndroid Build Coastguard Worker     }
1027*8975f5c5SAndroid Build Coastguard Worker 
1028*8975f5c5SAndroid Build Coastguard Worker     bool nonEqualFormatsAllowed = false;
1029*8975f5c5SAndroid Build Coastguard Worker 
1030*8975f5c5SAndroid Build Coastguard Worker     if (isCompressed)
1031*8975f5c5SAndroid Build Coastguard Worker     {
1032*8975f5c5SAndroid Build Coastguard Worker         GLenum actualInternalFormat =
1033*8975f5c5SAndroid Build Coastguard Worker             isSubImage ? texture->getFormat(target, level).info->sizedInternalFormat
1034*8975f5c5SAndroid Build Coastguard Worker                        : internalformat;
1035*8975f5c5SAndroid Build Coastguard Worker 
1036*8975f5c5SAndroid Build Coastguard Worker         const InternalFormat &internalFormatInfo = GetSizedInternalFormatInfo(actualInternalFormat);
1037*8975f5c5SAndroid Build Coastguard Worker 
1038*8975f5c5SAndroid Build Coastguard Worker         if (!internalFormatInfo.compressed && !internalFormatInfo.paletted)
1039*8975f5c5SAndroid Build Coastguard Worker         {
1040*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kInvalidInternalFormat, internalformat);
1041*8975f5c5SAndroid Build Coastguard Worker             return false;
1042*8975f5c5SAndroid Build Coastguard Worker         }
1043*8975f5c5SAndroid Build Coastguard Worker 
1044*8975f5c5SAndroid Build Coastguard Worker         if (!internalFormatInfo.textureSupport(context->getClientVersion(),
1045*8975f5c5SAndroid Build Coastguard Worker                                                context->getExtensions()))
1046*8975f5c5SAndroid Build Coastguard Worker         {
1047*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kInvalidInternalFormat, internalformat);
1048*8975f5c5SAndroid Build Coastguard Worker             return false;
1049*8975f5c5SAndroid Build Coastguard Worker         }
1050*8975f5c5SAndroid Build Coastguard Worker 
1051*8975f5c5SAndroid Build Coastguard Worker         if (isSubImage)
1052*8975f5c5SAndroid Build Coastguard Worker         {
1053*8975f5c5SAndroid Build Coastguard Worker             // From OpenGL ES Version 1.1.12, section 3.7.4 Compressed Paletted
1054*8975f5c5SAndroid Build Coastguard Worker             // Textures:
1055*8975f5c5SAndroid Build Coastguard Worker             //
1056*8975f5c5SAndroid Build Coastguard Worker             // Subimages may not be specified for compressed paletted textures.
1057*8975f5c5SAndroid Build Coastguard Worker             // Calling CompressedTexSubImage2D with any of the PALETTE*
1058*8975f5c5SAndroid Build Coastguard Worker             // arguments in table 3.11 will generate an INVALID OPERATION error.
1059*8975f5c5SAndroid Build Coastguard Worker             if (internalFormatInfo.paletted)
1060*8975f5c5SAndroid Build Coastguard Worker             {
1061*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERRORF(GL_INVALID_OPERATION, kInvalidInternalFormat,
1062*8975f5c5SAndroid Build Coastguard Worker                                         internalformat);
1063*8975f5c5SAndroid Build Coastguard Worker                 return false;
1064*8975f5c5SAndroid Build Coastguard Worker             }
1065*8975f5c5SAndroid Build Coastguard Worker 
1066*8975f5c5SAndroid Build Coastguard Worker             // From the OES_compressed_ETC1_RGB8_texture spec:
1067*8975f5c5SAndroid Build Coastguard Worker             //
1068*8975f5c5SAndroid Build Coastguard Worker             // INVALID_OPERATION is generated by CompressedTexSubImage2D, TexSubImage2D, or
1069*8975f5c5SAndroid Build Coastguard Worker             // CopyTexSubImage2D if the texture image <level> bound to <target> has internal format
1070*8975f5c5SAndroid Build Coastguard Worker             // ETC1_RGB8_OES.
1071*8975f5c5SAndroid Build Coastguard Worker             //
1072*8975f5c5SAndroid Build Coastguard Worker             // This is relaxed if GL_EXT_compressed_ETC1_RGB8_sub_texture is supported.
1073*8975f5c5SAndroid Build Coastguard Worker             if (IsETC1Format(actualInternalFormat) &&
1074*8975f5c5SAndroid Build Coastguard Worker                 !context->getExtensions().compressedETC1RGB8SubTextureEXT)
1075*8975f5c5SAndroid Build Coastguard Worker             {
1076*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERRORF(GL_INVALID_OPERATION, kInvalidInternalFormat,
1077*8975f5c5SAndroid Build Coastguard Worker                                         internalformat);
1078*8975f5c5SAndroid Build Coastguard Worker                 return false;
1079*8975f5c5SAndroid Build Coastguard Worker             }
1080*8975f5c5SAndroid Build Coastguard Worker 
1081*8975f5c5SAndroid Build Coastguard Worker             if (!ValidCompressedSubImageSize(context, actualInternalFormat, xoffset, yoffset, 0,
1082*8975f5c5SAndroid Build Coastguard Worker                                              width, height, 1, texture->getWidth(target, level),
1083*8975f5c5SAndroid Build Coastguard Worker                                              texture->getHeight(target, level),
1084*8975f5c5SAndroid Build Coastguard Worker                                              texture->getDepth(target, level)))
1085*8975f5c5SAndroid Build Coastguard Worker             {
1086*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
1087*8975f5c5SAndroid Build Coastguard Worker                 return false;
1088*8975f5c5SAndroid Build Coastguard Worker             }
1089*8975f5c5SAndroid Build Coastguard Worker 
1090*8975f5c5SAndroid Build Coastguard Worker             if (format != actualInternalFormat)
1091*8975f5c5SAndroid Build Coastguard Worker             {
1092*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormat);
1093*8975f5c5SAndroid Build Coastguard Worker                 return false;
1094*8975f5c5SAndroid Build Coastguard Worker             }
1095*8975f5c5SAndroid Build Coastguard Worker         }
1096*8975f5c5SAndroid Build Coastguard Worker         else
1097*8975f5c5SAndroid Build Coastguard Worker         {
1098*8975f5c5SAndroid Build Coastguard Worker             if (!ValidCompressedImageSize(context, actualInternalFormat, level, width, height, 1))
1099*8975f5c5SAndroid Build Coastguard Worker             {
1100*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
1101*8975f5c5SAndroid Build Coastguard Worker                 return false;
1102*8975f5c5SAndroid Build Coastguard Worker             }
1103*8975f5c5SAndroid Build Coastguard Worker         }
1104*8975f5c5SAndroid Build Coastguard Worker     }
1105*8975f5c5SAndroid Build Coastguard Worker     else
1106*8975f5c5SAndroid Build Coastguard Worker     {
1107*8975f5c5SAndroid Build Coastguard Worker         // validate <type> by itself (used as secondary key below)
1108*8975f5c5SAndroid Build Coastguard Worker         switch (type)
1109*8975f5c5SAndroid Build Coastguard Worker         {
1110*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_BYTE:
1111*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_SHORT_5_6_5:
1112*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_SHORT_4_4_4_4:
1113*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_SHORT_5_5_5_1:
1114*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_SHORT:
1115*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_INT:
1116*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_INT_24_8_OES:
1117*8975f5c5SAndroid Build Coastguard Worker             case GL_HALF_FLOAT_OES:
1118*8975f5c5SAndroid Build Coastguard Worker             case GL_FLOAT:
1119*8975f5c5SAndroid Build Coastguard Worker                 break;
1120*8975f5c5SAndroid Build Coastguard Worker             case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
1121*8975f5c5SAndroid Build Coastguard Worker                 if (!context->getExtensions().textureType2101010REVEXT)
1122*8975f5c5SAndroid Build Coastguard Worker                 {
1123*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, type);
1124*8975f5c5SAndroid Build Coastguard Worker                     return false;
1125*8975f5c5SAndroid Build Coastguard Worker                 }
1126*8975f5c5SAndroid Build Coastguard Worker                 break;
1127*8975f5c5SAndroid Build Coastguard Worker             default:
1128*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidType);
1129*8975f5c5SAndroid Build Coastguard Worker                 return false;
1130*8975f5c5SAndroid Build Coastguard Worker         }
1131*8975f5c5SAndroid Build Coastguard Worker 
1132*8975f5c5SAndroid Build Coastguard Worker         // validate <format> + <type> combinations
1133*8975f5c5SAndroid Build Coastguard Worker         // - invalid <format> -> sets INVALID_ENUM
1134*8975f5c5SAndroid Build Coastguard Worker         // - invalid <format>+<type> combination -> sets INVALID_OPERATION
1135*8975f5c5SAndroid Build Coastguard Worker         switch (format)
1136*8975f5c5SAndroid Build Coastguard Worker         {
1137*8975f5c5SAndroid Build Coastguard Worker             case GL_ALPHA:
1138*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE:
1139*8975f5c5SAndroid Build Coastguard Worker             case GL_LUMINANCE_ALPHA:
1140*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1141*8975f5c5SAndroid Build Coastguard Worker                 {
1142*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_BYTE:
1143*8975f5c5SAndroid Build Coastguard Worker                     case GL_FLOAT:
1144*8975f5c5SAndroid Build Coastguard Worker                     case GL_HALF_FLOAT_OES:
1145*8975f5c5SAndroid Build Coastguard Worker                         break;
1146*8975f5c5SAndroid Build Coastguard Worker                     default:
1147*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1148*8975f5c5SAndroid Build Coastguard Worker                         return false;
1149*8975f5c5SAndroid Build Coastguard Worker                 }
1150*8975f5c5SAndroid Build Coastguard Worker                 break;
1151*8975f5c5SAndroid Build Coastguard Worker             case GL_RED:
1152*8975f5c5SAndroid Build Coastguard Worker             case GL_RG:
1153*8975f5c5SAndroid Build Coastguard Worker                 if (!context->getExtensions().textureRgEXT)
1154*8975f5c5SAndroid Build Coastguard Worker                 {
1155*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, format);
1156*8975f5c5SAndroid Build Coastguard Worker                     return false;
1157*8975f5c5SAndroid Build Coastguard Worker                 }
1158*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1159*8975f5c5SAndroid Build Coastguard Worker                 {
1160*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_BYTE:
1161*8975f5c5SAndroid Build Coastguard Worker                         break;
1162*8975f5c5SAndroid Build Coastguard Worker                     case GL_FLOAT:
1163*8975f5c5SAndroid Build Coastguard Worker                         if (!context->getExtensions().textureFloatOES)
1164*8975f5c5SAndroid Build Coastguard Worker                         {
1165*8975f5c5SAndroid Build Coastguard Worker                             ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, type);
1166*8975f5c5SAndroid Build Coastguard Worker                             return false;
1167*8975f5c5SAndroid Build Coastguard Worker                         }
1168*8975f5c5SAndroid Build Coastguard Worker                         break;
1169*8975f5c5SAndroid Build Coastguard Worker                     case GL_HALF_FLOAT_OES:
1170*8975f5c5SAndroid Build Coastguard Worker                         if (!context->getExtensions().textureFloatOES &&
1171*8975f5c5SAndroid Build Coastguard Worker                             !context->getExtensions().textureHalfFloatOES)
1172*8975f5c5SAndroid Build Coastguard Worker                         {
1173*8975f5c5SAndroid Build Coastguard Worker                             ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, type);
1174*8975f5c5SAndroid Build Coastguard Worker                             return false;
1175*8975f5c5SAndroid Build Coastguard Worker                         }
1176*8975f5c5SAndroid Build Coastguard Worker                         break;
1177*8975f5c5SAndroid Build Coastguard Worker                     case GL_SHORT:
1178*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_SHORT:
1179*8975f5c5SAndroid Build Coastguard Worker                         if (!context->getExtensions().textureNorm16EXT)
1180*8975f5c5SAndroid Build Coastguard Worker                         {
1181*8975f5c5SAndroid Build Coastguard Worker                             ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, type);
1182*8975f5c5SAndroid Build Coastguard Worker                             return false;
1183*8975f5c5SAndroid Build Coastguard Worker                         }
1184*8975f5c5SAndroid Build Coastguard Worker                         break;
1185*8975f5c5SAndroid Build Coastguard Worker                     default:
1186*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1187*8975f5c5SAndroid Build Coastguard Worker                         return false;
1188*8975f5c5SAndroid Build Coastguard Worker                 }
1189*8975f5c5SAndroid Build Coastguard Worker                 break;
1190*8975f5c5SAndroid Build Coastguard Worker             case GL_RGB:
1191*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1192*8975f5c5SAndroid Build Coastguard Worker                 {
1193*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_BYTE:
1194*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_SHORT_5_6_5:
1195*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
1196*8975f5c5SAndroid Build Coastguard Worker                     case GL_FLOAT:
1197*8975f5c5SAndroid Build Coastguard Worker                     case GL_HALF_FLOAT_OES:
1198*8975f5c5SAndroid Build Coastguard Worker                         break;
1199*8975f5c5SAndroid Build Coastguard Worker                     case GL_SHORT:
1200*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_SHORT:
1201*8975f5c5SAndroid Build Coastguard Worker                         if (!context->getExtensions().textureNorm16EXT)
1202*8975f5c5SAndroid Build Coastguard Worker                         {
1203*8975f5c5SAndroid Build Coastguard Worker                             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1204*8975f5c5SAndroid Build Coastguard Worker                             return false;
1205*8975f5c5SAndroid Build Coastguard Worker                         }
1206*8975f5c5SAndroid Build Coastguard Worker                         break;
1207*8975f5c5SAndroid Build Coastguard Worker                     default:
1208*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1209*8975f5c5SAndroid Build Coastguard Worker                         return false;
1210*8975f5c5SAndroid Build Coastguard Worker                 }
1211*8975f5c5SAndroid Build Coastguard Worker                 break;
1212*8975f5c5SAndroid Build Coastguard Worker             case GL_RGBA:
1213*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1214*8975f5c5SAndroid Build Coastguard Worker                 {
1215*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_BYTE:
1216*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_SHORT_4_4_4_4:
1217*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_SHORT_5_5_5_1:
1218*8975f5c5SAndroid Build Coastguard Worker                     case GL_FLOAT:
1219*8975f5c5SAndroid Build Coastguard Worker                     case GL_HALF_FLOAT_OES:
1220*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
1221*8975f5c5SAndroid Build Coastguard Worker                         break;
1222*8975f5c5SAndroid Build Coastguard Worker                     case GL_SHORT:
1223*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_SHORT:
1224*8975f5c5SAndroid Build Coastguard Worker                         if (!context->getExtensions().textureNorm16EXT)
1225*8975f5c5SAndroid Build Coastguard Worker                         {
1226*8975f5c5SAndroid Build Coastguard Worker                             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1227*8975f5c5SAndroid Build Coastguard Worker                             return false;
1228*8975f5c5SAndroid Build Coastguard Worker                         }
1229*8975f5c5SAndroid Build Coastguard Worker                         break;
1230*8975f5c5SAndroid Build Coastguard Worker                     default:
1231*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1232*8975f5c5SAndroid Build Coastguard Worker                         return false;
1233*8975f5c5SAndroid Build Coastguard Worker                 }
1234*8975f5c5SAndroid Build Coastguard Worker                 break;
1235*8975f5c5SAndroid Build Coastguard Worker             case GL_BGRA_EXT:
1236*8975f5c5SAndroid Build Coastguard Worker                 if (!context->getExtensions().textureFormatBGRA8888EXT)
1237*8975f5c5SAndroid Build Coastguard Worker                 {
1238*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, format);
1239*8975f5c5SAndroid Build Coastguard Worker                     return false;
1240*8975f5c5SAndroid Build Coastguard Worker                 }
1241*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1242*8975f5c5SAndroid Build Coastguard Worker                 {
1243*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_BYTE:
1244*8975f5c5SAndroid Build Coastguard Worker                         break;
1245*8975f5c5SAndroid Build Coastguard Worker                     default:
1246*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1247*8975f5c5SAndroid Build Coastguard Worker                         return false;
1248*8975f5c5SAndroid Build Coastguard Worker                 }
1249*8975f5c5SAndroid Build Coastguard Worker                 break;
1250*8975f5c5SAndroid Build Coastguard Worker             case GL_SRGB_EXT:
1251*8975f5c5SAndroid Build Coastguard Worker             case GL_SRGB_ALPHA_EXT:
1252*8975f5c5SAndroid Build Coastguard Worker                 if (!context->getExtensions().sRGBEXT)
1253*8975f5c5SAndroid Build Coastguard Worker                 {
1254*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, format);
1255*8975f5c5SAndroid Build Coastguard Worker                     return false;
1256*8975f5c5SAndroid Build Coastguard Worker                 }
1257*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1258*8975f5c5SAndroid Build Coastguard Worker                 {
1259*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_BYTE:
1260*8975f5c5SAndroid Build Coastguard Worker                         break;
1261*8975f5c5SAndroid Build Coastguard Worker                     default:
1262*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1263*8975f5c5SAndroid Build Coastguard Worker                         return false;
1264*8975f5c5SAndroid Build Coastguard Worker                 }
1265*8975f5c5SAndroid Build Coastguard Worker                 break;
1266*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH_COMPONENT:
1267*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1268*8975f5c5SAndroid Build Coastguard Worker                 {
1269*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_SHORT:
1270*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_INT:
1271*8975f5c5SAndroid Build Coastguard Worker                         break;
1272*8975f5c5SAndroid Build Coastguard Worker                     case GL_FLOAT:
1273*8975f5c5SAndroid Build Coastguard Worker                         if (!context->getExtensions().depthBufferFloat2NV)
1274*8975f5c5SAndroid Build Coastguard Worker                         {
1275*8975f5c5SAndroid Build Coastguard Worker                             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1276*8975f5c5SAndroid Build Coastguard Worker                             return false;
1277*8975f5c5SAndroid Build Coastguard Worker                         }
1278*8975f5c5SAndroid Build Coastguard Worker                         break;
1279*8975f5c5SAndroid Build Coastguard Worker                     default:
1280*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1281*8975f5c5SAndroid Build Coastguard Worker                         return false;
1282*8975f5c5SAndroid Build Coastguard Worker                 }
1283*8975f5c5SAndroid Build Coastguard Worker                 break;
1284*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH_STENCIL_OES:
1285*8975f5c5SAndroid Build Coastguard Worker                 switch (type)
1286*8975f5c5SAndroid Build Coastguard Worker                 {
1287*8975f5c5SAndroid Build Coastguard Worker                     case GL_UNSIGNED_INT_24_8_OES:
1288*8975f5c5SAndroid Build Coastguard Worker                         break;
1289*8975f5c5SAndroid Build Coastguard Worker                     default:
1290*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1291*8975f5c5SAndroid Build Coastguard Worker                         return false;
1292*8975f5c5SAndroid Build Coastguard Worker                 }
1293*8975f5c5SAndroid Build Coastguard Worker                 break;
1294*8975f5c5SAndroid Build Coastguard Worker             default:
1295*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, format);
1296*8975f5c5SAndroid Build Coastguard Worker                 return false;
1297*8975f5c5SAndroid Build Coastguard Worker         }
1298*8975f5c5SAndroid Build Coastguard Worker 
1299*8975f5c5SAndroid Build Coastguard Worker         switch (format)
1300*8975f5c5SAndroid Build Coastguard Worker         {
1301*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH_COMPONENT:
1302*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH_STENCIL_OES:
1303*8975f5c5SAndroid Build Coastguard Worker                 if (!context->getExtensions().depthTextureANGLE &&
1304*8975f5c5SAndroid Build Coastguard Worker                     !((context->getExtensions().packedDepthStencilOES ||
1305*8975f5c5SAndroid Build Coastguard Worker                        context->getExtensions().depthTextureCubeMapOES) &&
1306*8975f5c5SAndroid Build Coastguard Worker                       context->getExtensions().depthTextureOES))
1307*8975f5c5SAndroid Build Coastguard Worker                 {
1308*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, format);
1309*8975f5c5SAndroid Build Coastguard Worker                     return false;
1310*8975f5c5SAndroid Build Coastguard Worker                 }
1311*8975f5c5SAndroid Build Coastguard Worker 
1312*8975f5c5SAndroid Build Coastguard Worker                 switch (target)
1313*8975f5c5SAndroid Build Coastguard Worker                 {
1314*8975f5c5SAndroid Build Coastguard Worker                     case TextureTarget::_2D:
1315*8975f5c5SAndroid Build Coastguard Worker                         break;
1316*8975f5c5SAndroid Build Coastguard Worker                     case TextureTarget::CubeMapNegativeX:
1317*8975f5c5SAndroid Build Coastguard Worker                     case TextureTarget::CubeMapNegativeY:
1318*8975f5c5SAndroid Build Coastguard Worker                     case TextureTarget::CubeMapNegativeZ:
1319*8975f5c5SAndroid Build Coastguard Worker                     case TextureTarget::CubeMapPositiveX:
1320*8975f5c5SAndroid Build Coastguard Worker                     case TextureTarget::CubeMapPositiveY:
1321*8975f5c5SAndroid Build Coastguard Worker                     case TextureTarget::CubeMapPositiveZ:
1322*8975f5c5SAndroid Build Coastguard Worker                         if (!context->getExtensions().depthTextureCubeMapOES)
1323*8975f5c5SAndroid Build Coastguard Worker                         {
1324*8975f5c5SAndroid Build Coastguard Worker                             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
1325*8975f5c5SAndroid Build Coastguard Worker                                                    kMismatchedTargetAndFormat);
1326*8975f5c5SAndroid Build Coastguard Worker                             return false;
1327*8975f5c5SAndroid Build Coastguard Worker                         }
1328*8975f5c5SAndroid Build Coastguard Worker                         break;
1329*8975f5c5SAndroid Build Coastguard Worker                     default:
1330*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTargetAndFormat);
1331*8975f5c5SAndroid Build Coastguard Worker                         return false;
1332*8975f5c5SAndroid Build Coastguard Worker                 }
1333*8975f5c5SAndroid Build Coastguard Worker 
1334*8975f5c5SAndroid Build Coastguard Worker                 // OES_depth_texture supports loading depth data and multiple levels,
1335*8975f5c5SAndroid Build Coastguard Worker                 // but ANGLE_depth_texture does not
1336*8975f5c5SAndroid Build Coastguard Worker                 if (!context->getExtensions().depthTextureOES)
1337*8975f5c5SAndroid Build Coastguard Worker                 {
1338*8975f5c5SAndroid Build Coastguard Worker                     if (pixels != nullptr)
1339*8975f5c5SAndroid Build Coastguard Worker                     {
1340*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kPixelDataNotNull);
1341*8975f5c5SAndroid Build Coastguard Worker                         return false;
1342*8975f5c5SAndroid Build Coastguard Worker                     }
1343*8975f5c5SAndroid Build Coastguard Worker                     if (level != 0)
1344*8975f5c5SAndroid Build Coastguard Worker                     {
1345*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kLevelNotZero);
1346*8975f5c5SAndroid Build Coastguard Worker                         return false;
1347*8975f5c5SAndroid Build Coastguard Worker                     }
1348*8975f5c5SAndroid Build Coastguard Worker                 }
1349*8975f5c5SAndroid Build Coastguard Worker                 break;
1350*8975f5c5SAndroid Build Coastguard Worker             default:
1351*8975f5c5SAndroid Build Coastguard Worker                 break;
1352*8975f5c5SAndroid Build Coastguard Worker         }
1353*8975f5c5SAndroid Build Coastguard Worker 
1354*8975f5c5SAndroid Build Coastguard Worker         if (!isSubImage)
1355*8975f5c5SAndroid Build Coastguard Worker         {
1356*8975f5c5SAndroid Build Coastguard Worker             switch (internalformat)
1357*8975f5c5SAndroid Build Coastguard Worker             {
1358*8975f5c5SAndroid Build Coastguard Worker                 // Core ES 2.0 formats
1359*8975f5c5SAndroid Build Coastguard Worker                 case GL_ALPHA:
1360*8975f5c5SAndroid Build Coastguard Worker                 case GL_LUMINANCE:
1361*8975f5c5SAndroid Build Coastguard Worker                 case GL_LUMINANCE_ALPHA:
1362*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB:
1363*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGBA:
1364*8975f5c5SAndroid Build Coastguard Worker                     break;
1365*8975f5c5SAndroid Build Coastguard Worker 
1366*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGBA32F:
1367*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().colorBufferFloatRgbaCHROMIUM)
1368*8975f5c5SAndroid Build Coastguard Worker                     {
1369*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1370*8975f5c5SAndroid Build Coastguard Worker                         return false;
1371*8975f5c5SAndroid Build Coastguard Worker                     }
1372*8975f5c5SAndroid Build Coastguard Worker 
1373*8975f5c5SAndroid Build Coastguard Worker                     nonEqualFormatsAllowed = true;
1374*8975f5c5SAndroid Build Coastguard Worker 
1375*8975f5c5SAndroid Build Coastguard Worker                     if (type != GL_FLOAT)
1376*8975f5c5SAndroid Build Coastguard Worker                     {
1377*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1378*8975f5c5SAndroid Build Coastguard Worker                         return false;
1379*8975f5c5SAndroid Build Coastguard Worker                     }
1380*8975f5c5SAndroid Build Coastguard Worker                     if (format != GL_RGBA)
1381*8975f5c5SAndroid Build Coastguard Worker                     {
1382*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1383*8975f5c5SAndroid Build Coastguard Worker                         return false;
1384*8975f5c5SAndroid Build Coastguard Worker                     }
1385*8975f5c5SAndroid Build Coastguard Worker                     break;
1386*8975f5c5SAndroid Build Coastguard Worker 
1387*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB32F:
1388*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().colorBufferFloatRgbCHROMIUM)
1389*8975f5c5SAndroid Build Coastguard Worker                     {
1390*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1391*8975f5c5SAndroid Build Coastguard Worker                         return false;
1392*8975f5c5SAndroid Build Coastguard Worker                     }
1393*8975f5c5SAndroid Build Coastguard Worker 
1394*8975f5c5SAndroid Build Coastguard Worker                     nonEqualFormatsAllowed = true;
1395*8975f5c5SAndroid Build Coastguard Worker 
1396*8975f5c5SAndroid Build Coastguard Worker                     if (type != GL_FLOAT)
1397*8975f5c5SAndroid Build Coastguard Worker                     {
1398*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1399*8975f5c5SAndroid Build Coastguard Worker                         return false;
1400*8975f5c5SAndroid Build Coastguard Worker                     }
1401*8975f5c5SAndroid Build Coastguard Worker                     if (format != GL_RGB)
1402*8975f5c5SAndroid Build Coastguard Worker                     {
1403*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1404*8975f5c5SAndroid Build Coastguard Worker                         return false;
1405*8975f5c5SAndroid Build Coastguard Worker                     }
1406*8975f5c5SAndroid Build Coastguard Worker                     break;
1407*8975f5c5SAndroid Build Coastguard Worker 
1408*8975f5c5SAndroid Build Coastguard Worker                 case GL_BGRA_EXT:
1409*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().textureFormatBGRA8888EXT)
1410*8975f5c5SAndroid Build Coastguard Worker                     {
1411*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1412*8975f5c5SAndroid Build Coastguard Worker                         return false;
1413*8975f5c5SAndroid Build Coastguard Worker                     }
1414*8975f5c5SAndroid Build Coastguard Worker                     break;
1415*8975f5c5SAndroid Build Coastguard Worker 
1416*8975f5c5SAndroid Build Coastguard Worker                 case GL_DEPTH_COMPONENT:
1417*8975f5c5SAndroid Build Coastguard Worker                     if (!(context->getExtensions().depthTextureAny()))
1418*8975f5c5SAndroid Build Coastguard Worker                     {
1419*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1420*8975f5c5SAndroid Build Coastguard Worker                         return false;
1421*8975f5c5SAndroid Build Coastguard Worker                     }
1422*8975f5c5SAndroid Build Coastguard Worker                     break;
1423*8975f5c5SAndroid Build Coastguard Worker 
1424*8975f5c5SAndroid Build Coastguard Worker                 case GL_DEPTH_STENCIL:
1425*8975f5c5SAndroid Build Coastguard Worker                     if (!(context->getExtensions().depthTextureANGLE ||
1426*8975f5c5SAndroid Build Coastguard Worker                           context->getExtensions().packedDepthStencilOES ||
1427*8975f5c5SAndroid Build Coastguard Worker                           context->getExtensions().depthTextureCubeMapOES))
1428*8975f5c5SAndroid Build Coastguard Worker                     {
1429*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1430*8975f5c5SAndroid Build Coastguard Worker                         return false;
1431*8975f5c5SAndroid Build Coastguard Worker                     }
1432*8975f5c5SAndroid Build Coastguard Worker                     break;
1433*8975f5c5SAndroid Build Coastguard Worker                 // Valid sized internal format for GL_OES_required_internalformat.
1434*8975f5c5SAndroid Build Coastguard Worker                 case GL_ALPHA8_OES:
1435*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1436*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_BYTE && format == GL_ALPHA)
1437*8975f5c5SAndroid Build Coastguard Worker                     {
1438*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1439*8975f5c5SAndroid Build Coastguard Worker                     }
1440*8975f5c5SAndroid Build Coastguard Worker                     break;
1441*8975f5c5SAndroid Build Coastguard Worker 
1442*8975f5c5SAndroid Build Coastguard Worker                 case GL_LUMINANCE8_OES:
1443*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1444*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_BYTE && format == GL_LUMINANCE)
1445*8975f5c5SAndroid Build Coastguard Worker                     {
1446*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1447*8975f5c5SAndroid Build Coastguard Worker                     }
1448*8975f5c5SAndroid Build Coastguard Worker                     break;
1449*8975f5c5SAndroid Build Coastguard Worker 
1450*8975f5c5SAndroid Build Coastguard Worker                 case GL_LUMINANCE4_ALPHA4_OES:
1451*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1452*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_BYTE && format == GL_LUMINANCE_ALPHA)
1453*8975f5c5SAndroid Build Coastguard Worker                     {
1454*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1455*8975f5c5SAndroid Build Coastguard Worker                     }
1456*8975f5c5SAndroid Build Coastguard Worker                     break;
1457*8975f5c5SAndroid Build Coastguard Worker 
1458*8975f5c5SAndroid Build Coastguard Worker                 case GL_LUMINANCE8_ALPHA8_OES:
1459*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1460*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_BYTE && format == GL_LUMINANCE_ALPHA)
1461*8975f5c5SAndroid Build Coastguard Worker                     {
1462*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1463*8975f5c5SAndroid Build Coastguard Worker                     }
1464*8975f5c5SAndroid Build Coastguard Worker                     break;
1465*8975f5c5SAndroid Build Coastguard Worker 
1466*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB565_OES:
1467*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1468*8975f5c5SAndroid Build Coastguard Worker                         (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT_5_6_5) &&
1469*8975f5c5SAndroid Build Coastguard Worker                         format == GL_RGB)
1470*8975f5c5SAndroid Build Coastguard Worker                     {
1471*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1472*8975f5c5SAndroid Build Coastguard Worker                     }
1473*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1474*8975f5c5SAndroid Build Coastguard Worker                         context->getExtensions().textureType2101010REVEXT &&
1475*8975f5c5SAndroid Build Coastguard Worker                         GL_UNSIGNED_INT_2_10_10_10_REV_EXT && format == GL_RGB)
1476*8975f5c5SAndroid Build Coastguard Worker                     {
1477*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1478*8975f5c5SAndroid Build Coastguard Worker                     }
1479*8975f5c5SAndroid Build Coastguard Worker                     break;
1480*8975f5c5SAndroid Build Coastguard Worker 
1481*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB8_OES:
1482*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1483*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_BYTE && format == GL_RGB)
1484*8975f5c5SAndroid Build Coastguard Worker                     {
1485*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1486*8975f5c5SAndroid Build Coastguard Worker                     }
1487*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1488*8975f5c5SAndroid Build Coastguard Worker                         context->getExtensions().textureType2101010REVEXT &&
1489*8975f5c5SAndroid Build Coastguard Worker                         GL_UNSIGNED_INT_2_10_10_10_REV_EXT && format == GL_RGB)
1490*8975f5c5SAndroid Build Coastguard Worker                     {
1491*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1492*8975f5c5SAndroid Build Coastguard Worker                     }
1493*8975f5c5SAndroid Build Coastguard Worker                     break;
1494*8975f5c5SAndroid Build Coastguard Worker 
1495*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGBA4_OES:
1496*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1497*8975f5c5SAndroid Build Coastguard Worker                         (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT_4_4_4_4) &&
1498*8975f5c5SAndroid Build Coastguard Worker                         format == GL_RGBA)
1499*8975f5c5SAndroid Build Coastguard Worker                     {
1500*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1501*8975f5c5SAndroid Build Coastguard Worker                     }
1502*8975f5c5SAndroid Build Coastguard Worker                     break;
1503*8975f5c5SAndroid Build Coastguard Worker 
1504*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB5_A1:
1505*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1506*8975f5c5SAndroid Build Coastguard Worker                         (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT_5_5_5_1) &&
1507*8975f5c5SAndroid Build Coastguard Worker                         format == GL_RGBA)
1508*8975f5c5SAndroid Build Coastguard Worker                     {
1509*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1510*8975f5c5SAndroid Build Coastguard Worker                     }
1511*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1512*8975f5c5SAndroid Build Coastguard Worker                         context->getExtensions().textureType2101010REVEXT &&
1513*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_INT_2_10_10_10_REV_EXT && format == GL_RGBA)
1514*8975f5c5SAndroid Build Coastguard Worker                     {
1515*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1516*8975f5c5SAndroid Build Coastguard Worker                     }
1517*8975f5c5SAndroid Build Coastguard Worker                     break;
1518*8975f5c5SAndroid Build Coastguard Worker 
1519*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGBA8_OES:
1520*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1521*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_BYTE && format == GL_RGBA)
1522*8975f5c5SAndroid Build Coastguard Worker                     {
1523*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1524*8975f5c5SAndroid Build Coastguard Worker                     }
1525*8975f5c5SAndroid Build Coastguard Worker                     break;
1526*8975f5c5SAndroid Build Coastguard Worker 
1527*8975f5c5SAndroid Build Coastguard Worker                 case GL_DEPTH_COMPONENT16_OES:
1528*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().requiredInternalformatOES &&
1529*8975f5c5SAndroid Build Coastguard Worker                         (type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT) &&
1530*8975f5c5SAndroid Build Coastguard Worker                         format == GL_DEPTH_COMPONENT)
1531*8975f5c5SAndroid Build Coastguard Worker                     {
1532*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1533*8975f5c5SAndroid Build Coastguard Worker                     }
1534*8975f5c5SAndroid Build Coastguard Worker                     break;
1535*8975f5c5SAndroid Build Coastguard Worker 
1536*8975f5c5SAndroid Build Coastguard Worker                 case GL_DEPTH_COMPONENT24_OES:
1537*8975f5c5SAndroid Build Coastguard Worker                     if ((context->getExtensions().requiredInternalformatOES &&
1538*8975f5c5SAndroid Build Coastguard Worker                          context->getExtensions().depth24OES) &&
1539*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_INT && format == GL_DEPTH_COMPONENT)
1540*8975f5c5SAndroid Build Coastguard Worker                     {
1541*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1542*8975f5c5SAndroid Build Coastguard Worker                     }
1543*8975f5c5SAndroid Build Coastguard Worker                     break;
1544*8975f5c5SAndroid Build Coastguard Worker 
1545*8975f5c5SAndroid Build Coastguard Worker                 case GL_DEPTH_COMPONENT32_OES:
1546*8975f5c5SAndroid Build Coastguard Worker                     if ((context->getExtensions().requiredInternalformatOES &&
1547*8975f5c5SAndroid Build Coastguard Worker                          context->getExtensions().depth32OES) &&
1548*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_INT && format == GL_DEPTH_COMPONENT)
1549*8975f5c5SAndroid Build Coastguard Worker                     {
1550*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1551*8975f5c5SAndroid Build Coastguard Worker                     }
1552*8975f5c5SAndroid Build Coastguard Worker                     break;
1553*8975f5c5SAndroid Build Coastguard Worker 
1554*8975f5c5SAndroid Build Coastguard Worker                 case GL_DEPTH24_STENCIL8_OES:
1555*8975f5c5SAndroid Build Coastguard Worker                     if ((context->getExtensions().requiredInternalformatOES &&
1556*8975f5c5SAndroid Build Coastguard Worker                          context->getExtensions().packedDepthStencilOES) &&
1557*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_INT_24_8_OES && format == GL_DEPTH_STENCIL_OES)
1558*8975f5c5SAndroid Build Coastguard Worker                     {
1559*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1560*8975f5c5SAndroid Build Coastguard Worker                     }
1561*8975f5c5SAndroid Build Coastguard Worker                     break;
1562*8975f5c5SAndroid Build Coastguard Worker 
1563*8975f5c5SAndroid Build Coastguard Worker                 case GL_RED:
1564*8975f5c5SAndroid Build Coastguard Worker                 case GL_RG:
1565*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().textureRgEXT)
1566*8975f5c5SAndroid Build Coastguard Worker                     {
1567*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1568*8975f5c5SAndroid Build Coastguard Worker                         return false;
1569*8975f5c5SAndroid Build Coastguard Worker                     }
1570*8975f5c5SAndroid Build Coastguard Worker                     break;
1571*8975f5c5SAndroid Build Coastguard Worker 
1572*8975f5c5SAndroid Build Coastguard Worker                 case GL_SRGB_EXT:
1573*8975f5c5SAndroid Build Coastguard Worker                 case GL_SRGB_ALPHA_EXT:
1574*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().sRGBEXT)
1575*8975f5c5SAndroid Build Coastguard Worker                     {
1576*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, internalformat);
1577*8975f5c5SAndroid Build Coastguard Worker                         return false;
1578*8975f5c5SAndroid Build Coastguard Worker                     }
1579*8975f5c5SAndroid Build Coastguard Worker                     break;
1580*8975f5c5SAndroid Build Coastguard Worker 
1581*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB10_A2_EXT:
1582*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().textureType2101010REVEXT)
1583*8975f5c5SAndroid Build Coastguard Worker                     {
1584*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, internalformat);
1585*8975f5c5SAndroid Build Coastguard Worker                         return false;
1586*8975f5c5SAndroid Build Coastguard Worker                     }
1587*8975f5c5SAndroid Build Coastguard Worker 
1588*8975f5c5SAndroid Build Coastguard Worker                     if (type != GL_UNSIGNED_INT_2_10_10_10_REV_EXT || format != GL_RGBA)
1589*8975f5c5SAndroid Build Coastguard Worker                     {
1590*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
1591*8975f5c5SAndroid Build Coastguard Worker                         return false;
1592*8975f5c5SAndroid Build Coastguard Worker                     }
1593*8975f5c5SAndroid Build Coastguard Worker 
1594*8975f5c5SAndroid Build Coastguard Worker                     nonEqualFormatsAllowed = true;
1595*8975f5c5SAndroid Build Coastguard Worker 
1596*8975f5c5SAndroid Build Coastguard Worker                     break;
1597*8975f5c5SAndroid Build Coastguard Worker 
1598*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGBX8_ANGLE:
1599*8975f5c5SAndroid Build Coastguard Worker                     if (context->getExtensions().rgbxInternalFormatANGLE &&
1600*8975f5c5SAndroid Build Coastguard Worker                         type == GL_UNSIGNED_BYTE && format == GL_RGB)
1601*8975f5c5SAndroid Build Coastguard Worker                     {
1602*8975f5c5SAndroid Build Coastguard Worker                         nonEqualFormatsAllowed = true;
1603*8975f5c5SAndroid Build Coastguard Worker                     }
1604*8975f5c5SAndroid Build Coastguard Worker 
1605*8975f5c5SAndroid Build Coastguard Worker                     break;
1606*8975f5c5SAndroid Build Coastguard Worker 
1607*8975f5c5SAndroid Build Coastguard Worker                 case GL_R16_EXT:
1608*8975f5c5SAndroid Build Coastguard Worker                 case GL_RG16_EXT:
1609*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB16_EXT:
1610*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGBA16_EXT:
1611*8975f5c5SAndroid Build Coastguard Worker                 case GL_R16_SNORM_EXT:
1612*8975f5c5SAndroid Build Coastguard Worker                 case GL_RG16_SNORM_EXT:
1613*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGB16_SNORM_EXT:
1614*8975f5c5SAndroid Build Coastguard Worker                 case GL_RGBA16_SNORM_EXT:
1615*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().textureNorm16EXT)
1616*8975f5c5SAndroid Build Coastguard Worker                     {
1617*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, internalformat);
1618*8975f5c5SAndroid Build Coastguard Worker                         return false;
1619*8975f5c5SAndroid Build Coastguard Worker                     }
1620*8975f5c5SAndroid Build Coastguard Worker                     break;
1621*8975f5c5SAndroid Build Coastguard Worker                 default:
1622*8975f5c5SAndroid Build Coastguard Worker                     // Compressed formats are not valid internal formats for glTexImage*D
1623*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERRORF(GL_INVALID_VALUE, kInvalidInternalFormat,
1624*8975f5c5SAndroid Build Coastguard Worker                                             internalformat);
1625*8975f5c5SAndroid Build Coastguard Worker                     return false;
1626*8975f5c5SAndroid Build Coastguard Worker             }
1627*8975f5c5SAndroid Build Coastguard Worker         }
1628*8975f5c5SAndroid Build Coastguard Worker 
1629*8975f5c5SAndroid Build Coastguard Worker         if (type == GL_FLOAT)
1630*8975f5c5SAndroid Build Coastguard Worker         {
1631*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().textureFloatOES)
1632*8975f5c5SAndroid Build Coastguard Worker             {
1633*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, type);
1634*8975f5c5SAndroid Build Coastguard Worker                 return false;
1635*8975f5c5SAndroid Build Coastguard Worker             }
1636*8975f5c5SAndroid Build Coastguard Worker         }
1637*8975f5c5SAndroid Build Coastguard Worker         else if (type == GL_HALF_FLOAT_OES)
1638*8975f5c5SAndroid Build Coastguard Worker         {
1639*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().textureHalfFloatOES)
1640*8975f5c5SAndroid Build Coastguard Worker             {
1641*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, type);
1642*8975f5c5SAndroid Build Coastguard Worker                 return false;
1643*8975f5c5SAndroid Build Coastguard Worker             }
1644*8975f5c5SAndroid Build Coastguard Worker         }
1645*8975f5c5SAndroid Build Coastguard Worker     }
1646*8975f5c5SAndroid Build Coastguard Worker 
1647*8975f5c5SAndroid Build Coastguard Worker     if (isSubImage)
1648*8975f5c5SAndroid Build Coastguard Worker     {
1649*8975f5c5SAndroid Build Coastguard Worker         const InternalFormat &textureInternalFormat = *texture->getFormat(target, level).info;
1650*8975f5c5SAndroid Build Coastguard Worker         if (textureInternalFormat.internalFormat == GL_NONE)
1651*8975f5c5SAndroid Build Coastguard Worker         {
1652*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureLevel);
1653*8975f5c5SAndroid Build Coastguard Worker             return false;
1654*8975f5c5SAndroid Build Coastguard Worker         }
1655*8975f5c5SAndroid Build Coastguard Worker 
1656*8975f5c5SAndroid Build Coastguard Worker         if (format != textureInternalFormat.format)
1657*8975f5c5SAndroid Build Coastguard Worker         {
1658*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kTextureFormatMismatch);
1659*8975f5c5SAndroid Build Coastguard Worker             return false;
1660*8975f5c5SAndroid Build Coastguard Worker         }
1661*8975f5c5SAndroid Build Coastguard Worker 
1662*8975f5c5SAndroid Build Coastguard Worker         if (context->isWebGL())
1663*8975f5c5SAndroid Build Coastguard Worker         {
1664*8975f5c5SAndroid Build Coastguard Worker             if (GetInternalFormatInfo(format, type).sizedInternalFormat !=
1665*8975f5c5SAndroid Build Coastguard Worker                 textureInternalFormat.sizedInternalFormat)
1666*8975f5c5SAndroid Build Coastguard Worker             {
1667*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTextureTypeMismatch);
1668*8975f5c5SAndroid Build Coastguard Worker                 return false;
1669*8975f5c5SAndroid Build Coastguard Worker             }
1670*8975f5c5SAndroid Build Coastguard Worker         }
1671*8975f5c5SAndroid Build Coastguard Worker 
1672*8975f5c5SAndroid Build Coastguard Worker         if (static_cast<size_t>(xoffset + width) > texture->getWidth(target, level) ||
1673*8975f5c5SAndroid Build Coastguard Worker             static_cast<size_t>(yoffset + height) > texture->getHeight(target, level))
1674*8975f5c5SAndroid Build Coastguard Worker         {
1675*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kOffsetOverflow);
1676*8975f5c5SAndroid Build Coastguard Worker             return false;
1677*8975f5c5SAndroid Build Coastguard Worker         }
1678*8975f5c5SAndroid Build Coastguard Worker 
1679*8975f5c5SAndroid Build Coastguard Worker         if (width > 0 && height > 0 && pixels == nullptr &&
1680*8975f5c5SAndroid Build Coastguard Worker             context->getState().getTargetBuffer(BufferBinding::PixelUnpack) == nullptr)
1681*8975f5c5SAndroid Build Coastguard Worker         {
1682*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kPixelDataNull);
1683*8975f5c5SAndroid Build Coastguard Worker             return false;
1684*8975f5c5SAndroid Build Coastguard Worker         }
1685*8975f5c5SAndroid Build Coastguard Worker     }
1686*8975f5c5SAndroid Build Coastguard Worker     else
1687*8975f5c5SAndroid Build Coastguard Worker     {
1688*8975f5c5SAndroid Build Coastguard Worker         if (texture->getImmutableFormat())
1689*8975f5c5SAndroid Build Coastguard Worker         {
1690*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTextureIsImmutable);
1691*8975f5c5SAndroid Build Coastguard Worker             return false;
1692*8975f5c5SAndroid Build Coastguard Worker         }
1693*8975f5c5SAndroid Build Coastguard Worker     }
1694*8975f5c5SAndroid Build Coastguard Worker 
1695*8975f5c5SAndroid Build Coastguard Worker     // From GL_CHROMIUM_color_buffer_float_rgb[a]:
1696*8975f5c5SAndroid Build Coastguard Worker     // GL_RGB[A] / GL_RGB[A]32F becomes an allowable format / internalformat parameter pair for
1697*8975f5c5SAndroid Build Coastguard Worker     // TexImage2D. The restriction in section 3.7.1 of the OpenGL ES 2.0 spec that the
1698*8975f5c5SAndroid Build Coastguard Worker     // internalformat parameter and format parameter of TexImage2D must match is lifted for this
1699*8975f5c5SAndroid Build Coastguard Worker     // case.
1700*8975f5c5SAndroid Build Coastguard Worker     if (!isSubImage && !isCompressed && internalformat != format && !nonEqualFormatsAllowed)
1701*8975f5c5SAndroid Build Coastguard Worker     {
1702*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormatCombination);
1703*8975f5c5SAndroid Build Coastguard Worker         return false;
1704*8975f5c5SAndroid Build Coastguard Worker     }
1705*8975f5c5SAndroid Build Coastguard Worker 
1706*8975f5c5SAndroid Build Coastguard Worker     GLenum sizeCheckFormat = isSubImage ? format : internalformat;
1707*8975f5c5SAndroid Build Coastguard Worker     return ValidImageDataSize(context, entryPoint, texType, width, height, 1, sizeCheckFormat, type,
1708*8975f5c5SAndroid Build Coastguard Worker                               pixels, imageSize);
1709*8975f5c5SAndroid Build Coastguard Worker }
1710*8975f5c5SAndroid Build Coastguard Worker 
ValidateES2TexStorageParametersBase(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLsizei levels,GLenum internalformat,GLsizei width,GLsizei height)1711*8975f5c5SAndroid Build Coastguard Worker bool ValidateES2TexStorageParametersBase(const Context *context,
1712*8975f5c5SAndroid Build Coastguard Worker                                          angle::EntryPoint entryPoint,
1713*8975f5c5SAndroid Build Coastguard Worker                                          TextureType target,
1714*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei levels,
1715*8975f5c5SAndroid Build Coastguard Worker                                          GLenum internalformat,
1716*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei width,
1717*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei height)
1718*8975f5c5SAndroid Build Coastguard Worker {
1719*8975f5c5SAndroid Build Coastguard Worker     if (target != TextureType::_2D && target != TextureType::CubeMap &&
1720*8975f5c5SAndroid Build Coastguard Worker         target != TextureType::Rectangle)
1721*8975f5c5SAndroid Build Coastguard Worker     {
1722*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
1723*8975f5c5SAndroid Build Coastguard Worker         return false;
1724*8975f5c5SAndroid Build Coastguard Worker     }
1725*8975f5c5SAndroid Build Coastguard Worker 
1726*8975f5c5SAndroid Build Coastguard Worker     if (width < 1 || height < 1 || levels < 1)
1727*8975f5c5SAndroid Build Coastguard Worker     {
1728*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kTextureSizeTooSmall);
1729*8975f5c5SAndroid Build Coastguard Worker         return false;
1730*8975f5c5SAndroid Build Coastguard Worker     }
1731*8975f5c5SAndroid Build Coastguard Worker 
1732*8975f5c5SAndroid Build Coastguard Worker     if (target == TextureType::CubeMap && width != height)
1733*8975f5c5SAndroid Build Coastguard Worker     {
1734*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kCubemapFacesEqualDimensions);
1735*8975f5c5SAndroid Build Coastguard Worker         return false;
1736*8975f5c5SAndroid Build Coastguard Worker     }
1737*8975f5c5SAndroid Build Coastguard Worker 
1738*8975f5c5SAndroid Build Coastguard Worker     if (levels != 1 && levels != log2(std::max(width, height)) + 1)
1739*8975f5c5SAndroid Build Coastguard Worker     {
1740*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidMipLevels);
1741*8975f5c5SAndroid Build Coastguard Worker         return false;
1742*8975f5c5SAndroid Build Coastguard Worker     }
1743*8975f5c5SAndroid Build Coastguard Worker 
1744*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &formatInfo = GetSizedInternalFormatInfo(internalformat);
1745*8975f5c5SAndroid Build Coastguard Worker     if (formatInfo.format == GL_NONE || formatInfo.type == GL_NONE)
1746*8975f5c5SAndroid Build Coastguard Worker     {
1747*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1748*8975f5c5SAndroid Build Coastguard Worker         return false;
1749*8975f5c5SAndroid Build Coastguard Worker     }
1750*8975f5c5SAndroid Build Coastguard Worker 
1751*8975f5c5SAndroid Build Coastguard Worker     const Caps &caps = context->getCaps();
1752*8975f5c5SAndroid Build Coastguard Worker 
1753*8975f5c5SAndroid Build Coastguard Worker     switch (target)
1754*8975f5c5SAndroid Build Coastguard Worker     {
1755*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_2D:
1756*8975f5c5SAndroid Build Coastguard Worker             if (width > caps.max2DTextureSize || height > caps.max2DTextureSize)
1757*8975f5c5SAndroid Build Coastguard Worker             {
1758*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kResourceMaxTextureSize);
1759*8975f5c5SAndroid Build Coastguard Worker                 return false;
1760*8975f5c5SAndroid Build Coastguard Worker             }
1761*8975f5c5SAndroid Build Coastguard Worker             break;
1762*8975f5c5SAndroid Build Coastguard Worker         case TextureType::Rectangle:
1763*8975f5c5SAndroid Build Coastguard Worker             if (levels != 1)
1764*8975f5c5SAndroid Build Coastguard Worker             {
1765*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
1766*8975f5c5SAndroid Build Coastguard Worker                 return false;
1767*8975f5c5SAndroid Build Coastguard Worker             }
1768*8975f5c5SAndroid Build Coastguard Worker 
1769*8975f5c5SAndroid Build Coastguard Worker             if (width > caps.maxRectangleTextureSize || height > caps.maxRectangleTextureSize)
1770*8975f5c5SAndroid Build Coastguard Worker             {
1771*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kResourceMaxTextureSize);
1772*8975f5c5SAndroid Build Coastguard Worker                 return false;
1773*8975f5c5SAndroid Build Coastguard Worker             }
1774*8975f5c5SAndroid Build Coastguard Worker             if (formatInfo.compressed)
1775*8975f5c5SAndroid Build Coastguard Worker             {
1776*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kRectangleTextureCompressed);
1777*8975f5c5SAndroid Build Coastguard Worker                 return false;
1778*8975f5c5SAndroid Build Coastguard Worker             }
1779*8975f5c5SAndroid Build Coastguard Worker             break;
1780*8975f5c5SAndroid Build Coastguard Worker         case TextureType::CubeMap:
1781*8975f5c5SAndroid Build Coastguard Worker             if (width > caps.maxCubeMapTextureSize || height > caps.maxCubeMapTextureSize)
1782*8975f5c5SAndroid Build Coastguard Worker             {
1783*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kResourceMaxTextureSize);
1784*8975f5c5SAndroid Build Coastguard Worker                 return false;
1785*8975f5c5SAndroid Build Coastguard Worker             }
1786*8975f5c5SAndroid Build Coastguard Worker             break;
1787*8975f5c5SAndroid Build Coastguard Worker         case TextureType::InvalidEnum:
1788*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kEnumInvalid);
1789*8975f5c5SAndroid Build Coastguard Worker             return false;
1790*8975f5c5SAndroid Build Coastguard Worker         default:
1791*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, ToGLenum(target));
1792*8975f5c5SAndroid Build Coastguard Worker             return false;
1793*8975f5c5SAndroid Build Coastguard Worker     }
1794*8975f5c5SAndroid Build Coastguard Worker 
1795*8975f5c5SAndroid Build Coastguard Worker     if (levels != 1 && !context->getExtensions().textureNpotOES)
1796*8975f5c5SAndroid Build Coastguard Worker     {
1797*8975f5c5SAndroid Build Coastguard Worker         if (!isPow2(width) || !isPow2(height))
1798*8975f5c5SAndroid Build Coastguard Worker         {
1799*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kDimensionsMustBePow2);
1800*8975f5c5SAndroid Build Coastguard Worker             return false;
1801*8975f5c5SAndroid Build Coastguard Worker         }
1802*8975f5c5SAndroid Build Coastguard Worker     }
1803*8975f5c5SAndroid Build Coastguard Worker 
1804*8975f5c5SAndroid Build Coastguard Worker     if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
1805*8975f5c5SAndroid Build Coastguard Worker     {
1806*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFormat);
1807*8975f5c5SAndroid Build Coastguard Worker         return false;
1808*8975f5c5SAndroid Build Coastguard Worker     }
1809*8975f5c5SAndroid Build Coastguard Worker 
1810*8975f5c5SAndroid Build Coastguard Worker     // Even with OES_texture_npot, some compressed formats may impose extra restrictions.
1811*8975f5c5SAndroid Build Coastguard Worker     if (formatInfo.compressed)
1812*8975f5c5SAndroid Build Coastguard Worker     {
1813*8975f5c5SAndroid Build Coastguard Worker         if (!ValidCompressedImageSize(context, formatInfo.internalFormat, 0, width, height, 1))
1814*8975f5c5SAndroid Build Coastguard Worker         {
1815*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
1816*8975f5c5SAndroid Build Coastguard Worker             return false;
1817*8975f5c5SAndroid Build Coastguard Worker         }
1818*8975f5c5SAndroid Build Coastguard Worker     }
1819*8975f5c5SAndroid Build Coastguard Worker 
1820*8975f5c5SAndroid Build Coastguard Worker     switch (internalformat)
1821*8975f5c5SAndroid Build Coastguard Worker     {
1822*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH_COMPONENT16:
1823*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH_COMPONENT32_OES:
1824*8975f5c5SAndroid Build Coastguard Worker             switch (target)
1825*8975f5c5SAndroid Build Coastguard Worker             {
1826*8975f5c5SAndroid Build Coastguard Worker                 case TextureType::_2D:
1827*8975f5c5SAndroid Build Coastguard Worker                     break;
1828*8975f5c5SAndroid Build Coastguard Worker                 case TextureType::CubeMap:
1829*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().depthTextureCubeMapOES)
1830*8975f5c5SAndroid Build Coastguard Worker                     {
1831*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureTarget);
1832*8975f5c5SAndroid Build Coastguard Worker                         return false;
1833*8975f5c5SAndroid Build Coastguard Worker                     }
1834*8975f5c5SAndroid Build Coastguard Worker                     break;
1835*8975f5c5SAndroid Build Coastguard Worker                 default:
1836*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureTarget);
1837*8975f5c5SAndroid Build Coastguard Worker                     return false;
1838*8975f5c5SAndroid Build Coastguard Worker             }
1839*8975f5c5SAndroid Build Coastguard Worker 
1840*8975f5c5SAndroid Build Coastguard Worker             // ANGLE_depth_texture only supports 1-level textures
1841*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().depthTextureOES)
1842*8975f5c5SAndroid Build Coastguard Worker             {
1843*8975f5c5SAndroid Build Coastguard Worker                 if (levels != 1)
1844*8975f5c5SAndroid Build Coastguard Worker                 {
1845*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidMipLevels);
1846*8975f5c5SAndroid Build Coastguard Worker                     return false;
1847*8975f5c5SAndroid Build Coastguard Worker                 }
1848*8975f5c5SAndroid Build Coastguard Worker             }
1849*8975f5c5SAndroid Build Coastguard Worker             break;
1850*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH24_STENCIL8_OES:
1851*8975f5c5SAndroid Build Coastguard Worker             switch (target)
1852*8975f5c5SAndroid Build Coastguard Worker             {
1853*8975f5c5SAndroid Build Coastguard Worker                 case TextureType::_2D:
1854*8975f5c5SAndroid Build Coastguard Worker                     break;
1855*8975f5c5SAndroid Build Coastguard Worker                 case TextureType::CubeMap:
1856*8975f5c5SAndroid Build Coastguard Worker                     if (!context->getExtensions().depthTextureCubeMapOES)
1857*8975f5c5SAndroid Build Coastguard Worker                     {
1858*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureTarget);
1859*8975f5c5SAndroid Build Coastguard Worker                         return false;
1860*8975f5c5SAndroid Build Coastguard Worker                     }
1861*8975f5c5SAndroid Build Coastguard Worker                     break;
1862*8975f5c5SAndroid Build Coastguard Worker                 default:
1863*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureTarget);
1864*8975f5c5SAndroid Build Coastguard Worker                     return false;
1865*8975f5c5SAndroid Build Coastguard Worker             }
1866*8975f5c5SAndroid Build Coastguard Worker 
1867*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().packedDepthStencilOES &&
1868*8975f5c5SAndroid Build Coastguard Worker                 !context->getExtensions().depthTextureCubeMapOES)
1869*8975f5c5SAndroid Build Coastguard Worker             {
1870*8975f5c5SAndroid Build Coastguard Worker                 // ANGLE_depth_texture only supports 1-level textures
1871*8975f5c5SAndroid Build Coastguard Worker                 if (levels != 1)
1872*8975f5c5SAndroid Build Coastguard Worker                 {
1873*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidMipLevels);
1874*8975f5c5SAndroid Build Coastguard Worker                     return false;
1875*8975f5c5SAndroid Build Coastguard Worker                 }
1876*8975f5c5SAndroid Build Coastguard Worker             }
1877*8975f5c5SAndroid Build Coastguard Worker             break;
1878*8975f5c5SAndroid Build Coastguard Worker 
1879*8975f5c5SAndroid Build Coastguard Worker         default:
1880*8975f5c5SAndroid Build Coastguard Worker             break;
1881*8975f5c5SAndroid Build Coastguard Worker     }
1882*8975f5c5SAndroid Build Coastguard Worker 
1883*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = context->getTextureByType(target);
1884*8975f5c5SAndroid Build Coastguard Worker     if (!texture || texture->id().value == 0)
1885*8975f5c5SAndroid Build Coastguard Worker     {
1886*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMissingTexture);
1887*8975f5c5SAndroid Build Coastguard Worker         return false;
1888*8975f5c5SAndroid Build Coastguard Worker     }
1889*8975f5c5SAndroid Build Coastguard Worker 
1890*8975f5c5SAndroid Build Coastguard Worker     if (texture->getImmutableFormat())
1891*8975f5c5SAndroid Build Coastguard Worker     {
1892*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTextureIsImmutable);
1893*8975f5c5SAndroid Build Coastguard Worker         return false;
1894*8975f5c5SAndroid Build Coastguard Worker     }
1895*8975f5c5SAndroid Build Coastguard Worker 
1896*8975f5c5SAndroid Build Coastguard Worker     return true;
1897*8975f5c5SAndroid Build Coastguard Worker }
1898*8975f5c5SAndroid Build Coastguard Worker 
ValidateDiscardFramebufferEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLsizei numAttachments,const GLenum * attachments)1899*8975f5c5SAndroid Build Coastguard Worker bool ValidateDiscardFramebufferEXT(const Context *context,
1900*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
1901*8975f5c5SAndroid Build Coastguard Worker                                    GLenum target,
1902*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei numAttachments,
1903*8975f5c5SAndroid Build Coastguard Worker                                    const GLenum *attachments)
1904*8975f5c5SAndroid Build Coastguard Worker {
1905*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().discardFramebufferEXT)
1906*8975f5c5SAndroid Build Coastguard Worker     {
1907*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
1908*8975f5c5SAndroid Build Coastguard Worker         return false;
1909*8975f5c5SAndroid Build Coastguard Worker     }
1910*8975f5c5SAndroid Build Coastguard Worker 
1911*8975f5c5SAndroid Build Coastguard Worker     bool defaultFramebuffer = false;
1912*8975f5c5SAndroid Build Coastguard Worker 
1913*8975f5c5SAndroid Build Coastguard Worker     switch (target)
1914*8975f5c5SAndroid Build Coastguard Worker     {
1915*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAMEBUFFER:
1916*8975f5c5SAndroid Build Coastguard Worker             defaultFramebuffer =
1917*8975f5c5SAndroid Build Coastguard Worker                 (context->getState().getTargetFramebuffer(GL_FRAMEBUFFER)->isDefault());
1918*8975f5c5SAndroid Build Coastguard Worker             break;
1919*8975f5c5SAndroid Build Coastguard Worker         default:
1920*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFramebufferTarget);
1921*8975f5c5SAndroid Build Coastguard Worker             return false;
1922*8975f5c5SAndroid Build Coastguard Worker     }
1923*8975f5c5SAndroid Build Coastguard Worker 
1924*8975f5c5SAndroid Build Coastguard Worker     return ValidateDiscardFramebufferBase(context, entryPoint, target, numAttachments, attachments,
1925*8975f5c5SAndroid Build Coastguard Worker                                           defaultFramebuffer);
1926*8975f5c5SAndroid Build Coastguard Worker }
1927*8975f5c5SAndroid Build Coastguard Worker 
ValidateBindVertexArrayOES(const Context * context,angle::EntryPoint entryPoint,VertexArrayID array)1928*8975f5c5SAndroid Build Coastguard Worker bool ValidateBindVertexArrayOES(const Context *context,
1929*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
1930*8975f5c5SAndroid Build Coastguard Worker                                 VertexArrayID array)
1931*8975f5c5SAndroid Build Coastguard Worker {
1932*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().vertexArrayObjectOES)
1933*8975f5c5SAndroid Build Coastguard Worker     {
1934*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
1935*8975f5c5SAndroid Build Coastguard Worker         return false;
1936*8975f5c5SAndroid Build Coastguard Worker     }
1937*8975f5c5SAndroid Build Coastguard Worker 
1938*8975f5c5SAndroid Build Coastguard Worker     return ValidateBindVertexArrayBase(context, entryPoint, array);
1939*8975f5c5SAndroid Build Coastguard Worker }
1940*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteVertexArraysOES(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const VertexArrayID * arrays)1941*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteVertexArraysOES(const Context *context,
1942*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
1943*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei n,
1944*8975f5c5SAndroid Build Coastguard Worker                                    const VertexArrayID *arrays)
1945*8975f5c5SAndroid Build Coastguard Worker {
1946*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().vertexArrayObjectOES)
1947*8975f5c5SAndroid Build Coastguard Worker     {
1948*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
1949*8975f5c5SAndroid Build Coastguard Worker         return false;
1950*8975f5c5SAndroid Build Coastguard Worker     }
1951*8975f5c5SAndroid Build Coastguard Worker 
1952*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
1953*8975f5c5SAndroid Build Coastguard Worker }
1954*8975f5c5SAndroid Build Coastguard Worker 
ValidateGenVertexArraysOES(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const VertexArrayID * arrays)1955*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenVertexArraysOES(const Context *context,
1956*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
1957*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei n,
1958*8975f5c5SAndroid Build Coastguard Worker                                 const VertexArrayID *arrays)
1959*8975f5c5SAndroid Build Coastguard Worker {
1960*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().vertexArrayObjectOES)
1961*8975f5c5SAndroid Build Coastguard Worker     {
1962*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
1963*8975f5c5SAndroid Build Coastguard Worker         return false;
1964*8975f5c5SAndroid Build Coastguard Worker     }
1965*8975f5c5SAndroid Build Coastguard Worker 
1966*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
1967*8975f5c5SAndroid Build Coastguard Worker }
1968*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsVertexArrayOES(const Context * context,angle::EntryPoint entryPoint,VertexArrayID array)1969*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsVertexArrayOES(const Context *context,
1970*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
1971*8975f5c5SAndroid Build Coastguard Worker                               VertexArrayID array)
1972*8975f5c5SAndroid Build Coastguard Worker {
1973*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().vertexArrayObjectOES)
1974*8975f5c5SAndroid Build Coastguard Worker     {
1975*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
1976*8975f5c5SAndroid Build Coastguard Worker         return false;
1977*8975f5c5SAndroid Build Coastguard Worker     }
1978*8975f5c5SAndroid Build Coastguard Worker 
1979*8975f5c5SAndroid Build Coastguard Worker     return true;
1980*8975f5c5SAndroid Build Coastguard Worker }
1981*8975f5c5SAndroid Build Coastguard Worker 
ValidateProgramBinaryOES(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLenum binaryFormat,const void * binary,GLint length)1982*8975f5c5SAndroid Build Coastguard Worker bool ValidateProgramBinaryOES(const Context *context,
1983*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
1984*8975f5c5SAndroid Build Coastguard Worker                               ShaderProgramID program,
1985*8975f5c5SAndroid Build Coastguard Worker                               GLenum binaryFormat,
1986*8975f5c5SAndroid Build Coastguard Worker                               const void *binary,
1987*8975f5c5SAndroid Build Coastguard Worker                               GLint length)
1988*8975f5c5SAndroid Build Coastguard Worker {
1989*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().getProgramBinaryOES)
1990*8975f5c5SAndroid Build Coastguard Worker     {
1991*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
1992*8975f5c5SAndroid Build Coastguard Worker         return false;
1993*8975f5c5SAndroid Build Coastguard Worker     }
1994*8975f5c5SAndroid Build Coastguard Worker 
1995*8975f5c5SAndroid Build Coastguard Worker     return ValidateProgramBinaryBase(context, entryPoint, program, binaryFormat, binary, length);
1996*8975f5c5SAndroid Build Coastguard Worker }
1997*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetProgramBinaryOES(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLsizei bufSize,const GLsizei * length,const GLenum * binaryFormat,const void * binary)1998*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetProgramBinaryOES(const Context *context,
1999*8975f5c5SAndroid Build Coastguard Worker                                  angle::EntryPoint entryPoint,
2000*8975f5c5SAndroid Build Coastguard Worker                                  ShaderProgramID program,
2001*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei bufSize,
2002*8975f5c5SAndroid Build Coastguard Worker                                  const GLsizei *length,
2003*8975f5c5SAndroid Build Coastguard Worker                                  const GLenum *binaryFormat,
2004*8975f5c5SAndroid Build Coastguard Worker                                  const void *binary)
2005*8975f5c5SAndroid Build Coastguard Worker {
2006*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().getProgramBinaryOES)
2007*8975f5c5SAndroid Build Coastguard Worker     {
2008*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2009*8975f5c5SAndroid Build Coastguard Worker         return false;
2010*8975f5c5SAndroid Build Coastguard Worker     }
2011*8975f5c5SAndroid Build Coastguard Worker 
2012*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetProgramBinaryBase(context, entryPoint, program, bufSize, length, binaryFormat,
2013*8975f5c5SAndroid Build Coastguard Worker                                         binary);
2014*8975f5c5SAndroid Build Coastguard Worker }
2015*8975f5c5SAndroid Build Coastguard Worker 
ValidDebugSource(GLenum source,bool mustBeThirdPartyOrApplication)2016*8975f5c5SAndroid Build Coastguard Worker static bool ValidDebugSource(GLenum source, bool mustBeThirdPartyOrApplication)
2017*8975f5c5SAndroid Build Coastguard Worker {
2018*8975f5c5SAndroid Build Coastguard Worker     switch (source)
2019*8975f5c5SAndroid Build Coastguard Worker     {
2020*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SOURCE_API:
2021*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SOURCE_SHADER_COMPILER:
2022*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
2023*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SOURCE_OTHER:
2024*8975f5c5SAndroid Build Coastguard Worker             // Only THIRD_PARTY and APPLICATION sources are allowed to be manually inserted
2025*8975f5c5SAndroid Build Coastguard Worker             return !mustBeThirdPartyOrApplication;
2026*8975f5c5SAndroid Build Coastguard Worker 
2027*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SOURCE_THIRD_PARTY:
2028*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SOURCE_APPLICATION:
2029*8975f5c5SAndroid Build Coastguard Worker             return true;
2030*8975f5c5SAndroid Build Coastguard Worker 
2031*8975f5c5SAndroid Build Coastguard Worker         default:
2032*8975f5c5SAndroid Build Coastguard Worker             return false;
2033*8975f5c5SAndroid Build Coastguard Worker     }
2034*8975f5c5SAndroid Build Coastguard Worker }
2035*8975f5c5SAndroid Build Coastguard Worker 
ValidDebugType(GLenum type)2036*8975f5c5SAndroid Build Coastguard Worker static bool ValidDebugType(GLenum type)
2037*8975f5c5SAndroid Build Coastguard Worker {
2038*8975f5c5SAndroid Build Coastguard Worker     switch (type)
2039*8975f5c5SAndroid Build Coastguard Worker     {
2040*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_ERROR:
2041*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
2042*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
2043*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_PERFORMANCE:
2044*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_PORTABILITY:
2045*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_OTHER:
2046*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_MARKER:
2047*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_PUSH_GROUP:
2048*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_TYPE_POP_GROUP:
2049*8975f5c5SAndroid Build Coastguard Worker             return true;
2050*8975f5c5SAndroid Build Coastguard Worker 
2051*8975f5c5SAndroid Build Coastguard Worker         default:
2052*8975f5c5SAndroid Build Coastguard Worker             return false;
2053*8975f5c5SAndroid Build Coastguard Worker     }
2054*8975f5c5SAndroid Build Coastguard Worker }
2055*8975f5c5SAndroid Build Coastguard Worker 
ValidDebugSeverity(GLenum severity)2056*8975f5c5SAndroid Build Coastguard Worker static bool ValidDebugSeverity(GLenum severity)
2057*8975f5c5SAndroid Build Coastguard Worker {
2058*8975f5c5SAndroid Build Coastguard Worker     switch (severity)
2059*8975f5c5SAndroid Build Coastguard Worker     {
2060*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SEVERITY_HIGH:
2061*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SEVERITY_MEDIUM:
2062*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SEVERITY_LOW:
2063*8975f5c5SAndroid Build Coastguard Worker         case GL_DEBUG_SEVERITY_NOTIFICATION:
2064*8975f5c5SAndroid Build Coastguard Worker             return true;
2065*8975f5c5SAndroid Build Coastguard Worker 
2066*8975f5c5SAndroid Build Coastguard Worker         default:
2067*8975f5c5SAndroid Build Coastguard Worker             return false;
2068*8975f5c5SAndroid Build Coastguard Worker     }
2069*8975f5c5SAndroid Build Coastguard Worker }
2070*8975f5c5SAndroid Build Coastguard Worker 
ValidateDebugMessageControlKHR(const Context * context,angle::EntryPoint entryPoint,GLenum source,GLenum type,GLenum severity,GLsizei count,const GLuint * ids,GLboolean enabled)2071*8975f5c5SAndroid Build Coastguard Worker bool ValidateDebugMessageControlKHR(const Context *context,
2072*8975f5c5SAndroid Build Coastguard Worker                                     angle::EntryPoint entryPoint,
2073*8975f5c5SAndroid Build Coastguard Worker                                     GLenum source,
2074*8975f5c5SAndroid Build Coastguard Worker                                     GLenum type,
2075*8975f5c5SAndroid Build Coastguard Worker                                     GLenum severity,
2076*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei count,
2077*8975f5c5SAndroid Build Coastguard Worker                                     const GLuint *ids,
2078*8975f5c5SAndroid Build Coastguard Worker                                     GLboolean enabled)
2079*8975f5c5SAndroid Build Coastguard Worker {
2080*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2081*8975f5c5SAndroid Build Coastguard Worker     {
2082*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2083*8975f5c5SAndroid Build Coastguard Worker         return false;
2084*8975f5c5SAndroid Build Coastguard Worker     }
2085*8975f5c5SAndroid Build Coastguard Worker 
2086*8975f5c5SAndroid Build Coastguard Worker     if (!ValidDebugSource(source, false) && source != GL_DONT_CARE)
2087*8975f5c5SAndroid Build Coastguard Worker     {
2088*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidDebugSource);
2089*8975f5c5SAndroid Build Coastguard Worker         return false;
2090*8975f5c5SAndroid Build Coastguard Worker     }
2091*8975f5c5SAndroid Build Coastguard Worker 
2092*8975f5c5SAndroid Build Coastguard Worker     if (!ValidDebugType(type) && type != GL_DONT_CARE)
2093*8975f5c5SAndroid Build Coastguard Worker     {
2094*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidDebugType);
2095*8975f5c5SAndroid Build Coastguard Worker         return false;
2096*8975f5c5SAndroid Build Coastguard Worker     }
2097*8975f5c5SAndroid Build Coastguard Worker 
2098*8975f5c5SAndroid Build Coastguard Worker     if (!ValidDebugSeverity(severity) && severity != GL_DONT_CARE)
2099*8975f5c5SAndroid Build Coastguard Worker     {
2100*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidDebugSeverity);
2101*8975f5c5SAndroid Build Coastguard Worker         return false;
2102*8975f5c5SAndroid Build Coastguard Worker     }
2103*8975f5c5SAndroid Build Coastguard Worker 
2104*8975f5c5SAndroid Build Coastguard Worker     if (count > 0)
2105*8975f5c5SAndroid Build Coastguard Worker     {
2106*8975f5c5SAndroid Build Coastguard Worker         if (source == GL_DONT_CARE || type == GL_DONT_CARE)
2107*8975f5c5SAndroid Build Coastguard Worker         {
2108*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidDebugSourceType);
2109*8975f5c5SAndroid Build Coastguard Worker             return false;
2110*8975f5c5SAndroid Build Coastguard Worker         }
2111*8975f5c5SAndroid Build Coastguard Worker 
2112*8975f5c5SAndroid Build Coastguard Worker         if (severity != GL_DONT_CARE)
2113*8975f5c5SAndroid Build Coastguard Worker         {
2114*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidDebugSeverity);
2115*8975f5c5SAndroid Build Coastguard Worker             return false;
2116*8975f5c5SAndroid Build Coastguard Worker         }
2117*8975f5c5SAndroid Build Coastguard Worker     }
2118*8975f5c5SAndroid Build Coastguard Worker 
2119*8975f5c5SAndroid Build Coastguard Worker     return true;
2120*8975f5c5SAndroid Build Coastguard Worker }
2121*8975f5c5SAndroid Build Coastguard Worker 
ValidateDebugMessageInsertKHR(const Context * context,angle::EntryPoint entryPoint,GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar * buf)2122*8975f5c5SAndroid Build Coastguard Worker bool ValidateDebugMessageInsertKHR(const Context *context,
2123*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
2124*8975f5c5SAndroid Build Coastguard Worker                                    GLenum source,
2125*8975f5c5SAndroid Build Coastguard Worker                                    GLenum type,
2126*8975f5c5SAndroid Build Coastguard Worker                                    GLuint id,
2127*8975f5c5SAndroid Build Coastguard Worker                                    GLenum severity,
2128*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei length,
2129*8975f5c5SAndroid Build Coastguard Worker                                    const GLchar *buf)
2130*8975f5c5SAndroid Build Coastguard Worker {
2131*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2132*8975f5c5SAndroid Build Coastguard Worker     {
2133*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2134*8975f5c5SAndroid Build Coastguard Worker         return false;
2135*8975f5c5SAndroid Build Coastguard Worker     }
2136*8975f5c5SAndroid Build Coastguard Worker 
2137*8975f5c5SAndroid Build Coastguard Worker     if (!context->getState().getDebug().isOutputEnabled())
2138*8975f5c5SAndroid Build Coastguard Worker     {
2139*8975f5c5SAndroid Build Coastguard Worker         // If the DEBUG_OUTPUT state is disabled calls to DebugMessageInsert are discarded and do
2140*8975f5c5SAndroid Build Coastguard Worker         // not generate an error.
2141*8975f5c5SAndroid Build Coastguard Worker         return false;
2142*8975f5c5SAndroid Build Coastguard Worker     }
2143*8975f5c5SAndroid Build Coastguard Worker 
2144*8975f5c5SAndroid Build Coastguard Worker     if (!ValidDebugSeverity(severity))
2145*8975f5c5SAndroid Build Coastguard Worker     {
2146*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidDebugSource);
2147*8975f5c5SAndroid Build Coastguard Worker         return false;
2148*8975f5c5SAndroid Build Coastguard Worker     }
2149*8975f5c5SAndroid Build Coastguard Worker 
2150*8975f5c5SAndroid Build Coastguard Worker     if (!ValidDebugType(type))
2151*8975f5c5SAndroid Build Coastguard Worker     {
2152*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidDebugType);
2153*8975f5c5SAndroid Build Coastguard Worker         return false;
2154*8975f5c5SAndroid Build Coastguard Worker     }
2155*8975f5c5SAndroid Build Coastguard Worker 
2156*8975f5c5SAndroid Build Coastguard Worker     if (!ValidDebugSource(source, true))
2157*8975f5c5SAndroid Build Coastguard Worker     {
2158*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidDebugSource);
2159*8975f5c5SAndroid Build Coastguard Worker         return false;
2160*8975f5c5SAndroid Build Coastguard Worker     }
2161*8975f5c5SAndroid Build Coastguard Worker 
2162*8975f5c5SAndroid Build Coastguard Worker     size_t messageLength = (length < 0) ? strlen(buf) : length;
2163*8975f5c5SAndroid Build Coastguard Worker     if (messageLength > context->getCaps().maxDebugMessageLength)
2164*8975f5c5SAndroid Build Coastguard Worker     {
2165*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kExceedsMaxDebugMessageLength);
2166*8975f5c5SAndroid Build Coastguard Worker         return false;
2167*8975f5c5SAndroid Build Coastguard Worker     }
2168*8975f5c5SAndroid Build Coastguard Worker 
2169*8975f5c5SAndroid Build Coastguard Worker     return true;
2170*8975f5c5SAndroid Build Coastguard Worker }
2171*8975f5c5SAndroid Build Coastguard Worker 
ValidateDebugMessageCallbackKHR(const Context * context,angle::EntryPoint entryPoint,GLDEBUGPROCKHR callback,const void * userParam)2172*8975f5c5SAndroid Build Coastguard Worker bool ValidateDebugMessageCallbackKHR(const Context *context,
2173*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
2174*8975f5c5SAndroid Build Coastguard Worker                                      GLDEBUGPROCKHR callback,
2175*8975f5c5SAndroid Build Coastguard Worker                                      const void *userParam)
2176*8975f5c5SAndroid Build Coastguard Worker {
2177*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2178*8975f5c5SAndroid Build Coastguard Worker     {
2179*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2180*8975f5c5SAndroid Build Coastguard Worker         return false;
2181*8975f5c5SAndroid Build Coastguard Worker     }
2182*8975f5c5SAndroid Build Coastguard Worker 
2183*8975f5c5SAndroid Build Coastguard Worker     return true;
2184*8975f5c5SAndroid Build Coastguard Worker }
2185*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetDebugMessageLogKHR(const Context * context,angle::EntryPoint entryPoint,GLuint count,GLsizei bufSize,const GLenum * sources,const GLenum * types,const GLuint * ids,const GLenum * severities,const GLsizei * lengths,const GLchar * messageLog)2186*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetDebugMessageLogKHR(const Context *context,
2187*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
2188*8975f5c5SAndroid Build Coastguard Worker                                    GLuint count,
2189*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
2190*8975f5c5SAndroid Build Coastguard Worker                                    const GLenum *sources,
2191*8975f5c5SAndroid Build Coastguard Worker                                    const GLenum *types,
2192*8975f5c5SAndroid Build Coastguard Worker                                    const GLuint *ids,
2193*8975f5c5SAndroid Build Coastguard Worker                                    const GLenum *severities,
2194*8975f5c5SAndroid Build Coastguard Worker                                    const GLsizei *lengths,
2195*8975f5c5SAndroid Build Coastguard Worker                                    const GLchar *messageLog)
2196*8975f5c5SAndroid Build Coastguard Worker {
2197*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2198*8975f5c5SAndroid Build Coastguard Worker     {
2199*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2200*8975f5c5SAndroid Build Coastguard Worker         return false;
2201*8975f5c5SAndroid Build Coastguard Worker     }
2202*8975f5c5SAndroid Build Coastguard Worker 
2203*8975f5c5SAndroid Build Coastguard Worker     if (bufSize < 0 && messageLog != nullptr)
2204*8975f5c5SAndroid Build Coastguard Worker     {
2205*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
2206*8975f5c5SAndroid Build Coastguard Worker         return false;
2207*8975f5c5SAndroid Build Coastguard Worker     }
2208*8975f5c5SAndroid Build Coastguard Worker 
2209*8975f5c5SAndroid Build Coastguard Worker     return true;
2210*8975f5c5SAndroid Build Coastguard Worker }
2211*8975f5c5SAndroid Build Coastguard Worker 
ValidatePushDebugGroupBase(const Context * context,angle::EntryPoint entryPoint,GLenum source,GLuint id,GLsizei length,const GLchar * message)2212*8975f5c5SAndroid Build Coastguard Worker bool ValidatePushDebugGroupBase(const Context *context,
2213*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
2214*8975f5c5SAndroid Build Coastguard Worker                                 GLenum source,
2215*8975f5c5SAndroid Build Coastguard Worker                                 GLuint id,
2216*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei length,
2217*8975f5c5SAndroid Build Coastguard Worker                                 const GLchar *message)
2218*8975f5c5SAndroid Build Coastguard Worker {
2219*8975f5c5SAndroid Build Coastguard Worker     if (!ValidDebugSource(source, true))
2220*8975f5c5SAndroid Build Coastguard Worker     {
2221*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidDebugSource);
2222*8975f5c5SAndroid Build Coastguard Worker         return false;
2223*8975f5c5SAndroid Build Coastguard Worker     }
2224*8975f5c5SAndroid Build Coastguard Worker 
2225*8975f5c5SAndroid Build Coastguard Worker     size_t messageLength = (length < 0) ? strlen(message) : length;
2226*8975f5c5SAndroid Build Coastguard Worker     if (messageLength > context->getCaps().maxDebugMessageLength)
2227*8975f5c5SAndroid Build Coastguard Worker     {
2228*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kExceedsMaxDebugMessageLength);
2229*8975f5c5SAndroid Build Coastguard Worker         return false;
2230*8975f5c5SAndroid Build Coastguard Worker     }
2231*8975f5c5SAndroid Build Coastguard Worker 
2232*8975f5c5SAndroid Build Coastguard Worker     size_t currentStackSize = context->getState().getDebug().getGroupStackDepth();
2233*8975f5c5SAndroid Build Coastguard Worker     if (currentStackSize >= context->getCaps().maxDebugGroupStackDepth)
2234*8975f5c5SAndroid Build Coastguard Worker     {
2235*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_STACK_OVERFLOW, kExceedsMaxDebugGroupStackDepth);
2236*8975f5c5SAndroid Build Coastguard Worker         return false;
2237*8975f5c5SAndroid Build Coastguard Worker     }
2238*8975f5c5SAndroid Build Coastguard Worker 
2239*8975f5c5SAndroid Build Coastguard Worker     return true;
2240*8975f5c5SAndroid Build Coastguard Worker }
2241*8975f5c5SAndroid Build Coastguard Worker 
ValidatePopDebugGroupBase(const Context * context,angle::EntryPoint entryPoint)2242*8975f5c5SAndroid Build Coastguard Worker bool ValidatePopDebugGroupBase(const Context *context, angle::EntryPoint entryPoint)
2243*8975f5c5SAndroid Build Coastguard Worker {
2244*8975f5c5SAndroid Build Coastguard Worker     size_t currentStackSize = context->getState().getDebug().getGroupStackDepth();
2245*8975f5c5SAndroid Build Coastguard Worker     if (currentStackSize <= 1)
2246*8975f5c5SAndroid Build Coastguard Worker     {
2247*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_STACK_UNDERFLOW, kCannotPopDefaultDebugGroup);
2248*8975f5c5SAndroid Build Coastguard Worker         return false;
2249*8975f5c5SAndroid Build Coastguard Worker     }
2250*8975f5c5SAndroid Build Coastguard Worker 
2251*8975f5c5SAndroid Build Coastguard Worker     return true;
2252*8975f5c5SAndroid Build Coastguard Worker }
2253*8975f5c5SAndroid Build Coastguard Worker 
ValidatePushDebugGroupKHR(const Context * context,angle::EntryPoint entryPoint,GLenum source,GLuint id,GLsizei length,const GLchar * message)2254*8975f5c5SAndroid Build Coastguard Worker bool ValidatePushDebugGroupKHR(const Context *context,
2255*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
2256*8975f5c5SAndroid Build Coastguard Worker                                GLenum source,
2257*8975f5c5SAndroid Build Coastguard Worker                                GLuint id,
2258*8975f5c5SAndroid Build Coastguard Worker                                GLsizei length,
2259*8975f5c5SAndroid Build Coastguard Worker                                const GLchar *message)
2260*8975f5c5SAndroid Build Coastguard Worker {
2261*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2262*8975f5c5SAndroid Build Coastguard Worker     {
2263*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2264*8975f5c5SAndroid Build Coastguard Worker         return false;
2265*8975f5c5SAndroid Build Coastguard Worker     }
2266*8975f5c5SAndroid Build Coastguard Worker 
2267*8975f5c5SAndroid Build Coastguard Worker     return ValidatePushDebugGroupBase(context, entryPoint, source, id, length, message);
2268*8975f5c5SAndroid Build Coastguard Worker }
2269*8975f5c5SAndroid Build Coastguard Worker 
ValidatePopDebugGroupKHR(const Context * context,angle::EntryPoint entryPoint)2270*8975f5c5SAndroid Build Coastguard Worker bool ValidatePopDebugGroupKHR(const Context *context, angle::EntryPoint entryPoint)
2271*8975f5c5SAndroid Build Coastguard Worker {
2272*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2273*8975f5c5SAndroid Build Coastguard Worker     {
2274*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2275*8975f5c5SAndroid Build Coastguard Worker         return false;
2276*8975f5c5SAndroid Build Coastguard Worker     }
2277*8975f5c5SAndroid Build Coastguard Worker 
2278*8975f5c5SAndroid Build Coastguard Worker     return ValidatePopDebugGroupBase(context, entryPoint);
2279*8975f5c5SAndroid Build Coastguard Worker }
2280*8975f5c5SAndroid Build Coastguard Worker 
ValidateObjectIdentifierAndName(const Context * context,angle::EntryPoint entryPoint,GLenum identifier,GLuint name)2281*8975f5c5SAndroid Build Coastguard Worker static bool ValidateObjectIdentifierAndName(const Context *context,
2282*8975f5c5SAndroid Build Coastguard Worker                                             angle::EntryPoint entryPoint,
2283*8975f5c5SAndroid Build Coastguard Worker                                             GLenum identifier,
2284*8975f5c5SAndroid Build Coastguard Worker                                             GLuint name)
2285*8975f5c5SAndroid Build Coastguard Worker {
2286*8975f5c5SAndroid Build Coastguard Worker     switch (identifier)
2287*8975f5c5SAndroid Build Coastguard Worker     {
2288*8975f5c5SAndroid Build Coastguard Worker         case GL_BUFFER:
2289*8975f5c5SAndroid Build Coastguard Worker             if (context->getBuffer({name}) == nullptr)
2290*8975f5c5SAndroid Build Coastguard Worker             {
2291*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidBufferName);
2292*8975f5c5SAndroid Build Coastguard Worker                 return false;
2293*8975f5c5SAndroid Build Coastguard Worker             }
2294*8975f5c5SAndroid Build Coastguard Worker             return true;
2295*8975f5c5SAndroid Build Coastguard Worker 
2296*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADER:
2297*8975f5c5SAndroid Build Coastguard Worker             if (context->getShaderNoResolveCompile({name}) == nullptr)
2298*8975f5c5SAndroid Build Coastguard Worker             {
2299*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidShaderName);
2300*8975f5c5SAndroid Build Coastguard Worker                 return false;
2301*8975f5c5SAndroid Build Coastguard Worker             }
2302*8975f5c5SAndroid Build Coastguard Worker             return true;
2303*8975f5c5SAndroid Build Coastguard Worker 
2304*8975f5c5SAndroid Build Coastguard Worker         case GL_PROGRAM:
2305*8975f5c5SAndroid Build Coastguard Worker             if (context->getProgramNoResolveLink({name}) == nullptr)
2306*8975f5c5SAndroid Build Coastguard Worker             {
2307*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidProgramName);
2308*8975f5c5SAndroid Build Coastguard Worker                 return false;
2309*8975f5c5SAndroid Build Coastguard Worker             }
2310*8975f5c5SAndroid Build Coastguard Worker             return true;
2311*8975f5c5SAndroid Build Coastguard Worker 
2312*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY:
2313*8975f5c5SAndroid Build Coastguard Worker             if (context->getVertexArray({name}) == nullptr)
2314*8975f5c5SAndroid Build Coastguard Worker             {
2315*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidVertexArrayName);
2316*8975f5c5SAndroid Build Coastguard Worker                 return false;
2317*8975f5c5SAndroid Build Coastguard Worker             }
2318*8975f5c5SAndroid Build Coastguard Worker             return true;
2319*8975f5c5SAndroid Build Coastguard Worker 
2320*8975f5c5SAndroid Build Coastguard Worker         case GL_QUERY:
2321*8975f5c5SAndroid Build Coastguard Worker             if (context->getQuery({name}) == nullptr)
2322*8975f5c5SAndroid Build Coastguard Worker             {
2323*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidQueryName);
2324*8975f5c5SAndroid Build Coastguard Worker                 return false;
2325*8975f5c5SAndroid Build Coastguard Worker             }
2326*8975f5c5SAndroid Build Coastguard Worker             return true;
2327*8975f5c5SAndroid Build Coastguard Worker 
2328*8975f5c5SAndroid Build Coastguard Worker         case GL_TRANSFORM_FEEDBACK:
2329*8975f5c5SAndroid Build Coastguard Worker             if (context->getTransformFeedback({name}) == nullptr)
2330*8975f5c5SAndroid Build Coastguard Worker             {
2331*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidTransformFeedbackName);
2332*8975f5c5SAndroid Build Coastguard Worker                 return false;
2333*8975f5c5SAndroid Build Coastguard Worker             }
2334*8975f5c5SAndroid Build Coastguard Worker             return true;
2335*8975f5c5SAndroid Build Coastguard Worker 
2336*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLER:
2337*8975f5c5SAndroid Build Coastguard Worker             if (context->getSampler({name}) == nullptr)
2338*8975f5c5SAndroid Build Coastguard Worker             {
2339*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSamplerName);
2340*8975f5c5SAndroid Build Coastguard Worker                 return false;
2341*8975f5c5SAndroid Build Coastguard Worker             }
2342*8975f5c5SAndroid Build Coastguard Worker             return true;
2343*8975f5c5SAndroid Build Coastguard Worker 
2344*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE:
2345*8975f5c5SAndroid Build Coastguard Worker             if (context->getTexture({name}) == nullptr)
2346*8975f5c5SAndroid Build Coastguard Worker             {
2347*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidTextureName);
2348*8975f5c5SAndroid Build Coastguard Worker                 return false;
2349*8975f5c5SAndroid Build Coastguard Worker             }
2350*8975f5c5SAndroid Build Coastguard Worker             return true;
2351*8975f5c5SAndroid Build Coastguard Worker 
2352*8975f5c5SAndroid Build Coastguard Worker         case GL_RENDERBUFFER:
2353*8975f5c5SAndroid Build Coastguard Worker             if (!context->isRenderbuffer({name}))
2354*8975f5c5SAndroid Build Coastguard Worker             {
2355*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidRenderbufferName);
2356*8975f5c5SAndroid Build Coastguard Worker                 return false;
2357*8975f5c5SAndroid Build Coastguard Worker             }
2358*8975f5c5SAndroid Build Coastguard Worker             return true;
2359*8975f5c5SAndroid Build Coastguard Worker 
2360*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAMEBUFFER:
2361*8975f5c5SAndroid Build Coastguard Worker             if (context->getFramebuffer({name}) == nullptr)
2362*8975f5c5SAndroid Build Coastguard Worker             {
2363*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidFramebufferName);
2364*8975f5c5SAndroid Build Coastguard Worker                 return false;
2365*8975f5c5SAndroid Build Coastguard Worker             }
2366*8975f5c5SAndroid Build Coastguard Worker             return true;
2367*8975f5c5SAndroid Build Coastguard Worker 
2368*8975f5c5SAndroid Build Coastguard Worker         case GL_PROGRAM_PIPELINE:
2369*8975f5c5SAndroid Build Coastguard Worker             if (context->getProgramPipeline({name}) == nullptr)
2370*8975f5c5SAndroid Build Coastguard Worker             {
2371*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidProgramPipelineName);
2372*8975f5c5SAndroid Build Coastguard Worker                 return false;
2373*8975f5c5SAndroid Build Coastguard Worker             }
2374*8975f5c5SAndroid Build Coastguard Worker             return true;
2375*8975f5c5SAndroid Build Coastguard Worker 
2376*8975f5c5SAndroid Build Coastguard Worker         default:
2377*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidIndentifier);
2378*8975f5c5SAndroid Build Coastguard Worker             return false;
2379*8975f5c5SAndroid Build Coastguard Worker     }
2380*8975f5c5SAndroid Build Coastguard Worker }
2381*8975f5c5SAndroid Build Coastguard Worker 
ValidateLabelLength(const Context * context,angle::EntryPoint entryPoint,GLsizei length,const GLchar * label)2382*8975f5c5SAndroid Build Coastguard Worker static bool ValidateLabelLength(const Context *context,
2383*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
2384*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei length,
2385*8975f5c5SAndroid Build Coastguard Worker                                 const GLchar *label)
2386*8975f5c5SAndroid Build Coastguard Worker {
2387*8975f5c5SAndroid Build Coastguard Worker     size_t labelLength = 0;
2388*8975f5c5SAndroid Build Coastguard Worker 
2389*8975f5c5SAndroid Build Coastguard Worker     if (length < 0)
2390*8975f5c5SAndroid Build Coastguard Worker     {
2391*8975f5c5SAndroid Build Coastguard Worker         if (label != nullptr)
2392*8975f5c5SAndroid Build Coastguard Worker         {
2393*8975f5c5SAndroid Build Coastguard Worker             labelLength = strlen(label);
2394*8975f5c5SAndroid Build Coastguard Worker         }
2395*8975f5c5SAndroid Build Coastguard Worker     }
2396*8975f5c5SAndroid Build Coastguard Worker     else
2397*8975f5c5SAndroid Build Coastguard Worker     {
2398*8975f5c5SAndroid Build Coastguard Worker         labelLength = static_cast<size_t>(length);
2399*8975f5c5SAndroid Build Coastguard Worker     }
2400*8975f5c5SAndroid Build Coastguard Worker 
2401*8975f5c5SAndroid Build Coastguard Worker     if (labelLength > context->getCaps().maxLabelLength)
2402*8975f5c5SAndroid Build Coastguard Worker     {
2403*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kExceedsMaxLabelLength);
2404*8975f5c5SAndroid Build Coastguard Worker         return false;
2405*8975f5c5SAndroid Build Coastguard Worker     }
2406*8975f5c5SAndroid Build Coastguard Worker 
2407*8975f5c5SAndroid Build Coastguard Worker     return true;
2408*8975f5c5SAndroid Build Coastguard Worker }
2409*8975f5c5SAndroid Build Coastguard Worker 
ValidateObjectLabelBase(const Context * context,angle::EntryPoint entryPoint,GLenum identifier,GLuint name,GLsizei length,const GLchar * label)2410*8975f5c5SAndroid Build Coastguard Worker bool ValidateObjectLabelBase(const Context *context,
2411*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
2412*8975f5c5SAndroid Build Coastguard Worker                              GLenum identifier,
2413*8975f5c5SAndroid Build Coastguard Worker                              GLuint name,
2414*8975f5c5SAndroid Build Coastguard Worker                              GLsizei length,
2415*8975f5c5SAndroid Build Coastguard Worker                              const GLchar *label)
2416*8975f5c5SAndroid Build Coastguard Worker {
2417*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateObjectIdentifierAndName(context, entryPoint, identifier, name))
2418*8975f5c5SAndroid Build Coastguard Worker     {
2419*8975f5c5SAndroid Build Coastguard Worker         return false;
2420*8975f5c5SAndroid Build Coastguard Worker     }
2421*8975f5c5SAndroid Build Coastguard Worker 
2422*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateLabelLength(context, entryPoint, length, label))
2423*8975f5c5SAndroid Build Coastguard Worker     {
2424*8975f5c5SAndroid Build Coastguard Worker         return false;
2425*8975f5c5SAndroid Build Coastguard Worker     }
2426*8975f5c5SAndroid Build Coastguard Worker 
2427*8975f5c5SAndroid Build Coastguard Worker     return true;
2428*8975f5c5SAndroid Build Coastguard Worker }
2429*8975f5c5SAndroid Build Coastguard Worker 
ValidateObjectLabelKHR(const Context * context,angle::EntryPoint entryPoint,GLenum identifier,GLuint name,GLsizei length,const GLchar * label)2430*8975f5c5SAndroid Build Coastguard Worker bool ValidateObjectLabelKHR(const Context *context,
2431*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
2432*8975f5c5SAndroid Build Coastguard Worker                             GLenum identifier,
2433*8975f5c5SAndroid Build Coastguard Worker                             GLuint name,
2434*8975f5c5SAndroid Build Coastguard Worker                             GLsizei length,
2435*8975f5c5SAndroid Build Coastguard Worker                             const GLchar *label)
2436*8975f5c5SAndroid Build Coastguard Worker {
2437*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2438*8975f5c5SAndroid Build Coastguard Worker     {
2439*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2440*8975f5c5SAndroid Build Coastguard Worker         return false;
2441*8975f5c5SAndroid Build Coastguard Worker     }
2442*8975f5c5SAndroid Build Coastguard Worker 
2443*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateObjectLabelBase(context, entryPoint, identifier, name, length, label))
2444*8975f5c5SAndroid Build Coastguard Worker     {
2445*8975f5c5SAndroid Build Coastguard Worker         return false;
2446*8975f5c5SAndroid Build Coastguard Worker     }
2447*8975f5c5SAndroid Build Coastguard Worker 
2448*8975f5c5SAndroid Build Coastguard Worker     return true;
2449*8975f5c5SAndroid Build Coastguard Worker }
2450*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetObjectLabelBase(const Context * context,angle::EntryPoint entryPoint,GLenum identifier,GLuint name,GLsizei bufSize,const GLsizei * length,const GLchar * label)2451*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetObjectLabelBase(const Context *context,
2452*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
2453*8975f5c5SAndroid Build Coastguard Worker                                 GLenum identifier,
2454*8975f5c5SAndroid Build Coastguard Worker                                 GLuint name,
2455*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei bufSize,
2456*8975f5c5SAndroid Build Coastguard Worker                                 const GLsizei *length,
2457*8975f5c5SAndroid Build Coastguard Worker                                 const GLchar *label)
2458*8975f5c5SAndroid Build Coastguard Worker {
2459*8975f5c5SAndroid Build Coastguard Worker     if (bufSize < 0)
2460*8975f5c5SAndroid Build Coastguard Worker     {
2461*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
2462*8975f5c5SAndroid Build Coastguard Worker         return false;
2463*8975f5c5SAndroid Build Coastguard Worker     }
2464*8975f5c5SAndroid Build Coastguard Worker 
2465*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateObjectIdentifierAndName(context, entryPoint, identifier, name))
2466*8975f5c5SAndroid Build Coastguard Worker     {
2467*8975f5c5SAndroid Build Coastguard Worker         return false;
2468*8975f5c5SAndroid Build Coastguard Worker     }
2469*8975f5c5SAndroid Build Coastguard Worker 
2470*8975f5c5SAndroid Build Coastguard Worker     return true;
2471*8975f5c5SAndroid Build Coastguard Worker }
2472*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetObjectLabelKHR(const Context * context,angle::EntryPoint entryPoint,GLenum identifier,GLuint name,GLsizei bufSize,const GLsizei * length,const GLchar * label)2473*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetObjectLabelKHR(const Context *context,
2474*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
2475*8975f5c5SAndroid Build Coastguard Worker                                GLenum identifier,
2476*8975f5c5SAndroid Build Coastguard Worker                                GLuint name,
2477*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufSize,
2478*8975f5c5SAndroid Build Coastguard Worker                                const GLsizei *length,
2479*8975f5c5SAndroid Build Coastguard Worker                                const GLchar *label)
2480*8975f5c5SAndroid Build Coastguard Worker {
2481*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2482*8975f5c5SAndroid Build Coastguard Worker     {
2483*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2484*8975f5c5SAndroid Build Coastguard Worker         return false;
2485*8975f5c5SAndroid Build Coastguard Worker     }
2486*8975f5c5SAndroid Build Coastguard Worker 
2487*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateGetObjectLabelBase(context, entryPoint, identifier, name, bufSize, length, label))
2488*8975f5c5SAndroid Build Coastguard Worker     {
2489*8975f5c5SAndroid Build Coastguard Worker         return false;
2490*8975f5c5SAndroid Build Coastguard Worker     }
2491*8975f5c5SAndroid Build Coastguard Worker 
2492*8975f5c5SAndroid Build Coastguard Worker     return true;
2493*8975f5c5SAndroid Build Coastguard Worker }
2494*8975f5c5SAndroid Build Coastguard Worker 
ValidateObjectPtrName(const Context * context,angle::EntryPoint entryPoint,const void * ptr)2495*8975f5c5SAndroid Build Coastguard Worker static bool ValidateObjectPtrName(const Context *context,
2496*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
2497*8975f5c5SAndroid Build Coastguard Worker                                   const void *ptr)
2498*8975f5c5SAndroid Build Coastguard Worker {
2499*8975f5c5SAndroid Build Coastguard Worker     if (!context->getSync({unsafe_pointer_to_int_cast<uint32_t>(ptr)}))
2500*8975f5c5SAndroid Build Coastguard Worker     {
2501*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSyncPointer);
2502*8975f5c5SAndroid Build Coastguard Worker         return false;
2503*8975f5c5SAndroid Build Coastguard Worker     }
2504*8975f5c5SAndroid Build Coastguard Worker 
2505*8975f5c5SAndroid Build Coastguard Worker     return true;
2506*8975f5c5SAndroid Build Coastguard Worker }
2507*8975f5c5SAndroid Build Coastguard Worker 
ValidateObjectPtrLabelBase(const Context * context,angle::EntryPoint entryPoint,const void * ptr,GLsizei length,const GLchar * label)2508*8975f5c5SAndroid Build Coastguard Worker bool ValidateObjectPtrLabelBase(const Context *context,
2509*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
2510*8975f5c5SAndroid Build Coastguard Worker                                 const void *ptr,
2511*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei length,
2512*8975f5c5SAndroid Build Coastguard Worker                                 const GLchar *label)
2513*8975f5c5SAndroid Build Coastguard Worker {
2514*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateObjectPtrName(context, entryPoint, ptr))
2515*8975f5c5SAndroid Build Coastguard Worker     {
2516*8975f5c5SAndroid Build Coastguard Worker         return false;
2517*8975f5c5SAndroid Build Coastguard Worker     }
2518*8975f5c5SAndroid Build Coastguard Worker 
2519*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateLabelLength(context, entryPoint, length, label))
2520*8975f5c5SAndroid Build Coastguard Worker     {
2521*8975f5c5SAndroid Build Coastguard Worker         return false;
2522*8975f5c5SAndroid Build Coastguard Worker     }
2523*8975f5c5SAndroid Build Coastguard Worker 
2524*8975f5c5SAndroid Build Coastguard Worker     return true;
2525*8975f5c5SAndroid Build Coastguard Worker }
2526*8975f5c5SAndroid Build Coastguard Worker 
ValidateObjectPtrLabelKHR(const Context * context,angle::EntryPoint entryPoint,const void * ptr,GLsizei length,const GLchar * label)2527*8975f5c5SAndroid Build Coastguard Worker bool ValidateObjectPtrLabelKHR(const Context *context,
2528*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
2529*8975f5c5SAndroid Build Coastguard Worker                                const void *ptr,
2530*8975f5c5SAndroid Build Coastguard Worker                                GLsizei length,
2531*8975f5c5SAndroid Build Coastguard Worker                                const GLchar *label)
2532*8975f5c5SAndroid Build Coastguard Worker {
2533*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2534*8975f5c5SAndroid Build Coastguard Worker     {
2535*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2536*8975f5c5SAndroid Build Coastguard Worker         return false;
2537*8975f5c5SAndroid Build Coastguard Worker     }
2538*8975f5c5SAndroid Build Coastguard Worker 
2539*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateObjectPtrLabelBase(context, entryPoint, ptr, length, label))
2540*8975f5c5SAndroid Build Coastguard Worker     {
2541*8975f5c5SAndroid Build Coastguard Worker         return false;
2542*8975f5c5SAndroid Build Coastguard Worker     }
2543*8975f5c5SAndroid Build Coastguard Worker 
2544*8975f5c5SAndroid Build Coastguard Worker     return true;
2545*8975f5c5SAndroid Build Coastguard Worker }
2546*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetObjectPtrLabelBase(const Context * context,angle::EntryPoint entryPoint,const void * ptr,GLsizei bufSize,const GLsizei * length,const GLchar * label)2547*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetObjectPtrLabelBase(const Context *context,
2548*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
2549*8975f5c5SAndroid Build Coastguard Worker                                    const void *ptr,
2550*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
2551*8975f5c5SAndroid Build Coastguard Worker                                    const GLsizei *length,
2552*8975f5c5SAndroid Build Coastguard Worker                                    const GLchar *label)
2553*8975f5c5SAndroid Build Coastguard Worker {
2554*8975f5c5SAndroid Build Coastguard Worker     if (bufSize < 0)
2555*8975f5c5SAndroid Build Coastguard Worker     {
2556*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
2557*8975f5c5SAndroid Build Coastguard Worker         return false;
2558*8975f5c5SAndroid Build Coastguard Worker     }
2559*8975f5c5SAndroid Build Coastguard Worker 
2560*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateObjectPtrName(context, entryPoint, ptr))
2561*8975f5c5SAndroid Build Coastguard Worker     {
2562*8975f5c5SAndroid Build Coastguard Worker         return false;
2563*8975f5c5SAndroid Build Coastguard Worker     }
2564*8975f5c5SAndroid Build Coastguard Worker 
2565*8975f5c5SAndroid Build Coastguard Worker     return true;
2566*8975f5c5SAndroid Build Coastguard Worker }
2567*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetObjectPtrLabelKHR(const Context * context,angle::EntryPoint entryPoint,const void * ptr,GLsizei bufSize,const GLsizei * length,const GLchar * label)2568*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetObjectPtrLabelKHR(const Context *context,
2569*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
2570*8975f5c5SAndroid Build Coastguard Worker                                   const void *ptr,
2571*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
2572*8975f5c5SAndroid Build Coastguard Worker                                   const GLsizei *length,
2573*8975f5c5SAndroid Build Coastguard Worker                                   const GLchar *label)
2574*8975f5c5SAndroid Build Coastguard Worker {
2575*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2576*8975f5c5SAndroid Build Coastguard Worker     {
2577*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2578*8975f5c5SAndroid Build Coastguard Worker         return false;
2579*8975f5c5SAndroid Build Coastguard Worker     }
2580*8975f5c5SAndroid Build Coastguard Worker 
2581*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateGetObjectPtrLabelBase(context, entryPoint, ptr, bufSize, length, label))
2582*8975f5c5SAndroid Build Coastguard Worker     {
2583*8975f5c5SAndroid Build Coastguard Worker         return false;
2584*8975f5c5SAndroid Build Coastguard Worker     }
2585*8975f5c5SAndroid Build Coastguard Worker 
2586*8975f5c5SAndroid Build Coastguard Worker     return true;
2587*8975f5c5SAndroid Build Coastguard Worker }
2588*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetPointervKHR(const Context * context,angle::EntryPoint entryPoint,GLenum pname,void * const * params)2589*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetPointervKHR(const Context *context,
2590*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
2591*8975f5c5SAndroid Build Coastguard Worker                             GLenum pname,
2592*8975f5c5SAndroid Build Coastguard Worker                             void *const *params)
2593*8975f5c5SAndroid Build Coastguard Worker {
2594*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugKHR)
2595*8975f5c5SAndroid Build Coastguard Worker     {
2596*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2597*8975f5c5SAndroid Build Coastguard Worker         return false;
2598*8975f5c5SAndroid Build Coastguard Worker     }
2599*8975f5c5SAndroid Build Coastguard Worker 
2600*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetPointerv(context, entryPoint, pname, params);
2601*8975f5c5SAndroid Build Coastguard Worker }
2602*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetPointervRobustANGLERobustANGLE(const Context * context,angle::EntryPoint entryPoint,GLenum pname,GLsizei bufSize,const GLsizei * length,void * const * params)2603*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetPointervRobustANGLERobustANGLE(const Context *context,
2604*8975f5c5SAndroid Build Coastguard Worker                                                angle::EntryPoint entryPoint,
2605*8975f5c5SAndroid Build Coastguard Worker                                                GLenum pname,
2606*8975f5c5SAndroid Build Coastguard Worker                                                GLsizei bufSize,
2607*8975f5c5SAndroid Build Coastguard Worker                                                const GLsizei *length,
2608*8975f5c5SAndroid Build Coastguard Worker                                                void *const *params)
2609*8975f5c5SAndroid Build Coastguard Worker {
2610*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2611*8975f5c5SAndroid Build Coastguard Worker     return false;
2612*8975f5c5SAndroid Build Coastguard Worker }
2613*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlitFramebufferANGLE(const Context * context,angle::EntryPoint entryPoint,GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)2614*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlitFramebufferANGLE(const Context *context,
2615*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
2616*8975f5c5SAndroid Build Coastguard Worker                                   GLint srcX0,
2617*8975f5c5SAndroid Build Coastguard Worker                                   GLint srcY0,
2618*8975f5c5SAndroid Build Coastguard Worker                                   GLint srcX1,
2619*8975f5c5SAndroid Build Coastguard Worker                                   GLint srcY1,
2620*8975f5c5SAndroid Build Coastguard Worker                                   GLint dstX0,
2621*8975f5c5SAndroid Build Coastguard Worker                                   GLint dstY0,
2622*8975f5c5SAndroid Build Coastguard Worker                                   GLint dstX1,
2623*8975f5c5SAndroid Build Coastguard Worker                                   GLint dstY1,
2624*8975f5c5SAndroid Build Coastguard Worker                                   GLbitfield mask,
2625*8975f5c5SAndroid Build Coastguard Worker                                   GLenum filter)
2626*8975f5c5SAndroid Build Coastguard Worker {
2627*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().framebufferBlitANGLE)
2628*8975f5c5SAndroid Build Coastguard Worker     {
2629*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBlitExtensionNotAvailable);
2630*8975f5c5SAndroid Build Coastguard Worker         return false;
2631*8975f5c5SAndroid Build Coastguard Worker     }
2632*8975f5c5SAndroid Build Coastguard Worker 
2633*8975f5c5SAndroid Build Coastguard Worker     if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
2634*8975f5c5SAndroid Build Coastguard Worker     {
2635*8975f5c5SAndroid Build Coastguard Worker         // TODO(jmadill): Determine if this should be available on other implementations.
2636*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBlitExtensionScaleOrFlip);
2637*8975f5c5SAndroid Build Coastguard Worker         return false;
2638*8975f5c5SAndroid Build Coastguard Worker     }
2639*8975f5c5SAndroid Build Coastguard Worker 
2640*8975f5c5SAndroid Build Coastguard Worker     if (filter == GL_LINEAR)
2641*8975f5c5SAndroid Build Coastguard Worker     {
2642*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kBlitExtensionLinear);
2643*8975f5c5SAndroid Build Coastguard Worker         return false;
2644*8975f5c5SAndroid Build Coastguard Worker     }
2645*8975f5c5SAndroid Build Coastguard Worker 
2646*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *readFramebuffer = context->getState().getReadFramebuffer();
2647*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer();
2648*8975f5c5SAndroid Build Coastguard Worker 
2649*8975f5c5SAndroid Build Coastguard Worker     if (mask & GL_COLOR_BUFFER_BIT)
2650*8975f5c5SAndroid Build Coastguard Worker     {
2651*8975f5c5SAndroid Build Coastguard Worker         const FramebufferAttachment *readColorAttachment =
2652*8975f5c5SAndroid Build Coastguard Worker             readFramebuffer->getReadColorAttachment();
2653*8975f5c5SAndroid Build Coastguard Worker         const FramebufferAttachment *drawColorAttachment =
2654*8975f5c5SAndroid Build Coastguard Worker             drawFramebuffer->getFirstColorAttachment();
2655*8975f5c5SAndroid Build Coastguard Worker 
2656*8975f5c5SAndroid Build Coastguard Worker         if (readColorAttachment && drawColorAttachment)
2657*8975f5c5SAndroid Build Coastguard Worker         {
2658*8975f5c5SAndroid Build Coastguard Worker             if (!(readColorAttachment->type() == GL_TEXTURE &&
2659*8975f5c5SAndroid Build Coastguard Worker                   (readColorAttachment->getTextureImageIndex().getType() == TextureType::_2D ||
2660*8975f5c5SAndroid Build Coastguard Worker                    readColorAttachment->getTextureImageIndex().getType() ==
2661*8975f5c5SAndroid Build Coastguard Worker                        TextureType::Rectangle)) &&
2662*8975f5c5SAndroid Build Coastguard Worker                 readColorAttachment->type() != GL_RENDERBUFFER &&
2663*8975f5c5SAndroid Build Coastguard Worker                 readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT)
2664*8975f5c5SAndroid Build Coastguard Worker             {
2665*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
2666*8975f5c5SAndroid Build Coastguard Worker                                        kBlitExtensionFromInvalidAttachmentType);
2667*8975f5c5SAndroid Build Coastguard Worker                 return false;
2668*8975f5c5SAndroid Build Coastguard Worker             }
2669*8975f5c5SAndroid Build Coastguard Worker 
2670*8975f5c5SAndroid Build Coastguard Worker             for (size_t drawbufferIdx = 0;
2671*8975f5c5SAndroid Build Coastguard Worker                  drawbufferIdx < drawFramebuffer->getDrawbufferStateCount(); ++drawbufferIdx)
2672*8975f5c5SAndroid Build Coastguard Worker             {
2673*8975f5c5SAndroid Build Coastguard Worker                 const FramebufferAttachment *attachment =
2674*8975f5c5SAndroid Build Coastguard Worker                     drawFramebuffer->getDrawBuffer(drawbufferIdx);
2675*8975f5c5SAndroid Build Coastguard Worker                 if (attachment)
2676*8975f5c5SAndroid Build Coastguard Worker                 {
2677*8975f5c5SAndroid Build Coastguard Worker                     if (!(attachment->type() == GL_TEXTURE &&
2678*8975f5c5SAndroid Build Coastguard Worker                           (attachment->getTextureImageIndex().getType() == TextureType::_2D ||
2679*8975f5c5SAndroid Build Coastguard Worker                            attachment->getTextureImageIndex().getType() ==
2680*8975f5c5SAndroid Build Coastguard Worker                                TextureType::Rectangle)) &&
2681*8975f5c5SAndroid Build Coastguard Worker                         attachment->type() != GL_RENDERBUFFER &&
2682*8975f5c5SAndroid Build Coastguard Worker                         attachment->type() != GL_FRAMEBUFFER_DEFAULT)
2683*8975f5c5SAndroid Build Coastguard Worker                     {
2684*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
2685*8975f5c5SAndroid Build Coastguard Worker                                                kBlitExtensionToInvalidAttachmentType);
2686*8975f5c5SAndroid Build Coastguard Worker                         return false;
2687*8975f5c5SAndroid Build Coastguard Worker                     }
2688*8975f5c5SAndroid Build Coastguard Worker 
2689*8975f5c5SAndroid Build Coastguard Worker                     // Return an error if the destination formats do not match
2690*8975f5c5SAndroid Build Coastguard Worker                     if (!Format::EquivalentForBlit(attachment->getFormat(),
2691*8975f5c5SAndroid Build Coastguard Worker                                                    readColorAttachment->getFormat()))
2692*8975f5c5SAndroid Build Coastguard Worker                     {
2693*8975f5c5SAndroid Build Coastguard Worker                         ANGLE_VALIDATION_ERRORF(
2694*8975f5c5SAndroid Build Coastguard Worker                             GL_INVALID_OPERATION, kBlitExtensionFormatMismatch,
2695*8975f5c5SAndroid Build Coastguard Worker                             readColorAttachment->getFormat().info->sizedInternalFormat,
2696*8975f5c5SAndroid Build Coastguard Worker                             attachment->getFormat().info->sizedInternalFormat);
2697*8975f5c5SAndroid Build Coastguard Worker                         return false;
2698*8975f5c5SAndroid Build Coastguard Worker                     }
2699*8975f5c5SAndroid Build Coastguard Worker                 }
2700*8975f5c5SAndroid Build Coastguard Worker             }
2701*8975f5c5SAndroid Build Coastguard Worker 
2702*8975f5c5SAndroid Build Coastguard Worker             GLint samples = readFramebuffer->getSamples(context);
2703*8975f5c5SAndroid Build Coastguard Worker             if (samples != 0 &&
2704*8975f5c5SAndroid Build Coastguard Worker                 IsPartialBlit(context, readColorAttachment, drawColorAttachment, srcX0, srcY0,
2705*8975f5c5SAndroid Build Coastguard Worker                               srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
2706*8975f5c5SAndroid Build Coastguard Worker             {
2707*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
2708*8975f5c5SAndroid Build Coastguard Worker                                        kBlitExtensionMultisampledWholeBufferBlit);
2709*8975f5c5SAndroid Build Coastguard Worker                 return false;
2710*8975f5c5SAndroid Build Coastguard Worker             }
2711*8975f5c5SAndroid Build Coastguard Worker         }
2712*8975f5c5SAndroid Build Coastguard Worker     }
2713*8975f5c5SAndroid Build Coastguard Worker 
2714*8975f5c5SAndroid Build Coastguard Worker     GLenum masks[]       = {GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT};
2715*8975f5c5SAndroid Build Coastguard Worker     GLenum attachments[] = {GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
2716*8975f5c5SAndroid Build Coastguard Worker     for (size_t i = 0; i < 2; i++)
2717*8975f5c5SAndroid Build Coastguard Worker     {
2718*8975f5c5SAndroid Build Coastguard Worker         if (mask & masks[i])
2719*8975f5c5SAndroid Build Coastguard Worker         {
2720*8975f5c5SAndroid Build Coastguard Worker             const FramebufferAttachment *readBuffer =
2721*8975f5c5SAndroid Build Coastguard Worker                 readFramebuffer->getAttachment(context, attachments[i]);
2722*8975f5c5SAndroid Build Coastguard Worker             const FramebufferAttachment *drawBuffer =
2723*8975f5c5SAndroid Build Coastguard Worker                 drawFramebuffer->getAttachment(context, attachments[i]);
2724*8975f5c5SAndroid Build Coastguard Worker 
2725*8975f5c5SAndroid Build Coastguard Worker             if (readBuffer && drawBuffer)
2726*8975f5c5SAndroid Build Coastguard Worker             {
2727*8975f5c5SAndroid Build Coastguard Worker                 if (IsPartialBlit(context, readBuffer, drawBuffer, srcX0, srcY0, srcX1, srcY1,
2728*8975f5c5SAndroid Build Coastguard Worker                                   dstX0, dstY0, dstX1, dstY1))
2729*8975f5c5SAndroid Build Coastguard Worker                 {
2730*8975f5c5SAndroid Build Coastguard Worker                     // only whole-buffer copies are permitted
2731*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
2732*8975f5c5SAndroid Build Coastguard Worker                                            kBlitExtensionDepthStencilWholeBufferBlit);
2733*8975f5c5SAndroid Build Coastguard Worker                     return false;
2734*8975f5c5SAndroid Build Coastguard Worker                 }
2735*8975f5c5SAndroid Build Coastguard Worker 
2736*8975f5c5SAndroid Build Coastguard Worker                 if (readBuffer->getResourceSamples() != 0 || drawBuffer->getResourceSamples() != 0)
2737*8975f5c5SAndroid Build Coastguard Worker                 {
2738*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
2739*8975f5c5SAndroid Build Coastguard Worker                                            kBlitExtensionMultisampledDepthOrStencil);
2740*8975f5c5SAndroid Build Coastguard Worker                     return false;
2741*8975f5c5SAndroid Build Coastguard Worker                 }
2742*8975f5c5SAndroid Build Coastguard Worker             }
2743*8975f5c5SAndroid Build Coastguard Worker         }
2744*8975f5c5SAndroid Build Coastguard Worker     }
2745*8975f5c5SAndroid Build Coastguard Worker 
2746*8975f5c5SAndroid Build Coastguard Worker     return ValidateBlitFramebufferParameters(context, entryPoint, srcX0, srcY0, srcX1, srcY1, dstX0,
2747*8975f5c5SAndroid Build Coastguard Worker                                              dstY0, dstX1, dstY1, mask, filter);
2748*8975f5c5SAndroid Build Coastguard Worker }
2749*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlitFramebufferNV(const Context * context,angle::EntryPoint entryPoint,GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)2750*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlitFramebufferNV(const Context *context,
2751*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
2752*8975f5c5SAndroid Build Coastguard Worker                                GLint srcX0,
2753*8975f5c5SAndroid Build Coastguard Worker                                GLint srcY0,
2754*8975f5c5SAndroid Build Coastguard Worker                                GLint srcX1,
2755*8975f5c5SAndroid Build Coastguard Worker                                GLint srcY1,
2756*8975f5c5SAndroid Build Coastguard Worker                                GLint dstX0,
2757*8975f5c5SAndroid Build Coastguard Worker                                GLint dstY0,
2758*8975f5c5SAndroid Build Coastguard Worker                                GLint dstX1,
2759*8975f5c5SAndroid Build Coastguard Worker                                GLint dstY1,
2760*8975f5c5SAndroid Build Coastguard Worker                                GLbitfield mask,
2761*8975f5c5SAndroid Build Coastguard Worker                                GLenum filter)
2762*8975f5c5SAndroid Build Coastguard Worker {
2763*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().framebufferBlitANGLE)
2764*8975f5c5SAndroid Build Coastguard Worker     {
2765*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBlitExtensionNotAvailable);
2766*8975f5c5SAndroid Build Coastguard Worker         return false;
2767*8975f5c5SAndroid Build Coastguard Worker     }
2768*8975f5c5SAndroid Build Coastguard Worker 
2769*8975f5c5SAndroid Build Coastguard Worker     return ValidateBlitFramebufferParameters(context, entryPoint, srcX0, srcY0, srcX1, srcY1, dstX0,
2770*8975f5c5SAndroid Build Coastguard Worker                                              dstY0, dstX1, dstY1, mask, filter);
2771*8975f5c5SAndroid Build Coastguard Worker }
2772*8975f5c5SAndroid Build Coastguard Worker 
ValidateClear(const Context * context,angle::EntryPoint entryPoint,GLbitfield mask)2773*8975f5c5SAndroid Build Coastguard Worker bool ValidateClear(const Context *context, angle::EntryPoint entryPoint, GLbitfield mask)
2774*8975f5c5SAndroid Build Coastguard Worker {
2775*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *fbo             = context->getState().getDrawFramebuffer();
2776*8975f5c5SAndroid Build Coastguard Worker     const Extensions &extensions = context->getExtensions();
2777*8975f5c5SAndroid Build Coastguard Worker 
2778*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateFramebufferComplete(context, entryPoint, fbo))
2779*8975f5c5SAndroid Build Coastguard Worker     {
2780*8975f5c5SAndroid Build Coastguard Worker         return false;
2781*8975f5c5SAndroid Build Coastguard Worker     }
2782*8975f5c5SAndroid Build Coastguard Worker 
2783*8975f5c5SAndroid Build Coastguard Worker     // The QCOM_framebuffer_foveated spec:
2784*8975f5c5SAndroid Build Coastguard Worker     if (fbo->isFoveationEnabled())
2785*8975f5c5SAndroid Build Coastguard Worker     {
2786*8975f5c5SAndroid Build Coastguard Worker         // INVALID_OPERATION is generated by any API call which causes a framebuffer
2787*8975f5c5SAndroid Build Coastguard Worker         // attachment to be written to if the framebuffer attachments have changed for
2788*8975f5c5SAndroid Build Coastguard Worker         // a foveated fbo.
2789*8975f5c5SAndroid Build Coastguard Worker         if (fbo->hasAnyAttachmentChanged())
2790*8975f5c5SAndroid Build Coastguard Worker         {
2791*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kFramebufferFoveationAttachmentChanged);
2792*8975f5c5SAndroid Build Coastguard Worker             return false;
2793*8975f5c5SAndroid Build Coastguard Worker         }
2794*8975f5c5SAndroid Build Coastguard Worker     }
2795*8975f5c5SAndroid Build Coastguard Worker 
2796*8975f5c5SAndroid Build Coastguard Worker     if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
2797*8975f5c5SAndroid Build Coastguard Worker     {
2798*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidClearMask);
2799*8975f5c5SAndroid Build Coastguard Worker         return false;
2800*8975f5c5SAndroid Build Coastguard Worker     }
2801*8975f5c5SAndroid Build Coastguard Worker 
2802*8975f5c5SAndroid Build Coastguard Worker     if (extensions.webglCompatibilityANGLE && (mask & GL_COLOR_BUFFER_BIT) != 0)
2803*8975f5c5SAndroid Build Coastguard Worker     {
2804*8975f5c5SAndroid Build Coastguard Worker         if (GetIntOrUnsignedIntDrawBufferMask(fbo->getDrawBufferTypeMask()).any())
2805*8975f5c5SAndroid Build Coastguard Worker         {
2806*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNoDefinedClearConversion);
2807*8975f5c5SAndroid Build Coastguard Worker             return false;
2808*8975f5c5SAndroid Build Coastguard Worker         }
2809*8975f5c5SAndroid Build Coastguard Worker     }
2810*8975f5c5SAndroid Build Coastguard Worker 
2811*8975f5c5SAndroid Build Coastguard Worker     if (extensions.renderSharedExponentQCOM && (mask & GL_COLOR_BUFFER_BIT) != 0)
2812*8975f5c5SAndroid Build Coastguard Worker     {
2813*8975f5c5SAndroid Build Coastguard Worker         const State &state = context->getState();
2814*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateColorMasksForSharedExponentColorBuffers(state.getBlendStateExt(),
2815*8975f5c5SAndroid Build Coastguard Worker                                                              state.getDrawFramebuffer()))
2816*8975f5c5SAndroid Build Coastguard Worker         {
2817*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
2818*8975f5c5SAndroid Build Coastguard Worker                                    kUnsupportedColorMaskForSharedExponentColorBuffer);
2819*8975f5c5SAndroid Build Coastguard Worker             return false;
2820*8975f5c5SAndroid Build Coastguard Worker         }
2821*8975f5c5SAndroid Build Coastguard Worker     }
2822*8975f5c5SAndroid Build Coastguard Worker 
2823*8975f5c5SAndroid Build Coastguard Worker     if ((extensions.multiviewOVR || extensions.multiview2OVR) && extensions.disjointTimerQueryEXT)
2824*8975f5c5SAndroid Build Coastguard Worker     {
2825*8975f5c5SAndroid Build Coastguard Worker         const State &state       = context->getState();
2826*8975f5c5SAndroid Build Coastguard Worker         Framebuffer *framebuffer = state.getDrawFramebuffer();
2827*8975f5c5SAndroid Build Coastguard Worker         if (framebuffer->getNumViews() > 1 && state.isQueryActive(QueryType::TimeElapsed))
2828*8975f5c5SAndroid Build Coastguard Worker         {
2829*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMultiviewTimerQuery);
2830*8975f5c5SAndroid Build Coastguard Worker             return false;
2831*8975f5c5SAndroid Build Coastguard Worker         }
2832*8975f5c5SAndroid Build Coastguard Worker     }
2833*8975f5c5SAndroid Build Coastguard Worker 
2834*8975f5c5SAndroid Build Coastguard Worker     return true;
2835*8975f5c5SAndroid Build Coastguard Worker }
2836*8975f5c5SAndroid Build Coastguard Worker 
ValidateDrawBuffersEXT(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const GLenum * bufs)2837*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawBuffersEXT(const Context *context,
2838*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
2839*8975f5c5SAndroid Build Coastguard Worker                             GLsizei n,
2840*8975f5c5SAndroid Build Coastguard Worker                             const GLenum *bufs)
2841*8975f5c5SAndroid Build Coastguard Worker {
2842*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().drawBuffersEXT)
2843*8975f5c5SAndroid Build Coastguard Worker     {
2844*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
2845*8975f5c5SAndroid Build Coastguard Worker         return false;
2846*8975f5c5SAndroid Build Coastguard Worker     }
2847*8975f5c5SAndroid Build Coastguard Worker 
2848*8975f5c5SAndroid Build Coastguard Worker     return ValidateDrawBuffersBase(context, entryPoint, n, bufs);
2849*8975f5c5SAndroid Build Coastguard Worker }
2850*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexImage2D(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const void * pixels)2851*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexImage2D(const Context *context,
2852*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
2853*8975f5c5SAndroid Build Coastguard Worker                         TextureTarget target,
2854*8975f5c5SAndroid Build Coastguard Worker                         GLint level,
2855*8975f5c5SAndroid Build Coastguard Worker                         GLint internalformat,
2856*8975f5c5SAndroid Build Coastguard Worker                         GLsizei width,
2857*8975f5c5SAndroid Build Coastguard Worker                         GLsizei height,
2858*8975f5c5SAndroid Build Coastguard Worker                         GLint border,
2859*8975f5c5SAndroid Build Coastguard Worker                         GLenum format,
2860*8975f5c5SAndroid Build Coastguard Worker                         GLenum type,
2861*8975f5c5SAndroid Build Coastguard Worker                         const void *pixels)
2862*8975f5c5SAndroid Build Coastguard Worker {
2863*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
2864*8975f5c5SAndroid Build Coastguard Worker     {
2865*8975f5c5SAndroid Build Coastguard Worker         return ValidateES2TexImageParameters(context, entryPoint, target, level, internalformat,
2866*8975f5c5SAndroid Build Coastguard Worker                                              false, false, 0, 0, width, height, border, format,
2867*8975f5c5SAndroid Build Coastguard Worker                                              type, -1, pixels);
2868*8975f5c5SAndroid Build Coastguard Worker     }
2869*8975f5c5SAndroid Build Coastguard Worker 
2870*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->getClientMajorVersion() >= 3);
2871*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3TexImage2DParameters(context, entryPoint, target, level, internalformat,
2872*8975f5c5SAndroid Build Coastguard Worker                                            false, false, 0, 0, 0, width, height, 1, border, format,
2873*8975f5c5SAndroid Build Coastguard Worker                                            type, -1, pixels);
2874*8975f5c5SAndroid Build Coastguard Worker }
2875*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexImage2DRobustANGLE(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,GLsizei bufSize,const void * pixels)2876*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexImage2DRobustANGLE(const Context *context,
2877*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
2878*8975f5c5SAndroid Build Coastguard Worker                                    TextureTarget target,
2879*8975f5c5SAndroid Build Coastguard Worker                                    GLint level,
2880*8975f5c5SAndroid Build Coastguard Worker                                    GLint internalformat,
2881*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei width,
2882*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei height,
2883*8975f5c5SAndroid Build Coastguard Worker                                    GLint border,
2884*8975f5c5SAndroid Build Coastguard Worker                                    GLenum format,
2885*8975f5c5SAndroid Build Coastguard Worker                                    GLenum type,
2886*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
2887*8975f5c5SAndroid Build Coastguard Worker                                    const void *pixels)
2888*8975f5c5SAndroid Build Coastguard Worker {
2889*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateRobustEntryPoint(context, entryPoint, bufSize))
2890*8975f5c5SAndroid Build Coastguard Worker     {
2891*8975f5c5SAndroid Build Coastguard Worker         return false;
2892*8975f5c5SAndroid Build Coastguard Worker     }
2893*8975f5c5SAndroid Build Coastguard Worker 
2894*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
2895*8975f5c5SAndroid Build Coastguard Worker     {
2896*8975f5c5SAndroid Build Coastguard Worker         return ValidateES2TexImageParameters(context, entryPoint, target, level, internalformat,
2897*8975f5c5SAndroid Build Coastguard Worker                                              false, false, 0, 0, width, height, border, format,
2898*8975f5c5SAndroid Build Coastguard Worker                                              type, bufSize, pixels);
2899*8975f5c5SAndroid Build Coastguard Worker     }
2900*8975f5c5SAndroid Build Coastguard Worker 
2901*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->getClientMajorVersion() >= 3);
2902*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3TexImage2DParameters(context, entryPoint, target, level, internalformat,
2903*8975f5c5SAndroid Build Coastguard Worker                                            false, false, 0, 0, 0, width, height, 1, border, format,
2904*8975f5c5SAndroid Build Coastguard Worker                                            type, bufSize, pixels);
2905*8975f5c5SAndroid Build Coastguard Worker }
2906*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexSubImage2D(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const void * pixels)2907*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexSubImage2D(const Context *context,
2908*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
2909*8975f5c5SAndroid Build Coastguard Worker                            TextureTarget target,
2910*8975f5c5SAndroid Build Coastguard Worker                            GLint level,
2911*8975f5c5SAndroid Build Coastguard Worker                            GLint xoffset,
2912*8975f5c5SAndroid Build Coastguard Worker                            GLint yoffset,
2913*8975f5c5SAndroid Build Coastguard Worker                            GLsizei width,
2914*8975f5c5SAndroid Build Coastguard Worker                            GLsizei height,
2915*8975f5c5SAndroid Build Coastguard Worker                            GLenum format,
2916*8975f5c5SAndroid Build Coastguard Worker                            GLenum type,
2917*8975f5c5SAndroid Build Coastguard Worker                            const void *pixels)
2918*8975f5c5SAndroid Build Coastguard Worker {
2919*8975f5c5SAndroid Build Coastguard Worker 
2920*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
2921*8975f5c5SAndroid Build Coastguard Worker     {
2922*8975f5c5SAndroid Build Coastguard Worker         return ValidateES2TexImageParameters(context, entryPoint, target, level, GL_NONE, false,
2923*8975f5c5SAndroid Build Coastguard Worker                                              true, xoffset, yoffset, width, height, 0, format, type,
2924*8975f5c5SAndroid Build Coastguard Worker                                              -1, pixels);
2925*8975f5c5SAndroid Build Coastguard Worker     }
2926*8975f5c5SAndroid Build Coastguard Worker 
2927*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->getClientMajorVersion() >= 3);
2928*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3TexImage2DParameters(context, entryPoint, target, level, GL_NONE, false, true,
2929*8975f5c5SAndroid Build Coastguard Worker                                            xoffset, yoffset, 0, width, height, 1, 0, format, type,
2930*8975f5c5SAndroid Build Coastguard Worker                                            -1, pixels);
2931*8975f5c5SAndroid Build Coastguard Worker }
2932*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexSubImage2DRobustANGLE(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,const void * pixels)2933*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexSubImage2DRobustANGLE(const Context *context,
2934*8975f5c5SAndroid Build Coastguard Worker                                       angle::EntryPoint entryPoint,
2935*8975f5c5SAndroid Build Coastguard Worker                                       TextureTarget target,
2936*8975f5c5SAndroid Build Coastguard Worker                                       GLint level,
2937*8975f5c5SAndroid Build Coastguard Worker                                       GLint xoffset,
2938*8975f5c5SAndroid Build Coastguard Worker                                       GLint yoffset,
2939*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei width,
2940*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei height,
2941*8975f5c5SAndroid Build Coastguard Worker                                       GLenum format,
2942*8975f5c5SAndroid Build Coastguard Worker                                       GLenum type,
2943*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei bufSize,
2944*8975f5c5SAndroid Build Coastguard Worker                                       const void *pixels)
2945*8975f5c5SAndroid Build Coastguard Worker {
2946*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateRobustEntryPoint(context, entryPoint, bufSize))
2947*8975f5c5SAndroid Build Coastguard Worker     {
2948*8975f5c5SAndroid Build Coastguard Worker         return false;
2949*8975f5c5SAndroid Build Coastguard Worker     }
2950*8975f5c5SAndroid Build Coastguard Worker 
2951*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
2952*8975f5c5SAndroid Build Coastguard Worker     {
2953*8975f5c5SAndroid Build Coastguard Worker         return ValidateES2TexImageParameters(context, entryPoint, target, level, GL_NONE, false,
2954*8975f5c5SAndroid Build Coastguard Worker                                              true, xoffset, yoffset, width, height, 0, format, type,
2955*8975f5c5SAndroid Build Coastguard Worker                                              bufSize, pixels);
2956*8975f5c5SAndroid Build Coastguard Worker     }
2957*8975f5c5SAndroid Build Coastguard Worker 
2958*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->getClientMajorVersion() >= 3);
2959*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3TexImage2DParameters(context, entryPoint, target, level, GL_NONE, false, true,
2960*8975f5c5SAndroid Build Coastguard Worker                                            xoffset, yoffset, 0, width, height, 1, 0, format, type,
2961*8975f5c5SAndroid Build Coastguard Worker                                            bufSize, pixels);
2962*8975f5c5SAndroid Build Coastguard Worker }
2963*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexSubImage3DOES(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const void * pixels)2964*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexSubImage3DOES(const Context *context,
2965*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
2966*8975f5c5SAndroid Build Coastguard Worker                               TextureTarget target,
2967*8975f5c5SAndroid Build Coastguard Worker                               GLint level,
2968*8975f5c5SAndroid Build Coastguard Worker                               GLint xoffset,
2969*8975f5c5SAndroid Build Coastguard Worker                               GLint yoffset,
2970*8975f5c5SAndroid Build Coastguard Worker                               GLint zoffset,
2971*8975f5c5SAndroid Build Coastguard Worker                               GLsizei width,
2972*8975f5c5SAndroid Build Coastguard Worker                               GLsizei height,
2973*8975f5c5SAndroid Build Coastguard Worker                               GLsizei depth,
2974*8975f5c5SAndroid Build Coastguard Worker                               GLenum format,
2975*8975f5c5SAndroid Build Coastguard Worker                               GLenum type,
2976*8975f5c5SAndroid Build Coastguard Worker                               const void *pixels)
2977*8975f5c5SAndroid Build Coastguard Worker {
2978*8975f5c5SAndroid Build Coastguard Worker     return ValidateTexSubImage3D(context, entryPoint, target, level, xoffset, yoffset, zoffset,
2979*8975f5c5SAndroid Build Coastguard Worker                                  width, height, depth, format, type, pixels);
2980*8975f5c5SAndroid Build Coastguard Worker }
2981*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompressedTexImage2D(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const void * data)2982*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompressedTexImage2D(const Context *context,
2983*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
2984*8975f5c5SAndroid Build Coastguard Worker                                   TextureTarget target,
2985*8975f5c5SAndroid Build Coastguard Worker                                   GLint level,
2986*8975f5c5SAndroid Build Coastguard Worker                                   GLenum internalformat,
2987*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei width,
2988*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei height,
2989*8975f5c5SAndroid Build Coastguard Worker                                   GLint border,
2990*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei imageSize,
2991*8975f5c5SAndroid Build Coastguard Worker                                   const void *data)
2992*8975f5c5SAndroid Build Coastguard Worker {
2993*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
2994*8975f5c5SAndroid Build Coastguard Worker     {
2995*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateES2TexImageParameters(context, entryPoint, target, level, internalformat, true,
2996*8975f5c5SAndroid Build Coastguard Worker                                            false, 0, 0, width, height, border, GL_NONE, GL_NONE, -1,
2997*8975f5c5SAndroid Build Coastguard Worker                                            data))
2998*8975f5c5SAndroid Build Coastguard Worker         {
2999*8975f5c5SAndroid Build Coastguard Worker             return false;
3000*8975f5c5SAndroid Build Coastguard Worker         }
3001*8975f5c5SAndroid Build Coastguard Worker     }
3002*8975f5c5SAndroid Build Coastguard Worker     else
3003*8975f5c5SAndroid Build Coastguard Worker     {
3004*8975f5c5SAndroid Build Coastguard Worker         ASSERT(context->getClientMajorVersion() >= 3);
3005*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateES3TexImage2DParameters(context, entryPoint, target, level, internalformat,
3006*8975f5c5SAndroid Build Coastguard Worker                                              true, false, 0, 0, 0, width, height, 1, border,
3007*8975f5c5SAndroid Build Coastguard Worker                                              GL_NONE, GL_NONE, -1, data))
3008*8975f5c5SAndroid Build Coastguard Worker         {
3009*8975f5c5SAndroid Build Coastguard Worker             return false;
3010*8975f5c5SAndroid Build Coastguard Worker         }
3011*8975f5c5SAndroid Build Coastguard Worker     }
3012*8975f5c5SAndroid Build Coastguard Worker 
3013*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &formatInfo = GetSizedInternalFormatInfo(internalformat);
3014*8975f5c5SAndroid Build Coastguard Worker 
3015*8975f5c5SAndroid Build Coastguard Worker     GLuint expectedImageSize = 0;
3016*8975f5c5SAndroid Build Coastguard Worker     if (!formatInfo.computeCompressedImageSize(Extents(width, height, 1), &expectedImageSize))
3017*8975f5c5SAndroid Build Coastguard Worker     {
3018*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kIntegerOverflow);
3019*8975f5c5SAndroid Build Coastguard Worker         return false;
3020*8975f5c5SAndroid Build Coastguard Worker     }
3021*8975f5c5SAndroid Build Coastguard Worker 
3022*8975f5c5SAndroid Build Coastguard Worker     if (imageSize < 0 || static_cast<GLuint>(imageSize) != expectedImageSize)
3023*8975f5c5SAndroid Build Coastguard Worker     {
3024*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kCompressedTextureDimensionsMustMatchData);
3025*8975f5c5SAndroid Build Coastguard Worker         return false;
3026*8975f5c5SAndroid Build Coastguard Worker     }
3027*8975f5c5SAndroid Build Coastguard Worker 
3028*8975f5c5SAndroid Build Coastguard Worker     if (target == TextureTarget::Rectangle)
3029*8975f5c5SAndroid Build Coastguard Worker     {
3030*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kRectangleTextureCompressed);
3031*8975f5c5SAndroid Build Coastguard Worker         return false;
3032*8975f5c5SAndroid Build Coastguard Worker     }
3033*8975f5c5SAndroid Build Coastguard Worker 
3034*8975f5c5SAndroid Build Coastguard Worker     return true;
3035*8975f5c5SAndroid Build Coastguard Worker }
3036*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompressedTexImage2DRobustANGLE(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,GLsizei dataSize,const void * data)3037*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompressedTexImage2DRobustANGLE(const Context *context,
3038*8975f5c5SAndroid Build Coastguard Worker                                              angle::EntryPoint entryPoint,
3039*8975f5c5SAndroid Build Coastguard Worker                                              TextureTarget target,
3040*8975f5c5SAndroid Build Coastguard Worker                                              GLint level,
3041*8975f5c5SAndroid Build Coastguard Worker                                              GLenum internalformat,
3042*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei width,
3043*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei height,
3044*8975f5c5SAndroid Build Coastguard Worker                                              GLint border,
3045*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei imageSize,
3046*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei dataSize,
3047*8975f5c5SAndroid Build Coastguard Worker                                              const void *data)
3048*8975f5c5SAndroid Build Coastguard Worker {
3049*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateRobustCompressedTexImageBase(context, entryPoint, imageSize, dataSize))
3050*8975f5c5SAndroid Build Coastguard Worker     {
3051*8975f5c5SAndroid Build Coastguard Worker         return false;
3052*8975f5c5SAndroid Build Coastguard Worker     }
3053*8975f5c5SAndroid Build Coastguard Worker 
3054*8975f5c5SAndroid Build Coastguard Worker     return ValidateCompressedTexImage2D(context, entryPoint, target, level, internalformat, width,
3055*8975f5c5SAndroid Build Coastguard Worker                                         height, border, imageSize, data);
3056*8975f5c5SAndroid Build Coastguard Worker }
3057*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompressedTexImage3DOES(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const void * data)3058*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompressedTexImage3DOES(const Context *context,
3059*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
3060*8975f5c5SAndroid Build Coastguard Worker                                      TextureTarget target,
3061*8975f5c5SAndroid Build Coastguard Worker                                      GLint level,
3062*8975f5c5SAndroid Build Coastguard Worker                                      GLenum internalformat,
3063*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei width,
3064*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei height,
3065*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei depth,
3066*8975f5c5SAndroid Build Coastguard Worker                                      GLint border,
3067*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei imageSize,
3068*8975f5c5SAndroid Build Coastguard Worker                                      const void *data)
3069*8975f5c5SAndroid Build Coastguard Worker {
3070*8975f5c5SAndroid Build Coastguard Worker     return ValidateCompressedTexImage3D(context, entryPoint, target, level, internalformat, width,
3071*8975f5c5SAndroid Build Coastguard Worker                                         height, depth, border, imageSize, data);
3072*8975f5c5SAndroid Build Coastguard Worker }
3073*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompressedTexSubImage2DRobustANGLE(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,GLsizei dataSize,const void * data)3074*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompressedTexSubImage2DRobustANGLE(const Context *context,
3075*8975f5c5SAndroid Build Coastguard Worker                                                 angle::EntryPoint entryPoint,
3076*8975f5c5SAndroid Build Coastguard Worker                                                 TextureTarget target,
3077*8975f5c5SAndroid Build Coastguard Worker                                                 GLint level,
3078*8975f5c5SAndroid Build Coastguard Worker                                                 GLint xoffset,
3079*8975f5c5SAndroid Build Coastguard Worker                                                 GLint yoffset,
3080*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei width,
3081*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei height,
3082*8975f5c5SAndroid Build Coastguard Worker                                                 GLenum format,
3083*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei imageSize,
3084*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei dataSize,
3085*8975f5c5SAndroid Build Coastguard Worker                                                 const void *data)
3086*8975f5c5SAndroid Build Coastguard Worker {
3087*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateRobustCompressedTexImageBase(context, entryPoint, imageSize, dataSize))
3088*8975f5c5SAndroid Build Coastguard Worker     {
3089*8975f5c5SAndroid Build Coastguard Worker         return false;
3090*8975f5c5SAndroid Build Coastguard Worker     }
3091*8975f5c5SAndroid Build Coastguard Worker 
3092*8975f5c5SAndroid Build Coastguard Worker     return ValidateCompressedTexSubImage2D(context, entryPoint, target, level, xoffset, yoffset,
3093*8975f5c5SAndroid Build Coastguard Worker                                            width, height, format, imageSize, data);
3094*8975f5c5SAndroid Build Coastguard Worker }
3095*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompressedTexSubImage2D(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const void * data)3096*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompressedTexSubImage2D(const Context *context,
3097*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
3098*8975f5c5SAndroid Build Coastguard Worker                                      TextureTarget target,
3099*8975f5c5SAndroid Build Coastguard Worker                                      GLint level,
3100*8975f5c5SAndroid Build Coastguard Worker                                      GLint xoffset,
3101*8975f5c5SAndroid Build Coastguard Worker                                      GLint yoffset,
3102*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei width,
3103*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei height,
3104*8975f5c5SAndroid Build Coastguard Worker                                      GLenum format,
3105*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei imageSize,
3106*8975f5c5SAndroid Build Coastguard Worker                                      const void *data)
3107*8975f5c5SAndroid Build Coastguard Worker {
3108*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
3109*8975f5c5SAndroid Build Coastguard Worker     {
3110*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateES2TexImageParameters(context, entryPoint, target, level, GL_NONE, true, true,
3111*8975f5c5SAndroid Build Coastguard Worker                                            xoffset, yoffset, width, height, 0, format, GL_NONE, -1,
3112*8975f5c5SAndroid Build Coastguard Worker                                            data))
3113*8975f5c5SAndroid Build Coastguard Worker         {
3114*8975f5c5SAndroid Build Coastguard Worker             return false;
3115*8975f5c5SAndroid Build Coastguard Worker         }
3116*8975f5c5SAndroid Build Coastguard Worker     }
3117*8975f5c5SAndroid Build Coastguard Worker     else
3118*8975f5c5SAndroid Build Coastguard Worker     {
3119*8975f5c5SAndroid Build Coastguard Worker         ASSERT(context->getClientMajorVersion() >= 3);
3120*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateES3TexImage2DParameters(context, entryPoint, target, level, GL_NONE, true,
3121*8975f5c5SAndroid Build Coastguard Worker                                              true, xoffset, yoffset, 0, width, height, 1, 0, format,
3122*8975f5c5SAndroid Build Coastguard Worker                                              GL_NONE, -1, data))
3123*8975f5c5SAndroid Build Coastguard Worker         {
3124*8975f5c5SAndroid Build Coastguard Worker             return false;
3125*8975f5c5SAndroid Build Coastguard Worker         }
3126*8975f5c5SAndroid Build Coastguard Worker     }
3127*8975f5c5SAndroid Build Coastguard Worker 
3128*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &formatInfo = GetSizedInternalFormatInfo(format);
3129*8975f5c5SAndroid Build Coastguard Worker     GLuint blockSize                 = 0;
3130*8975f5c5SAndroid Build Coastguard Worker     if (!formatInfo.computeCompressedImageSize(Extents(width, height, 1), &blockSize))
3131*8975f5c5SAndroid Build Coastguard Worker     {
3132*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kIntegerOverflow);
3133*8975f5c5SAndroid Build Coastguard Worker         return false;
3134*8975f5c5SAndroid Build Coastguard Worker     }
3135*8975f5c5SAndroid Build Coastguard Worker 
3136*8975f5c5SAndroid Build Coastguard Worker     if (imageSize < 0 || static_cast<GLuint>(imageSize) != blockSize)
3137*8975f5c5SAndroid Build Coastguard Worker     {
3138*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidCompressedImageSize);
3139*8975f5c5SAndroid Build Coastguard Worker         return false;
3140*8975f5c5SAndroid Build Coastguard Worker     }
3141*8975f5c5SAndroid Build Coastguard Worker 
3142*8975f5c5SAndroid Build Coastguard Worker     return true;
3143*8975f5c5SAndroid Build Coastguard Worker }
3144*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompressedTexSubImage3DOES(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const void * data)3145*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompressedTexSubImage3DOES(const Context *context,
3146*8975f5c5SAndroid Build Coastguard Worker                                         angle::EntryPoint entryPoint,
3147*8975f5c5SAndroid Build Coastguard Worker                                         TextureTarget target,
3148*8975f5c5SAndroid Build Coastguard Worker                                         GLint level,
3149*8975f5c5SAndroid Build Coastguard Worker                                         GLint xoffset,
3150*8975f5c5SAndroid Build Coastguard Worker                                         GLint yoffset,
3151*8975f5c5SAndroid Build Coastguard Worker                                         GLint zoffset,
3152*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei width,
3153*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei height,
3154*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei depth,
3155*8975f5c5SAndroid Build Coastguard Worker                                         GLenum format,
3156*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei imageSize,
3157*8975f5c5SAndroid Build Coastguard Worker                                         const void *data)
3158*8975f5c5SAndroid Build Coastguard Worker {
3159*8975f5c5SAndroid Build Coastguard Worker     return ValidateCompressedTexSubImage3D(context, entryPoint, target, level, xoffset, yoffset,
3160*8975f5c5SAndroid Build Coastguard Worker                                            zoffset, width, height, depth, format, imageSize, data);
3161*8975f5c5SAndroid Build Coastguard Worker }
3162*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetBufferPointervOES(const Context * context,angle::EntryPoint entryPoint,BufferBinding target,GLenum pname,void * const * params)3163*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetBufferPointervOES(const Context *context,
3164*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
3165*8975f5c5SAndroid Build Coastguard Worker                                   BufferBinding target,
3166*8975f5c5SAndroid Build Coastguard Worker                                   GLenum pname,
3167*8975f5c5SAndroid Build Coastguard Worker                                   void *const *params)
3168*8975f5c5SAndroid Build Coastguard Worker {
3169*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().mapbufferOES)
3170*8975f5c5SAndroid Build Coastguard Worker     {
3171*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3172*8975f5c5SAndroid Build Coastguard Worker         return false;
3173*8975f5c5SAndroid Build Coastguard Worker     }
3174*8975f5c5SAndroid Build Coastguard Worker 
3175*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetBufferPointervBase(context, entryPoint, target, pname, nullptr, params);
3176*8975f5c5SAndroid Build Coastguard Worker }
3177*8975f5c5SAndroid Build Coastguard Worker 
ValidateMapBufferOES(const Context * context,angle::EntryPoint entryPoint,BufferBinding target,GLenum access)3178*8975f5c5SAndroid Build Coastguard Worker bool ValidateMapBufferOES(const Context *context,
3179*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
3180*8975f5c5SAndroid Build Coastguard Worker                           BufferBinding target,
3181*8975f5c5SAndroid Build Coastguard Worker                           GLenum access)
3182*8975f5c5SAndroid Build Coastguard Worker {
3183*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().mapbufferOES)
3184*8975f5c5SAndroid Build Coastguard Worker     {
3185*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3186*8975f5c5SAndroid Build Coastguard Worker         return false;
3187*8975f5c5SAndroid Build Coastguard Worker     }
3188*8975f5c5SAndroid Build Coastguard Worker 
3189*8975f5c5SAndroid Build Coastguard Worker     if (!context->isValidBufferBinding(target))
3190*8975f5c5SAndroid Build Coastguard Worker     {
3191*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidBufferTypes);
3192*8975f5c5SAndroid Build Coastguard Worker         return false;
3193*8975f5c5SAndroid Build Coastguard Worker     }
3194*8975f5c5SAndroid Build Coastguard Worker 
3195*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = context->getState().getTargetBuffer(target);
3196*8975f5c5SAndroid Build Coastguard Worker 
3197*8975f5c5SAndroid Build Coastguard Worker     if (buffer == nullptr)
3198*8975f5c5SAndroid Build Coastguard Worker     {
3199*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferNotMappable);
3200*8975f5c5SAndroid Build Coastguard Worker         return false;
3201*8975f5c5SAndroid Build Coastguard Worker     }
3202*8975f5c5SAndroid Build Coastguard Worker 
3203*8975f5c5SAndroid Build Coastguard Worker     if (access != GL_WRITE_ONLY_OES)
3204*8975f5c5SAndroid Build Coastguard Worker     {
3205*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidAccessBits);
3206*8975f5c5SAndroid Build Coastguard Worker         return false;
3207*8975f5c5SAndroid Build Coastguard Worker     }
3208*8975f5c5SAndroid Build Coastguard Worker 
3209*8975f5c5SAndroid Build Coastguard Worker     // Though there is no explicit mention of an interaction between GL_EXT_buffer_storage
3210*8975f5c5SAndroid Build Coastguard Worker     // and GL_OES_mapbuffer extension, allow it as long as the access type of glmapbufferOES
3211*8975f5c5SAndroid Build Coastguard Worker     // is compatible with the buffer's usage flags specified during glBufferStorageEXT
3212*8975f5c5SAndroid Build Coastguard Worker     if (buffer->isImmutable() && (buffer->getStorageExtUsageFlags() & GL_MAP_WRITE_BIT) == 0)
3213*8975f5c5SAndroid Build Coastguard Worker     {
3214*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferNotMappable);
3215*8975f5c5SAndroid Build Coastguard Worker         return false;
3216*8975f5c5SAndroid Build Coastguard Worker     }
3217*8975f5c5SAndroid Build Coastguard Worker 
3218*8975f5c5SAndroid Build Coastguard Worker     if (buffer->isMapped())
3219*8975f5c5SAndroid Build Coastguard Worker     {
3220*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferAlreadyMapped);
3221*8975f5c5SAndroid Build Coastguard Worker         return false;
3222*8975f5c5SAndroid Build Coastguard Worker     }
3223*8975f5c5SAndroid Build Coastguard Worker 
3224*8975f5c5SAndroid Build Coastguard Worker     return ValidateMapBufferBase(context, entryPoint, target);
3225*8975f5c5SAndroid Build Coastguard Worker }
3226*8975f5c5SAndroid Build Coastguard Worker 
ValidateUnmapBufferOES(const Context * context,angle::EntryPoint entryPoint,BufferBinding target)3227*8975f5c5SAndroid Build Coastguard Worker bool ValidateUnmapBufferOES(const Context *context,
3228*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
3229*8975f5c5SAndroid Build Coastguard Worker                             BufferBinding target)
3230*8975f5c5SAndroid Build Coastguard Worker {
3231*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().mapbufferOES)
3232*8975f5c5SAndroid Build Coastguard Worker     {
3233*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3234*8975f5c5SAndroid Build Coastguard Worker         return false;
3235*8975f5c5SAndroid Build Coastguard Worker     }
3236*8975f5c5SAndroid Build Coastguard Worker 
3237*8975f5c5SAndroid Build Coastguard Worker     return ValidateUnmapBufferBase(context, entryPoint, target);
3238*8975f5c5SAndroid Build Coastguard Worker }
3239*8975f5c5SAndroid Build Coastguard Worker 
ValidateMapBufferRangeEXT(const Context * context,angle::EntryPoint entryPoint,BufferBinding target,GLintptr offset,GLsizeiptr length,GLbitfield access)3240*8975f5c5SAndroid Build Coastguard Worker bool ValidateMapBufferRangeEXT(const Context *context,
3241*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
3242*8975f5c5SAndroid Build Coastguard Worker                                BufferBinding target,
3243*8975f5c5SAndroid Build Coastguard Worker                                GLintptr offset,
3244*8975f5c5SAndroid Build Coastguard Worker                                GLsizeiptr length,
3245*8975f5c5SAndroid Build Coastguard Worker                                GLbitfield access)
3246*8975f5c5SAndroid Build Coastguard Worker {
3247*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().mapBufferRangeEXT)
3248*8975f5c5SAndroid Build Coastguard Worker     {
3249*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3250*8975f5c5SAndroid Build Coastguard Worker         return false;
3251*8975f5c5SAndroid Build Coastguard Worker     }
3252*8975f5c5SAndroid Build Coastguard Worker 
3253*8975f5c5SAndroid Build Coastguard Worker     return ValidateMapBufferRangeBase(context, entryPoint, target, offset, length, access);
3254*8975f5c5SAndroid Build Coastguard Worker }
3255*8975f5c5SAndroid Build Coastguard Worker 
ValidateMapBufferBase(const Context * context,angle::EntryPoint entryPoint,BufferBinding target)3256*8975f5c5SAndroid Build Coastguard Worker bool ValidateMapBufferBase(const Context *context,
3257*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
3258*8975f5c5SAndroid Build Coastguard Worker                            BufferBinding target)
3259*8975f5c5SAndroid Build Coastguard Worker {
3260*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = context->getState().getTargetBuffer(target);
3261*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer != nullptr);
3262*8975f5c5SAndroid Build Coastguard Worker 
3263*8975f5c5SAndroid Build Coastguard Worker     // Check if this buffer is currently being used as a transform feedback output buffer
3264*8975f5c5SAndroid Build Coastguard Worker     if (context->getState().isTransformFeedbackActive())
3265*8975f5c5SAndroid Build Coastguard Worker     {
3266*8975f5c5SAndroid Build Coastguard Worker         TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
3267*8975f5c5SAndroid Build Coastguard Worker         for (size_t i = 0; i < transformFeedback->getIndexedBufferCount(); i++)
3268*8975f5c5SAndroid Build Coastguard Worker         {
3269*8975f5c5SAndroid Build Coastguard Worker             const auto &transformFeedbackBuffer = transformFeedback->getIndexedBuffer(i);
3270*8975f5c5SAndroid Build Coastguard Worker             if (transformFeedbackBuffer.get() == buffer)
3271*8975f5c5SAndroid Build Coastguard Worker             {
3272*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback);
3273*8975f5c5SAndroid Build Coastguard Worker                 return false;
3274*8975f5c5SAndroid Build Coastguard Worker             }
3275*8975f5c5SAndroid Build Coastguard Worker         }
3276*8975f5c5SAndroid Build Coastguard Worker     }
3277*8975f5c5SAndroid Build Coastguard Worker 
3278*8975f5c5SAndroid Build Coastguard Worker     if (buffer->hasWebGLXFBBindingConflict(context->isWebGL()))
3279*8975f5c5SAndroid Build Coastguard Worker     {
3280*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback);
3281*8975f5c5SAndroid Build Coastguard Worker         return false;
3282*8975f5c5SAndroid Build Coastguard Worker     }
3283*8975f5c5SAndroid Build Coastguard Worker 
3284*8975f5c5SAndroid Build Coastguard Worker     return true;
3285*8975f5c5SAndroid Build Coastguard Worker }
3286*8975f5c5SAndroid Build Coastguard Worker 
ValidateFlushMappedBufferRangeEXT(const Context * context,angle::EntryPoint entryPoint,BufferBinding target,GLintptr offset,GLsizeiptr length)3287*8975f5c5SAndroid Build Coastguard Worker bool ValidateFlushMappedBufferRangeEXT(const Context *context,
3288*8975f5c5SAndroid Build Coastguard Worker                                        angle::EntryPoint entryPoint,
3289*8975f5c5SAndroid Build Coastguard Worker                                        BufferBinding target,
3290*8975f5c5SAndroid Build Coastguard Worker                                        GLintptr offset,
3291*8975f5c5SAndroid Build Coastguard Worker                                        GLsizeiptr length)
3292*8975f5c5SAndroid Build Coastguard Worker {
3293*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().mapBufferRangeEXT)
3294*8975f5c5SAndroid Build Coastguard Worker     {
3295*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3296*8975f5c5SAndroid Build Coastguard Worker         return false;
3297*8975f5c5SAndroid Build Coastguard Worker     }
3298*8975f5c5SAndroid Build Coastguard Worker 
3299*8975f5c5SAndroid Build Coastguard Worker     return ValidateFlushMappedBufferRangeBase(context, entryPoint, target, offset, length);
3300*8975f5c5SAndroid Build Coastguard Worker }
3301*8975f5c5SAndroid Build Coastguard Worker 
ValidateBindUniformLocationCHROMIUM(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,UniformLocation location,const GLchar * name)3302*8975f5c5SAndroid Build Coastguard Worker bool ValidateBindUniformLocationCHROMIUM(const Context *context,
3303*8975f5c5SAndroid Build Coastguard Worker                                          angle::EntryPoint entryPoint,
3304*8975f5c5SAndroid Build Coastguard Worker                                          ShaderProgramID program,
3305*8975f5c5SAndroid Build Coastguard Worker                                          UniformLocation location,
3306*8975f5c5SAndroid Build Coastguard Worker                                          const GLchar *name)
3307*8975f5c5SAndroid Build Coastguard Worker {
3308*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().bindUniformLocationCHROMIUM)
3309*8975f5c5SAndroid Build Coastguard Worker     {
3310*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3311*8975f5c5SAndroid Build Coastguard Worker         return false;
3312*8975f5c5SAndroid Build Coastguard Worker     }
3313*8975f5c5SAndroid Build Coastguard Worker 
3314*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
3315*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
3316*8975f5c5SAndroid Build Coastguard Worker     {
3317*8975f5c5SAndroid Build Coastguard Worker         return false;
3318*8975f5c5SAndroid Build Coastguard Worker     }
3319*8975f5c5SAndroid Build Coastguard Worker 
3320*8975f5c5SAndroid Build Coastguard Worker     if (location.value < 0)
3321*8975f5c5SAndroid Build Coastguard Worker     {
3322*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeLocation);
3323*8975f5c5SAndroid Build Coastguard Worker         return false;
3324*8975f5c5SAndroid Build Coastguard Worker     }
3325*8975f5c5SAndroid Build Coastguard Worker 
3326*8975f5c5SAndroid Build Coastguard Worker     const Caps &caps = context->getCaps();
3327*8975f5c5SAndroid Build Coastguard Worker     if (static_cast<long>(location.value) >=
3328*8975f5c5SAndroid Build Coastguard Worker         (caps.maxVertexUniformVectors + caps.maxFragmentUniformVectors) * 4)
3329*8975f5c5SAndroid Build Coastguard Worker     {
3330*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidBindUniformLocation);
3331*8975f5c5SAndroid Build Coastguard Worker         return false;
3332*8975f5c5SAndroid Build Coastguard Worker     }
3333*8975f5c5SAndroid Build Coastguard Worker 
3334*8975f5c5SAndroid Build Coastguard Worker     // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters for
3335*8975f5c5SAndroid Build Coastguard Worker     // shader-related entry points
3336*8975f5c5SAndroid Build Coastguard Worker     if (context->isWebGL() && !IsValidESSLString(name, strlen(name)))
3337*8975f5c5SAndroid Build Coastguard Worker     {
3338*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidNameCharacters);
3339*8975f5c5SAndroid Build Coastguard Worker         return false;
3340*8975f5c5SAndroid Build Coastguard Worker     }
3341*8975f5c5SAndroid Build Coastguard Worker 
3342*8975f5c5SAndroid Build Coastguard Worker     if (strncmp(name, "gl_", 3) == 0)
3343*8975f5c5SAndroid Build Coastguard Worker     {
3344*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNameBeginsWithGL);
3345*8975f5c5SAndroid Build Coastguard Worker         return false;
3346*8975f5c5SAndroid Build Coastguard Worker     }
3347*8975f5c5SAndroid Build Coastguard Worker 
3348*8975f5c5SAndroid Build Coastguard Worker     return true;
3349*8975f5c5SAndroid Build Coastguard Worker }
3350*8975f5c5SAndroid Build Coastguard Worker 
ValidateCoverageModulationCHROMIUM(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum components)3351*8975f5c5SAndroid Build Coastguard Worker bool ValidateCoverageModulationCHROMIUM(const PrivateState &state,
3352*8975f5c5SAndroid Build Coastguard Worker                                         ErrorSet *errors,
3353*8975f5c5SAndroid Build Coastguard Worker                                         angle::EntryPoint entryPoint,
3354*8975f5c5SAndroid Build Coastguard Worker                                         GLenum components)
3355*8975f5c5SAndroid Build Coastguard Worker {
3356*8975f5c5SAndroid Build Coastguard Worker     if (!state.getExtensions().framebufferMixedSamplesCHROMIUM)
3357*8975f5c5SAndroid Build Coastguard Worker     {
3358*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
3359*8975f5c5SAndroid Build Coastguard Worker         return false;
3360*8975f5c5SAndroid Build Coastguard Worker     }
3361*8975f5c5SAndroid Build Coastguard Worker     switch (components)
3362*8975f5c5SAndroid Build Coastguard Worker     {
3363*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB:
3364*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA:
3365*8975f5c5SAndroid Build Coastguard Worker         case GL_ALPHA:
3366*8975f5c5SAndroid Build Coastguard Worker         case GL_NONE:
3367*8975f5c5SAndroid Build Coastguard Worker             break;
3368*8975f5c5SAndroid Build Coastguard Worker         default:
3369*8975f5c5SAndroid Build Coastguard Worker             errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidCoverageComponents);
3370*8975f5c5SAndroid Build Coastguard Worker             return false;
3371*8975f5c5SAndroid Build Coastguard Worker     }
3372*8975f5c5SAndroid Build Coastguard Worker 
3373*8975f5c5SAndroid Build Coastguard Worker     return true;
3374*8975f5c5SAndroid Build Coastguard Worker }
3375*8975f5c5SAndroid Build Coastguard Worker 
ValidateCopyTextureCHROMIUM(const Context * context,angle::EntryPoint entryPoint,TextureID sourceId,GLint sourceLevel,TextureTarget destTarget,TextureID destId,GLint destLevel,GLint internalFormat,GLenum destType,GLboolean unpackFlipY,GLboolean unpackPremultiplyAlpha,GLboolean unpackUnmultiplyAlpha)3376*8975f5c5SAndroid Build Coastguard Worker bool ValidateCopyTextureCHROMIUM(const Context *context,
3377*8975f5c5SAndroid Build Coastguard Worker                                  angle::EntryPoint entryPoint,
3378*8975f5c5SAndroid Build Coastguard Worker                                  TextureID sourceId,
3379*8975f5c5SAndroid Build Coastguard Worker                                  GLint sourceLevel,
3380*8975f5c5SAndroid Build Coastguard Worker                                  TextureTarget destTarget,
3381*8975f5c5SAndroid Build Coastguard Worker                                  TextureID destId,
3382*8975f5c5SAndroid Build Coastguard Worker                                  GLint destLevel,
3383*8975f5c5SAndroid Build Coastguard Worker                                  GLint internalFormat,
3384*8975f5c5SAndroid Build Coastguard Worker                                  GLenum destType,
3385*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean unpackFlipY,
3386*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean unpackPremultiplyAlpha,
3387*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean unpackUnmultiplyAlpha)
3388*8975f5c5SAndroid Build Coastguard Worker {
3389*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().copyTextureCHROMIUM)
3390*8975f5c5SAndroid Build Coastguard Worker     {
3391*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3392*8975f5c5SAndroid Build Coastguard Worker         return false;
3393*8975f5c5SAndroid Build Coastguard Worker     }
3394*8975f5c5SAndroid Build Coastguard Worker 
3395*8975f5c5SAndroid Build Coastguard Worker     const Texture *source = context->getTexture(sourceId);
3396*8975f5c5SAndroid Build Coastguard Worker     if (source == nullptr)
3397*8975f5c5SAndroid Build Coastguard Worker     {
3398*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSourceTexture);
3399*8975f5c5SAndroid Build Coastguard Worker         return false;
3400*8975f5c5SAndroid Build Coastguard Worker     }
3401*8975f5c5SAndroid Build Coastguard Worker 
3402*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureSourceTarget(context, source->getType()))
3403*8975f5c5SAndroid Build Coastguard Worker     {
3404*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERRORF(GL_INVALID_OPERATION, kInvalidInternalFormat, internalFormat);
3405*8975f5c5SAndroid Build Coastguard Worker         return false;
3406*8975f5c5SAndroid Build Coastguard Worker     }
3407*8975f5c5SAndroid Build Coastguard Worker 
3408*8975f5c5SAndroid Build Coastguard Worker     TextureType sourceType = source->getType();
3409*8975f5c5SAndroid Build Coastguard Worker     ASSERT(sourceType != TextureType::CubeMap);
3410*8975f5c5SAndroid Build Coastguard Worker     TextureTarget sourceTarget = NonCubeTextureTypeToTarget(sourceType);
3411*8975f5c5SAndroid Build Coastguard Worker 
3412*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureSourceLevel(context, sourceType, sourceLevel))
3413*8975f5c5SAndroid Build Coastguard Worker     {
3414*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSourceTextureLevel);
3415*8975f5c5SAndroid Build Coastguard Worker         return false;
3416*8975f5c5SAndroid Build Coastguard Worker     }
3417*8975f5c5SAndroid Build Coastguard Worker 
3418*8975f5c5SAndroid Build Coastguard Worker     GLsizei sourceWidth  = static_cast<GLsizei>(source->getWidth(sourceTarget, sourceLevel));
3419*8975f5c5SAndroid Build Coastguard Worker     GLsizei sourceHeight = static_cast<GLsizei>(source->getHeight(sourceTarget, sourceLevel));
3420*8975f5c5SAndroid Build Coastguard Worker     if (sourceWidth == 0 || sourceHeight == 0)
3421*8975f5c5SAndroid Build Coastguard Worker     {
3422*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERRORF(GL_INVALID_OPERATION, kInvalidInternalFormat, internalFormat);
3423*8975f5c5SAndroid Build Coastguard Worker         return false;
3424*8975f5c5SAndroid Build Coastguard Worker     }
3425*8975f5c5SAndroid Build Coastguard Worker 
3426*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &sourceFormat = *source->getFormat(sourceTarget, sourceLevel).info;
3427*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureSourceInternalFormatEnum(sourceFormat.internalFormat))
3428*8975f5c5SAndroid Build Coastguard Worker     {
3429*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidSourceTextureInternalFormat);
3430*8975f5c5SAndroid Build Coastguard Worker         return false;
3431*8975f5c5SAndroid Build Coastguard Worker     }
3432*8975f5c5SAndroid Build Coastguard Worker 
3433*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationTargetEnum(context, destTarget))
3434*8975f5c5SAndroid Build Coastguard Worker     {
3435*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
3436*8975f5c5SAndroid Build Coastguard Worker         return false;
3437*8975f5c5SAndroid Build Coastguard Worker     }
3438*8975f5c5SAndroid Build Coastguard Worker 
3439*8975f5c5SAndroid Build Coastguard Worker     const Texture *dest = context->getTexture(destId);
3440*8975f5c5SAndroid Build Coastguard Worker     if (dest == nullptr)
3441*8975f5c5SAndroid Build Coastguard Worker     {
3442*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidDestinationTexture);
3443*8975f5c5SAndroid Build Coastguard Worker         return false;
3444*8975f5c5SAndroid Build Coastguard Worker     }
3445*8975f5c5SAndroid Build Coastguard Worker 
3446*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &destInternalFormatInfo = GetInternalFormatInfo(internalFormat, destType);
3447*8975f5c5SAndroid Build Coastguard Worker     if (sourceType == TextureType::External && destInternalFormatInfo.isInt() &&
3448*8975f5c5SAndroid Build Coastguard Worker         !context->getExtensions().EGLImageExternalEssl3OES)
3449*8975f5c5SAndroid Build Coastguard Worker     {
3450*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kANGLECopyTextureMissingRequiredExtension);
3451*8975f5c5SAndroid Build Coastguard Worker         return false;
3452*8975f5c5SAndroid Build Coastguard Worker     }
3453*8975f5c5SAndroid Build Coastguard Worker 
3454*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationTarget(context, dest->getType(), destTarget))
3455*8975f5c5SAndroid Build Coastguard Worker     {
3456*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidDestinationTextureType);
3457*8975f5c5SAndroid Build Coastguard Worker         return false;
3458*8975f5c5SAndroid Build Coastguard Worker     }
3459*8975f5c5SAndroid Build Coastguard Worker 
3460*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationLevel(context, entryPoint, dest->getType(), destLevel,
3461*8975f5c5SAndroid Build Coastguard Worker                                             sourceWidth, sourceHeight, false))
3462*8975f5c5SAndroid Build Coastguard Worker     {
3463*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
3464*8975f5c5SAndroid Build Coastguard Worker         return false;
3465*8975f5c5SAndroid Build Coastguard Worker     }
3466*8975f5c5SAndroid Build Coastguard Worker 
3467*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationFormatType(context, entryPoint, internalFormat, destType))
3468*8975f5c5SAndroid Build Coastguard Worker     {
3469*8975f5c5SAndroid Build Coastguard Worker         return false;
3470*8975f5c5SAndroid Build Coastguard Worker     }
3471*8975f5c5SAndroid Build Coastguard Worker 
3472*8975f5c5SAndroid Build Coastguard Worker     if (dest->getType() == TextureType::CubeMap && sourceWidth != sourceHeight)
3473*8975f5c5SAndroid Build Coastguard Worker     {
3474*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kCubemapFacesEqualDimensions);
3475*8975f5c5SAndroid Build Coastguard Worker         return false;
3476*8975f5c5SAndroid Build Coastguard Worker     }
3477*8975f5c5SAndroid Build Coastguard Worker 
3478*8975f5c5SAndroid Build Coastguard Worker     if (dest->getImmutableFormat())
3479*8975f5c5SAndroid Build Coastguard Worker     {
3480*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kDestinationImmutable);
3481*8975f5c5SAndroid Build Coastguard Worker         return false;
3482*8975f5c5SAndroid Build Coastguard Worker     }
3483*8975f5c5SAndroid Build Coastguard Worker 
3484*8975f5c5SAndroid Build Coastguard Worker     return true;
3485*8975f5c5SAndroid Build Coastguard Worker }
3486*8975f5c5SAndroid Build Coastguard Worker 
ValidateCopySubTextureCHROMIUM(const Context * context,angle::EntryPoint entryPoint,TextureID sourceId,GLint sourceLevel,TextureTarget destTarget,TextureID destId,GLint destLevel,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height,GLboolean unpackFlipY,GLboolean unpackPremultiplyAlpha,GLboolean unpackUnmultiplyAlpha)3487*8975f5c5SAndroid Build Coastguard Worker bool ValidateCopySubTextureCHROMIUM(const Context *context,
3488*8975f5c5SAndroid Build Coastguard Worker                                     angle::EntryPoint entryPoint,
3489*8975f5c5SAndroid Build Coastguard Worker                                     TextureID sourceId,
3490*8975f5c5SAndroid Build Coastguard Worker                                     GLint sourceLevel,
3491*8975f5c5SAndroid Build Coastguard Worker                                     TextureTarget destTarget,
3492*8975f5c5SAndroid Build Coastguard Worker                                     TextureID destId,
3493*8975f5c5SAndroid Build Coastguard Worker                                     GLint destLevel,
3494*8975f5c5SAndroid Build Coastguard Worker                                     GLint xoffset,
3495*8975f5c5SAndroid Build Coastguard Worker                                     GLint yoffset,
3496*8975f5c5SAndroid Build Coastguard Worker                                     GLint x,
3497*8975f5c5SAndroid Build Coastguard Worker                                     GLint y,
3498*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei width,
3499*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei height,
3500*8975f5c5SAndroid Build Coastguard Worker                                     GLboolean unpackFlipY,
3501*8975f5c5SAndroid Build Coastguard Worker                                     GLboolean unpackPremultiplyAlpha,
3502*8975f5c5SAndroid Build Coastguard Worker                                     GLboolean unpackUnmultiplyAlpha)
3503*8975f5c5SAndroid Build Coastguard Worker {
3504*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().copyTextureCHROMIUM)
3505*8975f5c5SAndroid Build Coastguard Worker     {
3506*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3507*8975f5c5SAndroid Build Coastguard Worker         return false;
3508*8975f5c5SAndroid Build Coastguard Worker     }
3509*8975f5c5SAndroid Build Coastguard Worker 
3510*8975f5c5SAndroid Build Coastguard Worker     const Texture *source = context->getTexture(sourceId);
3511*8975f5c5SAndroid Build Coastguard Worker     if (source == nullptr)
3512*8975f5c5SAndroid Build Coastguard Worker     {
3513*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSourceTexture);
3514*8975f5c5SAndroid Build Coastguard Worker         return false;
3515*8975f5c5SAndroid Build Coastguard Worker     }
3516*8975f5c5SAndroid Build Coastguard Worker 
3517*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureSourceTarget(context, source->getType()))
3518*8975f5c5SAndroid Build Coastguard Worker     {
3519*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSourceTextureType);
3520*8975f5c5SAndroid Build Coastguard Worker         return false;
3521*8975f5c5SAndroid Build Coastguard Worker     }
3522*8975f5c5SAndroid Build Coastguard Worker 
3523*8975f5c5SAndroid Build Coastguard Worker     TextureType sourceType = source->getType();
3524*8975f5c5SAndroid Build Coastguard Worker     ASSERT(sourceType != TextureType::CubeMap);
3525*8975f5c5SAndroid Build Coastguard Worker     TextureTarget sourceTarget = NonCubeTextureTypeToTarget(sourceType);
3526*8975f5c5SAndroid Build Coastguard Worker 
3527*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureSourceLevel(context, sourceType, sourceLevel))
3528*8975f5c5SAndroid Build Coastguard Worker     {
3529*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
3530*8975f5c5SAndroid Build Coastguard Worker         return false;
3531*8975f5c5SAndroid Build Coastguard Worker     }
3532*8975f5c5SAndroid Build Coastguard Worker 
3533*8975f5c5SAndroid Build Coastguard Worker     if (source->getWidth(sourceTarget, sourceLevel) == 0 ||
3534*8975f5c5SAndroid Build Coastguard Worker         source->getHeight(sourceTarget, sourceLevel) == 0)
3535*8975f5c5SAndroid Build Coastguard Worker     {
3536*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSourceTextureLevel);
3537*8975f5c5SAndroid Build Coastguard Worker         return false;
3538*8975f5c5SAndroid Build Coastguard Worker     }
3539*8975f5c5SAndroid Build Coastguard Worker 
3540*8975f5c5SAndroid Build Coastguard Worker     if (x < 0 || y < 0)
3541*8975f5c5SAndroid Build Coastguard Worker     {
3542*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeOffset);
3543*8975f5c5SAndroid Build Coastguard Worker         return false;
3544*8975f5c5SAndroid Build Coastguard Worker     }
3545*8975f5c5SAndroid Build Coastguard Worker 
3546*8975f5c5SAndroid Build Coastguard Worker     if (width < 0 || height < 0)
3547*8975f5c5SAndroid Build Coastguard Worker     {
3548*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeSize);
3549*8975f5c5SAndroid Build Coastguard Worker         return false;
3550*8975f5c5SAndroid Build Coastguard Worker     }
3551*8975f5c5SAndroid Build Coastguard Worker 
3552*8975f5c5SAndroid Build Coastguard Worker     if (static_cast<size_t>(x + width) > source->getWidth(sourceTarget, sourceLevel) ||
3553*8975f5c5SAndroid Build Coastguard Worker         static_cast<size_t>(y + height) > source->getHeight(sourceTarget, sourceLevel))
3554*8975f5c5SAndroid Build Coastguard Worker     {
3555*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kSourceTextureTooSmall);
3556*8975f5c5SAndroid Build Coastguard Worker         return false;
3557*8975f5c5SAndroid Build Coastguard Worker     }
3558*8975f5c5SAndroid Build Coastguard Worker 
3559*8975f5c5SAndroid Build Coastguard Worker     const Format &sourceFormat = source->getFormat(sourceTarget, sourceLevel);
3560*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopySubTextureSourceInternalFormat(sourceFormat.info->internalFormat))
3561*8975f5c5SAndroid Build Coastguard Worker     {
3562*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERRORF(GL_INVALID_OPERATION, kInvalidInternalFormat,
3563*8975f5c5SAndroid Build Coastguard Worker                                 sourceFormat.info->internalFormat);
3564*8975f5c5SAndroid Build Coastguard Worker         return false;
3565*8975f5c5SAndroid Build Coastguard Worker     }
3566*8975f5c5SAndroid Build Coastguard Worker 
3567*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationTargetEnum(context, destTarget))
3568*8975f5c5SAndroid Build Coastguard Worker     {
3569*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
3570*8975f5c5SAndroid Build Coastguard Worker         return false;
3571*8975f5c5SAndroid Build Coastguard Worker     }
3572*8975f5c5SAndroid Build Coastguard Worker 
3573*8975f5c5SAndroid Build Coastguard Worker     const Texture *dest = context->getTexture(destId);
3574*8975f5c5SAndroid Build Coastguard Worker     if (dest == nullptr)
3575*8975f5c5SAndroid Build Coastguard Worker     {
3576*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidDestinationTexture);
3577*8975f5c5SAndroid Build Coastguard Worker         return false;
3578*8975f5c5SAndroid Build Coastguard Worker     }
3579*8975f5c5SAndroid Build Coastguard Worker 
3580*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationTarget(context, dest->getType(), destTarget))
3581*8975f5c5SAndroid Build Coastguard Worker     {
3582*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidDestinationTextureType);
3583*8975f5c5SAndroid Build Coastguard Worker         return false;
3584*8975f5c5SAndroid Build Coastguard Worker     }
3585*8975f5c5SAndroid Build Coastguard Worker 
3586*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopyTextureDestinationLevel(context, entryPoint, dest->getType(), destLevel, width,
3587*8975f5c5SAndroid Build Coastguard Worker                                             height, true))
3588*8975f5c5SAndroid Build Coastguard Worker     {
3589*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
3590*8975f5c5SAndroid Build Coastguard Worker         return false;
3591*8975f5c5SAndroid Build Coastguard Worker     }
3592*8975f5c5SAndroid Build Coastguard Worker 
3593*8975f5c5SAndroid Build Coastguard Worker     if (dest->getWidth(destTarget, destLevel) == 0 || dest->getHeight(destTarget, destLevel) == 0)
3594*8975f5c5SAndroid Build Coastguard Worker     {
3595*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kDestinationLevelNotDefined);
3596*8975f5c5SAndroid Build Coastguard Worker         return false;
3597*8975f5c5SAndroid Build Coastguard Worker     }
3598*8975f5c5SAndroid Build Coastguard Worker 
3599*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &destFormat = *dest->getFormat(destTarget, destLevel).info;
3600*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidCopySubTextureDestionationInternalFormat(destFormat.internalFormat))
3601*8975f5c5SAndroid Build Coastguard Worker     {
3602*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFormatCombination);
3603*8975f5c5SAndroid Build Coastguard Worker         return false;
3604*8975f5c5SAndroid Build Coastguard Worker     }
3605*8975f5c5SAndroid Build Coastguard Worker 
3606*8975f5c5SAndroid Build Coastguard Worker     if (sourceType == TextureType::External && destFormat.isInt() &&
3607*8975f5c5SAndroid Build Coastguard Worker         !context->getExtensions().EGLImageExternalEssl3OES)
3608*8975f5c5SAndroid Build Coastguard Worker     {
3609*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kANGLECopyTextureMissingRequiredExtension);
3610*8975f5c5SAndroid Build Coastguard Worker         return false;
3611*8975f5c5SAndroid Build Coastguard Worker     }
3612*8975f5c5SAndroid Build Coastguard Worker 
3613*8975f5c5SAndroid Build Coastguard Worker     if (xoffset < 0 || yoffset < 0)
3614*8975f5c5SAndroid Build Coastguard Worker     {
3615*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeOffset);
3616*8975f5c5SAndroid Build Coastguard Worker         return false;
3617*8975f5c5SAndroid Build Coastguard Worker     }
3618*8975f5c5SAndroid Build Coastguard Worker 
3619*8975f5c5SAndroid Build Coastguard Worker     if (static_cast<size_t>(xoffset + width) > dest->getWidth(destTarget, destLevel) ||
3620*8975f5c5SAndroid Build Coastguard Worker         static_cast<size_t>(yoffset + height) > dest->getHeight(destTarget, destLevel))
3621*8975f5c5SAndroid Build Coastguard Worker     {
3622*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kOffsetOverflow);
3623*8975f5c5SAndroid Build Coastguard Worker         return false;
3624*8975f5c5SAndroid Build Coastguard Worker     }
3625*8975f5c5SAndroid Build Coastguard Worker 
3626*8975f5c5SAndroid Build Coastguard Worker     return true;
3627*8975f5c5SAndroid Build Coastguard Worker }
3628*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompressedCopyTextureCHROMIUM(const Context * context,angle::EntryPoint entryPoint,TextureID sourceId,TextureID destId)3629*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompressedCopyTextureCHROMIUM(const Context *context,
3630*8975f5c5SAndroid Build Coastguard Worker                                            angle::EntryPoint entryPoint,
3631*8975f5c5SAndroid Build Coastguard Worker                                            TextureID sourceId,
3632*8975f5c5SAndroid Build Coastguard Worker                                            TextureID destId)
3633*8975f5c5SAndroid Build Coastguard Worker {
3634*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().copyCompressedTextureCHROMIUM)
3635*8975f5c5SAndroid Build Coastguard Worker     {
3636*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3637*8975f5c5SAndroid Build Coastguard Worker         return false;
3638*8975f5c5SAndroid Build Coastguard Worker     }
3639*8975f5c5SAndroid Build Coastguard Worker 
3640*8975f5c5SAndroid Build Coastguard Worker     const Texture *source = context->getTexture(sourceId);
3641*8975f5c5SAndroid Build Coastguard Worker     if (source == nullptr)
3642*8975f5c5SAndroid Build Coastguard Worker     {
3643*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSourceTexture);
3644*8975f5c5SAndroid Build Coastguard Worker         return false;
3645*8975f5c5SAndroid Build Coastguard Worker     }
3646*8975f5c5SAndroid Build Coastguard Worker 
3647*8975f5c5SAndroid Build Coastguard Worker     if (source->getType() != TextureType::_2D)
3648*8975f5c5SAndroid Build Coastguard Worker     {
3649*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidSourceTextureType);
3650*8975f5c5SAndroid Build Coastguard Worker         return false;
3651*8975f5c5SAndroid Build Coastguard Worker     }
3652*8975f5c5SAndroid Build Coastguard Worker 
3653*8975f5c5SAndroid Build Coastguard Worker     if (source->getWidth(TextureTarget::_2D, 0) == 0 ||
3654*8975f5c5SAndroid Build Coastguard Worker         source->getHeight(TextureTarget::_2D, 0) == 0)
3655*8975f5c5SAndroid Build Coastguard Worker     {
3656*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kSourceTextureLevelZeroDefined);
3657*8975f5c5SAndroid Build Coastguard Worker         return false;
3658*8975f5c5SAndroid Build Coastguard Worker     }
3659*8975f5c5SAndroid Build Coastguard Worker 
3660*8975f5c5SAndroid Build Coastguard Worker     const Format &sourceFormat = source->getFormat(TextureTarget::_2D, 0);
3661*8975f5c5SAndroid Build Coastguard Worker     if (!sourceFormat.info->compressed)
3662*8975f5c5SAndroid Build Coastguard Worker     {
3663*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kSourceTextureMustBeCompressed);
3664*8975f5c5SAndroid Build Coastguard Worker         return false;
3665*8975f5c5SAndroid Build Coastguard Worker     }
3666*8975f5c5SAndroid Build Coastguard Worker 
3667*8975f5c5SAndroid Build Coastguard Worker     const Texture *dest = context->getTexture(destId);
3668*8975f5c5SAndroid Build Coastguard Worker     if (dest == nullptr)
3669*8975f5c5SAndroid Build Coastguard Worker     {
3670*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidDestinationTexture);
3671*8975f5c5SAndroid Build Coastguard Worker         return false;
3672*8975f5c5SAndroid Build Coastguard Worker     }
3673*8975f5c5SAndroid Build Coastguard Worker 
3674*8975f5c5SAndroid Build Coastguard Worker     if (dest->getType() != TextureType::_2D)
3675*8975f5c5SAndroid Build Coastguard Worker     {
3676*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidDestinationTextureType);
3677*8975f5c5SAndroid Build Coastguard Worker         return false;
3678*8975f5c5SAndroid Build Coastguard Worker     }
3679*8975f5c5SAndroid Build Coastguard Worker 
3680*8975f5c5SAndroid Build Coastguard Worker     if (dest->getImmutableFormat())
3681*8975f5c5SAndroid Build Coastguard Worker     {
3682*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kDestinationImmutable);
3683*8975f5c5SAndroid Build Coastguard Worker         return false;
3684*8975f5c5SAndroid Build Coastguard Worker     }
3685*8975f5c5SAndroid Build Coastguard Worker 
3686*8975f5c5SAndroid Build Coastguard Worker     return true;
3687*8975f5c5SAndroid Build Coastguard Worker }
3688*8975f5c5SAndroid Build Coastguard Worker 
ValidateCreateShader(const Context * context,angle::EntryPoint entryPoint,ShaderType type)3689*8975f5c5SAndroid Build Coastguard Worker bool ValidateCreateShader(const Context *context, angle::EntryPoint entryPoint, ShaderType type)
3690*8975f5c5SAndroid Build Coastguard Worker {
3691*8975f5c5SAndroid Build Coastguard Worker     switch (type)
3692*8975f5c5SAndroid Build Coastguard Worker     {
3693*8975f5c5SAndroid Build Coastguard Worker         case ShaderType::Vertex:
3694*8975f5c5SAndroid Build Coastguard Worker         case ShaderType::Fragment:
3695*8975f5c5SAndroid Build Coastguard Worker             break;
3696*8975f5c5SAndroid Build Coastguard Worker 
3697*8975f5c5SAndroid Build Coastguard Worker         case ShaderType::Compute:
3698*8975f5c5SAndroid Build Coastguard Worker             if (context->getClientVersion() < ES_3_1)
3699*8975f5c5SAndroid Build Coastguard Worker             {
3700*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kES31Required);
3701*8975f5c5SAndroid Build Coastguard Worker                 return false;
3702*8975f5c5SAndroid Build Coastguard Worker             }
3703*8975f5c5SAndroid Build Coastguard Worker             break;
3704*8975f5c5SAndroid Build Coastguard Worker 
3705*8975f5c5SAndroid Build Coastguard Worker         case ShaderType::Geometry:
3706*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().geometryShaderAny() &&
3707*8975f5c5SAndroid Build Coastguard Worker                 context->getClientVersion() < ES_3_2)
3708*8975f5c5SAndroid Build Coastguard Worker             {
3709*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidShaderType);
3710*8975f5c5SAndroid Build Coastguard Worker                 return false;
3711*8975f5c5SAndroid Build Coastguard Worker             }
3712*8975f5c5SAndroid Build Coastguard Worker             break;
3713*8975f5c5SAndroid Build Coastguard Worker 
3714*8975f5c5SAndroid Build Coastguard Worker         case ShaderType::TessControl:
3715*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().tessellationShaderAny() &&
3716*8975f5c5SAndroid Build Coastguard Worker                 context->getClientVersion() < ES_3_2)
3717*8975f5c5SAndroid Build Coastguard Worker             {
3718*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidShaderType);
3719*8975f5c5SAndroid Build Coastguard Worker                 return false;
3720*8975f5c5SAndroid Build Coastguard Worker             }
3721*8975f5c5SAndroid Build Coastguard Worker             break;
3722*8975f5c5SAndroid Build Coastguard Worker 
3723*8975f5c5SAndroid Build Coastguard Worker         case ShaderType::TessEvaluation:
3724*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().tessellationShaderAny() &&
3725*8975f5c5SAndroid Build Coastguard Worker                 context->getClientVersion() < ES_3_2)
3726*8975f5c5SAndroid Build Coastguard Worker             {
3727*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidShaderType);
3728*8975f5c5SAndroid Build Coastguard Worker                 return false;
3729*8975f5c5SAndroid Build Coastguard Worker             }
3730*8975f5c5SAndroid Build Coastguard Worker             break;
3731*8975f5c5SAndroid Build Coastguard Worker 
3732*8975f5c5SAndroid Build Coastguard Worker         default:
3733*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidShaderType);
3734*8975f5c5SAndroid Build Coastguard Worker             return false;
3735*8975f5c5SAndroid Build Coastguard Worker     }
3736*8975f5c5SAndroid Build Coastguard Worker 
3737*8975f5c5SAndroid Build Coastguard Worker     return true;
3738*8975f5c5SAndroid Build Coastguard Worker }
3739*8975f5c5SAndroid Build Coastguard Worker 
ValidateBufferData(const Context * context,angle::EntryPoint entryPoint,BufferBinding target,GLsizeiptr size,const void * data,BufferUsage usage)3740*8975f5c5SAndroid Build Coastguard Worker bool ValidateBufferData(const Context *context,
3741*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
3742*8975f5c5SAndroid Build Coastguard Worker                         BufferBinding target,
3743*8975f5c5SAndroid Build Coastguard Worker                         GLsizeiptr size,
3744*8975f5c5SAndroid Build Coastguard Worker                         const void *data,
3745*8975f5c5SAndroid Build Coastguard Worker                         BufferUsage usage)
3746*8975f5c5SAndroid Build Coastguard Worker {
3747*8975f5c5SAndroid Build Coastguard Worker     if (size < 0)
3748*8975f5c5SAndroid Build Coastguard Worker     {
3749*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeSize);
3750*8975f5c5SAndroid Build Coastguard Worker         return false;
3751*8975f5c5SAndroid Build Coastguard Worker     }
3752*8975f5c5SAndroid Build Coastguard Worker 
3753*8975f5c5SAndroid Build Coastguard Worker     switch (usage)
3754*8975f5c5SAndroid Build Coastguard Worker     {
3755*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::StreamDraw:
3756*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::StaticDraw:
3757*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::DynamicDraw:
3758*8975f5c5SAndroid Build Coastguard Worker             break;
3759*8975f5c5SAndroid Build Coastguard Worker 
3760*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::StreamRead:
3761*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::StaticRead:
3762*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::DynamicRead:
3763*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::StreamCopy:
3764*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::StaticCopy:
3765*8975f5c5SAndroid Build Coastguard Worker         case BufferUsage::DynamicCopy:
3766*8975f5c5SAndroid Build Coastguard Worker             if (context->getClientMajorVersion() < 3)
3767*8975f5c5SAndroid Build Coastguard Worker             {
3768*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidBufferUsage);
3769*8975f5c5SAndroid Build Coastguard Worker                 return false;
3770*8975f5c5SAndroid Build Coastguard Worker             }
3771*8975f5c5SAndroid Build Coastguard Worker             break;
3772*8975f5c5SAndroid Build Coastguard Worker 
3773*8975f5c5SAndroid Build Coastguard Worker         default:
3774*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidBufferUsage);
3775*8975f5c5SAndroid Build Coastguard Worker             return false;
3776*8975f5c5SAndroid Build Coastguard Worker     }
3777*8975f5c5SAndroid Build Coastguard Worker 
3778*8975f5c5SAndroid Build Coastguard Worker     if (!context->isValidBufferBinding(target))
3779*8975f5c5SAndroid Build Coastguard Worker     {
3780*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidBufferTypes);
3781*8975f5c5SAndroid Build Coastguard Worker         return false;
3782*8975f5c5SAndroid Build Coastguard Worker     }
3783*8975f5c5SAndroid Build Coastguard Worker 
3784*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = context->getState().getTargetBuffer(target);
3785*8975f5c5SAndroid Build Coastguard Worker 
3786*8975f5c5SAndroid Build Coastguard Worker     if (!buffer)
3787*8975f5c5SAndroid Build Coastguard Worker     {
3788*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferNotBound);
3789*8975f5c5SAndroid Build Coastguard Worker         return false;
3790*8975f5c5SAndroid Build Coastguard Worker     }
3791*8975f5c5SAndroid Build Coastguard Worker 
3792*8975f5c5SAndroid Build Coastguard Worker     if (buffer->hasWebGLXFBBindingConflict(context->isWebGL()))
3793*8975f5c5SAndroid Build Coastguard Worker     {
3794*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback);
3795*8975f5c5SAndroid Build Coastguard Worker         return false;
3796*8975f5c5SAndroid Build Coastguard Worker     }
3797*8975f5c5SAndroid Build Coastguard Worker 
3798*8975f5c5SAndroid Build Coastguard Worker     if (buffer->isImmutable())
3799*8975f5c5SAndroid Build Coastguard Worker     {
3800*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferImmutable);
3801*8975f5c5SAndroid Build Coastguard Worker         return false;
3802*8975f5c5SAndroid Build Coastguard Worker     }
3803*8975f5c5SAndroid Build Coastguard Worker 
3804*8975f5c5SAndroid Build Coastguard Worker     return true;
3805*8975f5c5SAndroid Build Coastguard Worker }
3806*8975f5c5SAndroid Build Coastguard Worker 
ValidateBufferSubData(const Context * context,angle::EntryPoint entryPoint,BufferBinding target,GLintptr offset,GLsizeiptr size,const void * data)3807*8975f5c5SAndroid Build Coastguard Worker bool ValidateBufferSubData(const Context *context,
3808*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
3809*8975f5c5SAndroid Build Coastguard Worker                            BufferBinding target,
3810*8975f5c5SAndroid Build Coastguard Worker                            GLintptr offset,
3811*8975f5c5SAndroid Build Coastguard Worker                            GLsizeiptr size,
3812*8975f5c5SAndroid Build Coastguard Worker                            const void *data)
3813*8975f5c5SAndroid Build Coastguard Worker {
3814*8975f5c5SAndroid Build Coastguard Worker     if (size < 0)
3815*8975f5c5SAndroid Build Coastguard Worker     {
3816*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeSize);
3817*8975f5c5SAndroid Build Coastguard Worker         return false;
3818*8975f5c5SAndroid Build Coastguard Worker     }
3819*8975f5c5SAndroid Build Coastguard Worker 
3820*8975f5c5SAndroid Build Coastguard Worker     if (offset < 0)
3821*8975f5c5SAndroid Build Coastguard Worker     {
3822*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeOffset);
3823*8975f5c5SAndroid Build Coastguard Worker         return false;
3824*8975f5c5SAndroid Build Coastguard Worker     }
3825*8975f5c5SAndroid Build Coastguard Worker 
3826*8975f5c5SAndroid Build Coastguard Worker     if (!context->isValidBufferBinding(target))
3827*8975f5c5SAndroid Build Coastguard Worker     {
3828*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidBufferTypes);
3829*8975f5c5SAndroid Build Coastguard Worker         return false;
3830*8975f5c5SAndroid Build Coastguard Worker     }
3831*8975f5c5SAndroid Build Coastguard Worker 
3832*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = context->getState().getTargetBuffer(target);
3833*8975f5c5SAndroid Build Coastguard Worker 
3834*8975f5c5SAndroid Build Coastguard Worker     if (!buffer)
3835*8975f5c5SAndroid Build Coastguard Worker     {
3836*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferNotBound);
3837*8975f5c5SAndroid Build Coastguard Worker         return false;
3838*8975f5c5SAndroid Build Coastguard Worker     }
3839*8975f5c5SAndroid Build Coastguard Worker 
3840*8975f5c5SAndroid Build Coastguard Worker     // EXT_buffer_storage allows persistently mapped buffers to be updated via glBufferSubData
3841*8975f5c5SAndroid Build Coastguard Worker     bool isPersistent = (buffer->getAccessFlags() & GL_MAP_PERSISTENT_BIT_EXT) != 0;
3842*8975f5c5SAndroid Build Coastguard Worker 
3843*8975f5c5SAndroid Build Coastguard Worker     // Verify that buffer is not currently mapped unless persistent
3844*8975f5c5SAndroid Build Coastguard Worker     if (buffer->isMapped() && !isPersistent)
3845*8975f5c5SAndroid Build Coastguard Worker     {
3846*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferMapped);
3847*8975f5c5SAndroid Build Coastguard Worker         return false;
3848*8975f5c5SAndroid Build Coastguard Worker     }
3849*8975f5c5SAndroid Build Coastguard Worker 
3850*8975f5c5SAndroid Build Coastguard Worker     if (buffer->hasWebGLXFBBindingConflict(context->isWebGL()))
3851*8975f5c5SAndroid Build Coastguard Worker     {
3852*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback);
3853*8975f5c5SAndroid Build Coastguard Worker         return false;
3854*8975f5c5SAndroid Build Coastguard Worker     }
3855*8975f5c5SAndroid Build Coastguard Worker 
3856*8975f5c5SAndroid Build Coastguard Worker     if (buffer->isImmutable() &&
3857*8975f5c5SAndroid Build Coastguard Worker         (buffer->getStorageExtUsageFlags() & GL_DYNAMIC_STORAGE_BIT_EXT) == 0)
3858*8975f5c5SAndroid Build Coastguard Worker     {
3859*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBufferNotUpdatable);
3860*8975f5c5SAndroid Build Coastguard Worker         return false;
3861*8975f5c5SAndroid Build Coastguard Worker     }
3862*8975f5c5SAndroid Build Coastguard Worker 
3863*8975f5c5SAndroid Build Coastguard Worker     // Check for possible overflow of size + offset
3864*8975f5c5SAndroid Build Coastguard Worker     angle::CheckedNumeric<decltype(size + offset)> checkedSize(size);
3865*8975f5c5SAndroid Build Coastguard Worker     checkedSize += offset;
3866*8975f5c5SAndroid Build Coastguard Worker     if (!checkedSize.IsValid())
3867*8975f5c5SAndroid Build Coastguard Worker     {
3868*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kParamOverflow);
3869*8975f5c5SAndroid Build Coastguard Worker         return false;
3870*8975f5c5SAndroid Build Coastguard Worker     }
3871*8975f5c5SAndroid Build Coastguard Worker 
3872*8975f5c5SAndroid Build Coastguard Worker     if (size + offset > buffer->getSize())
3873*8975f5c5SAndroid Build Coastguard Worker     {
3874*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInsufficientBufferSize);
3875*8975f5c5SAndroid Build Coastguard Worker         return false;
3876*8975f5c5SAndroid Build Coastguard Worker     }
3877*8975f5c5SAndroid Build Coastguard Worker 
3878*8975f5c5SAndroid Build Coastguard Worker     return true;
3879*8975f5c5SAndroid Build Coastguard Worker }
3880*8975f5c5SAndroid Build Coastguard Worker 
ValidateRequestExtensionANGLE(const Context * context,angle::EntryPoint entryPoint,const GLchar * name)3881*8975f5c5SAndroid Build Coastguard Worker bool ValidateRequestExtensionANGLE(const Context *context,
3882*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
3883*8975f5c5SAndroid Build Coastguard Worker                                    const GLchar *name)
3884*8975f5c5SAndroid Build Coastguard Worker {
3885*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().requestExtensionANGLE)
3886*8975f5c5SAndroid Build Coastguard Worker     {
3887*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3888*8975f5c5SAndroid Build Coastguard Worker         return false;
3889*8975f5c5SAndroid Build Coastguard Worker     }
3890*8975f5c5SAndroid Build Coastguard Worker 
3891*8975f5c5SAndroid Build Coastguard Worker     if (!context->isExtensionRequestable(name))
3892*8975f5c5SAndroid Build Coastguard Worker     {
3893*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotRequestable);
3894*8975f5c5SAndroid Build Coastguard Worker         return false;
3895*8975f5c5SAndroid Build Coastguard Worker     }
3896*8975f5c5SAndroid Build Coastguard Worker 
3897*8975f5c5SAndroid Build Coastguard Worker     return true;
3898*8975f5c5SAndroid Build Coastguard Worker }
3899*8975f5c5SAndroid Build Coastguard Worker 
ValidateDisableExtensionANGLE(const Context * context,angle::EntryPoint entryPoint,const GLchar * name)3900*8975f5c5SAndroid Build Coastguard Worker bool ValidateDisableExtensionANGLE(const Context *context,
3901*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
3902*8975f5c5SAndroid Build Coastguard Worker                                    const GLchar *name)
3903*8975f5c5SAndroid Build Coastguard Worker {
3904*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().requestExtensionANGLE)
3905*8975f5c5SAndroid Build Coastguard Worker     {
3906*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
3907*8975f5c5SAndroid Build Coastguard Worker         return false;
3908*8975f5c5SAndroid Build Coastguard Worker     }
3909*8975f5c5SAndroid Build Coastguard Worker 
3910*8975f5c5SAndroid Build Coastguard Worker     if (!context->isExtensionDisablable(name))
3911*8975f5c5SAndroid Build Coastguard Worker     {
3912*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotDisablable);
3913*8975f5c5SAndroid Build Coastguard Worker         return false;
3914*8975f5c5SAndroid Build Coastguard Worker     }
3915*8975f5c5SAndroid Build Coastguard Worker 
3916*8975f5c5SAndroid Build Coastguard Worker     return true;
3917*8975f5c5SAndroid Build Coastguard Worker }
3918*8975f5c5SAndroid Build Coastguard Worker 
ValidateActiveTexture(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum texture)3919*8975f5c5SAndroid Build Coastguard Worker bool ValidateActiveTexture(const PrivateState &state,
3920*8975f5c5SAndroid Build Coastguard Worker                            ErrorSet *errors,
3921*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
3922*8975f5c5SAndroid Build Coastguard Worker                            GLenum texture)
3923*8975f5c5SAndroid Build Coastguard Worker {
3924*8975f5c5SAndroid Build Coastguard Worker     if (state.getClientMajorVersion() < 2)
3925*8975f5c5SAndroid Build Coastguard Worker     {
3926*8975f5c5SAndroid Build Coastguard Worker         return ValidateMultitextureUnit(state, errors, entryPoint, texture);
3927*8975f5c5SAndroid Build Coastguard Worker     }
3928*8975f5c5SAndroid Build Coastguard Worker 
3929*8975f5c5SAndroid Build Coastguard Worker     if (texture < GL_TEXTURE0 ||
3930*8975f5c5SAndroid Build Coastguard Worker         texture >
3931*8975f5c5SAndroid Build Coastguard Worker             GL_TEXTURE0 + static_cast<GLuint>(state.getCaps().maxCombinedTextureImageUnits) - 1)
3932*8975f5c5SAndroid Build Coastguard Worker     {
3933*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidCombinedImageUnit);
3934*8975f5c5SAndroid Build Coastguard Worker         return false;
3935*8975f5c5SAndroid Build Coastguard Worker     }
3936*8975f5c5SAndroid Build Coastguard Worker 
3937*8975f5c5SAndroid Build Coastguard Worker     return true;
3938*8975f5c5SAndroid Build Coastguard Worker }
3939*8975f5c5SAndroid Build Coastguard Worker 
ValidateAttachShader(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,ShaderProgramID shader)3940*8975f5c5SAndroid Build Coastguard Worker bool ValidateAttachShader(const Context *context,
3941*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
3942*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID program,
3943*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID shader)
3944*8975f5c5SAndroid Build Coastguard Worker {
3945*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
3946*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
3947*8975f5c5SAndroid Build Coastguard Worker     {
3948*8975f5c5SAndroid Build Coastguard Worker         return false;
3949*8975f5c5SAndroid Build Coastguard Worker     }
3950*8975f5c5SAndroid Build Coastguard Worker 
3951*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = GetValidShader(context, entryPoint, shader);
3952*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
3953*8975f5c5SAndroid Build Coastguard Worker     {
3954*8975f5c5SAndroid Build Coastguard Worker         return false;
3955*8975f5c5SAndroid Build Coastguard Worker     }
3956*8975f5c5SAndroid Build Coastguard Worker 
3957*8975f5c5SAndroid Build Coastguard Worker     if (programObject->getAttachedShader(shaderObject->getType()))
3958*8975f5c5SAndroid Build Coastguard Worker     {
3959*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kShaderAttachmentHasShader);
3960*8975f5c5SAndroid Build Coastguard Worker         return false;
3961*8975f5c5SAndroid Build Coastguard Worker     }
3962*8975f5c5SAndroid Build Coastguard Worker 
3963*8975f5c5SAndroid Build Coastguard Worker     return true;
3964*8975f5c5SAndroid Build Coastguard Worker }
3965*8975f5c5SAndroid Build Coastguard Worker 
ValidateBindAttribLocation(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLuint index,const GLchar * name)3966*8975f5c5SAndroid Build Coastguard Worker bool ValidateBindAttribLocation(const Context *context,
3967*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
3968*8975f5c5SAndroid Build Coastguard Worker                                 ShaderProgramID program,
3969*8975f5c5SAndroid Build Coastguard Worker                                 GLuint index,
3970*8975f5c5SAndroid Build Coastguard Worker                                 const GLchar *name)
3971*8975f5c5SAndroid Build Coastguard Worker {
3972*8975f5c5SAndroid Build Coastguard Worker     if (index >= static_cast<GLuint>(context->getCaps().maxVertexAttributes))
3973*8975f5c5SAndroid Build Coastguard Worker     {
3974*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute);
3975*8975f5c5SAndroid Build Coastguard Worker         return false;
3976*8975f5c5SAndroid Build Coastguard Worker     }
3977*8975f5c5SAndroid Build Coastguard Worker 
3978*8975f5c5SAndroid Build Coastguard Worker     if (strncmp(name, "gl_", 3) == 0)
3979*8975f5c5SAndroid Build Coastguard Worker     {
3980*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNameBeginsWithGL);
3981*8975f5c5SAndroid Build Coastguard Worker         return false;
3982*8975f5c5SAndroid Build Coastguard Worker     }
3983*8975f5c5SAndroid Build Coastguard Worker 
3984*8975f5c5SAndroid Build Coastguard Worker     if (context->isWebGL())
3985*8975f5c5SAndroid Build Coastguard Worker     {
3986*8975f5c5SAndroid Build Coastguard Worker         const size_t length = strlen(name);
3987*8975f5c5SAndroid Build Coastguard Worker 
3988*8975f5c5SAndroid Build Coastguard Worker         if (!IsValidESSLString(name, length))
3989*8975f5c5SAndroid Build Coastguard Worker         {
3990*8975f5c5SAndroid Build Coastguard Worker             // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters
3991*8975f5c5SAndroid Build Coastguard Worker             // for shader-related entry points
3992*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidNameCharacters);
3993*8975f5c5SAndroid Build Coastguard Worker             return false;
3994*8975f5c5SAndroid Build Coastguard Worker         }
3995*8975f5c5SAndroid Build Coastguard Worker 
3996*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateWebGLNameLength(context, entryPoint, length) ||
3997*8975f5c5SAndroid Build Coastguard Worker             !ValidateWebGLNamePrefix(context, entryPoint, name))
3998*8975f5c5SAndroid Build Coastguard Worker         {
3999*8975f5c5SAndroid Build Coastguard Worker             return false;
4000*8975f5c5SAndroid Build Coastguard Worker         }
4001*8975f5c5SAndroid Build Coastguard Worker     }
4002*8975f5c5SAndroid Build Coastguard Worker 
4003*8975f5c5SAndroid Build Coastguard Worker     return GetValidProgram(context, entryPoint, program) != nullptr;
4004*8975f5c5SAndroid Build Coastguard Worker }
4005*8975f5c5SAndroid Build Coastguard Worker 
ValidateBindFramebuffer(const Context * context,angle::EntryPoint entryPoint,GLenum target,FramebufferID framebuffer)4006*8975f5c5SAndroid Build Coastguard Worker bool ValidateBindFramebuffer(const Context *context,
4007*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
4008*8975f5c5SAndroid Build Coastguard Worker                              GLenum target,
4009*8975f5c5SAndroid Build Coastguard Worker                              FramebufferID framebuffer)
4010*8975f5c5SAndroid Build Coastguard Worker {
4011*8975f5c5SAndroid Build Coastguard Worker     return ValidateBindFramebufferBase(context, entryPoint, target, framebuffer);
4012*8975f5c5SAndroid Build Coastguard Worker }
4013*8975f5c5SAndroid Build Coastguard Worker 
ValidateBindRenderbuffer(const Context * context,angle::EntryPoint entryPoint,GLenum target,RenderbufferID renderbuffer)4014*8975f5c5SAndroid Build Coastguard Worker bool ValidateBindRenderbuffer(const Context *context,
4015*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
4016*8975f5c5SAndroid Build Coastguard Worker                               GLenum target,
4017*8975f5c5SAndroid Build Coastguard Worker                               RenderbufferID renderbuffer)
4018*8975f5c5SAndroid Build Coastguard Worker {
4019*8975f5c5SAndroid Build Coastguard Worker     return ValidateBindRenderbufferBase(context, entryPoint, target, renderbuffer);
4020*8975f5c5SAndroid Build Coastguard Worker }
4021*8975f5c5SAndroid Build Coastguard Worker 
ValidBlendEquationMode(const PrivateState & state,ErrorSet * errors,GLenum mode)4022*8975f5c5SAndroid Build Coastguard Worker static bool ValidBlendEquationMode(const PrivateState &state, ErrorSet *errors, GLenum mode)
4023*8975f5c5SAndroid Build Coastguard Worker {
4024*8975f5c5SAndroid Build Coastguard Worker     switch (mode)
4025*8975f5c5SAndroid Build Coastguard Worker     {
4026*8975f5c5SAndroid Build Coastguard Worker         case GL_FUNC_ADD:
4027*8975f5c5SAndroid Build Coastguard Worker         case GL_FUNC_SUBTRACT:
4028*8975f5c5SAndroid Build Coastguard Worker         case GL_FUNC_REVERSE_SUBTRACT:
4029*8975f5c5SAndroid Build Coastguard Worker             return true;
4030*8975f5c5SAndroid Build Coastguard Worker 
4031*8975f5c5SAndroid Build Coastguard Worker         case GL_MIN:
4032*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX:
4033*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() >= ES_3_0 || state.getExtensions().blendMinmaxEXT;
4034*8975f5c5SAndroid Build Coastguard Worker 
4035*8975f5c5SAndroid Build Coastguard Worker         default:
4036*8975f5c5SAndroid Build Coastguard Worker             return false;
4037*8975f5c5SAndroid Build Coastguard Worker     }
4038*8975f5c5SAndroid Build Coastguard Worker }
4039*8975f5c5SAndroid Build Coastguard Worker 
ValidAdvancedBlendEquationMode(const PrivateState & state,GLenum mode)4040*8975f5c5SAndroid Build Coastguard Worker static bool ValidAdvancedBlendEquationMode(const PrivateState &state, GLenum mode)
4041*8975f5c5SAndroid Build Coastguard Worker {
4042*8975f5c5SAndroid Build Coastguard Worker     switch (mode)
4043*8975f5c5SAndroid Build Coastguard Worker     {
4044*8975f5c5SAndroid Build Coastguard Worker         case GL_MULTIPLY_KHR:
4045*8975f5c5SAndroid Build Coastguard Worker         case GL_SCREEN_KHR:
4046*8975f5c5SAndroid Build Coastguard Worker         case GL_OVERLAY_KHR:
4047*8975f5c5SAndroid Build Coastguard Worker         case GL_DARKEN_KHR:
4048*8975f5c5SAndroid Build Coastguard Worker         case GL_LIGHTEN_KHR:
4049*8975f5c5SAndroid Build Coastguard Worker         case GL_COLORDODGE_KHR:
4050*8975f5c5SAndroid Build Coastguard Worker         case GL_COLORBURN_KHR:
4051*8975f5c5SAndroid Build Coastguard Worker         case GL_HARDLIGHT_KHR:
4052*8975f5c5SAndroid Build Coastguard Worker         case GL_SOFTLIGHT_KHR:
4053*8975f5c5SAndroid Build Coastguard Worker         case GL_DIFFERENCE_KHR:
4054*8975f5c5SAndroid Build Coastguard Worker         case GL_EXCLUSION_KHR:
4055*8975f5c5SAndroid Build Coastguard Worker         case GL_HSL_HUE_KHR:
4056*8975f5c5SAndroid Build Coastguard Worker         case GL_HSL_SATURATION_KHR:
4057*8975f5c5SAndroid Build Coastguard Worker         case GL_HSL_COLOR_KHR:
4058*8975f5c5SAndroid Build Coastguard Worker         case GL_HSL_LUMINOSITY_KHR:
4059*8975f5c5SAndroid Build Coastguard Worker             return state.getClientVersion() >= ES_3_2 ||
4060*8975f5c5SAndroid Build Coastguard Worker                    state.getExtensions().blendEquationAdvancedKHR;
4061*8975f5c5SAndroid Build Coastguard Worker 
4062*8975f5c5SAndroid Build Coastguard Worker         default:
4063*8975f5c5SAndroid Build Coastguard Worker             return false;
4064*8975f5c5SAndroid Build Coastguard Worker     }
4065*8975f5c5SAndroid Build Coastguard Worker }
4066*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlendColor(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)4067*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlendColor(const PrivateState &state,
4068*8975f5c5SAndroid Build Coastguard Worker                         ErrorSet *errors,
4069*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
4070*8975f5c5SAndroid Build Coastguard Worker                         GLfloat red,
4071*8975f5c5SAndroid Build Coastguard Worker                         GLfloat green,
4072*8975f5c5SAndroid Build Coastguard Worker                         GLfloat blue,
4073*8975f5c5SAndroid Build Coastguard Worker                         GLfloat alpha)
4074*8975f5c5SAndroid Build Coastguard Worker {
4075*8975f5c5SAndroid Build Coastguard Worker     return true;
4076*8975f5c5SAndroid Build Coastguard Worker }
4077*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlendEquation(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum mode)4078*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlendEquation(const PrivateState &state,
4079*8975f5c5SAndroid Build Coastguard Worker                            ErrorSet *errors,
4080*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
4081*8975f5c5SAndroid Build Coastguard Worker                            GLenum mode)
4082*8975f5c5SAndroid Build Coastguard Worker {
4083*8975f5c5SAndroid Build Coastguard Worker     if (ValidBlendEquationMode(state, errors, mode))
4084*8975f5c5SAndroid Build Coastguard Worker     {
4085*8975f5c5SAndroid Build Coastguard Worker         return true;
4086*8975f5c5SAndroid Build Coastguard Worker     }
4087*8975f5c5SAndroid Build Coastguard Worker 
4088*8975f5c5SAndroid Build Coastguard Worker     if (ValidAdvancedBlendEquationMode(state, mode))
4089*8975f5c5SAndroid Build Coastguard Worker     {
4090*8975f5c5SAndroid Build Coastguard Worker         if (state.getPixelLocalStorageActivePlanes() != 0)
4091*8975f5c5SAndroid Build Coastguard Worker         {
4092*8975f5c5SAndroid Build Coastguard Worker             // INVALID_OPERATION is generated by BlendEquation*() if <mode> is one of the advanced
4093*8975f5c5SAndroid Build Coastguard Worker             // blend equations defined in KHR_blend_equation_advanced.
4094*8975f5c5SAndroid Build Coastguard Worker             errors->validationError(entryPoint, GL_INVALID_OPERATION,
4095*8975f5c5SAndroid Build Coastguard Worker                                     kPLSAdvancedBlendNotSupported);
4096*8975f5c5SAndroid Build Coastguard Worker             return false;
4097*8975f5c5SAndroid Build Coastguard Worker         }
4098*8975f5c5SAndroid Build Coastguard Worker         return true;
4099*8975f5c5SAndroid Build Coastguard Worker     }
4100*8975f5c5SAndroid Build Coastguard Worker 
4101*8975f5c5SAndroid Build Coastguard Worker     errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidBlendEquation);
4102*8975f5c5SAndroid Build Coastguard Worker     return false;
4103*8975f5c5SAndroid Build Coastguard Worker }
4104*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlendEquationSeparate(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum modeRGB,GLenum modeAlpha)4105*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlendEquationSeparate(const PrivateState &state,
4106*8975f5c5SAndroid Build Coastguard Worker                                    ErrorSet *errors,
4107*8975f5c5SAndroid Build Coastguard Worker                                    angle::EntryPoint entryPoint,
4108*8975f5c5SAndroid Build Coastguard Worker                                    GLenum modeRGB,
4109*8975f5c5SAndroid Build Coastguard Worker                                    GLenum modeAlpha)
4110*8975f5c5SAndroid Build Coastguard Worker {
4111*8975f5c5SAndroid Build Coastguard Worker     if (!ValidBlendEquationMode(state, errors, modeRGB))
4112*8975f5c5SAndroid Build Coastguard Worker     {
4113*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidBlendEquation);
4114*8975f5c5SAndroid Build Coastguard Worker         return false;
4115*8975f5c5SAndroid Build Coastguard Worker     }
4116*8975f5c5SAndroid Build Coastguard Worker 
4117*8975f5c5SAndroid Build Coastguard Worker     if (!ValidBlendEquationMode(state, errors, modeAlpha))
4118*8975f5c5SAndroid Build Coastguard Worker     {
4119*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidBlendEquation);
4120*8975f5c5SAndroid Build Coastguard Worker         return false;
4121*8975f5c5SAndroid Build Coastguard Worker     }
4122*8975f5c5SAndroid Build Coastguard Worker 
4123*8975f5c5SAndroid Build Coastguard Worker     return true;
4124*8975f5c5SAndroid Build Coastguard Worker }
4125*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlendFunc(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum sfactor,GLenum dfactor)4126*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlendFunc(const PrivateState &state,
4127*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
4128*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4129*8975f5c5SAndroid Build Coastguard Worker                        GLenum sfactor,
4130*8975f5c5SAndroid Build Coastguard Worker                        GLenum dfactor)
4131*8975f5c5SAndroid Build Coastguard Worker {
4132*8975f5c5SAndroid Build Coastguard Worker     return ValidateBlendFuncSeparate(state, errors, entryPoint, sfactor, dfactor, sfactor, dfactor);
4133*8975f5c5SAndroid Build Coastguard Worker }
4134*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlendFuncSeparate(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)4135*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlendFuncSeparate(const PrivateState &state,
4136*8975f5c5SAndroid Build Coastguard Worker                                ErrorSet *errors,
4137*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
4138*8975f5c5SAndroid Build Coastguard Worker                                GLenum srcRGB,
4139*8975f5c5SAndroid Build Coastguard Worker                                GLenum dstRGB,
4140*8975f5c5SAndroid Build Coastguard Worker                                GLenum srcAlpha,
4141*8975f5c5SAndroid Build Coastguard Worker                                GLenum dstAlpha)
4142*8975f5c5SAndroid Build Coastguard Worker {
4143*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateSrcBlendFunc(state, errors, entryPoint, srcRGB) ||
4144*8975f5c5SAndroid Build Coastguard Worker         !ValidateDstBlendFunc(state, errors, entryPoint, dstRGB) ||
4145*8975f5c5SAndroid Build Coastguard Worker         !ValidateSrcBlendFunc(state, errors, entryPoint, srcAlpha) ||
4146*8975f5c5SAndroid Build Coastguard Worker         !ValidateDstBlendFunc(state, errors, entryPoint, dstAlpha))
4147*8975f5c5SAndroid Build Coastguard Worker     {
4148*8975f5c5SAndroid Build Coastguard Worker         return false;
4149*8975f5c5SAndroid Build Coastguard Worker     }
4150*8975f5c5SAndroid Build Coastguard Worker 
4151*8975f5c5SAndroid Build Coastguard Worker     if (state.getLimitations().noSimultaneousConstantColorAndAlphaBlendFunc || state.isWebGL())
4152*8975f5c5SAndroid Build Coastguard Worker     {
4153*8975f5c5SAndroid Build Coastguard Worker         bool constantColorUsed =
4154*8975f5c5SAndroid Build Coastguard Worker             (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
4155*8975f5c5SAndroid Build Coastguard Worker              dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
4156*8975f5c5SAndroid Build Coastguard Worker 
4157*8975f5c5SAndroid Build Coastguard Worker         bool constantAlphaUsed =
4158*8975f5c5SAndroid Build Coastguard Worker             (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
4159*8975f5c5SAndroid Build Coastguard Worker              dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
4160*8975f5c5SAndroid Build Coastguard Worker 
4161*8975f5c5SAndroid Build Coastguard Worker         if (constantColorUsed && constantAlphaUsed)
4162*8975f5c5SAndroid Build Coastguard Worker         {
4163*8975f5c5SAndroid Build Coastguard Worker             if (state.isWebGL())
4164*8975f5c5SAndroid Build Coastguard Worker             {
4165*8975f5c5SAndroid Build Coastguard Worker                 errors->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidConstantColor);
4166*8975f5c5SAndroid Build Coastguard Worker                 return false;
4167*8975f5c5SAndroid Build Coastguard Worker             }
4168*8975f5c5SAndroid Build Coastguard Worker 
4169*8975f5c5SAndroid Build Coastguard Worker             WARN() << kConstantColorAlphaLimitation;
4170*8975f5c5SAndroid Build Coastguard Worker             errors->validationError(entryPoint, GL_INVALID_OPERATION,
4171*8975f5c5SAndroid Build Coastguard Worker                                     kConstantColorAlphaLimitation);
4172*8975f5c5SAndroid Build Coastguard Worker             return false;
4173*8975f5c5SAndroid Build Coastguard Worker         }
4174*8975f5c5SAndroid Build Coastguard Worker     }
4175*8975f5c5SAndroid Build Coastguard Worker 
4176*8975f5c5SAndroid Build Coastguard Worker     return true;
4177*8975f5c5SAndroid Build Coastguard Worker }
4178*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetString(const Context * context,angle::EntryPoint entryPoint,GLenum name)4179*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetString(const Context *context, angle::EntryPoint entryPoint, GLenum name)
4180*8975f5c5SAndroid Build Coastguard Worker {
4181*8975f5c5SAndroid Build Coastguard Worker     switch (name)
4182*8975f5c5SAndroid Build Coastguard Worker     {
4183*8975f5c5SAndroid Build Coastguard Worker         case GL_VENDOR:
4184*8975f5c5SAndroid Build Coastguard Worker         case GL_RENDERER:
4185*8975f5c5SAndroid Build Coastguard Worker         case GL_VERSION:
4186*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADING_LANGUAGE_VERSION:
4187*8975f5c5SAndroid Build Coastguard Worker         case GL_EXTENSIONS:
4188*8975f5c5SAndroid Build Coastguard Worker             break;
4189*8975f5c5SAndroid Build Coastguard Worker 
4190*8975f5c5SAndroid Build Coastguard Worker         case GL_REQUESTABLE_EXTENSIONS_ANGLE:
4191*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().requestExtensionANGLE)
4192*8975f5c5SAndroid Build Coastguard Worker             {
4193*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidName);
4194*8975f5c5SAndroid Build Coastguard Worker                 return false;
4195*8975f5c5SAndroid Build Coastguard Worker             }
4196*8975f5c5SAndroid Build Coastguard Worker             break;
4197*8975f5c5SAndroid Build Coastguard Worker 
4198*8975f5c5SAndroid Build Coastguard Worker         case GL_SERIALIZED_CONTEXT_STRING_ANGLE:
4199*8975f5c5SAndroid Build Coastguard Worker             if (!context->getExtensions().getSerializedContextStringANGLE)
4200*8975f5c5SAndroid Build Coastguard Worker             {
4201*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidName);
4202*8975f5c5SAndroid Build Coastguard Worker                 return false;
4203*8975f5c5SAndroid Build Coastguard Worker             }
4204*8975f5c5SAndroid Build Coastguard Worker             break;
4205*8975f5c5SAndroid Build Coastguard Worker 
4206*8975f5c5SAndroid Build Coastguard Worker         default:
4207*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidName);
4208*8975f5c5SAndroid Build Coastguard Worker             return false;
4209*8975f5c5SAndroid Build Coastguard Worker     }
4210*8975f5c5SAndroid Build Coastguard Worker 
4211*8975f5c5SAndroid Build Coastguard Worker     return true;
4212*8975f5c5SAndroid Build Coastguard Worker }
4213*8975f5c5SAndroid Build Coastguard Worker 
ValidateLineWidth(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLfloat width)4214*8975f5c5SAndroid Build Coastguard Worker bool ValidateLineWidth(const PrivateState &state,
4215*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
4216*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4217*8975f5c5SAndroid Build Coastguard Worker                        GLfloat width)
4218*8975f5c5SAndroid Build Coastguard Worker {
4219*8975f5c5SAndroid Build Coastguard Worker     if (width <= 0.0f || isNaN(width))
4220*8975f5c5SAndroid Build Coastguard Worker     {
4221*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_VALUE, kInvalidWidth);
4222*8975f5c5SAndroid Build Coastguard Worker         return false;
4223*8975f5c5SAndroid Build Coastguard Worker     }
4224*8975f5c5SAndroid Build Coastguard Worker 
4225*8975f5c5SAndroid Build Coastguard Worker     return true;
4226*8975f5c5SAndroid Build Coastguard Worker }
4227*8975f5c5SAndroid Build Coastguard Worker 
ValidateDepthRangef(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLfloat zNear,GLfloat zFar)4228*8975f5c5SAndroid Build Coastguard Worker bool ValidateDepthRangef(const PrivateState &state,
4229*8975f5c5SAndroid Build Coastguard Worker                          ErrorSet *errors,
4230*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
4231*8975f5c5SAndroid Build Coastguard Worker                          GLfloat zNear,
4232*8975f5c5SAndroid Build Coastguard Worker                          GLfloat zFar)
4233*8975f5c5SAndroid Build Coastguard Worker {
4234*8975f5c5SAndroid Build Coastguard Worker     if (state.isWebGL() && zNear > zFar)
4235*8975f5c5SAndroid Build Coastguard Worker     {
4236*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidDepthRange);
4237*8975f5c5SAndroid Build Coastguard Worker         return false;
4238*8975f5c5SAndroid Build Coastguard Worker     }
4239*8975f5c5SAndroid Build Coastguard Worker 
4240*8975f5c5SAndroid Build Coastguard Worker     return true;
4241*8975f5c5SAndroid Build Coastguard Worker }
4242*8975f5c5SAndroid Build Coastguard Worker 
ValidateRenderbufferStorage(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum internalformat,GLsizei width,GLsizei height)4243*8975f5c5SAndroid Build Coastguard Worker bool ValidateRenderbufferStorage(const Context *context,
4244*8975f5c5SAndroid Build Coastguard Worker                                  angle::EntryPoint entryPoint,
4245*8975f5c5SAndroid Build Coastguard Worker                                  GLenum target,
4246*8975f5c5SAndroid Build Coastguard Worker                                  GLenum internalformat,
4247*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei width,
4248*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei height)
4249*8975f5c5SAndroid Build Coastguard Worker {
4250*8975f5c5SAndroid Build Coastguard Worker     return ValidateRenderbufferStorageParametersBase(context, entryPoint, target, 0, internalformat,
4251*8975f5c5SAndroid Build Coastguard Worker                                                      width, height);
4252*8975f5c5SAndroid Build Coastguard Worker }
4253*8975f5c5SAndroid Build Coastguard Worker 
ValidateRenderbufferStorageMultisampleANGLE(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height)4254*8975f5c5SAndroid Build Coastguard Worker bool ValidateRenderbufferStorageMultisampleANGLE(const Context *context,
4255*8975f5c5SAndroid Build Coastguard Worker                                                  angle::EntryPoint entryPoint,
4256*8975f5c5SAndroid Build Coastguard Worker                                                  GLenum target,
4257*8975f5c5SAndroid Build Coastguard Worker                                                  GLsizei samples,
4258*8975f5c5SAndroid Build Coastguard Worker                                                  GLenum internalformat,
4259*8975f5c5SAndroid Build Coastguard Worker                                                  GLsizei width,
4260*8975f5c5SAndroid Build Coastguard Worker                                                  GLsizei height)
4261*8975f5c5SAndroid Build Coastguard Worker {
4262*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().framebufferMultisampleANGLE)
4263*8975f5c5SAndroid Build Coastguard Worker     {
4264*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
4265*8975f5c5SAndroid Build Coastguard Worker         return false;
4266*8975f5c5SAndroid Build Coastguard Worker     }
4267*8975f5c5SAndroid Build Coastguard Worker 
4268*8975f5c5SAndroid Build Coastguard Worker     // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
4269*8975f5c5SAndroid Build Coastguard Worker     // to MAX_SAMPLES_ANGLE (Context::getCaps().maxSamples) otherwise GL_INVALID_VALUE is
4270*8975f5c5SAndroid Build Coastguard Worker     // generated.
4271*8975f5c5SAndroid Build Coastguard Worker     if (samples > context->getCaps().maxSamples)
4272*8975f5c5SAndroid Build Coastguard Worker     {
4273*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kSamplesOutOfRange);
4274*8975f5c5SAndroid Build Coastguard Worker         return false;
4275*8975f5c5SAndroid Build Coastguard Worker     }
4276*8975f5c5SAndroid Build Coastguard Worker 
4277*8975f5c5SAndroid Build Coastguard Worker     // ANGLE_framebuffer_multisample states GL_OUT_OF_MEMORY is generated on a failure to create
4278*8975f5c5SAndroid Build Coastguard Worker     // the specified storage. This is different than ES 3.0 in which a sample number higher
4279*8975f5c5SAndroid Build Coastguard Worker     // than the maximum sample number supported by this format generates a GL_INVALID_VALUE.
4280*8975f5c5SAndroid Build Coastguard Worker     // The TextureCaps::getMaxSamples method is only guarenteed to be valid when the context is ES3.
4281*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() >= 3)
4282*8975f5c5SAndroid Build Coastguard Worker     {
4283*8975f5c5SAndroid Build Coastguard Worker         const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
4284*8975f5c5SAndroid Build Coastguard Worker         if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
4285*8975f5c5SAndroid Build Coastguard Worker         {
4286*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_OUT_OF_MEMORY, kSamplesOutOfRange);
4287*8975f5c5SAndroid Build Coastguard Worker             return false;
4288*8975f5c5SAndroid Build Coastguard Worker         }
4289*8975f5c5SAndroid Build Coastguard Worker     }
4290*8975f5c5SAndroid Build Coastguard Worker 
4291*8975f5c5SAndroid Build Coastguard Worker     return ValidateRenderbufferStorageParametersBase(context, entryPoint, target, samples,
4292*8975f5c5SAndroid Build Coastguard Worker                                                      internalformat, width, height);
4293*8975f5c5SAndroid Build Coastguard Worker }
4294*8975f5c5SAndroid Build Coastguard Worker 
ValidateCheckFramebufferStatus(const Context * context,angle::EntryPoint entryPoint,GLenum target)4295*8975f5c5SAndroid Build Coastguard Worker bool ValidateCheckFramebufferStatus(const Context *context,
4296*8975f5c5SAndroid Build Coastguard Worker                                     angle::EntryPoint entryPoint,
4297*8975f5c5SAndroid Build Coastguard Worker                                     GLenum target)
4298*8975f5c5SAndroid Build Coastguard Worker {
4299*8975f5c5SAndroid Build Coastguard Worker     if (!ValidFramebufferTarget(context, target))
4300*8975f5c5SAndroid Build Coastguard Worker     {
4301*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFramebufferTarget);
4302*8975f5c5SAndroid Build Coastguard Worker         return false;
4303*8975f5c5SAndroid Build Coastguard Worker     }
4304*8975f5c5SAndroid Build Coastguard Worker 
4305*8975f5c5SAndroid Build Coastguard Worker     return true;
4306*8975f5c5SAndroid Build Coastguard Worker }
4307*8975f5c5SAndroid Build Coastguard Worker 
ValidateClearColor(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)4308*8975f5c5SAndroid Build Coastguard Worker bool ValidateClearColor(const PrivateState &state,
4309*8975f5c5SAndroid Build Coastguard Worker                         ErrorSet *errors,
4310*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
4311*8975f5c5SAndroid Build Coastguard Worker                         GLfloat red,
4312*8975f5c5SAndroid Build Coastguard Worker                         GLfloat green,
4313*8975f5c5SAndroid Build Coastguard Worker                         GLfloat blue,
4314*8975f5c5SAndroid Build Coastguard Worker                         GLfloat alpha)
4315*8975f5c5SAndroid Build Coastguard Worker {
4316*8975f5c5SAndroid Build Coastguard Worker     return true;
4317*8975f5c5SAndroid Build Coastguard Worker }
4318*8975f5c5SAndroid Build Coastguard Worker 
ValidateClearDepthf(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLfloat depth)4319*8975f5c5SAndroid Build Coastguard Worker bool ValidateClearDepthf(const PrivateState &state,
4320*8975f5c5SAndroid Build Coastguard Worker                          ErrorSet *errors,
4321*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
4322*8975f5c5SAndroid Build Coastguard Worker                          GLfloat depth)
4323*8975f5c5SAndroid Build Coastguard Worker {
4324*8975f5c5SAndroid Build Coastguard Worker     return true;
4325*8975f5c5SAndroid Build Coastguard Worker }
4326*8975f5c5SAndroid Build Coastguard Worker 
ValidateClearStencil(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLint s)4327*8975f5c5SAndroid Build Coastguard Worker bool ValidateClearStencil(const PrivateState &state,
4328*8975f5c5SAndroid Build Coastguard Worker                           ErrorSet *errors,
4329*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
4330*8975f5c5SAndroid Build Coastguard Worker                           GLint s)
4331*8975f5c5SAndroid Build Coastguard Worker {
4332*8975f5c5SAndroid Build Coastguard Worker     return true;
4333*8975f5c5SAndroid Build Coastguard Worker }
4334*8975f5c5SAndroid Build Coastguard Worker 
ValidateColorMask(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)4335*8975f5c5SAndroid Build Coastguard Worker bool ValidateColorMask(const PrivateState &state,
4336*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
4337*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4338*8975f5c5SAndroid Build Coastguard Worker                        GLboolean red,
4339*8975f5c5SAndroid Build Coastguard Worker                        GLboolean green,
4340*8975f5c5SAndroid Build Coastguard Worker                        GLboolean blue,
4341*8975f5c5SAndroid Build Coastguard Worker                        GLboolean alpha)
4342*8975f5c5SAndroid Build Coastguard Worker {
4343*8975f5c5SAndroid Build Coastguard Worker     return true;
4344*8975f5c5SAndroid Build Coastguard Worker }
4345*8975f5c5SAndroid Build Coastguard Worker 
ValidateCompileShader(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader)4346*8975f5c5SAndroid Build Coastguard Worker bool ValidateCompileShader(const Context *context,
4347*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
4348*8975f5c5SAndroid Build Coastguard Worker                            ShaderProgramID shader)
4349*8975f5c5SAndroid Build Coastguard Worker {
4350*8975f5c5SAndroid Build Coastguard Worker     return true;
4351*8975f5c5SAndroid Build Coastguard Worker }
4352*8975f5c5SAndroid Build Coastguard Worker 
ValidateCreateProgram(const Context * context,angle::EntryPoint entryPoint)4353*8975f5c5SAndroid Build Coastguard Worker bool ValidateCreateProgram(const Context *context, angle::EntryPoint entryPoint)
4354*8975f5c5SAndroid Build Coastguard Worker {
4355*8975f5c5SAndroid Build Coastguard Worker     return true;
4356*8975f5c5SAndroid Build Coastguard Worker }
4357*8975f5c5SAndroid Build Coastguard Worker 
ValidateCullFace(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,CullFaceMode mode)4358*8975f5c5SAndroid Build Coastguard Worker bool ValidateCullFace(const PrivateState &state,
4359*8975f5c5SAndroid Build Coastguard Worker                       ErrorSet *errors,
4360*8975f5c5SAndroid Build Coastguard Worker                       angle::EntryPoint entryPoint,
4361*8975f5c5SAndroid Build Coastguard Worker                       CullFaceMode mode)
4362*8975f5c5SAndroid Build Coastguard Worker {
4363*8975f5c5SAndroid Build Coastguard Worker     switch (mode)
4364*8975f5c5SAndroid Build Coastguard Worker     {
4365*8975f5c5SAndroid Build Coastguard Worker         case CullFaceMode::Front:
4366*8975f5c5SAndroid Build Coastguard Worker         case CullFaceMode::Back:
4367*8975f5c5SAndroid Build Coastguard Worker         case CullFaceMode::FrontAndBack:
4368*8975f5c5SAndroid Build Coastguard Worker             break;
4369*8975f5c5SAndroid Build Coastguard Worker 
4370*8975f5c5SAndroid Build Coastguard Worker         default:
4371*8975f5c5SAndroid Build Coastguard Worker             errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidCullMode);
4372*8975f5c5SAndroid Build Coastguard Worker             return false;
4373*8975f5c5SAndroid Build Coastguard Worker     }
4374*8975f5c5SAndroid Build Coastguard Worker 
4375*8975f5c5SAndroid Build Coastguard Worker     return true;
4376*8975f5c5SAndroid Build Coastguard Worker }
4377*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteProgram(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program)4378*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteProgram(const Context *context,
4379*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
4380*8975f5c5SAndroid Build Coastguard Worker                            ShaderProgramID program)
4381*8975f5c5SAndroid Build Coastguard Worker {
4382*8975f5c5SAndroid Build Coastguard Worker     if (program.value == 0)
4383*8975f5c5SAndroid Build Coastguard Worker     {
4384*8975f5c5SAndroid Build Coastguard Worker         return false;
4385*8975f5c5SAndroid Build Coastguard Worker     }
4386*8975f5c5SAndroid Build Coastguard Worker 
4387*8975f5c5SAndroid Build Coastguard Worker     if (!context->getProgramResolveLink(program))
4388*8975f5c5SAndroid Build Coastguard Worker     {
4389*8975f5c5SAndroid Build Coastguard Worker         if (context->getShaderNoResolveCompile(program))
4390*8975f5c5SAndroid Build Coastguard Worker         {
4391*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExpectedProgramName);
4392*8975f5c5SAndroid Build Coastguard Worker             return false;
4393*8975f5c5SAndroid Build Coastguard Worker         }
4394*8975f5c5SAndroid Build Coastguard Worker         else
4395*8975f5c5SAndroid Build Coastguard Worker         {
4396*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidProgramName);
4397*8975f5c5SAndroid Build Coastguard Worker             return false;
4398*8975f5c5SAndroid Build Coastguard Worker         }
4399*8975f5c5SAndroid Build Coastguard Worker     }
4400*8975f5c5SAndroid Build Coastguard Worker 
4401*8975f5c5SAndroid Build Coastguard Worker     return true;
4402*8975f5c5SAndroid Build Coastguard Worker }
4403*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteShader(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader)4404*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteShader(const Context *context,
4405*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
4406*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID shader)
4407*8975f5c5SAndroid Build Coastguard Worker {
4408*8975f5c5SAndroid Build Coastguard Worker     if (shader.value == 0)
4409*8975f5c5SAndroid Build Coastguard Worker     {
4410*8975f5c5SAndroid Build Coastguard Worker         return false;
4411*8975f5c5SAndroid Build Coastguard Worker     }
4412*8975f5c5SAndroid Build Coastguard Worker 
4413*8975f5c5SAndroid Build Coastguard Worker     if (!context->getShaderNoResolveCompile(shader))
4414*8975f5c5SAndroid Build Coastguard Worker     {
4415*8975f5c5SAndroid Build Coastguard Worker         if (context->getProgramResolveLink(shader))
4416*8975f5c5SAndroid Build Coastguard Worker         {
4417*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidShaderName);
4418*8975f5c5SAndroid Build Coastguard Worker             return false;
4419*8975f5c5SAndroid Build Coastguard Worker         }
4420*8975f5c5SAndroid Build Coastguard Worker         else
4421*8975f5c5SAndroid Build Coastguard Worker         {
4422*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kExpectedShaderName);
4423*8975f5c5SAndroid Build Coastguard Worker             return false;
4424*8975f5c5SAndroid Build Coastguard Worker         }
4425*8975f5c5SAndroid Build Coastguard Worker     }
4426*8975f5c5SAndroid Build Coastguard Worker 
4427*8975f5c5SAndroid Build Coastguard Worker     return true;
4428*8975f5c5SAndroid Build Coastguard Worker }
4429*8975f5c5SAndroid Build Coastguard Worker 
ValidateDepthFunc(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum func)4430*8975f5c5SAndroid Build Coastguard Worker bool ValidateDepthFunc(const PrivateState &state,
4431*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
4432*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4433*8975f5c5SAndroid Build Coastguard Worker                        GLenum func)
4434*8975f5c5SAndroid Build Coastguard Worker {
4435*8975f5c5SAndroid Build Coastguard Worker     switch (func)
4436*8975f5c5SAndroid Build Coastguard Worker     {
4437*8975f5c5SAndroid Build Coastguard Worker         case GL_NEVER:
4438*8975f5c5SAndroid Build Coastguard Worker         case GL_ALWAYS:
4439*8975f5c5SAndroid Build Coastguard Worker         case GL_LESS:
4440*8975f5c5SAndroid Build Coastguard Worker         case GL_LEQUAL:
4441*8975f5c5SAndroid Build Coastguard Worker         case GL_EQUAL:
4442*8975f5c5SAndroid Build Coastguard Worker         case GL_GREATER:
4443*8975f5c5SAndroid Build Coastguard Worker         case GL_GEQUAL:
4444*8975f5c5SAndroid Build Coastguard Worker         case GL_NOTEQUAL:
4445*8975f5c5SAndroid Build Coastguard Worker             break;
4446*8975f5c5SAndroid Build Coastguard Worker 
4447*8975f5c5SAndroid Build Coastguard Worker         default:
4448*8975f5c5SAndroid Build Coastguard Worker             errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, func);
4449*8975f5c5SAndroid Build Coastguard Worker             return false;
4450*8975f5c5SAndroid Build Coastguard Worker     }
4451*8975f5c5SAndroid Build Coastguard Worker 
4452*8975f5c5SAndroid Build Coastguard Worker     return true;
4453*8975f5c5SAndroid Build Coastguard Worker }
4454*8975f5c5SAndroid Build Coastguard Worker 
ValidateDepthMask(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLboolean flag)4455*8975f5c5SAndroid Build Coastguard Worker bool ValidateDepthMask(const PrivateState &state,
4456*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
4457*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4458*8975f5c5SAndroid Build Coastguard Worker                        GLboolean flag)
4459*8975f5c5SAndroid Build Coastguard Worker {
4460*8975f5c5SAndroid Build Coastguard Worker     return true;
4461*8975f5c5SAndroid Build Coastguard Worker }
4462*8975f5c5SAndroid Build Coastguard Worker 
ValidateDetachShader(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,ShaderProgramID shader)4463*8975f5c5SAndroid Build Coastguard Worker bool ValidateDetachShader(const Context *context,
4464*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
4465*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID program,
4466*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID shader)
4467*8975f5c5SAndroid Build Coastguard Worker {
4468*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
4469*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
4470*8975f5c5SAndroid Build Coastguard Worker     {
4471*8975f5c5SAndroid Build Coastguard Worker         return false;
4472*8975f5c5SAndroid Build Coastguard Worker     }
4473*8975f5c5SAndroid Build Coastguard Worker 
4474*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = GetValidShader(context, entryPoint, shader);
4475*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
4476*8975f5c5SAndroid Build Coastguard Worker     {
4477*8975f5c5SAndroid Build Coastguard Worker         return false;
4478*8975f5c5SAndroid Build Coastguard Worker     }
4479*8975f5c5SAndroid Build Coastguard Worker 
4480*8975f5c5SAndroid Build Coastguard Worker     const Shader *attachedShader = programObject->getAttachedShader(shaderObject->getType());
4481*8975f5c5SAndroid Build Coastguard Worker     if (attachedShader != shaderObject)
4482*8975f5c5SAndroid Build Coastguard Worker     {
4483*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kShaderToDetachMustBeAttached);
4484*8975f5c5SAndroid Build Coastguard Worker         return false;
4485*8975f5c5SAndroid Build Coastguard Worker     }
4486*8975f5c5SAndroid Build Coastguard Worker 
4487*8975f5c5SAndroid Build Coastguard Worker     return true;
4488*8975f5c5SAndroid Build Coastguard Worker }
4489*8975f5c5SAndroid Build Coastguard Worker 
ValidateDisableVertexAttribArray(const Context * context,angle::EntryPoint entryPoint,GLuint index)4490*8975f5c5SAndroid Build Coastguard Worker bool ValidateDisableVertexAttribArray(const Context *context,
4491*8975f5c5SAndroid Build Coastguard Worker                                       angle::EntryPoint entryPoint,
4492*8975f5c5SAndroid Build Coastguard Worker                                       GLuint index)
4493*8975f5c5SAndroid Build Coastguard Worker {
4494*8975f5c5SAndroid Build Coastguard Worker     if (index >= static_cast<GLuint>(context->getCaps().maxVertexAttributes))
4495*8975f5c5SAndroid Build Coastguard Worker     {
4496*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute);
4497*8975f5c5SAndroid Build Coastguard Worker         return false;
4498*8975f5c5SAndroid Build Coastguard Worker     }
4499*8975f5c5SAndroid Build Coastguard Worker 
4500*8975f5c5SAndroid Build Coastguard Worker     return true;
4501*8975f5c5SAndroid Build Coastguard Worker }
4502*8975f5c5SAndroid Build Coastguard Worker 
ValidateEnableVertexAttribArray(const Context * context,angle::EntryPoint entryPoint,GLuint index)4503*8975f5c5SAndroid Build Coastguard Worker bool ValidateEnableVertexAttribArray(const Context *context,
4504*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
4505*8975f5c5SAndroid Build Coastguard Worker                                      GLuint index)
4506*8975f5c5SAndroid Build Coastguard Worker {
4507*8975f5c5SAndroid Build Coastguard Worker     if (index >= static_cast<GLuint>(context->getCaps().maxVertexAttributes))
4508*8975f5c5SAndroid Build Coastguard Worker     {
4509*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute);
4510*8975f5c5SAndroid Build Coastguard Worker         return false;
4511*8975f5c5SAndroid Build Coastguard Worker     }
4512*8975f5c5SAndroid Build Coastguard Worker 
4513*8975f5c5SAndroid Build Coastguard Worker     return true;
4514*8975f5c5SAndroid Build Coastguard Worker }
4515*8975f5c5SAndroid Build Coastguard Worker 
ValidateFinish(const Context * context,angle::EntryPoint entryPoint)4516*8975f5c5SAndroid Build Coastguard Worker bool ValidateFinish(const Context *context, angle::EntryPoint entryPoint)
4517*8975f5c5SAndroid Build Coastguard Worker {
4518*8975f5c5SAndroid Build Coastguard Worker     return true;
4519*8975f5c5SAndroid Build Coastguard Worker }
4520*8975f5c5SAndroid Build Coastguard Worker 
ValidateFlush(const Context * context,angle::EntryPoint entryPoint)4521*8975f5c5SAndroid Build Coastguard Worker bool ValidateFlush(const Context *context, angle::EntryPoint entryPoint)
4522*8975f5c5SAndroid Build Coastguard Worker {
4523*8975f5c5SAndroid Build Coastguard Worker     return true;
4524*8975f5c5SAndroid Build Coastguard Worker }
4525*8975f5c5SAndroid Build Coastguard Worker 
ValidateFrontFace(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum mode)4526*8975f5c5SAndroid Build Coastguard Worker bool ValidateFrontFace(const PrivateState &state,
4527*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
4528*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4529*8975f5c5SAndroid Build Coastguard Worker                        GLenum mode)
4530*8975f5c5SAndroid Build Coastguard Worker {
4531*8975f5c5SAndroid Build Coastguard Worker     switch (mode)
4532*8975f5c5SAndroid Build Coastguard Worker     {
4533*8975f5c5SAndroid Build Coastguard Worker         case GL_CW:
4534*8975f5c5SAndroid Build Coastguard Worker         case GL_CCW:
4535*8975f5c5SAndroid Build Coastguard Worker             break;
4536*8975f5c5SAndroid Build Coastguard Worker         default:
4537*8975f5c5SAndroid Build Coastguard Worker             errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, mode);
4538*8975f5c5SAndroid Build Coastguard Worker             return false;
4539*8975f5c5SAndroid Build Coastguard Worker     }
4540*8975f5c5SAndroid Build Coastguard Worker 
4541*8975f5c5SAndroid Build Coastguard Worker     return true;
4542*8975f5c5SAndroid Build Coastguard Worker }
4543*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetActiveAttrib(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLuint index,GLsizei bufsize,const GLsizei * length,const GLint * size,const GLenum * type,const GLchar * name)4544*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetActiveAttrib(const Context *context,
4545*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
4546*8975f5c5SAndroid Build Coastguard Worker                              ShaderProgramID program,
4547*8975f5c5SAndroid Build Coastguard Worker                              GLuint index,
4548*8975f5c5SAndroid Build Coastguard Worker                              GLsizei bufsize,
4549*8975f5c5SAndroid Build Coastguard Worker                              const GLsizei *length,
4550*8975f5c5SAndroid Build Coastguard Worker                              const GLint *size,
4551*8975f5c5SAndroid Build Coastguard Worker                              const GLenum *type,
4552*8975f5c5SAndroid Build Coastguard Worker                              const GLchar *name)
4553*8975f5c5SAndroid Build Coastguard Worker {
4554*8975f5c5SAndroid Build Coastguard Worker     if (bufsize < 0)
4555*8975f5c5SAndroid Build Coastguard Worker     {
4556*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
4557*8975f5c5SAndroid Build Coastguard Worker         return false;
4558*8975f5c5SAndroid Build Coastguard Worker     }
4559*8975f5c5SAndroid Build Coastguard Worker 
4560*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
4561*8975f5c5SAndroid Build Coastguard Worker 
4562*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
4563*8975f5c5SAndroid Build Coastguard Worker     {
4564*8975f5c5SAndroid Build Coastguard Worker         return false;
4565*8975f5c5SAndroid Build Coastguard Worker     }
4566*8975f5c5SAndroid Build Coastguard Worker 
4567*8975f5c5SAndroid Build Coastguard Worker     if (index >= static_cast<GLuint>(programObject->getExecutable().getProgramInputs().size()))
4568*8975f5c5SAndroid Build Coastguard Worker     {
4569*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kIndexExceedsMaxActiveUniform);
4570*8975f5c5SAndroid Build Coastguard Worker         return false;
4571*8975f5c5SAndroid Build Coastguard Worker     }
4572*8975f5c5SAndroid Build Coastguard Worker 
4573*8975f5c5SAndroid Build Coastguard Worker     return true;
4574*8975f5c5SAndroid Build Coastguard Worker }
4575*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetActiveUniform(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLuint index,GLsizei bufsize,const GLsizei * length,const GLint * size,const GLenum * type,const GLchar * name)4576*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetActiveUniform(const Context *context,
4577*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
4578*8975f5c5SAndroid Build Coastguard Worker                               ShaderProgramID program,
4579*8975f5c5SAndroid Build Coastguard Worker                               GLuint index,
4580*8975f5c5SAndroid Build Coastguard Worker                               GLsizei bufsize,
4581*8975f5c5SAndroid Build Coastguard Worker                               const GLsizei *length,
4582*8975f5c5SAndroid Build Coastguard Worker                               const GLint *size,
4583*8975f5c5SAndroid Build Coastguard Worker                               const GLenum *type,
4584*8975f5c5SAndroid Build Coastguard Worker                               const GLchar *name)
4585*8975f5c5SAndroid Build Coastguard Worker {
4586*8975f5c5SAndroid Build Coastguard Worker     if (bufsize < 0)
4587*8975f5c5SAndroid Build Coastguard Worker     {
4588*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
4589*8975f5c5SAndroid Build Coastguard Worker         return false;
4590*8975f5c5SAndroid Build Coastguard Worker     }
4591*8975f5c5SAndroid Build Coastguard Worker 
4592*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
4593*8975f5c5SAndroid Build Coastguard Worker 
4594*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
4595*8975f5c5SAndroid Build Coastguard Worker     {
4596*8975f5c5SAndroid Build Coastguard Worker         return false;
4597*8975f5c5SAndroid Build Coastguard Worker     }
4598*8975f5c5SAndroid Build Coastguard Worker 
4599*8975f5c5SAndroid Build Coastguard Worker     if (index >= programObject->getExecutable().getUniforms().size())
4600*8975f5c5SAndroid Build Coastguard Worker     {
4601*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kIndexExceedsMaxActiveUniform);
4602*8975f5c5SAndroid Build Coastguard Worker         return false;
4603*8975f5c5SAndroid Build Coastguard Worker     }
4604*8975f5c5SAndroid Build Coastguard Worker 
4605*8975f5c5SAndroid Build Coastguard Worker     return true;
4606*8975f5c5SAndroid Build Coastguard Worker }
4607*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetAttachedShaders(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLsizei maxcount,const GLsizei * count,const ShaderProgramID * shaders)4608*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetAttachedShaders(const Context *context,
4609*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
4610*8975f5c5SAndroid Build Coastguard Worker                                 ShaderProgramID program,
4611*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei maxcount,
4612*8975f5c5SAndroid Build Coastguard Worker                                 const GLsizei *count,
4613*8975f5c5SAndroid Build Coastguard Worker                                 const ShaderProgramID *shaders)
4614*8975f5c5SAndroid Build Coastguard Worker {
4615*8975f5c5SAndroid Build Coastguard Worker     if (maxcount < 0)
4616*8975f5c5SAndroid Build Coastguard Worker     {
4617*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeMaxCount);
4618*8975f5c5SAndroid Build Coastguard Worker         return false;
4619*8975f5c5SAndroid Build Coastguard Worker     }
4620*8975f5c5SAndroid Build Coastguard Worker 
4621*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
4622*8975f5c5SAndroid Build Coastguard Worker 
4623*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
4624*8975f5c5SAndroid Build Coastguard Worker     {
4625*8975f5c5SAndroid Build Coastguard Worker         return false;
4626*8975f5c5SAndroid Build Coastguard Worker     }
4627*8975f5c5SAndroid Build Coastguard Worker 
4628*8975f5c5SAndroid Build Coastguard Worker     return true;
4629*8975f5c5SAndroid Build Coastguard Worker }
4630*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetAttribLocation(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,const GLchar * name)4631*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetAttribLocation(const Context *context,
4632*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
4633*8975f5c5SAndroid Build Coastguard Worker                                ShaderProgramID program,
4634*8975f5c5SAndroid Build Coastguard Worker                                const GLchar *name)
4635*8975f5c5SAndroid Build Coastguard Worker {
4636*8975f5c5SAndroid Build Coastguard Worker     if (strncmp(name, "gl_", 3) == 0)
4637*8975f5c5SAndroid Build Coastguard Worker     {
4638*8975f5c5SAndroid Build Coastguard Worker         return false;
4639*8975f5c5SAndroid Build Coastguard Worker     }
4640*8975f5c5SAndroid Build Coastguard Worker 
4641*8975f5c5SAndroid Build Coastguard Worker     if (context->isWebGL())
4642*8975f5c5SAndroid Build Coastguard Worker     {
4643*8975f5c5SAndroid Build Coastguard Worker         const size_t length = strlen(name);
4644*8975f5c5SAndroid Build Coastguard Worker 
4645*8975f5c5SAndroid Build Coastguard Worker         if (!IsValidESSLString(name, length))
4646*8975f5c5SAndroid Build Coastguard Worker         {
4647*8975f5c5SAndroid Build Coastguard Worker             // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters
4648*8975f5c5SAndroid Build Coastguard Worker             // for shader-related entry points
4649*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidNameCharacters);
4650*8975f5c5SAndroid Build Coastguard Worker             return false;
4651*8975f5c5SAndroid Build Coastguard Worker         }
4652*8975f5c5SAndroid Build Coastguard Worker 
4653*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateWebGLNameLength(context, entryPoint, length) ||
4654*8975f5c5SAndroid Build Coastguard Worker             strncmp(name, "webgl_", 6) == 0 || strncmp(name, "_webgl_", 7) == 0)
4655*8975f5c5SAndroid Build Coastguard Worker         {
4656*8975f5c5SAndroid Build Coastguard Worker             return false;
4657*8975f5c5SAndroid Build Coastguard Worker         }
4658*8975f5c5SAndroid Build Coastguard Worker     }
4659*8975f5c5SAndroid Build Coastguard Worker 
4660*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
4661*8975f5c5SAndroid Build Coastguard Worker 
4662*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
4663*8975f5c5SAndroid Build Coastguard Worker     {
4664*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kProgramNotBound);
4665*8975f5c5SAndroid Build Coastguard Worker         return false;
4666*8975f5c5SAndroid Build Coastguard Worker     }
4667*8975f5c5SAndroid Build Coastguard Worker 
4668*8975f5c5SAndroid Build Coastguard Worker     if (!programObject->isLinked())
4669*8975f5c5SAndroid Build Coastguard Worker     {
4670*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kProgramNotLinked);
4671*8975f5c5SAndroid Build Coastguard Worker         return false;
4672*8975f5c5SAndroid Build Coastguard Worker     }
4673*8975f5c5SAndroid Build Coastguard Worker 
4674*8975f5c5SAndroid Build Coastguard Worker     return true;
4675*8975f5c5SAndroid Build Coastguard Worker }
4676*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetBooleanv(const Context * context,angle::EntryPoint entryPoint,GLenum pname,const GLboolean * params)4677*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetBooleanv(const Context *context,
4678*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
4679*8975f5c5SAndroid Build Coastguard Worker                          GLenum pname,
4680*8975f5c5SAndroid Build Coastguard Worker                          const GLboolean *params)
4681*8975f5c5SAndroid Build Coastguard Worker {
4682*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
4683*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams = 0;
4684*8975f5c5SAndroid Build Coastguard Worker     return ValidateStateQuery(context, entryPoint, pname, &nativeType, &numParams);
4685*8975f5c5SAndroid Build Coastguard Worker }
4686*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetError(const Context * context,angle::EntryPoint entryPoint)4687*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetError(const Context *context, angle::EntryPoint entryPoint)
4688*8975f5c5SAndroid Build Coastguard Worker {
4689*8975f5c5SAndroid Build Coastguard Worker     return true;
4690*8975f5c5SAndroid Build Coastguard Worker }
4691*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetFloatv(const Context * context,angle::EntryPoint entryPoint,GLenum pname,const GLfloat * params)4692*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetFloatv(const Context *context,
4693*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4694*8975f5c5SAndroid Build Coastguard Worker                        GLenum pname,
4695*8975f5c5SAndroid Build Coastguard Worker                        const GLfloat *params)
4696*8975f5c5SAndroid Build Coastguard Worker {
4697*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
4698*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams = 0;
4699*8975f5c5SAndroid Build Coastguard Worker     return ValidateStateQuery(context, entryPoint, pname, &nativeType, &numParams);
4700*8975f5c5SAndroid Build Coastguard Worker }
4701*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetIntegerv(const Context * context,angle::EntryPoint entryPoint,GLenum pname,const GLint * params)4702*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetIntegerv(const Context *context,
4703*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
4704*8975f5c5SAndroid Build Coastguard Worker                          GLenum pname,
4705*8975f5c5SAndroid Build Coastguard Worker                          const GLint *params)
4706*8975f5c5SAndroid Build Coastguard Worker {
4707*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
4708*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams = 0;
4709*8975f5c5SAndroid Build Coastguard Worker     return ValidateStateQuery(context, entryPoint, pname, &nativeType, &numParams);
4710*8975f5c5SAndroid Build Coastguard Worker }
4711*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetProgramInfoLog(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLsizei bufsize,const GLsizei * length,const GLchar * infolog)4712*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetProgramInfoLog(const Context *context,
4713*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
4714*8975f5c5SAndroid Build Coastguard Worker                                ShaderProgramID program,
4715*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufsize,
4716*8975f5c5SAndroid Build Coastguard Worker                                const GLsizei *length,
4717*8975f5c5SAndroid Build Coastguard Worker                                const GLchar *infolog)
4718*8975f5c5SAndroid Build Coastguard Worker {
4719*8975f5c5SAndroid Build Coastguard Worker     if (bufsize < 0)
4720*8975f5c5SAndroid Build Coastguard Worker     {
4721*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
4722*8975f5c5SAndroid Build Coastguard Worker         return false;
4723*8975f5c5SAndroid Build Coastguard Worker     }
4724*8975f5c5SAndroid Build Coastguard Worker 
4725*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
4726*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
4727*8975f5c5SAndroid Build Coastguard Worker     {
4728*8975f5c5SAndroid Build Coastguard Worker         return false;
4729*8975f5c5SAndroid Build Coastguard Worker     }
4730*8975f5c5SAndroid Build Coastguard Worker 
4731*8975f5c5SAndroid Build Coastguard Worker     return true;
4732*8975f5c5SAndroid Build Coastguard Worker }
4733*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetShaderInfoLog(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader,GLsizei bufsize,const GLsizei * length,const GLchar * infolog)4734*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetShaderInfoLog(const Context *context,
4735*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
4736*8975f5c5SAndroid Build Coastguard Worker                               ShaderProgramID shader,
4737*8975f5c5SAndroid Build Coastguard Worker                               GLsizei bufsize,
4738*8975f5c5SAndroid Build Coastguard Worker                               const GLsizei *length,
4739*8975f5c5SAndroid Build Coastguard Worker                               const GLchar *infolog)
4740*8975f5c5SAndroid Build Coastguard Worker {
4741*8975f5c5SAndroid Build Coastguard Worker     if (bufsize < 0)
4742*8975f5c5SAndroid Build Coastguard Worker     {
4743*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
4744*8975f5c5SAndroid Build Coastguard Worker         return false;
4745*8975f5c5SAndroid Build Coastguard Worker     }
4746*8975f5c5SAndroid Build Coastguard Worker 
4747*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = GetValidShader(context, entryPoint, shader);
4748*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
4749*8975f5c5SAndroid Build Coastguard Worker     {
4750*8975f5c5SAndroid Build Coastguard Worker         return false;
4751*8975f5c5SAndroid Build Coastguard Worker     }
4752*8975f5c5SAndroid Build Coastguard Worker 
4753*8975f5c5SAndroid Build Coastguard Worker     return true;
4754*8975f5c5SAndroid Build Coastguard Worker }
4755*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetShaderPrecisionFormat(const Context * context,angle::EntryPoint entryPoint,GLenum shadertype,GLenum precisiontype,const GLint * range,const GLint * precision)4756*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetShaderPrecisionFormat(const Context *context,
4757*8975f5c5SAndroid Build Coastguard Worker                                       angle::EntryPoint entryPoint,
4758*8975f5c5SAndroid Build Coastguard Worker                                       GLenum shadertype,
4759*8975f5c5SAndroid Build Coastguard Worker                                       GLenum precisiontype,
4760*8975f5c5SAndroid Build Coastguard Worker                                       const GLint *range,
4761*8975f5c5SAndroid Build Coastguard Worker                                       const GLint *precision)
4762*8975f5c5SAndroid Build Coastguard Worker {
4763*8975f5c5SAndroid Build Coastguard Worker     switch (shadertype)
4764*8975f5c5SAndroid Build Coastguard Worker     {
4765*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_SHADER:
4766*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAGMENT_SHADER:
4767*8975f5c5SAndroid Build Coastguard Worker             break;
4768*8975f5c5SAndroid Build Coastguard Worker         case GL_COMPUTE_SHADER:
4769*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kUnimplementedComputeShaderPrecision);
4770*8975f5c5SAndroid Build Coastguard Worker             return false;
4771*8975f5c5SAndroid Build Coastguard Worker         default:
4772*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidShaderType);
4773*8975f5c5SAndroid Build Coastguard Worker             return false;
4774*8975f5c5SAndroid Build Coastguard Worker     }
4775*8975f5c5SAndroid Build Coastguard Worker 
4776*8975f5c5SAndroid Build Coastguard Worker     switch (precisiontype)
4777*8975f5c5SAndroid Build Coastguard Worker     {
4778*8975f5c5SAndroid Build Coastguard Worker         case GL_LOW_FLOAT:
4779*8975f5c5SAndroid Build Coastguard Worker         case GL_MEDIUM_FLOAT:
4780*8975f5c5SAndroid Build Coastguard Worker         case GL_HIGH_FLOAT:
4781*8975f5c5SAndroid Build Coastguard Worker         case GL_LOW_INT:
4782*8975f5c5SAndroid Build Coastguard Worker         case GL_MEDIUM_INT:
4783*8975f5c5SAndroid Build Coastguard Worker         case GL_HIGH_INT:
4784*8975f5c5SAndroid Build Coastguard Worker             break;
4785*8975f5c5SAndroid Build Coastguard Worker 
4786*8975f5c5SAndroid Build Coastguard Worker         default:
4787*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidPrecision);
4788*8975f5c5SAndroid Build Coastguard Worker             return false;
4789*8975f5c5SAndroid Build Coastguard Worker     }
4790*8975f5c5SAndroid Build Coastguard Worker 
4791*8975f5c5SAndroid Build Coastguard Worker     return true;
4792*8975f5c5SAndroid Build Coastguard Worker }
4793*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetShaderSource(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader,GLsizei bufsize,const GLsizei * length,const GLchar * source)4794*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetShaderSource(const Context *context,
4795*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
4796*8975f5c5SAndroid Build Coastguard Worker                              ShaderProgramID shader,
4797*8975f5c5SAndroid Build Coastguard Worker                              GLsizei bufsize,
4798*8975f5c5SAndroid Build Coastguard Worker                              const GLsizei *length,
4799*8975f5c5SAndroid Build Coastguard Worker                              const GLchar *source)
4800*8975f5c5SAndroid Build Coastguard Worker {
4801*8975f5c5SAndroid Build Coastguard Worker     if (bufsize < 0)
4802*8975f5c5SAndroid Build Coastguard Worker     {
4803*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
4804*8975f5c5SAndroid Build Coastguard Worker         return false;
4805*8975f5c5SAndroid Build Coastguard Worker     }
4806*8975f5c5SAndroid Build Coastguard Worker 
4807*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = GetValidShader(context, entryPoint, shader);
4808*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
4809*8975f5c5SAndroid Build Coastguard Worker     {
4810*8975f5c5SAndroid Build Coastguard Worker         return false;
4811*8975f5c5SAndroid Build Coastguard Worker     }
4812*8975f5c5SAndroid Build Coastguard Worker 
4813*8975f5c5SAndroid Build Coastguard Worker     return true;
4814*8975f5c5SAndroid Build Coastguard Worker }
4815*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetUniformLocation(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,const GLchar * name)4816*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetUniformLocation(const Context *context,
4817*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
4818*8975f5c5SAndroid Build Coastguard Worker                                 ShaderProgramID program,
4819*8975f5c5SAndroid Build Coastguard Worker                                 const GLchar *name)
4820*8975f5c5SAndroid Build Coastguard Worker {
4821*8975f5c5SAndroid Build Coastguard Worker     if (strstr(name, "gl_") == name)
4822*8975f5c5SAndroid Build Coastguard Worker     {
4823*8975f5c5SAndroid Build Coastguard Worker         return false;
4824*8975f5c5SAndroid Build Coastguard Worker     }
4825*8975f5c5SAndroid Build Coastguard Worker 
4826*8975f5c5SAndroid Build Coastguard Worker     // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters for
4827*8975f5c5SAndroid Build Coastguard Worker     // shader-related entry points
4828*8975f5c5SAndroid Build Coastguard Worker     if (context->isWebGL() && !IsValidESSLString(name, strlen(name)))
4829*8975f5c5SAndroid Build Coastguard Worker     {
4830*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidNameCharacters);
4831*8975f5c5SAndroid Build Coastguard Worker         return false;
4832*8975f5c5SAndroid Build Coastguard Worker     }
4833*8975f5c5SAndroid Build Coastguard Worker 
4834*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
4835*8975f5c5SAndroid Build Coastguard Worker 
4836*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
4837*8975f5c5SAndroid Build Coastguard Worker     {
4838*8975f5c5SAndroid Build Coastguard Worker         return false;
4839*8975f5c5SAndroid Build Coastguard Worker     }
4840*8975f5c5SAndroid Build Coastguard Worker 
4841*8975f5c5SAndroid Build Coastguard Worker     if (!programObject->isLinked())
4842*8975f5c5SAndroid Build Coastguard Worker     {
4843*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kProgramNotLinked);
4844*8975f5c5SAndroid Build Coastguard Worker         return false;
4845*8975f5c5SAndroid Build Coastguard Worker     }
4846*8975f5c5SAndroid Build Coastguard Worker 
4847*8975f5c5SAndroid Build Coastguard Worker     return true;
4848*8975f5c5SAndroid Build Coastguard Worker }
4849*8975f5c5SAndroid Build Coastguard Worker 
ValidateHint(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum target,GLenum mode)4850*8975f5c5SAndroid Build Coastguard Worker bool ValidateHint(const PrivateState &state,
4851*8975f5c5SAndroid Build Coastguard Worker                   ErrorSet *errors,
4852*8975f5c5SAndroid Build Coastguard Worker                   angle::EntryPoint entryPoint,
4853*8975f5c5SAndroid Build Coastguard Worker                   GLenum target,
4854*8975f5c5SAndroid Build Coastguard Worker                   GLenum mode)
4855*8975f5c5SAndroid Build Coastguard Worker {
4856*8975f5c5SAndroid Build Coastguard Worker     switch (mode)
4857*8975f5c5SAndroid Build Coastguard Worker     {
4858*8975f5c5SAndroid Build Coastguard Worker         case GL_FASTEST:
4859*8975f5c5SAndroid Build Coastguard Worker         case GL_NICEST:
4860*8975f5c5SAndroid Build Coastguard Worker         case GL_DONT_CARE:
4861*8975f5c5SAndroid Build Coastguard Worker             break;
4862*8975f5c5SAndroid Build Coastguard Worker 
4863*8975f5c5SAndroid Build Coastguard Worker         default:
4864*8975f5c5SAndroid Build Coastguard Worker             errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, mode);
4865*8975f5c5SAndroid Build Coastguard Worker             return false;
4866*8975f5c5SAndroid Build Coastguard Worker     }
4867*8975f5c5SAndroid Build Coastguard Worker 
4868*8975f5c5SAndroid Build Coastguard Worker     switch (target)
4869*8975f5c5SAndroid Build Coastguard Worker     {
4870*8975f5c5SAndroid Build Coastguard Worker         case GL_GENERATE_MIPMAP_HINT:
4871*8975f5c5SAndroid Build Coastguard Worker             break;
4872*8975f5c5SAndroid Build Coastguard Worker 
4873*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAGMENT_SHADER_DERIVATIVE_HINT:
4874*8975f5c5SAndroid Build Coastguard Worker             if (state.getClientVersion() < ES_3_0 && !state.getExtensions().standardDerivativesOES)
4875*8975f5c5SAndroid Build Coastguard Worker             {
4876*8975f5c5SAndroid Build Coastguard Worker                 errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, target);
4877*8975f5c5SAndroid Build Coastguard Worker                 return false;
4878*8975f5c5SAndroid Build Coastguard Worker             }
4879*8975f5c5SAndroid Build Coastguard Worker             break;
4880*8975f5c5SAndroid Build Coastguard Worker 
4881*8975f5c5SAndroid Build Coastguard Worker         case GL_PERSPECTIVE_CORRECTION_HINT:
4882*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SMOOTH_HINT:
4883*8975f5c5SAndroid Build Coastguard Worker         case GL_LINE_SMOOTH_HINT:
4884*8975f5c5SAndroid Build Coastguard Worker         case GL_FOG_HINT:
4885*8975f5c5SAndroid Build Coastguard Worker             if (state.getClientMajorVersion() >= 2)
4886*8975f5c5SAndroid Build Coastguard Worker             {
4887*8975f5c5SAndroid Build Coastguard Worker                 errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, target);
4888*8975f5c5SAndroid Build Coastguard Worker                 return false;
4889*8975f5c5SAndroid Build Coastguard Worker             }
4890*8975f5c5SAndroid Build Coastguard Worker             break;
4891*8975f5c5SAndroid Build Coastguard Worker 
4892*8975f5c5SAndroid Build Coastguard Worker         default:
4893*8975f5c5SAndroid Build Coastguard Worker             errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, target);
4894*8975f5c5SAndroid Build Coastguard Worker             return false;
4895*8975f5c5SAndroid Build Coastguard Worker     }
4896*8975f5c5SAndroid Build Coastguard Worker 
4897*8975f5c5SAndroid Build Coastguard Worker     return true;
4898*8975f5c5SAndroid Build Coastguard Worker }
4899*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsBuffer(const Context * context,angle::EntryPoint entryPoint,BufferID buffer)4900*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsBuffer(const Context *context, angle::EntryPoint entryPoint, BufferID buffer)
4901*8975f5c5SAndroid Build Coastguard Worker {
4902*8975f5c5SAndroid Build Coastguard Worker     return true;
4903*8975f5c5SAndroid Build Coastguard Worker }
4904*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsFramebuffer(const Context * context,angle::EntryPoint entryPoint,FramebufferID framebuffer)4905*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsFramebuffer(const Context *context,
4906*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
4907*8975f5c5SAndroid Build Coastguard Worker                            FramebufferID framebuffer)
4908*8975f5c5SAndroid Build Coastguard Worker {
4909*8975f5c5SAndroid Build Coastguard Worker     return true;
4910*8975f5c5SAndroid Build Coastguard Worker }
4911*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsProgram(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program)4912*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsProgram(const Context *context,
4913*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
4914*8975f5c5SAndroid Build Coastguard Worker                        ShaderProgramID program)
4915*8975f5c5SAndroid Build Coastguard Worker {
4916*8975f5c5SAndroid Build Coastguard Worker     return true;
4917*8975f5c5SAndroid Build Coastguard Worker }
4918*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsRenderbuffer(const Context * context,angle::EntryPoint entryPoint,RenderbufferID renderbuffer)4919*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsRenderbuffer(const Context *context,
4920*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
4921*8975f5c5SAndroid Build Coastguard Worker                             RenderbufferID renderbuffer)
4922*8975f5c5SAndroid Build Coastguard Worker {
4923*8975f5c5SAndroid Build Coastguard Worker     return true;
4924*8975f5c5SAndroid Build Coastguard Worker }
4925*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsShader(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader)4926*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsShader(const Context *context, angle::EntryPoint entryPoint, ShaderProgramID shader)
4927*8975f5c5SAndroid Build Coastguard Worker {
4928*8975f5c5SAndroid Build Coastguard Worker     return true;
4929*8975f5c5SAndroid Build Coastguard Worker }
4930*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsTexture(const Context * context,angle::EntryPoint entryPoint,TextureID texture)4931*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsTexture(const Context *context, angle::EntryPoint entryPoint, TextureID texture)
4932*8975f5c5SAndroid Build Coastguard Worker {
4933*8975f5c5SAndroid Build Coastguard Worker     return true;
4934*8975f5c5SAndroid Build Coastguard Worker }
4935*8975f5c5SAndroid Build Coastguard Worker 
ValidatePixelStorei(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum pname,GLint param)4936*8975f5c5SAndroid Build Coastguard Worker bool ValidatePixelStorei(const PrivateState &state,
4937*8975f5c5SAndroid Build Coastguard Worker                          ErrorSet *errors,
4938*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
4939*8975f5c5SAndroid Build Coastguard Worker                          GLenum pname,
4940*8975f5c5SAndroid Build Coastguard Worker                          GLint param)
4941*8975f5c5SAndroid Build Coastguard Worker {
4942*8975f5c5SAndroid Build Coastguard Worker     if (state.getClientMajorVersion() < 3)
4943*8975f5c5SAndroid Build Coastguard Worker     {
4944*8975f5c5SAndroid Build Coastguard Worker         switch (pname)
4945*8975f5c5SAndroid Build Coastguard Worker         {
4946*8975f5c5SAndroid Build Coastguard Worker             case GL_UNPACK_IMAGE_HEIGHT:
4947*8975f5c5SAndroid Build Coastguard Worker             case GL_UNPACK_SKIP_IMAGES:
4948*8975f5c5SAndroid Build Coastguard Worker                 errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
4949*8975f5c5SAndroid Build Coastguard Worker                 return false;
4950*8975f5c5SAndroid Build Coastguard Worker 
4951*8975f5c5SAndroid Build Coastguard Worker             case GL_UNPACK_ROW_LENGTH:
4952*8975f5c5SAndroid Build Coastguard Worker             case GL_UNPACK_SKIP_ROWS:
4953*8975f5c5SAndroid Build Coastguard Worker             case GL_UNPACK_SKIP_PIXELS:
4954*8975f5c5SAndroid Build Coastguard Worker                 if (!state.getExtensions().unpackSubimageEXT)
4955*8975f5c5SAndroid Build Coastguard Worker                 {
4956*8975f5c5SAndroid Build Coastguard Worker                     errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
4957*8975f5c5SAndroid Build Coastguard Worker                     return false;
4958*8975f5c5SAndroid Build Coastguard Worker                 }
4959*8975f5c5SAndroid Build Coastguard Worker                 break;
4960*8975f5c5SAndroid Build Coastguard Worker 
4961*8975f5c5SAndroid Build Coastguard Worker             case GL_PACK_ROW_LENGTH:
4962*8975f5c5SAndroid Build Coastguard Worker             case GL_PACK_SKIP_ROWS:
4963*8975f5c5SAndroid Build Coastguard Worker             case GL_PACK_SKIP_PIXELS:
4964*8975f5c5SAndroid Build Coastguard Worker                 if (!state.getExtensions().packSubimageNV)
4965*8975f5c5SAndroid Build Coastguard Worker                 {
4966*8975f5c5SAndroid Build Coastguard Worker                     errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
4967*8975f5c5SAndroid Build Coastguard Worker                     return false;
4968*8975f5c5SAndroid Build Coastguard Worker                 }
4969*8975f5c5SAndroid Build Coastguard Worker                 break;
4970*8975f5c5SAndroid Build Coastguard Worker         }
4971*8975f5c5SAndroid Build Coastguard Worker     }
4972*8975f5c5SAndroid Build Coastguard Worker 
4973*8975f5c5SAndroid Build Coastguard Worker     if (param < 0)
4974*8975f5c5SAndroid Build Coastguard Worker     {
4975*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_VALUE, kNegativeParam);
4976*8975f5c5SAndroid Build Coastguard Worker         return false;
4977*8975f5c5SAndroid Build Coastguard Worker     }
4978*8975f5c5SAndroid Build Coastguard Worker 
4979*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
4980*8975f5c5SAndroid Build Coastguard Worker     {
4981*8975f5c5SAndroid Build Coastguard Worker         case GL_UNPACK_ALIGNMENT:
4982*8975f5c5SAndroid Build Coastguard Worker             if (param != 1 && param != 2 && param != 4 && param != 8)
4983*8975f5c5SAndroid Build Coastguard Worker             {
4984*8975f5c5SAndroid Build Coastguard Worker                 errors->validationError(entryPoint, GL_INVALID_VALUE, kInvalidUnpackAlignment);
4985*8975f5c5SAndroid Build Coastguard Worker                 return false;
4986*8975f5c5SAndroid Build Coastguard Worker             }
4987*8975f5c5SAndroid Build Coastguard Worker             break;
4988*8975f5c5SAndroid Build Coastguard Worker 
4989*8975f5c5SAndroid Build Coastguard Worker         case GL_PACK_ALIGNMENT:
4990*8975f5c5SAndroid Build Coastguard Worker             if (param != 1 && param != 2 && param != 4 && param != 8)
4991*8975f5c5SAndroid Build Coastguard Worker             {
4992*8975f5c5SAndroid Build Coastguard Worker                 errors->validationError(entryPoint, GL_INVALID_VALUE, kInvalidUnpackAlignment);
4993*8975f5c5SAndroid Build Coastguard Worker                 return false;
4994*8975f5c5SAndroid Build Coastguard Worker             }
4995*8975f5c5SAndroid Build Coastguard Worker             break;
4996*8975f5c5SAndroid Build Coastguard Worker 
4997*8975f5c5SAndroid Build Coastguard Worker         case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
4998*8975f5c5SAndroid Build Coastguard Worker             if (!state.getExtensions().packReverseRowOrderANGLE)
4999*8975f5c5SAndroid Build Coastguard Worker             {
5000*8975f5c5SAndroid Build Coastguard Worker                 errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, pname);
5001*8975f5c5SAndroid Build Coastguard Worker             }
5002*8975f5c5SAndroid Build Coastguard Worker             break;
5003*8975f5c5SAndroid Build Coastguard Worker 
5004*8975f5c5SAndroid Build Coastguard Worker         case GL_UNPACK_ROW_LENGTH:
5005*8975f5c5SAndroid Build Coastguard Worker         case GL_UNPACK_IMAGE_HEIGHT:
5006*8975f5c5SAndroid Build Coastguard Worker         case GL_UNPACK_SKIP_IMAGES:
5007*8975f5c5SAndroid Build Coastguard Worker         case GL_UNPACK_SKIP_ROWS:
5008*8975f5c5SAndroid Build Coastguard Worker         case GL_UNPACK_SKIP_PIXELS:
5009*8975f5c5SAndroid Build Coastguard Worker         case GL_PACK_ROW_LENGTH:
5010*8975f5c5SAndroid Build Coastguard Worker         case GL_PACK_SKIP_ROWS:
5011*8975f5c5SAndroid Build Coastguard Worker         case GL_PACK_SKIP_PIXELS:
5012*8975f5c5SAndroid Build Coastguard Worker             break;
5013*8975f5c5SAndroid Build Coastguard Worker 
5014*8975f5c5SAndroid Build Coastguard Worker         default:
5015*8975f5c5SAndroid Build Coastguard Worker             errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, pname);
5016*8975f5c5SAndroid Build Coastguard Worker             return false;
5017*8975f5c5SAndroid Build Coastguard Worker     }
5018*8975f5c5SAndroid Build Coastguard Worker 
5019*8975f5c5SAndroid Build Coastguard Worker     return true;
5020*8975f5c5SAndroid Build Coastguard Worker }
5021*8975f5c5SAndroid Build Coastguard Worker 
ValidatePolygonOffset(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLfloat factor,GLfloat units)5022*8975f5c5SAndroid Build Coastguard Worker bool ValidatePolygonOffset(const PrivateState &state,
5023*8975f5c5SAndroid Build Coastguard Worker                            ErrorSet *errors,
5024*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
5025*8975f5c5SAndroid Build Coastguard Worker                            GLfloat factor,
5026*8975f5c5SAndroid Build Coastguard Worker                            GLfloat units)
5027*8975f5c5SAndroid Build Coastguard Worker {
5028*8975f5c5SAndroid Build Coastguard Worker     return true;
5029*8975f5c5SAndroid Build Coastguard Worker }
5030*8975f5c5SAndroid Build Coastguard Worker 
ValidateReleaseShaderCompiler(const Context * context,angle::EntryPoint entryPoint)5031*8975f5c5SAndroid Build Coastguard Worker bool ValidateReleaseShaderCompiler(const Context *context, angle::EntryPoint entryPoint)
5032*8975f5c5SAndroid Build Coastguard Worker {
5033*8975f5c5SAndroid Build Coastguard Worker     return true;
5034*8975f5c5SAndroid Build Coastguard Worker }
5035*8975f5c5SAndroid Build Coastguard Worker 
ValidateSampleCoverage(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLfloat value,GLboolean invert)5036*8975f5c5SAndroid Build Coastguard Worker bool ValidateSampleCoverage(const PrivateState &state,
5037*8975f5c5SAndroid Build Coastguard Worker                             ErrorSet *errors,
5038*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5039*8975f5c5SAndroid Build Coastguard Worker                             GLfloat value,
5040*8975f5c5SAndroid Build Coastguard Worker                             GLboolean invert)
5041*8975f5c5SAndroid Build Coastguard Worker {
5042*8975f5c5SAndroid Build Coastguard Worker     return true;
5043*8975f5c5SAndroid Build Coastguard Worker }
5044*8975f5c5SAndroid Build Coastguard Worker 
ValidateScissor(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLint x,GLint y,GLsizei width,GLsizei height)5045*8975f5c5SAndroid Build Coastguard Worker bool ValidateScissor(const PrivateState &state,
5046*8975f5c5SAndroid Build Coastguard Worker                      ErrorSet *errors,
5047*8975f5c5SAndroid Build Coastguard Worker                      angle::EntryPoint entryPoint,
5048*8975f5c5SAndroid Build Coastguard Worker                      GLint x,
5049*8975f5c5SAndroid Build Coastguard Worker                      GLint y,
5050*8975f5c5SAndroid Build Coastguard Worker                      GLsizei width,
5051*8975f5c5SAndroid Build Coastguard Worker                      GLsizei height)
5052*8975f5c5SAndroid Build Coastguard Worker {
5053*8975f5c5SAndroid Build Coastguard Worker     if (width < 0 || height < 0)
5054*8975f5c5SAndroid Build Coastguard Worker     {
5055*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_VALUE, kNegativeSize);
5056*8975f5c5SAndroid Build Coastguard Worker         return false;
5057*8975f5c5SAndroid Build Coastguard Worker     }
5058*8975f5c5SAndroid Build Coastguard Worker 
5059*8975f5c5SAndroid Build Coastguard Worker     return true;
5060*8975f5c5SAndroid Build Coastguard Worker }
5061*8975f5c5SAndroid Build Coastguard Worker 
ValidateShaderBinary(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const ShaderProgramID * shaders,GLenum binaryformat,const void * binary,GLsizei length)5062*8975f5c5SAndroid Build Coastguard Worker bool ValidateShaderBinary(const Context *context,
5063*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
5064*8975f5c5SAndroid Build Coastguard Worker                           GLsizei n,
5065*8975f5c5SAndroid Build Coastguard Worker                           const ShaderProgramID *shaders,
5066*8975f5c5SAndroid Build Coastguard Worker                           GLenum binaryformat,
5067*8975f5c5SAndroid Build Coastguard Worker                           const void *binary,
5068*8975f5c5SAndroid Build Coastguard Worker                           GLsizei length)
5069*8975f5c5SAndroid Build Coastguard Worker {
5070*8975f5c5SAndroid Build Coastguard Worker     const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
5071*8975f5c5SAndroid Build Coastguard Worker     if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) ==
5072*8975f5c5SAndroid Build Coastguard Worker         shaderBinaryFormats.end())
5073*8975f5c5SAndroid Build Coastguard Worker     {
5074*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidShaderBinaryFormat);
5075*8975f5c5SAndroid Build Coastguard Worker         return false;
5076*8975f5c5SAndroid Build Coastguard Worker     }
5077*8975f5c5SAndroid Build Coastguard Worker 
5078*8975f5c5SAndroid Build Coastguard Worker     ASSERT(binaryformat == GL_SHADER_BINARY_ANGLE);
5079*8975f5c5SAndroid Build Coastguard Worker 
5080*8975f5c5SAndroid Build Coastguard Worker     if (n <= 0)
5081*8975f5c5SAndroid Build Coastguard Worker     {
5082*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidShaderCount);
5083*8975f5c5SAndroid Build Coastguard Worker         return false;
5084*8975f5c5SAndroid Build Coastguard Worker     }
5085*8975f5c5SAndroid Build Coastguard Worker 
5086*8975f5c5SAndroid Build Coastguard Worker     if (length < 0)
5087*8975f5c5SAndroid Build Coastguard Worker     {
5088*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeLength);
5089*8975f5c5SAndroid Build Coastguard Worker         return false;
5090*8975f5c5SAndroid Build Coastguard Worker     }
5091*8975f5c5SAndroid Build Coastguard Worker 
5092*8975f5c5SAndroid Build Coastguard Worker     // GL_SHADER_BINARY_ANGLE shader binaries contain a single shader.
5093*8975f5c5SAndroid Build Coastguard Worker     if (n > 1)
5094*8975f5c5SAndroid Build Coastguard Worker     {
5095*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidShaderCount);
5096*8975f5c5SAndroid Build Coastguard Worker         return false;
5097*8975f5c5SAndroid Build Coastguard Worker     }
5098*8975f5c5SAndroid Build Coastguard Worker 
5099*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = GetValidShader(context, entryPoint, shaders[0]);
5100*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
5101*8975f5c5SAndroid Build Coastguard Worker     {
5102*8975f5c5SAndroid Build Coastguard Worker         return false;
5103*8975f5c5SAndroid Build Coastguard Worker     }
5104*8975f5c5SAndroid Build Coastguard Worker 
5105*8975f5c5SAndroid Build Coastguard Worker     // Check ANGLE version used to generate binary matches the current version.
5106*8975f5c5SAndroid Build Coastguard Worker     BinaryInputStream stream(binary, length);
5107*8975f5c5SAndroid Build Coastguard Worker     std::vector<uint8_t> versionString(angle::GetANGLEShaderProgramVersionHashSize(), 0);
5108*8975f5c5SAndroid Build Coastguard Worker     stream.readBytes(versionString.data(), versionString.size());
5109*8975f5c5SAndroid Build Coastguard Worker     if (memcmp(versionString.data(), angle::GetANGLEShaderProgramVersion(), versionString.size()) !=
5110*8975f5c5SAndroid Build Coastguard Worker         0)
5111*8975f5c5SAndroid Build Coastguard Worker     {
5112*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidShaderBinary);
5113*8975f5c5SAndroid Build Coastguard Worker         return false;
5114*8975f5c5SAndroid Build Coastguard Worker     }
5115*8975f5c5SAndroid Build Coastguard Worker 
5116*8975f5c5SAndroid Build Coastguard Worker     // Check that the shader type of the binary matches the type of target shader.
5117*8975f5c5SAndroid Build Coastguard Worker     gl::ShaderType shaderType;
5118*8975f5c5SAndroid Build Coastguard Worker     stream.readEnum(&shaderType);
5119*8975f5c5SAndroid Build Coastguard Worker     if (shaderObject->getType() != shaderType)
5120*8975f5c5SAndroid Build Coastguard Worker     {
5121*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kMismatchedShaderBinaryType);
5122*8975f5c5SAndroid Build Coastguard Worker         return false;
5123*8975f5c5SAndroid Build Coastguard Worker     }
5124*8975f5c5SAndroid Build Coastguard Worker 
5125*8975f5c5SAndroid Build Coastguard Worker     return true;
5126*8975f5c5SAndroid Build Coastguard Worker }
5127*8975f5c5SAndroid Build Coastguard Worker 
ValidateShaderSource(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader,GLsizei count,const GLchar * const * string,const GLint * length)5128*8975f5c5SAndroid Build Coastguard Worker bool ValidateShaderSource(const Context *context,
5129*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
5130*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID shader,
5131*8975f5c5SAndroid Build Coastguard Worker                           GLsizei count,
5132*8975f5c5SAndroid Build Coastguard Worker                           const GLchar *const *string,
5133*8975f5c5SAndroid Build Coastguard Worker                           const GLint *length)
5134*8975f5c5SAndroid Build Coastguard Worker {
5135*8975f5c5SAndroid Build Coastguard Worker     if (count < 0)
5136*8975f5c5SAndroid Build Coastguard Worker     {
5137*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeCount);
5138*8975f5c5SAndroid Build Coastguard Worker         return false;
5139*8975f5c5SAndroid Build Coastguard Worker     }
5140*8975f5c5SAndroid Build Coastguard Worker 
5141*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = GetValidShader(context, entryPoint, shader);
5142*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
5143*8975f5c5SAndroid Build Coastguard Worker     {
5144*8975f5c5SAndroid Build Coastguard Worker         return false;
5145*8975f5c5SAndroid Build Coastguard Worker     }
5146*8975f5c5SAndroid Build Coastguard Worker 
5147*8975f5c5SAndroid Build Coastguard Worker     return true;
5148*8975f5c5SAndroid Build Coastguard Worker }
5149*8975f5c5SAndroid Build Coastguard Worker 
ValidateStencilFunc(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum func,GLint ref,GLuint mask)5150*8975f5c5SAndroid Build Coastguard Worker bool ValidateStencilFunc(const PrivateState &state,
5151*8975f5c5SAndroid Build Coastguard Worker                          ErrorSet *errors,
5152*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
5153*8975f5c5SAndroid Build Coastguard Worker                          GLenum func,
5154*8975f5c5SAndroid Build Coastguard Worker                          GLint ref,
5155*8975f5c5SAndroid Build Coastguard Worker                          GLuint mask)
5156*8975f5c5SAndroid Build Coastguard Worker {
5157*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilFunc(func))
5158*8975f5c5SAndroid Build Coastguard Worker     {
5159*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5160*8975f5c5SAndroid Build Coastguard Worker         return false;
5161*8975f5c5SAndroid Build Coastguard Worker     }
5162*8975f5c5SAndroid Build Coastguard Worker 
5163*8975f5c5SAndroid Build Coastguard Worker     return true;
5164*8975f5c5SAndroid Build Coastguard Worker }
5165*8975f5c5SAndroid Build Coastguard Worker 
ValidateStencilFuncSeparate(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum face,GLenum func,GLint ref,GLuint mask)5166*8975f5c5SAndroid Build Coastguard Worker bool ValidateStencilFuncSeparate(const PrivateState &state,
5167*8975f5c5SAndroid Build Coastguard Worker                                  ErrorSet *errors,
5168*8975f5c5SAndroid Build Coastguard Worker                                  angle::EntryPoint entryPoint,
5169*8975f5c5SAndroid Build Coastguard Worker                                  GLenum face,
5170*8975f5c5SAndroid Build Coastguard Worker                                  GLenum func,
5171*8975f5c5SAndroid Build Coastguard Worker                                  GLint ref,
5172*8975f5c5SAndroid Build Coastguard Worker                                  GLuint mask)
5173*8975f5c5SAndroid Build Coastguard Worker {
5174*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilFace(face))
5175*8975f5c5SAndroid Build Coastguard Worker     {
5176*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5177*8975f5c5SAndroid Build Coastguard Worker         return false;
5178*8975f5c5SAndroid Build Coastguard Worker     }
5179*8975f5c5SAndroid Build Coastguard Worker 
5180*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilFunc(func))
5181*8975f5c5SAndroid Build Coastguard Worker     {
5182*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5183*8975f5c5SAndroid Build Coastguard Worker         return false;
5184*8975f5c5SAndroid Build Coastguard Worker     }
5185*8975f5c5SAndroid Build Coastguard Worker 
5186*8975f5c5SAndroid Build Coastguard Worker     return true;
5187*8975f5c5SAndroid Build Coastguard Worker }
5188*8975f5c5SAndroid Build Coastguard Worker 
ValidateStencilMask(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint mask)5189*8975f5c5SAndroid Build Coastguard Worker bool ValidateStencilMask(const PrivateState &state,
5190*8975f5c5SAndroid Build Coastguard Worker                          ErrorSet *errors,
5191*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
5192*8975f5c5SAndroid Build Coastguard Worker                          GLuint mask)
5193*8975f5c5SAndroid Build Coastguard Worker {
5194*8975f5c5SAndroid Build Coastguard Worker     return true;
5195*8975f5c5SAndroid Build Coastguard Worker }
5196*8975f5c5SAndroid Build Coastguard Worker 
ValidateStencilMaskSeparate(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum face,GLuint mask)5197*8975f5c5SAndroid Build Coastguard Worker bool ValidateStencilMaskSeparate(const PrivateState &state,
5198*8975f5c5SAndroid Build Coastguard Worker                                  ErrorSet *errors,
5199*8975f5c5SAndroid Build Coastguard Worker                                  angle::EntryPoint entryPoint,
5200*8975f5c5SAndroid Build Coastguard Worker                                  GLenum face,
5201*8975f5c5SAndroid Build Coastguard Worker                                  GLuint mask)
5202*8975f5c5SAndroid Build Coastguard Worker {
5203*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilFace(face))
5204*8975f5c5SAndroid Build Coastguard Worker     {
5205*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5206*8975f5c5SAndroid Build Coastguard Worker         return false;
5207*8975f5c5SAndroid Build Coastguard Worker     }
5208*8975f5c5SAndroid Build Coastguard Worker 
5209*8975f5c5SAndroid Build Coastguard Worker     return true;
5210*8975f5c5SAndroid Build Coastguard Worker }
5211*8975f5c5SAndroid Build Coastguard Worker 
ValidateStencilOp(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum fail,GLenum zfail,GLenum zpass)5212*8975f5c5SAndroid Build Coastguard Worker bool ValidateStencilOp(const PrivateState &state,
5213*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
5214*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5215*8975f5c5SAndroid Build Coastguard Worker                        GLenum fail,
5216*8975f5c5SAndroid Build Coastguard Worker                        GLenum zfail,
5217*8975f5c5SAndroid Build Coastguard Worker                        GLenum zpass)
5218*8975f5c5SAndroid Build Coastguard Worker {
5219*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilOp(fail))
5220*8975f5c5SAndroid Build Coastguard Worker     {
5221*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5222*8975f5c5SAndroid Build Coastguard Worker         return false;
5223*8975f5c5SAndroid Build Coastguard Worker     }
5224*8975f5c5SAndroid Build Coastguard Worker 
5225*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilOp(zfail))
5226*8975f5c5SAndroid Build Coastguard Worker     {
5227*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5228*8975f5c5SAndroid Build Coastguard Worker         return false;
5229*8975f5c5SAndroid Build Coastguard Worker     }
5230*8975f5c5SAndroid Build Coastguard Worker 
5231*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilOp(zpass))
5232*8975f5c5SAndroid Build Coastguard Worker     {
5233*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5234*8975f5c5SAndroid Build Coastguard Worker         return false;
5235*8975f5c5SAndroid Build Coastguard Worker     }
5236*8975f5c5SAndroid Build Coastguard Worker 
5237*8975f5c5SAndroid Build Coastguard Worker     return true;
5238*8975f5c5SAndroid Build Coastguard Worker }
5239*8975f5c5SAndroid Build Coastguard Worker 
ValidateStencilOpSeparate(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum face,GLenum fail,GLenum zfail,GLenum zpass)5240*8975f5c5SAndroid Build Coastguard Worker bool ValidateStencilOpSeparate(const PrivateState &state,
5241*8975f5c5SAndroid Build Coastguard Worker                                ErrorSet *errors,
5242*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
5243*8975f5c5SAndroid Build Coastguard Worker                                GLenum face,
5244*8975f5c5SAndroid Build Coastguard Worker                                GLenum fail,
5245*8975f5c5SAndroid Build Coastguard Worker                                GLenum zfail,
5246*8975f5c5SAndroid Build Coastguard Worker                                GLenum zpass)
5247*8975f5c5SAndroid Build Coastguard Worker {
5248*8975f5c5SAndroid Build Coastguard Worker     if (!IsValidStencilFace(face))
5249*8975f5c5SAndroid Build Coastguard Worker     {
5250*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_ENUM, kInvalidStencil);
5251*8975f5c5SAndroid Build Coastguard Worker         return false;
5252*8975f5c5SAndroid Build Coastguard Worker     }
5253*8975f5c5SAndroid Build Coastguard Worker 
5254*8975f5c5SAndroid Build Coastguard Worker     return ValidateStencilOp(state, errors, entryPoint, fail, zfail, zpass);
5255*8975f5c5SAndroid Build Coastguard Worker }
5256*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform1f(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLfloat x)5257*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform1f(const Context *context,
5258*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5259*8975f5c5SAndroid Build Coastguard Worker                        UniformLocation location,
5260*8975f5c5SAndroid Build Coastguard Worker                        GLfloat x)
5261*8975f5c5SAndroid Build Coastguard Worker {
5262*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_FLOAT, location, 1);
5263*8975f5c5SAndroid Build Coastguard Worker }
5264*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform1fv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,const GLfloat * v)5265*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform1fv(const Context *context,
5266*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5267*8975f5c5SAndroid Build Coastguard Worker                         UniformLocation location,
5268*8975f5c5SAndroid Build Coastguard Worker                         GLsizei count,
5269*8975f5c5SAndroid Build Coastguard Worker                         const GLfloat *v)
5270*8975f5c5SAndroid Build Coastguard Worker {
5271*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_FLOAT, location, count);
5272*8975f5c5SAndroid Build Coastguard Worker }
5273*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform1i(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLint x)5274*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform1i(const Context *context,
5275*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5276*8975f5c5SAndroid Build Coastguard Worker                        UniformLocation location,
5277*8975f5c5SAndroid Build Coastguard Worker                        GLint x)
5278*8975f5c5SAndroid Build Coastguard Worker {
5279*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform1iv(context, entryPoint, location, 1, &x);
5280*8975f5c5SAndroid Build Coastguard Worker }
5281*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform2fv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,const GLfloat * v)5282*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform2fv(const Context *context,
5283*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5284*8975f5c5SAndroid Build Coastguard Worker                         UniformLocation location,
5285*8975f5c5SAndroid Build Coastguard Worker                         GLsizei count,
5286*8975f5c5SAndroid Build Coastguard Worker                         const GLfloat *v)
5287*8975f5c5SAndroid Build Coastguard Worker {
5288*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_FLOAT_VEC2, location, count);
5289*8975f5c5SAndroid Build Coastguard Worker }
5290*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform2i(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLint x,GLint y)5291*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform2i(const Context *context,
5292*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5293*8975f5c5SAndroid Build Coastguard Worker                        UniformLocation location,
5294*8975f5c5SAndroid Build Coastguard Worker                        GLint x,
5295*8975f5c5SAndroid Build Coastguard Worker                        GLint y)
5296*8975f5c5SAndroid Build Coastguard Worker {
5297*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_INT_VEC2, location, 1);
5298*8975f5c5SAndroid Build Coastguard Worker }
5299*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform2iv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,const GLint * v)5300*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform2iv(const Context *context,
5301*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5302*8975f5c5SAndroid Build Coastguard Worker                         UniformLocation location,
5303*8975f5c5SAndroid Build Coastguard Worker                         GLsizei count,
5304*8975f5c5SAndroid Build Coastguard Worker                         const GLint *v)
5305*8975f5c5SAndroid Build Coastguard Worker {
5306*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_INT_VEC2, location, count);
5307*8975f5c5SAndroid Build Coastguard Worker }
5308*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform3f(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLfloat x,GLfloat y,GLfloat z)5309*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform3f(const Context *context,
5310*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5311*8975f5c5SAndroid Build Coastguard Worker                        UniformLocation location,
5312*8975f5c5SAndroid Build Coastguard Worker                        GLfloat x,
5313*8975f5c5SAndroid Build Coastguard Worker                        GLfloat y,
5314*8975f5c5SAndroid Build Coastguard Worker                        GLfloat z)
5315*8975f5c5SAndroid Build Coastguard Worker {
5316*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_FLOAT_VEC3, location, 1);
5317*8975f5c5SAndroid Build Coastguard Worker }
5318*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform3fv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,const GLfloat * v)5319*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform3fv(const Context *context,
5320*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5321*8975f5c5SAndroid Build Coastguard Worker                         UniformLocation location,
5322*8975f5c5SAndroid Build Coastguard Worker                         GLsizei count,
5323*8975f5c5SAndroid Build Coastguard Worker                         const GLfloat *v)
5324*8975f5c5SAndroid Build Coastguard Worker {
5325*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_FLOAT_VEC3, location, count);
5326*8975f5c5SAndroid Build Coastguard Worker }
5327*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform3i(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLint x,GLint y,GLint z)5328*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform3i(const Context *context,
5329*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5330*8975f5c5SAndroid Build Coastguard Worker                        UniformLocation location,
5331*8975f5c5SAndroid Build Coastguard Worker                        GLint x,
5332*8975f5c5SAndroid Build Coastguard Worker                        GLint y,
5333*8975f5c5SAndroid Build Coastguard Worker                        GLint z)
5334*8975f5c5SAndroid Build Coastguard Worker {
5335*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_INT_VEC3, location, 1);
5336*8975f5c5SAndroid Build Coastguard Worker }
5337*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform3iv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,const GLint * v)5338*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform3iv(const Context *context,
5339*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5340*8975f5c5SAndroid Build Coastguard Worker                         UniformLocation location,
5341*8975f5c5SAndroid Build Coastguard Worker                         GLsizei count,
5342*8975f5c5SAndroid Build Coastguard Worker                         const GLint *v)
5343*8975f5c5SAndroid Build Coastguard Worker {
5344*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_INT_VEC3, location, count);
5345*8975f5c5SAndroid Build Coastguard Worker }
5346*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform4f(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)5347*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform4f(const Context *context,
5348*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5349*8975f5c5SAndroid Build Coastguard Worker                        UniformLocation location,
5350*8975f5c5SAndroid Build Coastguard Worker                        GLfloat x,
5351*8975f5c5SAndroid Build Coastguard Worker                        GLfloat y,
5352*8975f5c5SAndroid Build Coastguard Worker                        GLfloat z,
5353*8975f5c5SAndroid Build Coastguard Worker                        GLfloat w)
5354*8975f5c5SAndroid Build Coastguard Worker {
5355*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_FLOAT_VEC4, location, 1);
5356*8975f5c5SAndroid Build Coastguard Worker }
5357*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform4fv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,const GLfloat * v)5358*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform4fv(const Context *context,
5359*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5360*8975f5c5SAndroid Build Coastguard Worker                         UniformLocation location,
5361*8975f5c5SAndroid Build Coastguard Worker                         GLsizei count,
5362*8975f5c5SAndroid Build Coastguard Worker                         const GLfloat *v)
5363*8975f5c5SAndroid Build Coastguard Worker {
5364*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_FLOAT_VEC4, location, count);
5365*8975f5c5SAndroid Build Coastguard Worker }
5366*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform4i(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLint x,GLint y,GLint z,GLint w)5367*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform4i(const Context *context,
5368*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
5369*8975f5c5SAndroid Build Coastguard Worker                        UniformLocation location,
5370*8975f5c5SAndroid Build Coastguard Worker                        GLint x,
5371*8975f5c5SAndroid Build Coastguard Worker                        GLint y,
5372*8975f5c5SAndroid Build Coastguard Worker                        GLint z,
5373*8975f5c5SAndroid Build Coastguard Worker                        GLint w)
5374*8975f5c5SAndroid Build Coastguard Worker {
5375*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_INT_VEC4, location, 1);
5376*8975f5c5SAndroid Build Coastguard Worker }
5377*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniform4iv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,const GLint * v)5378*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform4iv(const Context *context,
5379*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5380*8975f5c5SAndroid Build Coastguard Worker                         UniformLocation location,
5381*8975f5c5SAndroid Build Coastguard Worker                         GLsizei count,
5382*8975f5c5SAndroid Build Coastguard Worker                         const GLint *v)
5383*8975f5c5SAndroid Build Coastguard Worker {
5384*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniform(context, entryPoint, GL_INT_VEC4, location, count);
5385*8975f5c5SAndroid Build Coastguard Worker }
5386*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniformMatrix2fv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)5387*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniformMatrix2fv(const Context *context,
5388*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
5389*8975f5c5SAndroid Build Coastguard Worker                               UniformLocation location,
5390*8975f5c5SAndroid Build Coastguard Worker                               GLsizei count,
5391*8975f5c5SAndroid Build Coastguard Worker                               GLboolean transpose,
5392*8975f5c5SAndroid Build Coastguard Worker                               const GLfloat *value)
5393*8975f5c5SAndroid Build Coastguard Worker {
5394*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniformMatrix(context, entryPoint, GL_FLOAT_MAT2, location, count, transpose);
5395*8975f5c5SAndroid Build Coastguard Worker }
5396*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniformMatrix3fv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)5397*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniformMatrix3fv(const Context *context,
5398*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
5399*8975f5c5SAndroid Build Coastguard Worker                               UniformLocation location,
5400*8975f5c5SAndroid Build Coastguard Worker                               GLsizei count,
5401*8975f5c5SAndroid Build Coastguard Worker                               GLboolean transpose,
5402*8975f5c5SAndroid Build Coastguard Worker                               const GLfloat *value)
5403*8975f5c5SAndroid Build Coastguard Worker {
5404*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniformMatrix(context, entryPoint, GL_FLOAT_MAT3, location, count, transpose);
5405*8975f5c5SAndroid Build Coastguard Worker }
5406*8975f5c5SAndroid Build Coastguard Worker 
ValidateUniformMatrix4fv(const Context * context,angle::EntryPoint entryPoint,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)5407*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniformMatrix4fv(const Context *context,
5408*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
5409*8975f5c5SAndroid Build Coastguard Worker                               UniformLocation location,
5410*8975f5c5SAndroid Build Coastguard Worker                               GLsizei count,
5411*8975f5c5SAndroid Build Coastguard Worker                               GLboolean transpose,
5412*8975f5c5SAndroid Build Coastguard Worker                               const GLfloat *value)
5413*8975f5c5SAndroid Build Coastguard Worker {
5414*8975f5c5SAndroid Build Coastguard Worker     return ValidateUniformMatrix(context, entryPoint, GL_FLOAT_MAT4, location, count, transpose);
5415*8975f5c5SAndroid Build Coastguard Worker }
5416*8975f5c5SAndroid Build Coastguard Worker 
ValidateValidateProgram(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program)5417*8975f5c5SAndroid Build Coastguard Worker bool ValidateValidateProgram(const Context *context,
5418*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
5419*8975f5c5SAndroid Build Coastguard Worker                              ShaderProgramID program)
5420*8975f5c5SAndroid Build Coastguard Worker {
5421*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
5422*8975f5c5SAndroid Build Coastguard Worker 
5423*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
5424*8975f5c5SAndroid Build Coastguard Worker     {
5425*8975f5c5SAndroid Build Coastguard Worker         return false;
5426*8975f5c5SAndroid Build Coastguard Worker     }
5427*8975f5c5SAndroid Build Coastguard Worker 
5428*8975f5c5SAndroid Build Coastguard Worker     return true;
5429*8975f5c5SAndroid Build Coastguard Worker }
5430*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib1f(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,GLfloat x)5431*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib1f(const PrivateState &state,
5432*8975f5c5SAndroid Build Coastguard Worker                             ErrorSet *errors,
5433*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5434*8975f5c5SAndroid Build Coastguard Worker                             GLuint index,
5435*8975f5c5SAndroid Build Coastguard Worker                             GLfloat x)
5436*8975f5c5SAndroid Build Coastguard Worker {
5437*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5438*8975f5c5SAndroid Build Coastguard Worker }
5439*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib1fv(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,const GLfloat * values)5440*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib1fv(const PrivateState &state,
5441*8975f5c5SAndroid Build Coastguard Worker                              ErrorSet *errors,
5442*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
5443*8975f5c5SAndroid Build Coastguard Worker                              GLuint index,
5444*8975f5c5SAndroid Build Coastguard Worker                              const GLfloat *values)
5445*8975f5c5SAndroid Build Coastguard Worker {
5446*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5447*8975f5c5SAndroid Build Coastguard Worker }
5448*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib2f(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,GLfloat x,GLfloat y)5449*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib2f(const PrivateState &state,
5450*8975f5c5SAndroid Build Coastguard Worker                             ErrorSet *errors,
5451*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5452*8975f5c5SAndroid Build Coastguard Worker                             GLuint index,
5453*8975f5c5SAndroid Build Coastguard Worker                             GLfloat x,
5454*8975f5c5SAndroid Build Coastguard Worker                             GLfloat y)
5455*8975f5c5SAndroid Build Coastguard Worker {
5456*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5457*8975f5c5SAndroid Build Coastguard Worker }
5458*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib2fv(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,const GLfloat * values)5459*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib2fv(const PrivateState &state,
5460*8975f5c5SAndroid Build Coastguard Worker                              ErrorSet *errors,
5461*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
5462*8975f5c5SAndroid Build Coastguard Worker                              GLuint index,
5463*8975f5c5SAndroid Build Coastguard Worker                              const GLfloat *values)
5464*8975f5c5SAndroid Build Coastguard Worker {
5465*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5466*8975f5c5SAndroid Build Coastguard Worker }
5467*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib3f(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,GLfloat x,GLfloat y,GLfloat z)5468*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib3f(const PrivateState &state,
5469*8975f5c5SAndroid Build Coastguard Worker                             ErrorSet *errors,
5470*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5471*8975f5c5SAndroid Build Coastguard Worker                             GLuint index,
5472*8975f5c5SAndroid Build Coastguard Worker                             GLfloat x,
5473*8975f5c5SAndroid Build Coastguard Worker                             GLfloat y,
5474*8975f5c5SAndroid Build Coastguard Worker                             GLfloat z)
5475*8975f5c5SAndroid Build Coastguard Worker {
5476*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5477*8975f5c5SAndroid Build Coastguard Worker }
5478*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib3fv(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,const GLfloat * values)5479*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib3fv(const PrivateState &state,
5480*8975f5c5SAndroid Build Coastguard Worker                              ErrorSet *errors,
5481*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
5482*8975f5c5SAndroid Build Coastguard Worker                              GLuint index,
5483*8975f5c5SAndroid Build Coastguard Worker                              const GLfloat *values)
5484*8975f5c5SAndroid Build Coastguard Worker {
5485*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5486*8975f5c5SAndroid Build Coastguard Worker }
5487*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib4f(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)5488*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib4f(const PrivateState &state,
5489*8975f5c5SAndroid Build Coastguard Worker                             ErrorSet *errors,
5490*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5491*8975f5c5SAndroid Build Coastguard Worker                             GLuint index,
5492*8975f5c5SAndroid Build Coastguard Worker                             GLfloat x,
5493*8975f5c5SAndroid Build Coastguard Worker                             GLfloat y,
5494*8975f5c5SAndroid Build Coastguard Worker                             GLfloat z,
5495*8975f5c5SAndroid Build Coastguard Worker                             GLfloat w)
5496*8975f5c5SAndroid Build Coastguard Worker {
5497*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5498*8975f5c5SAndroid Build Coastguard Worker }
5499*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttrib4fv(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index,const GLfloat * values)5500*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttrib4fv(const PrivateState &state,
5501*8975f5c5SAndroid Build Coastguard Worker                              ErrorSet *errors,
5502*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
5503*8975f5c5SAndroid Build Coastguard Worker                              GLuint index,
5504*8975f5c5SAndroid Build Coastguard Worker                              const GLfloat *values)
5505*8975f5c5SAndroid Build Coastguard Worker {
5506*8975f5c5SAndroid Build Coastguard Worker     return ValidateVertexAttribIndex(state, errors, entryPoint, index);
5507*8975f5c5SAndroid Build Coastguard Worker }
5508*8975f5c5SAndroid Build Coastguard Worker 
ValidateViewport(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLint x,GLint y,GLsizei width,GLsizei height)5509*8975f5c5SAndroid Build Coastguard Worker bool ValidateViewport(const PrivateState &state,
5510*8975f5c5SAndroid Build Coastguard Worker                       ErrorSet *errors,
5511*8975f5c5SAndroid Build Coastguard Worker                       angle::EntryPoint entryPoint,
5512*8975f5c5SAndroid Build Coastguard Worker                       GLint x,
5513*8975f5c5SAndroid Build Coastguard Worker                       GLint y,
5514*8975f5c5SAndroid Build Coastguard Worker                       GLsizei width,
5515*8975f5c5SAndroid Build Coastguard Worker                       GLsizei height)
5516*8975f5c5SAndroid Build Coastguard Worker {
5517*8975f5c5SAndroid Build Coastguard Worker     if (width < 0 || height < 0)
5518*8975f5c5SAndroid Build Coastguard Worker     {
5519*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_VALUE, kViewportNegativeSize);
5520*8975f5c5SAndroid Build Coastguard Worker         return false;
5521*8975f5c5SAndroid Build Coastguard Worker     }
5522*8975f5c5SAndroid Build Coastguard Worker 
5523*8975f5c5SAndroid Build Coastguard Worker     return true;
5524*8975f5c5SAndroid Build Coastguard Worker }
5525*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetFramebufferAttachmentParameteriv(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum attachment,GLenum pname,const GLint * params)5526*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetFramebufferAttachmentParameteriv(const Context *context,
5527*8975f5c5SAndroid Build Coastguard Worker                                                  angle::EntryPoint entryPoint,
5528*8975f5c5SAndroid Build Coastguard Worker                                                  GLenum target,
5529*8975f5c5SAndroid Build Coastguard Worker                                                  GLenum attachment,
5530*8975f5c5SAndroid Build Coastguard Worker                                                  GLenum pname,
5531*8975f5c5SAndroid Build Coastguard Worker                                                  const GLint *params)
5532*8975f5c5SAndroid Build Coastguard Worker {
5533*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetFramebufferAttachmentParameterivBase(context, entryPoint, target, attachment,
5534*8975f5c5SAndroid Build Coastguard Worker                                                            pname, nullptr);
5535*8975f5c5SAndroid Build Coastguard Worker }
5536*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetProgramiv(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,GLenum pname,const GLint * params)5537*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetProgramiv(const Context *context,
5538*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
5539*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID program,
5540*8975f5c5SAndroid Build Coastguard Worker                           GLenum pname,
5541*8975f5c5SAndroid Build Coastguard Worker                           const GLint *params)
5542*8975f5c5SAndroid Build Coastguard Worker {
5543*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetProgramivBase(context, entryPoint, program, pname, nullptr);
5544*8975f5c5SAndroid Build Coastguard Worker }
5545*8975f5c5SAndroid Build Coastguard Worker 
ValidateCopyTexImage2D(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)5546*8975f5c5SAndroid Build Coastguard Worker bool ValidateCopyTexImage2D(const Context *context,
5547*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5548*8975f5c5SAndroid Build Coastguard Worker                             TextureTarget target,
5549*8975f5c5SAndroid Build Coastguard Worker                             GLint level,
5550*8975f5c5SAndroid Build Coastguard Worker                             GLenum internalformat,
5551*8975f5c5SAndroid Build Coastguard Worker                             GLint x,
5552*8975f5c5SAndroid Build Coastguard Worker                             GLint y,
5553*8975f5c5SAndroid Build Coastguard Worker                             GLsizei width,
5554*8975f5c5SAndroid Build Coastguard Worker                             GLsizei height,
5555*8975f5c5SAndroid Build Coastguard Worker                             GLint border)
5556*8975f5c5SAndroid Build Coastguard Worker {
5557*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
5558*8975f5c5SAndroid Build Coastguard Worker     {
5559*8975f5c5SAndroid Build Coastguard Worker         return ValidateES2CopyTexImageParameters(context, entryPoint, target, level, internalformat,
5560*8975f5c5SAndroid Build Coastguard Worker                                                  false, 0, 0, x, y, width, height, border);
5561*8975f5c5SAndroid Build Coastguard Worker     }
5562*8975f5c5SAndroid Build Coastguard Worker 
5563*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->getClientMajorVersion() == 3);
5564*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3CopyTexImage2DParameters(context, entryPoint, target, level, internalformat,
5565*8975f5c5SAndroid Build Coastguard Worker                                                false, 0, 0, 0, x, y, width, height, border);
5566*8975f5c5SAndroid Build Coastguard Worker }
5567*8975f5c5SAndroid Build Coastguard Worker 
ValidateCopyTexSubImage2D(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height)5568*8975f5c5SAndroid Build Coastguard Worker bool ValidateCopyTexSubImage2D(const Context *context,
5569*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
5570*8975f5c5SAndroid Build Coastguard Worker                                TextureTarget target,
5571*8975f5c5SAndroid Build Coastguard Worker                                GLint level,
5572*8975f5c5SAndroid Build Coastguard Worker                                GLint xoffset,
5573*8975f5c5SAndroid Build Coastguard Worker                                GLint yoffset,
5574*8975f5c5SAndroid Build Coastguard Worker                                GLint x,
5575*8975f5c5SAndroid Build Coastguard Worker                                GLint y,
5576*8975f5c5SAndroid Build Coastguard Worker                                GLsizei width,
5577*8975f5c5SAndroid Build Coastguard Worker                                GLsizei height)
5578*8975f5c5SAndroid Build Coastguard Worker {
5579*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
5580*8975f5c5SAndroid Build Coastguard Worker     {
5581*8975f5c5SAndroid Build Coastguard Worker         return ValidateES2CopyTexImageParameters(context, entryPoint, target, level, GL_NONE, true,
5582*8975f5c5SAndroid Build Coastguard Worker                                                  xoffset, yoffset, x, y, width, height, 0);
5583*8975f5c5SAndroid Build Coastguard Worker     }
5584*8975f5c5SAndroid Build Coastguard Worker 
5585*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3CopyTexImage2DParameters(context, entryPoint, target, level, GL_NONE, true,
5586*8975f5c5SAndroid Build Coastguard Worker                                                xoffset, yoffset, 0, x, y, width, height, 0);
5587*8975f5c5SAndroid Build Coastguard Worker }
5588*8975f5c5SAndroid Build Coastguard Worker 
ValidateCopyTexSubImage3DOES(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLsizei height)5589*8975f5c5SAndroid Build Coastguard Worker bool ValidateCopyTexSubImage3DOES(const Context *context,
5590*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
5591*8975f5c5SAndroid Build Coastguard Worker                                   TextureTarget target,
5592*8975f5c5SAndroid Build Coastguard Worker                                   GLint level,
5593*8975f5c5SAndroid Build Coastguard Worker                                   GLint xoffset,
5594*8975f5c5SAndroid Build Coastguard Worker                                   GLint yoffset,
5595*8975f5c5SAndroid Build Coastguard Worker                                   GLint zoffset,
5596*8975f5c5SAndroid Build Coastguard Worker                                   GLint x,
5597*8975f5c5SAndroid Build Coastguard Worker                                   GLint y,
5598*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei width,
5599*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei height)
5600*8975f5c5SAndroid Build Coastguard Worker {
5601*8975f5c5SAndroid Build Coastguard Worker     return ValidateCopyTexSubImage3D(context, entryPoint, target, level, xoffset, yoffset, zoffset,
5602*8975f5c5SAndroid Build Coastguard Worker                                      x, y, width, height);
5603*8975f5c5SAndroid Build Coastguard Worker }
5604*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteBuffers(const Context * context,angle::EntryPoint entryPoint,GLint n,const BufferID * buffers)5605*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteBuffers(const Context *context,
5606*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
5607*8975f5c5SAndroid Build Coastguard Worker                            GLint n,
5608*8975f5c5SAndroid Build Coastguard Worker                            const BufferID *buffers)
5609*8975f5c5SAndroid Build Coastguard Worker {
5610*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5611*8975f5c5SAndroid Build Coastguard Worker }
5612*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteFramebuffers(const Context * context,angle::EntryPoint entryPoint,GLint n,const FramebufferID * framebuffers)5613*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteFramebuffers(const Context *context,
5614*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
5615*8975f5c5SAndroid Build Coastguard Worker                                 GLint n,
5616*8975f5c5SAndroid Build Coastguard Worker                                 const FramebufferID *framebuffers)
5617*8975f5c5SAndroid Build Coastguard Worker {
5618*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5619*8975f5c5SAndroid Build Coastguard Worker }
5620*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteRenderbuffers(const Context * context,angle::EntryPoint entryPoint,GLint n,const RenderbufferID * renderbuffers)5621*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteRenderbuffers(const Context *context,
5622*8975f5c5SAndroid Build Coastguard Worker                                  angle::EntryPoint entryPoint,
5623*8975f5c5SAndroid Build Coastguard Worker                                  GLint n,
5624*8975f5c5SAndroid Build Coastguard Worker                                  const RenderbufferID *renderbuffers)
5625*8975f5c5SAndroid Build Coastguard Worker {
5626*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5627*8975f5c5SAndroid Build Coastguard Worker }
5628*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteTextures(const Context * context,angle::EntryPoint entryPoint,GLint n,const TextureID * textures)5629*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteTextures(const Context *context,
5630*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5631*8975f5c5SAndroid Build Coastguard Worker                             GLint n,
5632*8975f5c5SAndroid Build Coastguard Worker                             const TextureID *textures)
5633*8975f5c5SAndroid Build Coastguard Worker {
5634*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5635*8975f5c5SAndroid Build Coastguard Worker }
5636*8975f5c5SAndroid Build Coastguard Worker 
ValidateDisable(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum cap)5637*8975f5c5SAndroid Build Coastguard Worker bool ValidateDisable(const PrivateState &state,
5638*8975f5c5SAndroid Build Coastguard Worker                      ErrorSet *errors,
5639*8975f5c5SAndroid Build Coastguard Worker                      angle::EntryPoint entryPoint,
5640*8975f5c5SAndroid Build Coastguard Worker                      GLenum cap)
5641*8975f5c5SAndroid Build Coastguard Worker {
5642*8975f5c5SAndroid Build Coastguard Worker     if (!ValidCap(state, errors, cap, false))
5643*8975f5c5SAndroid Build Coastguard Worker     {
5644*8975f5c5SAndroid Build Coastguard Worker         errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, cap);
5645*8975f5c5SAndroid Build Coastguard Worker         return false;
5646*8975f5c5SAndroid Build Coastguard Worker     }
5647*8975f5c5SAndroid Build Coastguard Worker 
5648*8975f5c5SAndroid Build Coastguard Worker     if (state.getPixelLocalStorageActivePlanes() != 0)
5649*8975f5c5SAndroid Build Coastguard Worker     {
5650*8975f5c5SAndroid Build Coastguard Worker         if (IsCapBannedWithActivePLS(cap))
5651*8975f5c5SAndroid Build Coastguard Worker         {
5652*8975f5c5SAndroid Build Coastguard Worker             errors->validationErrorF(entryPoint, GL_INVALID_OPERATION, kPLSCapNotAllowed, cap);
5653*8975f5c5SAndroid Build Coastguard Worker             return false;
5654*8975f5c5SAndroid Build Coastguard Worker         }
5655*8975f5c5SAndroid Build Coastguard Worker     }
5656*8975f5c5SAndroid Build Coastguard Worker 
5657*8975f5c5SAndroid Build Coastguard Worker     return true;
5658*8975f5c5SAndroid Build Coastguard Worker }
5659*8975f5c5SAndroid Build Coastguard Worker 
ValidateEnable(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum cap)5660*8975f5c5SAndroid Build Coastguard Worker bool ValidateEnable(const PrivateState &state,
5661*8975f5c5SAndroid Build Coastguard Worker                     ErrorSet *errors,
5662*8975f5c5SAndroid Build Coastguard Worker                     angle::EntryPoint entryPoint,
5663*8975f5c5SAndroid Build Coastguard Worker                     GLenum cap)
5664*8975f5c5SAndroid Build Coastguard Worker {
5665*8975f5c5SAndroid Build Coastguard Worker     if (!ValidCap(state, errors, cap, false))
5666*8975f5c5SAndroid Build Coastguard Worker     {
5667*8975f5c5SAndroid Build Coastguard Worker         errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, cap);
5668*8975f5c5SAndroid Build Coastguard Worker         return false;
5669*8975f5c5SAndroid Build Coastguard Worker     }
5670*8975f5c5SAndroid Build Coastguard Worker 
5671*8975f5c5SAndroid Build Coastguard Worker     if (state.getLimitations().noSampleAlphaToCoverageSupport && cap == GL_SAMPLE_ALPHA_TO_COVERAGE)
5672*8975f5c5SAndroid Build Coastguard Worker     {
5673*8975f5c5SAndroid Build Coastguard Worker         errors->validationError(entryPoint, GL_INVALID_OPERATION,
5674*8975f5c5SAndroid Build Coastguard Worker                                 kNoSampleAlphaToCoveragesLimitation);
5675*8975f5c5SAndroid Build Coastguard Worker 
5676*8975f5c5SAndroid Build Coastguard Worker         // We also output an error message to the debugger window if tracing is active, so that
5677*8975f5c5SAndroid Build Coastguard Worker         // developers can see the error message.
5678*8975f5c5SAndroid Build Coastguard Worker         ERR() << kNoSampleAlphaToCoveragesLimitation;
5679*8975f5c5SAndroid Build Coastguard Worker         return false;
5680*8975f5c5SAndroid Build Coastguard Worker     }
5681*8975f5c5SAndroid Build Coastguard Worker 
5682*8975f5c5SAndroid Build Coastguard Worker     if (state.getPixelLocalStorageActivePlanes() != 0)
5683*8975f5c5SAndroid Build Coastguard Worker     {
5684*8975f5c5SAndroid Build Coastguard Worker         if (IsCapBannedWithActivePLS(cap))
5685*8975f5c5SAndroid Build Coastguard Worker         {
5686*8975f5c5SAndroid Build Coastguard Worker             errors->validationErrorF(entryPoint, GL_INVALID_OPERATION, kPLSCapNotAllowed, cap);
5687*8975f5c5SAndroid Build Coastguard Worker             return false;
5688*8975f5c5SAndroid Build Coastguard Worker         }
5689*8975f5c5SAndroid Build Coastguard Worker     }
5690*8975f5c5SAndroid Build Coastguard Worker 
5691*8975f5c5SAndroid Build Coastguard Worker     return true;
5692*8975f5c5SAndroid Build Coastguard Worker }
5693*8975f5c5SAndroid Build Coastguard Worker 
ValidateFramebufferRenderbuffer(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum attachment,GLenum renderbuffertarget,RenderbufferID renderbuffer)5694*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferRenderbuffer(const Context *context,
5695*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
5696*8975f5c5SAndroid Build Coastguard Worker                                      GLenum target,
5697*8975f5c5SAndroid Build Coastguard Worker                                      GLenum attachment,
5698*8975f5c5SAndroid Build Coastguard Worker                                      GLenum renderbuffertarget,
5699*8975f5c5SAndroid Build Coastguard Worker                                      RenderbufferID renderbuffer)
5700*8975f5c5SAndroid Build Coastguard Worker {
5701*8975f5c5SAndroid Build Coastguard Worker     return ValidateFramebufferRenderbufferBase(context, entryPoint, target, attachment,
5702*8975f5c5SAndroid Build Coastguard Worker                                                renderbuffertarget, renderbuffer);
5703*8975f5c5SAndroid Build Coastguard Worker }
5704*8975f5c5SAndroid Build Coastguard Worker 
ValidateFramebufferTexture2D(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum attachment,TextureTarget textarget,TextureID texture,GLint level)5705*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferTexture2D(const Context *context,
5706*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
5707*8975f5c5SAndroid Build Coastguard Worker                                   GLenum target,
5708*8975f5c5SAndroid Build Coastguard Worker                                   GLenum attachment,
5709*8975f5c5SAndroid Build Coastguard Worker                                   TextureTarget textarget,
5710*8975f5c5SAndroid Build Coastguard Worker                                   TextureID texture,
5711*8975f5c5SAndroid Build Coastguard Worker                                   GLint level)
5712*8975f5c5SAndroid Build Coastguard Worker {
5713*8975f5c5SAndroid Build Coastguard Worker     // Attachments are required to be bound to level 0 without ES3 or the GL_OES_fbo_render_mipmap
5714*8975f5c5SAndroid Build Coastguard Worker     // extension
5715*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3 && !context->getExtensions().fboRenderMipmapOES &&
5716*8975f5c5SAndroid Build Coastguard Worker         level != 0)
5717*8975f5c5SAndroid Build Coastguard Worker     {
5718*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidFramebufferTextureLevel);
5719*8975f5c5SAndroid Build Coastguard Worker         return false;
5720*8975f5c5SAndroid Build Coastguard Worker     }
5721*8975f5c5SAndroid Build Coastguard Worker 
5722*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateFramebufferTextureBase(context, entryPoint, target, attachment, texture, level))
5723*8975f5c5SAndroid Build Coastguard Worker     {
5724*8975f5c5SAndroid Build Coastguard Worker         return false;
5725*8975f5c5SAndroid Build Coastguard Worker     }
5726*8975f5c5SAndroid Build Coastguard Worker 
5727*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
5728*8975f5c5SAndroid Build Coastguard Worker     {
5729*8975f5c5SAndroid Build Coastguard Worker         Texture *tex = context->getTexture(texture);
5730*8975f5c5SAndroid Build Coastguard Worker         ASSERT(tex);
5731*8975f5c5SAndroid Build Coastguard Worker 
5732*8975f5c5SAndroid Build Coastguard Worker         const Caps &caps = context->getCaps();
5733*8975f5c5SAndroid Build Coastguard Worker 
5734*8975f5c5SAndroid Build Coastguard Worker         switch (textarget)
5735*8975f5c5SAndroid Build Coastguard Worker         {
5736*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::_2D:
5737*8975f5c5SAndroid Build Coastguard Worker             {
5738*8975f5c5SAndroid Build Coastguard Worker                 if (level > log2(caps.max2DTextureSize))
5739*8975f5c5SAndroid Build Coastguard Worker                 {
5740*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
5741*8975f5c5SAndroid Build Coastguard Worker                     return false;
5742*8975f5c5SAndroid Build Coastguard Worker                 }
5743*8975f5c5SAndroid Build Coastguard Worker                 if (tex->getType() != TextureType::_2D)
5744*8975f5c5SAndroid Build Coastguard Worker                 {
5745*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureTarget);
5746*8975f5c5SAndroid Build Coastguard Worker                     return false;
5747*8975f5c5SAndroid Build Coastguard Worker                 }
5748*8975f5c5SAndroid Build Coastguard Worker             }
5749*8975f5c5SAndroid Build Coastguard Worker             break;
5750*8975f5c5SAndroid Build Coastguard Worker 
5751*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::Rectangle:
5752*8975f5c5SAndroid Build Coastguard Worker             {
5753*8975f5c5SAndroid Build Coastguard Worker                 if (level != 0)
5754*8975f5c5SAndroid Build Coastguard Worker                 {
5755*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
5756*8975f5c5SAndroid Build Coastguard Worker                     return false;
5757*8975f5c5SAndroid Build Coastguard Worker                 }
5758*8975f5c5SAndroid Build Coastguard Worker                 if (tex->getType() != TextureType::Rectangle)
5759*8975f5c5SAndroid Build Coastguard Worker                 {
5760*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTextureTargetMismatch);
5761*8975f5c5SAndroid Build Coastguard Worker                     return false;
5762*8975f5c5SAndroid Build Coastguard Worker                 }
5763*8975f5c5SAndroid Build Coastguard Worker             }
5764*8975f5c5SAndroid Build Coastguard Worker             break;
5765*8975f5c5SAndroid Build Coastguard Worker 
5766*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::CubeMapNegativeX:
5767*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::CubeMapNegativeY:
5768*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::CubeMapNegativeZ:
5769*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::CubeMapPositiveX:
5770*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::CubeMapPositiveY:
5771*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::CubeMapPositiveZ:
5772*8975f5c5SAndroid Build Coastguard Worker             {
5773*8975f5c5SAndroid Build Coastguard Worker                 if (level > log2(caps.maxCubeMapTextureSize))
5774*8975f5c5SAndroid Build Coastguard Worker                 {
5775*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
5776*8975f5c5SAndroid Build Coastguard Worker                     return false;
5777*8975f5c5SAndroid Build Coastguard Worker                 }
5778*8975f5c5SAndroid Build Coastguard Worker                 if (tex->getType() != TextureType::CubeMap)
5779*8975f5c5SAndroid Build Coastguard Worker                 {
5780*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTextureTargetMismatch);
5781*8975f5c5SAndroid Build Coastguard Worker                     return false;
5782*8975f5c5SAndroid Build Coastguard Worker                 }
5783*8975f5c5SAndroid Build Coastguard Worker             }
5784*8975f5c5SAndroid Build Coastguard Worker             break;
5785*8975f5c5SAndroid Build Coastguard Worker 
5786*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::_2DMultisample:
5787*8975f5c5SAndroid Build Coastguard Worker             {
5788*8975f5c5SAndroid Build Coastguard Worker                 if (context->getClientVersion() < ES_3_1 &&
5789*8975f5c5SAndroid Build Coastguard Worker                     !context->getExtensions().textureMultisampleANGLE)
5790*8975f5c5SAndroid Build Coastguard Worker                 {
5791*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION,
5792*8975f5c5SAndroid Build Coastguard Worker                                            kMultisampleTextureExtensionOrES31Required);
5793*8975f5c5SAndroid Build Coastguard Worker                     return false;
5794*8975f5c5SAndroid Build Coastguard Worker                 }
5795*8975f5c5SAndroid Build Coastguard Worker 
5796*8975f5c5SAndroid Build Coastguard Worker                 if (level != 0)
5797*8975f5c5SAndroid Build Coastguard Worker                 {
5798*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kLevelNotZero);
5799*8975f5c5SAndroid Build Coastguard Worker                     return false;
5800*8975f5c5SAndroid Build Coastguard Worker                 }
5801*8975f5c5SAndroid Build Coastguard Worker                 if (tex->getType() != TextureType::_2DMultisample)
5802*8975f5c5SAndroid Build Coastguard Worker                 {
5803*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTextureTargetMismatch);
5804*8975f5c5SAndroid Build Coastguard Worker                     return false;
5805*8975f5c5SAndroid Build Coastguard Worker                 }
5806*8975f5c5SAndroid Build Coastguard Worker             }
5807*8975f5c5SAndroid Build Coastguard Worker             break;
5808*8975f5c5SAndroid Build Coastguard Worker 
5809*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::External:
5810*8975f5c5SAndroid Build Coastguard Worker             {
5811*8975f5c5SAndroid Build Coastguard Worker                 if (!context->getExtensions().YUVTargetEXT)
5812*8975f5c5SAndroid Build Coastguard Worker                 {
5813*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kYUVTargetExtensionRequired);
5814*8975f5c5SAndroid Build Coastguard Worker                     return false;
5815*8975f5c5SAndroid Build Coastguard Worker                 }
5816*8975f5c5SAndroid Build Coastguard Worker 
5817*8975f5c5SAndroid Build Coastguard Worker                 if (attachment != GL_COLOR_ATTACHMENT0)
5818*8975f5c5SAndroid Build Coastguard Worker                 {
5819*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidAttachment);
5820*8975f5c5SAndroid Build Coastguard Worker                     return false;
5821*8975f5c5SAndroid Build Coastguard Worker                 }
5822*8975f5c5SAndroid Build Coastguard Worker 
5823*8975f5c5SAndroid Build Coastguard Worker                 if (tex->getType() != TextureType::External)
5824*8975f5c5SAndroid Build Coastguard Worker                 {
5825*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTextureTargetMismatch);
5826*8975f5c5SAndroid Build Coastguard Worker                     return false;
5827*8975f5c5SAndroid Build Coastguard Worker                 }
5828*8975f5c5SAndroid Build Coastguard Worker             }
5829*8975f5c5SAndroid Build Coastguard Worker             break;
5830*8975f5c5SAndroid Build Coastguard Worker 
5831*8975f5c5SAndroid Build Coastguard Worker             default:
5832*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
5833*8975f5c5SAndroid Build Coastguard Worker                 return false;
5834*8975f5c5SAndroid Build Coastguard Worker         }
5835*8975f5c5SAndroid Build Coastguard Worker     }
5836*8975f5c5SAndroid Build Coastguard Worker 
5837*8975f5c5SAndroid Build Coastguard Worker     return true;
5838*8975f5c5SAndroid Build Coastguard Worker }
5839*8975f5c5SAndroid Build Coastguard Worker 
ValidateFramebufferTexture3DOES(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum attachment,TextureTarget textargetPacked,TextureID texture,GLint level,GLint zoffset)5840*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferTexture3DOES(const Context *context,
5841*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
5842*8975f5c5SAndroid Build Coastguard Worker                                      GLenum target,
5843*8975f5c5SAndroid Build Coastguard Worker                                      GLenum attachment,
5844*8975f5c5SAndroid Build Coastguard Worker                                      TextureTarget textargetPacked,
5845*8975f5c5SAndroid Build Coastguard Worker                                      TextureID texture,
5846*8975f5c5SAndroid Build Coastguard Worker                                      GLint level,
5847*8975f5c5SAndroid Build Coastguard Worker                                      GLint zoffset)
5848*8975f5c5SAndroid Build Coastguard Worker {
5849*8975f5c5SAndroid Build Coastguard Worker     // We don't call into a base ValidateFramebufferTexture3D here because
5850*8975f5c5SAndroid Build Coastguard Worker     // it doesn't exist for OpenGL ES. This function is replaced by
5851*8975f5c5SAndroid Build Coastguard Worker     // FramebufferTextureLayer in ES 3.x, which has broader support.
5852*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().texture3DOES)
5853*8975f5c5SAndroid Build Coastguard Worker     {
5854*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
5855*8975f5c5SAndroid Build Coastguard Worker         return false;
5856*8975f5c5SAndroid Build Coastguard Worker     }
5857*8975f5c5SAndroid Build Coastguard Worker 
5858*8975f5c5SAndroid Build Coastguard Worker     // Attachments are required to be bound to level 0 without ES3 or the
5859*8975f5c5SAndroid Build Coastguard Worker     // GL_OES_fbo_render_mipmap extension
5860*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3 && !context->getExtensions().fboRenderMipmapOES &&
5861*8975f5c5SAndroid Build Coastguard Worker         level != 0)
5862*8975f5c5SAndroid Build Coastguard Worker     {
5863*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidFramebufferTextureLevel);
5864*8975f5c5SAndroid Build Coastguard Worker         return false;
5865*8975f5c5SAndroid Build Coastguard Worker     }
5866*8975f5c5SAndroid Build Coastguard Worker 
5867*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateFramebufferTextureBase(context, entryPoint, target, attachment, texture, level))
5868*8975f5c5SAndroid Build Coastguard Worker     {
5869*8975f5c5SAndroid Build Coastguard Worker         return false;
5870*8975f5c5SAndroid Build Coastguard Worker     }
5871*8975f5c5SAndroid Build Coastguard Worker 
5872*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
5873*8975f5c5SAndroid Build Coastguard Worker     {
5874*8975f5c5SAndroid Build Coastguard Worker         Texture *tex = context->getTexture(texture);
5875*8975f5c5SAndroid Build Coastguard Worker         ASSERT(tex);
5876*8975f5c5SAndroid Build Coastguard Worker 
5877*8975f5c5SAndroid Build Coastguard Worker         const Caps &caps = context->getCaps();
5878*8975f5c5SAndroid Build Coastguard Worker 
5879*8975f5c5SAndroid Build Coastguard Worker         switch (textargetPacked)
5880*8975f5c5SAndroid Build Coastguard Worker         {
5881*8975f5c5SAndroid Build Coastguard Worker             case TextureTarget::_3D:
5882*8975f5c5SAndroid Build Coastguard Worker             {
5883*8975f5c5SAndroid Build Coastguard Worker                 if (level > log2(caps.max3DTextureSize))
5884*8975f5c5SAndroid Build Coastguard Worker                 {
5885*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidMipLevel);
5886*8975f5c5SAndroid Build Coastguard Worker                     return false;
5887*8975f5c5SAndroid Build Coastguard Worker                 }
5888*8975f5c5SAndroid Build Coastguard Worker                 if (zoffset >= caps.max3DTextureSize)
5889*8975f5c5SAndroid Build Coastguard Worker                 {
5890*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidZOffset);
5891*8975f5c5SAndroid Build Coastguard Worker                     return false;
5892*8975f5c5SAndroid Build Coastguard Worker                 }
5893*8975f5c5SAndroid Build Coastguard Worker                 if (tex->getType() != TextureType::_3D)
5894*8975f5c5SAndroid Build Coastguard Worker                 {
5895*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureType);
5896*8975f5c5SAndroid Build Coastguard Worker                     return false;
5897*8975f5c5SAndroid Build Coastguard Worker                 }
5898*8975f5c5SAndroid Build Coastguard Worker             }
5899*8975f5c5SAndroid Build Coastguard Worker             break;
5900*8975f5c5SAndroid Build Coastguard Worker 
5901*8975f5c5SAndroid Build Coastguard Worker             default:
5902*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidTextureTarget);
5903*8975f5c5SAndroid Build Coastguard Worker                 return false;
5904*8975f5c5SAndroid Build Coastguard Worker         }
5905*8975f5c5SAndroid Build Coastguard Worker     }
5906*8975f5c5SAndroid Build Coastguard Worker 
5907*8975f5c5SAndroid Build Coastguard Worker     return true;
5908*8975f5c5SAndroid Build Coastguard Worker }
5909*8975f5c5SAndroid Build Coastguard Worker 
ValidateGenBuffers(const Context * context,angle::EntryPoint entryPoint,GLint n,const BufferID * buffers)5910*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenBuffers(const Context *context,
5911*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
5912*8975f5c5SAndroid Build Coastguard Worker                         GLint n,
5913*8975f5c5SAndroid Build Coastguard Worker                         const BufferID *buffers)
5914*8975f5c5SAndroid Build Coastguard Worker {
5915*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5916*8975f5c5SAndroid Build Coastguard Worker }
5917*8975f5c5SAndroid Build Coastguard Worker 
ValidateGenFramebuffers(const Context * context,angle::EntryPoint entryPoint,GLint n,const FramebufferID * framebuffers)5918*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenFramebuffers(const Context *context,
5919*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
5920*8975f5c5SAndroid Build Coastguard Worker                              GLint n,
5921*8975f5c5SAndroid Build Coastguard Worker                              const FramebufferID *framebuffers)
5922*8975f5c5SAndroid Build Coastguard Worker {
5923*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5924*8975f5c5SAndroid Build Coastguard Worker }
5925*8975f5c5SAndroid Build Coastguard Worker 
ValidateGenRenderbuffers(const Context * context,angle::EntryPoint entryPoint,GLint n,const RenderbufferID * renderbuffers)5926*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenRenderbuffers(const Context *context,
5927*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
5928*8975f5c5SAndroid Build Coastguard Worker                               GLint n,
5929*8975f5c5SAndroid Build Coastguard Worker                               const RenderbufferID *renderbuffers)
5930*8975f5c5SAndroid Build Coastguard Worker {
5931*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5932*8975f5c5SAndroid Build Coastguard Worker }
5933*8975f5c5SAndroid Build Coastguard Worker 
ValidateGenTextures(const Context * context,angle::EntryPoint entryPoint,GLint n,const TextureID * textures)5934*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenTextures(const Context *context,
5935*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
5936*8975f5c5SAndroid Build Coastguard Worker                          GLint n,
5937*8975f5c5SAndroid Build Coastguard Worker                          const TextureID *textures)
5938*8975f5c5SAndroid Build Coastguard Worker {
5939*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenOrDelete(context, entryPoint, n);
5940*8975f5c5SAndroid Build Coastguard Worker }
5941*8975f5c5SAndroid Build Coastguard Worker 
ValidateGenerateMipmap(const Context * context,angle::EntryPoint entryPoint,TextureType target)5942*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenerateMipmap(const Context *context,
5943*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
5944*8975f5c5SAndroid Build Coastguard Worker                             TextureType target)
5945*8975f5c5SAndroid Build Coastguard Worker {
5946*8975f5c5SAndroid Build Coastguard Worker     return ValidateGenerateMipmapBase(context, entryPoint, target);
5947*8975f5c5SAndroid Build Coastguard Worker }
5948*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetBufferParameteriv(const Context * context,angle::EntryPoint entryPoint,BufferBinding target,GLenum pname,const GLint * params)5949*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetBufferParameteriv(const Context *context,
5950*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
5951*8975f5c5SAndroid Build Coastguard Worker                                   BufferBinding target,
5952*8975f5c5SAndroid Build Coastguard Worker                                   GLenum pname,
5953*8975f5c5SAndroid Build Coastguard Worker                                   const GLint *params)
5954*8975f5c5SAndroid Build Coastguard Worker {
5955*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetBufferParameterBase(context, entryPoint, target, pname, false, nullptr);
5956*8975f5c5SAndroid Build Coastguard Worker }
5957*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetRenderbufferParameteriv(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum pname,const GLint * params)5958*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetRenderbufferParameteriv(const Context *context,
5959*8975f5c5SAndroid Build Coastguard Worker                                         angle::EntryPoint entryPoint,
5960*8975f5c5SAndroid Build Coastguard Worker                                         GLenum target,
5961*8975f5c5SAndroid Build Coastguard Worker                                         GLenum pname,
5962*8975f5c5SAndroid Build Coastguard Worker                                         const GLint *params)
5963*8975f5c5SAndroid Build Coastguard Worker {
5964*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetRenderbufferParameterivBase(context, entryPoint, target, pname, nullptr);
5965*8975f5c5SAndroid Build Coastguard Worker }
5966*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetShaderiv(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader,GLenum pname,const GLint * params)5967*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetShaderiv(const Context *context,
5968*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
5969*8975f5c5SAndroid Build Coastguard Worker                          ShaderProgramID shader,
5970*8975f5c5SAndroid Build Coastguard Worker                          GLenum pname,
5971*8975f5c5SAndroid Build Coastguard Worker                          const GLint *params)
5972*8975f5c5SAndroid Build Coastguard Worker {
5973*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetShaderivBase(context, entryPoint, shader, pname, nullptr);
5974*8975f5c5SAndroid Build Coastguard Worker }
5975*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetTexParameterfv(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLenum pname,const GLfloat * params)5976*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetTexParameterfv(const Context *context,
5977*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
5978*8975f5c5SAndroid Build Coastguard Worker                                TextureType target,
5979*8975f5c5SAndroid Build Coastguard Worker                                GLenum pname,
5980*8975f5c5SAndroid Build Coastguard Worker                                const GLfloat *params)
5981*8975f5c5SAndroid Build Coastguard Worker {
5982*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetTexParameterBase(context, entryPoint, target, pname, nullptr);
5983*8975f5c5SAndroid Build Coastguard Worker }
5984*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetTexParameteriv(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLenum pname,const GLint * params)5985*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetTexParameteriv(const Context *context,
5986*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
5987*8975f5c5SAndroid Build Coastguard Worker                                TextureType target,
5988*8975f5c5SAndroid Build Coastguard Worker                                GLenum pname,
5989*8975f5c5SAndroid Build Coastguard Worker                                const GLint *params)
5990*8975f5c5SAndroid Build Coastguard Worker {
5991*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetTexParameterBase(context, entryPoint, target, pname, nullptr);
5992*8975f5c5SAndroid Build Coastguard Worker }
5993*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetUniformfv(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,UniformLocation location,const GLfloat * params)5994*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetUniformfv(const Context *context,
5995*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
5996*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID program,
5997*8975f5c5SAndroid Build Coastguard Worker                           UniformLocation location,
5998*8975f5c5SAndroid Build Coastguard Worker                           const GLfloat *params)
5999*8975f5c5SAndroid Build Coastguard Worker {
6000*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetUniformBase(context, entryPoint, program, location);
6001*8975f5c5SAndroid Build Coastguard Worker }
6002*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetUniformiv(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program,UniformLocation location,const GLint * params)6003*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetUniformiv(const Context *context,
6004*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
6005*8975f5c5SAndroid Build Coastguard Worker                           ShaderProgramID program,
6006*8975f5c5SAndroid Build Coastguard Worker                           UniformLocation location,
6007*8975f5c5SAndroid Build Coastguard Worker                           const GLint *params)
6008*8975f5c5SAndroid Build Coastguard Worker {
6009*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetUniformBase(context, entryPoint, program, location);
6010*8975f5c5SAndroid Build Coastguard Worker }
6011*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetVertexAttribfv(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLenum pname,const GLfloat * params)6012*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetVertexAttribfv(const Context *context,
6013*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
6014*8975f5c5SAndroid Build Coastguard Worker                                GLuint index,
6015*8975f5c5SAndroid Build Coastguard Worker                                GLenum pname,
6016*8975f5c5SAndroid Build Coastguard Worker                                const GLfloat *params)
6017*8975f5c5SAndroid Build Coastguard Worker {
6018*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetVertexAttribBase(context, entryPoint, index, pname, nullptr, false, false);
6019*8975f5c5SAndroid Build Coastguard Worker }
6020*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetVertexAttribiv(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLenum pname,const GLint * params)6021*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetVertexAttribiv(const Context *context,
6022*8975f5c5SAndroid Build Coastguard Worker                                angle::EntryPoint entryPoint,
6023*8975f5c5SAndroid Build Coastguard Worker                                GLuint index,
6024*8975f5c5SAndroid Build Coastguard Worker                                GLenum pname,
6025*8975f5c5SAndroid Build Coastguard Worker                                const GLint *params)
6026*8975f5c5SAndroid Build Coastguard Worker {
6027*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetVertexAttribBase(context, entryPoint, index, pname, nullptr, false, false);
6028*8975f5c5SAndroid Build Coastguard Worker }
6029*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetVertexAttribPointerv(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLenum pname,void * const * pointer)6030*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetVertexAttribPointerv(const Context *context,
6031*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
6032*8975f5c5SAndroid Build Coastguard Worker                                      GLuint index,
6033*8975f5c5SAndroid Build Coastguard Worker                                      GLenum pname,
6034*8975f5c5SAndroid Build Coastguard Worker                                      void *const *pointer)
6035*8975f5c5SAndroid Build Coastguard Worker {
6036*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetVertexAttribBase(context, entryPoint, index, pname, nullptr, true, false);
6037*8975f5c5SAndroid Build Coastguard Worker }
6038*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsEnabled(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLenum cap)6039*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsEnabled(const PrivateState &state,
6040*8975f5c5SAndroid Build Coastguard Worker                        ErrorSet *errors,
6041*8975f5c5SAndroid Build Coastguard Worker                        angle::EntryPoint entryPoint,
6042*8975f5c5SAndroid Build Coastguard Worker                        GLenum cap)
6043*8975f5c5SAndroid Build Coastguard Worker {
6044*8975f5c5SAndroid Build Coastguard Worker     if (!ValidCap(state, errors, cap, true))
6045*8975f5c5SAndroid Build Coastguard Worker     {
6046*8975f5c5SAndroid Build Coastguard Worker         errors->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, cap);
6047*8975f5c5SAndroid Build Coastguard Worker         return false;
6048*8975f5c5SAndroid Build Coastguard Worker     }
6049*8975f5c5SAndroid Build Coastguard Worker 
6050*8975f5c5SAndroid Build Coastguard Worker     return true;
6051*8975f5c5SAndroid Build Coastguard Worker }
6052*8975f5c5SAndroid Build Coastguard Worker 
ValidateLinkProgram(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program)6053*8975f5c5SAndroid Build Coastguard Worker bool ValidateLinkProgram(const Context *context,
6054*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
6055*8975f5c5SAndroid Build Coastguard Worker                          ShaderProgramID program)
6056*8975f5c5SAndroid Build Coastguard Worker {
6057*8975f5c5SAndroid Build Coastguard Worker     if (context->hasActiveTransformFeedback(program))
6058*8975f5c5SAndroid Build Coastguard Worker     {
6059*8975f5c5SAndroid Build Coastguard Worker         // ES 3.0.4 section 2.15 page 91
6060*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTransformFeedbackActiveDuringLink);
6061*8975f5c5SAndroid Build Coastguard Worker         return false;
6062*8975f5c5SAndroid Build Coastguard Worker     }
6063*8975f5c5SAndroid Build Coastguard Worker 
6064*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = GetValidProgram(context, entryPoint, program);
6065*8975f5c5SAndroid Build Coastguard Worker     if (!programObject)
6066*8975f5c5SAndroid Build Coastguard Worker     {
6067*8975f5c5SAndroid Build Coastguard Worker         return false;
6068*8975f5c5SAndroid Build Coastguard Worker     }
6069*8975f5c5SAndroid Build Coastguard Worker 
6070*8975f5c5SAndroid Build Coastguard Worker     return true;
6071*8975f5c5SAndroid Build Coastguard Worker }
6072*8975f5c5SAndroid Build Coastguard Worker 
ValidateReadPixels(const Context * context,angle::EntryPoint entryPoint,GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,const void * pixels)6073*8975f5c5SAndroid Build Coastguard Worker bool ValidateReadPixels(const Context *context,
6074*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
6075*8975f5c5SAndroid Build Coastguard Worker                         GLint x,
6076*8975f5c5SAndroid Build Coastguard Worker                         GLint y,
6077*8975f5c5SAndroid Build Coastguard Worker                         GLsizei width,
6078*8975f5c5SAndroid Build Coastguard Worker                         GLsizei height,
6079*8975f5c5SAndroid Build Coastguard Worker                         GLenum format,
6080*8975f5c5SAndroid Build Coastguard Worker                         GLenum type,
6081*8975f5c5SAndroid Build Coastguard Worker                         const void *pixels)
6082*8975f5c5SAndroid Build Coastguard Worker {
6083*8975f5c5SAndroid Build Coastguard Worker     return ValidateReadPixelsBase(context, entryPoint, x, y, width, height, format, type, -1,
6084*8975f5c5SAndroid Build Coastguard Worker                                   nullptr, nullptr, nullptr, pixels);
6085*8975f5c5SAndroid Build Coastguard Worker }
6086*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexParameterf(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLenum pname,GLfloat param)6087*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexParameterf(const Context *context,
6088*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
6089*8975f5c5SAndroid Build Coastguard Worker                            TextureType target,
6090*8975f5c5SAndroid Build Coastguard Worker                            GLenum pname,
6091*8975f5c5SAndroid Build Coastguard Worker                            GLfloat param)
6092*8975f5c5SAndroid Build Coastguard Worker {
6093*8975f5c5SAndroid Build Coastguard Worker     return ValidateTexParameterBase(context, entryPoint, target, pname, -1, false, &param);
6094*8975f5c5SAndroid Build Coastguard Worker }
6095*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexParameterfv(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLenum pname,const GLfloat * params)6096*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexParameterfv(const Context *context,
6097*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
6098*8975f5c5SAndroid Build Coastguard Worker                             TextureType target,
6099*8975f5c5SAndroid Build Coastguard Worker                             GLenum pname,
6100*8975f5c5SAndroid Build Coastguard Worker                             const GLfloat *params)
6101*8975f5c5SAndroid Build Coastguard Worker {
6102*8975f5c5SAndroid Build Coastguard Worker     return ValidateTexParameterBase(context, entryPoint, target, pname, -1, true, params);
6103*8975f5c5SAndroid Build Coastguard Worker }
6104*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexParameteri(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLenum pname,GLint param)6105*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexParameteri(const Context *context,
6106*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
6107*8975f5c5SAndroid Build Coastguard Worker                            TextureType target,
6108*8975f5c5SAndroid Build Coastguard Worker                            GLenum pname,
6109*8975f5c5SAndroid Build Coastguard Worker                            GLint param)
6110*8975f5c5SAndroid Build Coastguard Worker {
6111*8975f5c5SAndroid Build Coastguard Worker     return ValidateTexParameterBase(context, entryPoint, target, pname, -1, false, &param);
6112*8975f5c5SAndroid Build Coastguard Worker }
6113*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexParameteriv(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLenum pname,const GLint * params)6114*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexParameteriv(const Context *context,
6115*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
6116*8975f5c5SAndroid Build Coastguard Worker                             TextureType target,
6117*8975f5c5SAndroid Build Coastguard Worker                             GLenum pname,
6118*8975f5c5SAndroid Build Coastguard Worker                             const GLint *params)
6119*8975f5c5SAndroid Build Coastguard Worker {
6120*8975f5c5SAndroid Build Coastguard Worker     return ValidateTexParameterBase(context, entryPoint, target, pname, -1, true, params);
6121*8975f5c5SAndroid Build Coastguard Worker }
6122*8975f5c5SAndroid Build Coastguard Worker 
ValidateUseProgram(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID program)6123*8975f5c5SAndroid Build Coastguard Worker bool ValidateUseProgram(const Context *context,
6124*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
6125*8975f5c5SAndroid Build Coastguard Worker                         ShaderProgramID program)
6126*8975f5c5SAndroid Build Coastguard Worker {
6127*8975f5c5SAndroid Build Coastguard Worker     if (program.value != 0)
6128*8975f5c5SAndroid Build Coastguard Worker     {
6129*8975f5c5SAndroid Build Coastguard Worker         Program *programObject = context->getProgramResolveLink(program);
6130*8975f5c5SAndroid Build Coastguard Worker         if (!programObject)
6131*8975f5c5SAndroid Build Coastguard Worker         {
6132*8975f5c5SAndroid Build Coastguard Worker             // ES 3.1.0 section 7.3 page 72
6133*8975f5c5SAndroid Build Coastguard Worker             if (context->getShaderNoResolveCompile(program))
6134*8975f5c5SAndroid Build Coastguard Worker             {
6135*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExpectedProgramName);
6136*8975f5c5SAndroid Build Coastguard Worker                 return false;
6137*8975f5c5SAndroid Build Coastguard Worker             }
6138*8975f5c5SAndroid Build Coastguard Worker             else
6139*8975f5c5SAndroid Build Coastguard Worker             {
6140*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kInvalidProgramName);
6141*8975f5c5SAndroid Build Coastguard Worker                 return false;
6142*8975f5c5SAndroid Build Coastguard Worker             }
6143*8975f5c5SAndroid Build Coastguard Worker         }
6144*8975f5c5SAndroid Build Coastguard Worker         if (!programObject->isLinked())
6145*8975f5c5SAndroid Build Coastguard Worker         {
6146*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kProgramNotLinked);
6147*8975f5c5SAndroid Build Coastguard Worker             return false;
6148*8975f5c5SAndroid Build Coastguard Worker         }
6149*8975f5c5SAndroid Build Coastguard Worker     }
6150*8975f5c5SAndroid Build Coastguard Worker     if (context->getState().isTransformFeedbackActiveUnpaused())
6151*8975f5c5SAndroid Build Coastguard Worker     {
6152*8975f5c5SAndroid Build Coastguard Worker         // ES 3.0.4 section 2.15 page 91
6153*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kTransformFeedbackUseProgram);
6154*8975f5c5SAndroid Build Coastguard Worker         return false;
6155*8975f5c5SAndroid Build Coastguard Worker     }
6156*8975f5c5SAndroid Build Coastguard Worker 
6157*8975f5c5SAndroid Build Coastguard Worker     return true;
6158*8975f5c5SAndroid Build Coastguard Worker }
6159*8975f5c5SAndroid Build Coastguard Worker 
ValidateDeleteFencesNV(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const FenceNVID * fences)6160*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteFencesNV(const Context *context,
6161*8975f5c5SAndroid Build Coastguard Worker                             angle::EntryPoint entryPoint,
6162*8975f5c5SAndroid Build Coastguard Worker                             GLsizei n,
6163*8975f5c5SAndroid Build Coastguard Worker                             const FenceNVID *fences)
6164*8975f5c5SAndroid Build Coastguard Worker {
6165*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().fenceNV)
6166*8975f5c5SAndroid Build Coastguard Worker     {
6167*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNVFenceNotSupported);
6168*8975f5c5SAndroid Build Coastguard Worker         return false;
6169*8975f5c5SAndroid Build Coastguard Worker     }
6170*8975f5c5SAndroid Build Coastguard Worker 
6171*8975f5c5SAndroid Build Coastguard Worker     if (n < 0)
6172*8975f5c5SAndroid Build Coastguard Worker     {
6173*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeCount);
6174*8975f5c5SAndroid Build Coastguard Worker         return false;
6175*8975f5c5SAndroid Build Coastguard Worker     }
6176*8975f5c5SAndroid Build Coastguard Worker 
6177*8975f5c5SAndroid Build Coastguard Worker     return true;
6178*8975f5c5SAndroid Build Coastguard Worker }
6179*8975f5c5SAndroid Build Coastguard Worker 
ValidateFinishFenceNV(const Context * context,angle::EntryPoint entryPoint,FenceNVID fence)6180*8975f5c5SAndroid Build Coastguard Worker bool ValidateFinishFenceNV(const Context *context, angle::EntryPoint entryPoint, FenceNVID fence)
6181*8975f5c5SAndroid Build Coastguard Worker {
6182*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().fenceNV)
6183*8975f5c5SAndroid Build Coastguard Worker     {
6184*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNVFenceNotSupported);
6185*8975f5c5SAndroid Build Coastguard Worker         return false;
6186*8975f5c5SAndroid Build Coastguard Worker     }
6187*8975f5c5SAndroid Build Coastguard Worker 
6188*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = context->getFenceNV(fence);
6189*8975f5c5SAndroid Build Coastguard Worker 
6190*8975f5c5SAndroid Build Coastguard Worker     if (fenceObject == nullptr)
6191*8975f5c5SAndroid Build Coastguard Worker     {
6192*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFence);
6193*8975f5c5SAndroid Build Coastguard Worker         return false;
6194*8975f5c5SAndroid Build Coastguard Worker     }
6195*8975f5c5SAndroid Build Coastguard Worker 
6196*8975f5c5SAndroid Build Coastguard Worker     if (!fenceObject->isSet())
6197*8975f5c5SAndroid Build Coastguard Worker     {
6198*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFenceState);
6199*8975f5c5SAndroid Build Coastguard Worker         return false;
6200*8975f5c5SAndroid Build Coastguard Worker     }
6201*8975f5c5SAndroid Build Coastguard Worker 
6202*8975f5c5SAndroid Build Coastguard Worker     return true;
6203*8975f5c5SAndroid Build Coastguard Worker }
6204*8975f5c5SAndroid Build Coastguard Worker 
ValidateGenFencesNV(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const FenceNVID * fences)6205*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenFencesNV(const Context *context,
6206*8975f5c5SAndroid Build Coastguard Worker                          angle::EntryPoint entryPoint,
6207*8975f5c5SAndroid Build Coastguard Worker                          GLsizei n,
6208*8975f5c5SAndroid Build Coastguard Worker                          const FenceNVID *fences)
6209*8975f5c5SAndroid Build Coastguard Worker {
6210*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().fenceNV)
6211*8975f5c5SAndroid Build Coastguard Worker     {
6212*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNVFenceNotSupported);
6213*8975f5c5SAndroid Build Coastguard Worker         return false;
6214*8975f5c5SAndroid Build Coastguard Worker     }
6215*8975f5c5SAndroid Build Coastguard Worker 
6216*8975f5c5SAndroid Build Coastguard Worker     if (n < 0)
6217*8975f5c5SAndroid Build Coastguard Worker     {
6218*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeCount);
6219*8975f5c5SAndroid Build Coastguard Worker         return false;
6220*8975f5c5SAndroid Build Coastguard Worker     }
6221*8975f5c5SAndroid Build Coastguard Worker 
6222*8975f5c5SAndroid Build Coastguard Worker     return true;
6223*8975f5c5SAndroid Build Coastguard Worker }
6224*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetFenceivNV(const Context * context,angle::EntryPoint entryPoint,FenceNVID fence,GLenum pname,const GLint * params)6225*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetFenceivNV(const Context *context,
6226*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint entryPoint,
6227*8975f5c5SAndroid Build Coastguard Worker                           FenceNVID fence,
6228*8975f5c5SAndroid Build Coastguard Worker                           GLenum pname,
6229*8975f5c5SAndroid Build Coastguard Worker                           const GLint *params)
6230*8975f5c5SAndroid Build Coastguard Worker {
6231*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().fenceNV)
6232*8975f5c5SAndroid Build Coastguard Worker     {
6233*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNVFenceNotSupported);
6234*8975f5c5SAndroid Build Coastguard Worker         return false;
6235*8975f5c5SAndroid Build Coastguard Worker     }
6236*8975f5c5SAndroid Build Coastguard Worker 
6237*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = context->getFenceNV(fence);
6238*8975f5c5SAndroid Build Coastguard Worker 
6239*8975f5c5SAndroid Build Coastguard Worker     if (fenceObject == nullptr)
6240*8975f5c5SAndroid Build Coastguard Worker     {
6241*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFence);
6242*8975f5c5SAndroid Build Coastguard Worker         return false;
6243*8975f5c5SAndroid Build Coastguard Worker     }
6244*8975f5c5SAndroid Build Coastguard Worker 
6245*8975f5c5SAndroid Build Coastguard Worker     if (!fenceObject->isSet())
6246*8975f5c5SAndroid Build Coastguard Worker     {
6247*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFenceState);
6248*8975f5c5SAndroid Build Coastguard Worker         return false;
6249*8975f5c5SAndroid Build Coastguard Worker     }
6250*8975f5c5SAndroid Build Coastguard Worker 
6251*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
6252*8975f5c5SAndroid Build Coastguard Worker     {
6253*8975f5c5SAndroid Build Coastguard Worker         case GL_FENCE_STATUS_NV:
6254*8975f5c5SAndroid Build Coastguard Worker         case GL_FENCE_CONDITION_NV:
6255*8975f5c5SAndroid Build Coastguard Worker             break;
6256*8975f5c5SAndroid Build Coastguard Worker 
6257*8975f5c5SAndroid Build Coastguard Worker         default:
6258*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidPname);
6259*8975f5c5SAndroid Build Coastguard Worker             return false;
6260*8975f5c5SAndroid Build Coastguard Worker     }
6261*8975f5c5SAndroid Build Coastguard Worker 
6262*8975f5c5SAndroid Build Coastguard Worker     return true;
6263*8975f5c5SAndroid Build Coastguard Worker }
6264*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetGraphicsResetStatusEXT(const Context * context,angle::EntryPoint entryPoint)6265*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetGraphicsResetStatusEXT(const Context *context, angle::EntryPoint entryPoint)
6266*8975f5c5SAndroid Build Coastguard Worker {
6267*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().robustnessEXT)
6268*8975f5c5SAndroid Build Coastguard Worker     {
6269*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6270*8975f5c5SAndroid Build Coastguard Worker         return false;
6271*8975f5c5SAndroid Build Coastguard Worker     }
6272*8975f5c5SAndroid Build Coastguard Worker 
6273*8975f5c5SAndroid Build Coastguard Worker     return true;
6274*8975f5c5SAndroid Build Coastguard Worker }
6275*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetTranslatedShaderSourceANGLE(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID shader,GLsizei bufsize,const GLsizei * length,const GLchar * source)6276*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetTranslatedShaderSourceANGLE(const Context *context,
6277*8975f5c5SAndroid Build Coastguard Worker                                             angle::EntryPoint entryPoint,
6278*8975f5c5SAndroid Build Coastguard Worker                                             ShaderProgramID shader,
6279*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei bufsize,
6280*8975f5c5SAndroid Build Coastguard Worker                                             const GLsizei *length,
6281*8975f5c5SAndroid Build Coastguard Worker                                             const GLchar *source)
6282*8975f5c5SAndroid Build Coastguard Worker {
6283*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().translatedShaderSourceANGLE)
6284*8975f5c5SAndroid Build Coastguard Worker     {
6285*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6286*8975f5c5SAndroid Build Coastguard Worker         return false;
6287*8975f5c5SAndroid Build Coastguard Worker     }
6288*8975f5c5SAndroid Build Coastguard Worker 
6289*8975f5c5SAndroid Build Coastguard Worker     if (bufsize < 0)
6290*8975f5c5SAndroid Build Coastguard Worker     {
6291*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kNegativeBufferSize);
6292*8975f5c5SAndroid Build Coastguard Worker         return false;
6293*8975f5c5SAndroid Build Coastguard Worker     }
6294*8975f5c5SAndroid Build Coastguard Worker 
6295*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = context->getShaderNoResolveCompile(shader);
6296*8975f5c5SAndroid Build Coastguard Worker 
6297*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
6298*8975f5c5SAndroid Build Coastguard Worker     {
6299*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidShaderName);
6300*8975f5c5SAndroid Build Coastguard Worker         return false;
6301*8975f5c5SAndroid Build Coastguard Worker     }
6302*8975f5c5SAndroid Build Coastguard Worker 
6303*8975f5c5SAndroid Build Coastguard Worker     return true;
6304*8975f5c5SAndroid Build Coastguard Worker }
6305*8975f5c5SAndroid Build Coastguard Worker 
ValidateIsFenceNV(const Context * context,angle::EntryPoint entryPoint,FenceNVID fence)6306*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsFenceNV(const Context *context, angle::EntryPoint entryPoint, FenceNVID fence)
6307*8975f5c5SAndroid Build Coastguard Worker {
6308*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().fenceNV)
6309*8975f5c5SAndroid Build Coastguard Worker     {
6310*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNVFenceNotSupported);
6311*8975f5c5SAndroid Build Coastguard Worker         return false;
6312*8975f5c5SAndroid Build Coastguard Worker     }
6313*8975f5c5SAndroid Build Coastguard Worker 
6314*8975f5c5SAndroid Build Coastguard Worker     return true;
6315*8975f5c5SAndroid Build Coastguard Worker }
6316*8975f5c5SAndroid Build Coastguard Worker 
ValidateSetFenceNV(const Context * context,angle::EntryPoint entryPoint,FenceNVID fence,GLenum condition)6317*8975f5c5SAndroid Build Coastguard Worker bool ValidateSetFenceNV(const Context *context,
6318*8975f5c5SAndroid Build Coastguard Worker                         angle::EntryPoint entryPoint,
6319*8975f5c5SAndroid Build Coastguard Worker                         FenceNVID fence,
6320*8975f5c5SAndroid Build Coastguard Worker                         GLenum condition)
6321*8975f5c5SAndroid Build Coastguard Worker {
6322*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().fenceNV)
6323*8975f5c5SAndroid Build Coastguard Worker     {
6324*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNVFenceNotSupported);
6325*8975f5c5SAndroid Build Coastguard Worker         return false;
6326*8975f5c5SAndroid Build Coastguard Worker     }
6327*8975f5c5SAndroid Build Coastguard Worker 
6328*8975f5c5SAndroid Build Coastguard Worker     if (condition != GL_ALL_COMPLETED_NV)
6329*8975f5c5SAndroid Build Coastguard Worker     {
6330*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidFenceCondition);
6331*8975f5c5SAndroid Build Coastguard Worker         return false;
6332*8975f5c5SAndroid Build Coastguard Worker     }
6333*8975f5c5SAndroid Build Coastguard Worker 
6334*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = context->getFenceNV(fence);
6335*8975f5c5SAndroid Build Coastguard Worker 
6336*8975f5c5SAndroid Build Coastguard Worker     if (fenceObject == nullptr)
6337*8975f5c5SAndroid Build Coastguard Worker     {
6338*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFence);
6339*8975f5c5SAndroid Build Coastguard Worker         return false;
6340*8975f5c5SAndroid Build Coastguard Worker     }
6341*8975f5c5SAndroid Build Coastguard Worker 
6342*8975f5c5SAndroid Build Coastguard Worker     return true;
6343*8975f5c5SAndroid Build Coastguard Worker }
6344*8975f5c5SAndroid Build Coastguard Worker 
ValidateTestFenceNV(const Context * context,angle::EntryPoint entryPoint,FenceNVID fence)6345*8975f5c5SAndroid Build Coastguard Worker bool ValidateTestFenceNV(const Context *context, angle::EntryPoint entryPoint, FenceNVID fence)
6346*8975f5c5SAndroid Build Coastguard Worker {
6347*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().fenceNV)
6348*8975f5c5SAndroid Build Coastguard Worker     {
6349*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kNVFenceNotSupported);
6350*8975f5c5SAndroid Build Coastguard Worker         return false;
6351*8975f5c5SAndroid Build Coastguard Worker     }
6352*8975f5c5SAndroid Build Coastguard Worker 
6353*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = context->getFenceNV(fence);
6354*8975f5c5SAndroid Build Coastguard Worker 
6355*8975f5c5SAndroid Build Coastguard Worker     if (fenceObject == nullptr)
6356*8975f5c5SAndroid Build Coastguard Worker     {
6357*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFence);
6358*8975f5c5SAndroid Build Coastguard Worker         return false;
6359*8975f5c5SAndroid Build Coastguard Worker     }
6360*8975f5c5SAndroid Build Coastguard Worker 
6361*8975f5c5SAndroid Build Coastguard Worker     if (fenceObject->isSet() != GL_TRUE)
6362*8975f5c5SAndroid Build Coastguard Worker     {
6363*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kInvalidFenceState);
6364*8975f5c5SAndroid Build Coastguard Worker         return false;
6365*8975f5c5SAndroid Build Coastguard Worker     }
6366*8975f5c5SAndroid Build Coastguard Worker 
6367*8975f5c5SAndroid Build Coastguard Worker     return true;
6368*8975f5c5SAndroid Build Coastguard Worker }
6369*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexStorage2DEXT(const Context * context,angle::EntryPoint entryPoint,TextureType type,GLsizei levels,GLenum internalformat,GLsizei width,GLsizei height)6370*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexStorage2DEXT(const Context *context,
6371*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
6372*8975f5c5SAndroid Build Coastguard Worker                              TextureType type,
6373*8975f5c5SAndroid Build Coastguard Worker                              GLsizei levels,
6374*8975f5c5SAndroid Build Coastguard Worker                              GLenum internalformat,
6375*8975f5c5SAndroid Build Coastguard Worker                              GLsizei width,
6376*8975f5c5SAndroid Build Coastguard Worker                              GLsizei height)
6377*8975f5c5SAndroid Build Coastguard Worker {
6378*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().textureStorageEXT)
6379*8975f5c5SAndroid Build Coastguard Worker     {
6380*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6381*8975f5c5SAndroid Build Coastguard Worker         return false;
6382*8975f5c5SAndroid Build Coastguard Worker     }
6383*8975f5c5SAndroid Build Coastguard Worker 
6384*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
6385*8975f5c5SAndroid Build Coastguard Worker     {
6386*8975f5c5SAndroid Build Coastguard Worker         return ValidateES2TexStorageParametersBase(context, entryPoint, type, levels,
6387*8975f5c5SAndroid Build Coastguard Worker                                                    internalformat, width, height);
6388*8975f5c5SAndroid Build Coastguard Worker     }
6389*8975f5c5SAndroid Build Coastguard Worker 
6390*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->getClientMajorVersion() >= 3);
6391*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3TexStorage2DParameters(context, entryPoint, type, levels, internalformat,
6392*8975f5c5SAndroid Build Coastguard Worker                                              width, height, 1);
6393*8975f5c5SAndroid Build Coastguard Worker }
6394*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttribDivisorANGLE(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLuint divisor)6395*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttribDivisorANGLE(const Context *context,
6396*8975f5c5SAndroid Build Coastguard Worker                                       angle::EntryPoint entryPoint,
6397*8975f5c5SAndroid Build Coastguard Worker                                       GLuint index,
6398*8975f5c5SAndroid Build Coastguard Worker                                       GLuint divisor)
6399*8975f5c5SAndroid Build Coastguard Worker {
6400*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().instancedArraysANGLE)
6401*8975f5c5SAndroid Build Coastguard Worker     {
6402*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6403*8975f5c5SAndroid Build Coastguard Worker         return false;
6404*8975f5c5SAndroid Build Coastguard Worker     }
6405*8975f5c5SAndroid Build Coastguard Worker 
6406*8975f5c5SAndroid Build Coastguard Worker     if (index >= static_cast<GLuint>(context->getCaps().maxVertexAttributes))
6407*8975f5c5SAndroid Build Coastguard Worker     {
6408*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute);
6409*8975f5c5SAndroid Build Coastguard Worker         return false;
6410*8975f5c5SAndroid Build Coastguard Worker     }
6411*8975f5c5SAndroid Build Coastguard Worker 
6412*8975f5c5SAndroid Build Coastguard Worker     if (context->getLimitations().attributeZeroRequiresZeroDivisorInEXT)
6413*8975f5c5SAndroid Build Coastguard Worker     {
6414*8975f5c5SAndroid Build Coastguard Worker         if (index == 0 && divisor != 0)
6415*8975f5c5SAndroid Build Coastguard Worker         {
6416*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kAttributeZeroRequiresDivisorLimitation);
6417*8975f5c5SAndroid Build Coastguard Worker 
6418*8975f5c5SAndroid Build Coastguard Worker             // We also output an error message to the debugger window if tracing is active, so
6419*8975f5c5SAndroid Build Coastguard Worker             // that developers can see the error message.
6420*8975f5c5SAndroid Build Coastguard Worker             ERR() << kAttributeZeroRequiresDivisorLimitation;
6421*8975f5c5SAndroid Build Coastguard Worker             return false;
6422*8975f5c5SAndroid Build Coastguard Worker         }
6423*8975f5c5SAndroid Build Coastguard Worker     }
6424*8975f5c5SAndroid Build Coastguard Worker 
6425*8975f5c5SAndroid Build Coastguard Worker     return true;
6426*8975f5c5SAndroid Build Coastguard Worker }
6427*8975f5c5SAndroid Build Coastguard Worker 
ValidateVertexAttribDivisorEXT(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLuint divisor)6428*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttribDivisorEXT(const Context *context,
6429*8975f5c5SAndroid Build Coastguard Worker                                     angle::EntryPoint entryPoint,
6430*8975f5c5SAndroid Build Coastguard Worker                                     GLuint index,
6431*8975f5c5SAndroid Build Coastguard Worker                                     GLuint divisor)
6432*8975f5c5SAndroid Build Coastguard Worker {
6433*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().instancedArraysEXT)
6434*8975f5c5SAndroid Build Coastguard Worker     {
6435*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6436*8975f5c5SAndroid Build Coastguard Worker         return false;
6437*8975f5c5SAndroid Build Coastguard Worker     }
6438*8975f5c5SAndroid Build Coastguard Worker 
6439*8975f5c5SAndroid Build Coastguard Worker     if (index >= static_cast<GLuint>(context->getCaps().maxVertexAttributes))
6440*8975f5c5SAndroid Build Coastguard Worker     {
6441*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute);
6442*8975f5c5SAndroid Build Coastguard Worker         return false;
6443*8975f5c5SAndroid Build Coastguard Worker     }
6444*8975f5c5SAndroid Build Coastguard Worker 
6445*8975f5c5SAndroid Build Coastguard Worker     return true;
6446*8975f5c5SAndroid Build Coastguard Worker }
6447*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexImage3DOES(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const void * pixels)6448*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexImage3DOES(const Context *context,
6449*8975f5c5SAndroid Build Coastguard Worker                            angle::EntryPoint entryPoint,
6450*8975f5c5SAndroid Build Coastguard Worker                            TextureTarget target,
6451*8975f5c5SAndroid Build Coastguard Worker                            GLint level,
6452*8975f5c5SAndroid Build Coastguard Worker                            GLenum internalformat,
6453*8975f5c5SAndroid Build Coastguard Worker                            GLsizei width,
6454*8975f5c5SAndroid Build Coastguard Worker                            GLsizei height,
6455*8975f5c5SAndroid Build Coastguard Worker                            GLsizei depth,
6456*8975f5c5SAndroid Build Coastguard Worker                            GLint border,
6457*8975f5c5SAndroid Build Coastguard Worker                            GLenum format,
6458*8975f5c5SAndroid Build Coastguard Worker                            GLenum type,
6459*8975f5c5SAndroid Build Coastguard Worker                            const void *pixels)
6460*8975f5c5SAndroid Build Coastguard Worker {
6461*8975f5c5SAndroid Build Coastguard Worker     return ValidateTexImage3D(context, entryPoint, target, level, internalformat, width, height,
6462*8975f5c5SAndroid Build Coastguard Worker                               depth, border, format, type, pixels);
6463*8975f5c5SAndroid Build Coastguard Worker }
6464*8975f5c5SAndroid Build Coastguard Worker 
ValidatePopGroupMarkerEXT(const Context * context,angle::EntryPoint entryPoint)6465*8975f5c5SAndroid Build Coastguard Worker bool ValidatePopGroupMarkerEXT(const Context *context, angle::EntryPoint entryPoint)
6466*8975f5c5SAndroid Build Coastguard Worker {
6467*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().debugMarkerEXT)
6468*8975f5c5SAndroid Build Coastguard Worker     {
6469*8975f5c5SAndroid Build Coastguard Worker         // The debug marker calls should not set error state
6470*8975f5c5SAndroid Build Coastguard Worker         // However, it seems reasonable to set an error state if the extension is not enabled
6471*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6472*8975f5c5SAndroid Build Coastguard Worker         return false;
6473*8975f5c5SAndroid Build Coastguard Worker     }
6474*8975f5c5SAndroid Build Coastguard Worker 
6475*8975f5c5SAndroid Build Coastguard Worker     return true;
6476*8975f5c5SAndroid Build Coastguard Worker }
6477*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexStorage1DEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLsizei levels,GLenum internalformat,GLsizei width)6478*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexStorage1DEXT(const Context *context,
6479*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
6480*8975f5c5SAndroid Build Coastguard Worker                              GLenum target,
6481*8975f5c5SAndroid Build Coastguard Worker                              GLsizei levels,
6482*8975f5c5SAndroid Build Coastguard Worker                              GLenum internalformat,
6483*8975f5c5SAndroid Build Coastguard Worker                              GLsizei width)
6484*8975f5c5SAndroid Build Coastguard Worker {
6485*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
6486*8975f5c5SAndroid Build Coastguard Worker     ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6487*8975f5c5SAndroid Build Coastguard Worker     return false;
6488*8975f5c5SAndroid Build Coastguard Worker }
6489*8975f5c5SAndroid Build Coastguard Worker 
ValidateTexStorage3DEXT(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLsizei levels,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth)6490*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexStorage3DEXT(const Context *context,
6491*8975f5c5SAndroid Build Coastguard Worker                              angle::EntryPoint entryPoint,
6492*8975f5c5SAndroid Build Coastguard Worker                              TextureType target,
6493*8975f5c5SAndroid Build Coastguard Worker                              GLsizei levels,
6494*8975f5c5SAndroid Build Coastguard Worker                              GLenum internalformat,
6495*8975f5c5SAndroid Build Coastguard Worker                              GLsizei width,
6496*8975f5c5SAndroid Build Coastguard Worker                              GLsizei height,
6497*8975f5c5SAndroid Build Coastguard Worker                              GLsizei depth)
6498*8975f5c5SAndroid Build Coastguard Worker {
6499*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().textureStorageEXT)
6500*8975f5c5SAndroid Build Coastguard Worker     {
6501*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6502*8975f5c5SAndroid Build Coastguard Worker         return false;
6503*8975f5c5SAndroid Build Coastguard Worker     }
6504*8975f5c5SAndroid Build Coastguard Worker 
6505*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() < 3)
6506*8975f5c5SAndroid Build Coastguard Worker     {
6507*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6508*8975f5c5SAndroid Build Coastguard Worker         return false;
6509*8975f5c5SAndroid Build Coastguard Worker     }
6510*8975f5c5SAndroid Build Coastguard Worker 
6511*8975f5c5SAndroid Build Coastguard Worker     return ValidateES3TexStorage3DParameters(context, entryPoint, target, levels, internalformat,
6512*8975f5c5SAndroid Build Coastguard Worker                                              width, height, depth);
6513*8975f5c5SAndroid Build Coastguard Worker }
6514*8975f5c5SAndroid Build Coastguard Worker 
ValidateMaxShaderCompilerThreadsKHR(const Context * context,angle::EntryPoint entryPoint,GLuint count)6515*8975f5c5SAndroid Build Coastguard Worker bool ValidateMaxShaderCompilerThreadsKHR(const Context *context,
6516*8975f5c5SAndroid Build Coastguard Worker                                          angle::EntryPoint entryPoint,
6517*8975f5c5SAndroid Build Coastguard Worker                                          GLuint count)
6518*8975f5c5SAndroid Build Coastguard Worker {
6519*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().parallelShaderCompileKHR)
6520*8975f5c5SAndroid Build Coastguard Worker     {
6521*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6522*8975f5c5SAndroid Build Coastguard Worker         return false;
6523*8975f5c5SAndroid Build Coastguard Worker     }
6524*8975f5c5SAndroid Build Coastguard Worker     return true;
6525*8975f5c5SAndroid Build Coastguard Worker }
6526*8975f5c5SAndroid Build Coastguard Worker 
ValidateMultiDrawArraysANGLE(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,const GLint * firsts,const GLsizei * counts,GLsizei drawcount)6527*8975f5c5SAndroid Build Coastguard Worker bool ValidateMultiDrawArraysANGLE(const Context *context,
6528*8975f5c5SAndroid Build Coastguard Worker                                   angle::EntryPoint entryPoint,
6529*8975f5c5SAndroid Build Coastguard Worker                                   PrimitiveMode mode,
6530*8975f5c5SAndroid Build Coastguard Worker                                   const GLint *firsts,
6531*8975f5c5SAndroid Build Coastguard Worker                                   const GLsizei *counts,
6532*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei drawcount)
6533*8975f5c5SAndroid Build Coastguard Worker {
6534*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().multiDrawANGLE)
6535*8975f5c5SAndroid Build Coastguard Worker     {
6536*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6537*8975f5c5SAndroid Build Coastguard Worker         return false;
6538*8975f5c5SAndroid Build Coastguard Worker     }
6539*8975f5c5SAndroid Build Coastguard Worker     for (GLsizei drawID = 0; drawID < drawcount; ++drawID)
6540*8975f5c5SAndroid Build Coastguard Worker     {
6541*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateDrawArrays(context, entryPoint, mode, firsts[drawID], counts[drawID]))
6542*8975f5c5SAndroid Build Coastguard Worker         {
6543*8975f5c5SAndroid Build Coastguard Worker             return false;
6544*8975f5c5SAndroid Build Coastguard Worker         }
6545*8975f5c5SAndroid Build Coastguard Worker     }
6546*8975f5c5SAndroid Build Coastguard Worker     return true;
6547*8975f5c5SAndroid Build Coastguard Worker }
6548*8975f5c5SAndroid Build Coastguard Worker 
ValidateMultiDrawElementsANGLE(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,const GLsizei * counts,DrawElementsType type,const GLvoid * const * indices,GLsizei drawcount)6549*8975f5c5SAndroid Build Coastguard Worker bool ValidateMultiDrawElementsANGLE(const Context *context,
6550*8975f5c5SAndroid Build Coastguard Worker                                     angle::EntryPoint entryPoint,
6551*8975f5c5SAndroid Build Coastguard Worker                                     PrimitiveMode mode,
6552*8975f5c5SAndroid Build Coastguard Worker                                     const GLsizei *counts,
6553*8975f5c5SAndroid Build Coastguard Worker                                     DrawElementsType type,
6554*8975f5c5SAndroid Build Coastguard Worker                                     const GLvoid *const *indices,
6555*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei drawcount)
6556*8975f5c5SAndroid Build Coastguard Worker {
6557*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().multiDrawANGLE)
6558*8975f5c5SAndroid Build Coastguard Worker     {
6559*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6560*8975f5c5SAndroid Build Coastguard Worker         return false;
6561*8975f5c5SAndroid Build Coastguard Worker     }
6562*8975f5c5SAndroid Build Coastguard Worker     for (GLsizei drawID = 0; drawID < drawcount; ++drawID)
6563*8975f5c5SAndroid Build Coastguard Worker     {
6564*8975f5c5SAndroid Build Coastguard Worker         if (!ValidateDrawElements(context, entryPoint, mode, counts[drawID], type, indices[drawID]))
6565*8975f5c5SAndroid Build Coastguard Worker         {
6566*8975f5c5SAndroid Build Coastguard Worker             return false;
6567*8975f5c5SAndroid Build Coastguard Worker         }
6568*8975f5c5SAndroid Build Coastguard Worker     }
6569*8975f5c5SAndroid Build Coastguard Worker     return true;
6570*8975f5c5SAndroid Build Coastguard Worker }
6571*8975f5c5SAndroid Build Coastguard Worker 
ValidateFramebufferTexture2DMultisampleEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum attachment,TextureTarget textarget,TextureID texture,GLint level,GLsizei samples)6572*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferTexture2DMultisampleEXT(const Context *context,
6573*8975f5c5SAndroid Build Coastguard Worker                                                 angle::EntryPoint entryPoint,
6574*8975f5c5SAndroid Build Coastguard Worker                                                 GLenum target,
6575*8975f5c5SAndroid Build Coastguard Worker                                                 GLenum attachment,
6576*8975f5c5SAndroid Build Coastguard Worker                                                 TextureTarget textarget,
6577*8975f5c5SAndroid Build Coastguard Worker                                                 TextureID texture,
6578*8975f5c5SAndroid Build Coastguard Worker                                                 GLint level,
6579*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei samples)
6580*8975f5c5SAndroid Build Coastguard Worker {
6581*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().multisampledRenderToTextureEXT)
6582*8975f5c5SAndroid Build Coastguard Worker     {
6583*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6584*8975f5c5SAndroid Build Coastguard Worker         return false;
6585*8975f5c5SAndroid Build Coastguard Worker     }
6586*8975f5c5SAndroid Build Coastguard Worker 
6587*8975f5c5SAndroid Build Coastguard Worker     if (samples < 0)
6588*8975f5c5SAndroid Build Coastguard Worker     {
6589*8975f5c5SAndroid Build Coastguard Worker         return false;
6590*8975f5c5SAndroid Build Coastguard Worker     }
6591*8975f5c5SAndroid Build Coastguard Worker 
6592*8975f5c5SAndroid Build Coastguard Worker     // EXT_multisampled_render_to_texture states that the value of samples
6593*8975f5c5SAndroid Build Coastguard Worker     // must be less than or equal to MAX_SAMPLES_EXT (Context::getCaps().maxSamples)
6594*8975f5c5SAndroid Build Coastguard Worker     // otherwise GL_INVALID_VALUE is generated.
6595*8975f5c5SAndroid Build Coastguard Worker     if (samples > context->getCaps().maxSamples)
6596*8975f5c5SAndroid Build Coastguard Worker     {
6597*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kSamplesOutOfRange);
6598*8975f5c5SAndroid Build Coastguard Worker         return false;
6599*8975f5c5SAndroid Build Coastguard Worker     }
6600*8975f5c5SAndroid Build Coastguard Worker 
6601*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateFramebufferTextureBase(context, entryPoint, target, attachment, texture, level))
6602*8975f5c5SAndroid Build Coastguard Worker     {
6603*8975f5c5SAndroid Build Coastguard Worker         return false;
6604*8975f5c5SAndroid Build Coastguard Worker     }
6605*8975f5c5SAndroid Build Coastguard Worker 
6606*8975f5c5SAndroid Build Coastguard Worker     // EXT_multisampled_render_to_texture returns INVALID_OPERATION when a sample number higher than
6607*8975f5c5SAndroid Build Coastguard Worker     // the maximum sample number supported by this format is passed.
6608*8975f5c5SAndroid Build Coastguard Worker     // The TextureCaps::getMaxSamples method is only guarenteed to be valid when the context is ES3.
6609*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0 && context->getClientMajorVersion() >= 3)
6610*8975f5c5SAndroid Build Coastguard Worker     {
6611*8975f5c5SAndroid Build Coastguard Worker         Texture *tex                  = context->getTexture(texture);
6612*8975f5c5SAndroid Build Coastguard Worker         GLenum sizedInternalFormat    = tex->getFormat(textarget, level).info->sizedInternalFormat;
6613*8975f5c5SAndroid Build Coastguard Worker         const TextureCaps &formatCaps = context->getTextureCaps().get(sizedInternalFormat);
6614*8975f5c5SAndroid Build Coastguard Worker         if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
6615*8975f5c5SAndroid Build Coastguard Worker         {
6616*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kSamplesOutOfRange);
6617*8975f5c5SAndroid Build Coastguard Worker             return false;
6618*8975f5c5SAndroid Build Coastguard Worker         }
6619*8975f5c5SAndroid Build Coastguard Worker     }
6620*8975f5c5SAndroid Build Coastguard Worker 
6621*8975f5c5SAndroid Build Coastguard Worker     // Unless EXT_multisampled_render_to_texture2 is enabled, only color attachment 0 can be used.
6622*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().multisampledRenderToTexture2EXT &&
6623*8975f5c5SAndroid Build Coastguard Worker         attachment != GL_COLOR_ATTACHMENT0)
6624*8975f5c5SAndroid Build Coastguard Worker     {
6625*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidAttachment);
6626*8975f5c5SAndroid Build Coastguard Worker         return false;
6627*8975f5c5SAndroid Build Coastguard Worker     }
6628*8975f5c5SAndroid Build Coastguard Worker 
6629*8975f5c5SAndroid Build Coastguard Worker     if (!ValidTexture2DDestinationTarget(context, textarget))
6630*8975f5c5SAndroid Build Coastguard Worker     {
6631*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
6632*8975f5c5SAndroid Build Coastguard Worker         return false;
6633*8975f5c5SAndroid Build Coastguard Worker     }
6634*8975f5c5SAndroid Build Coastguard Worker 
6635*8975f5c5SAndroid Build Coastguard Worker     return true;
6636*8975f5c5SAndroid Build Coastguard Worker }
6637*8975f5c5SAndroid Build Coastguard Worker 
ValidateRenderbufferStorageMultisampleEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height)6638*8975f5c5SAndroid Build Coastguard Worker bool ValidateRenderbufferStorageMultisampleEXT(const Context *context,
6639*8975f5c5SAndroid Build Coastguard Worker                                                angle::EntryPoint entryPoint,
6640*8975f5c5SAndroid Build Coastguard Worker                                                GLenum target,
6641*8975f5c5SAndroid Build Coastguard Worker                                                GLsizei samples,
6642*8975f5c5SAndroid Build Coastguard Worker                                                GLenum internalformat,
6643*8975f5c5SAndroid Build Coastguard Worker                                                GLsizei width,
6644*8975f5c5SAndroid Build Coastguard Worker                                                GLsizei height)
6645*8975f5c5SAndroid Build Coastguard Worker {
6646*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().multisampledRenderToTextureEXT)
6647*8975f5c5SAndroid Build Coastguard Worker     {
6648*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6649*8975f5c5SAndroid Build Coastguard Worker         return false;
6650*8975f5c5SAndroid Build Coastguard Worker     }
6651*8975f5c5SAndroid Build Coastguard Worker     if (!ValidateRenderbufferStorageParametersBase(context, entryPoint, target, samples,
6652*8975f5c5SAndroid Build Coastguard Worker                                                    internalformat, width, height))
6653*8975f5c5SAndroid Build Coastguard Worker     {
6654*8975f5c5SAndroid Build Coastguard Worker         return false;
6655*8975f5c5SAndroid Build Coastguard Worker     }
6656*8975f5c5SAndroid Build Coastguard Worker 
6657*8975f5c5SAndroid Build Coastguard Worker     // EXT_multisampled_render_to_texture states that the value of samples
6658*8975f5c5SAndroid Build Coastguard Worker     // must be less than or equal to MAX_SAMPLES_EXT (Context::getCaps().maxSamples)
6659*8975f5c5SAndroid Build Coastguard Worker     // otherwise GL_INVALID_VALUE is generated.
6660*8975f5c5SAndroid Build Coastguard Worker     if (samples > context->getCaps().maxSamples)
6661*8975f5c5SAndroid Build Coastguard Worker     {
6662*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, kSamplesOutOfRange);
6663*8975f5c5SAndroid Build Coastguard Worker         return false;
6664*8975f5c5SAndroid Build Coastguard Worker     }
6665*8975f5c5SAndroid Build Coastguard Worker 
6666*8975f5c5SAndroid Build Coastguard Worker     // EXT_multisampled_render_to_texture returns GL_OUT_OF_MEMORY on failure to create
6667*8975f5c5SAndroid Build Coastguard Worker     // the specified storage. This is different than ES 3.0 in which a sample number higher
6668*8975f5c5SAndroid Build Coastguard Worker     // than the maximum sample number supported by this format generates a GL_INVALID_VALUE.
6669*8975f5c5SAndroid Build Coastguard Worker     // The TextureCaps::getMaxSamples method is only guarenteed to be valid when the context is ES3.
6670*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() >= 3)
6671*8975f5c5SAndroid Build Coastguard Worker     {
6672*8975f5c5SAndroid Build Coastguard Worker         const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
6673*8975f5c5SAndroid Build Coastguard Worker         if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
6674*8975f5c5SAndroid Build Coastguard Worker         {
6675*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_OUT_OF_MEMORY, kSamplesOutOfRange);
6676*8975f5c5SAndroid Build Coastguard Worker             return false;
6677*8975f5c5SAndroid Build Coastguard Worker         }
6678*8975f5c5SAndroid Build Coastguard Worker     }
6679*8975f5c5SAndroid Build Coastguard Worker 
6680*8975f5c5SAndroid Build Coastguard Worker     return true;
6681*8975f5c5SAndroid Build Coastguard Worker }
6682*8975f5c5SAndroid Build Coastguard Worker 
ValidateBlobCacheCallbacksANGLE(const Context * context,angle::EntryPoint entryPoint,GLSETBLOBPROCANGLE set,GLGETBLOBPROCANGLE get,const void * userParam)6683*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlobCacheCallbacksANGLE(const Context *context,
6684*8975f5c5SAndroid Build Coastguard Worker                                      angle::EntryPoint entryPoint,
6685*8975f5c5SAndroid Build Coastguard Worker                                      GLSETBLOBPROCANGLE set,
6686*8975f5c5SAndroid Build Coastguard Worker                                      GLGETBLOBPROCANGLE get,
6687*8975f5c5SAndroid Build Coastguard Worker                                      const void *userParam)
6688*8975f5c5SAndroid Build Coastguard Worker {
6689*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().blobCacheANGLE)
6690*8975f5c5SAndroid Build Coastguard Worker     {
6691*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6692*8975f5c5SAndroid Build Coastguard Worker         return false;
6693*8975f5c5SAndroid Build Coastguard Worker     }
6694*8975f5c5SAndroid Build Coastguard Worker 
6695*8975f5c5SAndroid Build Coastguard Worker     if ((get == nullptr) != (set == nullptr))
6696*8975f5c5SAndroid Build Coastguard Worker     {
6697*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kBlobCacheCallbacksUnbalanced);
6698*8975f5c5SAndroid Build Coastguard Worker         return false;
6699*8975f5c5SAndroid Build Coastguard Worker     }
6700*8975f5c5SAndroid Build Coastguard Worker 
6701*8975f5c5SAndroid Build Coastguard Worker     return true;
6702*8975f5c5SAndroid Build Coastguard Worker }
6703*8975f5c5SAndroid Build Coastguard Worker 
ValidateGetPointervANGLE(const Context * context,angle::EntryPoint entryPoint,GLenum pname,void * const * params)6704*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetPointervANGLE(const Context *context,
6705*8975f5c5SAndroid Build Coastguard Worker                               angle::EntryPoint entryPoint,
6706*8975f5c5SAndroid Build Coastguard Worker                               GLenum pname,
6707*8975f5c5SAndroid Build Coastguard Worker                               void *const *params)
6708*8975f5c5SAndroid Build Coastguard Worker {
6709*8975f5c5SAndroid Build Coastguard Worker     if (!context->getExtensions().blobCacheANGLE)
6710*8975f5c5SAndroid Build Coastguard Worker     {
6711*8975f5c5SAndroid Build Coastguard Worker         ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kExtensionNotEnabled);
6712*8975f5c5SAndroid Build Coastguard Worker         return false;
6713*8975f5c5SAndroid Build Coastguard Worker     }
6714*8975f5c5SAndroid Build Coastguard Worker 
6715*8975f5c5SAndroid Build Coastguard Worker     return ValidateGetPointerv(context, entryPoint, pname, params);
6716*8975f5c5SAndroid Build Coastguard Worker }
6717*8975f5c5SAndroid Build Coastguard Worker 
RecordBindTextureTypeError(const Context * context,angle::EntryPoint entryPoint,TextureType target)6718*8975f5c5SAndroid Build Coastguard Worker void RecordBindTextureTypeError(const Context *context,
6719*8975f5c5SAndroid Build Coastguard Worker                                 angle::EntryPoint entryPoint,
6720*8975f5c5SAndroid Build Coastguard Worker                                 TextureType target)
6721*8975f5c5SAndroid Build Coastguard Worker {
6722*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!context->getStateCache().isValidBindTextureType(target));
6723*8975f5c5SAndroid Build Coastguard Worker 
6724*8975f5c5SAndroid Build Coastguard Worker     switch (target)
6725*8975f5c5SAndroid Build Coastguard Worker     {
6726*8975f5c5SAndroid Build Coastguard Worker         case TextureType::Rectangle:
6727*8975f5c5SAndroid Build Coastguard Worker             ASSERT(!context->getExtensions().textureRectangleANGLE);
6728*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kTextureRectangleNotSupported);
6729*8975f5c5SAndroid Build Coastguard Worker             break;
6730*8975f5c5SAndroid Build Coastguard Worker 
6731*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_3D:
6732*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_2DArray:
6733*8975f5c5SAndroid Build Coastguard Worker             ASSERT(context->getClientMajorVersion() < 3);
6734*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kES3Required);
6735*8975f5c5SAndroid Build Coastguard Worker             break;
6736*8975f5c5SAndroid Build Coastguard Worker 
6737*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_2DMultisample:
6738*8975f5c5SAndroid Build Coastguard Worker             ASSERT(context->getClientVersion() < Version(3, 1) &&
6739*8975f5c5SAndroid Build Coastguard Worker                    !context->getExtensions().textureMultisampleANGLE);
6740*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kMultisampleTextureExtensionOrES31Required);
6741*8975f5c5SAndroid Build Coastguard Worker             break;
6742*8975f5c5SAndroid Build Coastguard Worker 
6743*8975f5c5SAndroid Build Coastguard Worker         case TextureType::_2DMultisampleArray:
6744*8975f5c5SAndroid Build Coastguard Worker             ASSERT(context->getClientVersion() < Version(3, 2) &&
6745*8975f5c5SAndroid Build Coastguard Worker                    !context->getExtensions().textureStorageMultisample2dArrayOES);
6746*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kMultisampleArrayExtensionOrES32Required);
6747*8975f5c5SAndroid Build Coastguard Worker             break;
6748*8975f5c5SAndroid Build Coastguard Worker 
6749*8975f5c5SAndroid Build Coastguard Worker         case TextureType::External:
6750*8975f5c5SAndroid Build Coastguard Worker             ASSERT(!context->getExtensions().EGLImageExternalOES &&
6751*8975f5c5SAndroid Build Coastguard Worker                    !context->getExtensions().EGLStreamConsumerExternalNV);
6752*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kExternalTextureNotSupported);
6753*8975f5c5SAndroid Build Coastguard Worker             break;
6754*8975f5c5SAndroid Build Coastguard Worker 
6755*8975f5c5SAndroid Build Coastguard Worker         case TextureType::VideoImage:
6756*8975f5c5SAndroid Build Coastguard Worker             ASSERT(!context->getExtensions().videoTextureWEBGL);
6757*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kExtensionNotEnabled);
6758*8975f5c5SAndroid Build Coastguard Worker             break;
6759*8975f5c5SAndroid Build Coastguard Worker 
6760*8975f5c5SAndroid Build Coastguard Worker         case TextureType::Buffer:
6761*8975f5c5SAndroid Build Coastguard Worker             ASSERT(!context->getExtensions().textureBufferOES &&
6762*8975f5c5SAndroid Build Coastguard Worker                    !context->getExtensions().textureBufferEXT);
6763*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kExtensionNotEnabled);
6764*8975f5c5SAndroid Build Coastguard Worker             break;
6765*8975f5c5SAndroid Build Coastguard Worker 
6766*8975f5c5SAndroid Build Coastguard Worker         default:
6767*8975f5c5SAndroid Build Coastguard Worker             ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidTextureTarget);
6768*8975f5c5SAndroid Build Coastguard Worker     }
6769*8975f5c5SAndroid Build Coastguard Worker }
6770*8975f5c5SAndroid Build Coastguard Worker 
6771*8975f5c5SAndroid Build Coastguard Worker }  // namespace gl
6772