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