• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // validationES1.cpp: Validation functions for OpenGL ES 1.0 entry point parameters
8 
9 #include "libANGLE/validationES1_autogen.h"
10 
11 #include "common/debug.h"
12 #include "libANGLE/Context.h"
13 #include "libANGLE/ErrorStrings.h"
14 #include "libANGLE/GLES1State.h"
15 #include "libANGLE/queryconversions.h"
16 #include "libANGLE/queryutils.h"
17 #include "libANGLE/validationES.h"
18 
19 #define ANGLE_VALIDATE_IS_GLES1(context)                                                        \
20     do                                                                                          \
21     {                                                                                           \
22         if (context->getClientType() != EGL_OPENGL_API && context->getClientMajorVersion() > 1) \
23         {                                                                                       \
24             context->validationError(GL_INVALID_OPERATION, kGLES1Only);                         \
25             return false;                                                                       \
26         }                                                                                       \
27     } while (0)
28 
29 namespace gl
30 {
31 using namespace err;
32 
ValidateAlphaFuncCommon(const Context * context,AlphaTestFunc func)33 bool ValidateAlphaFuncCommon(const Context *context, AlphaTestFunc func)
34 {
35     switch (func)
36     {
37         case AlphaTestFunc::AlwaysPass:
38         case AlphaTestFunc::Equal:
39         case AlphaTestFunc::Gequal:
40         case AlphaTestFunc::Greater:
41         case AlphaTestFunc::Lequal:
42         case AlphaTestFunc::Less:
43         case AlphaTestFunc::Never:
44         case AlphaTestFunc::NotEqual:
45             return true;
46         default:
47             context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
48             return false;
49     }
50 }
51 
ValidateClientStateCommon(const Context * context,ClientVertexArrayType arrayType)52 bool ValidateClientStateCommon(const Context *context, ClientVertexArrayType arrayType)
53 {
54     ANGLE_VALIDATE_IS_GLES1(context);
55     switch (arrayType)
56     {
57         case ClientVertexArrayType::Vertex:
58         case ClientVertexArrayType::Normal:
59         case ClientVertexArrayType::Color:
60         case ClientVertexArrayType::TextureCoord:
61             return true;
62         case ClientVertexArrayType::PointSize:
63             if (!context->getExtensions().pointSizeArrayOES)
64             {
65                 context->validationError(GL_INVALID_ENUM, kPointSizeArrayExtensionNotEnabled);
66                 return false;
67             }
68             return true;
69         default:
70             context->validationError(GL_INVALID_ENUM, kInvalidClientState);
71             return false;
72     }
73 }
74 
ValidateBuiltinVertexAttributeCommon(const Context * context,ClientVertexArrayType arrayType,GLint size,VertexAttribType type,GLsizei stride,const void * pointer)75 bool ValidateBuiltinVertexAttributeCommon(const Context *context,
76                                           ClientVertexArrayType arrayType,
77                                           GLint size,
78                                           VertexAttribType type,
79                                           GLsizei stride,
80                                           const void *pointer)
81 {
82     ANGLE_VALIDATE_IS_GLES1(context);
83 
84     if (stride < 0)
85     {
86         context->validationError(GL_INVALID_VALUE, kInvalidVertexPointerStride);
87         return false;
88     }
89 
90     int minSize = 1;
91     int maxSize = 4;
92 
93     switch (arrayType)
94     {
95         case ClientVertexArrayType::Vertex:
96         case ClientVertexArrayType::TextureCoord:
97             minSize = 2;
98             maxSize = 4;
99             break;
100         case ClientVertexArrayType::Normal:
101             minSize = 3;
102             maxSize = 3;
103             break;
104         case ClientVertexArrayType::Color:
105             minSize = 4;
106             maxSize = 4;
107             break;
108         case ClientVertexArrayType::PointSize:
109             if (!context->getExtensions().pointSizeArrayOES)
110             {
111                 context->validationError(GL_INVALID_ENUM, kPointSizeArrayExtensionNotEnabled);
112                 return false;
113             }
114 
115             minSize = 1;
116             maxSize = 1;
117             break;
118         default:
119             UNREACHABLE();
120             return false;
121     }
122 
123     if (size < minSize || size > maxSize)
124     {
125         context->validationError(GL_INVALID_VALUE, kInvalidVertexPointerSize);
126         return false;
127     }
128 
129     switch (type)
130     {
131         case VertexAttribType::Byte:
132             if (arrayType == ClientVertexArrayType::PointSize)
133             {
134                 context->validationError(GL_INVALID_ENUM, kInvalidVertexPointerType);
135                 return false;
136             }
137             break;
138         case VertexAttribType::Short:
139             if (arrayType == ClientVertexArrayType::PointSize ||
140                 arrayType == ClientVertexArrayType::Color)
141             {
142                 context->validationError(GL_INVALID_ENUM, kInvalidVertexPointerType);
143                 return false;
144             }
145             break;
146         case VertexAttribType::Fixed:
147         case VertexAttribType::Float:
148             break;
149         default:
150             context->validationError(GL_INVALID_ENUM, kInvalidVertexPointerType);
151             return false;
152     }
153 
154     return true;
155 }
156 
ValidateLightCaps(const Context * context,GLenum light)157 bool ValidateLightCaps(const Context *context, GLenum light)
158 {
159     if (light < GL_LIGHT0 || light >= GL_LIGHT0 + context->getCaps().maxLights)
160     {
161         context->validationError(GL_INVALID_ENUM, kInvalidLight);
162         return false;
163     }
164 
165     return true;
166 }
167 
ValidateLightCommon(const Context * context,GLenum light,LightParameter pname,const GLfloat * params)168 bool ValidateLightCommon(const Context *context,
169                          GLenum light,
170                          LightParameter pname,
171                          const GLfloat *params)
172 {
173 
174     ANGLE_VALIDATE_IS_GLES1(context);
175 
176     if (!ValidateLightCaps(context, light))
177     {
178         return false;
179     }
180 
181     switch (pname)
182     {
183         case LightParameter::Ambient:
184         case LightParameter::Diffuse:
185         case LightParameter::Specular:
186         case LightParameter::Position:
187         case LightParameter::SpotDirection:
188             return true;
189         case LightParameter::SpotExponent:
190             if (params[0] < 0.0f || params[0] > 128.0f)
191             {
192                 context->validationError(GL_INVALID_VALUE, kLightParameterOutOfRange);
193                 return false;
194             }
195             return true;
196         case LightParameter::SpotCutoff:
197             if (params[0] == 180.0f)
198             {
199                 return true;
200             }
201             if (params[0] < 0.0f || params[0] > 90.0f)
202             {
203                 context->validationError(GL_INVALID_VALUE, kLightParameterOutOfRange);
204                 return false;
205             }
206             return true;
207         case LightParameter::ConstantAttenuation:
208         case LightParameter::LinearAttenuation:
209         case LightParameter::QuadraticAttenuation:
210             if (params[0] < 0.0f)
211             {
212                 context->validationError(GL_INVALID_VALUE, kLightParameterOutOfRange);
213                 return false;
214             }
215             return true;
216         default:
217             context->validationError(GL_INVALID_ENUM, kInvalidLightParameter);
218             return false;
219     }
220 }
221 
ValidateLightSingleComponent(const Context * context,GLenum light,LightParameter pname,GLfloat param)222 bool ValidateLightSingleComponent(const Context *context,
223                                   GLenum light,
224                                   LightParameter pname,
225                                   GLfloat param)
226 {
227     if (!ValidateLightCommon(context, light, pname, &param))
228     {
229         return false;
230     }
231 
232     if (GetLightParameterCount(pname) > 1)
233     {
234         context->validationError(GL_INVALID_ENUM, kInvalidLightParameter);
235         return false;
236     }
237 
238     return true;
239 }
240 
ValidateMaterialCommon(const Context * context,GLenum face,MaterialParameter pname,const GLfloat * params)241 bool ValidateMaterialCommon(const Context *context,
242                             GLenum face,
243                             MaterialParameter pname,
244                             const GLfloat *params)
245 {
246     switch (pname)
247     {
248         case MaterialParameter::Ambient:
249         case MaterialParameter::AmbientAndDiffuse:
250         case MaterialParameter::Diffuse:
251         case MaterialParameter::Specular:
252         case MaterialParameter::Emission:
253             return true;
254         case MaterialParameter::Shininess:
255             if (params[0] < 0.0f || params[0] > 128.0f)
256             {
257                 context->validationError(GL_INVALID_VALUE, kMaterialParameterOutOfRange);
258                 return false;
259             }
260             return true;
261         default:
262             context->validationError(GL_INVALID_ENUM, kInvalidMaterialParameter);
263             return false;
264     }
265 }
266 
ValidateMaterialSetting(const Context * context,GLenum face,MaterialParameter pname,const GLfloat * params)267 bool ValidateMaterialSetting(const Context *context,
268                              GLenum face,
269                              MaterialParameter pname,
270                              const GLfloat *params)
271 {
272     ANGLE_VALIDATE_IS_GLES1(context);
273 
274     if (face != GL_FRONT_AND_BACK)
275     {
276         context->validationError(GL_INVALID_ENUM, kInvalidMaterialFace);
277         return false;
278     }
279 
280     return ValidateMaterialCommon(context, face, pname, params);
281 }
282 
ValidateMaterialQuery(const Context * context,GLenum face,MaterialParameter pname)283 bool ValidateMaterialQuery(const Context *context, GLenum face, MaterialParameter pname)
284 {
285     ANGLE_VALIDATE_IS_GLES1(context);
286 
287     if (face != GL_FRONT && face != GL_BACK)
288     {
289         context->validationError(GL_INVALID_ENUM, kInvalidMaterialFace);
290         return false;
291     }
292 
293     GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
294 
295     return ValidateMaterialCommon(context, face, pname, dummyParams);
296 }
297 
ValidateMaterialSingleComponent(const Context * context,GLenum face,MaterialParameter pname,GLfloat param)298 bool ValidateMaterialSingleComponent(const Context *context,
299                                      GLenum face,
300                                      MaterialParameter pname,
301                                      GLfloat param)
302 {
303     if (!ValidateMaterialSetting(context, face, pname, &param))
304     {
305         return false;
306     }
307 
308     if (GetMaterialParameterCount(pname) > 1)
309     {
310         context->validationError(GL_INVALID_ENUM, kInvalidMaterialParameter);
311         return false;
312     }
313 
314     return true;
315 }
316 
ValidateLightModelCommon(const Context * context,GLenum pname)317 bool ValidateLightModelCommon(const Context *context, GLenum pname)
318 {
319     ANGLE_VALIDATE_IS_GLES1(context);
320     switch (pname)
321     {
322         case GL_LIGHT_MODEL_AMBIENT:
323         case GL_LIGHT_MODEL_TWO_SIDE:
324             return true;
325         default:
326             context->validationError(GL_INVALID_ENUM, kInvalidLightModelParameter);
327             return false;
328     }
329 }
330 
ValidateLightModelSingleComponent(const Context * context,GLenum pname)331 bool ValidateLightModelSingleComponent(const Context *context, GLenum pname)
332 {
333     if (!ValidateLightModelCommon(context, pname))
334     {
335         return false;
336     }
337 
338     switch (pname)
339     {
340         case GL_LIGHT_MODEL_TWO_SIDE:
341             return true;
342         default:
343             context->validationError(GL_INVALID_ENUM, kInvalidLightModelParameter);
344             return false;
345     }
346 }
347 
ValidateClipPlaneCommon(const Context * context,GLenum plane)348 bool ValidateClipPlaneCommon(const Context *context, GLenum plane)
349 {
350     ANGLE_VALIDATE_IS_GLES1(context);
351 
352     if (plane < GL_CLIP_PLANE0 || plane >= GL_CLIP_PLANE0 + context->getCaps().maxClipPlanes)
353     {
354         context->validationError(GL_INVALID_ENUM, kInvalidClipPlane);
355         return false;
356     }
357 
358     return true;
359 }
360 
ValidateFogCommon(const Context * context,GLenum pname,const GLfloat * params)361 bool ValidateFogCommon(const Context *context, GLenum pname, const GLfloat *params)
362 {
363     ANGLE_VALIDATE_IS_GLES1(context);
364 
365     switch (pname)
366     {
367         case GL_FOG_MODE:
368         {
369             GLenum modeParam = static_cast<GLenum>(params[0]);
370             switch (modeParam)
371             {
372                 case GL_EXP:
373                 case GL_EXP2:
374                 case GL_LINEAR:
375                     return true;
376                 default:
377                     context->validationError(GL_INVALID_VALUE, kInvalidFogMode);
378                     return false;
379             }
380         }
381         break;
382         case GL_FOG_START:
383         case GL_FOG_END:
384         case GL_FOG_COLOR:
385             break;
386         case GL_FOG_DENSITY:
387             if (params[0] < 0.0f)
388             {
389                 context->validationError(GL_INVALID_VALUE, kInvalidFogDensity);
390                 return false;
391             }
392             break;
393         default:
394             context->validationError(GL_INVALID_ENUM, kInvalidFogParameter);
395             return false;
396     }
397     return true;
398 }
399 
ValidateTexEnvCommon(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,const GLfloat * params)400 bool ValidateTexEnvCommon(const Context *context,
401                           TextureEnvTarget target,
402                           TextureEnvParameter pname,
403                           const GLfloat *params)
404 {
405     ANGLE_VALIDATE_IS_GLES1(context);
406 
407     switch (target)
408     {
409         case TextureEnvTarget::Env:
410             switch (pname)
411             {
412                 case TextureEnvParameter::Mode:
413                 {
414                     TextureEnvMode mode = FromGLenum<TextureEnvMode>(ConvertToGLenum(params[0]));
415                     switch (mode)
416                     {
417                         case TextureEnvMode::Add:
418                         case TextureEnvMode::Blend:
419                         case TextureEnvMode::Combine:
420                         case TextureEnvMode::Decal:
421                         case TextureEnvMode::Modulate:
422                         case TextureEnvMode::Replace:
423                             break;
424                         default:
425                             context->validationError(GL_INVALID_VALUE, kInvalidTextureEnvMode);
426                             return false;
427                     }
428                     break;
429                 }
430                 case TextureEnvParameter::CombineRgb:
431                 case TextureEnvParameter::CombineAlpha:
432                 {
433                     TextureCombine combine = FromGLenum<TextureCombine>(ConvertToGLenum(params[0]));
434                     switch (combine)
435                     {
436                         case TextureCombine::Add:
437                         case TextureCombine::AddSigned:
438                         case TextureCombine::Interpolate:
439                         case TextureCombine::Modulate:
440                         case TextureCombine::Replace:
441                         case TextureCombine::Subtract:
442                             break;
443                         case TextureCombine::Dot3Rgb:
444                         case TextureCombine::Dot3Rgba:
445                             if (pname == TextureEnvParameter::CombineAlpha)
446                             {
447                                 context->validationError(GL_INVALID_VALUE, kInvalidTextureCombine);
448                                 return false;
449                             }
450                             break;
451                         default:
452                             context->validationError(GL_INVALID_VALUE, kInvalidTextureCombine);
453                             return false;
454                     }
455                     break;
456                 }
457                 case TextureEnvParameter::Src0Rgb:
458                 case TextureEnvParameter::Src1Rgb:
459                 case TextureEnvParameter::Src2Rgb:
460                 case TextureEnvParameter::Src0Alpha:
461                 case TextureEnvParameter::Src1Alpha:
462                 case TextureEnvParameter::Src2Alpha:
463                 {
464                     TextureSrc combine = FromGLenum<TextureSrc>(ConvertToGLenum(params[0]));
465                     switch (combine)
466                     {
467                         case TextureSrc::Constant:
468                         case TextureSrc::Previous:
469                         case TextureSrc::PrimaryColor:
470                         case TextureSrc::Texture:
471                             break;
472                         default:
473                             context->validationError(GL_INVALID_VALUE, kInvalidTextureCombineSrc);
474                             return false;
475                     }
476                     break;
477                 }
478                 case TextureEnvParameter::Op0Rgb:
479                 case TextureEnvParameter::Op1Rgb:
480                 case TextureEnvParameter::Op2Rgb:
481                 case TextureEnvParameter::Op0Alpha:
482                 case TextureEnvParameter::Op1Alpha:
483                 case TextureEnvParameter::Op2Alpha:
484                 {
485                     TextureOp operand = FromGLenum<TextureOp>(ConvertToGLenum(params[0]));
486                     switch (operand)
487                     {
488                         case TextureOp::SrcAlpha:
489                         case TextureOp::OneMinusSrcAlpha:
490                             break;
491                         case TextureOp::SrcColor:
492                         case TextureOp::OneMinusSrcColor:
493                             if (pname == TextureEnvParameter::Op0Alpha ||
494                                 pname == TextureEnvParameter::Op1Alpha ||
495                                 pname == TextureEnvParameter::Op2Alpha)
496                             {
497                                 context->validationError(GL_INVALID_VALUE, kInvalidTextureCombine);
498                                 return false;
499                             }
500                             break;
501                         default:
502                             context->validationError(GL_INVALID_VALUE, kInvalidTextureCombineOp);
503                             return false;
504                     }
505                     break;
506                 }
507                 case TextureEnvParameter::RgbScale:
508                 case TextureEnvParameter::AlphaScale:
509                     if (params[0] != 1.0f && params[0] != 2.0f && params[0] != 4.0f)
510                     {
511                         context->validationError(GL_INVALID_VALUE, kInvalidTextureEnvScale);
512                         return false;
513                     }
514                     break;
515                 case TextureEnvParameter::Color:
516                     break;
517                 default:
518                     context->validationError(GL_INVALID_ENUM, kInvalidTextureEnvParameter);
519                     return false;
520             }
521             break;
522         case TextureEnvTarget::PointSprite:
523             if (!context->getExtensions().pointSpriteOES)
524             {
525                 context->validationError(GL_INVALID_ENUM, kInvalidTextureEnvTarget);
526                 return false;
527             }
528             switch (pname)
529             {
530                 case TextureEnvParameter::PointCoordReplace:
531                     break;
532                 default:
533                     context->validationError(GL_INVALID_ENUM, kInvalidTextureEnvParameter);
534                     return false;
535             }
536             break;
537         default:
538             context->validationError(GL_INVALID_ENUM, kInvalidTextureEnvTarget);
539             return false;
540     }
541     return true;
542 }
543 
ValidateGetTexEnvCommon(const Context * context,TextureEnvTarget target,TextureEnvParameter pname)544 bool ValidateGetTexEnvCommon(const Context *context,
545                              TextureEnvTarget target,
546                              TextureEnvParameter pname)
547 {
548     GLfloat dummy[4] = {};
549     switch (pname)
550     {
551         case TextureEnvParameter::Mode:
552             ConvertPackedEnum(TextureEnvMode::Add, dummy);
553             break;
554         case TextureEnvParameter::CombineRgb:
555         case TextureEnvParameter::CombineAlpha:
556             ConvertPackedEnum(TextureCombine::Add, dummy);
557             break;
558         case TextureEnvParameter::Src0Rgb:
559         case TextureEnvParameter::Src1Rgb:
560         case TextureEnvParameter::Src2Rgb:
561         case TextureEnvParameter::Src0Alpha:
562         case TextureEnvParameter::Src1Alpha:
563         case TextureEnvParameter::Src2Alpha:
564             ConvertPackedEnum(TextureSrc::Constant, dummy);
565             break;
566         case TextureEnvParameter::Op0Rgb:
567         case TextureEnvParameter::Op1Rgb:
568         case TextureEnvParameter::Op2Rgb:
569         case TextureEnvParameter::Op0Alpha:
570         case TextureEnvParameter::Op1Alpha:
571         case TextureEnvParameter::Op2Alpha:
572             ConvertPackedEnum(TextureOp::SrcAlpha, dummy);
573             break;
574         case TextureEnvParameter::RgbScale:
575         case TextureEnvParameter::AlphaScale:
576         case TextureEnvParameter::PointCoordReplace:
577             dummy[0] = 1.0f;
578             break;
579         default:
580             break;
581     }
582 
583     return ValidateTexEnvCommon(context, target, pname, dummy);
584 }
585 
ValidatePointParameterCommon(const Context * context,PointParameter pname,const GLfloat * params)586 bool ValidatePointParameterCommon(const Context *context,
587                                   PointParameter pname,
588                                   const GLfloat *params)
589 {
590     ANGLE_VALIDATE_IS_GLES1(context);
591 
592     switch (pname)
593     {
594         case PointParameter::PointSizeMin:
595         case PointParameter::PointSizeMax:
596         case PointParameter::PointFadeThresholdSize:
597         case PointParameter::PointDistanceAttenuation:
598             for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
599             {
600                 if (params[i] < 0.0f)
601                 {
602                     context->validationError(GL_INVALID_VALUE, kInvalidPointParameterValue);
603                     return false;
604                 }
605             }
606             break;
607         default:
608             context->validationError(GL_INVALID_ENUM, kInvalidPointParameter);
609             return false;
610     }
611 
612     return true;
613 }
614 
ValidatePointSizeCommon(const Context * context,GLfloat size)615 bool ValidatePointSizeCommon(const Context *context, GLfloat size)
616 {
617     ANGLE_VALIDATE_IS_GLES1(context);
618 
619     if (size <= 0.0f)
620     {
621         context->validationError(GL_INVALID_VALUE, kInvalidPointSizeValue);
622         return false;
623     }
624 
625     return true;
626 }
627 
ValidateDrawTexCommon(const Context * context,float width,float height)628 bool ValidateDrawTexCommon(const Context *context, float width, float height)
629 {
630     ANGLE_VALIDATE_IS_GLES1(context);
631 
632     if (width <= 0.0f || height <= 0.0f)
633     {
634         context->validationError(GL_INVALID_VALUE, kNonPositiveDrawTextureDimension);
635         return false;
636     }
637 
638     return true;
639 }
640 
641 }  // namespace gl
642 
643 namespace gl
644 {
645 
ValidateAlphaFunc(const Context * context,AlphaTestFunc func,GLfloat ref)646 bool ValidateAlphaFunc(const Context *context, AlphaTestFunc func, GLfloat ref)
647 {
648     ANGLE_VALIDATE_IS_GLES1(context);
649     return ValidateAlphaFuncCommon(context, func);
650 }
651 
ValidateAlphaFuncx(const Context * context,AlphaTestFunc func,GLfixed ref)652 bool ValidateAlphaFuncx(const Context *context, AlphaTestFunc func, GLfixed ref)
653 {
654     ANGLE_VALIDATE_IS_GLES1(context);
655     return ValidateAlphaFuncCommon(context, func);
656 }
657 
ValidateClearColorx(const Context * context,GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)658 bool ValidateClearColorx(const Context *context,
659                          GLfixed red,
660                          GLfixed green,
661                          GLfixed blue,
662                          GLfixed alpha)
663 {
664     ANGLE_VALIDATE_IS_GLES1(context);
665     return true;
666 }
667 
ValidateClearDepthx(const Context * context,GLfixed depth)668 bool ValidateClearDepthx(const Context *context, GLfixed depth)
669 {
670     ANGLE_VALIDATE_IS_GLES1(context);
671     return true;
672 }
673 
ValidateClientActiveTexture(const Context * context,GLenum texture)674 bool ValidateClientActiveTexture(const Context *context, GLenum texture)
675 {
676     ANGLE_VALIDATE_IS_GLES1(context);
677     return ValidateMultitextureUnit(context, texture);
678 }
679 
ValidateClipPlanef(const Context * context,GLenum plane,const GLfloat * eqn)680 bool ValidateClipPlanef(const Context *context, GLenum plane, const GLfloat *eqn)
681 {
682     return ValidateClipPlaneCommon(context, plane);
683 }
684 
ValidateClipPlanex(const Context * context,GLenum plane,const GLfixed * equation)685 bool ValidateClipPlanex(const Context *context, GLenum plane, const GLfixed *equation)
686 {
687     return ValidateClipPlaneCommon(context, plane);
688 }
689 
ValidateColor4f(const Context * context,GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)690 bool ValidateColor4f(const Context *context,
691                      GLfloat red,
692                      GLfloat green,
693                      GLfloat blue,
694                      GLfloat alpha)
695 {
696     ANGLE_VALIDATE_IS_GLES1(context);
697     return true;
698 }
699 
ValidateColor4ub(const Context * context,GLubyte red,GLubyte green,GLubyte blue,GLubyte alpha)700 bool ValidateColor4ub(const Context *context,
701                       GLubyte red,
702                       GLubyte green,
703                       GLubyte blue,
704                       GLubyte alpha)
705 {
706     ANGLE_VALIDATE_IS_GLES1(context);
707     return true;
708 }
709 
ValidateColor4x(const Context * context,GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)710 bool ValidateColor4x(const Context *context,
711                      GLfixed red,
712                      GLfixed green,
713                      GLfixed blue,
714                      GLfixed alpha)
715 {
716     ANGLE_VALIDATE_IS_GLES1(context);
717     return true;
718 }
719 
ValidateColorPointer(const Context * context,GLint size,VertexAttribType type,GLsizei stride,const void * pointer)720 bool ValidateColorPointer(const Context *context,
721                           GLint size,
722                           VertexAttribType type,
723                           GLsizei stride,
724                           const void *pointer)
725 {
726     return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Color, size, type,
727                                                 stride, pointer);
728 }
729 
ValidateCullFace(const Context * context,GLenum mode)730 bool ValidateCullFace(const Context *context, GLenum mode)
731 {
732     UNIMPLEMENTED();
733     return true;
734 }
735 
ValidateDepthRangex(const Context * context,GLfixed n,GLfixed f)736 bool ValidateDepthRangex(const Context *context, GLfixed n, GLfixed f)
737 {
738     ANGLE_VALIDATE_IS_GLES1(context);
739     if (context->getExtensions().webglCompatibility && n > f)
740     {
741         context->validationError(GL_INVALID_OPERATION, kInvalidDepthRange);
742         return false;
743     }
744 
745     return true;
746 }
747 
ValidateDisableClientState(const Context * context,ClientVertexArrayType arrayType)748 bool ValidateDisableClientState(const Context *context, ClientVertexArrayType arrayType)
749 {
750     return ValidateClientStateCommon(context, arrayType);
751 }
752 
ValidateEnableClientState(const Context * context,ClientVertexArrayType arrayType)753 bool ValidateEnableClientState(const Context *context, ClientVertexArrayType arrayType)
754 {
755     return ValidateClientStateCommon(context, arrayType);
756 }
757 
ValidateFogf(const Context * context,GLenum pname,GLfloat param)758 bool ValidateFogf(const Context *context, GLenum pname, GLfloat param)
759 {
760     return ValidateFogCommon(context, pname, &param);
761 }
762 
ValidateFogfv(const Context * context,GLenum pname,const GLfloat * params)763 bool ValidateFogfv(const Context *context, GLenum pname, const GLfloat *params)
764 {
765     return ValidateFogCommon(context, pname, params);
766 }
767 
ValidateFogx(const Context * context,GLenum pname,GLfixed param)768 bool ValidateFogx(const Context *context, GLenum pname, GLfixed param)
769 {
770     ANGLE_VALIDATE_IS_GLES1(context);
771     GLfloat asFloat =
772         pname == GL_FOG_MODE ? static_cast<GLfloat>(param) : ConvertFixedToFloat(param);
773     return ValidateFogCommon(context, pname, &asFloat);
774 }
775 
ValidateFogxv(const Context * context,GLenum pname,const GLfixed * params)776 bool ValidateFogxv(const Context *context, GLenum pname, const GLfixed *params)
777 {
778     ANGLE_VALIDATE_IS_GLES1(context);
779     unsigned int paramCount = GetFogParameterCount(pname);
780     GLfloat paramsf[4]      = {};
781 
782     if (pname == GL_FOG_MODE)
783     {
784         paramsf[0] = static_cast<GLfloat>(params[0]);
785     }
786     else
787     {
788         for (unsigned int i = 0; i < paramCount; i++)
789         {
790             paramsf[i] = ConvertFixedToFloat(params[i]);
791         }
792     }
793 
794     return ValidateFogCommon(context, pname, paramsf);
795 }
796 
ValidateFrustumf(const Context * context,GLfloat l,GLfloat r,GLfloat b,GLfloat t,GLfloat n,GLfloat f)797 bool ValidateFrustumf(const Context *context,
798                       GLfloat l,
799                       GLfloat r,
800                       GLfloat b,
801                       GLfloat t,
802                       GLfloat n,
803                       GLfloat f)
804 {
805     ANGLE_VALIDATE_IS_GLES1(context);
806     if (l == r || b == t || n == f || n <= 0.0f || f <= 0.0f)
807     {
808         context->validationError(GL_INVALID_VALUE, kInvalidProjectionMatrix);
809     }
810     return true;
811 }
812 
ValidateFrustumx(const Context * context,GLfixed l,GLfixed r,GLfixed b,GLfixed t,GLfixed n,GLfixed f)813 bool ValidateFrustumx(const Context *context,
814                       GLfixed l,
815                       GLfixed r,
816                       GLfixed b,
817                       GLfixed t,
818                       GLfixed n,
819                       GLfixed f)
820 {
821     ANGLE_VALIDATE_IS_GLES1(context);
822     if (l == r || b == t || n == f || n <= 0 || f <= 0)
823     {
824         context->validationError(GL_INVALID_VALUE, kInvalidProjectionMatrix);
825     }
826     return true;
827 }
828 
ValidateGetBufferParameteriv(const Context * context,GLenum target,GLenum pname,const GLint * params)829 bool ValidateGetBufferParameteriv(const Context *context,
830                                   GLenum target,
831                                   GLenum pname,
832                                   const GLint *params)
833 {
834     UNIMPLEMENTED();
835     return true;
836 }
837 
ValidateGetClipPlanef(const Context * context,GLenum plane,const GLfloat * equation)838 bool ValidateGetClipPlanef(const Context *context, GLenum plane, const GLfloat *equation)
839 {
840     return ValidateClipPlaneCommon(context, plane);
841 }
842 
ValidateGetClipPlanex(const Context * context,GLenum plane,const GLfixed * equation)843 bool ValidateGetClipPlanex(const Context *context, GLenum plane, const GLfixed *equation)
844 {
845     return ValidateClipPlaneCommon(context, plane);
846 }
847 
ValidateGetFixedv(const Context * context,GLenum pname,const GLfixed * params)848 bool ValidateGetFixedv(const Context *context, GLenum pname, const GLfixed *params)
849 {
850     ANGLE_VALIDATE_IS_GLES1(context);
851     GLenum nativeType;
852     unsigned int numParams = 0;
853     return ValidateStateQuery(context, pname, &nativeType, &numParams);
854 }
855 
ValidateGetLightfv(const Context * context,GLenum light,LightParameter pname,const GLfloat * params)856 bool ValidateGetLightfv(const Context *context,
857                         GLenum light,
858                         LightParameter pname,
859                         const GLfloat *params)
860 {
861     GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
862     return ValidateLightCommon(context, light, pname, dummyParams);
863 }
864 
ValidateGetLightxv(const Context * context,GLenum light,LightParameter pname,const GLfixed * params)865 bool ValidateGetLightxv(const Context *context,
866                         GLenum light,
867                         LightParameter pname,
868                         const GLfixed *params)
869 {
870     GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
871     return ValidateLightCommon(context, light, pname, dummyParams);
872 }
873 
ValidateGetMaterialfv(const Context * context,GLenum face,MaterialParameter pname,const GLfloat * params)874 bool ValidateGetMaterialfv(const Context *context,
875                            GLenum face,
876                            MaterialParameter pname,
877                            const GLfloat *params)
878 {
879     return ValidateMaterialQuery(context, face, pname);
880 }
881 
ValidateGetMaterialxv(const Context * context,GLenum face,MaterialParameter pname,const GLfixed * params)882 bool ValidateGetMaterialxv(const Context *context,
883                            GLenum face,
884                            MaterialParameter pname,
885                            const GLfixed *params)
886 {
887     return ValidateMaterialQuery(context, face, pname);
888 }
889 
ValidateGetTexEnvfv(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,const GLfloat * params)890 bool ValidateGetTexEnvfv(const Context *context,
891                          TextureEnvTarget target,
892                          TextureEnvParameter pname,
893                          const GLfloat *params)
894 {
895     return ValidateGetTexEnvCommon(context, target, pname);
896 }
897 
ValidateGetTexEnviv(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,const GLint * params)898 bool ValidateGetTexEnviv(const Context *context,
899                          TextureEnvTarget target,
900                          TextureEnvParameter pname,
901                          const GLint *params)
902 {
903     return ValidateGetTexEnvCommon(context, target, pname);
904 }
905 
ValidateGetTexEnvxv(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,const GLfixed * params)906 bool ValidateGetTexEnvxv(const Context *context,
907                          TextureEnvTarget target,
908                          TextureEnvParameter pname,
909                          const GLfixed *params)
910 {
911     return ValidateGetTexEnvCommon(context, target, pname);
912 }
913 
ValidateGetTexParameterxv(const Context * context,TextureType target,GLenum pname,const GLfixed * params)914 bool ValidateGetTexParameterxv(const Context *context,
915                                TextureType target,
916                                GLenum pname,
917                                const GLfixed *params)
918 {
919     ANGLE_VALIDATE_IS_GLES1(context);
920 
921     if (!ValidateGetTexParameterBase(context, target, pname, nullptr))
922     {
923         return false;
924     }
925 
926     return true;
927 }
928 
ValidateLightModelf(const Context * context,GLenum pname,GLfloat param)929 bool ValidateLightModelf(const Context *context, GLenum pname, GLfloat param)
930 {
931     return ValidateLightModelSingleComponent(context, pname);
932 }
933 
ValidateLightModelfv(const Context * context,GLenum pname,const GLfloat * params)934 bool ValidateLightModelfv(const Context *context, GLenum pname, const GLfloat *params)
935 {
936     return ValidateLightModelCommon(context, pname);
937 }
938 
ValidateLightModelx(const Context * context,GLenum pname,GLfixed param)939 bool ValidateLightModelx(const Context *context, GLenum pname, GLfixed param)
940 {
941     return ValidateLightModelSingleComponent(context, pname);
942 }
943 
ValidateLightModelxv(const Context * context,GLenum pname,const GLfixed * param)944 bool ValidateLightModelxv(const Context *context, GLenum pname, const GLfixed *param)
945 {
946     return ValidateLightModelCommon(context, pname);
947 }
948 
ValidateLightf(const Context * context,GLenum light,LightParameter pname,GLfloat param)949 bool ValidateLightf(const Context *context, GLenum light, LightParameter pname, GLfloat param)
950 {
951     return ValidateLightSingleComponent(context, light, pname, param);
952 }
953 
ValidateLightfv(const Context * context,GLenum light,LightParameter pname,const GLfloat * params)954 bool ValidateLightfv(const Context *context,
955                      GLenum light,
956                      LightParameter pname,
957                      const GLfloat *params)
958 {
959     return ValidateLightCommon(context, light, pname, params);
960 }
961 
ValidateLightx(const Context * context,GLenum light,LightParameter pname,GLfixed param)962 bool ValidateLightx(const Context *context, GLenum light, LightParameter pname, GLfixed param)
963 {
964     return ValidateLightSingleComponent(context, light, pname, ConvertFixedToFloat(param));
965 }
966 
ValidateLightxv(const Context * context,GLenum light,LightParameter pname,const GLfixed * params)967 bool ValidateLightxv(const Context *context,
968                      GLenum light,
969                      LightParameter pname,
970                      const GLfixed *params)
971 {
972     GLfloat paramsf[4];
973     for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
974     {
975         paramsf[i] = ConvertFixedToFloat(params[i]);
976     }
977 
978     return ValidateLightCommon(context, light, pname, paramsf);
979 }
980 
ValidateLineWidthx(const Context * context,GLfixed width)981 bool ValidateLineWidthx(const Context *context, GLfixed width)
982 {
983     ANGLE_VALIDATE_IS_GLES1(context);
984     if (width <= 0)
985     {
986         context->validationError(GL_INVALID_VALUE, kInvalidWidth);
987         return false;
988     }
989 
990     return true;
991 }
992 
ValidateLoadIdentity(const Context * context)993 bool ValidateLoadIdentity(const Context *context)
994 {
995     ANGLE_VALIDATE_IS_GLES1(context);
996     return true;
997 }
998 
ValidateLoadMatrixf(const Context * context,const GLfloat * m)999 bool ValidateLoadMatrixf(const Context *context, const GLfloat *m)
1000 {
1001     ANGLE_VALIDATE_IS_GLES1(context);
1002     return true;
1003 }
1004 
ValidateLoadMatrixx(const Context * context,const GLfixed * m)1005 bool ValidateLoadMatrixx(const Context *context, const GLfixed *m)
1006 {
1007     ANGLE_VALIDATE_IS_GLES1(context);
1008     return true;
1009 }
1010 
ValidateLogicOp(const Context * context,LogicalOperation opcode)1011 bool ValidateLogicOp(const Context *context, LogicalOperation opcode)
1012 {
1013     ANGLE_VALIDATE_IS_GLES1(context);
1014     switch (opcode)
1015     {
1016         case LogicalOperation::And:
1017         case LogicalOperation::AndInverted:
1018         case LogicalOperation::AndReverse:
1019         case LogicalOperation::Clear:
1020         case LogicalOperation::Copy:
1021         case LogicalOperation::CopyInverted:
1022         case LogicalOperation::Equiv:
1023         case LogicalOperation::Invert:
1024         case LogicalOperation::Nand:
1025         case LogicalOperation::Noop:
1026         case LogicalOperation::Nor:
1027         case LogicalOperation::Or:
1028         case LogicalOperation::OrInverted:
1029         case LogicalOperation::OrReverse:
1030         case LogicalOperation::Set:
1031         case LogicalOperation::Xor:
1032             return true;
1033         default:
1034             context->validationError(GL_INVALID_ENUM, kInvalidLogicOp);
1035             return false;
1036     }
1037 }
1038 
ValidateMaterialf(const Context * context,GLenum face,MaterialParameter pname,GLfloat param)1039 bool ValidateMaterialf(const Context *context, GLenum face, MaterialParameter pname, GLfloat param)
1040 {
1041     return ValidateMaterialSingleComponent(context, face, pname, param);
1042 }
1043 
ValidateMaterialfv(const Context * context,GLenum face,MaterialParameter pname,const GLfloat * params)1044 bool ValidateMaterialfv(const Context *context,
1045                         GLenum face,
1046                         MaterialParameter pname,
1047                         const GLfloat *params)
1048 {
1049     return ValidateMaterialSetting(context, face, pname, params);
1050 }
1051 
ValidateMaterialx(const Context * context,GLenum face,MaterialParameter pname,GLfixed param)1052 bool ValidateMaterialx(const Context *context, GLenum face, MaterialParameter pname, GLfixed param)
1053 {
1054     return ValidateMaterialSingleComponent(context, face, pname, ConvertFixedToFloat(param));
1055 }
1056 
ValidateMaterialxv(const Context * context,GLenum face,MaterialParameter pname,const GLfixed * params)1057 bool ValidateMaterialxv(const Context *context,
1058                         GLenum face,
1059                         MaterialParameter pname,
1060                         const GLfixed *params)
1061 {
1062     GLfloat paramsf[4];
1063 
1064     for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
1065     {
1066         paramsf[i] = ConvertFixedToFloat(params[i]);
1067     }
1068 
1069     return ValidateMaterialSetting(context, face, pname, paramsf);
1070 }
1071 
ValidateMatrixMode(const Context * context,MatrixType mode)1072 bool ValidateMatrixMode(const Context *context, MatrixType mode)
1073 {
1074     ANGLE_VALIDATE_IS_GLES1(context);
1075     switch (mode)
1076     {
1077         case MatrixType::Projection:
1078         case MatrixType::Modelview:
1079         case MatrixType::Texture:
1080             return true;
1081         default:
1082             context->validationError(GL_INVALID_ENUM, kInvalidMatrixMode);
1083             return false;
1084     }
1085 }
1086 
ValidateMultMatrixf(const Context * context,const GLfloat * m)1087 bool ValidateMultMatrixf(const Context *context, const GLfloat *m)
1088 {
1089     ANGLE_VALIDATE_IS_GLES1(context);
1090     return true;
1091 }
1092 
ValidateMultMatrixx(const Context * context,const GLfixed * m)1093 bool ValidateMultMatrixx(const Context *context, const GLfixed *m)
1094 {
1095     ANGLE_VALIDATE_IS_GLES1(context);
1096     return true;
1097 }
1098 
ValidateMultiTexCoord4f(const Context * context,GLenum target,GLfloat s,GLfloat t,GLfloat r,GLfloat q)1099 bool ValidateMultiTexCoord4f(const Context *context,
1100                              GLenum target,
1101                              GLfloat s,
1102                              GLfloat t,
1103                              GLfloat r,
1104                              GLfloat q)
1105 {
1106     ANGLE_VALIDATE_IS_GLES1(context);
1107     return ValidateMultitextureUnit(context, target);
1108 }
1109 
ValidateMultiTexCoord4x(const Context * context,GLenum target,GLfixed s,GLfixed t,GLfixed r,GLfixed q)1110 bool ValidateMultiTexCoord4x(const Context *context,
1111                              GLenum target,
1112                              GLfixed s,
1113                              GLfixed t,
1114                              GLfixed r,
1115                              GLfixed q)
1116 {
1117     ANGLE_VALIDATE_IS_GLES1(context);
1118     return ValidateMultitextureUnit(context, target);
1119 }
1120 
ValidateNormal3f(const Context * context,GLfloat nx,GLfloat ny,GLfloat nz)1121 bool ValidateNormal3f(const Context *context, GLfloat nx, GLfloat ny, GLfloat nz)
1122 {
1123     ANGLE_VALIDATE_IS_GLES1(context);
1124     return true;
1125 }
1126 
ValidateNormal3x(const Context * context,GLfixed nx,GLfixed ny,GLfixed nz)1127 bool ValidateNormal3x(const Context *context, GLfixed nx, GLfixed ny, GLfixed nz)
1128 {
1129     ANGLE_VALIDATE_IS_GLES1(context);
1130     return true;
1131 }
1132 
ValidateNormalPointer(const Context * context,VertexAttribType type,GLsizei stride,const void * pointer)1133 bool ValidateNormalPointer(const Context *context,
1134                            VertexAttribType type,
1135                            GLsizei stride,
1136                            const void *pointer)
1137 {
1138     return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Normal, 3, type,
1139                                                 stride, pointer);
1140 }
1141 
ValidateOrthof(const Context * context,GLfloat l,GLfloat r,GLfloat b,GLfloat t,GLfloat n,GLfloat f)1142 bool ValidateOrthof(const Context *context,
1143                     GLfloat l,
1144                     GLfloat r,
1145                     GLfloat b,
1146                     GLfloat t,
1147                     GLfloat n,
1148                     GLfloat f)
1149 {
1150     ANGLE_VALIDATE_IS_GLES1(context);
1151     // [OpenGL ES 1.1.12] section 2.10.2 page 31:
1152     // If l is equal to r, b is equal to t, or n is equal to f, the
1153     // error INVALID VALUE results.
1154     if (l == r || b == t || n == f)
1155     {
1156         context->validationError(GL_INVALID_VALUE, kInvalidProjectionMatrix);
1157     }
1158     return true;
1159 }
1160 
ValidateOrthox(const Context * context,GLfixed l,GLfixed r,GLfixed b,GLfixed t,GLfixed n,GLfixed f)1161 bool ValidateOrthox(const Context *context,
1162                     GLfixed l,
1163                     GLfixed r,
1164                     GLfixed b,
1165                     GLfixed t,
1166                     GLfixed n,
1167                     GLfixed f)
1168 {
1169     ANGLE_VALIDATE_IS_GLES1(context);
1170     if (l == r || b == t || n == f)
1171     {
1172         context->validationError(GL_INVALID_VALUE, kInvalidProjectionMatrix);
1173     }
1174     return true;
1175 }
1176 
ValidatePointParameterf(const Context * context,PointParameter pname,GLfloat param)1177 bool ValidatePointParameterf(const Context *context, PointParameter pname, GLfloat param)
1178 {
1179     unsigned int paramCount = GetPointParameterCount(pname);
1180     if (paramCount != 1)
1181     {
1182         context->validationError(GL_INVALID_ENUM, kInvalidPointParameter);
1183         return false;
1184     }
1185 
1186     return ValidatePointParameterCommon(context, pname, &param);
1187 }
1188 
ValidatePointParameterfv(const Context * context,PointParameter pname,const GLfloat * params)1189 bool ValidatePointParameterfv(const Context *context, PointParameter pname, const GLfloat *params)
1190 {
1191     return ValidatePointParameterCommon(context, pname, params);
1192 }
1193 
ValidatePointParameterx(const Context * context,PointParameter pname,GLfixed param)1194 bool ValidatePointParameterx(const Context *context, PointParameter pname, GLfixed param)
1195 {
1196     unsigned int paramCount = GetPointParameterCount(pname);
1197     if (paramCount != 1)
1198     {
1199         context->validationError(GL_INVALID_ENUM, kInvalidPointParameter);
1200         return false;
1201     }
1202 
1203     GLfloat paramf = ConvertFixedToFloat(param);
1204     return ValidatePointParameterCommon(context, pname, &paramf);
1205 }
1206 
ValidatePointParameterxv(const Context * context,PointParameter pname,const GLfixed * params)1207 bool ValidatePointParameterxv(const Context *context, PointParameter pname, const GLfixed *params)
1208 {
1209     GLfloat paramsf[4] = {};
1210     for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
1211     {
1212         paramsf[i] = ConvertFixedToFloat(params[i]);
1213     }
1214     return ValidatePointParameterCommon(context, pname, paramsf);
1215 }
1216 
ValidatePointSize(const Context * context,GLfloat size)1217 bool ValidatePointSize(const Context *context, GLfloat size)
1218 {
1219     return ValidatePointSizeCommon(context, size);
1220 }
1221 
ValidatePointSizex(const Context * context,GLfixed size)1222 bool ValidatePointSizex(const Context *context, GLfixed size)
1223 {
1224     return ValidatePointSizeCommon(context, ConvertFixedToFloat(size));
1225 }
1226 
ValidatePolygonOffsetx(const Context * context,GLfixed factor,GLfixed units)1227 bool ValidatePolygonOffsetx(const Context *context, GLfixed factor, GLfixed units)
1228 {
1229     ANGLE_VALIDATE_IS_GLES1(context);
1230     return true;
1231 }
1232 
ValidatePopMatrix(const Context * context)1233 bool ValidatePopMatrix(const Context *context)
1234 {
1235     ANGLE_VALIDATE_IS_GLES1(context);
1236     const auto &stack = context->getState().gles1().currentMatrixStack();
1237     if (stack.size() == 1)
1238     {
1239         context->validationError(GL_STACK_UNDERFLOW, kMatrixStackUnderflow);
1240         return false;
1241     }
1242     return true;
1243 }
1244 
ValidatePushMatrix(const Context * context)1245 bool ValidatePushMatrix(const Context *context)
1246 {
1247     ANGLE_VALIDATE_IS_GLES1(context);
1248     const auto &stack = context->getState().gles1().currentMatrixStack();
1249     if (stack.size() == stack.max_size())
1250     {
1251         context->validationError(GL_STACK_OVERFLOW, kMatrixStackOverflow);
1252         return false;
1253     }
1254     return true;
1255 }
1256 
ValidateRotatef(const Context * context,GLfloat angle,GLfloat x,GLfloat y,GLfloat z)1257 bool ValidateRotatef(const Context *context, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
1258 {
1259     ANGLE_VALIDATE_IS_GLES1(context);
1260     return true;
1261 }
1262 
ValidateRotatex(const Context * context,GLfixed angle,GLfixed x,GLfixed y,GLfixed z)1263 bool ValidateRotatex(const Context *context, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
1264 {
1265     ANGLE_VALIDATE_IS_GLES1(context);
1266     return true;
1267 }
1268 
ValidateSampleCoveragex(const Context * context,GLclampx value,GLboolean invert)1269 bool ValidateSampleCoveragex(const Context *context, GLclampx value, GLboolean invert)
1270 {
1271     ANGLE_VALIDATE_IS_GLES1(context);
1272     return true;
1273 }
1274 
ValidateScalef(const Context * context,GLfloat x,GLfloat y,GLfloat z)1275 bool ValidateScalef(const Context *context, GLfloat x, GLfloat y, GLfloat z)
1276 {
1277     ANGLE_VALIDATE_IS_GLES1(context);
1278     return true;
1279 }
1280 
ValidateScalex(const Context * context,GLfixed x,GLfixed y,GLfixed z)1281 bool ValidateScalex(const Context *context, GLfixed x, GLfixed y, GLfixed z)
1282 {
1283     ANGLE_VALIDATE_IS_GLES1(context);
1284     return true;
1285 }
1286 
ValidateShadeModel(const Context * context,ShadingModel mode)1287 bool ValidateShadeModel(const Context *context, ShadingModel mode)
1288 {
1289     ANGLE_VALIDATE_IS_GLES1(context);
1290     switch (mode)
1291     {
1292         case ShadingModel::Flat:
1293         case ShadingModel::Smooth:
1294             return true;
1295         default:
1296             context->validationError(GL_INVALID_ENUM, kInvalidShadingModel);
1297             return false;
1298     }
1299 }
1300 
ValidateTexCoordPointer(const Context * context,GLint size,VertexAttribType type,GLsizei stride,const void * pointer)1301 bool ValidateTexCoordPointer(const Context *context,
1302                              GLint size,
1303                              VertexAttribType type,
1304                              GLsizei stride,
1305                              const void *pointer)
1306 {
1307     return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::TextureCoord, size,
1308                                                 type, stride, pointer);
1309 }
1310 
ValidateTexEnvf(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,GLfloat param)1311 bool ValidateTexEnvf(const Context *context,
1312                      TextureEnvTarget target,
1313                      TextureEnvParameter pname,
1314                      GLfloat param)
1315 {
1316     return ValidateTexEnvCommon(context, target, pname, &param);
1317 }
1318 
ValidateTexEnvfv(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,const GLfloat * params)1319 bool ValidateTexEnvfv(const Context *context,
1320                       TextureEnvTarget target,
1321                       TextureEnvParameter pname,
1322                       const GLfloat *params)
1323 {
1324     return ValidateTexEnvCommon(context, target, pname, params);
1325 }
1326 
ValidateTexEnvi(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,GLint param)1327 bool ValidateTexEnvi(const Context *context,
1328                      TextureEnvTarget target,
1329                      TextureEnvParameter pname,
1330                      GLint param)
1331 {
1332     GLfloat paramf = static_cast<GLfloat>(param);
1333     return ValidateTexEnvCommon(context, target, pname, &paramf);
1334 }
1335 
ValidateTexEnviv(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,const GLint * params)1336 bool ValidateTexEnviv(const Context *context,
1337                       TextureEnvTarget target,
1338                       TextureEnvParameter pname,
1339                       const GLint *params)
1340 {
1341     GLfloat paramsf[4];
1342     for (unsigned int i = 0; i < GetTextureEnvParameterCount(pname); i++)
1343     {
1344         paramsf[i] = static_cast<GLfloat>(params[i]);
1345     }
1346     return ValidateTexEnvCommon(context, target, pname, paramsf);
1347 }
1348 
ValidateTexEnvx(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,GLfixed param)1349 bool ValidateTexEnvx(const Context *context,
1350                      TextureEnvTarget target,
1351                      TextureEnvParameter pname,
1352                      GLfixed param)
1353 {
1354     ANGLE_VALIDATE_IS_GLES1(context);
1355     GLfloat paramsf[4] = {};
1356     ConvertTextureEnvFromFixed(pname, &param, paramsf);
1357     return ValidateTexEnvCommon(context, target, pname, paramsf);
1358 }
1359 
ValidateTexEnvxv(const Context * context,TextureEnvTarget target,TextureEnvParameter pname,const GLfixed * params)1360 bool ValidateTexEnvxv(const Context *context,
1361                       TextureEnvTarget target,
1362                       TextureEnvParameter pname,
1363                       const GLfixed *params)
1364 {
1365     ANGLE_VALIDATE_IS_GLES1(context);
1366     GLfloat paramsf[4] = {};
1367     ConvertTextureEnvFromFixed(pname, params, paramsf);
1368     return ValidateTexEnvCommon(context, target, pname, paramsf);
1369 }
1370 
ValidateTexParameterBaseForGLfixed(const Context * context,TextureType target,GLenum pname,GLsizei bufSize,bool vectorParams,const GLfixed * params)1371 bool ValidateTexParameterBaseForGLfixed(const Context *context,
1372                                         TextureType target,
1373                                         GLenum pname,
1374                                         GLsizei bufSize,
1375                                         bool vectorParams,
1376                                         const GLfixed *params)
1377 {
1378     // Convert GLfixed parameter for GL_TEXTURE_MAX_ANISOTROPY_EXT independently
1379     // since it compares against 1 and maxTextureAnisotropy instead of just 0
1380     // (other values are fine to leave unconverted since they only check positive or negative or
1381     // are used as enums)
1382     GLfloat paramValue;
1383     if (pname == GL_TEXTURE_MAX_ANISOTROPY_EXT)
1384     {
1385         paramValue = ConvertFixedToFloat(static_cast<GLfixed>(params[0]));
1386     }
1387     else
1388     {
1389         paramValue = static_cast<GLfloat>(params[0]);
1390     }
1391     return ValidateTexParameterBase(context, target, pname, bufSize, vectorParams, &paramValue);
1392 }
1393 
ValidateTexParameterx(const Context * context,TextureType target,GLenum pname,GLfixed param)1394 bool ValidateTexParameterx(const Context *context, TextureType target, GLenum pname, GLfixed param)
1395 {
1396     ANGLE_VALIDATE_IS_GLES1(context);
1397     return ValidateTexParameterBaseForGLfixed(context, target, pname, -1, false, &param);
1398 }
1399 
ValidateTexParameterxv(const Context * context,TextureType target,GLenum pname,const GLfixed * params)1400 bool ValidateTexParameterxv(const Context *context,
1401                             TextureType target,
1402                             GLenum pname,
1403                             const GLfixed *params)
1404 {
1405     ANGLE_VALIDATE_IS_GLES1(context);
1406     return ValidateTexParameterBaseForGLfixed(context, target, pname, -1, true, params);
1407 }
1408 
ValidateTranslatef(const Context * context,GLfloat x,GLfloat y,GLfloat z)1409 bool ValidateTranslatef(const Context *context, GLfloat x, GLfloat y, GLfloat z)
1410 {
1411     ANGLE_VALIDATE_IS_GLES1(context);
1412     return true;
1413 }
1414 
ValidateTranslatex(const Context * context,GLfixed x,GLfixed y,GLfixed z)1415 bool ValidateTranslatex(const Context *context, GLfixed x, GLfixed y, GLfixed z)
1416 {
1417     ANGLE_VALIDATE_IS_GLES1(context);
1418     return true;
1419 }
1420 
ValidateVertexPointer(const Context * context,GLint size,VertexAttribType type,GLsizei stride,const void * pointer)1421 bool ValidateVertexPointer(const Context *context,
1422                            GLint size,
1423                            VertexAttribType type,
1424                            GLsizei stride,
1425                            const void *pointer)
1426 {
1427     return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Vertex, size, type,
1428                                                 stride, pointer);
1429 }
1430 
ValidateDrawTexfOES(const Context * context,GLfloat x,GLfloat y,GLfloat z,GLfloat width,GLfloat height)1431 bool ValidateDrawTexfOES(const Context *context,
1432                          GLfloat x,
1433                          GLfloat y,
1434                          GLfloat z,
1435                          GLfloat width,
1436                          GLfloat height)
1437 {
1438     return ValidateDrawTexCommon(context, width, height);
1439 }
1440 
ValidateDrawTexfvOES(const Context * context,const GLfloat * coords)1441 bool ValidateDrawTexfvOES(const Context *context, const GLfloat *coords)
1442 {
1443     return ValidateDrawTexCommon(context, coords[3], coords[4]);
1444 }
1445 
ValidateDrawTexiOES(const Context * context,GLint x,GLint y,GLint z,GLint width,GLint height)1446 bool ValidateDrawTexiOES(const Context *context,
1447                          GLint x,
1448                          GLint y,
1449                          GLint z,
1450                          GLint width,
1451                          GLint height)
1452 {
1453     return ValidateDrawTexCommon(context, static_cast<GLfloat>(width),
1454                                  static_cast<GLfloat>(height));
1455 }
1456 
ValidateDrawTexivOES(const Context * context,const GLint * coords)1457 bool ValidateDrawTexivOES(const Context *context, const GLint *coords)
1458 {
1459     return ValidateDrawTexCommon(context, static_cast<GLfloat>(coords[3]),
1460                                  static_cast<GLfloat>(coords[4]));
1461 }
1462 
ValidateDrawTexsOES(const Context * context,GLshort x,GLshort y,GLshort z,GLshort width,GLshort height)1463 bool ValidateDrawTexsOES(const Context *context,
1464                          GLshort x,
1465                          GLshort y,
1466                          GLshort z,
1467                          GLshort width,
1468                          GLshort height)
1469 {
1470     return ValidateDrawTexCommon(context, static_cast<GLfloat>(width),
1471                                  static_cast<GLfloat>(height));
1472 }
1473 
ValidateDrawTexsvOES(const Context * context,const GLshort * coords)1474 bool ValidateDrawTexsvOES(const Context *context, const GLshort *coords)
1475 {
1476     return ValidateDrawTexCommon(context, static_cast<GLfloat>(coords[3]),
1477                                  static_cast<GLfloat>(coords[4]));
1478 }
1479 
ValidateDrawTexxOES(const Context * context,GLfixed x,GLfixed y,GLfixed z,GLfixed width,GLfixed height)1480 bool ValidateDrawTexxOES(const Context *context,
1481                          GLfixed x,
1482                          GLfixed y,
1483                          GLfixed z,
1484                          GLfixed width,
1485                          GLfixed height)
1486 {
1487     return ValidateDrawTexCommon(context, ConvertFixedToFloat(width), ConvertFixedToFloat(height));
1488 }
1489 
ValidateDrawTexxvOES(const Context * context,const GLfixed * coords)1490 bool ValidateDrawTexxvOES(const Context *context, const GLfixed *coords)
1491 {
1492     return ValidateDrawTexCommon(context, ConvertFixedToFloat(coords[3]),
1493                                  ConvertFixedToFloat(coords[4]));
1494 }
1495 
ValidateCurrentPaletteMatrixOES(const Context * context,GLuint matrixpaletteindex)1496 bool ValidateCurrentPaletteMatrixOES(const Context *context, GLuint matrixpaletteindex)
1497 {
1498     UNIMPLEMENTED();
1499     return true;
1500 }
1501 
ValidateLoadPaletteFromModelViewMatrixOES(const Context * context)1502 bool ValidateLoadPaletteFromModelViewMatrixOES(const Context *context)
1503 {
1504     UNIMPLEMENTED();
1505     return true;
1506 }
1507 
ValidateMatrixIndexPointerOES(const Context * context,GLint size,GLenum type,GLsizei stride,const void * pointer)1508 bool ValidateMatrixIndexPointerOES(const Context *context,
1509                                    GLint size,
1510                                    GLenum type,
1511                                    GLsizei stride,
1512                                    const void *pointer)
1513 {
1514     UNIMPLEMENTED();
1515     return true;
1516 }
1517 
ValidateWeightPointerOES(const Context * context,GLint size,GLenum type,GLsizei stride,const void * pointer)1518 bool ValidateWeightPointerOES(const Context *context,
1519                               GLint size,
1520                               GLenum type,
1521                               GLsizei stride,
1522                               const void *pointer)
1523 {
1524     UNIMPLEMENTED();
1525     return true;
1526 }
1527 
ValidatePointSizePointerOES(const Context * context,VertexAttribType type,GLsizei stride,const void * pointer)1528 bool ValidatePointSizePointerOES(const Context *context,
1529                                  VertexAttribType type,
1530                                  GLsizei stride,
1531                                  const void *pointer)
1532 {
1533     return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::PointSize, 1, type,
1534                                                 stride, pointer);
1535 }
1536 
ValidateQueryMatrixxOES(const Context * context,const GLfixed * mantissa,const GLint * exponent)1537 bool ValidateQueryMatrixxOES(const Context *context, const GLfixed *mantissa, const GLint *exponent)
1538 {
1539     UNIMPLEMENTED();
1540     return true;
1541 }
1542 
ValidateGenFramebuffersOES(const Context * context,GLsizei n,const FramebufferID * framebuffers)1543 bool ValidateGenFramebuffersOES(const Context *context,
1544                                 GLsizei n,
1545                                 const FramebufferID *framebuffers)
1546 {
1547     UNIMPLEMENTED();
1548     return true;
1549 }
1550 
ValidateDeleteFramebuffersOES(const Context * context,GLsizei n,const FramebufferID * framebuffers)1551 bool ValidateDeleteFramebuffersOES(const Context *context,
1552                                    GLsizei n,
1553                                    const FramebufferID *framebuffers)
1554 {
1555     UNIMPLEMENTED();
1556     return true;
1557 }
1558 
ValidateGenRenderbuffersOES(const Context * context,GLsizei n,const RenderbufferID * renderbuffers)1559 bool ValidateGenRenderbuffersOES(const Context *context,
1560                                  GLsizei n,
1561                                  const RenderbufferID *renderbuffers)
1562 {
1563     UNIMPLEMENTED();
1564     return true;
1565 }
1566 
ValidateDeleteRenderbuffersOES(const Context * context,GLsizei n,const RenderbufferID * renderbuffers)1567 bool ValidateDeleteRenderbuffersOES(const Context *context,
1568                                     GLsizei n,
1569                                     const RenderbufferID *renderbuffers)
1570 {
1571     UNIMPLEMENTED();
1572     return true;
1573 }
1574 
ValidateBindFramebufferOES(const Context * context,GLenum target,FramebufferID framebuffer)1575 bool ValidateBindFramebufferOES(const Context *context, GLenum target, FramebufferID framebuffer)
1576 {
1577     UNIMPLEMENTED();
1578     return true;
1579 }
1580 
ValidateBindRenderbufferOES(const Context * context,GLenum target,RenderbufferID renderbuffer)1581 bool ValidateBindRenderbufferOES(const Context *context, GLenum target, RenderbufferID renderbuffer)
1582 {
1583     UNIMPLEMENTED();
1584     return true;
1585 }
1586 
ValidateCheckFramebufferStatusOES(const Context * context,GLenum target)1587 bool ValidateCheckFramebufferStatusOES(const Context *context, GLenum target)
1588 {
1589     UNIMPLEMENTED();
1590     return true;
1591 }
1592 
ValidateFramebufferRenderbufferOES(const Context * context,GLenum target,GLenum attachment,GLenum rbtarget,RenderbufferID renderbuffer)1593 bool ValidateFramebufferRenderbufferOES(const Context *context,
1594                                         GLenum target,
1595                                         GLenum attachment,
1596                                         GLenum rbtarget,
1597                                         RenderbufferID renderbuffer)
1598 {
1599     UNIMPLEMENTED();
1600     return true;
1601 }
1602 
ValidateFramebufferTexture2DOES(const Context * context,GLenum target,GLenum attachment,TextureTarget textarget,TextureID texture,GLint level)1603 bool ValidateFramebufferTexture2DOES(const Context *context,
1604                                      GLenum target,
1605                                      GLenum attachment,
1606                                      TextureTarget textarget,
1607                                      TextureID texture,
1608                                      GLint level)
1609 {
1610     UNIMPLEMENTED();
1611     return true;
1612 }
1613 
ValidateGenerateMipmapOES(const Context * context,TextureType target)1614 bool ValidateGenerateMipmapOES(const Context *context, TextureType target)
1615 {
1616     UNIMPLEMENTED();
1617     return true;
1618 }
1619 
ValidateGetFramebufferAttachmentParameterivOES(const Context * context,GLenum target,GLenum attachment,GLenum pname,const GLint * params)1620 bool ValidateGetFramebufferAttachmentParameterivOES(const Context *context,
1621                                                     GLenum target,
1622                                                     GLenum attachment,
1623                                                     GLenum pname,
1624                                                     const GLint *params)
1625 {
1626     UNIMPLEMENTED();
1627     return true;
1628 }
1629 
ValidateGetRenderbufferParameterivOES(const Context * context,GLenum target,GLenum pname,const GLint * params)1630 bool ValidateGetRenderbufferParameterivOES(const Context *context,
1631                                            GLenum target,
1632                                            GLenum pname,
1633                                            const GLint *params)
1634 {
1635     UNIMPLEMENTED();
1636     return true;
1637 }
1638 
ValidateIsFramebufferOES(const Context * context,FramebufferID framebuffer)1639 bool ValidateIsFramebufferOES(const Context *context, FramebufferID framebuffer)
1640 {
1641     UNIMPLEMENTED();
1642     return true;
1643 }
1644 
ValidateIsRenderbufferOES(const Context * context,RenderbufferID renderbuffer)1645 bool ValidateIsRenderbufferOES(const Context *context, RenderbufferID renderbuffer)
1646 {
1647     UNIMPLEMENTED();
1648     return true;
1649 }
1650 
ValidateRenderbufferStorageOES(const Context * context,GLenum target,GLenum internalformat,GLsizei width,GLsizei height)1651 bool ValidateRenderbufferStorageOES(const Context *context,
1652                                     GLenum target,
1653                                     GLenum internalformat,
1654                                     GLsizei width,
1655                                     GLsizei height)
1656 {
1657     UNIMPLEMENTED();
1658     return true;
1659 }
1660 
1661 // GL_OES_texture_cube_map
1662 
ValidateGetTexGenfvOES(const Context * context,GLenum coord,GLenum pname,const GLfloat * params)1663 bool ValidateGetTexGenfvOES(const Context *context,
1664                             GLenum coord,
1665                             GLenum pname,
1666                             const GLfloat *params)
1667 {
1668     UNIMPLEMENTED();
1669     return true;
1670 }
1671 
ValidateGetTexGenivOES(const Context * context,GLenum coord,GLenum pname,const int * params)1672 bool ValidateGetTexGenivOES(const Context *context, GLenum coord, GLenum pname, const int *params)
1673 {
1674     UNIMPLEMENTED();
1675     return true;
1676 }
1677 
ValidateGetTexGenxvOES(const Context * context,GLenum coord,GLenum pname,const GLfixed * params)1678 bool ValidateGetTexGenxvOES(const Context *context,
1679                             GLenum coord,
1680                             GLenum pname,
1681                             const GLfixed *params)
1682 {
1683     UNIMPLEMENTED();
1684     return true;
1685 }
1686 
ValidateTexGenfvOES(const Context * context,GLenum coord,GLenum pname,const GLfloat * params)1687 bool ValidateTexGenfvOES(const Context *context, GLenum coord, GLenum pname, const GLfloat *params)
1688 {
1689     UNIMPLEMENTED();
1690     return true;
1691 }
1692 
ValidateTexGenivOES(const Context * context,GLenum coord,GLenum pname,const GLint * param)1693 bool ValidateTexGenivOES(const Context *context, GLenum coord, GLenum pname, const GLint *param)
1694 {
1695     UNIMPLEMENTED();
1696     return true;
1697 }
1698 
ValidateTexGenxvOES(const Context * context,GLenum coord,GLenum pname,const GLint * param)1699 bool ValidateTexGenxvOES(const Context *context, GLenum coord, GLenum pname, const GLint *param)
1700 {
1701     UNIMPLEMENTED();
1702     return true;
1703 }
1704 
ValidateTexGenfOES(const Context * context,GLenum coord,GLenum pname,GLfloat param)1705 bool ValidateTexGenfOES(const Context *context, GLenum coord, GLenum pname, GLfloat param)
1706 {
1707     UNIMPLEMENTED();
1708     return true;
1709 }
1710 
ValidateTexGeniOES(const Context * context,GLenum coord,GLenum pname,GLint param)1711 bool ValidateTexGeniOES(const Context *context, GLenum coord, GLenum pname, GLint param)
1712 {
1713     UNIMPLEMENTED();
1714     return true;
1715 }
1716 
ValidateTexGenxOES(const Context * context,GLenum coord,GLenum pname,GLfixed param)1717 bool ValidateTexGenxOES(const Context *context, GLenum coord, GLenum pname, GLfixed param)
1718 {
1719     UNIMPLEMENTED();
1720     return true;
1721 }
1722 
1723 }  // namespace gl
1724