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,ObjectT * obj,GLenum format,GLenum type)26 bool ValidateGetImageFormatAndType(const Context *context, ObjectT *obj, GLenum format, GLenum type)
27 {
28     GLenum implFormat = obj->getImplementationColorReadFormat(context);
29     if (!ValidES3Format(format) && (format != implFormat || format == GL_NONE))
30     {
31         context->validationError(GL_INVALID_ENUM, kInvalidFormat);
32         return false;
33     }
34 
35     GLenum implType = obj->getImplementationColorReadType(context);
36     if (!ValidES3Type(type) && (type != implType || type == GL_NONE))
37     {
38         context->validationError(GL_INVALID_ENUM, kInvalidType);
39         return false;
40     }
41 
42     // Format/type combinations are not yet validated.
43 
44     return true;
45 }
46 
IsValidImageLayout(ImageLayout layout)47 bool IsValidImageLayout(ImageLayout layout)
48 {
49     switch (layout)
50     {
51         case ImageLayout::Undefined:
52         case ImageLayout::General:
53         case ImageLayout::ColorAttachment:
54         case ImageLayout::DepthStencilAttachment:
55         case ImageLayout::DepthStencilReadOnlyAttachment:
56         case ImageLayout::ShaderReadOnly:
57         case ImageLayout::TransferSrc:
58         case ImageLayout::TransferDst:
59         case ImageLayout::DepthReadOnlyStencilAttachment:
60         case ImageLayout::DepthAttachmentStencilReadOnly:
61             return true;
62 
63         default:
64             return false;
65     }
66 }
67 
IsValidMemoryObjectParamater(const Context * context,GLenum pname)68 bool IsValidMemoryObjectParamater(const Context *context, GLenum pname)
69 {
70     switch (pname)
71     {
72         case GL_DEDICATED_MEMORY_OBJECT_EXT:
73             return true;
74 
75         default:
76             return false;
77     }
78 }
79 
ValidateObjectIdentifierAndName(const Context * context,GLenum identifier,GLuint name)80 bool ValidateObjectIdentifierAndName(const Context *context, GLenum identifier, GLuint name)
81 {
82     bool isGLES11 = context->getClientVersion() == Version(1, 1);
83     bool isGLES3  = context->getClientMajorVersion() >= 3;
84     bool isGLES31 = context->getClientVersion() >= Version(3, 1);
85     switch (identifier)
86     {
87         case GL_BUFFER_OBJECT_EXT:
88             if (context->getBuffer({name}) == nullptr)
89             {
90                 context->validationError(GL_INVALID_OPERATION, kInvalidBufferName);
91                 return false;
92             }
93             return true;
94 
95         case GL_SHADER_OBJECT_EXT:
96             if (isGLES11)
97             {
98                 context->validationError(GL_INVALID_ENUM, kInvalidType);
99                 return false;
100             }
101             if (context->getShader({name}) == nullptr)
102             {
103                 context->validationError(GL_INVALID_OPERATION, kInvalidShaderName);
104                 return false;
105             }
106             return true;
107 
108         case GL_PROGRAM_OBJECT_EXT:
109             if (isGLES11)
110             {
111                 context->validationError(GL_INVALID_ENUM, kInvalidType);
112                 return false;
113             }
114             if (context->getProgramNoResolveLink({name}) == nullptr)
115             {
116                 context->validationError(GL_INVALID_OPERATION, kInvalidProgramName);
117                 return false;
118             }
119             return true;
120 
121         case GL_VERTEX_ARRAY_OBJECT_EXT:
122             if (!isGLES3 && !context->getExtensions().vertexArrayObjectOES)
123             {
124                 context->validationError(GL_INVALID_ENUM, kInvalidType);
125                 return false;
126             }
127             if (context->getVertexArray({name}) == nullptr)
128             {
129                 context->validationError(GL_INVALID_OPERATION, kInvalidVertexArrayName);
130                 return false;
131             }
132             return true;
133 
134         case GL_QUERY_OBJECT_EXT:
135             if (!isGLES3 && !context->getExtensions().occlusionQueryBoolean)
136             {
137                 context->validationError(GL_INVALID_ENUM, kInvalidType);
138                 return false;
139             }
140             if (context->getQuery({name}) == nullptr)
141             {
142                 context->validationError(GL_INVALID_OPERATION, kInvalidQueryName);
143                 return false;
144             }
145             return true;
146 
147         case GL_TRANSFORM_FEEDBACK:
148             if (!isGLES3)
149             {
150                 context->validationError(GL_INVALID_ENUM, kInvalidType);
151                 return false;
152             }
153             if (context->getTransformFeedback({name}) == nullptr)
154             {
155                 context->validationError(GL_INVALID_OPERATION, kInvalidTransformFeedbackName);
156                 return false;
157             }
158             return true;
159 
160         case GL_SAMPLER:
161             if (!isGLES3)
162             {
163                 context->validationError(GL_INVALID_ENUM, kInvalidType);
164                 return false;
165             }
166             if (context->getSampler({name}) == nullptr)
167             {
168                 context->validationError(GL_INVALID_OPERATION, kInvalidSamplerName);
169                 return false;
170             }
171             return true;
172 
173         case GL_TEXTURE:
174             if (context->getTexture({name}) == nullptr)
175             {
176                 context->validationError(GL_INVALID_OPERATION, kInvalidTextureName);
177                 return false;
178             }
179             return true;
180 
181         case GL_RENDERBUFFER:
182             if (!context->isRenderbuffer({name}))
183             {
184                 context->validationError(GL_INVALID_OPERATION, kInvalidRenderbufferName);
185                 return false;
186             }
187             return true;
188 
189         case GL_FRAMEBUFFER:
190             if (context->getFramebuffer({name}) == nullptr)
191             {
192                 context->validationError(GL_INVALID_OPERATION, kInvalidFramebufferName);
193                 return false;
194             }
195             return true;
196 
197         case GL_PROGRAM_PIPELINE_OBJECT_EXT:
198             if (!isGLES31 && !context->getExtensions().separateShaderObjects)
199             {
200                 context->validationError(GL_INVALID_ENUM, kInvalidType);
201                 return false;
202             }
203             if (context->getProgramPipeline({name}) == nullptr)
204             {
205                 context->validationError(GL_INVALID_OPERATION, kInvalidProgramPipelineName);
206                 return false;
207             }
208             return true;
209 
210         default:
211             context->validationError(GL_INVALID_ENUM, kInvalidIndentifier);
212             return false;
213     }
214 }
215 }  // namespace
216 
ValidateGetTexImageANGLE(const Context * context,TextureTarget target,GLint level,GLenum format,GLenum type,const void * pixels)217 bool ValidateGetTexImageANGLE(const Context *context,
218                               TextureTarget target,
219                               GLint level,
220                               GLenum format,
221                               GLenum type,
222                               const void *pixels)
223 {
224     if (!context->getExtensions().getImageANGLE)
225     {
226         context->validationError(GL_INVALID_OPERATION, kGetImageExtensionNotEnabled);
227         return false;
228     }
229 
230     if (!ValidTexture2DDestinationTarget(context, target) &&
231         !ValidTexture3DDestinationTarget(context, target))
232     {
233         context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
234         return false;
235     }
236 
237     if (level < 0)
238     {
239         context->validationError(GL_INVALID_VALUE, kNegativeLevel);
240         return false;
241     }
242 
243     TextureType textureType = TextureTargetToType(target);
244     if (!ValidMipLevel(context, textureType, level))
245     {
246         context->validationError(GL_INVALID_VALUE, kInvalidMipLevel);
247         return false;
248     }
249 
250     Texture *texture = context->getTextureByTarget(target);
251 
252     if (!ValidateGetImageFormatAndType(context, texture, format, type))
253     {
254         return false;
255     }
256 
257     GLsizei width  = static_cast<GLsizei>(texture->getWidth(target, level));
258     GLsizei height = static_cast<GLsizei>(texture->getHeight(target, level));
259     if (!ValidatePixelPack(context, format, type, 0, 0, width, height, -1, nullptr, pixels))
260     {
261         return false;
262     }
263 
264     return true;
265 }
266 
ValidateGetRenderbufferImageANGLE(const Context * context,GLenum target,GLenum format,GLenum type,const void * pixels)267 bool ValidateGetRenderbufferImageANGLE(const Context *context,
268                                        GLenum target,
269                                        GLenum format,
270                                        GLenum type,
271                                        const void *pixels)
272 {
273     if (!context->getExtensions().getImageANGLE)
274     {
275         context->validationError(GL_INVALID_OPERATION, kGetImageExtensionNotEnabled);
276         return false;
277     }
278 
279     if (target != GL_RENDERBUFFER)
280     {
281         context->validationError(GL_INVALID_ENUM, kInvalidRenderbufferTarget);
282         return false;
283     }
284 
285     Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
286 
287     if (!ValidateGetImageFormatAndType(context, renderbuffer, format, type))
288     {
289         return false;
290     }
291 
292     GLsizei width  = renderbuffer->getWidth();
293     GLsizei height = renderbuffer->getHeight();
294     if (!ValidatePixelPack(context, format, type, 0, 0, width, height, -1, nullptr, pixels))
295     {
296         return false;
297     }
298 
299     return true;
300 }
301 
ValidateDrawElementsBaseVertexEXT(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)302 bool ValidateDrawElementsBaseVertexEXT(const Context *context,
303                                        PrimitiveMode mode,
304                                        GLsizei count,
305                                        DrawElementsType type,
306                                        const void *indices,
307                                        GLint basevertex)
308 {
309     if (!context->getExtensions().drawElementsBaseVertexAny())
310     {
311         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
312         return false;
313     }
314 
315     return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
316 }
317 
ValidateDrawElementsInstancedBaseVertexEXT(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instancecount,GLint basevertex)318 bool ValidateDrawElementsInstancedBaseVertexEXT(const Context *context,
319                                                 PrimitiveMode mode,
320                                                 GLsizei count,
321                                                 DrawElementsType type,
322                                                 const void *indices,
323                                                 GLsizei instancecount,
324                                                 GLint basevertex)
325 {
326     if (!context->getExtensions().drawElementsBaseVertexAny())
327     {
328         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
329         return false;
330     }
331 
332     return ValidateDrawElementsInstancedBase(context, mode, count, type, indices, instancecount);
333 }
334 
ValidateDrawRangeElementsBaseVertexEXT(const Context * context,PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)335 bool ValidateDrawRangeElementsBaseVertexEXT(const Context *context,
336                                             PrimitiveMode mode,
337                                             GLuint start,
338                                             GLuint end,
339                                             GLsizei count,
340                                             DrawElementsType type,
341                                             const void *indices,
342                                             GLint basevertex)
343 {
344     if (!context->getExtensions().drawElementsBaseVertexAny())
345     {
346         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
347         return false;
348     }
349 
350     if (end < start)
351     {
352         context->validationError(GL_INVALID_VALUE, kInvalidElementRange);
353         return false;
354     }
355 
356     if (!ValidateDrawElementsCommon(context, mode, count, type, indices, 0))
357     {
358         return false;
359     }
360 
361     // Skip range checks for no-op calls.
362     if (count <= 0)
363     {
364         return true;
365     }
366 
367     // Note that resolving the index range is a bit slow. We should probably optimize this.
368     IndexRange indexRange;
369     ANGLE_VALIDATION_TRY(context->getState().getVertexArray()->getIndexRange(context, type, count,
370                                                                              indices, &indexRange));
371 
372     if (indexRange.end > end || indexRange.start < start)
373     {
374         // GL spec says that behavior in this case is undefined - generating an error is fine.
375         context->validationError(GL_INVALID_OPERATION, kExceedsElementRange);
376         return false;
377     }
378     return true;
379 }
380 
ValidateMultiDrawElementsBaseVertexEXT(const Context * context,PrimitiveMode mode,const GLsizei * count,DrawElementsType type,const void * const * indices,GLsizei drawcount,const GLint * basevertex)381 bool ValidateMultiDrawElementsBaseVertexEXT(const Context *context,
382                                             PrimitiveMode mode,
383                                             const GLsizei *count,
384                                             DrawElementsType type,
385                                             const void *const *indices,
386                                             GLsizei drawcount,
387                                             const GLint *basevertex)
388 {
389     return true;
390 }
391 
ValidateDrawElementsBaseVertexOES(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)392 bool ValidateDrawElementsBaseVertexOES(const Context *context,
393                                        PrimitiveMode mode,
394                                        GLsizei count,
395                                        DrawElementsType type,
396                                        const void *indices,
397                                        GLint basevertex)
398 {
399     if (!context->getExtensions().drawElementsBaseVertexAny())
400     {
401         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
402         return false;
403     }
404 
405     return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
406 }
407 
ValidateDrawElementsInstancedBaseVertexOES(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instancecount,GLint basevertex)408 bool ValidateDrawElementsInstancedBaseVertexOES(const Context *context,
409                                                 PrimitiveMode mode,
410                                                 GLsizei count,
411                                                 DrawElementsType type,
412                                                 const void *indices,
413                                                 GLsizei instancecount,
414                                                 GLint basevertex)
415 {
416     if (!context->getExtensions().drawElementsBaseVertexAny())
417     {
418         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
419         return false;
420     }
421 
422     return ValidateDrawElementsInstancedBase(context, mode, count, type, indices, instancecount);
423 }
424 
ValidateDrawRangeElementsBaseVertexOES(const Context * context,PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)425 bool ValidateDrawRangeElementsBaseVertexOES(const Context *context,
426                                             PrimitiveMode mode,
427                                             GLuint start,
428                                             GLuint end,
429                                             GLsizei count,
430                                             DrawElementsType type,
431                                             const void *indices,
432                                             GLint basevertex)
433 {
434     if (!context->getExtensions().drawElementsBaseVertexAny())
435     {
436         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
437         return false;
438     }
439 
440     if (end < start)
441     {
442         context->validationError(GL_INVALID_VALUE, kInvalidElementRange);
443         return false;
444     }
445 
446     if (!ValidateDrawElementsCommon(context, mode, count, type, indices, 0))
447     {
448         return false;
449     }
450 
451     // Skip range checks for no-op calls.
452     if (count <= 0)
453     {
454         return true;
455     }
456 
457     // Note that resolving the index range is a bit slow. We should probably optimize this.
458     IndexRange indexRange;
459     ANGLE_VALIDATION_TRY(context->getState().getVertexArray()->getIndexRange(context, type, count,
460                                                                              indices, &indexRange));
461 
462     if (indexRange.end > end || indexRange.start < start)
463     {
464         // GL spec says that behavior in this case is undefined - generating an error is fine.
465         context->validationError(GL_INVALID_OPERATION, kExceedsElementRange);
466         return false;
467     }
468     return true;
469 }
470 
471 // GL_KHR_blend_equation_advanced
ValidateBlendBarrierKHR(const Context * context)472 bool ValidateBlendBarrierKHR(const Context *context)
473 {
474     context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
475     return false;
476 }
477 
ValidateBlendEquationSeparateiEXT(const Context * context,GLuint buf,GLenum modeRGB,GLenum modeAlpha)478 bool ValidateBlendEquationSeparateiEXT(const Context *context,
479                                        GLuint buf,
480                                        GLenum modeRGB,
481                                        GLenum modeAlpha)
482 {
483     if (!context->getExtensions().drawBuffersIndexedEXT)
484     {
485         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
486         return false;
487     }
488 
489     return ValidateBlendEquationSeparatei(context, buf, modeRGB, modeAlpha);
490 }
491 
ValidateBlendEquationiEXT(const Context * context,GLuint buf,GLenum mode)492 bool ValidateBlendEquationiEXT(const Context *context, GLuint buf, GLenum mode)
493 {
494     if (!context->getExtensions().drawBuffersIndexedEXT)
495     {
496         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
497         return false;
498     }
499 
500     return ValidateBlendEquationi(context, buf, mode);
501 }
502 
ValidateBlendFuncSeparateiEXT(const Context * context,GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)503 bool ValidateBlendFuncSeparateiEXT(const Context *context,
504                                    GLuint buf,
505                                    GLenum srcRGB,
506                                    GLenum dstRGB,
507                                    GLenum srcAlpha,
508                                    GLenum dstAlpha)
509 {
510     if (!context->getExtensions().drawBuffersIndexedEXT)
511     {
512         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
513         return false;
514     }
515 
516     return ValidateBlendFuncSeparatei(context, buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
517 }
518 
ValidateBlendFunciEXT(const Context * context,GLuint buf,GLenum src,GLenum dst)519 bool ValidateBlendFunciEXT(const Context *context, GLuint buf, GLenum src, GLenum dst)
520 {
521     if (!context->getExtensions().drawBuffersIndexedEXT)
522     {
523         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
524         return false;
525     }
526 
527     return ValidateBlendFunci(context, buf, src, dst);
528 }
529 
ValidateColorMaskiEXT(const Context * context,GLuint index,GLboolean r,GLboolean g,GLboolean b,GLboolean a)530 bool ValidateColorMaskiEXT(const Context *context,
531                            GLuint index,
532                            GLboolean r,
533                            GLboolean g,
534                            GLboolean b,
535                            GLboolean a)
536 {
537     if (!context->getExtensions().drawBuffersIndexedEXT)
538     {
539         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
540         return false;
541     }
542 
543     return ValidateColorMaski(context, index, r, g, b, a);
544 }
545 
ValidateDisableiEXT(const Context * context,GLenum target,GLuint index)546 bool ValidateDisableiEXT(const Context *context, GLenum target, GLuint index)
547 {
548     if (!context->getExtensions().drawBuffersIndexedEXT)
549     {
550         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
551         return false;
552     }
553 
554     return ValidateDisablei(context, target, index);
555 }
556 
ValidateEnableiEXT(const Context * context,GLenum target,GLuint index)557 bool ValidateEnableiEXT(const Context *context, GLenum target, GLuint index)
558 {
559     if (!context->getExtensions().drawBuffersIndexedEXT)
560     {
561         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
562         return false;
563     }
564 
565     return ValidateEnablei(context, target, index);
566 }
567 
ValidateIsEnablediEXT(const Context * context,GLenum target,GLuint index)568 bool ValidateIsEnablediEXT(const Context *context, GLenum target, GLuint index)
569 {
570     if (!context->getExtensions().drawBuffersIndexedEXT)
571     {
572         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
573         return false;
574     }
575 
576     return ValidateIsEnabledi(context, target, index);
577 }
578 
ValidateBlendEquationSeparateiOES(const Context * context,GLuint buf,GLenum modeRGB,GLenum modeAlpha)579 bool ValidateBlendEquationSeparateiOES(const Context *context,
580                                        GLuint buf,
581                                        GLenum modeRGB,
582                                        GLenum modeAlpha)
583 {
584     if (!context->getExtensions().drawBuffersIndexedOES)
585     {
586         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
587         return false;
588     }
589 
590     return ValidateBlendEquationSeparatei(context, buf, modeRGB, modeAlpha);
591 }
592 
ValidateBlendEquationiOES(const Context * context,GLuint buf,GLenum mode)593 bool ValidateBlendEquationiOES(const Context *context, GLuint buf, GLenum mode)
594 {
595     if (!context->getExtensions().drawBuffersIndexedOES)
596     {
597         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
598         return false;
599     }
600 
601     return ValidateBlendEquationi(context, buf, mode);
602 }
603 
ValidateBlendFuncSeparateiOES(const Context * context,GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)604 bool ValidateBlendFuncSeparateiOES(const Context *context,
605                                    GLuint buf,
606                                    GLenum srcRGB,
607                                    GLenum dstRGB,
608                                    GLenum srcAlpha,
609                                    GLenum dstAlpha)
610 {
611     if (!context->getExtensions().drawBuffersIndexedOES)
612     {
613         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
614         return false;
615     }
616 
617     return ValidateBlendFuncSeparatei(context, buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
618 }
619 
ValidateBlendFunciOES(const Context * context,GLuint buf,GLenum src,GLenum dst)620 bool ValidateBlendFunciOES(const Context *context, GLuint buf, GLenum src, GLenum dst)
621 {
622     if (!context->getExtensions().drawBuffersIndexedOES)
623     {
624         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
625         return false;
626     }
627 
628     return ValidateBlendFunci(context, buf, src, dst);
629 }
630 
ValidateColorMaskiOES(const Context * context,GLuint index,GLboolean r,GLboolean g,GLboolean b,GLboolean a)631 bool ValidateColorMaskiOES(const Context *context,
632                            GLuint index,
633                            GLboolean r,
634                            GLboolean g,
635                            GLboolean b,
636                            GLboolean a)
637 {
638     if (!context->getExtensions().drawBuffersIndexedOES)
639     {
640         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
641         return false;
642     }
643 
644     return ValidateColorMaski(context, index, r, g, b, a);
645 }
646 
ValidateDisableiOES(const Context * context,GLenum target,GLuint index)647 bool ValidateDisableiOES(const Context *context, GLenum target, GLuint index)
648 {
649     if (!context->getExtensions().drawBuffersIndexedOES)
650     {
651         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
652         return false;
653     }
654 
655     return ValidateDisablei(context, target, index);
656 }
657 
ValidateEnableiOES(const Context * context,GLenum target,GLuint index)658 bool ValidateEnableiOES(const Context *context, GLenum target, GLuint index)
659 {
660     if (!context->getExtensions().drawBuffersIndexedOES)
661     {
662         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
663         return false;
664     }
665 
666     return ValidateEnablei(context, target, index);
667 }
668 
ValidateIsEnablediOES(const Context * context,GLenum target,GLuint index)669 bool ValidateIsEnablediOES(const Context *context, GLenum target, GLuint index)
670 {
671     if (!context->getExtensions().drawBuffersIndexedOES)
672     {
673         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
674         return false;
675     }
676 
677     return ValidateIsEnabledi(context, target, index);
678 }
679 
ValidateGetInteger64vEXT(const Context * context,GLenum pname,const GLint64 * data)680 bool ValidateGetInteger64vEXT(const Context *context, GLenum pname, const GLint64 *data)
681 {
682     if (!context->getExtensions().disjointTimerQuery)
683     {
684         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
685         return false;
686     }
687 
688     GLenum nativeType      = GL_NONE;
689     unsigned int numParams = 0;
690     if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
691     {
692         return false;
693     }
694 
695     return true;
696 }
697 
ValidateCopyImageSubDataEXT(const Context * context,GLuint srcName,GLenum srcTarget,GLint srcLevel,GLint srcX,GLint srcY,GLint srcZ,GLuint dstName,GLenum dstTarget,GLint dstLevel,GLint dstX,GLint dstY,GLint dstZ,GLsizei srcWidth,GLsizei srcHeight,GLsizei srcDepth)698 bool ValidateCopyImageSubDataEXT(const Context *context,
699                                  GLuint srcName,
700                                  GLenum srcTarget,
701                                  GLint srcLevel,
702                                  GLint srcX,
703                                  GLint srcY,
704                                  GLint srcZ,
705                                  GLuint dstName,
706                                  GLenum dstTarget,
707                                  GLint dstLevel,
708                                  GLint dstX,
709                                  GLint dstY,
710                                  GLint dstZ,
711                                  GLsizei srcWidth,
712                                  GLsizei srcHeight,
713                                  GLsizei srcDepth)
714 {
715     if (!context->getExtensions().copyImageEXT)
716     {
717         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
718         return false;
719     }
720 
721     return ValidateCopyImageSubDataBase(context, srcName, srcTarget, srcLevel, srcX, srcY, srcZ,
722                                         dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth,
723                                         srcHeight, srcDepth);
724 }
725 
ValidateCopyImageSubDataOES(const Context * context,GLuint srcName,GLenum srcTarget,GLint srcLevel,GLint srcX,GLint srcY,GLint srcZ,GLuint dstName,GLenum dstTarget,GLint dstLevel,GLint dstX,GLint dstY,GLint dstZ,GLsizei srcWidth,GLsizei srcHeight,GLsizei srcDepth)726 bool ValidateCopyImageSubDataOES(const Context *context,
727                                  GLuint srcName,
728                                  GLenum srcTarget,
729                                  GLint srcLevel,
730                                  GLint srcX,
731                                  GLint srcY,
732                                  GLint srcZ,
733                                  GLuint dstName,
734                                  GLenum dstTarget,
735                                  GLint dstLevel,
736                                  GLint dstX,
737                                  GLint dstY,
738                                  GLint dstZ,
739                                  GLsizei srcWidth,
740                                  GLsizei srcHeight,
741                                  GLsizei srcDepth)
742 {
743     if (!context->getExtensions().copyImageEXT)
744     {
745         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
746         return false;
747     }
748 
749     return ValidateCopyImageSubDataBase(context, srcName, srcTarget, srcLevel, srcX, srcY, srcZ,
750                                         dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth,
751                                         srcHeight, srcDepth);
752 }
753 
ValidateBufferStorageMemEXT(const Context * context,TextureType target,GLsizeiptr size,MemoryObjectID memory,GLuint64 offset)754 bool ValidateBufferStorageMemEXT(const Context *context,
755                                  TextureType target,
756                                  GLsizeiptr size,
757                                  MemoryObjectID memory,
758                                  GLuint64 offset)
759 {
760     if (!context->getExtensions().memoryObject)
761     {
762         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
763         return false;
764     }
765 
766     UNIMPLEMENTED();
767     return false;
768 }
769 
ValidateCreateMemoryObjectsEXT(const Context * context,GLsizei n,const MemoryObjectID * memoryObjects)770 bool ValidateCreateMemoryObjectsEXT(const Context *context,
771                                     GLsizei n,
772                                     const MemoryObjectID *memoryObjects)
773 {
774     if (!context->getExtensions().memoryObject)
775     {
776         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
777         return false;
778     }
779 
780     return ValidateGenOrDelete(context, n);
781 }
782 
ValidateDeleteMemoryObjectsEXT(const Context * context,GLsizei n,const MemoryObjectID * memoryObjects)783 bool ValidateDeleteMemoryObjectsEXT(const Context *context,
784                                     GLsizei n,
785                                     const MemoryObjectID *memoryObjects)
786 {
787     if (!context->getExtensions().memoryObject)
788     {
789         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
790         return false;
791     }
792 
793     return ValidateGenOrDelete(context, n);
794 }
795 
ValidateGetMemoryObjectParameterivEXT(const Context * context,MemoryObjectID memoryObject,GLenum pname,const GLint * params)796 bool ValidateGetMemoryObjectParameterivEXT(const Context *context,
797                                            MemoryObjectID memoryObject,
798                                            GLenum pname,
799                                            const GLint *params)
800 {
801     if (!context->getExtensions().memoryObject)
802     {
803         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
804         return false;
805     }
806 
807     const MemoryObject *memory = context->getMemoryObject(memoryObject);
808     if (memory == nullptr)
809     {
810         context->validationError(GL_INVALID_VALUE, kInvalidMemoryObject);
811     }
812 
813     if (!IsValidMemoryObjectParamater(context, pname))
814     {
815         context->validationError(GL_INVALID_ENUM, kInvalidMemoryObjectParameter);
816         return false;
817     }
818 
819     return true;
820 }
821 
ValidateGetUnsignedBytevEXT(const Context * context,GLenum pname,const GLubyte * data)822 bool ValidateGetUnsignedBytevEXT(const Context *context, GLenum pname, const GLubyte *data)
823 {
824     if (!context->getExtensions().memoryObject && !context->getExtensions().semaphore)
825     {
826         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
827         return false;
828     }
829 
830     UNIMPLEMENTED();
831     return false;
832 }
833 
ValidateGetUnsignedBytei_vEXT(const Context * context,GLenum target,GLuint index,const GLubyte * data)834 bool ValidateGetUnsignedBytei_vEXT(const Context *context,
835                                    GLenum target,
836                                    GLuint index,
837                                    const GLubyte *data)
838 {
839     if (!context->getExtensions().memoryObject && !context->getExtensions().semaphore)
840     {
841         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
842         return false;
843     }
844 
845     UNIMPLEMENTED();
846     return false;
847 }
848 
ValidateIsMemoryObjectEXT(const Context * context,MemoryObjectID memoryObject)849 bool ValidateIsMemoryObjectEXT(const Context *context, MemoryObjectID memoryObject)
850 {
851     if (!context->getExtensions().memoryObject)
852     {
853         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
854         return false;
855     }
856 
857     return true;
858 }
859 
ValidateMemoryObjectParameterivEXT(const Context * context,MemoryObjectID memoryObject,GLenum pname,const GLint * params)860 bool ValidateMemoryObjectParameterivEXT(const Context *context,
861                                         MemoryObjectID memoryObject,
862                                         GLenum pname,
863                                         const GLint *params)
864 {
865     if (!context->getExtensions().memoryObject)
866     {
867         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
868         return false;
869     }
870 
871     const MemoryObject *memory = context->getMemoryObject(memoryObject);
872     if (memory == nullptr)
873     {
874         context->validationError(GL_INVALID_VALUE, kInvalidMemoryObject);
875         return false;
876     }
877 
878     if (memory->isImmutable())
879     {
880         context->validationError(GL_INVALID_OPERATION, kImmutableMemoryObject);
881         return false;
882     }
883 
884     if (!IsValidMemoryObjectParamater(context, pname))
885     {
886         context->validationError(GL_INVALID_ENUM, kInvalidMemoryObjectParameter);
887         return false;
888     }
889 
890     return true;
891 }
892 
ValidateTexStorageMem2DEXT(const Context * context,TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,MemoryObjectID memory,GLuint64 offset)893 bool ValidateTexStorageMem2DEXT(const Context *context,
894                                 TextureType target,
895                                 GLsizei levels,
896                                 GLenum internalFormat,
897                                 GLsizei width,
898                                 GLsizei height,
899                                 MemoryObjectID memory,
900                                 GLuint64 offset)
901 {
902     if (!context->getExtensions().memoryObject)
903     {
904         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
905         return false;
906     }
907 
908     if (context->getClientMajorVersion() < 3)
909     {
910         return ValidateES2TexStorageParametersBase(context, target, levels, internalFormat, width,
911                                                    height);
912     }
913 
914     ASSERT(context->getClientMajorVersion() >= 3);
915     return ValidateES3TexStorage2DParameters(context, target, levels, internalFormat, width, height,
916                                              1);
917 }
918 
ValidateTexStorageMem3DEXT(const Context * context,TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,MemoryObjectID memory,GLuint64 offset)919 bool ValidateTexStorageMem3DEXT(const Context *context,
920                                 TextureType target,
921                                 GLsizei levels,
922                                 GLenum internalFormat,
923                                 GLsizei width,
924                                 GLsizei height,
925                                 GLsizei depth,
926                                 MemoryObjectID memory,
927                                 GLuint64 offset)
928 {
929     if (!context->getExtensions().memoryObject)
930     {
931         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
932         return false;
933     }
934 
935     UNIMPLEMENTED();
936     return false;
937 }
938 
ValidateImportMemoryFdEXT(const Context * context,MemoryObjectID memory,GLuint64 size,HandleType handleType,GLint fd)939 bool ValidateImportMemoryFdEXT(const Context *context,
940                                MemoryObjectID memory,
941                                GLuint64 size,
942                                HandleType handleType,
943                                GLint fd)
944 {
945     if (!context->getExtensions().memoryObjectFd)
946     {
947         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
948         return false;
949     }
950 
951     switch (handleType)
952     {
953         case HandleType::OpaqueFd:
954             break;
955         default:
956             context->validationError(GL_INVALID_ENUM, kInvalidHandleType);
957             return false;
958     }
959 
960     return true;
961 }
962 
ValidateImportMemoryZirconHandleANGLE(const Context * context,MemoryObjectID memory,GLuint64 size,HandleType handleType,GLuint handle)963 bool ValidateImportMemoryZirconHandleANGLE(const Context *context,
964                                            MemoryObjectID memory,
965                                            GLuint64 size,
966                                            HandleType handleType,
967                                            GLuint handle)
968 {
969     if (!context->getExtensions().memoryObjectFuchsiaANGLE)
970     {
971         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
972         return false;
973     }
974 
975     switch (handleType)
976     {
977         case HandleType::ZirconVmo:
978             break;
979         default:
980             context->validationError(GL_INVALID_ENUM, kInvalidHandleType);
981             return false;
982     }
983 
984     return true;
985 }
986 
ValidateDeleteSemaphoresEXT(const Context * context,GLsizei n,const SemaphoreID * semaphores)987 bool ValidateDeleteSemaphoresEXT(const Context *context, GLsizei n, const SemaphoreID *semaphores)
988 {
989     if (!context->getExtensions().semaphore)
990     {
991         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
992         return false;
993     }
994 
995     return ValidateGenOrDelete(context, n);
996 }
997 
ValidateGenSemaphoresEXT(const Context * context,GLsizei n,const SemaphoreID * semaphores)998 bool ValidateGenSemaphoresEXT(const Context *context, GLsizei n, const SemaphoreID *semaphores)
999 {
1000     if (!context->getExtensions().semaphore)
1001     {
1002         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1003         return false;
1004     }
1005 
1006     return ValidateGenOrDelete(context, n);
1007 }
1008 
ValidateGetSemaphoreParameterui64vEXT(const Context * context,SemaphoreID semaphore,GLenum pname,const GLuint64 * params)1009 bool ValidateGetSemaphoreParameterui64vEXT(const Context *context,
1010                                            SemaphoreID semaphore,
1011                                            GLenum pname,
1012                                            const GLuint64 *params)
1013 {
1014     if (!context->getExtensions().semaphore)
1015     {
1016         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1017         return false;
1018     }
1019 
1020     UNIMPLEMENTED();
1021     return false;
1022 }
1023 
ValidateIsSemaphoreEXT(const Context * context,SemaphoreID semaphore)1024 bool ValidateIsSemaphoreEXT(const Context *context, SemaphoreID semaphore)
1025 {
1026     if (!context->getExtensions().semaphore)
1027     {
1028         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1029         return false;
1030     }
1031 
1032     return true;
1033 }
1034 
ValidateSemaphoreParameterui64vEXT(const Context * context,SemaphoreID semaphore,GLenum pname,const GLuint64 * params)1035 bool ValidateSemaphoreParameterui64vEXT(const Context *context,
1036                                         SemaphoreID semaphore,
1037                                         GLenum pname,
1038                                         const GLuint64 *params)
1039 {
1040     if (!context->getExtensions().semaphore)
1041     {
1042         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1043         return false;
1044     }
1045 
1046     UNIMPLEMENTED();
1047     return false;
1048 }
1049 
ValidateSignalSemaphoreEXT(const Context * context,SemaphoreID semaphore,GLuint numBufferBarriers,const BufferID * buffers,GLuint numTextureBarriers,const TextureID * textures,const GLenum * dstLayouts)1050 bool ValidateSignalSemaphoreEXT(const Context *context,
1051                                 SemaphoreID semaphore,
1052                                 GLuint numBufferBarriers,
1053                                 const BufferID *buffers,
1054                                 GLuint numTextureBarriers,
1055                                 const TextureID *textures,
1056                                 const GLenum *dstLayouts)
1057 {
1058     if (!context->getExtensions().semaphore)
1059     {
1060         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1061         return false;
1062     }
1063 
1064     for (GLuint i = 0; i < numTextureBarriers; ++i)
1065     {
1066         if (!IsValidImageLayout(FromGLenum<ImageLayout>(dstLayouts[i])))
1067         {
1068             context->validationError(GL_INVALID_ENUM, kInvalidImageLayout);
1069             return false;
1070         }
1071     }
1072 
1073     return true;
1074 }
1075 
ValidateWaitSemaphoreEXT(const Context * context,SemaphoreID semaphore,GLuint numBufferBarriers,const BufferID * buffers,GLuint numTextureBarriers,const TextureID * textures,const GLenum * srcLayouts)1076 bool ValidateWaitSemaphoreEXT(const Context *context,
1077                               SemaphoreID semaphore,
1078                               GLuint numBufferBarriers,
1079                               const BufferID *buffers,
1080                               GLuint numTextureBarriers,
1081                               const TextureID *textures,
1082                               const GLenum *srcLayouts)
1083 {
1084     if (!context->getExtensions().semaphore)
1085     {
1086         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1087         return false;
1088     }
1089 
1090     for (GLuint i = 0; i < numTextureBarriers; ++i)
1091     {
1092         if (!IsValidImageLayout(FromGLenum<ImageLayout>(srcLayouts[i])))
1093         {
1094             context->validationError(GL_INVALID_ENUM, kInvalidImageLayout);
1095             return false;
1096         }
1097     }
1098 
1099     return true;
1100 }
1101 
ValidateImportSemaphoreFdEXT(const Context * context,SemaphoreID semaphore,HandleType handleType,GLint fd)1102 bool ValidateImportSemaphoreFdEXT(const Context *context,
1103                                   SemaphoreID semaphore,
1104                                   HandleType handleType,
1105                                   GLint fd)
1106 {
1107     if (!context->getExtensions().semaphoreFd)
1108     {
1109         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1110         return false;
1111     }
1112 
1113     switch (handleType)
1114     {
1115         case HandleType::OpaqueFd:
1116             break;
1117         default:
1118             context->validationError(GL_INVALID_ENUM, kInvalidHandleType);
1119             return false;
1120     }
1121 
1122     return true;
1123 }
1124 
ValidateGetSamplerParameterIivEXT(const Context * context,SamplerID samplerPacked,GLenum pname,const GLint * params)1125 bool ValidateGetSamplerParameterIivEXT(const Context *context,
1126                                        SamplerID samplerPacked,
1127                                        GLenum pname,
1128                                        const GLint *params)
1129 {
1130     if (context->getClientMajorVersion() < 3)
1131     {
1132         context->validationError(GL_INVALID_OPERATION, kES3Required);
1133         return false;
1134     }
1135     return ValidateGetSamplerParameterBase(context, samplerPacked, pname, nullptr);
1136 }
1137 
ValidateGetSamplerParameterIuivEXT(const Context * context,SamplerID samplerPacked,GLenum pname,const GLuint * params)1138 bool ValidateGetSamplerParameterIuivEXT(const Context *context,
1139                                         SamplerID samplerPacked,
1140                                         GLenum pname,
1141                                         const GLuint *params)
1142 {
1143     if (context->getClientMajorVersion() < 3)
1144     {
1145         context->validationError(GL_INVALID_OPERATION, kES3Required);
1146         return false;
1147     }
1148     return ValidateGetSamplerParameterBase(context, samplerPacked, pname, nullptr);
1149 }
1150 
ValidateGetTexParameterIivEXT(const Context * context,TextureType targetPacked,GLenum pname,const GLint * params)1151 bool ValidateGetTexParameterIivEXT(const Context *context,
1152                                    TextureType targetPacked,
1153                                    GLenum pname,
1154                                    const GLint *params)
1155 {
1156     if (context->getClientMajorVersion() < 3)
1157     {
1158         context->validationError(GL_INVALID_OPERATION, kES3Required);
1159         return false;
1160     }
1161     return ValidateGetTexParameterBase(context, targetPacked, pname, nullptr);
1162 }
1163 
ValidateGetTexParameterIuivEXT(const Context * context,TextureType targetPacked,GLenum pname,const GLuint * params)1164 bool ValidateGetTexParameterIuivEXT(const Context *context,
1165                                     TextureType targetPacked,
1166                                     GLenum pname,
1167                                     const GLuint *params)
1168 {
1169     if (context->getClientMajorVersion() < 3)
1170     {
1171         context->validationError(GL_INVALID_OPERATION, kES3Required);
1172         return false;
1173     }
1174     return ValidateGetTexParameterBase(context, targetPacked, pname, nullptr);
1175 }
1176 
ValidateSamplerParameterIivEXT(const Context * context,SamplerID samplerPacked,GLenum pname,const GLint * param)1177 bool ValidateSamplerParameterIivEXT(const Context *context,
1178                                     SamplerID samplerPacked,
1179                                     GLenum pname,
1180                                     const GLint *param)
1181 {
1182     if (context->getClientMajorVersion() < 3)
1183     {
1184         context->validationError(GL_INVALID_OPERATION, kES3Required);
1185         return false;
1186     }
1187     return ValidateSamplerParameterBase(context, samplerPacked, pname, -1, true, param);
1188 }
1189 
ValidateSamplerParameterIuivEXT(const Context * context,SamplerID samplerPacked,GLenum pname,const GLuint * param)1190 bool ValidateSamplerParameterIuivEXT(const Context *context,
1191                                      SamplerID samplerPacked,
1192                                      GLenum pname,
1193                                      const GLuint *param)
1194 {
1195     if (context->getClientMajorVersion() < 3)
1196     {
1197         context->validationError(GL_INVALID_OPERATION, kES3Required);
1198         return false;
1199     }
1200     return ValidateSamplerParameterBase(context, samplerPacked, pname, -1, true, param);
1201 }
1202 
ValidateTexParameterIivEXT(const Context * context,TextureType targetPacked,GLenum pname,const GLint * params)1203 bool ValidateTexParameterIivEXT(const Context *context,
1204                                 TextureType targetPacked,
1205                                 GLenum pname,
1206                                 const GLint *params)
1207 {
1208     if (context->getClientMajorVersion() < 3)
1209     {
1210         context->validationError(GL_INVALID_OPERATION, kES3Required);
1211         return false;
1212     }
1213     return ValidateTexParameterBase(context, targetPacked, pname, -1, true, params);
1214 }
1215 
ValidateTexParameterIuivEXT(const Context * context,TextureType targetPacked,GLenum pname,const GLuint * params)1216 bool ValidateTexParameterIuivEXT(const Context *context,
1217                                  TextureType targetPacked,
1218                                  GLenum pname,
1219                                  const GLuint *params)
1220 {
1221     if (context->getClientMajorVersion() < 3)
1222     {
1223         context->validationError(GL_INVALID_OPERATION, kES3Required);
1224         return false;
1225     }
1226     return ValidateTexParameterBase(context, targetPacked, pname, -1, true, params);
1227 }
1228 
ValidateImportSemaphoreZirconHandleANGLE(const Context * context,SemaphoreID semaphore,HandleType handleType,GLuint handle)1229 bool ValidateImportSemaphoreZirconHandleANGLE(const Context *context,
1230                                               SemaphoreID semaphore,
1231                                               HandleType handleType,
1232                                               GLuint handle)
1233 {
1234     if (!context->getExtensions().semaphoreFuchsiaANGLE)
1235     {
1236         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1237         return false;
1238     }
1239 
1240     switch (handleType)
1241     {
1242         case HandleType::ZirconEvent:
1243             break;
1244         default:
1245             context->validationError(GL_INVALID_ENUM, kInvalidHandleType);
1246             return false;
1247     }
1248 
1249     return true;
1250 }
1251 
ValidateFramebufferFetchBarrierEXT(const Context * context)1252 bool ValidateFramebufferFetchBarrierEXT(const Context *context)
1253 {
1254     return true;
1255 }
1256 
ValidatePatchParameteriEXT(const Context * context,GLenum pname,GLint value)1257 bool ValidatePatchParameteriEXT(const Context *context, GLenum pname, GLint value)
1258 {
1259     if (!context->getExtensions().tessellationShaderEXT)
1260     {
1261         context->validationError(GL_INVALID_OPERATION, kTessellationShaderExtensionNotEnabled);
1262         return false;
1263     }
1264 
1265     if (pname != GL_PATCH_VERTICES)
1266     {
1267         context->validationError(GL_INVALID_ENUM, kInvalidPname);
1268         return false;
1269     }
1270 
1271     if (value <= 0)
1272     {
1273         context->validationError(GL_INVALID_VALUE, kInvalidValueNonPositive);
1274         return false;
1275     }
1276 
1277     if (value > context->getCaps().maxPatchVertices)
1278     {
1279         context->validationError(GL_INVALID_VALUE, kInvalidValueExceedsMaxPatchSize);
1280         return false;
1281     }
1282 
1283     return true;
1284 }
1285 
ValidateTexStorageMemFlags2DANGLE(const Context * context,TextureType targetPacked,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags)1286 bool ValidateTexStorageMemFlags2DANGLE(const Context *context,
1287                                        TextureType targetPacked,
1288                                        GLsizei levels,
1289                                        GLenum internalFormat,
1290                                        GLsizei width,
1291                                        GLsizei height,
1292                                        MemoryObjectID memoryPacked,
1293                                        GLuint64 offset,
1294                                        GLbitfield createFlags,
1295                                        GLbitfield usageFlags)
1296 {
1297     if (!context->getExtensions().memoryObjectFlagsANGLE)
1298     {
1299         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1300         return false;
1301     }
1302 
1303     if (!ValidateTexStorageMem2DEXT(context, targetPacked, levels, internalFormat, width, height,
1304                                     memoryPacked, offset))
1305     {
1306         return false;
1307     }
1308 
1309     // |createFlags| and |usageFlags| must only have bits specified by the extension.
1310     constexpr GLbitfield kAllCreateFlags =
1311         GL_CREATE_SPARSE_BINDING_BIT_ANGLE | GL_CREATE_SPARSE_RESIDENCY_BIT_ANGLE |
1312         GL_CREATE_SPARSE_ALIASED_BIT_ANGLE | GL_CREATE_MUTABLE_FORMAT_BIT_ANGLE |
1313         GL_CREATE_CUBE_COMPATIBLE_BIT_ANGLE | GL_CREATE_ALIAS_BIT_ANGLE |
1314         GL_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_ANGLE | GL_CREATE_2D_ARRAY_COMPATIBLE_BIT_ANGLE |
1315         GL_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_ANGLE | GL_CREATE_EXTENDED_USAGE_BIT_ANGLE |
1316         GL_CREATE_PROTECTED_BIT_ANGLE | GL_CREATE_DISJOINT_BIT_ANGLE |
1317         GL_CREATE_CORNER_SAMPLED_BIT_ANGLE | GL_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_ANGLE |
1318         GL_CREATE_SUBSAMPLED_BIT_ANGLE;
1319 
1320     if ((createFlags & ~kAllCreateFlags) != 0)
1321     {
1322         context->validationError(GL_INVALID_VALUE, kInvalidExternalCreateFlags);
1323         return false;
1324     }
1325 
1326     constexpr GLbitfield kAllUsageFlags =
1327         GL_USAGE_TRANSFER_SRC_BIT_ANGLE | GL_USAGE_TRANSFER_DST_BIT_ANGLE |
1328         GL_USAGE_SAMPLED_BIT_ANGLE | GL_USAGE_STORAGE_BIT_ANGLE |
1329         GL_USAGE_COLOR_ATTACHMENT_BIT_ANGLE | GL_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT_ANGLE |
1330         GL_USAGE_TRANSIENT_ATTACHMENT_BIT_ANGLE | GL_USAGE_INPUT_ATTACHMENT_BIT_ANGLE |
1331         GL_USAGE_SHADING_RATE_IMAGE_BIT_ANGLE | GL_USAGE_FRAGMENT_DENSITY_MAP_BIT_ANGLE;
1332 
1333     if ((usageFlags & ~kAllUsageFlags) != 0)
1334     {
1335         context->validationError(GL_INVALID_VALUE, kInvalidExternalUsageFlags);
1336         return false;
1337     }
1338 
1339     return true;
1340 }
1341 
ValidateTexStorageMemFlags2DMultisampleANGLE(const Context * context,TextureType targetPacked,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLboolean fixedSampleLocations,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags)1342 bool ValidateTexStorageMemFlags2DMultisampleANGLE(const Context *context,
1343                                                   TextureType targetPacked,
1344                                                   GLsizei samples,
1345                                                   GLenum internalFormat,
1346                                                   GLsizei width,
1347                                                   GLsizei height,
1348                                                   GLboolean fixedSampleLocations,
1349                                                   MemoryObjectID memoryPacked,
1350                                                   GLuint64 offset,
1351                                                   GLbitfield createFlags,
1352                                                   GLbitfield usageFlags)
1353 {
1354     UNIMPLEMENTED();
1355     return false;
1356 }
1357 
ValidateTexStorageMemFlags3DANGLE(const Context * context,TextureType targetPacked,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags)1358 bool ValidateTexStorageMemFlags3DANGLE(const Context *context,
1359                                        TextureType targetPacked,
1360                                        GLsizei levels,
1361                                        GLenum internalFormat,
1362                                        GLsizei width,
1363                                        GLsizei height,
1364                                        GLsizei depth,
1365                                        MemoryObjectID memoryPacked,
1366                                        GLuint64 offset,
1367                                        GLbitfield createFlags,
1368                                        GLbitfield usageFlags)
1369 {
1370     UNIMPLEMENTED();
1371     return false;
1372 }
1373 
ValidateTexStorageMemFlags3DMultisampleANGLE(const Context * context,TextureType targetPacked,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLboolean fixedSampleLocations,MemoryObjectID memoryPacked,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags)1374 bool ValidateTexStorageMemFlags3DMultisampleANGLE(const Context *context,
1375                                                   TextureType targetPacked,
1376                                                   GLsizei samples,
1377                                                   GLenum internalFormat,
1378                                                   GLsizei width,
1379                                                   GLsizei height,
1380                                                   GLsizei depth,
1381                                                   GLboolean fixedSampleLocations,
1382                                                   MemoryObjectID memoryPacked,
1383                                                   GLuint64 offset,
1384                                                   GLbitfield createFlags,
1385                                                   GLbitfield usageFlags)
1386 {
1387     UNIMPLEMENTED();
1388     return false;
1389 }
1390 
1391 // GL_EXT_buffer_storage
ValidateBufferStorageEXT(const Context * context,BufferBinding targetPacked,GLsizeiptr size,const void * data,GLbitfield flags)1392 bool ValidateBufferStorageEXT(const Context *context,
1393                               BufferBinding targetPacked,
1394                               GLsizeiptr size,
1395                               const void *data,
1396                               GLbitfield flags)
1397 {
1398     if (!context->isValidBufferBinding(targetPacked))
1399     {
1400         context->validationError(GL_INVALID_ENUM, kInvalidBufferTypes);
1401         return false;
1402     }
1403 
1404     if (size <= 0)
1405     {
1406         context->validationError(GL_INVALID_VALUE, kNonPositiveSize);
1407         return false;
1408     }
1409 
1410     constexpr GLbitfield kAllUsageFlags =
1411         (GL_DYNAMIC_STORAGE_BIT_EXT | GL_MAP_READ_BIT | GL_MAP_WRITE_BIT |
1412          GL_MAP_PERSISTENT_BIT_EXT | GL_MAP_COHERENT_BIT_EXT | GL_CLIENT_STORAGE_BIT_EXT);
1413     if ((flags & ~kAllUsageFlags) != 0)
1414     {
1415         context->validationError(GL_INVALID_VALUE, kInvalidBufferUsageFlags);
1416         return false;
1417     }
1418 
1419     if (((flags & GL_MAP_PERSISTENT_BIT_EXT) != 0) &&
1420         ((flags & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0))
1421     {
1422         context->validationError(GL_INVALID_VALUE, kInvalidBufferUsageFlags);
1423         return false;
1424     }
1425 
1426     if (((flags & GL_MAP_COHERENT_BIT_EXT) != 0) && ((flags & GL_MAP_PERSISTENT_BIT_EXT) == 0))
1427     {
1428         context->validationError(GL_INVALID_VALUE, kInvalidBufferUsageFlags);
1429         return false;
1430     }
1431 
1432     Buffer *buffer = context->getState().getTargetBuffer(targetPacked);
1433 
1434     if (buffer == nullptr)
1435     {
1436         context->validationError(GL_INVALID_OPERATION, kBufferNotBound);
1437         return false;
1438     }
1439 
1440     if (buffer->isImmutable())
1441     {
1442         context->validationError(GL_INVALID_OPERATION, kBufferImmutable);
1443         return false;
1444     }
1445 
1446     return true;
1447 }
1448 
1449 // GL_EXT_clip_control
ValidateClipControlEXT(const Context * context,GLenum origin,GLenum depth)1450 bool ValidateClipControlEXT(const Context *context, GLenum origin, GLenum depth)
1451 {
1452     if ((origin != GL_LOWER_LEFT_EXT) && (origin != GL_UPPER_LEFT_EXT))
1453     {
1454         context->validationError(GL_INVALID_ENUM, kInvalidOriginEnum);
1455         return false;
1456     }
1457 
1458     if ((depth != GL_NEGATIVE_ONE_TO_ONE_EXT) && (depth != GL_ZERO_TO_ONE_EXT))
1459     {
1460         context->validationError(GL_INVALID_ENUM, kInvalidDepthEnum);
1461         return false;
1462     }
1463 
1464     return true;
1465 }
1466 
1467 // GL_EXT_external_buffer
ValidateBufferStorageExternalEXT(const Context * context,BufferBinding targetPacked,GLintptr offset,GLsizeiptr size,GLeglClientBufferEXT clientBuffer,GLbitfield flags)1468 bool ValidateBufferStorageExternalEXT(const Context *context,
1469                                       BufferBinding targetPacked,
1470                                       GLintptr offset,
1471                                       GLsizeiptr size,
1472                                       GLeglClientBufferEXT clientBuffer,
1473                                       GLbitfield flags)
1474 {
1475     if (!ValidateBufferStorageEXT(context, targetPacked, size, nullptr, flags))
1476     {
1477         return false;
1478     }
1479 
1480     if (offset != 0)
1481     {
1482         context->validationError(GL_INVALID_VALUE, kExternalBufferInvalidOffset);
1483         return false;
1484     }
1485 
1486     if (clientBuffer == nullptr && size > 0)
1487     {
1488         context->validationError(GL_INVALID_VALUE, kClientBufferInvalid);
1489         return false;
1490     }
1491 
1492     return true;
1493 }
1494 
ValidateNamedBufferStorageExternalEXT(const Context * context,GLuint buffer,GLintptr offset,GLsizeiptr size,GLeglClientBufferEXT clientBuffer,GLbitfield flags)1495 bool ValidateNamedBufferStorageExternalEXT(const Context *context,
1496                                            GLuint buffer,
1497                                            GLintptr offset,
1498                                            GLsizeiptr size,
1499                                            GLeglClientBufferEXT clientBuffer,
1500                                            GLbitfield flags)
1501 {
1502     UNIMPLEMENTED();
1503     return false;
1504 }
1505 
1506 // GL_EXT_primitive_bounding_box
ValidatePrimitiveBoundingBoxEXT(const Context * context,GLfloat minX,GLfloat minY,GLfloat minZ,GLfloat minW,GLfloat maxX,GLfloat maxY,GLfloat maxZ,GLfloat maxW)1507 bool ValidatePrimitiveBoundingBoxEXT(const Context *context,
1508                                      GLfloat minX,
1509                                      GLfloat minY,
1510                                      GLfloat minZ,
1511                                      GLfloat minW,
1512                                      GLfloat maxX,
1513                                      GLfloat maxY,
1514                                      GLfloat maxZ,
1515                                      GLfloat maxW)
1516 {
1517     context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1518     return false;
1519 }
1520 
1521 // GL_EXT_separate_shader_objects
ValidateActiveShaderProgramEXT(const Context * context,ProgramPipelineID pipelinePacked,ShaderProgramID programPacked)1522 bool ValidateActiveShaderProgramEXT(const Context *context,
1523                                     ProgramPipelineID pipelinePacked,
1524                                     ShaderProgramID programPacked)
1525 {
1526     if (!context->getExtensions().separateShaderObjects)
1527     {
1528         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1529         return false;
1530     }
1531 
1532     return ValidateActiveShaderProgramBase(context, pipelinePacked, programPacked);
1533 }
1534 
ValidateBindProgramPipelineEXT(const Context * context,ProgramPipelineID pipelinePacked)1535 bool ValidateBindProgramPipelineEXT(const Context *context, ProgramPipelineID pipelinePacked)
1536 {
1537     if (!context->getExtensions().separateShaderObjects)
1538     {
1539         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1540         return false;
1541     }
1542 
1543     return ValidateBindProgramPipelineBase(context, pipelinePacked);
1544 }
1545 
ValidateCreateShaderProgramvEXT(const Context * context,ShaderType typePacked,GLsizei count,const GLchar ** strings)1546 bool ValidateCreateShaderProgramvEXT(const Context *context,
1547                                      ShaderType typePacked,
1548                                      GLsizei count,
1549                                      const GLchar **strings)
1550 {
1551     if (!context->getExtensions().separateShaderObjects)
1552     {
1553         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1554         return false;
1555     }
1556 
1557     return ValidateCreateShaderProgramvBase(context, typePacked, count, strings);
1558 }
1559 
ValidateDeleteProgramPipelinesEXT(const Context * context,GLsizei n,const ProgramPipelineID * pipelinesPacked)1560 bool ValidateDeleteProgramPipelinesEXT(const Context *context,
1561                                        GLsizei n,
1562                                        const ProgramPipelineID *pipelinesPacked)
1563 {
1564     if (!context->getExtensions().separateShaderObjects)
1565     {
1566         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1567         return false;
1568     }
1569 
1570     return ValidateDeleteProgramPipelinesBase(context, n, pipelinesPacked);
1571 }
1572 
ValidateGenProgramPipelinesEXT(const Context * context,GLsizei n,const ProgramPipelineID * pipelinesPacked)1573 bool ValidateGenProgramPipelinesEXT(const Context *context,
1574                                     GLsizei n,
1575                                     const ProgramPipelineID *pipelinesPacked)
1576 {
1577     if (!context->getExtensions().separateShaderObjects)
1578     {
1579         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1580         return false;
1581     }
1582 
1583     return ValidateGenProgramPipelinesBase(context, n, pipelinesPacked);
1584 }
1585 
ValidateGetProgramPipelineInfoLogEXT(const Context * context,ProgramPipelineID pipelinePacked,GLsizei bufSize,const GLsizei * length,const GLchar * infoLog)1586 bool ValidateGetProgramPipelineInfoLogEXT(const Context *context,
1587                                           ProgramPipelineID pipelinePacked,
1588                                           GLsizei bufSize,
1589                                           const GLsizei *length,
1590                                           const GLchar *infoLog)
1591 {
1592     if (!context->getExtensions().separateShaderObjects)
1593     {
1594         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1595         return false;
1596     }
1597 
1598     return ValidateGetProgramPipelineInfoLogBase(context, pipelinePacked, bufSize, length, infoLog);
1599 }
1600 
ValidateGetProgramPipelineivEXT(const Context * context,ProgramPipelineID pipelinePacked,GLenum pname,const GLint * params)1601 bool ValidateGetProgramPipelineivEXT(const Context *context,
1602                                      ProgramPipelineID pipelinePacked,
1603                                      GLenum pname,
1604                                      const GLint *params)
1605 {
1606     if (!context->getExtensions().separateShaderObjects)
1607     {
1608         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1609         return false;
1610     }
1611 
1612     return ValidateGetProgramPipelineivBase(context, pipelinePacked, pname, params);
1613 }
1614 
ValidateIsProgramPipelineEXT(const Context * context,ProgramPipelineID pipelinePacked)1615 bool ValidateIsProgramPipelineEXT(const Context *context, ProgramPipelineID pipelinePacked)
1616 {
1617     if (!context->getExtensions().separateShaderObjects)
1618     {
1619         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1620         return false;
1621     }
1622 
1623     return ValidateIsProgramPipelineBase(context, pipelinePacked);
1624 }
1625 
ValidateProgramParameteriEXT(const Context * context,ShaderProgramID programPacked,GLenum pname,GLint value)1626 bool ValidateProgramParameteriEXT(const Context *context,
1627                                   ShaderProgramID programPacked,
1628                                   GLenum pname,
1629                                   GLint value)
1630 {
1631     if (!context->getExtensions().separateShaderObjects)
1632     {
1633         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1634         return false;
1635     }
1636 
1637     return ValidateProgramParameteriBase(context, programPacked, pname, value);
1638 }
1639 
ValidateProgramUniform1fEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0)1640 bool ValidateProgramUniform1fEXT(const Context *context,
1641                                  ShaderProgramID programPacked,
1642                                  UniformLocation locationPacked,
1643                                  GLfloat v0)
1644 {
1645     if (!context->getExtensions().separateShaderObjects)
1646     {
1647         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1648         return false;
1649     }
1650 
1651     return ValidateProgramUniform1fBase(context, programPacked, locationPacked, v0);
1652 }
1653 
ValidateProgramUniform1fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)1654 bool ValidateProgramUniform1fvEXT(const Context *context,
1655                                   ShaderProgramID programPacked,
1656                                   UniformLocation locationPacked,
1657                                   GLsizei count,
1658                                   const GLfloat *value)
1659 {
1660     if (!context->getExtensions().separateShaderObjects)
1661     {
1662         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1663         return false;
1664     }
1665 
1666     return ValidateProgramUniform1fvBase(context, programPacked, locationPacked, count, value);
1667 }
1668 
ValidateProgramUniform1iEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0)1669 bool ValidateProgramUniform1iEXT(const Context *context,
1670                                  ShaderProgramID programPacked,
1671                                  UniformLocation locationPacked,
1672                                  GLint v0)
1673 {
1674     if (!context->getExtensions().separateShaderObjects)
1675     {
1676         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1677         return false;
1678     }
1679 
1680     return ValidateProgramUniform1iBase(context, programPacked, locationPacked, v0);
1681 }
1682 
ValidateProgramUniform1ivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)1683 bool ValidateProgramUniform1ivEXT(const Context *context,
1684                                   ShaderProgramID programPacked,
1685                                   UniformLocation locationPacked,
1686                                   GLsizei count,
1687                                   const GLint *value)
1688 {
1689     if (!context->getExtensions().separateShaderObjects)
1690     {
1691         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1692         return false;
1693     }
1694 
1695     return ValidateProgramUniform1ivBase(context, programPacked, locationPacked, count, value);
1696 }
1697 
ValidateProgramUniform1uiEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0)1698 bool ValidateProgramUniform1uiEXT(const Context *context,
1699                                   ShaderProgramID programPacked,
1700                                   UniformLocation locationPacked,
1701                                   GLuint v0)
1702 {
1703     if (!context->getExtensions().separateShaderObjects)
1704     {
1705         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1706         return false;
1707     }
1708 
1709     return ValidateProgramUniform1uiBase(context, programPacked, locationPacked, v0);
1710 }
1711 
ValidateProgramUniform1uivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)1712 bool ValidateProgramUniform1uivEXT(const Context *context,
1713                                    ShaderProgramID programPacked,
1714                                    UniformLocation locationPacked,
1715                                    GLsizei count,
1716                                    const GLuint *value)
1717 {
1718     if (!context->getExtensions().separateShaderObjects)
1719     {
1720         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1721         return false;
1722     }
1723 
1724     return ValidateProgramUniform1uivBase(context, programPacked, locationPacked, count, value);
1725 }
1726 
ValidateProgramUniform2fEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0,GLfloat v1)1727 bool ValidateProgramUniform2fEXT(const Context *context,
1728                                  ShaderProgramID programPacked,
1729                                  UniformLocation locationPacked,
1730                                  GLfloat v0,
1731                                  GLfloat v1)
1732 {
1733     if (!context->getExtensions().separateShaderObjects)
1734     {
1735         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1736         return false;
1737     }
1738 
1739     return ValidateProgramUniform2fBase(context, programPacked, locationPacked, v0, v1);
1740 }
1741 
ValidateProgramUniform2fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)1742 bool ValidateProgramUniform2fvEXT(const Context *context,
1743                                   ShaderProgramID programPacked,
1744                                   UniformLocation locationPacked,
1745                                   GLsizei count,
1746                                   const GLfloat *value)
1747 {
1748     if (!context->getExtensions().separateShaderObjects)
1749     {
1750         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1751         return false;
1752     }
1753 
1754     return ValidateProgramUniform2fvBase(context, programPacked, locationPacked, count, value);
1755 }
1756 
ValidateProgramUniform2iEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0,GLint v1)1757 bool ValidateProgramUniform2iEXT(const Context *context,
1758                                  ShaderProgramID programPacked,
1759                                  UniformLocation locationPacked,
1760                                  GLint v0,
1761                                  GLint v1)
1762 {
1763     if (!context->getExtensions().separateShaderObjects)
1764     {
1765         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1766         return false;
1767     }
1768 
1769     return ValidateProgramUniform2iBase(context, programPacked, locationPacked, v0, v1);
1770 }
1771 
ValidateProgramUniform2ivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)1772 bool ValidateProgramUniform2ivEXT(const Context *context,
1773                                   ShaderProgramID programPacked,
1774                                   UniformLocation locationPacked,
1775                                   GLsizei count,
1776                                   const GLint *value)
1777 {
1778     if (!context->getExtensions().separateShaderObjects)
1779     {
1780         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1781         return false;
1782     }
1783 
1784     return ValidateProgramUniform2ivBase(context, programPacked, locationPacked, count, value);
1785 }
1786 
ValidateProgramUniform2uiEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0,GLuint v1)1787 bool ValidateProgramUniform2uiEXT(const Context *context,
1788                                   ShaderProgramID programPacked,
1789                                   UniformLocation locationPacked,
1790                                   GLuint v0,
1791                                   GLuint v1)
1792 {
1793     if (!context->getExtensions().separateShaderObjects)
1794     {
1795         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1796         return false;
1797     }
1798 
1799     return ValidateProgramUniform2uiBase(context, programPacked, locationPacked, v0, v1);
1800 }
1801 
ValidateProgramUniform2uivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)1802 bool ValidateProgramUniform2uivEXT(const Context *context,
1803                                    ShaderProgramID programPacked,
1804                                    UniformLocation locationPacked,
1805                                    GLsizei count,
1806                                    const GLuint *value)
1807 {
1808     if (!context->getExtensions().separateShaderObjects)
1809     {
1810         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1811         return false;
1812     }
1813 
1814     return ValidateProgramUniform2uivBase(context, programPacked, locationPacked, count, value);
1815 }
1816 
ValidateProgramUniform3fEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0,GLfloat v1,GLfloat v2)1817 bool ValidateProgramUniform3fEXT(const Context *context,
1818                                  ShaderProgramID programPacked,
1819                                  UniformLocation locationPacked,
1820                                  GLfloat v0,
1821                                  GLfloat v1,
1822                                  GLfloat v2)
1823 {
1824     if (!context->getExtensions().separateShaderObjects)
1825     {
1826         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1827         return false;
1828     }
1829 
1830     return ValidateProgramUniform3fBase(context, programPacked, locationPacked, v0, v1, v2);
1831 }
1832 
ValidateProgramUniform3fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)1833 bool ValidateProgramUniform3fvEXT(const Context *context,
1834                                   ShaderProgramID programPacked,
1835                                   UniformLocation locationPacked,
1836                                   GLsizei count,
1837                                   const GLfloat *value)
1838 {
1839     if (!context->getExtensions().separateShaderObjects)
1840     {
1841         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1842         return false;
1843     }
1844 
1845     return ValidateProgramUniform3fvBase(context, programPacked, locationPacked, count, value);
1846 }
1847 
ValidateProgramUniform3iEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0,GLint v1,GLint v2)1848 bool ValidateProgramUniform3iEXT(const Context *context,
1849                                  ShaderProgramID programPacked,
1850                                  UniformLocation locationPacked,
1851                                  GLint v0,
1852                                  GLint v1,
1853                                  GLint v2)
1854 {
1855     if (!context->getExtensions().separateShaderObjects)
1856     {
1857         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1858         return false;
1859     }
1860 
1861     return ValidateProgramUniform3iBase(context, programPacked, locationPacked, v0, v1, v2);
1862 }
1863 
ValidateProgramUniform3ivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)1864 bool ValidateProgramUniform3ivEXT(const Context *context,
1865                                   ShaderProgramID programPacked,
1866                                   UniformLocation locationPacked,
1867                                   GLsizei count,
1868                                   const GLint *value)
1869 {
1870     if (!context->getExtensions().separateShaderObjects)
1871     {
1872         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1873         return false;
1874     }
1875 
1876     return ValidateProgramUniform3ivBase(context, programPacked, locationPacked, count, value);
1877 }
1878 
ValidateProgramUniform3uiEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0,GLuint v1,GLuint v2)1879 bool ValidateProgramUniform3uiEXT(const Context *context,
1880                                   ShaderProgramID programPacked,
1881                                   UniformLocation locationPacked,
1882                                   GLuint v0,
1883                                   GLuint v1,
1884                                   GLuint v2)
1885 {
1886     if (!context->getExtensions().separateShaderObjects)
1887     {
1888         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1889         return false;
1890     }
1891 
1892     return ValidateProgramUniform3uiBase(context, programPacked, locationPacked, v0, v1, v2);
1893 }
1894 
ValidateProgramUniform3uivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)1895 bool ValidateProgramUniform3uivEXT(const Context *context,
1896                                    ShaderProgramID programPacked,
1897                                    UniformLocation locationPacked,
1898                                    GLsizei count,
1899                                    const GLuint *value)
1900 {
1901     if (!context->getExtensions().separateShaderObjects)
1902     {
1903         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1904         return false;
1905     }
1906 
1907     return ValidateProgramUniform3uivBase(context, programPacked, locationPacked, count, value);
1908 }
1909 
ValidateProgramUniform4fEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLfloat v0,GLfloat v1,GLfloat v2,GLfloat v3)1910 bool ValidateProgramUniform4fEXT(const Context *context,
1911                                  ShaderProgramID programPacked,
1912                                  UniformLocation locationPacked,
1913                                  GLfloat v0,
1914                                  GLfloat v1,
1915                                  GLfloat v2,
1916                                  GLfloat v3)
1917 {
1918     if (!context->getExtensions().separateShaderObjects)
1919     {
1920         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1921         return false;
1922     }
1923 
1924     return ValidateProgramUniform4fBase(context, programPacked, locationPacked, v0, v1, v2, v3);
1925 }
1926 
ValidateProgramUniform4fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLfloat * value)1927 bool ValidateProgramUniform4fvEXT(const Context *context,
1928                                   ShaderProgramID programPacked,
1929                                   UniformLocation locationPacked,
1930                                   GLsizei count,
1931                                   const GLfloat *value)
1932 {
1933     if (!context->getExtensions().separateShaderObjects)
1934     {
1935         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1936         return false;
1937     }
1938 
1939     return ValidateProgramUniform4fvBase(context, programPacked, locationPacked, count, value);
1940 }
1941 
ValidateProgramUniform4iEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLint v0,GLint v1,GLint v2,GLint v3)1942 bool ValidateProgramUniform4iEXT(const Context *context,
1943                                  ShaderProgramID programPacked,
1944                                  UniformLocation locationPacked,
1945                                  GLint v0,
1946                                  GLint v1,
1947                                  GLint v2,
1948                                  GLint v3)
1949 {
1950     if (!context->getExtensions().separateShaderObjects)
1951     {
1952         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1953         return false;
1954     }
1955 
1956     return ValidateProgramUniform4iBase(context, programPacked, locationPacked, v0, v1, v2, v3);
1957 }
1958 
ValidateProgramUniform4ivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLint * value)1959 bool ValidateProgramUniform4ivEXT(const Context *context,
1960                                   ShaderProgramID programPacked,
1961                                   UniformLocation locationPacked,
1962                                   GLsizei count,
1963                                   const GLint *value)
1964 {
1965     return ValidateProgramUniform4ivBase(context, programPacked, locationPacked, count, value);
1966 }
1967 
ValidateProgramUniform4uiEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLuint v0,GLuint v1,GLuint v2,GLuint v3)1968 bool ValidateProgramUniform4uiEXT(const Context *context,
1969                                   ShaderProgramID programPacked,
1970                                   UniformLocation locationPacked,
1971                                   GLuint v0,
1972                                   GLuint v1,
1973                                   GLuint v2,
1974                                   GLuint v3)
1975 {
1976     if (!context->getExtensions().separateShaderObjects)
1977     {
1978         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
1979         return false;
1980     }
1981 
1982     return ValidateProgramUniform4uiBase(context, programPacked, locationPacked, v0, v1, v2, v3);
1983 }
1984 
ValidateProgramUniform4uivEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,const GLuint * value)1985 bool ValidateProgramUniform4uivEXT(const Context *context,
1986                                    ShaderProgramID programPacked,
1987                                    UniformLocation locationPacked,
1988                                    GLsizei count,
1989                                    const GLuint *value)
1990 {
1991     return ValidateProgramUniform4uivBase(context, programPacked, locationPacked, count, value);
1992 }
1993 
ValidateProgramUniformMatrix2fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)1994 bool ValidateProgramUniformMatrix2fvEXT(const Context *context,
1995                                         ShaderProgramID programPacked,
1996                                         UniformLocation locationPacked,
1997                                         GLsizei count,
1998                                         GLboolean transpose,
1999                                         const GLfloat *value)
2000 {
2001     if (!context->getExtensions().separateShaderObjects)
2002     {
2003         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2004         return false;
2005     }
2006 
2007     return ValidateProgramUniformMatrix2fvBase(context, programPacked, locationPacked, count,
2008                                                transpose, value);
2009 }
2010 
ValidateProgramUniformMatrix2x3fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2011 bool ValidateProgramUniformMatrix2x3fvEXT(const Context *context,
2012                                           ShaderProgramID programPacked,
2013                                           UniformLocation locationPacked,
2014                                           GLsizei count,
2015                                           GLboolean transpose,
2016                                           const GLfloat *value)
2017 {
2018     if (!context->getExtensions().separateShaderObjects)
2019     {
2020         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2021         return false;
2022     }
2023 
2024     return ValidateProgramUniformMatrix2x3fvBase(context, programPacked, locationPacked, count,
2025                                                  transpose, value);
2026 }
2027 
ValidateProgramUniformMatrix2x4fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2028 bool ValidateProgramUniformMatrix2x4fvEXT(const Context *context,
2029                                           ShaderProgramID programPacked,
2030                                           UniformLocation locationPacked,
2031                                           GLsizei count,
2032                                           GLboolean transpose,
2033                                           const GLfloat *value)
2034 {
2035     if (!context->getExtensions().separateShaderObjects)
2036     {
2037         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2038         return false;
2039     }
2040 
2041     return ValidateProgramUniformMatrix2x4fvBase(context, programPacked, locationPacked, count,
2042                                                  transpose, value);
2043 }
2044 
ValidateProgramUniformMatrix3fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2045 bool ValidateProgramUniformMatrix3fvEXT(const Context *context,
2046                                         ShaderProgramID programPacked,
2047                                         UniformLocation locationPacked,
2048                                         GLsizei count,
2049                                         GLboolean transpose,
2050                                         const GLfloat *value)
2051 {
2052     if (!context->getExtensions().separateShaderObjects)
2053     {
2054         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2055         return false;
2056     }
2057 
2058     return ValidateProgramUniformMatrix3fvBase(context, programPacked, locationPacked, count,
2059                                                transpose, value);
2060 }
2061 
ValidateProgramUniformMatrix3x2fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2062 bool ValidateProgramUniformMatrix3x2fvEXT(const Context *context,
2063                                           ShaderProgramID programPacked,
2064                                           UniformLocation locationPacked,
2065                                           GLsizei count,
2066                                           GLboolean transpose,
2067                                           const GLfloat *value)
2068 {
2069     if (!context->getExtensions().separateShaderObjects)
2070     {
2071         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2072         return false;
2073     }
2074 
2075     return ValidateProgramUniformMatrix3x2fvBase(context, programPacked, locationPacked, count,
2076                                                  transpose, value);
2077 }
2078 
ValidateProgramUniformMatrix3x4fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2079 bool ValidateProgramUniformMatrix3x4fvEXT(const Context *context,
2080                                           ShaderProgramID programPacked,
2081                                           UniformLocation locationPacked,
2082                                           GLsizei count,
2083                                           GLboolean transpose,
2084                                           const GLfloat *value)
2085 {
2086     if (!context->getExtensions().separateShaderObjects)
2087     {
2088         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2089         return false;
2090     }
2091 
2092     return ValidateProgramUniformMatrix3x4fvBase(context, programPacked, locationPacked, count,
2093                                                  transpose, value);
2094 }
2095 
ValidateProgramUniformMatrix4fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2096 bool ValidateProgramUniformMatrix4fvEXT(const Context *context,
2097                                         ShaderProgramID programPacked,
2098                                         UniformLocation locationPacked,
2099                                         GLsizei count,
2100                                         GLboolean transpose,
2101                                         const GLfloat *value)
2102 {
2103     if (!context->getExtensions().separateShaderObjects)
2104     {
2105         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2106         return false;
2107     }
2108 
2109     return ValidateProgramUniformMatrix4fvBase(context, programPacked, locationPacked, count,
2110                                                transpose, value);
2111 }
2112 
ValidateProgramUniformMatrix4x2fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2113 bool ValidateProgramUniformMatrix4x2fvEXT(const Context *context,
2114                                           ShaderProgramID programPacked,
2115                                           UniformLocation locationPacked,
2116                                           GLsizei count,
2117                                           GLboolean transpose,
2118                                           const GLfloat *value)
2119 {
2120     if (!context->getExtensions().separateShaderObjects)
2121     {
2122         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2123         return false;
2124     }
2125 
2126     return ValidateProgramUniformMatrix4x2fvBase(context, programPacked, locationPacked, count,
2127                                                  transpose, value);
2128 }
2129 
ValidateProgramUniformMatrix4x3fvEXT(const Context * context,ShaderProgramID programPacked,UniformLocation locationPacked,GLsizei count,GLboolean transpose,const GLfloat * value)2130 bool ValidateProgramUniformMatrix4x3fvEXT(const Context *context,
2131                                           ShaderProgramID programPacked,
2132                                           UniformLocation locationPacked,
2133                                           GLsizei count,
2134                                           GLboolean transpose,
2135                                           const GLfloat *value)
2136 {
2137     if (!context->getExtensions().separateShaderObjects)
2138     {
2139         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2140         return false;
2141     }
2142 
2143     return ValidateProgramUniformMatrix4x3fvBase(context, programPacked, locationPacked, count,
2144                                                  transpose, value);
2145 }
2146 
ValidateUseProgramStagesEXT(const Context * context,ProgramPipelineID pipelinePacked,GLbitfield stages,ShaderProgramID programPacked)2147 bool ValidateUseProgramStagesEXT(const Context *context,
2148                                  ProgramPipelineID pipelinePacked,
2149                                  GLbitfield stages,
2150                                  ShaderProgramID programPacked)
2151 {
2152     if (!context->getExtensions().separateShaderObjects)
2153     {
2154         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2155         return false;
2156     }
2157 
2158     return ValidateUseProgramStagesBase(context, pipelinePacked, stages, programPacked);
2159 }
2160 
ValidateValidateProgramPipelineEXT(const Context * context,ProgramPipelineID pipelinePacked)2161 bool ValidateValidateProgramPipelineEXT(const Context *context, ProgramPipelineID pipelinePacked)
2162 {
2163     if (!context->getExtensions().separateShaderObjects)
2164     {
2165         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2166         return false;
2167     }
2168 
2169     return ValidateValidateProgramPipelineBase(context, pipelinePacked);
2170 }
2171 
2172 // GL_EXT_debug_label
ValidateGetObjectLabelEXT(const Context * context,GLenum type,GLuint object,GLsizei bufSize,const GLsizei * length,const GLchar * label)2173 bool ValidateGetObjectLabelEXT(const Context *context,
2174                                GLenum type,
2175                                GLuint object,
2176                                GLsizei bufSize,
2177                                const GLsizei *length,
2178                                const GLchar *label)
2179 {
2180     if (!context->getExtensions().debugLabel)
2181     {
2182         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2183         return false;
2184     }
2185 
2186     if (bufSize < 0)
2187     {
2188         context->validationError(GL_INVALID_VALUE, kNegativeBufferSize);
2189         return false;
2190     }
2191 
2192     return ValidateObjectIdentifierAndName(context, type, object);
2193 }
2194 
ValidateLabelObjectEXT(const Context * context,GLenum type,GLuint object,GLsizei length,const GLchar * label)2195 bool ValidateLabelObjectEXT(const Context *context,
2196                             GLenum type,
2197                             GLuint object,
2198                             GLsizei length,
2199                             const GLchar *label)
2200 {
2201     if (!context->getExtensions().debugLabel)
2202     {
2203         context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
2204         return false;
2205     }
2206 
2207     if (length < 0)
2208     {
2209         context->validationError(GL_INVALID_VALUE, kNegativeLength);
2210         return false;
2211     }
2212 
2213     return ValidateObjectIdentifierAndName(context, type, object);
2214 }
2215 }  // namespace gl
2216