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 // validationESEXT.cpp: Validation functions for OpenGL ES extension entry points.
7
8 #include "libANGLE/validationESEXT_autogen.h"
9
10 #include "libANGLE/Context.h"
11 #include "libANGLE/ErrorStrings.h"
12 #include "libANGLE/MemoryObject.h"
13 #include "libANGLE/validationES.h"
14 #include "libANGLE/validationES2.h"
15 #include "libANGLE/validationES3.h"
16 #include "libANGLE/validationES31.h"
17 #include "libANGLE/validationES32.h"
18
19 namespace gl
20 {
21 using namespace err;
22
23 namespace
24 {
25 template <typename ObjectT>
ValidateGetImageFormatAndType(const Context * context,angle::EntryPoint entryPoint,ObjectT * obj,GLenum format,GLenum type)26 bool ValidateGetImageFormatAndType(const Context *context,
27 angle::EntryPoint entryPoint,
28 ObjectT *obj,
29 GLenum format,
30 GLenum type)
31 {
32 GLenum implFormat = obj->getImplementationColorReadFormat(context);
33 if (!ValidES3Format(format) && (format != implFormat || format == GL_NONE))
34 {
35 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidFormat);
36 return false;
37 }
38
39 GLenum implType = obj->getImplementationColorReadType(context);
40 if (!ValidES3Type(type) && (type != implType || type == GL_NONE))
41 {
42 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
43 return false;
44 }
45
46 // Format/type combinations are not yet validated.
47
48 return true;
49 }
50
IsValidImageLayout(ImageLayout layout)51 bool IsValidImageLayout(ImageLayout layout)
52 {
53 switch (layout)
54 {
55 case ImageLayout::Undefined:
56 case ImageLayout::General:
57 case ImageLayout::ColorAttachment:
58 case ImageLayout::DepthStencilAttachment:
59 case ImageLayout::DepthStencilReadOnlyAttachment:
60 case ImageLayout::ShaderReadOnly:
61 case ImageLayout::TransferSrc:
62 case ImageLayout::TransferDst:
63 case ImageLayout::DepthReadOnlyStencilAttachment:
64 case ImageLayout::DepthAttachmentStencilReadOnly:
65 return true;
66
67 default:
68 return false;
69 }
70 }
71
IsValidMemoryObjectParamater(const Context * context,angle::EntryPoint entryPoint,GLenum pname)72 bool IsValidMemoryObjectParamater(const Context *context,
73 angle::EntryPoint entryPoint,
74 GLenum pname)
75 {
76 switch (pname)
77 {
78 case GL_DEDICATED_MEMORY_OBJECT_EXT:
79 return true;
80
81 case GL_PROTECTED_MEMORY_OBJECT_EXT:
82 if (!context->getExtensions().protectedTexturesEXT)
83 {
84 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
85 return false;
86 }
87 return true;
88
89 default:
90 return false;
91 }
92 }
93
ValidateObjectIdentifierAndName(const Context * context,angle::EntryPoint entryPoint,GLenum identifier,GLuint name)94 bool ValidateObjectIdentifierAndName(const Context *context,
95 angle::EntryPoint entryPoint,
96 GLenum identifier,
97 GLuint name)
98 {
99 bool isGLES11 = context->getClientVersion() == Version(1, 1);
100 bool isGLES3 = context->getClientMajorVersion() >= 3;
101 bool isGLES31 = context->getClientVersion() >= Version(3, 1);
102 switch (identifier)
103 {
104 case GL_BUFFER_OBJECT_EXT:
105 if (context->getBuffer({name}) == nullptr)
106 {
107 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidBufferName);
108 return false;
109 }
110 return true;
111
112 case GL_SHADER_OBJECT_EXT:
113 if (isGLES11)
114 {
115 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
116 return false;
117 }
118 if (context->getShader({name}) == nullptr)
119 {
120 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidShaderName);
121 return false;
122 }
123 return true;
124
125 case GL_PROGRAM_OBJECT_EXT:
126 if (isGLES11)
127 {
128 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
129 return false;
130 }
131 if (context->getProgramNoResolveLink({name}) == nullptr)
132 {
133 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidProgramName);
134 return false;
135 }
136 return true;
137
138 case GL_VERTEX_ARRAY_OBJECT_EXT:
139 if (!isGLES3 && !context->getExtensions().vertexArrayObjectOES)
140 {
141 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
142 return false;
143 }
144 if (context->getVertexArray({name}) == nullptr)
145 {
146 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidVertexArrayName);
147 return false;
148 }
149 return true;
150
151 case GL_QUERY_OBJECT_EXT:
152 if (!isGLES3 && !context->getExtensions().occlusionQueryBooleanEXT)
153 {
154 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
155 return false;
156 }
157 if (context->getQuery({name}) == nullptr)
158 {
159 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidQueryName);
160 return false;
161 }
162 return true;
163
164 case GL_TRANSFORM_FEEDBACK:
165 if (!isGLES3)
166 {
167 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
168 return false;
169 }
170 if (context->getTransformFeedback({name}) == nullptr)
171 {
172 context->validationError(entryPoint, GL_INVALID_OPERATION,
173 kInvalidTransformFeedbackName);
174 return false;
175 }
176 return true;
177
178 case GL_SAMPLER:
179 if (!isGLES3)
180 {
181 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
182 return false;
183 }
184 if (context->getSampler({name}) == nullptr)
185 {
186 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidSamplerName);
187 return false;
188 }
189 return true;
190
191 case GL_TEXTURE:
192 if (context->getTexture({name}) == nullptr)
193 {
194 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidTextureName);
195 return false;
196 }
197 return true;
198
199 case GL_RENDERBUFFER:
200 if (!context->isRenderbuffer({name}))
201 {
202 context->validationError(entryPoint, GL_INVALID_OPERATION,
203 kInvalidRenderbufferName);
204 return false;
205 }
206 return true;
207
208 case GL_FRAMEBUFFER:
209 if (context->getFramebuffer({name}) == nullptr)
210 {
211 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidFramebufferName);
212 return false;
213 }
214 return true;
215
216 case GL_PROGRAM_PIPELINE_OBJECT_EXT:
217 if (!isGLES31 && !context->getExtensions().separateShaderObjectsEXT)
218 {
219 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidType);
220 return false;
221 }
222 if (context->getProgramPipeline({name}) == nullptr)
223 {
224 context->validationError(entryPoint, GL_INVALID_OPERATION,
225 kInvalidProgramPipelineName);
226 return false;
227 }
228 return true;
229
230 default:
231 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidIndentifier);
232 return false;
233 }
234 }
235 } // namespace
236
ValidateGetTexImage(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level)237 bool ValidateGetTexImage(const Context *context,
238 angle::EntryPoint entryPoint,
239 TextureTarget target,
240 GLint level)
241 {
242 if (!context->getExtensions().getImageANGLE)
243 {
244 context->validationError(entryPoint, GL_INVALID_OPERATION, kGetImageExtensionNotEnabled);
245 return false;
246 }
247
248 if (!ValidTexture2DDestinationTarget(context, target) &&
249 !ValidTexture3DDestinationTarget(context, target))
250 {
251 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidTextureTarget);
252 return false;
253 }
254
255 if (level < 0)
256 {
257 context->validationError(entryPoint, GL_INVALID_VALUE, kNegativeLevel);
258 return false;
259 }
260
261 TextureType textureType = TextureTargetToType(target);
262 if (!ValidMipLevel(context, textureType, level))
263 {
264 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidMipLevel);
265 return false;
266 }
267
268 return true;
269 }
270
ValidateGetTexImageANGLE(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,GLenum format,GLenum type,const void * pixels)271 bool ValidateGetTexImageANGLE(const Context *context,
272 angle::EntryPoint entryPoint,
273 TextureTarget target,
274 GLint level,
275 GLenum format,
276 GLenum type,
277 const void *pixels)
278 {
279 if (!ValidateGetTexImage(context, entryPoint, target, level))
280 {
281 return false;
282 }
283
284 Texture *texture = context->getTextureByTarget(target);
285
286 if (!ValidateGetImageFormatAndType(context, entryPoint, texture, format, type))
287 {
288 return false;
289 }
290
291 GLsizei width = static_cast<GLsizei>(texture->getWidth(target, level));
292 GLsizei height = static_cast<GLsizei>(texture->getHeight(target, level));
293 if (!ValidatePixelPack(context, entryPoint, format, type, 0, 0, width, height, -1, nullptr,
294 pixels))
295 {
296 return false;
297 }
298
299 if (texture->getFormat(target, level).info->compressed)
300 {
301 context->validationError(entryPoint, GL_INVALID_OPERATION, kGetImageCompressed);
302 return false;
303 }
304
305 return true;
306 }
307
ValidateGetCompressedTexImageANGLE(const Context * context,angle::EntryPoint entryPoint,TextureTarget target,GLint level,const void * pixels)308 bool ValidateGetCompressedTexImageANGLE(const Context *context,
309 angle::EntryPoint entryPoint,
310 TextureTarget target,
311 GLint level,
312 const void *pixels)
313 {
314 if (!ValidateGetTexImage(context, entryPoint, target, level))
315 {
316 return false;
317 }
318
319 Texture *texture = context->getTextureByTarget(target);
320 if (!texture->getFormat(target, level).info->compressed)
321 {
322 context->validationError(entryPoint, GL_INVALID_OPERATION, kGetImageNotCompressed);
323 return false;
324 }
325
326 // Check if format is emulated
327 // TODO(anglebug.com/6177): Check here for all the formats that ANGLE will use to emulate a
328 // compressed texture
329 GLenum implFormat = texture->getImplementationColorReadFormat(context);
330 if (implFormat == GL_RGBA || implFormat == GL_RG || implFormat == GL_RED)
331 {
332 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidEmulatedFormat);
333 return false;
334 }
335
336 return true;
337 }
338
ValidateGetRenderbufferImageANGLE(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum format,GLenum type,const void * pixels)339 bool ValidateGetRenderbufferImageANGLE(const Context *context,
340 angle::EntryPoint entryPoint,
341 GLenum target,
342 GLenum format,
343 GLenum type,
344 const void *pixels)
345 {
346 if (!context->getExtensions().getImageANGLE)
347 {
348 context->validationError(entryPoint, GL_INVALID_OPERATION, kGetImageExtensionNotEnabled);
349 return false;
350 }
351
352 if (target != GL_RENDERBUFFER)
353 {
354 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidRenderbufferTarget);
355 return false;
356 }
357
358 Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
359
360 if (!ValidateGetImageFormatAndType(context, entryPoint, renderbuffer, format, type))
361 {
362 return false;
363 }
364
365 GLsizei width = renderbuffer->getWidth();
366 GLsizei height = renderbuffer->getHeight();
367 if (!ValidatePixelPack(context, entryPoint, format, type, 0, 0, width, height, -1, nullptr,
368 pixels))
369 {
370 return false;
371 }
372
373 return true;
374 }
375
ValidateDrawElementsBaseVertexEXT(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)376 bool ValidateDrawElementsBaseVertexEXT(const Context *context,
377 angle::EntryPoint entryPoint,
378 PrimitiveMode mode,
379 GLsizei count,
380 DrawElementsType type,
381 const void *indices,
382 GLint basevertex)
383 {
384 if (!context->getExtensions().drawElementsBaseVertexAny())
385 {
386 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
387 return false;
388 }
389
390 return ValidateDrawElementsCommon(context, entryPoint, mode, count, type, indices, 1);
391 }
392
ValidateDrawElementsInstancedBaseVertexEXT(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instancecount,GLint basevertex)393 bool ValidateDrawElementsInstancedBaseVertexEXT(const Context *context,
394 angle::EntryPoint entryPoint,
395 PrimitiveMode mode,
396 GLsizei count,
397 DrawElementsType type,
398 const void *indices,
399 GLsizei instancecount,
400 GLint basevertex)
401 {
402 if (!context->getExtensions().drawElementsBaseVertexAny())
403 {
404 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
405 return false;
406 }
407
408 return ValidateDrawElementsInstancedBase(context, entryPoint, mode, count, type, indices,
409 instancecount);
410 }
411
ValidateDrawRangeElementsBaseVertexEXT(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)412 bool ValidateDrawRangeElementsBaseVertexEXT(const Context *context,
413 angle::EntryPoint entryPoint,
414 PrimitiveMode mode,
415 GLuint start,
416 GLuint end,
417 GLsizei count,
418 DrawElementsType type,
419 const void *indices,
420 GLint basevertex)
421 {
422 if (!context->getExtensions().drawElementsBaseVertexAny())
423 {
424 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
425 return false;
426 }
427
428 if (end < start)
429 {
430 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidElementRange);
431 return false;
432 }
433
434 if (!ValidateDrawElementsCommon(context, entryPoint, mode, count, type, indices, 0))
435 {
436 return false;
437 }
438
439 // Skip range checks for no-op calls.
440 if (count <= 0)
441 {
442 return true;
443 }
444
445 // Note that resolving the index range is a bit slow. We should probably optimize this.
446 IndexRange indexRange;
447 ANGLE_VALIDATION_TRY(context->getState().getVertexArray()->getIndexRange(context, type, count,
448 indices, &indexRange));
449
450 if (indexRange.end > end || indexRange.start < start)
451 {
452 // GL spec says that behavior in this case is undefined - generating an error is fine.
453 context->validationError(entryPoint, GL_INVALID_OPERATION, kExceedsElementRange);
454 return false;
455 }
456 return true;
457 }
458
ValidateMultiDrawElementsBaseVertexEXT(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,const GLsizei * count,DrawElementsType type,const void * const * indices,GLsizei drawcount,const GLint * basevertex)459 bool ValidateMultiDrawElementsBaseVertexEXT(const Context *context,
460 angle::EntryPoint entryPoint,
461 PrimitiveMode mode,
462 const GLsizei *count,
463 DrawElementsType type,
464 const void *const *indices,
465 GLsizei drawcount,
466 const GLint *basevertex)
467 {
468 return true;
469 }
470
ValidateMultiDrawArraysIndirectEXT(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode modePacked,const void * indirect,GLsizei drawcount,GLsizei stride)471 bool ValidateMultiDrawArraysIndirectEXT(const Context *context,
472 angle::EntryPoint entryPoint,
473 PrimitiveMode modePacked,
474 const void *indirect,
475 GLsizei drawcount,
476 GLsizei stride)
477 {
478 if (!ValidateMultiDrawIndirectBase(context, entryPoint, drawcount, stride))
479 {
480 return false;
481 }
482
483 if (!ValidateDrawArraysIndirect(context, entryPoint, modePacked, indirect))
484 {
485 return false;
486 }
487
488 return true;
489 }
490
ValidateMultiDrawElementsIndirectEXT(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode modePacked,DrawElementsType typePacked,const void * indirect,GLsizei drawcount,GLsizei stride)491 bool ValidateMultiDrawElementsIndirectEXT(const Context *context,
492 angle::EntryPoint entryPoint,
493 PrimitiveMode modePacked,
494 DrawElementsType typePacked,
495 const void *indirect,
496 GLsizei drawcount,
497 GLsizei stride)
498 {
499 if (!ValidateMultiDrawIndirectBase(context, entryPoint, drawcount, stride))
500 {
501 return false;
502 }
503
504 const State &state = context->getState();
505 TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
506 if (!ValidateDrawElementsIndirect(context, entryPoint, modePacked, typePacked, indirect))
507 {
508 return false;
509 }
510
511 if (curTransformFeedback && curTransformFeedback->isActive() &&
512 !curTransformFeedback->isPaused())
513 {
514 // EXT_geometry_shader allows transform feedback to work with all draw commands.
515 // [EXT_geometry_shader] Section 12.1, "Transform Feedback"
516 if (context->getExtensions().geometryShaderAny() || context->getClientVersion() >= ES_3_2)
517 {
518 if (!ValidateTransformFeedbackPrimitiveMode(
519 context, entryPoint, curTransformFeedback->getPrimitiveMode(), modePacked))
520 {
521 context->validationError(entryPoint, GL_INVALID_OPERATION,
522 kInvalidDrawModeTransformFeedback);
523 return false;
524 }
525 }
526 else
527 {
528 // An INVALID_OPERATION error is generated if transform feedback is active and not
529 // paused.
530 context->validationError(entryPoint, GL_INVALID_OPERATION,
531 kUnsupportedDrawModeForTransformFeedback);
532 return false;
533 }
534 }
535
536 return true;
537 }
538
ValidateDrawElementsBaseVertexOES(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)539 bool ValidateDrawElementsBaseVertexOES(const Context *context,
540 angle::EntryPoint entryPoint,
541 PrimitiveMode mode,
542 GLsizei count,
543 DrawElementsType type,
544 const void *indices,
545 GLint basevertex)
546 {
547 if (!context->getExtensions().drawElementsBaseVertexAny())
548 {
549 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
550 return false;
551 }
552
553 return ValidateDrawElementsCommon(context, entryPoint, mode, count, type, indices, 1);
554 }
555
ValidateDrawElementsInstancedBaseVertexOES(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instancecount,GLint basevertex)556 bool ValidateDrawElementsInstancedBaseVertexOES(const Context *context,
557 angle::EntryPoint entryPoint,
558 PrimitiveMode mode,
559 GLsizei count,
560 DrawElementsType type,
561 const void *indices,
562 GLsizei instancecount,
563 GLint basevertex)
564 {
565 if (!context->getExtensions().drawElementsBaseVertexAny())
566 {
567 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
568 return false;
569 }
570
571 return ValidateDrawElementsInstancedBase(context, entryPoint, mode, count, type, indices,
572 instancecount);
573 }
574
ValidateDrawRangeElementsBaseVertexOES(const Context * context,angle::EntryPoint entryPoint,PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)575 bool ValidateDrawRangeElementsBaseVertexOES(const Context *context,
576 angle::EntryPoint entryPoint,
577 PrimitiveMode mode,
578 GLuint start,
579 GLuint end,
580 GLsizei count,
581 DrawElementsType type,
582 const void *indices,
583 GLint basevertex)
584 {
585 if (!context->getExtensions().drawElementsBaseVertexAny())
586 {
587 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
588 return false;
589 }
590
591 if (end < start)
592 {
593 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidElementRange);
594 return false;
595 }
596
597 if (!ValidateDrawElementsCommon(context, entryPoint, mode, count, type, indices, 0))
598 {
599 return false;
600 }
601
602 // Skip range checks for no-op calls.
603 if (count <= 0)
604 {
605 return true;
606 }
607
608 // Note that resolving the index range is a bit slow. We should probably optimize this.
609 IndexRange indexRange;
610 ANGLE_VALIDATION_TRY(context->getState().getVertexArray()->getIndexRange(context, type, count,
611 indices, &indexRange));
612
613 if (indexRange.end > end || indexRange.start < start)
614 {
615 // GL spec says that behavior in this case is undefined - generating an error is fine.
616 context->validationError(entryPoint, GL_INVALID_OPERATION, kExceedsElementRange);
617 return false;
618 }
619 return true;
620 }
621
622 // GL_KHR_blend_equation_advanced
ValidateBlendBarrierKHR(const Context * context,angle::EntryPoint entryPoint)623 bool ValidateBlendBarrierKHR(const Context *context, angle::EntryPoint entryPoint)
624 {
625 const Extensions &extensions = context->getExtensions();
626
627 if (!extensions.blendEquationAdvancedKHR)
628 {
629 context->validationError(entryPoint, GL_INVALID_ENUM, kAdvancedBlendExtensionNotEnabled);
630 }
631
632 return true;
633 }
634
ValidateBlendEquationSeparateiEXT(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum modeRGB,GLenum modeAlpha)635 bool ValidateBlendEquationSeparateiEXT(const Context *context,
636 angle::EntryPoint entryPoint,
637 GLuint buf,
638 GLenum modeRGB,
639 GLenum modeAlpha)
640 {
641 if (!context->getExtensions().drawBuffersIndexedEXT)
642 {
643 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
644 return false;
645 }
646
647 return ValidateBlendEquationSeparatei(context, entryPoint, buf, modeRGB, modeAlpha);
648 }
649
ValidateBlendEquationiEXT(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum mode)650 bool ValidateBlendEquationiEXT(const Context *context,
651 angle::EntryPoint entryPoint,
652 GLuint buf,
653 GLenum mode)
654 {
655 if (!context->getExtensions().drawBuffersIndexedEXT)
656 {
657 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
658 return false;
659 }
660
661 return ValidateBlendEquationi(context, entryPoint, buf, mode);
662 }
663
ValidateBlendFuncSeparateiEXT(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)664 bool ValidateBlendFuncSeparateiEXT(const Context *context,
665 angle::EntryPoint entryPoint,
666 GLuint buf,
667 GLenum srcRGB,
668 GLenum dstRGB,
669 GLenum srcAlpha,
670 GLenum dstAlpha)
671 {
672 if (!context->getExtensions().drawBuffersIndexedEXT)
673 {
674 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
675 return false;
676 }
677
678 return ValidateBlendFuncSeparatei(context, entryPoint, buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
679 }
680
ValidateBlendFunciEXT(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum src,GLenum dst)681 bool ValidateBlendFunciEXT(const Context *context,
682 angle::EntryPoint entryPoint,
683 GLuint buf,
684 GLenum src,
685 GLenum dst)
686 {
687 if (!context->getExtensions().drawBuffersIndexedEXT)
688 {
689 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
690 return false;
691 }
692
693 return ValidateBlendFunci(context, entryPoint, buf, src, dst);
694 }
695
ValidateColorMaskiEXT(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLboolean r,GLboolean g,GLboolean b,GLboolean a)696 bool ValidateColorMaskiEXT(const Context *context,
697 angle::EntryPoint entryPoint,
698 GLuint index,
699 GLboolean r,
700 GLboolean g,
701 GLboolean b,
702 GLboolean a)
703 {
704 if (!context->getExtensions().drawBuffersIndexedEXT)
705 {
706 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
707 return false;
708 }
709
710 return ValidateColorMaski(context, entryPoint, index, r, g, b, a);
711 }
712
ValidateDisableiEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLuint index)713 bool ValidateDisableiEXT(const Context *context,
714 angle::EntryPoint entryPoint,
715 GLenum target,
716 GLuint index)
717 {
718 if (!context->getExtensions().drawBuffersIndexedEXT)
719 {
720 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
721 return false;
722 }
723
724 return ValidateDisablei(context, entryPoint, target, index);
725 }
726
ValidateEnableiEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLuint index)727 bool ValidateEnableiEXT(const Context *context,
728 angle::EntryPoint entryPoint,
729 GLenum target,
730 GLuint index)
731 {
732 if (!context->getExtensions().drawBuffersIndexedEXT)
733 {
734 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
735 return false;
736 }
737
738 return ValidateEnablei(context, entryPoint, target, index);
739 }
740
ValidateIsEnablediEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLuint index)741 bool ValidateIsEnablediEXT(const Context *context,
742 angle::EntryPoint entryPoint,
743 GLenum target,
744 GLuint index)
745 {
746 if (!context->getExtensions().drawBuffersIndexedEXT)
747 {
748 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
749 return false;
750 }
751
752 return ValidateIsEnabledi(context, entryPoint, target, index);
753 }
754
ValidateBlendEquationSeparateiOES(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum modeRGB,GLenum modeAlpha)755 bool ValidateBlendEquationSeparateiOES(const Context *context,
756 angle::EntryPoint entryPoint,
757 GLuint buf,
758 GLenum modeRGB,
759 GLenum modeAlpha)
760 {
761 if (!context->getExtensions().drawBuffersIndexedOES)
762 {
763 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
764 return false;
765 }
766
767 return ValidateBlendEquationSeparatei(context, entryPoint, buf, modeRGB, modeAlpha);
768 }
769
ValidateBlendEquationiOES(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum mode)770 bool ValidateBlendEquationiOES(const Context *context,
771 angle::EntryPoint entryPoint,
772 GLuint buf,
773 GLenum mode)
774 {
775 if (!context->getExtensions().drawBuffersIndexedOES)
776 {
777 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
778 return false;
779 }
780
781 return ValidateBlendEquationi(context, entryPoint, buf, mode);
782 }
783
ValidateBlendFuncSeparateiOES(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)784 bool ValidateBlendFuncSeparateiOES(const Context *context,
785 angle::EntryPoint entryPoint,
786 GLuint buf,
787 GLenum srcRGB,
788 GLenum dstRGB,
789 GLenum srcAlpha,
790 GLenum dstAlpha)
791 {
792 if (!context->getExtensions().drawBuffersIndexedOES)
793 {
794 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
795 return false;
796 }
797
798 return ValidateBlendFuncSeparatei(context, entryPoint, buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
799 }
800
ValidateBlendFunciOES(const Context * context,angle::EntryPoint entryPoint,GLuint buf,GLenum src,GLenum dst)801 bool ValidateBlendFunciOES(const Context *context,
802 angle::EntryPoint entryPoint,
803 GLuint buf,
804 GLenum src,
805 GLenum dst)
806 {
807 if (!context->getExtensions().drawBuffersIndexedOES)
808 {
809 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
810 return false;
811 }
812
813 return ValidateBlendFunci(context, entryPoint, buf, src, dst);
814 }
815
ValidateColorMaskiOES(const Context * context,angle::EntryPoint entryPoint,GLuint index,GLboolean r,GLboolean g,GLboolean b,GLboolean a)816 bool ValidateColorMaskiOES(const Context *context,
817 angle::EntryPoint entryPoint,
818 GLuint index,
819 GLboolean r,
820 GLboolean g,
821 GLboolean b,
822 GLboolean a)
823 {
824 if (!context->getExtensions().drawBuffersIndexedOES)
825 {
826 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
827 return false;
828 }
829
830 return ValidateColorMaski(context, entryPoint, index, r, g, b, a);
831 }
832
ValidateDisableiOES(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLuint index)833 bool ValidateDisableiOES(const Context *context,
834 angle::EntryPoint entryPoint,
835 GLenum target,
836 GLuint index)
837 {
838 if (!context->getExtensions().drawBuffersIndexedOES)
839 {
840 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
841 return false;
842 }
843
844 return ValidateDisablei(context, entryPoint, target, index);
845 }
846
ValidateEnableiOES(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLuint index)847 bool ValidateEnableiOES(const Context *context,
848 angle::EntryPoint entryPoint,
849 GLenum target,
850 GLuint index)
851 {
852 if (!context->getExtensions().drawBuffersIndexedOES)
853 {
854 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
855 return false;
856 }
857
858 return ValidateEnablei(context, entryPoint, target, index);
859 }
860
ValidateIsEnablediOES(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLuint index)861 bool ValidateIsEnablediOES(const Context *context,
862 angle::EntryPoint entryPoint,
863 GLenum target,
864 GLuint index)
865 {
866 if (!context->getExtensions().drawBuffersIndexedOES)
867 {
868 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
869 return false;
870 }
871
872 return ValidateIsEnabledi(context, entryPoint, target, index);
873 }
874
ValidateGetInteger64vEXT(const Context * context,angle::EntryPoint entryPoint,GLenum pname,const GLint64 * data)875 bool ValidateGetInteger64vEXT(const Context *context,
876 angle::EntryPoint entryPoint,
877 GLenum pname,
878 const GLint64 *data)
879 {
880 if (!context->getExtensions().disjointTimerQueryEXT)
881 {
882 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
883 return false;
884 }
885
886 GLenum nativeType = GL_NONE;
887 unsigned int numParams = 0;
888 if (!ValidateStateQuery(context, entryPoint, pname, &nativeType, &numParams))
889 {
890 return false;
891 }
892
893 return true;
894 }
895
ValidateCopyImageSubDataEXT(const Context * context,angle::EntryPoint entryPoint,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)896 bool ValidateCopyImageSubDataEXT(const Context *context,
897 angle::EntryPoint entryPoint,
898 GLuint srcName,
899 GLenum srcTarget,
900 GLint srcLevel,
901 GLint srcX,
902 GLint srcY,
903 GLint srcZ,
904 GLuint dstName,
905 GLenum dstTarget,
906 GLint dstLevel,
907 GLint dstX,
908 GLint dstY,
909 GLint dstZ,
910 GLsizei srcWidth,
911 GLsizei srcHeight,
912 GLsizei srcDepth)
913 {
914 if (!context->getExtensions().copyImageEXT)
915 {
916 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
917 return false;
918 }
919
920 return ValidateCopyImageSubDataBase(context, entryPoint, srcName, srcTarget, srcLevel, srcX,
921 srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ,
922 srcWidth, srcHeight, srcDepth);
923 }
924
ValidateCopyImageSubDataOES(const Context * context,angle::EntryPoint entryPoint,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)925 bool ValidateCopyImageSubDataOES(const Context *context,
926 angle::EntryPoint entryPoint,
927 GLuint srcName,
928 GLenum srcTarget,
929 GLint srcLevel,
930 GLint srcX,
931 GLint srcY,
932 GLint srcZ,
933 GLuint dstName,
934 GLenum dstTarget,
935 GLint dstLevel,
936 GLint dstX,
937 GLint dstY,
938 GLint dstZ,
939 GLsizei srcWidth,
940 GLsizei srcHeight,
941 GLsizei srcDepth)
942 {
943 if (!context->getExtensions().copyImageEXT)
944 {
945 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
946 return false;
947 }
948
949 return ValidateCopyImageSubDataBase(context, entryPoint, srcName, srcTarget, srcLevel, srcX,
950 srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ,
951 srcWidth, srcHeight, srcDepth);
952 }
953
ValidateBufferStorageMemEXT(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLsizeiptr size,MemoryObjectID memory,GLuint64 offset)954 bool ValidateBufferStorageMemEXT(const Context *context,
955 angle::EntryPoint entryPoint,
956 TextureType target,
957 GLsizeiptr size,
958 MemoryObjectID memory,
959 GLuint64 offset)
960 {
961 if (!context->getExtensions().memoryObjectEXT)
962 {
963 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
964 return false;
965 }
966
967 UNIMPLEMENTED();
968 return false;
969 }
970
ValidateCreateMemoryObjectsEXT(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const MemoryObjectID * memoryObjects)971 bool ValidateCreateMemoryObjectsEXT(const Context *context,
972 angle::EntryPoint entryPoint,
973 GLsizei n,
974 const MemoryObjectID *memoryObjects)
975 {
976 if (!context->getExtensions().memoryObjectEXT)
977 {
978 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
979 return false;
980 }
981
982 return ValidateGenOrDelete(context, entryPoint, n);
983 }
984
ValidateDeleteMemoryObjectsEXT(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const MemoryObjectID * memoryObjects)985 bool ValidateDeleteMemoryObjectsEXT(const Context *context,
986 angle::EntryPoint entryPoint,
987 GLsizei n,
988 const MemoryObjectID *memoryObjects)
989 {
990 if (!context->getExtensions().memoryObjectEXT)
991 {
992 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
993 return false;
994 }
995
996 return ValidateGenOrDelete(context, entryPoint, n);
997 }
998
ValidateGetMemoryObjectParameterivEXT(const Context * context,angle::EntryPoint entryPoint,MemoryObjectID memoryObject,GLenum pname,const GLint * params)999 bool ValidateGetMemoryObjectParameterivEXT(const Context *context,
1000 angle::EntryPoint entryPoint,
1001 MemoryObjectID memoryObject,
1002 GLenum pname,
1003 const GLint *params)
1004 {
1005 if (!context->getExtensions().memoryObjectEXT)
1006 {
1007 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1008 return false;
1009 }
1010
1011 const MemoryObject *memory = context->getMemoryObject(memoryObject);
1012 if (memory == nullptr)
1013 {
1014 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidMemoryObject);
1015 }
1016
1017 if (!IsValidMemoryObjectParamater(context, entryPoint, pname))
1018 {
1019 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidMemoryObjectParameter);
1020 return false;
1021 }
1022
1023 return true;
1024 }
1025
ValidateGetUnsignedBytevEXT(const Context * context,angle::EntryPoint entryPoint,GLenum pname,const GLubyte * data)1026 bool ValidateGetUnsignedBytevEXT(const Context *context,
1027 angle::EntryPoint entryPoint,
1028 GLenum pname,
1029 const GLubyte *data)
1030 {
1031 if (!context->getExtensions().memoryObjectEXT && !context->getExtensions().semaphoreEXT)
1032 {
1033 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1034 return false;
1035 }
1036
1037 UNIMPLEMENTED();
1038 return false;
1039 }
1040
ValidateGetUnsignedBytei_vEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLuint index,const GLubyte * data)1041 bool ValidateGetUnsignedBytei_vEXT(const Context *context,
1042 angle::EntryPoint entryPoint,
1043 GLenum target,
1044 GLuint index,
1045 const GLubyte *data)
1046 {
1047 if (!context->getExtensions().memoryObjectEXT && !context->getExtensions().semaphoreEXT)
1048 {
1049 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1050 return false;
1051 }
1052
1053 UNIMPLEMENTED();
1054 return false;
1055 }
1056
ValidateIsMemoryObjectEXT(const Context * context,angle::EntryPoint entryPoint,MemoryObjectID memoryObject)1057 bool ValidateIsMemoryObjectEXT(const Context *context,
1058 angle::EntryPoint entryPoint,
1059 MemoryObjectID memoryObject)
1060 {
1061 if (!context->getExtensions().memoryObjectEXT)
1062 {
1063 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1064 return false;
1065 }
1066
1067 return true;
1068 }
1069
ValidateMemoryObjectParameterivEXT(const Context * context,angle::EntryPoint entryPoint,MemoryObjectID memoryObject,GLenum pname,const GLint * params)1070 bool ValidateMemoryObjectParameterivEXT(const Context *context,
1071 angle::EntryPoint entryPoint,
1072 MemoryObjectID memoryObject,
1073 GLenum pname,
1074 const GLint *params)
1075 {
1076 if (!context->getExtensions().memoryObjectEXT)
1077 {
1078 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1079 return false;
1080 }
1081
1082 const MemoryObject *memory = context->getMemoryObject(memoryObject);
1083 if (memory == nullptr)
1084 {
1085 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidMemoryObject);
1086 return false;
1087 }
1088
1089 if (memory->isImmutable())
1090 {
1091 context->validationError(entryPoint, GL_INVALID_OPERATION, kImmutableMemoryObject);
1092 return false;
1093 }
1094
1095 if (!IsValidMemoryObjectParamater(context, entryPoint, pname))
1096 {
1097 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidMemoryObjectParameter);
1098 return false;
1099 }
1100
1101 return true;
1102 }
1103
ValidateTexStorageMem2DEXT(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,MemoryObjectID memory,GLuint64 offset)1104 bool ValidateTexStorageMem2DEXT(const Context *context,
1105 angle::EntryPoint entryPoint,
1106 TextureType target,
1107 GLsizei levels,
1108 GLenum internalFormat,
1109 GLsizei width,
1110 GLsizei height,
1111 MemoryObjectID memory,
1112 GLuint64 offset)
1113 {
1114 if (!context->getExtensions().memoryObjectEXT)
1115 {
1116 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1117 return false;
1118 }
1119
1120 if (context->getClientMajorVersion() < 3)
1121 {
1122 return ValidateES2TexStorageParametersBase(context, entryPoint, target, levels,
1123 internalFormat, width, height);
1124 }
1125
1126 ASSERT(context->getClientMajorVersion() >= 3);
1127 return ValidateES3TexStorage2DParameters(context, entryPoint, target, levels, internalFormat,
1128 width, height, 1);
1129 }
1130
ValidateTexStorageMem3DEXT(const Context * context,angle::EntryPoint entryPoint,TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,MemoryObjectID memory,GLuint64 offset)1131 bool ValidateTexStorageMem3DEXT(const Context *context,
1132 angle::EntryPoint entryPoint,
1133 TextureType target,
1134 GLsizei levels,
1135 GLenum internalFormat,
1136 GLsizei width,
1137 GLsizei height,
1138 GLsizei depth,
1139 MemoryObjectID memory,
1140 GLuint64 offset)
1141 {
1142 if (!context->getExtensions().memoryObjectEXT)
1143 {
1144 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1145 return false;
1146 }
1147
1148 UNIMPLEMENTED();
1149 return false;
1150 }
1151
ValidateImportMemoryFdEXT(const Context * context,angle::EntryPoint entryPoint,MemoryObjectID memory,GLuint64 size,HandleType handleType,GLint fd)1152 bool ValidateImportMemoryFdEXT(const Context *context,
1153 angle::EntryPoint entryPoint,
1154 MemoryObjectID memory,
1155 GLuint64 size,
1156 HandleType handleType,
1157 GLint fd)
1158 {
1159 if (!context->getExtensions().memoryObjectFdEXT)
1160 {
1161 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1162 return false;
1163 }
1164
1165 switch (handleType)
1166 {
1167 case HandleType::OpaqueFd:
1168 break;
1169 default:
1170 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidHandleType);
1171 return false;
1172 }
1173
1174 return true;
1175 }
1176
ValidateImportMemoryZirconHandleANGLE(const Context * context,angle::EntryPoint entryPoint,MemoryObjectID memory,GLuint64 size,HandleType handleType,GLuint handle)1177 bool ValidateImportMemoryZirconHandleANGLE(const Context *context,
1178 angle::EntryPoint entryPoint,
1179 MemoryObjectID memory,
1180 GLuint64 size,
1181 HandleType handleType,
1182 GLuint handle)
1183 {
1184 if (!context->getExtensions().memoryObjectFuchsiaANGLE)
1185 {
1186 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1187 return false;
1188 }
1189
1190 switch (handleType)
1191 {
1192 case HandleType::ZirconVmo:
1193 break;
1194 default:
1195 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidHandleType);
1196 return false;
1197 }
1198
1199 return true;
1200 }
1201
ValidateDeleteSemaphoresEXT(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const SemaphoreID * semaphores)1202 bool ValidateDeleteSemaphoresEXT(const Context *context,
1203 angle::EntryPoint entryPoint,
1204 GLsizei n,
1205 const SemaphoreID *semaphores)
1206 {
1207 if (!context->getExtensions().semaphoreEXT)
1208 {
1209 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1210 return false;
1211 }
1212
1213 return ValidateGenOrDelete(context, entryPoint, n);
1214 }
1215
ValidateGenSemaphoresEXT(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const SemaphoreID * semaphores)1216 bool ValidateGenSemaphoresEXT(const Context *context,
1217 angle::EntryPoint entryPoint,
1218 GLsizei n,
1219 const SemaphoreID *semaphores)
1220 {
1221 if (!context->getExtensions().semaphoreEXT)
1222 {
1223 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1224 return false;
1225 }
1226
1227 return ValidateGenOrDelete(context, entryPoint, n);
1228 }
1229
ValidateGetSemaphoreParameterui64vEXT(const Context * context,angle::EntryPoint entryPoint,SemaphoreID semaphore,GLenum pname,const GLuint64 * params)1230 bool ValidateGetSemaphoreParameterui64vEXT(const Context *context,
1231 angle::EntryPoint entryPoint,
1232 SemaphoreID semaphore,
1233 GLenum pname,
1234 const GLuint64 *params)
1235 {
1236 if (!context->getExtensions().semaphoreEXT)
1237 {
1238 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1239 return false;
1240 }
1241
1242 UNIMPLEMENTED();
1243 return false;
1244 }
1245
ValidateIsSemaphoreEXT(const Context * context,angle::EntryPoint entryPoint,SemaphoreID semaphore)1246 bool ValidateIsSemaphoreEXT(const Context *context,
1247 angle::EntryPoint entryPoint,
1248 SemaphoreID semaphore)
1249 {
1250 if (!context->getExtensions().semaphoreEXT)
1251 {
1252 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1253 return false;
1254 }
1255
1256 return true;
1257 }
1258
ValidateSemaphoreParameterui64vEXT(const Context * context,angle::EntryPoint entryPoint,SemaphoreID semaphore,GLenum pname,const GLuint64 * params)1259 bool ValidateSemaphoreParameterui64vEXT(const Context *context,
1260 angle::EntryPoint entryPoint,
1261 SemaphoreID semaphore,
1262 GLenum pname,
1263 const GLuint64 *params)
1264 {
1265 if (!context->getExtensions().semaphoreEXT)
1266 {
1267 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1268 return false;
1269 }
1270
1271 UNIMPLEMENTED();
1272 return false;
1273 }
1274
ValidateSignalSemaphoreEXT(const Context * context,angle::EntryPoint entryPoint,SemaphoreID semaphore,GLuint numBufferBarriers,const BufferID * buffers,GLuint numTextureBarriers,const TextureID * textures,const GLenum * dstLayouts)1275 bool ValidateSignalSemaphoreEXT(const Context *context,
1276 angle::EntryPoint entryPoint,
1277 SemaphoreID semaphore,
1278 GLuint numBufferBarriers,
1279 const BufferID *buffers,
1280 GLuint numTextureBarriers,
1281 const TextureID *textures,
1282 const GLenum *dstLayouts)
1283 {
1284 if (!context->getExtensions().semaphoreEXT)
1285 {
1286 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1287 return false;
1288 }
1289
1290 for (GLuint i = 0; i < numBufferBarriers; ++i)
1291 {
1292 if (!context->getBuffer(buffers[i]))
1293 {
1294 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidBufferName);
1295 return false;
1296 }
1297 }
1298
1299 for (GLuint i = 0; i < numTextureBarriers; ++i)
1300 {
1301 if (!context->getTexture(textures[i]))
1302 {
1303 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidTextureName);
1304 return false;
1305 }
1306 if (!IsValidImageLayout(FromGLenum<ImageLayout>(dstLayouts[i])))
1307 {
1308 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidImageLayout);
1309 return false;
1310 }
1311 }
1312
1313 return true;
1314 }
1315
ValidateWaitSemaphoreEXT(const Context * context,angle::EntryPoint entryPoint,SemaphoreID semaphore,GLuint numBufferBarriers,const BufferID * buffers,GLuint numTextureBarriers,const TextureID * textures,const GLenum * srcLayouts)1316 bool ValidateWaitSemaphoreEXT(const Context *context,
1317 angle::EntryPoint entryPoint,
1318 SemaphoreID semaphore,
1319 GLuint numBufferBarriers,
1320 const BufferID *buffers,
1321 GLuint numTextureBarriers,
1322 const TextureID *textures,
1323 const GLenum *srcLayouts)
1324 {
1325 if (!context->getExtensions().semaphoreEXT)
1326 {
1327 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1328 return false;
1329 }
1330
1331 for (GLuint i = 0; i < numBufferBarriers; ++i)
1332 {
1333 if (!context->getBuffer(buffers[i]))
1334 {
1335 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidBufferName);
1336 return false;
1337 }
1338 }
1339
1340 for (GLuint i = 0; i < numTextureBarriers; ++i)
1341 {
1342 if (!context->getTexture(textures[i]))
1343 {
1344 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidTextureName);
1345 return false;
1346 }
1347 if (!IsValidImageLayout(FromGLenum<ImageLayout>(srcLayouts[i])))
1348 {
1349 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidImageLayout);
1350 return false;
1351 }
1352 }
1353
1354 return true;
1355 }
1356
ValidateImportSemaphoreFdEXT(const Context * context,angle::EntryPoint entryPoint,SemaphoreID semaphore,HandleType handleType,GLint fd)1357 bool ValidateImportSemaphoreFdEXT(const Context *context,
1358 angle::EntryPoint entryPoint,
1359 SemaphoreID semaphore,
1360 HandleType handleType,
1361 GLint fd)
1362 {
1363 if (!context->getExtensions().semaphoreFdEXT)
1364 {
1365 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1366 return false;
1367 }
1368
1369 switch (handleType)
1370 {
1371 case HandleType::OpaqueFd:
1372 break;
1373 default:
1374 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidHandleType);
1375 return false;
1376 }
1377
1378 return true;
1379 }
1380
ValidateGetSamplerParameterIivEXT(const Context * context,angle::EntryPoint entryPoint,SamplerID samplerPacked,GLenum pname,const GLint * params)1381 bool ValidateGetSamplerParameterIivEXT(const Context *context,
1382 angle::EntryPoint entryPoint,
1383 SamplerID samplerPacked,
1384 GLenum pname,
1385 const GLint *params)
1386 {
1387 if (context->getClientMajorVersion() < 3)
1388 {
1389 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1390 return false;
1391 }
1392 return ValidateGetSamplerParameterBase(context, entryPoint, samplerPacked, pname, nullptr);
1393 }
1394
ValidateGetSamplerParameterIuivEXT(const Context * context,angle::EntryPoint entryPoint,SamplerID samplerPacked,GLenum pname,const GLuint * params)1395 bool ValidateGetSamplerParameterIuivEXT(const Context *context,
1396 angle::EntryPoint entryPoint,
1397 SamplerID samplerPacked,
1398 GLenum pname,
1399 const GLuint *params)
1400 {
1401 if (context->getClientMajorVersion() < 3)
1402 {
1403 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1404 return false;
1405 }
1406 return ValidateGetSamplerParameterBase(context, entryPoint, samplerPacked, pname, nullptr);
1407 }
1408
ValidateGetTexParameterIivEXT(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLenum pname,const GLint * params)1409 bool ValidateGetTexParameterIivEXT(const Context *context,
1410 angle::EntryPoint entryPoint,
1411 TextureType targetPacked,
1412 GLenum pname,
1413 const GLint *params)
1414 {
1415 if (context->getClientMajorVersion() < 3)
1416 {
1417 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1418 return false;
1419 }
1420 return ValidateGetTexParameterBase(context, entryPoint, targetPacked, pname, nullptr);
1421 }
1422
ValidateGetTexParameterIuivEXT(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLenum pname,const GLuint * params)1423 bool ValidateGetTexParameterIuivEXT(const Context *context,
1424 angle::EntryPoint entryPoint,
1425 TextureType targetPacked,
1426 GLenum pname,
1427 const GLuint *params)
1428 {
1429 if (context->getClientMajorVersion() < 3)
1430 {
1431 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1432 return false;
1433 }
1434 return ValidateGetTexParameterBase(context, entryPoint, targetPacked, pname, nullptr);
1435 }
1436
ValidateSamplerParameterIivEXT(const Context * context,angle::EntryPoint entryPoint,SamplerID samplerPacked,GLenum pname,const GLint * param)1437 bool ValidateSamplerParameterIivEXT(const Context *context,
1438 angle::EntryPoint entryPoint,
1439 SamplerID samplerPacked,
1440 GLenum pname,
1441 const GLint *param)
1442 {
1443 if (context->getClientMajorVersion() < 3)
1444 {
1445 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1446 return false;
1447 }
1448 return ValidateSamplerParameterBase(context, entryPoint, samplerPacked, pname, -1, true, param);
1449 }
1450
ValidateSamplerParameterIuivEXT(const Context * context,angle::EntryPoint entryPoint,SamplerID samplerPacked,GLenum pname,const GLuint * param)1451 bool ValidateSamplerParameterIuivEXT(const Context *context,
1452 angle::EntryPoint entryPoint,
1453 SamplerID samplerPacked,
1454 GLenum pname,
1455 const GLuint *param)
1456 {
1457 if (context->getClientMajorVersion() < 3)
1458 {
1459 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1460 return false;
1461 }
1462 return ValidateSamplerParameterBase(context, entryPoint, samplerPacked, pname, -1, true, param);
1463 }
1464
ValidateTexParameterIivEXT(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLenum pname,const GLint * params)1465 bool ValidateTexParameterIivEXT(const Context *context,
1466 angle::EntryPoint entryPoint,
1467 TextureType targetPacked,
1468 GLenum pname,
1469 const GLint *params)
1470 {
1471 if (context->getClientMajorVersion() < 3)
1472 {
1473 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1474 return false;
1475 }
1476 return ValidateTexParameterBase(context, entryPoint, targetPacked, pname, -1, true, params);
1477 }
1478
ValidateTexParameterIuivEXT(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLenum pname,const GLuint * params)1479 bool ValidateTexParameterIuivEXT(const Context *context,
1480 angle::EntryPoint entryPoint,
1481 TextureType targetPacked,
1482 GLenum pname,
1483 const GLuint *params)
1484 {
1485 if (context->getClientMajorVersion() < 3)
1486 {
1487 context->validationError(entryPoint, GL_INVALID_OPERATION, kES3Required);
1488 return false;
1489 }
1490 return ValidateTexParameterBase(context, entryPoint, targetPacked, pname, -1, true, params);
1491 }
1492
ValidateImportSemaphoreZirconHandleANGLE(const Context * context,angle::EntryPoint entryPoint,SemaphoreID semaphore,HandleType handleType,GLuint handle)1493 bool ValidateImportSemaphoreZirconHandleANGLE(const Context *context,
1494 angle::EntryPoint entryPoint,
1495 SemaphoreID semaphore,
1496 HandleType handleType,
1497 GLuint handle)
1498 {
1499 if (!context->getExtensions().semaphoreFuchsiaANGLE)
1500 {
1501 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1502 return false;
1503 }
1504
1505 switch (handleType)
1506 {
1507 case HandleType::ZirconEvent:
1508 break;
1509 default:
1510 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidHandleType);
1511 return false;
1512 }
1513
1514 return true;
1515 }
1516
ValidateFramebufferFetchBarrierEXT(const Context * context,angle::EntryPoint entryPoint)1517 bool ValidateFramebufferFetchBarrierEXT(const Context *context, angle::EntryPoint entryPoint)
1518 {
1519 return true;
1520 }
1521
ValidatePatchParameteriEXT(const Context * context,angle::EntryPoint entryPoint,GLenum pname,GLint value)1522 bool ValidatePatchParameteriEXT(const Context *context,
1523 angle::EntryPoint entryPoint,
1524 GLenum pname,
1525 GLint value)
1526 {
1527 if (!context->getExtensions().tessellationShaderEXT)
1528 {
1529 context->validationError(entryPoint, GL_INVALID_OPERATION,
1530 kTessellationShaderExtensionNotEnabled);
1531 return false;
1532 }
1533
1534 if (pname != GL_PATCH_VERTICES)
1535 {
1536 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
1537 return false;
1538 }
1539
1540 if (value <= 0)
1541 {
1542 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidValueNonPositive);
1543 return false;
1544 }
1545
1546 if (value > context->getCaps().maxPatchVertices)
1547 {
1548 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidValueExceedsMaxPatchSize);
1549 return false;
1550 }
1551
1552 return true;
1553 }
1554
ValidateTexStorageMemFlags2DANGLE(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)1555 bool ValidateTexStorageMemFlags2DANGLE(const Context *context,
1556 angle::EntryPoint entryPoint,
1557 TextureType targetPacked,
1558 GLsizei levels,
1559 GLenum internalFormat,
1560 GLsizei width,
1561 GLsizei height,
1562 MemoryObjectID memoryPacked,
1563 GLuint64 offset,
1564 GLbitfield createFlags,
1565 GLbitfield usageFlags,
1566 const void *imageCreateInfoPNext)
1567 {
1568 if (!context->getExtensions().memoryObjectFlagsANGLE)
1569 {
1570 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1571 return false;
1572 }
1573
1574 if (!ValidateTexStorageMem2DEXT(context, entryPoint, targetPacked, levels, internalFormat,
1575 width, height, memoryPacked, offset))
1576 {
1577 return false;
1578 }
1579
1580 // |createFlags| and |usageFlags| must only have bits specified by the extension.
1581 constexpr GLbitfield kAllCreateFlags =
1582 GL_CREATE_SPARSE_BINDING_BIT_ANGLE | GL_CREATE_SPARSE_RESIDENCY_BIT_ANGLE |
1583 GL_CREATE_SPARSE_ALIASED_BIT_ANGLE | GL_CREATE_MUTABLE_FORMAT_BIT_ANGLE |
1584 GL_CREATE_CUBE_COMPATIBLE_BIT_ANGLE | GL_CREATE_ALIAS_BIT_ANGLE |
1585 GL_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_ANGLE | GL_CREATE_2D_ARRAY_COMPATIBLE_BIT_ANGLE |
1586 GL_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_ANGLE | GL_CREATE_EXTENDED_USAGE_BIT_ANGLE |
1587 GL_CREATE_PROTECTED_BIT_ANGLE | GL_CREATE_DISJOINT_BIT_ANGLE |
1588 GL_CREATE_CORNER_SAMPLED_BIT_ANGLE | GL_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_ANGLE |
1589 GL_CREATE_SUBSAMPLED_BIT_ANGLE;
1590
1591 if ((createFlags & ~kAllCreateFlags) != 0)
1592 {
1593 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidExternalCreateFlags);
1594 return false;
1595 }
1596
1597 constexpr GLbitfield kAllUsageFlags =
1598 GL_USAGE_TRANSFER_SRC_BIT_ANGLE | GL_USAGE_TRANSFER_DST_BIT_ANGLE |
1599 GL_USAGE_SAMPLED_BIT_ANGLE | GL_USAGE_STORAGE_BIT_ANGLE |
1600 GL_USAGE_COLOR_ATTACHMENT_BIT_ANGLE | GL_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT_ANGLE |
1601 GL_USAGE_TRANSIENT_ATTACHMENT_BIT_ANGLE | GL_USAGE_INPUT_ATTACHMENT_BIT_ANGLE |
1602 GL_USAGE_SHADING_RATE_IMAGE_BIT_ANGLE | GL_USAGE_FRAGMENT_DENSITY_MAP_BIT_ANGLE;
1603
1604 if ((usageFlags & ~kAllUsageFlags) != 0)
1605 {
1606 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidExternalUsageFlags);
1607 return false;
1608 }
1609
1610 return true;
1611 }
1612
ValidateTexStorageMemFlags2DMultisampleANGLE(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLboolean fixedSampleLocations,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)1613 bool ValidateTexStorageMemFlags2DMultisampleANGLE(const Context *context,
1614 angle::EntryPoint entryPoint,
1615 TextureType targetPacked,
1616 GLsizei samples,
1617 GLenum internalFormat,
1618 GLsizei width,
1619 GLsizei height,
1620 GLboolean fixedSampleLocations,
1621 MemoryObjectID memoryPacked,
1622 GLuint64 offset,
1623 GLbitfield createFlags,
1624 GLbitfield usageFlags,
1625 const void *imageCreateInfoPNext)
1626 {
1627 UNIMPLEMENTED();
1628 return false;
1629 }
1630
ValidateTexStorageMemFlags3DANGLE(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)1631 bool ValidateTexStorageMemFlags3DANGLE(const Context *context,
1632 angle::EntryPoint entryPoint,
1633 TextureType targetPacked,
1634 GLsizei levels,
1635 GLenum internalFormat,
1636 GLsizei width,
1637 GLsizei height,
1638 GLsizei depth,
1639 MemoryObjectID memoryPacked,
1640 GLuint64 offset,
1641 GLbitfield createFlags,
1642 GLbitfield usageFlags,
1643 const void *imageCreateInfoPNext)
1644 {
1645 UNIMPLEMENTED();
1646 return false;
1647 }
1648
ValidateTexStorageMemFlags3DMultisampleANGLE(const Context * context,angle::EntryPoint entryPoint,TextureType targetPacked,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLboolean fixedSampleLocations,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)1649 bool ValidateTexStorageMemFlags3DMultisampleANGLE(const Context *context,
1650 angle::EntryPoint entryPoint,
1651 TextureType targetPacked,
1652 GLsizei samples,
1653 GLenum internalFormat,
1654 GLsizei width,
1655 GLsizei height,
1656 GLsizei depth,
1657 GLboolean fixedSampleLocations,
1658 MemoryObjectID memoryPacked,
1659 GLuint64 offset,
1660 GLbitfield createFlags,
1661 GLbitfield usageFlags,
1662 const void *imageCreateInfoPNext)
1663 {
1664 UNIMPLEMENTED();
1665 return false;
1666 }
1667
1668 // GL_EXT_buffer_storage
ValidateBufferStorageEXT(const Context * context,angle::EntryPoint entryPoint,BufferBinding targetPacked,GLsizeiptr size,const void * data,GLbitfield flags)1669 bool ValidateBufferStorageEXT(const Context *context,
1670 angle::EntryPoint entryPoint,
1671 BufferBinding targetPacked,
1672 GLsizeiptr size,
1673 const void *data,
1674 GLbitfield flags)
1675 {
1676 if (!context->isValidBufferBinding(targetPacked))
1677 {
1678 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidBufferTypes);
1679 return false;
1680 }
1681
1682 if (size <= 0)
1683 {
1684 context->validationError(entryPoint, GL_INVALID_VALUE, kNonPositiveSize);
1685 return false;
1686 }
1687
1688 constexpr GLbitfield kAllUsageFlags =
1689 (GL_DYNAMIC_STORAGE_BIT_EXT | GL_MAP_READ_BIT | GL_MAP_WRITE_BIT |
1690 GL_MAP_PERSISTENT_BIT_EXT | GL_MAP_COHERENT_BIT_EXT | GL_CLIENT_STORAGE_BIT_EXT);
1691 if ((flags & ~kAllUsageFlags) != 0)
1692 {
1693 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidBufferUsageFlags);
1694 return false;
1695 }
1696
1697 if (((flags & GL_MAP_PERSISTENT_BIT_EXT) != 0) &&
1698 ((flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0))
1699 {
1700 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidBufferUsageFlags);
1701 return false;
1702 }
1703
1704 if (((flags & GL_MAP_COHERENT_BIT_EXT) != 0) && ((flags & GL_MAP_PERSISTENT_BIT_EXT) == 0))
1705 {
1706 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidBufferUsageFlags);
1707 return false;
1708 }
1709
1710 Buffer *buffer = context->getState().getTargetBuffer(targetPacked);
1711
1712 if (buffer == nullptr)
1713 {
1714 context->validationError(entryPoint, GL_INVALID_OPERATION, kBufferNotBound);
1715 return false;
1716 }
1717
1718 if (buffer->isImmutable())
1719 {
1720 context->validationError(entryPoint, GL_INVALID_OPERATION, kBufferImmutable);
1721 return false;
1722 }
1723
1724 return true;
1725 }
1726
1727 // GL_EXT_clip_control
ValidateClipControlEXT(const Context * context,angle::EntryPoint entryPoint,GLenum origin,GLenum depth)1728 bool ValidateClipControlEXT(const Context *context,
1729 angle::EntryPoint entryPoint,
1730 GLenum origin,
1731 GLenum depth)
1732 {
1733 if ((origin != GL_LOWER_LEFT_EXT) && (origin != GL_UPPER_LEFT_EXT))
1734 {
1735 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidOriginEnum);
1736 return false;
1737 }
1738
1739 if ((depth != GL_NEGATIVE_ONE_TO_ONE_EXT) && (depth != GL_ZERO_TO_ONE_EXT))
1740 {
1741 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidDepthEnum);
1742 return false;
1743 }
1744
1745 return true;
1746 }
1747
1748 // GL_EXT_external_buffer
ValidateBufferStorageExternalEXT(const Context * context,angle::EntryPoint entryPoint,BufferBinding targetPacked,GLintptr offset,GLsizeiptr size,GLeglClientBufferEXT clientBuffer,GLbitfield flags)1749 bool ValidateBufferStorageExternalEXT(const Context *context,
1750 angle::EntryPoint entryPoint,
1751 BufferBinding targetPacked,
1752 GLintptr offset,
1753 GLsizeiptr size,
1754 GLeglClientBufferEXT clientBuffer,
1755 GLbitfield flags)
1756 {
1757 if (!ValidateBufferStorageEXT(context, entryPoint, targetPacked, size, nullptr, flags))
1758 {
1759 return false;
1760 }
1761
1762 if (offset != 0)
1763 {
1764 context->validationError(entryPoint, GL_INVALID_VALUE, kExternalBufferInvalidOffset);
1765 return false;
1766 }
1767
1768 if (clientBuffer == nullptr && size > 0)
1769 {
1770 context->validationError(entryPoint, GL_INVALID_VALUE, kClientBufferInvalid);
1771 return false;
1772 }
1773
1774 return true;
1775 }
1776
ValidateNamedBufferStorageExternalEXT(const Context * context,angle::EntryPoint entryPoint,GLuint buffer,GLintptr offset,GLsizeiptr size,GLeglClientBufferEXT clientBuffer,GLbitfield flags)1777 bool ValidateNamedBufferStorageExternalEXT(const Context *context,
1778 angle::EntryPoint entryPoint,
1779 GLuint buffer,
1780 GLintptr offset,
1781 GLsizeiptr size,
1782 GLeglClientBufferEXT clientBuffer,
1783 GLbitfield flags)
1784 {
1785 UNIMPLEMENTED();
1786 return false;
1787 }
1788
1789 // GL_EXT_primitive_bounding_box
ValidatePrimitiveBoundingBoxEXT(const Context * context,angle::EntryPoint entryPoint,GLfloat minX,GLfloat minY,GLfloat minZ,GLfloat minW,GLfloat maxX,GLfloat maxY,GLfloat maxZ,GLfloat maxW)1790 bool ValidatePrimitiveBoundingBoxEXT(const Context *context,
1791 angle::EntryPoint entryPoint,
1792 GLfloat minX,
1793 GLfloat minY,
1794 GLfloat minZ,
1795 GLfloat minW,
1796 GLfloat maxX,
1797 GLfloat maxY,
1798 GLfloat maxZ,
1799 GLfloat maxW)
1800 {
1801 if (!context->getExtensions().primitiveBoundingBoxEXT)
1802 {
1803 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1804 return false;
1805 }
1806
1807 return true;
1808 }
1809
1810 // GL_OES_primitive_bounding_box
ValidatePrimitiveBoundingBoxOES(const Context * context,angle::EntryPoint entryPoint,GLfloat minX,GLfloat minY,GLfloat minZ,GLfloat minW,GLfloat maxX,GLfloat maxY,GLfloat maxZ,GLfloat maxW)1811 bool ValidatePrimitiveBoundingBoxOES(const Context *context,
1812 angle::EntryPoint entryPoint,
1813 GLfloat minX,
1814 GLfloat minY,
1815 GLfloat minZ,
1816 GLfloat minW,
1817 GLfloat maxX,
1818 GLfloat maxY,
1819 GLfloat maxZ,
1820 GLfloat maxW)
1821 {
1822 if (!context->getExtensions().primitiveBoundingBoxOES)
1823 {
1824 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1825 return false;
1826 }
1827
1828 return true;
1829 }
1830
1831 // GL_EXT_separate_shader_objects
ValidateActiveShaderProgramEXT(const Context * context,angle::EntryPoint entryPoint,ProgramPipelineID pipelinePacked,ShaderProgramID programPacked)1832 bool ValidateActiveShaderProgramEXT(const Context *context,
1833 angle::EntryPoint entryPoint,
1834 ProgramPipelineID pipelinePacked,
1835 ShaderProgramID programPacked)
1836 {
1837 if (!context->getExtensions().separateShaderObjectsEXT)
1838 {
1839 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1840 return false;
1841 }
1842
1843 return ValidateActiveShaderProgramBase(context, entryPoint, pipelinePacked, programPacked);
1844 }
1845
ValidateBindProgramPipelineEXT(const Context * context,angle::EntryPoint entryPoint,ProgramPipelineID pipelinePacked)1846 bool ValidateBindProgramPipelineEXT(const Context *context,
1847 angle::EntryPoint entryPoint,
1848 ProgramPipelineID pipelinePacked)
1849 {
1850 if (!context->getExtensions().separateShaderObjectsEXT)
1851 {
1852 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1853 return false;
1854 }
1855
1856 return ValidateBindProgramPipelineBase(context, entryPoint, pipelinePacked);
1857 }
1858
ValidateCreateShaderProgramvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderType typePacked,GLsizei count,const GLchar ** strings)1859 bool ValidateCreateShaderProgramvEXT(const Context *context,
1860 angle::EntryPoint entryPoint,
1861 ShaderType typePacked,
1862 GLsizei count,
1863 const GLchar **strings)
1864 {
1865 if (!context->getExtensions().separateShaderObjectsEXT)
1866 {
1867 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1868 return false;
1869 }
1870
1871 return ValidateCreateShaderProgramvBase(context, entryPoint, typePacked, count, strings);
1872 }
1873
ValidateDeleteProgramPipelinesEXT(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const ProgramPipelineID * pipelinesPacked)1874 bool ValidateDeleteProgramPipelinesEXT(const Context *context,
1875 angle::EntryPoint entryPoint,
1876 GLsizei n,
1877 const ProgramPipelineID *pipelinesPacked)
1878 {
1879 if (!context->getExtensions().separateShaderObjectsEXT)
1880 {
1881 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1882 return false;
1883 }
1884
1885 return ValidateDeleteProgramPipelinesBase(context, entryPoint, n, pipelinesPacked);
1886 }
1887
ValidateGenProgramPipelinesEXT(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const ProgramPipelineID * pipelinesPacked)1888 bool ValidateGenProgramPipelinesEXT(const Context *context,
1889 angle::EntryPoint entryPoint,
1890 GLsizei n,
1891 const ProgramPipelineID *pipelinesPacked)
1892 {
1893 if (!context->getExtensions().separateShaderObjectsEXT)
1894 {
1895 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1896 return false;
1897 }
1898
1899 return ValidateGenProgramPipelinesBase(context, entryPoint, n, pipelinesPacked);
1900 }
1901
ValidateGetProgramPipelineInfoLogEXT(const Context * context,angle::EntryPoint entryPoint,ProgramPipelineID pipelinePacked,GLsizei bufSize,const GLsizei * length,const GLchar * infoLog)1902 bool ValidateGetProgramPipelineInfoLogEXT(const Context *context,
1903 angle::EntryPoint entryPoint,
1904 ProgramPipelineID pipelinePacked,
1905 GLsizei bufSize,
1906 const GLsizei *length,
1907 const GLchar *infoLog)
1908 {
1909 if (!context->getExtensions().separateShaderObjectsEXT)
1910 {
1911 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1912 return false;
1913 }
1914
1915 return ValidateGetProgramPipelineInfoLogBase(context, entryPoint, pipelinePacked, bufSize,
1916 length, infoLog);
1917 }
1918
ValidateGetProgramPipelineivEXT(const Context * context,angle::EntryPoint entryPoint,ProgramPipelineID pipelinePacked,GLenum pname,const GLint * params)1919 bool ValidateGetProgramPipelineivEXT(const Context *context,
1920 angle::EntryPoint entryPoint,
1921 ProgramPipelineID pipelinePacked,
1922 GLenum pname,
1923 const GLint *params)
1924 {
1925 if (!context->getExtensions().separateShaderObjectsEXT)
1926 {
1927 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1928 return false;
1929 }
1930
1931 return ValidateGetProgramPipelineivBase(context, entryPoint, pipelinePacked, pname, params);
1932 }
1933
ValidateIsProgramPipelineEXT(const Context * context,angle::EntryPoint entryPoint,ProgramPipelineID pipelinePacked)1934 bool ValidateIsProgramPipelineEXT(const Context *context,
1935 angle::EntryPoint entryPoint,
1936 ProgramPipelineID pipelinePacked)
1937 {
1938 if (!context->getExtensions().separateShaderObjectsEXT)
1939 {
1940 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1941 return false;
1942 }
1943
1944 return ValidateIsProgramPipelineBase(context, entryPoint, pipelinePacked);
1945 }
1946
ValidateProgramParameteriEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,GLenum pname,GLint value)1947 bool ValidateProgramParameteriEXT(const Context *context,
1948 angle::EntryPoint entryPoint,
1949 ShaderProgramID programPacked,
1950 GLenum pname,
1951 GLint value)
1952 {
1953 if (!context->getExtensions().separateShaderObjectsEXT)
1954 {
1955 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1956 return false;
1957 }
1958
1959 return ValidateProgramParameteriBase(context, entryPoint, programPacked, pname, value);
1960 }
1961
ValidateProgramUniform1fEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0)1962 bool ValidateProgramUniform1fEXT(const Context *context,
1963 angle::EntryPoint entryPoint,
1964 ShaderProgramID programPacked,
1965 UniformLocation locationPacked,
1966 GLfloat v0)
1967 {
1968 if (!context->getExtensions().separateShaderObjectsEXT)
1969 {
1970 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1971 return false;
1972 }
1973
1974 return ValidateProgramUniform1fBase(context, entryPoint, programPacked, locationPacked, v0);
1975 }
1976
ValidateProgramUniform1fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)1977 bool ValidateProgramUniform1fvEXT(const Context *context,
1978 angle::EntryPoint entryPoint,
1979 ShaderProgramID programPacked,
1980 UniformLocation locationPacked,
1981 GLsizei count,
1982 const GLfloat *value)
1983 {
1984 if (!context->getExtensions().separateShaderObjectsEXT)
1985 {
1986 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
1987 return false;
1988 }
1989
1990 return ValidateProgramUniform1fvBase(context, entryPoint, programPacked, locationPacked, count,
1991 value);
1992 }
1993
ValidateProgramUniform1iEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0)1994 bool ValidateProgramUniform1iEXT(const Context *context,
1995 angle::EntryPoint entryPoint,
1996 ShaderProgramID programPacked,
1997 UniformLocation locationPacked,
1998 GLint v0)
1999 {
2000 if (!context->getExtensions().separateShaderObjectsEXT)
2001 {
2002 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2003 return false;
2004 }
2005
2006 return ValidateProgramUniform1iBase(context, entryPoint, programPacked, locationPacked, v0);
2007 }
2008
ValidateProgramUniform1ivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)2009 bool ValidateProgramUniform1ivEXT(const Context *context,
2010 angle::EntryPoint entryPoint,
2011 ShaderProgramID programPacked,
2012 UniformLocation locationPacked,
2013 GLsizei count,
2014 const GLint *value)
2015 {
2016 if (!context->getExtensions().separateShaderObjectsEXT)
2017 {
2018 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2019 return false;
2020 }
2021
2022 return ValidateProgramUniform1ivBase(context, entryPoint, programPacked, locationPacked, count,
2023 value);
2024 }
2025
ValidateProgramUniform1uiEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0)2026 bool ValidateProgramUniform1uiEXT(const Context *context,
2027 angle::EntryPoint entryPoint,
2028 ShaderProgramID programPacked,
2029 UniformLocation locationPacked,
2030 GLuint v0)
2031 {
2032 if (!context->getExtensions().separateShaderObjectsEXT)
2033 {
2034 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2035 return false;
2036 }
2037
2038 return ValidateProgramUniform1uiBase(context, entryPoint, programPacked, locationPacked, v0);
2039 }
2040
ValidateProgramUniform1uivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)2041 bool ValidateProgramUniform1uivEXT(const Context *context,
2042 angle::EntryPoint entryPoint,
2043 ShaderProgramID programPacked,
2044 UniformLocation locationPacked,
2045 GLsizei count,
2046 const GLuint *value)
2047 {
2048 if (!context->getExtensions().separateShaderObjectsEXT)
2049 {
2050 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2051 return false;
2052 }
2053
2054 return ValidateProgramUniform1uivBase(context, entryPoint, programPacked, locationPacked, count,
2055 value);
2056 }
2057
ValidateProgramUniform2fEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0,GLfloat v1)2058 bool ValidateProgramUniform2fEXT(const Context *context,
2059 angle::EntryPoint entryPoint,
2060 ShaderProgramID programPacked,
2061 UniformLocation locationPacked,
2062 GLfloat v0,
2063 GLfloat v1)
2064 {
2065 if (!context->getExtensions().separateShaderObjectsEXT)
2066 {
2067 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2068 return false;
2069 }
2070
2071 return ValidateProgramUniform2fBase(context, entryPoint, programPacked, locationPacked, v0, v1);
2072 }
2073
ValidateProgramUniform2fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)2074 bool ValidateProgramUniform2fvEXT(const Context *context,
2075 angle::EntryPoint entryPoint,
2076 ShaderProgramID programPacked,
2077 UniformLocation locationPacked,
2078 GLsizei count,
2079 const GLfloat *value)
2080 {
2081 if (!context->getExtensions().separateShaderObjectsEXT)
2082 {
2083 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2084 return false;
2085 }
2086
2087 return ValidateProgramUniform2fvBase(context, entryPoint, programPacked, locationPacked, count,
2088 value);
2089 }
2090
ValidateProgramUniform2iEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0,GLint v1)2091 bool ValidateProgramUniform2iEXT(const Context *context,
2092 angle::EntryPoint entryPoint,
2093 ShaderProgramID programPacked,
2094 UniformLocation locationPacked,
2095 GLint v0,
2096 GLint v1)
2097 {
2098 if (!context->getExtensions().separateShaderObjectsEXT)
2099 {
2100 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2101 return false;
2102 }
2103
2104 return ValidateProgramUniform2iBase(context, entryPoint, programPacked, locationPacked, v0, v1);
2105 }
2106
ValidateProgramUniform2ivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)2107 bool ValidateProgramUniform2ivEXT(const Context *context,
2108 angle::EntryPoint entryPoint,
2109 ShaderProgramID programPacked,
2110 UniformLocation locationPacked,
2111 GLsizei count,
2112 const GLint *value)
2113 {
2114 if (!context->getExtensions().separateShaderObjectsEXT)
2115 {
2116 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2117 return false;
2118 }
2119
2120 return ValidateProgramUniform2ivBase(context, entryPoint, programPacked, locationPacked, count,
2121 value);
2122 }
2123
ValidateProgramUniform2uiEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0,GLuint v1)2124 bool ValidateProgramUniform2uiEXT(const Context *context,
2125 angle::EntryPoint entryPoint,
2126 ShaderProgramID programPacked,
2127 UniformLocation locationPacked,
2128 GLuint v0,
2129 GLuint v1)
2130 {
2131 if (!context->getExtensions().separateShaderObjectsEXT)
2132 {
2133 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2134 return false;
2135 }
2136
2137 return ValidateProgramUniform2uiBase(context, entryPoint, programPacked, locationPacked, v0,
2138 v1);
2139 }
2140
ValidateProgramUniform2uivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)2141 bool ValidateProgramUniform2uivEXT(const Context *context,
2142 angle::EntryPoint entryPoint,
2143 ShaderProgramID programPacked,
2144 UniformLocation locationPacked,
2145 GLsizei count,
2146 const GLuint *value)
2147 {
2148 if (!context->getExtensions().separateShaderObjectsEXT)
2149 {
2150 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2151 return false;
2152 }
2153
2154 return ValidateProgramUniform2uivBase(context, entryPoint, programPacked, locationPacked, count,
2155 value);
2156 }
2157
ValidateProgramUniform3fEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0,GLfloat v1,GLfloat v2)2158 bool ValidateProgramUniform3fEXT(const Context *context,
2159 angle::EntryPoint entryPoint,
2160 ShaderProgramID programPacked,
2161 UniformLocation locationPacked,
2162 GLfloat v0,
2163 GLfloat v1,
2164 GLfloat v2)
2165 {
2166 if (!context->getExtensions().separateShaderObjectsEXT)
2167 {
2168 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2169 return false;
2170 }
2171
2172 return ValidateProgramUniform3fBase(context, entryPoint, programPacked, locationPacked, v0, v1,
2173 v2);
2174 }
2175
ValidateProgramUniform3fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)2176 bool ValidateProgramUniform3fvEXT(const Context *context,
2177 angle::EntryPoint entryPoint,
2178 ShaderProgramID programPacked,
2179 UniformLocation locationPacked,
2180 GLsizei count,
2181 const GLfloat *value)
2182 {
2183 if (!context->getExtensions().separateShaderObjectsEXT)
2184 {
2185 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2186 return false;
2187 }
2188
2189 return ValidateProgramUniform3fvBase(context, entryPoint, programPacked, locationPacked, count,
2190 value);
2191 }
2192
ValidateProgramUniform3iEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0,GLint v1,GLint v2)2193 bool ValidateProgramUniform3iEXT(const Context *context,
2194 angle::EntryPoint entryPoint,
2195 ShaderProgramID programPacked,
2196 UniformLocation locationPacked,
2197 GLint v0,
2198 GLint v1,
2199 GLint v2)
2200 {
2201 if (!context->getExtensions().separateShaderObjectsEXT)
2202 {
2203 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2204 return false;
2205 }
2206
2207 return ValidateProgramUniform3iBase(context, entryPoint, programPacked, locationPacked, v0, v1,
2208 v2);
2209 }
2210
ValidateProgramUniform3ivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)2211 bool ValidateProgramUniform3ivEXT(const Context *context,
2212 angle::EntryPoint entryPoint,
2213 ShaderProgramID programPacked,
2214 UniformLocation locationPacked,
2215 GLsizei count,
2216 const GLint *value)
2217 {
2218 if (!context->getExtensions().separateShaderObjectsEXT)
2219 {
2220 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2221 return false;
2222 }
2223
2224 return ValidateProgramUniform3ivBase(context, entryPoint, programPacked, locationPacked, count,
2225 value);
2226 }
2227
ValidateProgramUniform3uiEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0,GLuint v1,GLuint v2)2228 bool ValidateProgramUniform3uiEXT(const Context *context,
2229 angle::EntryPoint entryPoint,
2230 ShaderProgramID programPacked,
2231 UniformLocation locationPacked,
2232 GLuint v0,
2233 GLuint v1,
2234 GLuint v2)
2235 {
2236 if (!context->getExtensions().separateShaderObjectsEXT)
2237 {
2238 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2239 return false;
2240 }
2241
2242 return ValidateProgramUniform3uiBase(context, entryPoint, programPacked, locationPacked, v0, v1,
2243 v2);
2244 }
2245
ValidateProgramUniform3uivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)2246 bool ValidateProgramUniform3uivEXT(const Context *context,
2247 angle::EntryPoint entryPoint,
2248 ShaderProgramID programPacked,
2249 UniformLocation locationPacked,
2250 GLsizei count,
2251 const GLuint *value)
2252 {
2253 if (!context->getExtensions().separateShaderObjectsEXT)
2254 {
2255 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2256 return false;
2257 }
2258
2259 return ValidateProgramUniform3uivBase(context, entryPoint, programPacked, locationPacked, count,
2260 value);
2261 }
2262
ValidateProgramUniform4fEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0,GLfloat v1,GLfloat v2,GLfloat v3)2263 bool ValidateProgramUniform4fEXT(const Context *context,
2264 angle::EntryPoint entryPoint,
2265 ShaderProgramID programPacked,
2266 UniformLocation locationPacked,
2267 GLfloat v0,
2268 GLfloat v1,
2269 GLfloat v2,
2270 GLfloat v3)
2271 {
2272 if (!context->getExtensions().separateShaderObjectsEXT)
2273 {
2274 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2275 return false;
2276 }
2277
2278 return ValidateProgramUniform4fBase(context, entryPoint, programPacked, locationPacked, v0, v1,
2279 v2, v3);
2280 }
2281
ValidateProgramUniform4fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)2282 bool ValidateProgramUniform4fvEXT(const Context *context,
2283 angle::EntryPoint entryPoint,
2284 ShaderProgramID programPacked,
2285 UniformLocation locationPacked,
2286 GLsizei count,
2287 const GLfloat *value)
2288 {
2289 if (!context->getExtensions().separateShaderObjectsEXT)
2290 {
2291 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2292 return false;
2293 }
2294
2295 return ValidateProgramUniform4fvBase(context, entryPoint, programPacked, locationPacked, count,
2296 value);
2297 }
2298
ValidateProgramUniform4iEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0,GLint v1,GLint v2,GLint v3)2299 bool ValidateProgramUniform4iEXT(const Context *context,
2300 angle::EntryPoint entryPoint,
2301 ShaderProgramID programPacked,
2302 UniformLocation locationPacked,
2303 GLint v0,
2304 GLint v1,
2305 GLint v2,
2306 GLint v3)
2307 {
2308 if (!context->getExtensions().separateShaderObjectsEXT)
2309 {
2310 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2311 return false;
2312 }
2313
2314 return ValidateProgramUniform4iBase(context, entryPoint, programPacked, locationPacked, v0, v1,
2315 v2, v3);
2316 }
2317
ValidateProgramUniform4ivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)2318 bool ValidateProgramUniform4ivEXT(const Context *context,
2319 angle::EntryPoint entryPoint,
2320 ShaderProgramID programPacked,
2321 UniformLocation locationPacked,
2322 GLsizei count,
2323 const GLint *value)
2324 {
2325 return ValidateProgramUniform4ivBase(context, entryPoint, programPacked, locationPacked, count,
2326 value);
2327 }
2328
ValidateProgramUniform4uiEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0,GLuint v1,GLuint v2,GLuint v3)2329 bool ValidateProgramUniform4uiEXT(const Context *context,
2330 angle::EntryPoint entryPoint,
2331 ShaderProgramID programPacked,
2332 UniformLocation locationPacked,
2333 GLuint v0,
2334 GLuint v1,
2335 GLuint v2,
2336 GLuint v3)
2337 {
2338 if (!context->getExtensions().separateShaderObjectsEXT)
2339 {
2340 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2341 return false;
2342 }
2343
2344 return ValidateProgramUniform4uiBase(context, entryPoint, programPacked, locationPacked, v0, v1,
2345 v2, v3);
2346 }
2347
ValidateProgramUniform4uivEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)2348 bool ValidateProgramUniform4uivEXT(const Context *context,
2349 angle::EntryPoint entryPoint,
2350 ShaderProgramID programPacked,
2351 UniformLocation locationPacked,
2352 GLsizei count,
2353 const GLuint *value)
2354 {
2355 return ValidateProgramUniform4uivBase(context, entryPoint, programPacked, locationPacked, count,
2356 value);
2357 }
2358
ValidateProgramUniformMatrix2fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2359 bool ValidateProgramUniformMatrix2fvEXT(const Context *context,
2360 angle::EntryPoint entryPoint,
2361 ShaderProgramID programPacked,
2362 UniformLocation locationPacked,
2363 GLsizei count,
2364 GLboolean transpose,
2365 const GLfloat *value)
2366 {
2367 if (!context->getExtensions().separateShaderObjectsEXT)
2368 {
2369 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2370 return false;
2371 }
2372
2373 return ValidateProgramUniformMatrix2fvBase(context, entryPoint, programPacked, locationPacked,
2374 count, transpose, value);
2375 }
2376
ValidateProgramUniformMatrix2x3fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2377 bool ValidateProgramUniformMatrix2x3fvEXT(const Context *context,
2378 angle::EntryPoint entryPoint,
2379 ShaderProgramID programPacked,
2380 UniformLocation locationPacked,
2381 GLsizei count,
2382 GLboolean transpose,
2383 const GLfloat *value)
2384 {
2385 if (!context->getExtensions().separateShaderObjectsEXT)
2386 {
2387 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2388 return false;
2389 }
2390
2391 return ValidateProgramUniformMatrix2x3fvBase(context, entryPoint, programPacked, locationPacked,
2392 count, transpose, value);
2393 }
2394
ValidateProgramUniformMatrix2x4fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2395 bool ValidateProgramUniformMatrix2x4fvEXT(const Context *context,
2396 angle::EntryPoint entryPoint,
2397 ShaderProgramID programPacked,
2398 UniformLocation locationPacked,
2399 GLsizei count,
2400 GLboolean transpose,
2401 const GLfloat *value)
2402 {
2403 if (!context->getExtensions().separateShaderObjectsEXT)
2404 {
2405 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2406 return false;
2407 }
2408
2409 return ValidateProgramUniformMatrix2x4fvBase(context, entryPoint, programPacked, locationPacked,
2410 count, transpose, value);
2411 }
2412
ValidateProgramUniformMatrix3fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2413 bool ValidateProgramUniformMatrix3fvEXT(const Context *context,
2414 angle::EntryPoint entryPoint,
2415 ShaderProgramID programPacked,
2416 UniformLocation locationPacked,
2417 GLsizei count,
2418 GLboolean transpose,
2419 const GLfloat *value)
2420 {
2421 if (!context->getExtensions().separateShaderObjectsEXT)
2422 {
2423 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2424 return false;
2425 }
2426
2427 return ValidateProgramUniformMatrix3fvBase(context, entryPoint, programPacked, locationPacked,
2428 count, transpose, value);
2429 }
2430
ValidateProgramUniformMatrix3x2fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2431 bool ValidateProgramUniformMatrix3x2fvEXT(const Context *context,
2432 angle::EntryPoint entryPoint,
2433 ShaderProgramID programPacked,
2434 UniformLocation locationPacked,
2435 GLsizei count,
2436 GLboolean transpose,
2437 const GLfloat *value)
2438 {
2439 if (!context->getExtensions().separateShaderObjectsEXT)
2440 {
2441 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2442 return false;
2443 }
2444
2445 return ValidateProgramUniformMatrix3x2fvBase(context, entryPoint, programPacked, locationPacked,
2446 count, transpose, value);
2447 }
2448
ValidateProgramUniformMatrix3x4fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2449 bool ValidateProgramUniformMatrix3x4fvEXT(const Context *context,
2450 angle::EntryPoint entryPoint,
2451 ShaderProgramID programPacked,
2452 UniformLocation locationPacked,
2453 GLsizei count,
2454 GLboolean transpose,
2455 const GLfloat *value)
2456 {
2457 if (!context->getExtensions().separateShaderObjectsEXT)
2458 {
2459 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2460 return false;
2461 }
2462
2463 return ValidateProgramUniformMatrix3x4fvBase(context, entryPoint, programPacked, locationPacked,
2464 count, transpose, value);
2465 }
2466
ValidateProgramUniformMatrix4fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2467 bool ValidateProgramUniformMatrix4fvEXT(const Context *context,
2468 angle::EntryPoint entryPoint,
2469 ShaderProgramID programPacked,
2470 UniformLocation locationPacked,
2471 GLsizei count,
2472 GLboolean transpose,
2473 const GLfloat *value)
2474 {
2475 if (!context->getExtensions().separateShaderObjectsEXT)
2476 {
2477 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2478 return false;
2479 }
2480
2481 return ValidateProgramUniformMatrix4fvBase(context, entryPoint, programPacked, locationPacked,
2482 count, transpose, value);
2483 }
2484
ValidateProgramUniformMatrix4x2fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2485 bool ValidateProgramUniformMatrix4x2fvEXT(const Context *context,
2486 angle::EntryPoint entryPoint,
2487 ShaderProgramID programPacked,
2488 UniformLocation locationPacked,
2489 GLsizei count,
2490 GLboolean transpose,
2491 const GLfloat *value)
2492 {
2493 if (!context->getExtensions().separateShaderObjectsEXT)
2494 {
2495 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2496 return false;
2497 }
2498
2499 return ValidateProgramUniformMatrix4x2fvBase(context, entryPoint, programPacked, locationPacked,
2500 count, transpose, value);
2501 }
2502
ValidateProgramUniformMatrix4x3fvEXT(const Context * context,angle::EntryPoint entryPoint,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2503 bool ValidateProgramUniformMatrix4x3fvEXT(const Context *context,
2504 angle::EntryPoint entryPoint,
2505 ShaderProgramID programPacked,
2506 UniformLocation locationPacked,
2507 GLsizei count,
2508 GLboolean transpose,
2509 const GLfloat *value)
2510 {
2511 if (!context->getExtensions().separateShaderObjectsEXT)
2512 {
2513 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2514 return false;
2515 }
2516
2517 return ValidateProgramUniformMatrix4x3fvBase(context, entryPoint, programPacked, locationPacked,
2518 count, transpose, value);
2519 }
2520
ValidateUseProgramStagesEXT(const Context * context,angle::EntryPoint entryPoint,ProgramPipelineID pipelinePacked,GLbitfield stages,ShaderProgramID programPacked)2521 bool ValidateUseProgramStagesEXT(const Context *context,
2522 angle::EntryPoint entryPoint,
2523 ProgramPipelineID pipelinePacked,
2524 GLbitfield stages,
2525 ShaderProgramID programPacked)
2526 {
2527 if (!context->getExtensions().separateShaderObjectsEXT)
2528 {
2529 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2530 return false;
2531 }
2532
2533 return ValidateUseProgramStagesBase(context, entryPoint, pipelinePacked, stages, programPacked);
2534 }
2535
ValidateValidateProgramPipelineEXT(const Context * context,angle::EntryPoint entryPoint,ProgramPipelineID pipelinePacked)2536 bool ValidateValidateProgramPipelineEXT(const Context *context,
2537 angle::EntryPoint entryPoint,
2538 ProgramPipelineID pipelinePacked)
2539 {
2540 if (!context->getExtensions().separateShaderObjectsEXT)
2541 {
2542 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2543 return false;
2544 }
2545
2546 return ValidateValidateProgramPipelineBase(context, entryPoint, pipelinePacked);
2547 }
2548
2549 // GL_EXT_debug_label
ValidateGetObjectLabelEXT(const Context * context,angle::EntryPoint entryPoint,GLenum type,GLuint object,GLsizei bufSize,const GLsizei * length,const GLchar * label)2550 bool ValidateGetObjectLabelEXT(const Context *context,
2551 angle::EntryPoint entryPoint,
2552 GLenum type,
2553 GLuint object,
2554 GLsizei bufSize,
2555 const GLsizei *length,
2556 const GLchar *label)
2557 {
2558 if (!context->getExtensions().debugLabelEXT)
2559 {
2560 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2561 return false;
2562 }
2563
2564 if (bufSize < 0)
2565 {
2566 context->validationError(entryPoint, GL_INVALID_VALUE, kNegativeBufferSize);
2567 return false;
2568 }
2569
2570 return ValidateObjectIdentifierAndName(context, entryPoint, type, object);
2571 }
2572
ValidateLabelObjectEXT(const Context * context,angle::EntryPoint entryPoint,GLenum type,GLuint object,GLsizei length,const GLchar * label)2573 bool ValidateLabelObjectEXT(const Context *context,
2574 angle::EntryPoint entryPoint,
2575 GLenum type,
2576 GLuint object,
2577 GLsizei length,
2578 const GLchar *label)
2579 {
2580 if (!context->getExtensions().debugLabelEXT)
2581 {
2582 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2583 return false;
2584 }
2585
2586 if (length < 0)
2587 {
2588 context->validationError(entryPoint, GL_INVALID_VALUE, kNegativeLength);
2589 return false;
2590 }
2591
2592 return ValidateObjectIdentifierAndName(context, entryPoint, type, object);
2593 }
2594
ValidateEGLImageTargetTextureStorageEXT(const Context * context,angle::EntryPoint entryPoint,GLuint texture,GLeglImageOES image,const GLint * attrib_list)2595 bool ValidateEGLImageTargetTextureStorageEXT(const Context *context,
2596 angle::EntryPoint entryPoint,
2597 GLuint texture,
2598 GLeglImageOES image,
2599 const GLint *attrib_list)
2600 {
2601 UNREACHABLE();
2602 return false;
2603 }
2604
ValidateEGLImageTargetTexStorageEXT(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLeglImageOES image,const GLint * attrib_list)2605 bool ValidateEGLImageTargetTexStorageEXT(const Context *context,
2606 angle::EntryPoint entryPoint,
2607 GLenum target,
2608 GLeglImageOES image,
2609 const GLint *attrib_list)
2610 {
2611 if (!context->getExtensions().EGLImageStorageEXT)
2612 {
2613 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2614 return false;
2615 }
2616
2617 gl::TextureType targetType = FromGLenum<TextureType>(target);
2618 switch (targetType)
2619 {
2620 case TextureType::External:
2621 if (!context->getExtensions().EGLImageExternalOES)
2622 {
2623 context->validationError(entryPoint, GL_INVALID_ENUM, kEnumNotSupported);
2624 }
2625 break;
2626 case TextureType::CubeMapArray:
2627 if (!context->getExtensions().textureCubeMapArrayAny())
2628 {
2629 context->validationError(entryPoint, GL_INVALID_ENUM, kEnumNotSupported);
2630 }
2631 break;
2632 case TextureType::_2D:
2633 case TextureType::_2DArray:
2634 case TextureType::_3D:
2635 case TextureType::CubeMap:
2636 break;
2637 default:
2638 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidTextureTarget);
2639 return false;
2640 }
2641
2642 // Validate egl source image is valid
2643 egl::Image *imageObject = static_cast<egl::Image *>(image);
2644 if (!ValidateEGLImageObject(context, entryPoint, targetType, image))
2645 {
2646 return false;
2647 }
2648
2649 // attrib list validation
2650 if (attrib_list != nullptr && attrib_list[0] != GL_NONE)
2651 {
2652 context->validationError(entryPoint, GL_INVALID_VALUE, kAttributeListNotNull);
2653 return false;
2654 }
2655
2656 GLsizei levelCount = imageObject->getLevelCount();
2657 Extents size = imageObject->getExtents();
2658 GLsizei width = static_cast<GLsizei>(size.width);
2659 GLsizei height = static_cast<GLsizei>(size.height);
2660 GLsizei depth = static_cast<GLsizei>(size.depth);
2661 GLenum internalformat = imageObject->getFormat().info->sizedInternalFormat;
2662
2663 if (width < 1 || height < 1 || depth < 1 || levelCount < 1)
2664 {
2665 context->validationError(entryPoint, GL_INVALID_VALUE, kTextureSizeTooSmall);
2666 return false;
2667 }
2668
2669 if (!ValidateES3TexStorageParametersLevel(context, entryPoint, targetType, levelCount, width,
2670 height, depth))
2671 {
2672 // Error already generated.
2673 return false;
2674 }
2675
2676 if (targetType == TextureType::External)
2677 {
2678 const Caps &caps = context->getCaps();
2679 if (width > caps.max2DTextureSize || height > caps.max2DTextureSize)
2680 {
2681 context->validationError(entryPoint, GL_INVALID_VALUE, kResourceMaxTextureSize);
2682 return false;
2683 }
2684 }
2685 else if (!ValidateES3TexStorageParametersExtent(context, entryPoint, targetType, levelCount,
2686 width, height, depth))
2687 {
2688 // Error already generated.
2689 return false;
2690 }
2691
2692 if (!ValidateES3TexStorageParametersTexObject(context, entryPoint, targetType))
2693 {
2694 // Error already generated.
2695 return false;
2696 }
2697
2698 if (!ValidateES3TexStorageParametersFormat(context, entryPoint, targetType, levelCount,
2699 internalformat, width, height, depth))
2700 {
2701 // Error already generated.
2702 return false;
2703 }
2704
2705 return true;
2706 }
2707
ValidateAcquireTexturesANGLE(const Context * context,angle::EntryPoint entryPoint,GLuint numTextures,const TextureID * textures,const GLenum * layouts)2708 bool ValidateAcquireTexturesANGLE(const Context *context,
2709 angle::EntryPoint entryPoint,
2710 GLuint numTextures,
2711 const TextureID *textures,
2712 const GLenum *layouts)
2713 {
2714 if (!context->getExtensions().vulkanImageANGLE)
2715 {
2716 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2717 return false;
2718 }
2719
2720 for (GLuint i = 0; i < numTextures; ++i)
2721 {
2722 if (!context->getTexture(textures[i]))
2723 {
2724 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidTextureName);
2725 return false;
2726 }
2727 if (!IsValidImageLayout(FromGLenum<ImageLayout>(layouts[i])))
2728 {
2729 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidImageLayout);
2730 return false;
2731 }
2732 }
2733
2734 return true;
2735 }
2736
ValidateReleaseTexturesANGLE(const Context * context,angle::EntryPoint entryPoint,GLuint numTextures,const TextureID * textures,const GLenum * layouts)2737 bool ValidateReleaseTexturesANGLE(const Context *context,
2738 angle::EntryPoint entryPoint,
2739 GLuint numTextures,
2740 const TextureID *textures,
2741 const GLenum *layouts)
2742 {
2743 if (!context->getExtensions().vulkanImageANGLE)
2744 {
2745 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2746 return false;
2747 }
2748 for (GLuint i = 0; i < numTextures; ++i)
2749 {
2750 if (!context->getTexture(textures[i]))
2751 {
2752 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidTextureName);
2753 return false;
2754 }
2755 }
2756
2757 return true;
2758 }
2759
ValidateFramebufferParameteriMESA(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum pname,GLint param)2760 bool ValidateFramebufferParameteriMESA(const Context *context,
2761 angle::EntryPoint entryPoint,
2762 GLenum target,
2763 GLenum pname,
2764 GLint param)
2765 {
2766 if (pname != GL_FRAMEBUFFER_FLIP_Y_MESA)
2767 {
2768 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
2769 return false;
2770 }
2771 return ValidateFramebufferParameteriBase(context, entryPoint, target, pname, param);
2772 }
2773
ValidateGetFramebufferParameterivMESA(const Context * context,angle::EntryPoint entryPoint,GLenum target,GLenum pname,const GLint * params)2774 bool ValidateGetFramebufferParameterivMESA(const Context *context,
2775 angle::EntryPoint entryPoint,
2776 GLenum target,
2777 GLenum pname,
2778 const GLint *params)
2779 {
2780 if (pname != GL_FRAMEBUFFER_FLIP_Y_MESA)
2781 {
2782 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
2783 return false;
2784 }
2785 return ValidateGetFramebufferParameterivBase(context, entryPoint, target, pname, params);
2786 }
2787
2788 // GL_AMD_performance_monitor
ValidateBeginPerfMonitorAMD(const Context * context,angle::EntryPoint entryPoint,GLuint monitor)2789 bool ValidateBeginPerfMonitorAMD(const Context *context,
2790 angle::EntryPoint entryPoint,
2791 GLuint monitor)
2792 {
2793 if (!context->getExtensions().performanceMonitorAMD)
2794 {
2795 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2796 return false;
2797 }
2798
2799 UNIMPLEMENTED();
2800 return false;
2801 }
2802
ValidateDeletePerfMonitorsAMD(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const GLuint * monitors)2803 bool ValidateDeletePerfMonitorsAMD(const Context *context,
2804 angle::EntryPoint entryPoint,
2805 GLsizei n,
2806 const GLuint *monitors)
2807 {
2808 if (!context->getExtensions().performanceMonitorAMD)
2809 {
2810 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2811 return false;
2812 }
2813
2814 UNIMPLEMENTED();
2815 return false;
2816 }
2817
ValidateEndPerfMonitorAMD(const Context * context,angle::EntryPoint entryPoint,GLuint monitor)2818 bool ValidateEndPerfMonitorAMD(const Context *context, angle::EntryPoint entryPoint, GLuint monitor)
2819 {
2820 if (!context->getExtensions().performanceMonitorAMD)
2821 {
2822 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2823 return false;
2824 }
2825
2826 UNIMPLEMENTED();
2827 return false;
2828 }
2829
ValidateGenPerfMonitorsAMD(const Context * context,angle::EntryPoint entryPoint,GLsizei n,const GLuint * monitors)2830 bool ValidateGenPerfMonitorsAMD(const Context *context,
2831 angle::EntryPoint entryPoint,
2832 GLsizei n,
2833 const GLuint *monitors)
2834 {
2835 if (!context->getExtensions().performanceMonitorAMD)
2836 {
2837 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2838 return false;
2839 }
2840
2841 UNIMPLEMENTED();
2842 return false;
2843 }
2844
ValidateGetPerfMonitorCounterDataAMD(const Context * context,angle::EntryPoint entryPoint,GLuint monitor,GLenum pname,GLsizei dataSize,const GLuint * data,const GLint * bytesWritten)2845 bool ValidateGetPerfMonitorCounterDataAMD(const Context *context,
2846 angle::EntryPoint entryPoint,
2847 GLuint monitor,
2848 GLenum pname,
2849 GLsizei dataSize,
2850 const GLuint *data,
2851 const GLint *bytesWritten)
2852 {
2853 if (!context->getExtensions().performanceMonitorAMD)
2854 {
2855 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2856 return false;
2857 }
2858
2859 if (monitor != 0)
2860 {
2861 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPerfMonitor);
2862 return false;
2863 }
2864
2865 switch (pname)
2866 {
2867 case GL_PERFMON_RESULT_AVAILABLE_AMD:
2868 case GL_PERFMON_RESULT_SIZE_AMD:
2869 case GL_PERFMON_RESULT_AMD:
2870 break;
2871
2872 default:
2873 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
2874 return false;
2875 }
2876
2877 return true;
2878 }
2879
ValidateGetPerfMonitorCounterInfoAMD(const Context * context,angle::EntryPoint entryPoint,GLuint group,GLuint counter,GLenum pname,const void * data)2880 bool ValidateGetPerfMonitorCounterInfoAMD(const Context *context,
2881 angle::EntryPoint entryPoint,
2882 GLuint group,
2883 GLuint counter,
2884 GLenum pname,
2885 const void *data)
2886 {
2887 if (!context->getExtensions().performanceMonitorAMD)
2888 {
2889 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2890 return false;
2891 }
2892
2893 const angle::PerfMonitorCounterGroups &groups = context->getPerfMonitorCounterGroups();
2894
2895 if (group >= groups.size())
2896 {
2897 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPerfMonitorGroup);
2898 return false;
2899 }
2900
2901 if (counter >= groups[group].counters.size())
2902 {
2903 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPerfMonitorCounter);
2904 return false;
2905 }
2906
2907 switch (pname)
2908 {
2909 case GL_COUNTER_TYPE_AMD:
2910 case GL_COUNTER_RANGE_AMD:
2911 break;
2912
2913 default:
2914 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPname);
2915 return false;
2916 }
2917
2918 return true;
2919 }
2920
ValidateGetPerfMonitorCounterStringAMD(const Context * context,angle::EntryPoint entryPoint,GLuint group,GLuint counter,GLsizei bufSize,const GLsizei * length,const GLchar * counterString)2921 bool ValidateGetPerfMonitorCounterStringAMD(const Context *context,
2922 angle::EntryPoint entryPoint,
2923 GLuint group,
2924 GLuint counter,
2925 GLsizei bufSize,
2926 const GLsizei *length,
2927 const GLchar *counterString)
2928 {
2929 if (!context->getExtensions().performanceMonitorAMD)
2930 {
2931 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2932 return false;
2933 }
2934
2935 const angle::PerfMonitorCounterGroups &groups = context->getPerfMonitorCounterGroups();
2936
2937 if (group >= groups.size())
2938 {
2939 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPerfMonitorGroup);
2940 return false;
2941 }
2942
2943 if (counter >= groups[group].counters.size())
2944 {
2945 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPerfMonitorCounter);
2946 return false;
2947 }
2948
2949 return true;
2950 }
2951
ValidateGetPerfMonitorCountersAMD(const Context * context,angle::EntryPoint entryPoint,GLuint group,const GLint * numCounters,const GLint * maxActiveCounters,GLsizei counterSize,const GLuint * counters)2952 bool ValidateGetPerfMonitorCountersAMD(const Context *context,
2953 angle::EntryPoint entryPoint,
2954 GLuint group,
2955 const GLint *numCounters,
2956 const GLint *maxActiveCounters,
2957 GLsizei counterSize,
2958 const GLuint *counters)
2959 {
2960 if (!context->getExtensions().performanceMonitorAMD)
2961 {
2962 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2963 return false;
2964 }
2965
2966 const angle::PerfMonitorCounterGroups &groups = context->getPerfMonitorCounterGroups();
2967
2968 if (group >= groups.size())
2969 {
2970 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPerfMonitorGroup);
2971 return false;
2972 }
2973
2974 return true;
2975 }
2976
ValidateGetPerfMonitorGroupStringAMD(const Context * context,angle::EntryPoint entryPoint,GLuint group,GLsizei bufSize,const GLsizei * length,const GLchar * groupString)2977 bool ValidateGetPerfMonitorGroupStringAMD(const Context *context,
2978 angle::EntryPoint entryPoint,
2979 GLuint group,
2980 GLsizei bufSize,
2981 const GLsizei *length,
2982 const GLchar *groupString)
2983 {
2984 if (!context->getExtensions().performanceMonitorAMD)
2985 {
2986 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
2987 return false;
2988 }
2989
2990 const angle::PerfMonitorCounterGroups &groups = context->getPerfMonitorCounterGroups();
2991
2992 if (group >= groups.size())
2993 {
2994 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPerfMonitorGroup);
2995 return false;
2996 }
2997
2998 return true;
2999 }
3000
ValidateGetPerfMonitorGroupsAMD(const Context * context,angle::EntryPoint entryPoint,const GLint * numGroups,GLsizei groupsSize,const GLuint * groups)3001 bool ValidateGetPerfMonitorGroupsAMD(const Context *context,
3002 angle::EntryPoint entryPoint,
3003 const GLint *numGroups,
3004 GLsizei groupsSize,
3005 const GLuint *groups)
3006 {
3007 if (!context->getExtensions().performanceMonitorAMD)
3008 {
3009 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
3010 return false;
3011 }
3012
3013 return true;
3014 }
3015
ValidateSelectPerfMonitorCountersAMD(const Context * context,angle::EntryPoint entryPoint,GLuint monitor,GLboolean enable,GLuint group,GLint numCounters,const GLuint * counterList)3016 bool ValidateSelectPerfMonitorCountersAMD(const Context *context,
3017 angle::EntryPoint entryPoint,
3018 GLuint monitor,
3019 GLboolean enable,
3020 GLuint group,
3021 GLint numCounters,
3022 const GLuint *counterList)
3023 {
3024 if (!context->getExtensions().performanceMonitorAMD)
3025 {
3026 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
3027 return false;
3028 }
3029
3030 UNIMPLEMENTED();
3031 return false;
3032 }
3033 } // namespace gl
3034