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 // validationES.h: Validation functions for generic OpenGL ES entry point parameters
8*8975f5c5SAndroid Build Coastguard Worker
9*8975f5c5SAndroid Build Coastguard Worker #ifndef LIBANGLE_VALIDATION_ES_H_
10*8975f5c5SAndroid Build Coastguard Worker #define LIBANGLE_VALIDATION_ES_H_
11*8975f5c5SAndroid Build Coastguard Worker
12*8975f5c5SAndroid Build Coastguard Worker #include "common/PackedEnums.h"
13*8975f5c5SAndroid Build Coastguard Worker #include "common/mathutil.h"
14*8975f5c5SAndroid Build Coastguard Worker #include "common/utilities.h"
15*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Context.h"
16*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/ErrorStrings.h"
17*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Framebuffer.h"
18*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/VertexArray.h"
19*8975f5c5SAndroid Build Coastguard Worker
20*8975f5c5SAndroid Build Coastguard Worker #include <GLES2/gl2.h>
21*8975f5c5SAndroid Build Coastguard Worker #include <GLES3/gl3.h>
22*8975f5c5SAndroid Build Coastguard Worker #include <GLES3/gl31.h>
23*8975f5c5SAndroid Build Coastguard Worker
24*8975f5c5SAndroid Build Coastguard Worker namespace egl
25*8975f5c5SAndroid Build Coastguard Worker {
26*8975f5c5SAndroid Build Coastguard Worker class Display;
27*8975f5c5SAndroid Build Coastguard Worker class Image;
28*8975f5c5SAndroid Build Coastguard Worker } // namespace egl
29*8975f5c5SAndroid Build Coastguard Worker
30*8975f5c5SAndroid Build Coastguard Worker namespace gl
31*8975f5c5SAndroid Build Coastguard Worker {
32*8975f5c5SAndroid Build Coastguard Worker class Context;
33*8975f5c5SAndroid Build Coastguard Worker struct Format;
34*8975f5c5SAndroid Build Coastguard Worker class Framebuffer;
35*8975f5c5SAndroid Build Coastguard Worker struct LinkedUniform;
36*8975f5c5SAndroid Build Coastguard Worker class Program;
37*8975f5c5SAndroid Build Coastguard Worker class Shader;
38*8975f5c5SAndroid Build Coastguard Worker
39*8975f5c5SAndroid Build Coastguard Worker #define ANGLE_VALIDATION_ERROR(errorCode, message) \
40*8975f5c5SAndroid Build Coastguard Worker context->getMutableErrorSetForValidation()->validationError(entryPoint, errorCode, message)
41*8975f5c5SAndroid Build Coastguard Worker #define ANGLE_VALIDATION_ERRORF(errorCode, ...) \
42*8975f5c5SAndroid Build Coastguard Worker context->getMutableErrorSetForValidation()->validationErrorF(entryPoint, errorCode, __VA_ARGS__)
43*8975f5c5SAndroid Build Coastguard Worker
44*8975f5c5SAndroid Build Coastguard Worker void SetRobustLengthParam(const GLsizei *length, GLsizei value);
45*8975f5c5SAndroid Build Coastguard Worker bool ValidTextureTarget(const Context *context, TextureType type);
46*8975f5c5SAndroid Build Coastguard Worker bool ValidTexture2DTarget(const Context *context, TextureType type);
47*8975f5c5SAndroid Build Coastguard Worker bool ValidTexture3DTarget(const Context *context, TextureType target);
48*8975f5c5SAndroid Build Coastguard Worker bool ValidTextureExternalTarget(const Context *context, TextureType target);
49*8975f5c5SAndroid Build Coastguard Worker bool ValidTextureExternalTarget(const Context *context, TextureTarget target);
50*8975f5c5SAndroid Build Coastguard Worker bool ValidTexture2DDestinationTarget(const Context *context, TextureTarget target);
51*8975f5c5SAndroid Build Coastguard Worker bool ValidTexture3DDestinationTarget(const Context *context, TextureTarget target);
52*8975f5c5SAndroid Build Coastguard Worker bool ValidTexLevelDestinationTarget(const Context *context, TextureType type);
53*8975f5c5SAndroid Build Coastguard Worker bool ValidFramebufferTarget(const Context *context, GLenum target);
54*8975f5c5SAndroid Build Coastguard Worker bool ValidMipLevel(const Context *context, TextureType type, GLint level);
55*8975f5c5SAndroid Build Coastguard Worker bool ValidImageSizeParameters(const Context *context,
56*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
57*8975f5c5SAndroid Build Coastguard Worker TextureType target,
58*8975f5c5SAndroid Build Coastguard Worker GLint level,
59*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
60*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
61*8975f5c5SAndroid Build Coastguard Worker GLsizei depth,
62*8975f5c5SAndroid Build Coastguard Worker bool isSubImage);
63*8975f5c5SAndroid Build Coastguard Worker bool ValidCompressedImageSize(const Context *context,
64*8975f5c5SAndroid Build Coastguard Worker GLenum internalFormat,
65*8975f5c5SAndroid Build Coastguard Worker GLint level,
66*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
67*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
68*8975f5c5SAndroid Build Coastguard Worker GLsizei depth);
69*8975f5c5SAndroid Build Coastguard Worker bool ValidCompressedSubImageSize(const Context *context,
70*8975f5c5SAndroid Build Coastguard Worker GLenum internalFormat,
71*8975f5c5SAndroid Build Coastguard Worker GLint xoffset,
72*8975f5c5SAndroid Build Coastguard Worker GLint yoffset,
73*8975f5c5SAndroid Build Coastguard Worker GLint zoffset,
74*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
75*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
76*8975f5c5SAndroid Build Coastguard Worker GLsizei depth,
77*8975f5c5SAndroid Build Coastguard Worker size_t textureWidth,
78*8975f5c5SAndroid Build Coastguard Worker size_t textureHeight,
79*8975f5c5SAndroid Build Coastguard Worker size_t textureDepth);
80*8975f5c5SAndroid Build Coastguard Worker bool ValidImageDataSize(const Context *context,
81*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
82*8975f5c5SAndroid Build Coastguard Worker TextureType texType,
83*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
84*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
85*8975f5c5SAndroid Build Coastguard Worker GLsizei depth,
86*8975f5c5SAndroid Build Coastguard Worker GLenum format,
87*8975f5c5SAndroid Build Coastguard Worker GLenum type,
88*8975f5c5SAndroid Build Coastguard Worker const void *pixels,
89*8975f5c5SAndroid Build Coastguard Worker GLsizei imageSize);
90*8975f5c5SAndroid Build Coastguard Worker
91*8975f5c5SAndroid Build Coastguard Worker bool ValidQueryType(const Context *context, QueryType queryType);
92*8975f5c5SAndroid Build Coastguard Worker
93*8975f5c5SAndroid Build Coastguard Worker bool ValidateWebGLVertexAttribPointer(const Context *context,
94*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
95*8975f5c5SAndroid Build Coastguard Worker VertexAttribType type,
96*8975f5c5SAndroid Build Coastguard Worker GLboolean normalized,
97*8975f5c5SAndroid Build Coastguard Worker GLsizei stride,
98*8975f5c5SAndroid Build Coastguard Worker const void *ptr,
99*8975f5c5SAndroid Build Coastguard Worker bool pureInteger);
100*8975f5c5SAndroid Build Coastguard Worker
101*8975f5c5SAndroid Build Coastguard Worker // Returns valid program if id is a valid program name
102*8975f5c5SAndroid Build Coastguard Worker // Errors INVALID_OPERATION if valid shader is given and returns NULL
103*8975f5c5SAndroid Build Coastguard Worker // Errors INVALID_VALUE otherwise and returns NULL
104*8975f5c5SAndroid Build Coastguard Worker Program *GetValidProgram(const Context *context, angle::EntryPoint entryPoint, ShaderProgramID id);
105*8975f5c5SAndroid Build Coastguard Worker
106*8975f5c5SAndroid Build Coastguard Worker // Returns valid shader if id is a valid shader name
107*8975f5c5SAndroid Build Coastguard Worker // Errors INVALID_OPERATION if valid program is given and returns NULL
108*8975f5c5SAndroid Build Coastguard Worker // Errors INVALID_VALUE otherwise and returns NULL
109*8975f5c5SAndroid Build Coastguard Worker Shader *GetValidShader(const Context *context, angle::EntryPoint entryPoint, ShaderProgramID id);
110*8975f5c5SAndroid Build Coastguard Worker
111*8975f5c5SAndroid Build Coastguard Worker bool ValidateAttachmentTarget(const Context *context,
112*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
113*8975f5c5SAndroid Build Coastguard Worker GLenum attachment);
114*8975f5c5SAndroid Build Coastguard Worker
115*8975f5c5SAndroid Build Coastguard Worker bool ValidateBlitFramebufferParameters(const Context *context,
116*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
117*8975f5c5SAndroid Build Coastguard Worker GLint srcX0,
118*8975f5c5SAndroid Build Coastguard Worker GLint srcY0,
119*8975f5c5SAndroid Build Coastguard Worker GLint srcX1,
120*8975f5c5SAndroid Build Coastguard Worker GLint srcY1,
121*8975f5c5SAndroid Build Coastguard Worker GLint dstX0,
122*8975f5c5SAndroid Build Coastguard Worker GLint dstY0,
123*8975f5c5SAndroid Build Coastguard Worker GLint dstX1,
124*8975f5c5SAndroid Build Coastguard Worker GLint dstY1,
125*8975f5c5SAndroid Build Coastguard Worker GLbitfield mask,
126*8975f5c5SAndroid Build Coastguard Worker GLenum filter);
127*8975f5c5SAndroid Build Coastguard Worker
128*8975f5c5SAndroid Build Coastguard Worker bool ValidateBindFramebufferBase(const Context *context,
129*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
130*8975f5c5SAndroid Build Coastguard Worker GLenum target,
131*8975f5c5SAndroid Build Coastguard Worker FramebufferID framebuffer);
132*8975f5c5SAndroid Build Coastguard Worker bool ValidateBindRenderbufferBase(const Context *context,
133*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
134*8975f5c5SAndroid Build Coastguard Worker GLenum target,
135*8975f5c5SAndroid Build Coastguard Worker RenderbufferID renderbuffer);
136*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferParameteriBase(const Context *context,
137*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
138*8975f5c5SAndroid Build Coastguard Worker GLenum target,
139*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
140*8975f5c5SAndroid Build Coastguard Worker GLint param);
141*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferRenderbufferBase(const Context *context,
142*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
143*8975f5c5SAndroid Build Coastguard Worker GLenum target,
144*8975f5c5SAndroid Build Coastguard Worker GLenum attachment,
145*8975f5c5SAndroid Build Coastguard Worker GLenum renderbuffertarget,
146*8975f5c5SAndroid Build Coastguard Worker RenderbufferID renderbuffer);
147*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferTextureBase(const Context *context,
148*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
149*8975f5c5SAndroid Build Coastguard Worker GLenum target,
150*8975f5c5SAndroid Build Coastguard Worker GLenum attachment,
151*8975f5c5SAndroid Build Coastguard Worker TextureID texture,
152*8975f5c5SAndroid Build Coastguard Worker GLint level);
153*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenerateMipmapBase(const Context *context,
154*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
155*8975f5c5SAndroid Build Coastguard Worker TextureType target);
156*8975f5c5SAndroid Build Coastguard Worker
157*8975f5c5SAndroid Build Coastguard Worker bool ValidateRenderbufferStorageParametersBase(const Context *context,
158*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
159*8975f5c5SAndroid Build Coastguard Worker GLenum target,
160*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
161*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
162*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
163*8975f5c5SAndroid Build Coastguard Worker GLsizei height);
164*8975f5c5SAndroid Build Coastguard Worker
165*8975f5c5SAndroid Build Coastguard Worker bool ValidatePixelPack(const Context *context,
166*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
167*8975f5c5SAndroid Build Coastguard Worker GLenum format,
168*8975f5c5SAndroid Build Coastguard Worker GLenum type,
169*8975f5c5SAndroid Build Coastguard Worker GLint x,
170*8975f5c5SAndroid Build Coastguard Worker GLint y,
171*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
172*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
173*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
174*8975f5c5SAndroid Build Coastguard Worker GLsizei *length,
175*8975f5c5SAndroid Build Coastguard Worker const void *pixels);
176*8975f5c5SAndroid Build Coastguard Worker
177*8975f5c5SAndroid Build Coastguard Worker bool ValidateReadPixelsBase(const Context *context,
178*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
179*8975f5c5SAndroid Build Coastguard Worker GLint x,
180*8975f5c5SAndroid Build Coastguard Worker GLint y,
181*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
182*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
183*8975f5c5SAndroid Build Coastguard Worker GLenum format,
184*8975f5c5SAndroid Build Coastguard Worker GLenum type,
185*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
186*8975f5c5SAndroid Build Coastguard Worker GLsizei *length,
187*8975f5c5SAndroid Build Coastguard Worker GLsizei *columns,
188*8975f5c5SAndroid Build Coastguard Worker GLsizei *rows,
189*8975f5c5SAndroid Build Coastguard Worker const void *pixels);
190*8975f5c5SAndroid Build Coastguard Worker bool ValidateReadPixelsRobustANGLE(const Context *context,
191*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
192*8975f5c5SAndroid Build Coastguard Worker GLint x,
193*8975f5c5SAndroid Build Coastguard Worker GLint y,
194*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
195*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
196*8975f5c5SAndroid Build Coastguard Worker GLenum format,
197*8975f5c5SAndroid Build Coastguard Worker GLenum type,
198*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
199*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
200*8975f5c5SAndroid Build Coastguard Worker const GLsizei *columns,
201*8975f5c5SAndroid Build Coastguard Worker const GLsizei *rows,
202*8975f5c5SAndroid Build Coastguard Worker const void *pixels);
203*8975f5c5SAndroid Build Coastguard Worker bool ValidateReadnPixelsEXT(const Context *context,
204*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
205*8975f5c5SAndroid Build Coastguard Worker GLint x,
206*8975f5c5SAndroid Build Coastguard Worker GLint y,
207*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
208*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
209*8975f5c5SAndroid Build Coastguard Worker GLenum format,
210*8975f5c5SAndroid Build Coastguard Worker GLenum type,
211*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
212*8975f5c5SAndroid Build Coastguard Worker const void *pixels);
213*8975f5c5SAndroid Build Coastguard Worker bool ValidateReadnPixelsRobustANGLE(const Context *context,
214*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
215*8975f5c5SAndroid Build Coastguard Worker GLint x,
216*8975f5c5SAndroid Build Coastguard Worker GLint y,
217*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
218*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
219*8975f5c5SAndroid Build Coastguard Worker GLenum format,
220*8975f5c5SAndroid Build Coastguard Worker GLenum type,
221*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
222*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
223*8975f5c5SAndroid Build Coastguard Worker const GLsizei *columns,
224*8975f5c5SAndroid Build Coastguard Worker const GLsizei *rows,
225*8975f5c5SAndroid Build Coastguard Worker const void *data);
226*8975f5c5SAndroid Build Coastguard Worker
227*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenQueriesEXT(const Context *context,
228*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
229*8975f5c5SAndroid Build Coastguard Worker GLsizei n,
230*8975f5c5SAndroid Build Coastguard Worker const QueryID *ids);
231*8975f5c5SAndroid Build Coastguard Worker bool ValidateDeleteQueriesEXT(const Context *context,
232*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
233*8975f5c5SAndroid Build Coastguard Worker GLsizei n,
234*8975f5c5SAndroid Build Coastguard Worker const QueryID *ids);
235*8975f5c5SAndroid Build Coastguard Worker bool ValidateIsQueryEXT(const Context *context, angle::EntryPoint entryPoint, QueryID id);
236*8975f5c5SAndroid Build Coastguard Worker bool ValidateBeginQueryBase(const Context *context,
237*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
238*8975f5c5SAndroid Build Coastguard Worker QueryType target,
239*8975f5c5SAndroid Build Coastguard Worker QueryID id);
240*8975f5c5SAndroid Build Coastguard Worker bool ValidateBeginQueryEXT(const Context *context,
241*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
242*8975f5c5SAndroid Build Coastguard Worker QueryType target,
243*8975f5c5SAndroid Build Coastguard Worker QueryID id);
244*8975f5c5SAndroid Build Coastguard Worker bool ValidateEndQueryBase(const Context *context, angle::EntryPoint entryPoint, QueryType target);
245*8975f5c5SAndroid Build Coastguard Worker bool ValidateEndQueryEXT(const Context *context, angle::EntryPoint entryPoint, QueryType target);
246*8975f5c5SAndroid Build Coastguard Worker bool ValidateQueryCounterEXT(const Context *context,
247*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
248*8975f5c5SAndroid Build Coastguard Worker QueryID id,
249*8975f5c5SAndroid Build Coastguard Worker QueryType target);
250*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryivBase(const Context *context,
251*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
252*8975f5c5SAndroid Build Coastguard Worker QueryType target,
253*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
254*8975f5c5SAndroid Build Coastguard Worker GLsizei *numParams);
255*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryivEXT(const Context *context,
256*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
257*8975f5c5SAndroid Build Coastguard Worker QueryType target,
258*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
259*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
260*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryivRobustANGLE(const Context *context,
261*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
262*8975f5c5SAndroid Build Coastguard Worker QueryType target,
263*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
264*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
265*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
266*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
267*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjectValueBase(const Context *context,
268*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
269*8975f5c5SAndroid Build Coastguard Worker QueryID id,
270*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
271*8975f5c5SAndroid Build Coastguard Worker GLsizei *numParams);
272*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjectivEXT(const Context *context,
273*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
274*8975f5c5SAndroid Build Coastguard Worker QueryID id,
275*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
276*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
277*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjectivRobustANGLE(const Context *context,
278*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
279*8975f5c5SAndroid Build Coastguard Worker QueryID id,
280*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
281*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
282*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
283*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
284*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjectuivEXT(const Context *context,
285*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
286*8975f5c5SAndroid Build Coastguard Worker QueryID id,
287*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
288*8975f5c5SAndroid Build Coastguard Worker const GLuint *params);
289*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjectuivRobustANGLE(const Context *context,
290*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
291*8975f5c5SAndroid Build Coastguard Worker QueryID id,
292*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
293*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
294*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
295*8975f5c5SAndroid Build Coastguard Worker const GLuint *params);
296*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjecti64vEXT(const Context *context,
297*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
298*8975f5c5SAndroid Build Coastguard Worker QueryID id,
299*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
300*8975f5c5SAndroid Build Coastguard Worker GLint64 *params);
301*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjecti64vRobustANGLE(const Context *context,
302*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
303*8975f5c5SAndroid Build Coastguard Worker QueryID id,
304*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
305*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
306*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
307*8975f5c5SAndroid Build Coastguard Worker GLint64 *params);
308*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjectui64vEXT(const Context *context,
309*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
310*8975f5c5SAndroid Build Coastguard Worker QueryID id,
311*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
312*8975f5c5SAndroid Build Coastguard Worker GLuint64 *params);
313*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetQueryObjectui64vRobustANGLE(const Context *context,
314*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
315*8975f5c5SAndroid Build Coastguard Worker QueryID id,
316*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
317*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
318*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
319*8975f5c5SAndroid Build Coastguard Worker GLuint64 *params);
320*8975f5c5SAndroid Build Coastguard Worker
321*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniformCommonBase(const Context *context,
322*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
323*8975f5c5SAndroid Build Coastguard Worker const Program *program,
324*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
325*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
326*8975f5c5SAndroid Build Coastguard Worker const LinkedUniform **uniformOut);
327*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform1ivValue(const Context *context,
328*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
329*8975f5c5SAndroid Build Coastguard Worker GLenum uniformType,
330*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
331*8975f5c5SAndroid Build Coastguard Worker const GLint *value);
332*8975f5c5SAndroid Build Coastguard Worker
ValidateUniformValue(const Context * context,angle::EntryPoint entryPoint,GLenum valueType,GLenum uniformType)333*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateUniformValue(const Context *context,
334*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
335*8975f5c5SAndroid Build Coastguard Worker GLenum valueType,
336*8975f5c5SAndroid Build Coastguard Worker GLenum uniformType)
337*8975f5c5SAndroid Build Coastguard Worker {
338*8975f5c5SAndroid Build Coastguard Worker // Check that the value type is compatible with uniform type.
339*8975f5c5SAndroid Build Coastguard Worker // Do the cheaper test first, for a little extra speed.
340*8975f5c5SAndroid Build Coastguard Worker if (valueType != uniformType && VariableBoolVectorType(valueType) != uniformType)
341*8975f5c5SAndroid Build Coastguard Worker {
342*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kUniformSizeMismatch);
343*8975f5c5SAndroid Build Coastguard Worker return false;
344*8975f5c5SAndroid Build Coastguard Worker }
345*8975f5c5SAndroid Build Coastguard Worker return true;
346*8975f5c5SAndroid Build Coastguard Worker }
347*8975f5c5SAndroid Build Coastguard Worker
348*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniformMatrixValue(const Context *context,
349*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
350*8975f5c5SAndroid Build Coastguard Worker GLenum valueType,
351*8975f5c5SAndroid Build Coastguard Worker GLenum uniformType);
352*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniform(const Context *context,
353*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
354*8975f5c5SAndroid Build Coastguard Worker GLenum uniformType,
355*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
356*8975f5c5SAndroid Build Coastguard Worker GLsizei count);
357*8975f5c5SAndroid Build Coastguard Worker bool ValidateUniformMatrix(const Context *context,
358*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
359*8975f5c5SAndroid Build Coastguard Worker GLenum matrixType,
360*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
361*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
362*8975f5c5SAndroid Build Coastguard Worker GLboolean transpose);
363*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetBooleanvRobustANGLE(const Context *context,
364*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
365*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
366*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
367*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
368*8975f5c5SAndroid Build Coastguard Worker const GLboolean *params);
369*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetFloatvRobustANGLE(const Context *context,
370*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
371*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
372*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
373*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
374*8975f5c5SAndroid Build Coastguard Worker const GLfloat *params);
375*8975f5c5SAndroid Build Coastguard Worker bool ValidateStateQuery(const Context *context,
376*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
377*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
378*8975f5c5SAndroid Build Coastguard Worker GLenum *nativeType,
379*8975f5c5SAndroid Build Coastguard Worker unsigned int *numParams);
380*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetIntegervRobustANGLE(const Context *context,
381*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
382*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
383*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
384*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
385*8975f5c5SAndroid Build Coastguard Worker const GLint *data);
386*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetInteger64vRobustANGLE(const Context *context,
387*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
388*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
389*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
390*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
391*8975f5c5SAndroid Build Coastguard Worker GLint64 *data);
392*8975f5c5SAndroid Build Coastguard Worker bool ValidateRobustStateQuery(const Context *context,
393*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
394*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
395*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
396*8975f5c5SAndroid Build Coastguard Worker GLenum *nativeType,
397*8975f5c5SAndroid Build Coastguard Worker unsigned int *numParams);
398*8975f5c5SAndroid Build Coastguard Worker
399*8975f5c5SAndroid Build Coastguard Worker bool ValidateCopyImageSubDataBase(const Context *context,
400*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
401*8975f5c5SAndroid Build Coastguard Worker GLuint srcName,
402*8975f5c5SAndroid Build Coastguard Worker GLenum srcTarget,
403*8975f5c5SAndroid Build Coastguard Worker GLint srcLevel,
404*8975f5c5SAndroid Build Coastguard Worker GLint srcX,
405*8975f5c5SAndroid Build Coastguard Worker GLint srcY,
406*8975f5c5SAndroid Build Coastguard Worker GLint srcZ,
407*8975f5c5SAndroid Build Coastguard Worker GLuint dstName,
408*8975f5c5SAndroid Build Coastguard Worker GLenum dstTarget,
409*8975f5c5SAndroid Build Coastguard Worker GLint dstLevel,
410*8975f5c5SAndroid Build Coastguard Worker GLint dstX,
411*8975f5c5SAndroid Build Coastguard Worker GLint dstY,
412*8975f5c5SAndroid Build Coastguard Worker GLint dstZ,
413*8975f5c5SAndroid Build Coastguard Worker GLsizei srcWidth,
414*8975f5c5SAndroid Build Coastguard Worker GLsizei srcHeight,
415*8975f5c5SAndroid Build Coastguard Worker GLsizei srcDepth);
416*8975f5c5SAndroid Build Coastguard Worker
417*8975f5c5SAndroid Build Coastguard Worker bool ValidateCopyTexImageParametersBase(const Context *context,
418*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
419*8975f5c5SAndroid Build Coastguard Worker TextureTarget target,
420*8975f5c5SAndroid Build Coastguard Worker GLint level,
421*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
422*8975f5c5SAndroid Build Coastguard Worker bool isSubImage,
423*8975f5c5SAndroid Build Coastguard Worker GLint xoffset,
424*8975f5c5SAndroid Build Coastguard Worker GLint yoffset,
425*8975f5c5SAndroid Build Coastguard Worker GLint zoffset,
426*8975f5c5SAndroid Build Coastguard Worker GLint x,
427*8975f5c5SAndroid Build Coastguard Worker GLint y,
428*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
429*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
430*8975f5c5SAndroid Build Coastguard Worker GLint border,
431*8975f5c5SAndroid Build Coastguard Worker Format *textureFormatOut);
432*8975f5c5SAndroid Build Coastguard Worker
433*8975f5c5SAndroid Build Coastguard Worker void RecordDrawModeError(const Context *context, angle::EntryPoint entryPoint, PrimitiveMode mode);
434*8975f5c5SAndroid Build Coastguard Worker const char *ValidateDrawElementsStates(const Context *context);
435*8975f5c5SAndroid Build Coastguard Worker
ValidateDrawBase(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode)436*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateDrawBase(const Context *context,
437*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
438*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode)
439*8975f5c5SAndroid Build Coastguard Worker {
440*8975f5c5SAndroid Build Coastguard Worker intptr_t drawStatesError = context->getStateCache().getBasicDrawStatesErrorString(
441*8975f5c5SAndroid Build Coastguard Worker context, &context->getPrivateStateCache());
442*8975f5c5SAndroid Build Coastguard Worker if (drawStatesError)
443*8975f5c5SAndroid Build Coastguard Worker {
444*8975f5c5SAndroid Build Coastguard Worker const char *errorMessage = reinterpret_cast<const char *>(drawStatesError);
445*8975f5c5SAndroid Build Coastguard Worker GLenum errorCode = context->getStateCache().getBasicDrawElementsErrorCode();
446*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(errorCode, errorMessage);
447*8975f5c5SAndroid Build Coastguard Worker return false;
448*8975f5c5SAndroid Build Coastguard Worker }
449*8975f5c5SAndroid Build Coastguard Worker
450*8975f5c5SAndroid Build Coastguard Worker if (!context->getStateCache().isValidDrawMode(mode))
451*8975f5c5SAndroid Build Coastguard Worker {
452*8975f5c5SAndroid Build Coastguard Worker RecordDrawModeError(context, entryPoint, mode);
453*8975f5c5SAndroid Build Coastguard Worker return false;
454*8975f5c5SAndroid Build Coastguard Worker }
455*8975f5c5SAndroid Build Coastguard Worker
456*8975f5c5SAndroid Build Coastguard Worker return true;
457*8975f5c5SAndroid Build Coastguard Worker }
458*8975f5c5SAndroid Build Coastguard Worker
459*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawArraysInstancedBase(const Context *context,
460*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
461*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
462*8975f5c5SAndroid Build Coastguard Worker GLint first,
463*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
464*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount,
465*8975f5c5SAndroid Build Coastguard Worker GLuint baseinstance);
466*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawArraysInstancedANGLE(const Context *context,
467*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
468*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
469*8975f5c5SAndroid Build Coastguard Worker GLint first,
470*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
471*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount);
472*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawArraysInstancedEXT(const Context *context,
473*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
474*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
475*8975f5c5SAndroid Build Coastguard Worker GLint first,
476*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
477*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount);
478*8975f5c5SAndroid Build Coastguard Worker
479*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawElementsInstancedBase(const Context *context,
480*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
481*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
482*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
483*8975f5c5SAndroid Build Coastguard Worker DrawElementsType type,
484*8975f5c5SAndroid Build Coastguard Worker const void *indices,
485*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount,
486*8975f5c5SAndroid Build Coastguard Worker GLuint baseinstance);
487*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawElementsInstancedANGLE(const Context *context,
488*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
489*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
490*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
491*8975f5c5SAndroid Build Coastguard Worker DrawElementsType type,
492*8975f5c5SAndroid Build Coastguard Worker const void *indices,
493*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount);
494*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawElementsInstancedEXT(const Context *context,
495*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
496*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
497*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
498*8975f5c5SAndroid Build Coastguard Worker DrawElementsType type,
499*8975f5c5SAndroid Build Coastguard Worker const void *indices,
500*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount);
501*8975f5c5SAndroid Build Coastguard Worker
502*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawInstancedANGLE(const Context *context, angle::EntryPoint entryPoint);
503*8975f5c5SAndroid Build Coastguard Worker
504*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetUniformBase(const Context *context,
505*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
506*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
507*8975f5c5SAndroid Build Coastguard Worker UniformLocation location);
508*8975f5c5SAndroid Build Coastguard Worker bool ValidateSizedGetUniform(const Context *context,
509*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
510*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
511*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
512*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
513*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
514*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetnUniformfvEXT(const Context *context,
515*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
516*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
517*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
518*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
519*8975f5c5SAndroid Build Coastguard Worker const GLfloat *params);
520*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetnUniformfvRobustANGLE(const Context *context,
521*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
522*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
523*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
524*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
525*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
526*8975f5c5SAndroid Build Coastguard Worker const GLfloat *params);
527*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetnUniformivEXT(const Context *context,
528*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
529*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
530*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
531*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
532*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
533*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetnUniformivRobustANGLE(const Context *context,
534*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
535*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
536*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
537*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
538*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
539*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
540*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetnUniformuivRobustANGLE(const Context *context,
541*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
542*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
543*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
544*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
545*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
546*8975f5c5SAndroid Build Coastguard Worker const GLuint *params);
547*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetUniformfvRobustANGLE(const Context *context,
548*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
549*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
550*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
551*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
552*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
553*8975f5c5SAndroid Build Coastguard Worker const GLfloat *params);
554*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetUniformivRobustANGLE(const Context *context,
555*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
556*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
557*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
558*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
559*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
560*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
561*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetUniformuivRobustANGLE(const Context *context,
562*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
563*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
564*8975f5c5SAndroid Build Coastguard Worker UniformLocation location,
565*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
566*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
567*8975f5c5SAndroid Build Coastguard Worker const GLuint *params);
568*8975f5c5SAndroid Build Coastguard Worker
569*8975f5c5SAndroid Build Coastguard Worker bool ValidateDiscardFramebufferBase(const Context *context,
570*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
571*8975f5c5SAndroid Build Coastguard Worker GLenum target,
572*8975f5c5SAndroid Build Coastguard Worker GLsizei numAttachments,
573*8975f5c5SAndroid Build Coastguard Worker const GLenum *attachments,
574*8975f5c5SAndroid Build Coastguard Worker bool defaultFramebuffer);
575*8975f5c5SAndroid Build Coastguard Worker
576*8975f5c5SAndroid Build Coastguard Worker bool ValidateInsertEventMarkerEXT(const Context *context,
577*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
578*8975f5c5SAndroid Build Coastguard Worker GLsizei length,
579*8975f5c5SAndroid Build Coastguard Worker const char *marker);
580*8975f5c5SAndroid Build Coastguard Worker bool ValidatePushGroupMarkerEXT(const Context *context,
581*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
582*8975f5c5SAndroid Build Coastguard Worker GLsizei length,
583*8975f5c5SAndroid Build Coastguard Worker const char *marker);
584*8975f5c5SAndroid Build Coastguard Worker bool ValidateEGLImageObject(const Context *context,
585*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
586*8975f5c5SAndroid Build Coastguard Worker TextureType type,
587*8975f5c5SAndroid Build Coastguard Worker egl::ImageID image);
588*8975f5c5SAndroid Build Coastguard Worker bool ValidateEGLImageTargetTexture2DOES(const Context *context,
589*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
590*8975f5c5SAndroid Build Coastguard Worker TextureType type,
591*8975f5c5SAndroid Build Coastguard Worker egl::ImageID image);
592*8975f5c5SAndroid Build Coastguard Worker bool ValidateEGLImageTargetRenderbufferStorageOES(const Context *context,
593*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
594*8975f5c5SAndroid Build Coastguard Worker GLenum target,
595*8975f5c5SAndroid Build Coastguard Worker egl::ImageID image);
596*8975f5c5SAndroid Build Coastguard Worker
597*8975f5c5SAndroid Build Coastguard Worker bool ValidateProgramBinaryBase(const Context *context,
598*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
599*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
600*8975f5c5SAndroid Build Coastguard Worker GLenum binaryFormat,
601*8975f5c5SAndroid Build Coastguard Worker const void *binary,
602*8975f5c5SAndroid Build Coastguard Worker GLint length);
603*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetProgramBinaryBase(const Context *context,
604*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
605*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
606*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
607*8975f5c5SAndroid Build Coastguard Worker const GLsizei *length,
608*8975f5c5SAndroid Build Coastguard Worker const GLenum *binaryFormat,
609*8975f5c5SAndroid Build Coastguard Worker const void *binary);
610*8975f5c5SAndroid Build Coastguard Worker
611*8975f5c5SAndroid Build Coastguard Worker bool ValidateDrawBuffersBase(const Context *context,
612*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
613*8975f5c5SAndroid Build Coastguard Worker GLsizei n,
614*8975f5c5SAndroid Build Coastguard Worker const GLenum *bufs);
615*8975f5c5SAndroid Build Coastguard Worker
616*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetBufferPointervBase(const Context *context,
617*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
618*8975f5c5SAndroid Build Coastguard Worker BufferBinding target,
619*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
620*8975f5c5SAndroid Build Coastguard Worker GLsizei *length,
621*8975f5c5SAndroid Build Coastguard Worker void *const *params);
622*8975f5c5SAndroid Build Coastguard Worker bool ValidateUnmapBufferBase(const Context *context,
623*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
624*8975f5c5SAndroid Build Coastguard Worker BufferBinding target);
625*8975f5c5SAndroid Build Coastguard Worker bool ValidateMapBufferRangeBase(const Context *context,
626*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
627*8975f5c5SAndroid Build Coastguard Worker BufferBinding target,
628*8975f5c5SAndroid Build Coastguard Worker GLintptr offset,
629*8975f5c5SAndroid Build Coastguard Worker GLsizeiptr length,
630*8975f5c5SAndroid Build Coastguard Worker GLbitfield access);
631*8975f5c5SAndroid Build Coastguard Worker bool ValidateFlushMappedBufferRangeBase(const Context *context,
632*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
633*8975f5c5SAndroid Build Coastguard Worker BufferBinding target,
634*8975f5c5SAndroid Build Coastguard Worker GLintptr offset,
635*8975f5c5SAndroid Build Coastguard Worker GLsizeiptr length);
636*8975f5c5SAndroid Build Coastguard Worker
637*8975f5c5SAndroid Build Coastguard Worker bool ValidateGenOrDelete(const Context *context, angle::EntryPoint entryPoint, GLint n);
638*8975f5c5SAndroid Build Coastguard Worker
639*8975f5c5SAndroid Build Coastguard Worker bool ValidateRobustEntryPoint(const Context *context,
640*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
641*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize);
642*8975f5c5SAndroid Build Coastguard Worker bool ValidateRobustBufferSize(const Context *context,
643*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
644*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
645*8975f5c5SAndroid Build Coastguard Worker GLsizei numParams);
646*8975f5c5SAndroid Build Coastguard Worker
647*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetFramebufferAttachmentParameterivBase(const Context *context,
648*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
649*8975f5c5SAndroid Build Coastguard Worker GLenum target,
650*8975f5c5SAndroid Build Coastguard Worker GLenum attachment,
651*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
652*8975f5c5SAndroid Build Coastguard Worker GLsizei *numParams);
653*8975f5c5SAndroid Build Coastguard Worker
654*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetFramebufferParameterivBase(const Context *context,
655*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
656*8975f5c5SAndroid Build Coastguard Worker GLenum target,
657*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
658*8975f5c5SAndroid Build Coastguard Worker const GLint *params);
659*8975f5c5SAndroid Build Coastguard Worker
660*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetBufferParameterBase(const Context *context,
661*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
662*8975f5c5SAndroid Build Coastguard Worker BufferBinding target,
663*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
664*8975f5c5SAndroid Build Coastguard Worker bool pointerVersion,
665*8975f5c5SAndroid Build Coastguard Worker GLsizei *numParams);
666*8975f5c5SAndroid Build Coastguard Worker
667*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetProgramivBase(const Context *context,
668*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
669*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
670*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
671*8975f5c5SAndroid Build Coastguard Worker GLsizei *numParams);
672*8975f5c5SAndroid Build Coastguard Worker
673*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetRenderbufferParameterivBase(const Context *context,
674*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
675*8975f5c5SAndroid Build Coastguard Worker GLenum target,
676*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
677*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
678*8975f5c5SAndroid Build Coastguard Worker
679*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetShaderivBase(const Context *context,
680*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
681*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID shader,
682*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
683*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
684*8975f5c5SAndroid Build Coastguard Worker
685*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetTexParameterBase(const Context *context,
686*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
687*8975f5c5SAndroid Build Coastguard Worker TextureType target,
688*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
689*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
690*8975f5c5SAndroid Build Coastguard Worker
691*8975f5c5SAndroid Build Coastguard Worker template <typename ParamType>
692*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexParameterBase(const Context *context,
693*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
694*8975f5c5SAndroid Build Coastguard Worker TextureType target,
695*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
696*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
697*8975f5c5SAndroid Build Coastguard Worker bool vectorParams,
698*8975f5c5SAndroid Build Coastguard Worker const ParamType *params);
699*8975f5c5SAndroid Build Coastguard Worker
700*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetVertexAttribBase(const Context *context,
701*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
702*8975f5c5SAndroid Build Coastguard Worker GLuint index,
703*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
704*8975f5c5SAndroid Build Coastguard Worker GLsizei *length,
705*8975f5c5SAndroid Build Coastguard Worker bool pointer,
706*8975f5c5SAndroid Build Coastguard Worker bool pureIntegerEntryPoint);
707*8975f5c5SAndroid Build Coastguard Worker
ValidateVertexFormat(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLint size,VertexAttribTypeCase validation)708*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateVertexFormat(const Context *context,
709*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
710*8975f5c5SAndroid Build Coastguard Worker GLuint index,
711*8975f5c5SAndroid Build Coastguard Worker GLint size,
712*8975f5c5SAndroid Build Coastguard Worker VertexAttribTypeCase validation)
713*8975f5c5SAndroid Build Coastguard Worker {
714*8975f5c5SAndroid Build Coastguard Worker const Caps &caps = context->getCaps();
715*8975f5c5SAndroid Build Coastguard Worker if (index >= static_cast<GLuint>(caps.maxVertexAttributes))
716*8975f5c5SAndroid Build Coastguard Worker {
717*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, err::kIndexExceedsMaxVertexAttribute);
718*8975f5c5SAndroid Build Coastguard Worker return false;
719*8975f5c5SAndroid Build Coastguard Worker }
720*8975f5c5SAndroid Build Coastguard Worker
721*8975f5c5SAndroid Build Coastguard Worker switch (validation)
722*8975f5c5SAndroid Build Coastguard Worker {
723*8975f5c5SAndroid Build Coastguard Worker case VertexAttribTypeCase::Invalid:
724*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, err::kInvalidType);
725*8975f5c5SAndroid Build Coastguard Worker return false;
726*8975f5c5SAndroid Build Coastguard Worker case VertexAttribTypeCase::Valid:
727*8975f5c5SAndroid Build Coastguard Worker if (size < 1 || size > 4)
728*8975f5c5SAndroid Build Coastguard Worker {
729*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, err::kInvalidVertexAttrSize);
730*8975f5c5SAndroid Build Coastguard Worker return false;
731*8975f5c5SAndroid Build Coastguard Worker }
732*8975f5c5SAndroid Build Coastguard Worker break;
733*8975f5c5SAndroid Build Coastguard Worker case VertexAttribTypeCase::ValidSize4Only:
734*8975f5c5SAndroid Build Coastguard Worker if (size != 4)
735*8975f5c5SAndroid Build Coastguard Worker {
736*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kInvalidVertexAttribSize2101010);
737*8975f5c5SAndroid Build Coastguard Worker return false;
738*8975f5c5SAndroid Build Coastguard Worker }
739*8975f5c5SAndroid Build Coastguard Worker break;
740*8975f5c5SAndroid Build Coastguard Worker case VertexAttribTypeCase::ValidSize3or4:
741*8975f5c5SAndroid Build Coastguard Worker if (size != 3 && size != 4)
742*8975f5c5SAndroid Build Coastguard Worker {
743*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kInvalidVertexAttribSize1010102);
744*8975f5c5SAndroid Build Coastguard Worker return false;
745*8975f5c5SAndroid Build Coastguard Worker }
746*8975f5c5SAndroid Build Coastguard Worker break;
747*8975f5c5SAndroid Build Coastguard Worker }
748*8975f5c5SAndroid Build Coastguard Worker
749*8975f5c5SAndroid Build Coastguard Worker return true;
750*8975f5c5SAndroid Build Coastguard Worker }
751*8975f5c5SAndroid Build Coastguard Worker
752*8975f5c5SAndroid Build Coastguard Worker // Note: These byte, short, and int types are all converted to float for the shader.
ValidateFloatVertexFormat(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLint size,VertexAttribType type)753*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateFloatVertexFormat(const Context *context,
754*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
755*8975f5c5SAndroid Build Coastguard Worker GLuint index,
756*8975f5c5SAndroid Build Coastguard Worker GLint size,
757*8975f5c5SAndroid Build Coastguard Worker VertexAttribType type)
758*8975f5c5SAndroid Build Coastguard Worker {
759*8975f5c5SAndroid Build Coastguard Worker return ValidateVertexFormat(context, entryPoint, index, size,
760*8975f5c5SAndroid Build Coastguard Worker context->getStateCache().getVertexAttribTypeValidation(type));
761*8975f5c5SAndroid Build Coastguard Worker }
762*8975f5c5SAndroid Build Coastguard Worker
ValidateIntegerVertexFormat(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLint size,VertexAttribType type)763*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateIntegerVertexFormat(const Context *context,
764*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
765*8975f5c5SAndroid Build Coastguard Worker GLuint index,
766*8975f5c5SAndroid Build Coastguard Worker GLint size,
767*8975f5c5SAndroid Build Coastguard Worker VertexAttribType type)
768*8975f5c5SAndroid Build Coastguard Worker {
769*8975f5c5SAndroid Build Coastguard Worker return ValidateVertexFormat(
770*8975f5c5SAndroid Build Coastguard Worker context, entryPoint, index, size,
771*8975f5c5SAndroid Build Coastguard Worker context->getStateCache().getIntegerVertexAttribTypeValidation(type));
772*8975f5c5SAndroid Build Coastguard Worker }
773*8975f5c5SAndroid Build Coastguard Worker
ValidateColorMasksForSharedExponentColorBuffers(const BlendStateExt & blendState,const Framebuffer * framebuffer)774*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateColorMasksForSharedExponentColorBuffers(const BlendStateExt &blendState,
775*8975f5c5SAndroid Build Coastguard Worker const Framebuffer *framebuffer)
776*8975f5c5SAndroid Build Coastguard Worker {
777*8975f5c5SAndroid Build Coastguard Worker // Get a mask of draw buffers that have color writemasks
778*8975f5c5SAndroid Build Coastguard Worker // incompatible with shared exponent color buffers.
779*8975f5c5SAndroid Build Coastguard Worker // The compatible writemasks are RGBA, RGB0, 000A, 0000.
780*8975f5c5SAndroid Build Coastguard Worker const BlendStateExt::ColorMaskStorage::Type rgbEnabledBits =
781*8975f5c5SAndroid Build Coastguard Worker blendState.expandColorMaskValue(true, true, true, false);
782*8975f5c5SAndroid Build Coastguard Worker const BlendStateExt::ColorMaskStorage::Type colorMaskNoAlphaBits =
783*8975f5c5SAndroid Build Coastguard Worker blendState.getColorMaskBits() & rgbEnabledBits;
784*8975f5c5SAndroid Build Coastguard Worker const DrawBufferMask incompatibleDiffMask =
785*8975f5c5SAndroid Build Coastguard Worker BlendStateExt::ColorMaskStorage::GetDiffMask(colorMaskNoAlphaBits, 0) &
786*8975f5c5SAndroid Build Coastguard Worker BlendStateExt::ColorMaskStorage::GetDiffMask(colorMaskNoAlphaBits, rgbEnabledBits);
787*8975f5c5SAndroid Build Coastguard Worker
788*8975f5c5SAndroid Build Coastguard Worker const DrawBufferMask sharedExponentBufferMask =
789*8975f5c5SAndroid Build Coastguard Worker framebuffer->getActiveSharedExponentColorAttachmentDrawBufferMask();
790*8975f5c5SAndroid Build Coastguard Worker return (sharedExponentBufferMask & incompatibleDiffMask).none();
791*8975f5c5SAndroid Build Coastguard Worker }
792*8975f5c5SAndroid Build Coastguard Worker
793*8975f5c5SAndroid Build Coastguard Worker bool ValidateRobustCompressedTexImageBase(const Context *context,
794*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
795*8975f5c5SAndroid Build Coastguard Worker GLsizei imageSize,
796*8975f5c5SAndroid Build Coastguard Worker GLsizei dataSize);
797*8975f5c5SAndroid Build Coastguard Worker
798*8975f5c5SAndroid Build Coastguard Worker bool ValidateVertexAttribIndex(const PrivateState &state,
799*8975f5c5SAndroid Build Coastguard Worker ErrorSet *errors,
800*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
801*8975f5c5SAndroid Build Coastguard Worker GLuint index);
802*8975f5c5SAndroid Build Coastguard Worker
803*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetActiveUniformBlockivBase(const Context *context,
804*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
805*8975f5c5SAndroid Build Coastguard Worker ShaderProgramID program,
806*8975f5c5SAndroid Build Coastguard Worker UniformBlockIndex uniformBlockIndex,
807*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
808*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
809*8975f5c5SAndroid Build Coastguard Worker
810*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetSamplerParameterBase(const Context *context,
811*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
812*8975f5c5SAndroid Build Coastguard Worker SamplerID sampler,
813*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
814*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
815*8975f5c5SAndroid Build Coastguard Worker
816*8975f5c5SAndroid Build Coastguard Worker template <typename ParamType>
817*8975f5c5SAndroid Build Coastguard Worker bool ValidateSamplerParameterBase(const Context *context,
818*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
819*8975f5c5SAndroid Build Coastguard Worker SamplerID sampler,
820*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
821*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
822*8975f5c5SAndroid Build Coastguard Worker bool vectorParams,
823*8975f5c5SAndroid Build Coastguard Worker const ParamType *params);
824*8975f5c5SAndroid Build Coastguard Worker
825*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetInternalFormativBase(const Context *context,
826*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
827*8975f5c5SAndroid Build Coastguard Worker GLenum target,
828*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
829*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
830*8975f5c5SAndroid Build Coastguard Worker GLsizei bufSize,
831*8975f5c5SAndroid Build Coastguard Worker GLsizei *numParams);
832*8975f5c5SAndroid Build Coastguard Worker
833*8975f5c5SAndroid Build Coastguard Worker bool ValidateFramebufferNotMultisampled(const Context *context,
834*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
835*8975f5c5SAndroid Build Coastguard Worker const Framebuffer *framebuffer,
836*8975f5c5SAndroid Build Coastguard Worker bool checkReadBufferResourceSamples);
837*8975f5c5SAndroid Build Coastguard Worker
838*8975f5c5SAndroid Build Coastguard Worker bool ValidateMultitextureUnit(const PrivateState &state,
839*8975f5c5SAndroid Build Coastguard Worker ErrorSet *errors,
840*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
841*8975f5c5SAndroid Build Coastguard Worker GLenum texture);
842*8975f5c5SAndroid Build Coastguard Worker
843*8975f5c5SAndroid Build Coastguard Worker bool ValidateTransformFeedbackPrimitiveMode(const Context *context,
844*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
845*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode transformFeedbackPrimitiveMode,
846*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode renderPrimitiveMode);
847*8975f5c5SAndroid Build Coastguard Worker
848*8975f5c5SAndroid Build Coastguard Worker // Common validation for 2D and 3D variants of TexStorage*Multisample.
849*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexStorageMultisample(const Context *context,
850*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
851*8975f5c5SAndroid Build Coastguard Worker TextureType target,
852*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
853*8975f5c5SAndroid Build Coastguard Worker GLint internalFormat,
854*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
855*8975f5c5SAndroid Build Coastguard Worker GLsizei height);
856*8975f5c5SAndroid Build Coastguard Worker
857*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexStorage2DMultisampleBase(const Context *context,
858*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
859*8975f5c5SAndroid Build Coastguard Worker TextureType target,
860*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
861*8975f5c5SAndroid Build Coastguard Worker GLint internalFormat,
862*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
863*8975f5c5SAndroid Build Coastguard Worker GLsizei height);
864*8975f5c5SAndroid Build Coastguard Worker
865*8975f5c5SAndroid Build Coastguard Worker bool ValidateTexStorage3DMultisampleBase(const Context *context,
866*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
867*8975f5c5SAndroid Build Coastguard Worker TextureType target,
868*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
869*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
870*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
871*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
872*8975f5c5SAndroid Build Coastguard Worker GLsizei depth);
873*8975f5c5SAndroid Build Coastguard Worker
874*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetTexLevelParameterBase(const Context *context,
875*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
876*8975f5c5SAndroid Build Coastguard Worker TextureTarget target,
877*8975f5c5SAndroid Build Coastguard Worker GLint level,
878*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
879*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
880*8975f5c5SAndroid Build Coastguard Worker
881*8975f5c5SAndroid Build Coastguard Worker bool ValidateMapBufferBase(const Context *context,
882*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
883*8975f5c5SAndroid Build Coastguard Worker BufferBinding target);
884*8975f5c5SAndroid Build Coastguard Worker bool ValidateIndexedStateQuery(const Context *context,
885*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
886*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
887*8975f5c5SAndroid Build Coastguard Worker GLuint index,
888*8975f5c5SAndroid Build Coastguard Worker GLsizei *length);
889*8975f5c5SAndroid Build Coastguard Worker bool ValidateES3TexImage2DParameters(const Context *context,
890*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
891*8975f5c5SAndroid Build Coastguard Worker TextureTarget target,
892*8975f5c5SAndroid Build Coastguard Worker GLint level,
893*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
894*8975f5c5SAndroid Build Coastguard Worker bool isCompressed,
895*8975f5c5SAndroid Build Coastguard Worker bool isSubImage,
896*8975f5c5SAndroid Build Coastguard Worker GLint xoffset,
897*8975f5c5SAndroid Build Coastguard Worker GLint yoffset,
898*8975f5c5SAndroid Build Coastguard Worker GLint zoffset,
899*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
900*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
901*8975f5c5SAndroid Build Coastguard Worker GLsizei depth,
902*8975f5c5SAndroid Build Coastguard Worker GLint border,
903*8975f5c5SAndroid Build Coastguard Worker GLenum format,
904*8975f5c5SAndroid Build Coastguard Worker GLenum type,
905*8975f5c5SAndroid Build Coastguard Worker GLsizei imageSize,
906*8975f5c5SAndroid Build Coastguard Worker const void *pixels);
907*8975f5c5SAndroid Build Coastguard Worker bool ValidateES3CopyTexImage2DParameters(const Context *context,
908*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
909*8975f5c5SAndroid Build Coastguard Worker TextureTarget target,
910*8975f5c5SAndroid Build Coastguard Worker GLint level,
911*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
912*8975f5c5SAndroid Build Coastguard Worker bool isSubImage,
913*8975f5c5SAndroid Build Coastguard Worker GLint xoffset,
914*8975f5c5SAndroid Build Coastguard Worker GLint yoffset,
915*8975f5c5SAndroid Build Coastguard Worker GLint zoffset,
916*8975f5c5SAndroid Build Coastguard Worker GLint x,
917*8975f5c5SAndroid Build Coastguard Worker GLint y,
918*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
919*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
920*8975f5c5SAndroid Build Coastguard Worker GLint border);
921*8975f5c5SAndroid Build Coastguard Worker bool ValidateES3TexStorageParametersBase(const Context *context,
922*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
923*8975f5c5SAndroid Build Coastguard Worker TextureType target,
924*8975f5c5SAndroid Build Coastguard Worker GLsizei levels,
925*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
926*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
927*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
928*8975f5c5SAndroid Build Coastguard Worker GLsizei depth);
929*8975f5c5SAndroid Build Coastguard Worker bool ValidateES3TexStorage2DParameters(const Context *context,
930*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
931*8975f5c5SAndroid Build Coastguard Worker TextureType target,
932*8975f5c5SAndroid Build Coastguard Worker GLsizei levels,
933*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
934*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
935*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
936*8975f5c5SAndroid Build Coastguard Worker GLsizei depth);
937*8975f5c5SAndroid Build Coastguard Worker bool ValidateES3TexStorage3DParameters(const Context *context,
938*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
939*8975f5c5SAndroid Build Coastguard Worker TextureType target,
940*8975f5c5SAndroid Build Coastguard Worker GLsizei levels,
941*8975f5c5SAndroid Build Coastguard Worker GLenum internalformat,
942*8975f5c5SAndroid Build Coastguard Worker GLsizei width,
943*8975f5c5SAndroid Build Coastguard Worker GLsizei height,
944*8975f5c5SAndroid Build Coastguard Worker GLsizei depth);
945*8975f5c5SAndroid Build Coastguard Worker
946*8975f5c5SAndroid Build Coastguard Worker bool ValidateGetMultisamplefvBase(const Context *context,
947*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
948*8975f5c5SAndroid Build Coastguard Worker GLenum pname,
949*8975f5c5SAndroid Build Coastguard Worker GLuint index,
950*8975f5c5SAndroid Build Coastguard Worker const GLfloat *val);
951*8975f5c5SAndroid Build Coastguard Worker bool ValidateSampleMaskiBase(const PrivateState &state,
952*8975f5c5SAndroid Build Coastguard Worker ErrorSet *errors,
953*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
954*8975f5c5SAndroid Build Coastguard Worker GLuint maskNumber,
955*8975f5c5SAndroid Build Coastguard Worker GLbitfield mask);
956*8975f5c5SAndroid Build Coastguard Worker
957*8975f5c5SAndroid Build Coastguard Worker bool ValidateProgramExecutableXFBBuffersPresent(const Context *context,
958*8975f5c5SAndroid Build Coastguard Worker const ProgramExecutable *programExecutable);
959*8975f5c5SAndroid Build Coastguard Worker
960*8975f5c5SAndroid Build Coastguard Worker // We should check with Khronos if returning INVALID_FRAMEBUFFER_OPERATION is OK when querying
961*8975f5c5SAndroid Build Coastguard Worker // implementation format info for incomplete framebuffers. It seems like these queries are
962*8975f5c5SAndroid Build Coastguard Worker // incongruent with the other errors.
963*8975f5c5SAndroid Build Coastguard Worker // Inlined for speed.
964*8975f5c5SAndroid Build Coastguard Worker template <GLenum ErrorCode = GL_INVALID_FRAMEBUFFER_OPERATION>
ValidateFramebufferComplete(const Context * context,angle::EntryPoint entryPoint,const Framebuffer * framebuffer)965*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateFramebufferComplete(const Context *context,
966*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
967*8975f5c5SAndroid Build Coastguard Worker const Framebuffer *framebuffer)
968*8975f5c5SAndroid Build Coastguard Worker {
969*8975f5c5SAndroid Build Coastguard Worker const FramebufferStatus &framebufferStatus = framebuffer->checkStatus(context);
970*8975f5c5SAndroid Build Coastguard Worker if (!framebufferStatus.isComplete())
971*8975f5c5SAndroid Build Coastguard Worker {
972*8975f5c5SAndroid Build Coastguard Worker ASSERT(framebufferStatus.reason != nullptr);
973*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(ErrorCode, framebufferStatus.reason);
974*8975f5c5SAndroid Build Coastguard Worker return false;
975*8975f5c5SAndroid Build Coastguard Worker }
976*8975f5c5SAndroid Build Coastguard Worker
977*8975f5c5SAndroid Build Coastguard Worker return true;
978*8975f5c5SAndroid Build Coastguard Worker }
979*8975f5c5SAndroid Build Coastguard Worker
980*8975f5c5SAndroid Build Coastguard Worker const char *ValidateProgramPipelineDrawStates(const State &state,
981*8975f5c5SAndroid Build Coastguard Worker const Extensions &extensions,
982*8975f5c5SAndroid Build Coastguard Worker ProgramPipeline *programPipeline);
983*8975f5c5SAndroid Build Coastguard Worker const char *ValidateProgramPipelineAttachedPrograms(ProgramPipeline *programPipeline);
984*8975f5c5SAndroid Build Coastguard Worker const char *ValidateDrawStates(const Context *context, GLenum *outErrorCode);
985*8975f5c5SAndroid Build Coastguard Worker const char *ValidateProgramPipeline(const Context *context);
986*8975f5c5SAndroid Build Coastguard Worker
987*8975f5c5SAndroid Build Coastguard Worker void RecordDrawAttribsError(const Context *context, angle::EntryPoint entryPoint);
988*8975f5c5SAndroid Build Coastguard Worker
ValidateDrawAttribs(const Context * context,angle::EntryPoint entryPoint,int64_t maxVertex)989*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateDrawAttribs(const Context *context,
990*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
991*8975f5c5SAndroid Build Coastguard Worker int64_t maxVertex)
992*8975f5c5SAndroid Build Coastguard Worker {
993*8975f5c5SAndroid Build Coastguard Worker // For non-instanced attributes, the maximum vertex must be accessible in the attribute buffers.
994*8975f5c5SAndroid Build Coastguard Worker // For instanced attributes, in non-instanced draw calls only attribute 0 is accessed. In
995*8975f5c5SAndroid Build Coastguard Worker // instanced draw calls, the instance limit is checked in ValidateDrawInstancedAttribs.
996*8975f5c5SAndroid Build Coastguard Worker if (maxVertex >= context->getStateCache().getNonInstancedVertexElementLimit() ||
997*8975f5c5SAndroid Build Coastguard Worker context->getStateCache().getInstancedVertexElementLimit() < 1)
998*8975f5c5SAndroid Build Coastguard Worker {
999*8975f5c5SAndroid Build Coastguard Worker RecordDrawAttribsError(context, entryPoint);
1000*8975f5c5SAndroid Build Coastguard Worker return false;
1001*8975f5c5SAndroid Build Coastguard Worker }
1002*8975f5c5SAndroid Build Coastguard Worker
1003*8975f5c5SAndroid Build Coastguard Worker return true;
1004*8975f5c5SAndroid Build Coastguard Worker }
1005*8975f5c5SAndroid Build Coastguard Worker
ValidateDrawArraysAttribs(const Context * context,angle::EntryPoint entryPoint,GLint first,GLsizei count)1006*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateDrawArraysAttribs(const Context *context,
1007*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1008*8975f5c5SAndroid Build Coastguard Worker GLint first,
1009*8975f5c5SAndroid Build Coastguard Worker GLsizei count)
1010*8975f5c5SAndroid Build Coastguard Worker {
1011*8975f5c5SAndroid Build Coastguard Worker if (!context->isBufferAccessValidationEnabled())
1012*8975f5c5SAndroid Build Coastguard Worker {
1013*8975f5c5SAndroid Build Coastguard Worker return true;
1014*8975f5c5SAndroid Build Coastguard Worker }
1015*8975f5c5SAndroid Build Coastguard Worker
1016*8975f5c5SAndroid Build Coastguard Worker // Check the computation of maxVertex doesn't overflow.
1017*8975f5c5SAndroid Build Coastguard Worker // - first < 0 has been checked as an error condition.
1018*8975f5c5SAndroid Build Coastguard Worker // - if count <= 0, skip validating no-op draw calls.
1019*8975f5c5SAndroid Build Coastguard Worker // From this we know maxVertex will be positive, and only need to check if it overflows GLint.
1020*8975f5c5SAndroid Build Coastguard Worker ASSERT(first >= 0);
1021*8975f5c5SAndroid Build Coastguard Worker ASSERT(count > 0);
1022*8975f5c5SAndroid Build Coastguard Worker int64_t maxVertex = static_cast<int64_t>(first) + static_cast<int64_t>(count) - 1;
1023*8975f5c5SAndroid Build Coastguard Worker if (maxVertex > static_cast<int64_t>(std::numeric_limits<GLint>::max()))
1024*8975f5c5SAndroid Build Coastguard Worker {
1025*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kIntegerOverflow);
1026*8975f5c5SAndroid Build Coastguard Worker return false;
1027*8975f5c5SAndroid Build Coastguard Worker }
1028*8975f5c5SAndroid Build Coastguard Worker
1029*8975f5c5SAndroid Build Coastguard Worker return ValidateDrawAttribs(context, entryPoint, maxVertex);
1030*8975f5c5SAndroid Build Coastguard Worker }
1031*8975f5c5SAndroid Build Coastguard Worker
ValidateDrawInstancedAttribs(const Context * context,angle::EntryPoint entryPoint,GLint primcount,GLuint baseinstance)1032*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateDrawInstancedAttribs(const Context *context,
1033*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1034*8975f5c5SAndroid Build Coastguard Worker GLint primcount,
1035*8975f5c5SAndroid Build Coastguard Worker GLuint baseinstance)
1036*8975f5c5SAndroid Build Coastguard Worker {
1037*8975f5c5SAndroid Build Coastguard Worker if (!context->isBufferAccessValidationEnabled())
1038*8975f5c5SAndroid Build Coastguard Worker {
1039*8975f5c5SAndroid Build Coastguard Worker return true;
1040*8975f5c5SAndroid Build Coastguard Worker }
1041*8975f5c5SAndroid Build Coastguard Worker
1042*8975f5c5SAndroid Build Coastguard Worker // Validate that the buffers bound for the attributes can hold enough vertices for this
1043*8975f5c5SAndroid Build Coastguard Worker // instanced draw. For attributes with a divisor of 0, ValidateDrawAttribs already checks this.
1044*8975f5c5SAndroid Build Coastguard Worker // Thus, the following only checks attributes with a non-zero divisor (i.e. "instanced").
1045*8975f5c5SAndroid Build Coastguard Worker const GLint64 limit = context->getStateCache().getInstancedVertexElementLimit();
1046*8975f5c5SAndroid Build Coastguard Worker if (baseinstance >= limit || primcount > limit - baseinstance)
1047*8975f5c5SAndroid Build Coastguard Worker {
1048*8975f5c5SAndroid Build Coastguard Worker RecordDrawAttribsError(context, entryPoint);
1049*8975f5c5SAndroid Build Coastguard Worker return false;
1050*8975f5c5SAndroid Build Coastguard Worker }
1051*8975f5c5SAndroid Build Coastguard Worker
1052*8975f5c5SAndroid Build Coastguard Worker return true;
1053*8975f5c5SAndroid Build Coastguard Worker }
1054*8975f5c5SAndroid Build Coastguard Worker
ValidateDrawArraysCommon(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLint first,GLsizei count,GLsizei primcount)1055*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateDrawArraysCommon(const Context *context,
1056*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1057*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
1058*8975f5c5SAndroid Build Coastguard Worker GLint first,
1059*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
1060*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount)
1061*8975f5c5SAndroid Build Coastguard Worker {
1062*8975f5c5SAndroid Build Coastguard Worker if (first < 0)
1063*8975f5c5SAndroid Build Coastguard Worker {
1064*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, err::kNegativeStart);
1065*8975f5c5SAndroid Build Coastguard Worker return false;
1066*8975f5c5SAndroid Build Coastguard Worker }
1067*8975f5c5SAndroid Build Coastguard Worker
1068*8975f5c5SAndroid Build Coastguard Worker if (count <= 0)
1069*8975f5c5SAndroid Build Coastguard Worker {
1070*8975f5c5SAndroid Build Coastguard Worker if (count < 0)
1071*8975f5c5SAndroid Build Coastguard Worker {
1072*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, err::kNegativeCount);
1073*8975f5c5SAndroid Build Coastguard Worker return false;
1074*8975f5c5SAndroid Build Coastguard Worker }
1075*8975f5c5SAndroid Build Coastguard Worker
1076*8975f5c5SAndroid Build Coastguard Worker // Early exit.
1077*8975f5c5SAndroid Build Coastguard Worker return ValidateDrawBase(context, entryPoint, mode);
1078*8975f5c5SAndroid Build Coastguard Worker }
1079*8975f5c5SAndroid Build Coastguard Worker
1080*8975f5c5SAndroid Build Coastguard Worker if (primcount <= 0)
1081*8975f5c5SAndroid Build Coastguard Worker {
1082*8975f5c5SAndroid Build Coastguard Worker if (primcount < 0)
1083*8975f5c5SAndroid Build Coastguard Worker {
1084*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, err::kNegativeCount);
1085*8975f5c5SAndroid Build Coastguard Worker return false;
1086*8975f5c5SAndroid Build Coastguard Worker }
1087*8975f5c5SAndroid Build Coastguard Worker // Early exit.
1088*8975f5c5SAndroid Build Coastguard Worker return ValidateDrawBase(context, entryPoint, mode);
1089*8975f5c5SAndroid Build Coastguard Worker }
1090*8975f5c5SAndroid Build Coastguard Worker
1091*8975f5c5SAndroid Build Coastguard Worker if (!ValidateDrawBase(context, entryPoint, mode))
1092*8975f5c5SAndroid Build Coastguard Worker {
1093*8975f5c5SAndroid Build Coastguard Worker return false;
1094*8975f5c5SAndroid Build Coastguard Worker }
1095*8975f5c5SAndroid Build Coastguard Worker
1096*8975f5c5SAndroid Build Coastguard Worker if (context->getStateCache().isTransformFeedbackActiveUnpaused() &&
1097*8975f5c5SAndroid Build Coastguard Worker !context->supportsGeometryOrTesselation())
1098*8975f5c5SAndroid Build Coastguard Worker {
1099*8975f5c5SAndroid Build Coastguard Worker const State &state = context->getState();
1100*8975f5c5SAndroid Build Coastguard Worker TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
1101*8975f5c5SAndroid Build Coastguard Worker if (!curTransformFeedback->checkBufferSpaceForDraw(count, primcount))
1102*8975f5c5SAndroid Build Coastguard Worker {
1103*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kTransformFeedbackBufferTooSmall);
1104*8975f5c5SAndroid Build Coastguard Worker return false;
1105*8975f5c5SAndroid Build Coastguard Worker }
1106*8975f5c5SAndroid Build Coastguard Worker }
1107*8975f5c5SAndroid Build Coastguard Worker
1108*8975f5c5SAndroid Build Coastguard Worker return ValidateDrawArraysAttribs(context, entryPoint, first, count);
1109*8975f5c5SAndroid Build Coastguard Worker }
1110*8975f5c5SAndroid Build Coastguard Worker
ValidateDrawElementsBase(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,DrawElementsType type)1111*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateDrawElementsBase(const Context *context,
1112*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1113*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
1114*8975f5c5SAndroid Build Coastguard Worker DrawElementsType type)
1115*8975f5c5SAndroid Build Coastguard Worker {
1116*8975f5c5SAndroid Build Coastguard Worker if (!context->getStateCache().isValidDrawElementsType(type))
1117*8975f5c5SAndroid Build Coastguard Worker {
1118*8975f5c5SAndroid Build Coastguard Worker if (type == DrawElementsType::UnsignedInt)
1119*8975f5c5SAndroid Build Coastguard Worker {
1120*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, err::kTypeNotUnsignedShortByte);
1121*8975f5c5SAndroid Build Coastguard Worker return false;
1122*8975f5c5SAndroid Build Coastguard Worker }
1123*8975f5c5SAndroid Build Coastguard Worker
1124*8975f5c5SAndroid Build Coastguard Worker ASSERT(type == DrawElementsType::InvalidEnum);
1125*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, err::kEnumInvalid);
1126*8975f5c5SAndroid Build Coastguard Worker return false;
1127*8975f5c5SAndroid Build Coastguard Worker }
1128*8975f5c5SAndroid Build Coastguard Worker
1129*8975f5c5SAndroid Build Coastguard Worker intptr_t drawElementsError = context->getStateCache().getBasicDrawElementsError(context);
1130*8975f5c5SAndroid Build Coastguard Worker if (drawElementsError)
1131*8975f5c5SAndroid Build Coastguard Worker {
1132*8975f5c5SAndroid Build Coastguard Worker // All errors from ValidateDrawElementsStates return INVALID_OPERATION.
1133*8975f5c5SAndroid Build Coastguard Worker const char *errorMessage = reinterpret_cast<const char *>(drawElementsError);
1134*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, errorMessage);
1135*8975f5c5SAndroid Build Coastguard Worker return false;
1136*8975f5c5SAndroid Build Coastguard Worker }
1137*8975f5c5SAndroid Build Coastguard Worker
1138*8975f5c5SAndroid Build Coastguard Worker // Note that we are missing overflow checks for active transform feedback buffers.
1139*8975f5c5SAndroid Build Coastguard Worker return true;
1140*8975f5c5SAndroid Build Coastguard Worker }
1141*8975f5c5SAndroid Build Coastguard Worker
ValidateDrawElementsCommon(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei primcount)1142*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateDrawElementsCommon(const Context *context,
1143*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1144*8975f5c5SAndroid Build Coastguard Worker PrimitiveMode mode,
1145*8975f5c5SAndroid Build Coastguard Worker GLsizei count,
1146*8975f5c5SAndroid Build Coastguard Worker DrawElementsType type,
1147*8975f5c5SAndroid Build Coastguard Worker const void *indices,
1148*8975f5c5SAndroid Build Coastguard Worker GLsizei primcount)
1149*8975f5c5SAndroid Build Coastguard Worker {
1150*8975f5c5SAndroid Build Coastguard Worker if (!ValidateDrawElementsBase(context, entryPoint, mode, type))
1151*8975f5c5SAndroid Build Coastguard Worker {
1152*8975f5c5SAndroid Build Coastguard Worker return false;
1153*8975f5c5SAndroid Build Coastguard Worker }
1154*8975f5c5SAndroid Build Coastguard Worker
1155*8975f5c5SAndroid Build Coastguard Worker ASSERT(isPow2(GetDrawElementsTypeSize(type)) && GetDrawElementsTypeSize(type) > 0);
1156*8975f5c5SAndroid Build Coastguard Worker
1157*8975f5c5SAndroid Build Coastguard Worker if (context->isWebGL())
1158*8975f5c5SAndroid Build Coastguard Worker {
1159*8975f5c5SAndroid Build Coastguard Worker GLuint typeBytes = GetDrawElementsTypeSize(type);
1160*8975f5c5SAndroid Build Coastguard Worker
1161*8975f5c5SAndroid Build Coastguard Worker if ((reinterpret_cast<uintptr_t>(indices) & static_cast<uintptr_t>(typeBytes - 1)) != 0)
1162*8975f5c5SAndroid Build Coastguard Worker {
1163*8975f5c5SAndroid Build Coastguard Worker // [WebGL 1.0] Section 6.4 Buffer Offset and Stride Requirements
1164*8975f5c5SAndroid Build Coastguard Worker // The offset arguments to drawElements and [...], must be a multiple of the size of the
1165*8975f5c5SAndroid Build Coastguard Worker // data type passed to the call, or an INVALID_OPERATION error is generated.
1166*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kOffsetMustBeMultipleOfType);
1167*8975f5c5SAndroid Build Coastguard Worker return false;
1168*8975f5c5SAndroid Build Coastguard Worker }
1169*8975f5c5SAndroid Build Coastguard Worker
1170*8975f5c5SAndroid Build Coastguard Worker // [WebGL 1.0] Section 6.4 Buffer Offset and Stride Requirements
1171*8975f5c5SAndroid Build Coastguard Worker // In addition the offset argument to drawElements must be non-negative or an INVALID_VALUE
1172*8975f5c5SAndroid Build Coastguard Worker // error is generated.
1173*8975f5c5SAndroid Build Coastguard Worker if (reinterpret_cast<intptr_t>(indices) < 0)
1174*8975f5c5SAndroid Build Coastguard Worker {
1175*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, err::kNegativeOffset);
1176*8975f5c5SAndroid Build Coastguard Worker return false;
1177*8975f5c5SAndroid Build Coastguard Worker }
1178*8975f5c5SAndroid Build Coastguard Worker }
1179*8975f5c5SAndroid Build Coastguard Worker
1180*8975f5c5SAndroid Build Coastguard Worker if (count <= 0)
1181*8975f5c5SAndroid Build Coastguard Worker {
1182*8975f5c5SAndroid Build Coastguard Worker if (count < 0)
1183*8975f5c5SAndroid Build Coastguard Worker {
1184*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_VALUE, err::kNegativeCount);
1185*8975f5c5SAndroid Build Coastguard Worker return false;
1186*8975f5c5SAndroid Build Coastguard Worker }
1187*8975f5c5SAndroid Build Coastguard Worker
1188*8975f5c5SAndroid Build Coastguard Worker // Early exit.
1189*8975f5c5SAndroid Build Coastguard Worker return ValidateDrawBase(context, entryPoint, mode);
1190*8975f5c5SAndroid Build Coastguard Worker }
1191*8975f5c5SAndroid Build Coastguard Worker
1192*8975f5c5SAndroid Build Coastguard Worker if (!ValidateDrawBase(context, entryPoint, mode))
1193*8975f5c5SAndroid Build Coastguard Worker {
1194*8975f5c5SAndroid Build Coastguard Worker return false;
1195*8975f5c5SAndroid Build Coastguard Worker }
1196*8975f5c5SAndroid Build Coastguard Worker
1197*8975f5c5SAndroid Build Coastguard Worker const State &state = context->getState();
1198*8975f5c5SAndroid Build Coastguard Worker const VertexArray *vao = state.getVertexArray();
1199*8975f5c5SAndroid Build Coastguard Worker Buffer *elementArrayBuffer = vao->getElementArrayBuffer();
1200*8975f5c5SAndroid Build Coastguard Worker
1201*8975f5c5SAndroid Build Coastguard Worker if (!elementArrayBuffer)
1202*8975f5c5SAndroid Build Coastguard Worker {
1203*8975f5c5SAndroid Build Coastguard Worker if (!indices)
1204*8975f5c5SAndroid Build Coastguard Worker {
1205*8975f5c5SAndroid Build Coastguard Worker // This is an application error that would normally result in a crash, but we catch
1206*8975f5c5SAndroid Build Coastguard Worker // it and return an error
1207*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kElementArrayNoBufferOrPointer);
1208*8975f5c5SAndroid Build Coastguard Worker return false;
1209*8975f5c5SAndroid Build Coastguard Worker }
1210*8975f5c5SAndroid Build Coastguard Worker }
1211*8975f5c5SAndroid Build Coastguard Worker else
1212*8975f5c5SAndroid Build Coastguard Worker {
1213*8975f5c5SAndroid Build Coastguard Worker // The max possible type size is 8 and count is on 32 bits so doing the multiplication
1214*8975f5c5SAndroid Build Coastguard Worker // in a 64 bit integer is safe. Also we are guaranteed that here count > 0.
1215*8975f5c5SAndroid Build Coastguard Worker static_assert(std::is_same<int, GLsizei>::value, "GLsizei isn't the expected type");
1216*8975f5c5SAndroid Build Coastguard Worker constexpr uint64_t kMaxTypeSize = 8;
1217*8975f5c5SAndroid Build Coastguard Worker constexpr uint64_t kIntMax = std::numeric_limits<int>::max();
1218*8975f5c5SAndroid Build Coastguard Worker constexpr uint64_t kUint64Max = std::numeric_limits<uint64_t>::max();
1219*8975f5c5SAndroid Build Coastguard Worker static_assert(kIntMax < kUint64Max / kMaxTypeSize, "");
1220*8975f5c5SAndroid Build Coastguard Worker
1221*8975f5c5SAndroid Build Coastguard Worker uint64_t elementCount = static_cast<uint64_t>(count);
1222*8975f5c5SAndroid Build Coastguard Worker ASSERT(elementCount > 0 && GetDrawElementsTypeSize(type) <= kMaxTypeSize);
1223*8975f5c5SAndroid Build Coastguard Worker
1224*8975f5c5SAndroid Build Coastguard Worker // Doing the multiplication here is overflow-safe
1225*8975f5c5SAndroid Build Coastguard Worker uint64_t elementDataSizeNoOffset = elementCount << GetDrawElementsTypeShift(type);
1226*8975f5c5SAndroid Build Coastguard Worker
1227*8975f5c5SAndroid Build Coastguard Worker // The offset can be any value, check for overflows
1228*8975f5c5SAndroid Build Coastguard Worker uint64_t offset = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(indices));
1229*8975f5c5SAndroid Build Coastguard Worker uint64_t elementDataSizeWithOffset = elementDataSizeNoOffset + offset;
1230*8975f5c5SAndroid Build Coastguard Worker if (elementDataSizeWithOffset < elementDataSizeNoOffset)
1231*8975f5c5SAndroid Build Coastguard Worker {
1232*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kIntegerOverflow);
1233*8975f5c5SAndroid Build Coastguard Worker return false;
1234*8975f5c5SAndroid Build Coastguard Worker }
1235*8975f5c5SAndroid Build Coastguard Worker
1236*8975f5c5SAndroid Build Coastguard Worker // Related to possible test bug: https://github.com/KhronosGroup/WebGL/issues/3064
1237*8975f5c5SAndroid Build Coastguard Worker if ((elementDataSizeWithOffset > static_cast<uint64_t>(elementArrayBuffer->getSize())) &&
1238*8975f5c5SAndroid Build Coastguard Worker (primcount > 0))
1239*8975f5c5SAndroid Build Coastguard Worker {
1240*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kInsufficientBufferSize);
1241*8975f5c5SAndroid Build Coastguard Worker return false;
1242*8975f5c5SAndroid Build Coastguard Worker }
1243*8975f5c5SAndroid Build Coastguard Worker }
1244*8975f5c5SAndroid Build Coastguard Worker
1245*8975f5c5SAndroid Build Coastguard Worker if (context->isBufferAccessValidationEnabled() && primcount > 0)
1246*8975f5c5SAndroid Build Coastguard Worker {
1247*8975f5c5SAndroid Build Coastguard Worker // Use the parameter buffer to retrieve and cache the index range.
1248*8975f5c5SAndroid Build Coastguard Worker // TODO: this calculation should take basevertex into account for
1249*8975f5c5SAndroid Build Coastguard Worker // glDrawElementsInstancedBaseVertexBaseInstanceEXT. http://anglebug.com/41481166
1250*8975f5c5SAndroid Build Coastguard Worker IndexRange indexRange{IndexRange::Undefined()};
1251*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_TRY(vao->getIndexRange(context, type, count, indices, &indexRange));
1252*8975f5c5SAndroid Build Coastguard Worker
1253*8975f5c5SAndroid Build Coastguard Worker // If we use an index greater than our maximum supported index range, return an error.
1254*8975f5c5SAndroid Build Coastguard Worker // The ES3 spec does not specify behaviour here, it is undefined, but ANGLE should
1255*8975f5c5SAndroid Build Coastguard Worker // always return an error if possible here.
1256*8975f5c5SAndroid Build Coastguard Worker if (static_cast<GLint64>(indexRange.end) >= context->getCaps().maxElementIndex)
1257*8975f5c5SAndroid Build Coastguard Worker {
1258*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kExceedsMaxElement);
1259*8975f5c5SAndroid Build Coastguard Worker return false;
1260*8975f5c5SAndroid Build Coastguard Worker }
1261*8975f5c5SAndroid Build Coastguard Worker
1262*8975f5c5SAndroid Build Coastguard Worker if (!ValidateDrawAttribs(context, entryPoint, static_cast<GLint>(indexRange.end)))
1263*8975f5c5SAndroid Build Coastguard Worker {
1264*8975f5c5SAndroid Build Coastguard Worker return false;
1265*8975f5c5SAndroid Build Coastguard Worker }
1266*8975f5c5SAndroid Build Coastguard Worker
1267*8975f5c5SAndroid Build Coastguard Worker // No op if there are no real indices in the index data (all are primitive restart).
1268*8975f5c5SAndroid Build Coastguard Worker return (indexRange.vertexIndexCount > 0);
1269*8975f5c5SAndroid Build Coastguard Worker }
1270*8975f5c5SAndroid Build Coastguard Worker
1271*8975f5c5SAndroid Build Coastguard Worker return true;
1272*8975f5c5SAndroid Build Coastguard Worker }
1273*8975f5c5SAndroid Build Coastguard Worker
ValidateBindVertexArrayBase(const Context * context,angle::EntryPoint entryPoint,VertexArrayID array)1274*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateBindVertexArrayBase(const Context *context,
1275*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1276*8975f5c5SAndroid Build Coastguard Worker VertexArrayID array)
1277*8975f5c5SAndroid Build Coastguard Worker {
1278*8975f5c5SAndroid Build Coastguard Worker if (!context->isVertexArrayGenerated(array))
1279*8975f5c5SAndroid Build Coastguard Worker {
1280*8975f5c5SAndroid Build Coastguard Worker // The default VAO should always exist
1281*8975f5c5SAndroid Build Coastguard Worker ASSERT(array.value != 0);
1282*8975f5c5SAndroid Build Coastguard Worker ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, err::kInvalidVertexArray);
1283*8975f5c5SAndroid Build Coastguard Worker return false;
1284*8975f5c5SAndroid Build Coastguard Worker }
1285*8975f5c5SAndroid Build Coastguard Worker
1286*8975f5c5SAndroid Build Coastguard Worker return true;
1287*8975f5c5SAndroid Build Coastguard Worker }
1288*8975f5c5SAndroid Build Coastguard Worker
ValidateVertexAttribIndex(const PrivateState & state,ErrorSet * errors,angle::EntryPoint entryPoint,GLuint index)1289*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE bool ValidateVertexAttribIndex(const PrivateState &state,
1290*8975f5c5SAndroid Build Coastguard Worker ErrorSet *errors,
1291*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1292*8975f5c5SAndroid Build Coastguard Worker GLuint index)
1293*8975f5c5SAndroid Build Coastguard Worker {
1294*8975f5c5SAndroid Build Coastguard Worker if (index >= static_cast<GLuint>(state.getCaps().maxVertexAttributes))
1295*8975f5c5SAndroid Build Coastguard Worker {
1296*8975f5c5SAndroid Build Coastguard Worker errors->validationError(entryPoint, GL_INVALID_VALUE, err::kIndexExceedsMaxVertexAttribute);
1297*8975f5c5SAndroid Build Coastguard Worker return false;
1298*8975f5c5SAndroid Build Coastguard Worker }
1299*8975f5c5SAndroid Build Coastguard Worker
1300*8975f5c5SAndroid Build Coastguard Worker return true;
1301*8975f5c5SAndroid Build Coastguard Worker }
1302*8975f5c5SAndroid Build Coastguard Worker
1303*8975f5c5SAndroid Build Coastguard Worker bool ValidateLogicOpCommon(const PrivateState &state,
1304*8975f5c5SAndroid Build Coastguard Worker ErrorSet *errors,
1305*8975f5c5SAndroid Build Coastguard Worker angle::EntryPoint entryPoint,
1306*8975f5c5SAndroid Build Coastguard Worker LogicalOperation opcodePacked);
1307*8975f5c5SAndroid Build Coastguard Worker } // namespace gl
1308*8975f5c5SAndroid Build Coastguard Worker
1309*8975f5c5SAndroid Build Coastguard Worker #endif // LIBANGLE_VALIDATION_ES_H_
1310