1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // validationES32.cpp: Validation functions for OpenGL ES 3.2 entry point parameters
8
9 #include "libANGLE/validationES32_autogen.h"
10
11 #include "libANGLE/Context.h"
12 #include "libANGLE/ErrorStrings.h"
13 #include "libANGLE/Framebuffer.h"
14 #include "libANGLE/VertexArray.h"
15 #include "libANGLE/validationES.h"
16 #include "libANGLE/validationES2_autogen.h"
17 #include "libANGLE/validationES31_autogen.h"
18 #include "libANGLE/validationES3_autogen.h"
19
20 #include "common/utilities.h"
21
22 using namespace angle;
23
24 namespace gl
25 {
26 using namespace err;
27
ValidateBlendBarrier(const Context * context)28 bool ValidateBlendBarrier(const Context *context)
29 {
30 return true;
31 }
32
ValidateBlendEquationSeparatei(const Context * context,GLuint buf,GLenum modeRGB,GLenum modeAlpha)33 bool ValidateBlendEquationSeparatei(const Context *context,
34 GLuint buf,
35 GLenum modeRGB,
36 GLenum modeAlpha)
37 {
38 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
39 {
40 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
41 return false;
42 }
43
44 if (!ValidateBlendEquationSeparate(context, modeRGB, modeAlpha))
45 {
46 // error already generated
47 return false;
48 }
49
50 return true;
51 }
52
ValidateBlendEquationi(const Context * context,GLuint buf,GLenum mode)53 bool ValidateBlendEquationi(const Context *context, GLuint buf, GLenum mode)
54 {
55 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
56 {
57 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
58 return false;
59 }
60
61 if (!ValidateBlendEquation(context, mode))
62 {
63 // error already generated
64 return false;
65 }
66
67 return true;
68 }
69
ValidateBlendFuncSeparatei(const Context * context,GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)70 bool ValidateBlendFuncSeparatei(const Context *context,
71 GLuint buf,
72 GLenum srcRGB,
73 GLenum dstRGB,
74 GLenum srcAlpha,
75 GLenum dstAlpha)
76 {
77 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
78 {
79 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
80 return false;
81 }
82
83 if (!ValidateBlendFuncSeparate(context, srcRGB, dstRGB, srcAlpha, dstAlpha))
84 {
85 // error already generated
86 return false;
87 }
88
89 return true;
90 }
91
ValidateBlendFunci(const Context * context,GLuint buf,GLenum src,GLenum dst)92 bool ValidateBlendFunci(const Context *context, GLuint buf, GLenum src, GLenum dst)
93 {
94 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
95 {
96 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
97 return false;
98 }
99
100 if (!ValidateBlendFunc(context, src, dst))
101 {
102 // error already generated
103 return false;
104 }
105
106 return true;
107 }
108
ValidateColorMaski(const Context * context,GLuint index,GLboolean r,GLboolean g,GLboolean b,GLboolean a)109 bool ValidateColorMaski(const Context *context,
110 GLuint index,
111 GLboolean r,
112 GLboolean g,
113 GLboolean b,
114 GLboolean a)
115 {
116 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
117 {
118 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
119 return false;
120 }
121
122 return true;
123 }
124
ValidateCopyImageSubData(const Context * context,GLuint srcName,GLenum srcTarget,GLint srcLevel,GLint srcX,GLint srcY,GLint srcZ,GLuint dstName,GLenum dstTarget,GLint dstLevel,GLint dstX,GLint dstY,GLint dstZ,GLsizei srcWidth,GLsizei srcHeight,GLsizei srcDepth)125 bool ValidateCopyImageSubData(const Context *context,
126 GLuint srcName,
127 GLenum srcTarget,
128 GLint srcLevel,
129 GLint srcX,
130 GLint srcY,
131 GLint srcZ,
132 GLuint dstName,
133 GLenum dstTarget,
134 GLint dstLevel,
135 GLint dstX,
136 GLint dstY,
137 GLint dstZ,
138 GLsizei srcWidth,
139 GLsizei srcHeight,
140 GLsizei srcDepth)
141 {
142 return true;
143 }
144
ValidateDebugMessageCallback(const Context * context,GLDEBUGPROC callback,const void * userParam)145 bool ValidateDebugMessageCallback(const Context *context,
146 GLDEBUGPROC callback,
147 const void *userParam)
148 {
149 return true;
150 }
151
ValidateDebugMessageControl(const Context * context,GLenum source,GLenum type,GLenum severity,GLsizei count,const GLuint * ids,GLboolean enabled)152 bool ValidateDebugMessageControl(const Context *context,
153 GLenum source,
154 GLenum type,
155 GLenum severity,
156 GLsizei count,
157 const GLuint *ids,
158 GLboolean enabled)
159 {
160 return true;
161 }
162
ValidateDebugMessageInsert(const Context * context,GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar * buf)163 bool ValidateDebugMessageInsert(const Context *context,
164 GLenum source,
165 GLenum type,
166 GLuint id,
167 GLenum severity,
168 GLsizei length,
169 const GLchar *buf)
170 {
171 return true;
172 }
173
ValidateDisablei(const Context * context,GLenum target,GLuint index)174 bool ValidateDisablei(const Context *context, GLenum target, GLuint index)
175 {
176 switch (target)
177 {
178 case GL_BLEND:
179 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
180 {
181 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
182 return false;
183 }
184 break;
185 default:
186 context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
187 return false;
188 }
189 return true;
190 }
191
ValidateDrawElementsBaseVertex(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)192 bool ValidateDrawElementsBaseVertex(const Context *context,
193 PrimitiveMode mode,
194 GLsizei count,
195 DrawElementsType type,
196 const void *indices,
197 GLint basevertex)
198 {
199 if (!context->getExtensions().drawElementsBaseVertexAny())
200 {
201 context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
202 return false;
203 }
204
205 return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
206 }
207
ValidateDrawElementsInstancedBaseVertex(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instancecount,GLint basevertex)208 bool ValidateDrawElementsInstancedBaseVertex(const Context *context,
209 PrimitiveMode mode,
210 GLsizei count,
211 DrawElementsType type,
212 const void *indices,
213 GLsizei instancecount,
214 GLint basevertex)
215 {
216 if (!context->getExtensions().drawElementsBaseVertexAny())
217 {
218 context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
219 return false;
220 }
221
222 return ValidateDrawElementsInstancedBase(context, mode, count, type, indices, instancecount);
223 }
224
ValidateDrawRangeElementsBaseVertex(const Context * context,PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)225 bool ValidateDrawRangeElementsBaseVertex(const Context *context,
226 PrimitiveMode mode,
227 GLuint start,
228 GLuint end,
229 GLsizei count,
230 DrawElementsType type,
231 const void *indices,
232 GLint basevertex)
233 {
234 if (!context->getExtensions().drawElementsBaseVertexAny())
235 {
236 context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
237 return false;
238 }
239
240 if (end < start)
241 {
242 context->validationError(GL_INVALID_VALUE, kInvalidElementRange);
243 return false;
244 }
245
246 if (!ValidateDrawElementsCommon(context, mode, count, type, indices, 0))
247 {
248 return false;
249 }
250
251 // Skip range checks for no-op calls.
252 if (count <= 0)
253 {
254 return true;
255 }
256
257 return true;
258 }
259
ValidateEnablei(const Context * context,GLenum target,GLuint index)260 bool ValidateEnablei(const Context *context, GLenum target, GLuint index)
261 {
262 switch (target)
263 {
264 case GL_BLEND:
265 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
266 {
267 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
268 return false;
269 }
270 break;
271 default:
272 context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
273 return false;
274 }
275 return true;
276 }
277
ValidateFramebufferTexture(const Context * context,GLenum target,GLenum attachment,TextureID texture,GLint level)278 bool ValidateFramebufferTexture(const Context *context,
279 GLenum target,
280 GLenum attachment,
281 TextureID texture,
282 GLint level)
283 {
284 return true;
285 }
286
ValidateGetDebugMessageLog(const Context * context,GLuint count,GLsizei bufSize,const GLenum * sources,const GLenum * types,const GLuint * ids,const GLenum * severities,const GLsizei * lengths,const GLchar * messageLog)287 bool ValidateGetDebugMessageLog(const Context *context,
288 GLuint count,
289 GLsizei bufSize,
290 const GLenum *sources,
291 const GLenum *types,
292 const GLuint *ids,
293 const GLenum *severities,
294 const GLsizei *lengths,
295 const GLchar *messageLog)
296 {
297 return true;
298 }
299
ValidateGetGraphicsResetStatus(const Context * context)300 bool ValidateGetGraphicsResetStatus(const Context *context)
301 {
302 return true;
303 }
304
ValidateGetObjectLabel(const Context * context,GLenum identifier,GLuint name,GLsizei bufSize,const GLsizei * length,const GLchar * label)305 bool ValidateGetObjectLabel(const Context *context,
306 GLenum identifier,
307 GLuint name,
308 GLsizei bufSize,
309 const GLsizei *length,
310 const GLchar *label)
311 {
312 return true;
313 }
314
ValidateGetObjectPtrLabel(const Context * context,const void * ptr,GLsizei bufSize,const GLsizei * length,const GLchar * label)315 bool ValidateGetObjectPtrLabel(const Context *context,
316 const void *ptr,
317 GLsizei bufSize,
318 const GLsizei *length,
319 const GLchar *label)
320 {
321 return true;
322 }
323
ValidateGetPointerv(const Context * context,GLenum pname,void * const * params)324 bool ValidateGetPointerv(const Context *context, GLenum pname, void *const *params)
325 {
326 Version clientVersion = context->getClientVersion();
327
328 if ((clientVersion == ES_1_0) || (clientVersion == ES_1_1))
329 {
330 switch (pname)
331 {
332 case GL_VERTEX_ARRAY_POINTER:
333 case GL_NORMAL_ARRAY_POINTER:
334 case GL_COLOR_ARRAY_POINTER:
335 case GL_TEXTURE_COORD_ARRAY_POINTER:
336 case GL_POINT_SIZE_ARRAY_POINTER_OES:
337 return true;
338 default:
339 context->validationError(GL_INVALID_ENUM, kInvalidPointerQuery);
340 return false;
341 }
342 }
343 else if (clientVersion == ES_3_2)
344 {
345 switch (pname)
346 {
347 case GL_DEBUG_CALLBACK_FUNCTION:
348 case GL_DEBUG_CALLBACK_USER_PARAM:
349 return true;
350 default:
351 context->validationError(GL_INVALID_ENUM, kInvalidPointerQuery);
352 return false;
353 }
354 }
355 else
356 {
357 context->validationError(GL_INVALID_OPERATION, kES1or32Required);
358 return false;
359 }
360 }
361
ValidateGetSamplerParameterIiv(const Context * context,SamplerID sampler,GLenum pname,const GLint * params)362 bool ValidateGetSamplerParameterIiv(const Context *context,
363 SamplerID sampler,
364 GLenum pname,
365 const GLint *params)
366 {
367 return true;
368 }
369
ValidateGetSamplerParameterIuiv(const Context * context,SamplerID sampler,GLenum pname,const GLuint * params)370 bool ValidateGetSamplerParameterIuiv(const Context *context,
371 SamplerID sampler,
372 GLenum pname,
373 const GLuint *params)
374 {
375 return true;
376 }
377
ValidateGetTexParameterIiv(const Context * context,TextureType targetPacked,GLenum pname,const GLint * params)378 bool ValidateGetTexParameterIiv(const Context *context,
379 TextureType targetPacked,
380 GLenum pname,
381 const GLint *params)
382 {
383 return true;
384 }
385
ValidateGetTexParameterIuiv(const Context * context,TextureType targetPacked,GLenum pname,const GLuint * params)386 bool ValidateGetTexParameterIuiv(const Context *context,
387 TextureType targetPacked,
388 GLenum pname,
389 const GLuint *params)
390 {
391 return true;
392 }
393
ValidateGetnUniformfv(const Context * context,ShaderProgramID program,UniformLocation location,GLsizei bufSize,const GLfloat * params)394 bool ValidateGetnUniformfv(const Context *context,
395 ShaderProgramID program,
396 UniformLocation location,
397 GLsizei bufSize,
398 const GLfloat *params)
399 {
400 return true;
401 }
402
ValidateGetnUniformiv(const Context * context,ShaderProgramID program,UniformLocation location,GLsizei bufSize,const GLint * params)403 bool ValidateGetnUniformiv(const Context *context,
404 ShaderProgramID program,
405 UniformLocation location,
406 GLsizei bufSize,
407 const GLint *params)
408 {
409 return true;
410 }
411
ValidateGetnUniformuiv(const Context * context,ShaderProgramID program,UniformLocation location,GLsizei bufSize,const GLuint * params)412 bool ValidateGetnUniformuiv(const Context *context,
413 ShaderProgramID program,
414 UniformLocation location,
415 GLsizei bufSize,
416 const GLuint *params)
417 {
418 return true;
419 }
420
ValidateIsEnabledi(const Context * context,GLenum target,GLuint index)421 bool ValidateIsEnabledi(const Context *context, GLenum target, GLuint index)
422 {
423 switch (target)
424 {
425 case GL_BLEND:
426 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
427 {
428 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
429 return false;
430 }
431 break;
432 default:
433 context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
434 return false;
435 }
436 return true;
437 }
438
ValidateMinSampleShading(const Context * context,GLfloat value)439 bool ValidateMinSampleShading(const Context *context, GLfloat value)
440 {
441 return true;
442 }
443
ValidateObjectLabel(const Context * context,GLenum identifier,GLuint name,GLsizei length,const GLchar * label)444 bool ValidateObjectLabel(const Context *context,
445 GLenum identifier,
446 GLuint name,
447 GLsizei length,
448 const GLchar *label)
449 {
450 return true;
451 }
452
ValidateObjectPtrLabel(const Context * context,const void * ptr,GLsizei length,const GLchar * label)453 bool ValidateObjectPtrLabel(const Context *context,
454 const void *ptr,
455 GLsizei length,
456 const GLchar *label)
457 {
458 return true;
459 }
460
ValidatePatchParameteri(const Context * context,GLenum pname,GLint value)461 bool ValidatePatchParameteri(const Context *context, GLenum pname, GLint value)
462 {
463 return true;
464 }
465
ValidatePopDebugGroup(const Context * context)466 bool ValidatePopDebugGroup(const Context *context)
467 {
468 return true;
469 }
470
ValidatePrimitiveBoundingBox(const Context * context,GLfloat minX,GLfloat minY,GLfloat minZ,GLfloat minW,GLfloat maxX,GLfloat maxY,GLfloat maxZ,GLfloat maxW)471 bool ValidatePrimitiveBoundingBox(const Context *context,
472 GLfloat minX,
473 GLfloat minY,
474 GLfloat minZ,
475 GLfloat minW,
476 GLfloat maxX,
477 GLfloat maxY,
478 GLfloat maxZ,
479 GLfloat maxW)
480 {
481 return true;
482 }
483
ValidatePushDebugGroup(const Context * context,GLenum source,GLuint id,GLsizei length,const GLchar * message)484 bool ValidatePushDebugGroup(const Context *context,
485 GLenum source,
486 GLuint id,
487 GLsizei length,
488 const GLchar *message)
489 {
490 return true;
491 }
492
ValidateReadnPixels(const Context * context,GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,const void * data)493 bool ValidateReadnPixels(const Context *context,
494 GLint x,
495 GLint y,
496 GLsizei width,
497 GLsizei height,
498 GLenum format,
499 GLenum type,
500 GLsizei bufSize,
501 const void *data)
502 {
503 return true;
504 }
505
ValidateSamplerParameterIiv(const Context * context,SamplerID sampler,GLenum pname,const GLint * param)506 bool ValidateSamplerParameterIiv(const Context *context,
507 SamplerID sampler,
508 GLenum pname,
509 const GLint *param)
510 {
511 return true;
512 }
513
ValidateSamplerParameterIuiv(const Context * context,SamplerID sampler,GLenum pname,const GLuint * param)514 bool ValidateSamplerParameterIuiv(const Context *context,
515 SamplerID sampler,
516 GLenum pname,
517 const GLuint *param)
518 {
519 return true;
520 }
521
ValidateTexBuffer(const Context * context,GLenum target,GLenum internalformat,BufferID buffer)522 bool ValidateTexBuffer(const Context *context,
523 GLenum target,
524 GLenum internalformat,
525 BufferID buffer)
526 {
527 return true;
528 }
529
ValidateTexBufferRange(const Context * context,GLenum target,GLenum internalformat,BufferID buffer,GLintptr offset,GLsizeiptr size)530 bool ValidateTexBufferRange(const Context *context,
531 GLenum target,
532 GLenum internalformat,
533 BufferID buffer,
534 GLintptr offset,
535 GLsizeiptr size)
536 {
537 return true;
538 }
539
ValidateTexParameterIiv(const Context * context,TextureType targetPacked,GLenum pname,const GLint * params)540 bool ValidateTexParameterIiv(const Context *context,
541 TextureType targetPacked,
542 GLenum pname,
543 const GLint *params)
544 {
545 return true;
546 }
547
ValidateTexParameterIuiv(const Context * context,TextureType targetPacked,GLenum pname,const GLuint * params)548 bool ValidateTexParameterIuiv(const Context *context,
549 TextureType targetPacked,
550 GLenum pname,
551 const GLuint *params)
552 {
553 return true;
554 }
555
ValidateTexStorage3DMultisample(const Context * context,TextureType targetPacked,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLboolean fixedsamplelocations)556 bool ValidateTexStorage3DMultisample(const Context *context,
557 TextureType targetPacked,
558 GLsizei samples,
559 GLenum internalformat,
560 GLsizei width,
561 GLsizei height,
562 GLsizei depth,
563 GLboolean fixedsamplelocations)
564 {
565 return true;
566 }
567
568 } // namespace gl
569