blob: e2e158cdfc127460f2207b81a19bc1ef85df55c0 [file] [log] [blame]
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001//
2// Copyright (c) 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.h"
10
11#include "common/debug.h"
Lingfeng Yang13b708f2018-03-21 12:14:10 -070012#include "libANGLE/Context.h"
13#include "libANGLE/ErrorStrings.h"
Lingfeng Yangd0febe72018-05-17 22:36:52 -070014#include "libANGLE/GLES1State.h"
Lingfeng Yang45b5a872018-06-07 11:33:25 -070015#include "libANGLE/queryconversions.h"
Lingfeng Yangd0febe72018-05-17 22:36:52 -070016#include "libANGLE/queryutils.h"
Lingfeng Yang038dd532018-03-29 17:31:52 -070017#include "libANGLE/validationES.h"
Lingfeng Yang13b708f2018-03-21 12:14:10 -070018
19#define ANGLE_VALIDATE_IS_GLES1(context) \
20 if (context->getClientMajorVersion() > 1) \
21 { \
22 ANGLE_VALIDATION_ERR(context, InvalidOperation(), GLES1Only); \
23 return false; \
24 }
25
Lingfeng Yang01074432018-04-16 10:19:51 -070026namespace gl
Lingfeng Yang13b708f2018-03-21 12:14:10 -070027{
28
Lingfeng Yangabb09f12018-04-16 10:43:53 -070029bool ValidateAlphaFuncCommon(Context *context, AlphaTestFunc func)
Lingfeng Yang13b708f2018-03-21 12:14:10 -070030{
31 switch (func)
32 {
Lingfeng Yangabb09f12018-04-16 10:43:53 -070033 case AlphaTestFunc::AlwaysPass:
34 case AlphaTestFunc::Equal:
35 case AlphaTestFunc::Gequal:
36 case AlphaTestFunc::Greater:
37 case AlphaTestFunc::Lequal:
38 case AlphaTestFunc::Less:
39 case AlphaTestFunc::Never:
40 case AlphaTestFunc::NotEqual:
Lingfeng Yang13b708f2018-03-21 12:14:10 -070041 return true;
42 default:
Lingfeng Yang01074432018-04-16 10:19:51 -070043 ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
Lingfeng Yang13b708f2018-03-21 12:14:10 -070044 return false;
45 }
46}
47
Lingfeng Yangabb09f12018-04-16 10:43:53 -070048bool ValidateClientStateCommon(Context *context, ClientVertexArrayType arrayType)
Lingfeng Yang01074432018-04-16 10:19:51 -070049{
50 ANGLE_VALIDATE_IS_GLES1(context);
51 switch (arrayType)
52 {
Lingfeng Yangabb09f12018-04-16 10:43:53 -070053 case ClientVertexArrayType::Vertex:
54 case ClientVertexArrayType::Normal:
55 case ClientVertexArrayType::Color:
56 case ClientVertexArrayType::TextureCoord:
Lingfeng Yang01074432018-04-16 10:19:51 -070057 return true;
Lingfeng Yangabb09f12018-04-16 10:43:53 -070058 case ClientVertexArrayType::PointSize:
Lingfeng Yang01074432018-04-16 10:19:51 -070059 if (!context->getExtensions().pointSizeArray)
60 {
61 ANGLE_VALIDATION_ERR(context, InvalidEnum(), PointSizeArrayExtensionNotEnabled);
62 return false;
63 }
64 return true;
65 default:
66 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidClientState);
67 return false;
68 }
69}
70
Lingfeng Yangabb09f12018-04-16 10:43:53 -070071bool ValidateBuiltinVertexAttributeCommon(Context *context,
72 ClientVertexArrayType arrayType,
73 GLint size,
74 GLenum type,
75 GLsizei stride,
76 const void *pointer)
77{
78 ANGLE_VALIDATE_IS_GLES1(context);
79
80 if (stride < 0)
81 {
82 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidVertexPointerStride);
83 return false;
84 }
85
86 int minSize = 1;
87 int maxSize = 4;
88
89 switch (arrayType)
90 {
91 case ClientVertexArrayType::Vertex:
92 case ClientVertexArrayType::TextureCoord:
93 minSize = 2;
94 maxSize = 4;
95 break;
96 case ClientVertexArrayType::Normal:
97 minSize = 3;
98 maxSize = 3;
99 break;
100 case ClientVertexArrayType::Color:
101 minSize = 4;
102 maxSize = 4;
103 break;
104 case ClientVertexArrayType::PointSize:
105 if (!context->getExtensions().pointSizeArray)
106 {
107 ANGLE_VALIDATION_ERR(context, InvalidEnum(), PointSizeArrayExtensionNotEnabled);
108 return false;
109 }
110
111 minSize = 1;
112 maxSize = 1;
113 break;
114 default:
115 UNREACHABLE();
116 return false;
117 }
118
119 if (size < minSize || size > maxSize)
120 {
121 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidVertexPointerSize);
122 return false;
123 }
124
125 switch (type)
126 {
127 case GL_BYTE:
128 if (arrayType == ClientVertexArrayType::PointSize)
129 {
130 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidVertexPointerType);
131 return false;
132 }
133 break;
134 case GL_SHORT:
135 if (arrayType == ClientVertexArrayType::PointSize ||
136 arrayType == ClientVertexArrayType::Color)
137 {
138 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidVertexPointerType);
139 return false;
140 }
141 break;
142 case GL_FIXED:
143 case GL_FLOAT:
144 break;
145 default:
146 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidVertexPointerType);
147 return false;
148 }
149
150 return true;
151}
152
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700153bool ValidateLightCaps(Context *context, GLenum light)
154{
155 if (light < GL_LIGHT0 || light >= GL_LIGHT0 + context->getCaps().maxLights)
156 {
157 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLight);
158 return false;
159 }
160
161 return true;
162}
163
164bool ValidateLightCommon(Context *context,
165 GLenum light,
166 LightParameter pname,
167 const GLfloat *params)
168{
169
170 ANGLE_VALIDATE_IS_GLES1(context);
171
172 if (!ValidateLightCaps(context, light))
173 {
174 return false;
175 }
176
177 switch (pname)
178 {
179 case LightParameter::Ambient:
180 case LightParameter::Diffuse:
181 case LightParameter::Specular:
182 case LightParameter::Position:
183 case LightParameter::SpotDirection:
184 return true;
185 case LightParameter::SpotExponent:
186 if (params[0] < 0.0f || params[0] > 128.0f)
187 {
188 ANGLE_VALIDATION_ERR(context, InvalidValue(), LightParameterOutOfRange);
189 return false;
190 }
191 return true;
192 case LightParameter::SpotCutoff:
193 if (params[0] == 180.0f)
194 {
195 return true;
196 }
197 if (params[0] < 0.0f || params[0] > 90.0f)
198 {
199 ANGLE_VALIDATION_ERR(context, InvalidValue(), LightParameterOutOfRange);
200 return false;
201 }
202 return true;
203 case LightParameter::ConstantAttenuation:
204 case LightParameter::LinearAttenuation:
205 case LightParameter::QuadraticAttenuation:
206 if (params[0] < 0.0f)
207 {
208 ANGLE_VALIDATION_ERR(context, InvalidValue(), LightParameterOutOfRange);
209 return false;
210 }
211 return true;
212 default:
213 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightParameter);
214 return false;
215 }
216}
217
218bool ValidateLightSingleComponent(Context *context,
219 GLenum light,
220 LightParameter pname,
221 GLfloat param)
222{
223 if (!ValidateLightCommon(context, light, pname, &param))
224 {
225 return false;
226 }
227
228 if (GetLightParameterCount(pname) > 1)
229 {
230 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightParameter);
231 return false;
232 }
233
234 return true;
235}
236
237bool ValidateMaterialCommon(Context *context,
238 GLenum face,
239 MaterialParameter pname,
240 const GLfloat *params)
241{
242 ANGLE_VALIDATE_IS_GLES1(context);
243
244 if (face != GL_FRONT_AND_BACK)
245 {
246 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMaterialFace);
247 return false;
248 }
249
250 switch (pname)
251 {
252 case MaterialParameter::Ambient:
253 case MaterialParameter::Diffuse:
254 case MaterialParameter::Specular:
255 case MaterialParameter::Emission:
256 return true;
257 case MaterialParameter::Shininess:
258 if (params[0] < 0.0f || params[0] > 128.0f)
259 {
260 ANGLE_VALIDATION_ERR(context, InvalidValue(), MaterialParameterOutOfRange);
261 return false;
262 }
263 return true;
264 default:
265 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMaterialParameter);
266 return false;
267 }
268}
269
270bool ValidateMaterialSingleComponent(Context *context,
271 GLenum face,
272 MaterialParameter pname,
273 GLfloat param)
274{
275 if (!ValidateMaterialCommon(context, face, pname, &param))
276 {
277 return false;
278 }
279
280 if (GetMaterialParameterCount(pname) > 1)
281 {
282 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMaterialParameter);
283 return false;
284 }
285
286 return true;
287}
288
289bool ValidateLightModelCommon(Context *context, GLenum pname)
290{
291 ANGLE_VALIDATE_IS_GLES1(context);
292 switch (pname)
293 {
294 case GL_LIGHT_MODEL_AMBIENT:
295 case GL_LIGHT_MODEL_TWO_SIDE:
296 return true;
297 default:
298 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightModelParameter);
299 return false;
300 }
301}
302
303bool ValidateLightModelSingleComponent(Context *context, GLenum pname)
304{
305 if (!ValidateLightModelCommon(context, pname))
306 {
307 return false;
308 }
309
310 switch (pname)
311 {
312 case GL_LIGHT_MODEL_TWO_SIDE:
313 return true;
314 default:
315 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightModelParameter);
316 return false;
317 }
318}
319
Lingfeng Yang060088a2018-05-30 20:40:57 -0700320bool ValidateClipPlaneCommon(Context *context, GLenum plane)
321{
322 ANGLE_VALIDATE_IS_GLES1(context);
323
324 if (plane < GL_CLIP_PLANE0 || plane >= GL_CLIP_PLANE0 + context->getCaps().maxClipPlanes)
325 {
326 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidClipPlane);
327 return false;
328 }
329
330 return true;
331}
332
Lingfeng Yang7ba3f422018-06-01 09:43:04 -0700333bool ValidateFogCommon(Context *context, GLenum pname, const GLfloat *params)
334{
335 ANGLE_VALIDATE_IS_GLES1(context);
336
337 switch (pname)
338 {
339 case GL_FOG_MODE:
340 {
341 GLenum modeParam = static_cast<GLenum>(params[0]);
342 switch (modeParam)
343 {
344 case GL_EXP:
345 case GL_EXP2:
346 case GL_LINEAR:
347 return true;
348 default:
349 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidFogMode);
350 return false;
351 }
352 }
353 break;
354 case GL_FOG_START:
355 case GL_FOG_END:
356 case GL_FOG_COLOR:
357 break;
358 case GL_FOG_DENSITY:
359 if (params[0] < 0.0f)
360 {
361 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidFogDensity);
362 return false;
363 }
364 break;
365 default:
366 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFogParameter);
367 return false;
368 }
369 return true;
370}
371
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700372bool ValidateTexEnvCommon(Context *context,
373 TextureEnvTarget target,
374 TextureEnvParameter pname,
375 const GLfloat *params)
376{
377 ANGLE_VALIDATE_IS_GLES1(context);
378
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700379 switch (target)
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700380 {
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700381 case TextureEnvTarget::Env:
382 switch (pname)
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700383 {
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700384 case TextureEnvParameter::Mode:
385 {
386 TextureEnvMode mode = FromGLenum<TextureEnvMode>(ConvertToGLenum(params[0]));
387 switch (mode)
Lingfeng Yang4004ae02018-06-13 09:29:00 -0700388 {
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700389 case TextureEnvMode::Add:
390 case TextureEnvMode::Blend:
391 case TextureEnvMode::Combine:
392 case TextureEnvMode::Decal:
393 case TextureEnvMode::Modulate:
394 case TextureEnvMode::Replace:
395 break;
396 default:
397 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureEnvMode);
398 return false;
399 }
400 break;
401 }
402 case TextureEnvParameter::CombineRgb:
403 case TextureEnvParameter::CombineAlpha:
404 {
405 TextureCombine combine = FromGLenum<TextureCombine>(ConvertToGLenum(params[0]));
406 switch (combine)
407 {
408 case TextureCombine::Add:
409 case TextureCombine::AddSigned:
410 case TextureCombine::Interpolate:
411 case TextureCombine::Modulate:
412 case TextureCombine::Replace:
413 case TextureCombine::Subtract:
414 break;
415 case TextureCombine::Dot3Rgb:
416 case TextureCombine::Dot3Rgba:
417 if (pname == TextureEnvParameter::CombineAlpha)
418 {
419 ANGLE_VALIDATION_ERR(context, InvalidValue(),
420 InvalidTextureCombine);
421 return false;
422 }
423 break;
424 default:
425 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombine);
426 return false;
427 }
428 break;
429 }
430 case TextureEnvParameter::Src0Rgb:
431 case TextureEnvParameter::Src1Rgb:
432 case TextureEnvParameter::Src2Rgb:
433 case TextureEnvParameter::Src0Alpha:
434 case TextureEnvParameter::Src1Alpha:
435 case TextureEnvParameter::Src2Alpha:
436 {
437 TextureSrc combine = FromGLenum<TextureSrc>(ConvertToGLenum(params[0]));
438 switch (combine)
439 {
440 case TextureSrc::Constant:
441 case TextureSrc::Previous:
442 case TextureSrc::PrimaryColor:
443 case TextureSrc::Texture:
444 break;
445 default:
446 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombineSrc);
447 return false;
448 }
449 break;
450 }
451 case TextureEnvParameter::Op0Rgb:
452 case TextureEnvParameter::Op1Rgb:
453 case TextureEnvParameter::Op2Rgb:
454 case TextureEnvParameter::Op0Alpha:
455 case TextureEnvParameter::Op1Alpha:
456 case TextureEnvParameter::Op2Alpha:
457 {
458 TextureOp operand = FromGLenum<TextureOp>(ConvertToGLenum(params[0]));
459 switch (operand)
460 {
461 case TextureOp::SrcAlpha:
462 case TextureOp::OneMinusSrcAlpha:
463 break;
464 case TextureOp::SrcColor:
465 case TextureOp::OneMinusSrcColor:
466 if (pname == TextureEnvParameter::Op0Alpha ||
467 pname == TextureEnvParameter::Op1Alpha ||
468 pname == TextureEnvParameter::Op2Alpha)
469 {
470 ANGLE_VALIDATION_ERR(context, InvalidValue(),
471 InvalidTextureCombine);
472 return false;
473 }
474 break;
475 default:
476 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombineOp);
477 return false;
478 }
479 break;
480 }
481 case TextureEnvParameter::RgbScale:
482 case TextureEnvParameter::AlphaScale:
483 if (params[0] != 1.0f && params[0] != 2.0f && params[0] != 4.0f)
484 {
485 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureEnvScale);
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700486 return false;
487 }
488 break;
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700489 case TextureEnvParameter::Color:
490 break;
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700491 default:
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700492 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureEnvParameter);
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700493 return false;
494 }
495 break;
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700496 case TextureEnvTarget::PointSprite:
497 if (!context->getExtensions().pointSprite)
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700498 {
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700499 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureEnvTarget);
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700500 return false;
501 }
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700502 switch (pname)
503 {
504 case TextureEnvParameter::PointCoordReplace:
505 break;
506 default:
507 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureEnvParameter);
508 return false;
509 }
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700510 break;
511 default:
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700512 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureEnvTarget);
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700513 return false;
514 }
515 return true;
516}
517
518bool ValidateGetTexEnvCommon(Context *context, TextureEnvTarget target, TextureEnvParameter pname)
519{
520 GLfloat dummy[4] = {};
521 switch (pname)
522 {
523 case TextureEnvParameter::Mode:
524 ConvertPackedEnum(TextureEnvMode::Add, dummy);
525 break;
526 case TextureEnvParameter::CombineRgb:
527 case TextureEnvParameter::CombineAlpha:
528 ConvertPackedEnum(TextureCombine::Add, dummy);
529 break;
530 case TextureEnvParameter::Src0Rgb:
531 case TextureEnvParameter::Src1Rgb:
532 case TextureEnvParameter::Src2Rgb:
533 case TextureEnvParameter::Src0Alpha:
534 case TextureEnvParameter::Src1Alpha:
535 case TextureEnvParameter::Src2Alpha:
536 ConvertPackedEnum(TextureSrc::Constant, dummy);
537 break;
538 case TextureEnvParameter::Op0Rgb:
539 case TextureEnvParameter::Op1Rgb:
540 case TextureEnvParameter::Op2Rgb:
541 case TextureEnvParameter::Op0Alpha:
542 case TextureEnvParameter::Op1Alpha:
543 case TextureEnvParameter::Op2Alpha:
544 ConvertPackedEnum(TextureOp::SrcAlpha, dummy);
545 break;
546 case TextureEnvParameter::RgbScale:
547 case TextureEnvParameter::AlphaScale:
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700548 case TextureEnvParameter::PointCoordReplace:
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700549 dummy[0] = 1.0f;
550 break;
551 default:
552 break;
553 }
554
555 return ValidateTexEnvCommon(context, target, pname, dummy);
556}
557
Lingfeng Yang9c4c0922018-06-13 09:29:00 -0700558bool ValidatePointParameterCommon(Context *context, PointParameter pname, const GLfloat *params)
559{
560 ANGLE_VALIDATE_IS_GLES1(context);
561
562 switch (pname)
563 {
564 case PointParameter::PointSizeMin:
565 case PointParameter::PointSizeMax:
566 case PointParameter::PointFadeThresholdSize:
567 case PointParameter::PointDistanceAttenuation:
568 for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
569 {
570 if (params[i] < 0.0f)
571 {
572 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidPointParameterValue);
573 return false;
574 }
575 }
576 break;
577 default:
578 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPointParameter);
579 return false;
580 }
581
582 return true;
583}
584
585bool ValidatePointSizeCommon(Context *context, GLfloat size)
586{
587 ANGLE_VALIDATE_IS_GLES1(context);
588
589 if (size <= 0.0f)
590 {
591 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidPointSizeValue);
592 return false;
593 }
594
595 return true;
596}
597
Lingfeng Yang0df813c2018-07-12 12:52:06 -0700598bool ValidateDrawTexCommon(Context *context, float width, float height)
599{
600 ANGLE_VALIDATE_IS_GLES1(context);
601
602 if (width <= 0.0f || height <= 0.0f)
603 {
604 ANGLE_VALIDATION_ERR(context, InvalidValue(), NonPositiveDrawTextureDimension);
605 return false;
606 }
607
608 return true;
609}
610
Lingfeng Yang01074432018-04-16 10:19:51 -0700611} // namespace gl
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500612
613namespace gl
614{
615
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700616bool ValidateAlphaFunc(Context *context, AlphaTestFunc func, GLfloat ref)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500617{
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700618 ANGLE_VALIDATE_IS_GLES1(context);
619 return ValidateAlphaFuncCommon(context, func);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500620}
621
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700622bool ValidateAlphaFuncx(Context *context, AlphaTestFunc func, GLfixed ref)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500623{
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700624 ANGLE_VALIDATE_IS_GLES1(context);
625 return ValidateAlphaFuncCommon(context, func);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500626}
627
628bool ValidateClearColorx(Context *context, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
629{
630 UNIMPLEMENTED();
631 return true;
632}
633
634bool ValidateClearDepthx(Context *context, GLfixed depth)
635{
636 UNIMPLEMENTED();
637 return true;
638}
639
640bool ValidateClientActiveTexture(Context *context, GLenum texture)
641{
Lingfeng Yang96310cd2018-03-28 11:56:28 -0700642 ANGLE_VALIDATE_IS_GLES1(context);
Lingfeng Yang038dd532018-03-29 17:31:52 -0700643 return ValidateMultitextureUnit(context, texture);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500644}
645
Lingfeng Yang060088a2018-05-30 20:40:57 -0700646bool ValidateClipPlanef(Context *context, GLenum plane, const GLfloat *eqn)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500647{
Lingfeng Yang060088a2018-05-30 20:40:57 -0700648 return ValidateClipPlaneCommon(context, plane);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500649}
650
651bool ValidateClipPlanex(Context *context, GLenum plane, const GLfixed *equation)
652{
Lingfeng Yang060088a2018-05-30 20:40:57 -0700653 return ValidateClipPlaneCommon(context, plane);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500654}
655
656bool ValidateColor4f(Context *context, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
657{
Lingfeng Yanga43994c2018-03-29 07:21:41 -0700658 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500659 return true;
660}
661
662bool ValidateColor4ub(Context *context, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
663{
Lingfeng Yanga43994c2018-03-29 07:21:41 -0700664 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500665 return true;
666}
667
668bool ValidateColor4x(Context *context, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
669{
Lingfeng Yanga43994c2018-03-29 07:21:41 -0700670 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500671 return true;
672}
673
674bool ValidateColorPointer(Context *context,
675 GLint size,
676 GLenum type,
677 GLsizei stride,
678 const void *pointer)
679{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700680 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Color, size, type,
681 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500682}
683
684bool ValidateCullFace(Context *context, GLenum mode)
685{
686 UNIMPLEMENTED();
687 return true;
688}
689
690bool ValidateDepthRangex(Context *context, GLfixed n, GLfixed f)
691{
692 UNIMPLEMENTED();
693 return true;
694}
695
Lingfeng Yang01074432018-04-16 10:19:51 -0700696bool ValidateDisableClientState(Context *context, ClientVertexArrayType arrayType)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500697{
Lingfeng Yang01074432018-04-16 10:19:51 -0700698 return ValidateClientStateCommon(context, arrayType);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500699}
700
Lingfeng Yang01074432018-04-16 10:19:51 -0700701bool ValidateEnableClientState(Context *context, ClientVertexArrayType arrayType)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500702{
Lingfeng Yang01074432018-04-16 10:19:51 -0700703 return ValidateClientStateCommon(context, arrayType);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500704}
705
706bool ValidateFogf(Context *context, GLenum pname, GLfloat param)
707{
Lingfeng Yang7ba3f422018-06-01 09:43:04 -0700708 return ValidateFogCommon(context, pname, &param);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500709}
710
711bool ValidateFogfv(Context *context, GLenum pname, const GLfloat *params)
712{
Lingfeng Yang7ba3f422018-06-01 09:43:04 -0700713 return ValidateFogCommon(context, pname, params);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500714}
715
716bool ValidateFogx(Context *context, GLenum pname, GLfixed param)
717{
Lingfeng Yang7ba3f422018-06-01 09:43:04 -0700718 GLfloat asFloat = FixedToFloat(param);
719 return ValidateFogCommon(context, pname, &asFloat);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500720}
721
Lingfeng Yang7ba3f422018-06-01 09:43:04 -0700722bool ValidateFogxv(Context *context, GLenum pname, const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500723{
Lingfeng Yang7ba3f422018-06-01 09:43:04 -0700724 unsigned int paramCount = GetFogParameterCount(pname);
725 GLfloat paramsf[4] = {};
726
727 for (unsigned int i = 0; i < paramCount; i++)
728 {
729 paramsf[i] = FixedToFloat(params[i]);
730 }
731
732 return ValidateFogCommon(context, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500733}
734
735bool ValidateFrustumf(Context *context,
736 GLfloat l,
737 GLfloat r,
738 GLfloat b,
739 GLfloat t,
740 GLfloat n,
741 GLfloat f)
742{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700743 ANGLE_VALIDATE_IS_GLES1(context);
744 if (l == r || b == t || n == f || n <= 0.0f || f <= 0.0f)
745 {
746 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
747 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500748 return true;
749}
750
751bool ValidateFrustumx(Context *context,
752 GLfixed l,
753 GLfixed r,
754 GLfixed b,
755 GLfixed t,
756 GLfixed n,
757 GLfixed f)
758{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700759 ANGLE_VALIDATE_IS_GLES1(context);
760 if (l == r || b == t || n == f || n <= 0 || f <= 0)
761 {
762 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
763 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500764 return true;
765}
766
767bool ValidateGetBufferParameteriv(Context *context, GLenum target, GLenum pname, GLint *params)
768{
769 UNIMPLEMENTED();
770 return true;
771}
772
773bool ValidateGetClipPlanef(Context *context, GLenum plane, GLfloat *equation)
774{
Lingfeng Yang060088a2018-05-30 20:40:57 -0700775 return ValidateClipPlaneCommon(context, plane);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500776}
777
778bool ValidateGetClipPlanex(Context *context, GLenum plane, GLfixed *equation)
779{
Lingfeng Yang060088a2018-05-30 20:40:57 -0700780 return ValidateClipPlaneCommon(context, plane);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500781}
782
783bool ValidateGetFixedv(Context *context, GLenum pname, GLfixed *params)
784{
785 UNIMPLEMENTED();
786 return true;
787}
788
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700789bool ValidateGetLightfv(Context *context, GLenum light, LightParameter pname, GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500790{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700791 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
792 return ValidateLightCommon(context, light, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500793}
794
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700795bool ValidateGetLightxv(Context *context, GLenum light, LightParameter pname, GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500796{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700797 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
798 return ValidateLightCommon(context, light, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500799}
800
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700801bool ValidateGetMaterialfv(Context *context, GLenum face, MaterialParameter pname, GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500802{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700803 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
804 return ValidateMaterialCommon(context, face, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500805}
806
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700807bool ValidateGetMaterialxv(Context *context, GLenum face, MaterialParameter pname, GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500808{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700809 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
810 return ValidateMaterialCommon(context, face, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500811}
812
813bool ValidateGetPointerv(Context *context, GLenum pname, void **params)
814{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700815 ANGLE_VALIDATE_IS_GLES1(context);
816 switch (pname)
817 {
818 case GL_VERTEX_ARRAY_POINTER:
819 case GL_NORMAL_ARRAY_POINTER:
820 case GL_COLOR_ARRAY_POINTER:
821 case GL_TEXTURE_COORD_ARRAY_POINTER:
822 case GL_POINT_SIZE_ARRAY_POINTER_OES:
823 return true;
824 default:
825 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPointerQuery);
826 return false;
827 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500828}
829
Lingfeng Yang74be2962018-06-07 09:13:38 -0700830bool ValidateGetTexEnvfv(Context *context,
831 TextureEnvTarget target,
832 TextureEnvParameter pname,
833 GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500834{
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700835 return ValidateGetTexEnvCommon(context, target, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500836}
837
Lingfeng Yang74be2962018-06-07 09:13:38 -0700838bool ValidateGetTexEnviv(Context *context,
839 TextureEnvTarget target,
840 TextureEnvParameter pname,
841 GLint *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500842{
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700843 return ValidateGetTexEnvCommon(context, target, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500844}
845
Lingfeng Yang74be2962018-06-07 09:13:38 -0700846bool ValidateGetTexEnvxv(Context *context,
847 TextureEnvTarget target,
848 TextureEnvParameter pname,
849 GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500850{
Lingfeng Yang45b5a872018-06-07 11:33:25 -0700851 return ValidateGetTexEnvCommon(context, target, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500852}
853
Corentin Wallezf0e89be2017-11-08 14:00:32 -0800854bool ValidateGetTexParameterxv(Context *context, TextureType target, GLenum pname, GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500855{
Lingfeng Yangf97641c2018-06-21 19:22:45 -0700856 ANGLE_VALIDATE_IS_GLES1(context);
857
858 if (!ValidateGetTexParameterBase(context, target, pname, nullptr))
859 {
860 return false;
861 }
862
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500863 return true;
864}
865
866bool ValidateLightModelf(Context *context, GLenum pname, GLfloat param)
867{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700868 return ValidateLightModelSingleComponent(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500869}
870
871bool ValidateLightModelfv(Context *context, GLenum pname, const GLfloat *params)
872{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700873 return ValidateLightModelCommon(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500874}
875
876bool ValidateLightModelx(Context *context, GLenum pname, GLfixed param)
877{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700878 return ValidateLightModelSingleComponent(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500879}
880
881bool ValidateLightModelxv(Context *context, GLenum pname, const GLfixed *param)
882{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700883 return ValidateLightModelCommon(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500884}
885
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700886bool ValidateLightf(Context *context, GLenum light, LightParameter pname, GLfloat param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500887{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700888 return ValidateLightSingleComponent(context, light, pname, param);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500889}
890
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700891bool ValidateLightfv(Context *context, GLenum light, LightParameter pname, const GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500892{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700893 return ValidateLightCommon(context, light, pname, params);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500894}
895
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700896bool ValidateLightx(Context *context, GLenum light, LightParameter pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500897{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700898 return ValidateLightSingleComponent(context, light, pname, FixedToFloat(param));
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500899}
900
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700901bool ValidateLightxv(Context *context, GLenum light, LightParameter pname, const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500902{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700903 GLfloat paramsf[4];
904 for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
905 {
906 paramsf[i] = FixedToFloat(params[i]);
907 }
908
909 return ValidateLightCommon(context, light, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500910}
911
912bool ValidateLineWidthx(Context *context, GLfixed width)
913{
914 UNIMPLEMENTED();
915 return true;
916}
917
918bool ValidateLoadIdentity(Context *context)
919{
Lingfeng Yang3a41af62018-04-09 07:28:56 -0700920 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500921 return true;
922}
923
924bool ValidateLoadMatrixf(Context *context, const GLfloat *m)
925{
Lingfeng Yang3a41af62018-04-09 07:28:56 -0700926 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500927 return true;
928}
929
930bool ValidateLoadMatrixx(Context *context, const GLfixed *m)
931{
Lingfeng Yang3a41af62018-04-09 07:28:56 -0700932 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500933 return true;
934}
935
936bool ValidateLogicOp(Context *context, GLenum opcode)
937{
938 UNIMPLEMENTED();
939 return true;
940}
941
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700942bool ValidateMaterialf(Context *context, GLenum face, MaterialParameter pname, GLfloat param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500943{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700944 return ValidateMaterialSingleComponent(context, face, pname, param);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500945}
946
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700947bool ValidateMaterialfv(Context *context,
948 GLenum face,
949 MaterialParameter pname,
950 const GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500951{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700952 return ValidateMaterialCommon(context, face, pname, params);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500953}
954
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700955bool ValidateMaterialx(Context *context, GLenum face, MaterialParameter pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500956{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700957 return ValidateMaterialSingleComponent(context, face, pname, FixedToFloat(param));
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500958}
959
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700960bool ValidateMaterialxv(Context *context,
961 GLenum face,
962 MaterialParameter pname,
963 const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500964{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700965 GLfloat paramsf[4];
966
967 for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
968 {
969 paramsf[i] = FixedToFloat(params[i]);
970 }
971
972 return ValidateMaterialCommon(context, face, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500973}
974
Lingfeng Yang00af4632018-04-02 12:42:24 -0700975bool ValidateMatrixMode(Context *context, MatrixType mode)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500976{
Lingfeng Yangd2488ab2018-04-04 09:25:48 -0700977 ANGLE_VALIDATE_IS_GLES1(context);
978 switch (mode)
979 {
980 case MatrixType::Projection:
981 case MatrixType::Modelview:
982 case MatrixType::Texture:
983 return true;
984 default:
985 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMatrixMode);
986 return false;
987 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500988}
989
990bool ValidateMultMatrixf(Context *context, const GLfloat *m)
991{
Lingfeng Yang568fc392018-04-09 07:57:23 -0700992 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500993 return true;
994}
995
996bool ValidateMultMatrixx(Context *context, const GLfixed *m)
997{
Lingfeng Yang568fc392018-04-09 07:57:23 -0700998 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500999 return true;
1000}
1001
1002bool ValidateMultiTexCoord4f(Context *context,
1003 GLenum target,
1004 GLfloat s,
1005 GLfloat t,
1006 GLfloat r,
1007 GLfloat q)
1008{
Lingfeng Yang038dd532018-03-29 17:31:52 -07001009 ANGLE_VALIDATE_IS_GLES1(context);
1010 return ValidateMultitextureUnit(context, target);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001011}
1012
1013bool ValidateMultiTexCoord4x(Context *context,
Lingfeng Yang038dd532018-03-29 17:31:52 -07001014 GLenum target,
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001015 GLfixed s,
1016 GLfixed t,
1017 GLfixed r,
1018 GLfixed q)
1019{
Lingfeng Yang038dd532018-03-29 17:31:52 -07001020 ANGLE_VALIDATE_IS_GLES1(context);
1021 return ValidateMultitextureUnit(context, target);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001022}
1023
1024bool ValidateNormal3f(Context *context, GLfloat nx, GLfloat ny, GLfloat nz)
1025{
Lingfeng Yang5a7e61b2018-03-29 16:50:32 -07001026 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001027 return true;
1028}
1029
1030bool ValidateNormal3x(Context *context, GLfixed nx, GLfixed ny, GLfixed nz)
1031{
Lingfeng Yang5a7e61b2018-03-29 16:50:32 -07001032 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001033 return true;
1034}
1035
1036bool ValidateNormalPointer(Context *context, GLenum type, GLsizei stride, const void *pointer)
1037{
Lingfeng Yangabb09f12018-04-16 10:43:53 -07001038 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Normal, 3, type,
1039 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001040}
1041
1042bool ValidateOrthof(Context *context,
1043 GLfloat l,
1044 GLfloat r,
1045 GLfloat b,
1046 GLfloat t,
1047 GLfloat n,
1048 GLfloat f)
1049{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001050 ANGLE_VALIDATE_IS_GLES1(context);
1051 if (l == r || b == t || n == f || n <= 0.0f || f <= 0.0f)
1052 {
1053 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
1054 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001055 return true;
1056}
1057
1058bool ValidateOrthox(Context *context,
1059 GLfixed l,
1060 GLfixed r,
1061 GLfixed b,
1062 GLfixed t,
1063 GLfixed n,
1064 GLfixed f)
1065{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001066 ANGLE_VALIDATE_IS_GLES1(context);
1067 if (l == r || b == t || n == f || n <= 0 || f <= 0)
1068 {
1069 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
1070 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001071 return true;
1072}
1073
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001074bool ValidatePointParameterf(Context *context, PointParameter pname, GLfloat param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001075{
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001076 unsigned int paramCount = GetPointParameterCount(pname);
1077 if (paramCount != 1)
1078 {
1079 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPointParameter);
1080 return false;
1081 }
1082
1083 return ValidatePointParameterCommon(context, pname, &param);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001084}
1085
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001086bool ValidatePointParameterfv(Context *context, PointParameter pname, const GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001087{
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001088 return ValidatePointParameterCommon(context, pname, params);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001089}
1090
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001091bool ValidatePointParameterx(Context *context, PointParameter pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001092{
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001093 unsigned int paramCount = GetPointParameterCount(pname);
1094 if (paramCount != 1)
1095 {
1096 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPointParameter);
1097 return false;
1098 }
1099
1100 GLfloat paramf = FixedToFloat(param);
1101 return ValidatePointParameterCommon(context, pname, &paramf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001102}
1103
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001104bool ValidatePointParameterxv(Context *context, PointParameter pname, const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001105{
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001106 GLfloat paramsf[4] = {};
1107 for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
1108 {
1109 paramsf[i] = FixedToFloat(params[i]);
1110 }
1111 return ValidatePointParameterCommon(context, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001112}
1113
1114bool ValidatePointSize(Context *context, GLfloat size)
1115{
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001116 return ValidatePointSizeCommon(context, size);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001117}
1118
1119bool ValidatePointSizex(Context *context, GLfixed size)
1120{
Lingfeng Yang9c4c0922018-06-13 09:29:00 -07001121 return ValidatePointSizeCommon(context, FixedToFloat(size));
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001122}
1123
1124bool ValidatePolygonOffsetx(Context *context, GLfixed factor, GLfixed units)
1125{
1126 UNIMPLEMENTED();
1127 return true;
1128}
1129
1130bool ValidatePopMatrix(Context *context)
1131{
Lingfeng Yange547aac2018-04-05 09:39:20 -07001132 ANGLE_VALIDATE_IS_GLES1(context);
1133 const auto &stack = context->getGLState().gles1().currentMatrixStack();
1134 if (stack.size() == 1)
1135 {
1136 ANGLE_VALIDATION_ERR(context, StackUnderflow(), MatrixStackUnderflow);
1137 return false;
1138 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001139 return true;
1140}
1141
1142bool ValidatePushMatrix(Context *context)
1143{
Lingfeng Yange547aac2018-04-05 09:39:20 -07001144 ANGLE_VALIDATE_IS_GLES1(context);
1145 const auto &stack = context->getGLState().gles1().currentMatrixStack();
1146 if (stack.size() == stack.max_size())
1147 {
1148 ANGLE_VALIDATION_ERR(context, StackOverflow(), MatrixStackOverflow);
1149 return false;
1150 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001151 return true;
1152}
1153
1154bool ValidateRotatef(Context *context, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
1155{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001156 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001157 return true;
1158}
1159
1160bool ValidateRotatex(Context *context, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
1161{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001162 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001163 return true;
1164}
1165
1166bool ValidateSampleCoveragex(Context *context, GLclampx value, GLboolean invert)
1167{
1168 UNIMPLEMENTED();
1169 return true;
1170}
1171
1172bool ValidateScalef(Context *context, GLfloat x, GLfloat y, GLfloat z)
1173{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001174 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001175 return true;
1176}
1177
1178bool ValidateScalex(Context *context, GLfixed x, GLfixed y, GLfixed z)
1179{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001180 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001181 return true;
1182}
1183
Lingfeng Yanga0cfa872018-05-30 21:12:17 -07001184bool ValidateShadeModel(Context *context, ShadingModel mode)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001185{
Lingfeng Yanga0cfa872018-05-30 21:12:17 -07001186 ANGLE_VALIDATE_IS_GLES1(context);
1187 switch (mode)
1188 {
1189 case ShadingModel::Flat:
1190 case ShadingModel::Smooth:
1191 return true;
1192 default:
1193 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidShadingModel);
1194 return false;
1195 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001196}
1197
1198bool ValidateTexCoordPointer(Context *context,
1199 GLint size,
1200 GLenum type,
1201 GLsizei stride,
1202 const void *pointer)
1203{
Lingfeng Yangabb09f12018-04-16 10:43:53 -07001204 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::TextureCoord, size,
1205 type, stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001206}
1207
Lingfeng Yang74be2962018-06-07 09:13:38 -07001208bool ValidateTexEnvf(Context *context,
1209 TextureEnvTarget target,
1210 TextureEnvParameter pname,
1211 GLfloat param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001212{
Lingfeng Yang45b5a872018-06-07 11:33:25 -07001213 return ValidateTexEnvCommon(context, target, pname, &param);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001214}
1215
Lingfeng Yang74be2962018-06-07 09:13:38 -07001216bool ValidateTexEnvfv(Context *context,
1217 TextureEnvTarget target,
1218 TextureEnvParameter pname,
1219 const GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001220{
Lingfeng Yang45b5a872018-06-07 11:33:25 -07001221 return ValidateTexEnvCommon(context, target, pname, params);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001222}
1223
Lingfeng Yang74be2962018-06-07 09:13:38 -07001224bool ValidateTexEnvi(Context *context,
1225 TextureEnvTarget target,
1226 TextureEnvParameter pname,
1227 GLint param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001228{
Lingfeng Yang45b5a872018-06-07 11:33:25 -07001229 GLfloat paramf = static_cast<GLfloat>(param);
1230 return ValidateTexEnvCommon(context, target, pname, &paramf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001231}
1232
Lingfeng Yang74be2962018-06-07 09:13:38 -07001233bool ValidateTexEnviv(Context *context,
1234 TextureEnvTarget target,
1235 TextureEnvParameter pname,
1236 const GLint *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001237{
Lingfeng Yang45b5a872018-06-07 11:33:25 -07001238 GLfloat paramsf[4];
1239 for (unsigned int i = 0; i < GetTextureEnvParameterCount(pname); i++)
1240 {
1241 paramsf[i] = static_cast<GLfloat>(params[i]);
1242 }
1243 return ValidateTexEnvCommon(context, target, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001244}
1245
Lingfeng Yang74be2962018-06-07 09:13:38 -07001246bool ValidateTexEnvx(Context *context,
1247 TextureEnvTarget target,
1248 TextureEnvParameter pname,
1249 GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001250{
Lingfeng Yang45b5a872018-06-07 11:33:25 -07001251 GLfloat paramf = static_cast<GLfloat>(param);
1252 return ValidateTexEnvCommon(context, target, pname, &paramf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001253}
1254
Lingfeng Yang74be2962018-06-07 09:13:38 -07001255bool ValidateTexEnvxv(Context *context,
1256 TextureEnvTarget target,
1257 TextureEnvParameter pname,
1258 const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001259{
Lingfeng Yang45b5a872018-06-07 11:33:25 -07001260 GLfloat paramsf[4];
1261 for (unsigned int i = 0; i < GetTextureEnvParameterCount(pname); i++)
1262 {
1263 paramsf[i] = static_cast<GLfloat>(params[i]);
1264 }
1265 return ValidateTexEnvCommon(context, target, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001266}
1267
Corentin Wallezf0e89be2017-11-08 14:00:32 -08001268bool ValidateTexParameterx(Context *context, TextureType target, GLenum pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001269{
Lingfeng Yangf97641c2018-06-21 19:22:45 -07001270 ANGLE_VALIDATE_IS_GLES1(context);
1271 GLfloat paramf = FixedToFloat(param);
1272 return ValidateTexParameterBase(context, target, pname, 1, &paramf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001273}
1274
Corentin Wallezf0e89be2017-11-08 14:00:32 -08001275bool ValidateTexParameterxv(Context *context,
1276 TextureType target,
1277 GLenum pname,
1278 const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001279{
Lingfeng Yangf97641c2018-06-21 19:22:45 -07001280 ANGLE_VALIDATE_IS_GLES1(context);
1281 GLfloat paramsf[4] = {};
1282 for (unsigned int i = 0; i < GetTexParameterCount(pname); i++)
1283 {
1284 paramsf[i] = FixedToFloat(params[i]);
1285 }
1286 return ValidateTexParameterBase(context, target, pname, -1, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001287}
1288
1289bool ValidateTranslatef(Context *context, GLfloat x, GLfloat y, GLfloat z)
1290{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001291 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001292 return true;
1293}
1294
1295bool ValidateTranslatex(Context *context, GLfixed x, GLfixed y, GLfixed z)
1296{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -07001297 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001298 return true;
1299}
1300
1301bool ValidateVertexPointer(Context *context,
1302 GLint size,
1303 GLenum type,
1304 GLsizei stride,
1305 const void *pointer)
1306{
Lingfeng Yangabb09f12018-04-16 10:43:53 -07001307 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Vertex, size, type,
1308 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001309}
1310
1311bool ValidateDrawTexfOES(Context *context,
1312 GLfloat x,
1313 GLfloat y,
1314 GLfloat z,
1315 GLfloat width,
1316 GLfloat height)
1317{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001318 return ValidateDrawTexCommon(context, width, height);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001319}
1320
1321bool ValidateDrawTexfvOES(Context *context, const GLfloat *coords)
1322{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001323 return ValidateDrawTexCommon(context, coords[3], coords[4]);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001324}
1325
1326bool ValidateDrawTexiOES(Context *context, GLint x, GLint y, GLint z, GLint width, GLint height)
1327{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001328 return ValidateDrawTexCommon(context, static_cast<GLfloat>(width),
1329 static_cast<GLfloat>(height));
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001330}
1331
1332bool ValidateDrawTexivOES(Context *context, const GLint *coords)
1333{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001334 return ValidateDrawTexCommon(context, static_cast<GLfloat>(coords[3]),
1335 static_cast<GLfloat>(coords[4]));
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001336}
1337
1338bool ValidateDrawTexsOES(Context *context,
1339 GLshort x,
1340 GLshort y,
1341 GLshort z,
1342 GLshort width,
1343 GLshort height)
1344{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001345 return ValidateDrawTexCommon(context, static_cast<GLfloat>(width),
1346 static_cast<GLfloat>(height));
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001347}
1348
1349bool ValidateDrawTexsvOES(Context *context, const GLshort *coords)
1350{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001351 return ValidateDrawTexCommon(context, static_cast<GLfloat>(coords[3]),
1352 static_cast<GLfloat>(coords[4]));
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001353}
1354
1355bool ValidateDrawTexxOES(Context *context,
1356 GLfixed x,
1357 GLfixed y,
1358 GLfixed z,
1359 GLfixed width,
1360 GLfixed height)
1361{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001362 return ValidateDrawTexCommon(context, FixedToFloat(width), FixedToFloat(height));
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001363}
1364
1365bool ValidateDrawTexxvOES(Context *context, const GLfixed *coords)
1366{
Lingfeng Yang0df813c2018-07-12 12:52:06 -07001367 return ValidateDrawTexCommon(context, FixedToFloat(coords[3]), FixedToFloat(coords[4]));
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001368}
1369
1370bool ValidateCurrentPaletteMatrixOES(Context *context, GLuint matrixpaletteindex)
1371{
1372 UNIMPLEMENTED();
1373 return true;
1374}
1375
1376bool ValidateLoadPaletteFromModelViewMatrixOES(Context *context)
1377{
1378 UNIMPLEMENTED();
1379 return true;
1380}
1381
1382bool ValidateMatrixIndexPointerOES(Context *context,
1383 GLint size,
1384 GLenum type,
1385 GLsizei stride,
1386 const void *pointer)
1387{
1388 UNIMPLEMENTED();
1389 return true;
1390}
1391
1392bool ValidateWeightPointerOES(Context *context,
1393 GLint size,
1394 GLenum type,
1395 GLsizei stride,
1396 const void *pointer)
1397{
1398 UNIMPLEMENTED();
1399 return true;
1400}
1401
1402bool ValidatePointSizePointerOES(Context *context, GLenum type, GLsizei stride, const void *pointer)
1403{
Lingfeng Yangabb09f12018-04-16 10:43:53 -07001404 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::PointSize, 1, type,
1405 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001406}
1407
1408bool ValidateQueryMatrixxOES(Context *context, GLfixed *mantissa, GLint *exponent)
1409{
1410 UNIMPLEMENTED();
1411 return true;
1412}
Lingfeng Yanga0648782018-03-12 14:45:25 -07001413
1414bool ValidateGenFramebuffersOES(Context *context, GLsizei n, GLuint *framebuffers)
1415{
1416 UNIMPLEMENTED();
1417 return true;
1418}
1419
1420bool ValidateDeleteFramebuffersOES(Context *context, GLsizei n, const GLuint *framebuffers)
1421{
1422 UNIMPLEMENTED();
1423 return true;
1424}
1425
1426bool ValidateGenRenderbuffersOES(Context *context, GLsizei n, GLuint *renderbuffers)
1427{
1428 UNIMPLEMENTED();
1429 return true;
1430}
1431
1432bool ValidateDeleteRenderbuffersOES(Context *context, GLsizei n, const GLuint *renderbuffers)
1433{
1434 UNIMPLEMENTED();
1435 return true;
1436}
1437
1438bool ValidateBindFramebufferOES(Context *context, GLenum target, GLuint framebuffer)
1439{
1440 UNIMPLEMENTED();
1441 return true;
1442}
1443
1444bool ValidateBindRenderbufferOES(Context *context, GLenum target, GLuint renderbuffer)
1445{
1446 UNIMPLEMENTED();
1447 return true;
1448}
1449
1450bool ValidateCheckFramebufferStatusOES(Context *context, GLenum target)
1451{
1452 UNIMPLEMENTED();
1453 return true;
1454}
1455
1456bool ValidateFramebufferRenderbufferOES(Context *context,
1457 GLenum target,
1458 GLenum attachment,
1459 GLenum rbtarget,
1460 GLuint renderbuffer)
1461{
1462 UNIMPLEMENTED();
1463 return true;
1464}
1465
1466bool ValidateFramebufferTexture2DOES(Context *context,
1467 GLenum target,
1468 GLenum attachment,
1469 TextureTarget textarget,
1470 GLuint texture,
1471 GLint level)
1472{
1473 UNIMPLEMENTED();
1474 return true;
1475}
1476
1477bool ValidateGenerateMipmapOES(Context *context, TextureType target)
1478{
1479 UNIMPLEMENTED();
1480 return true;
1481}
1482
1483bool ValidateGetFramebufferAttachmentParameterivOES(Context *context,
1484 GLenum target,
1485 GLenum attachment,
1486 GLenum pname,
1487 GLint *params)
1488{
1489 UNIMPLEMENTED();
1490 return true;
1491}
1492
1493bool ValidateGetRenderbufferParameterivOES(Context *context,
1494 GLenum target,
1495 GLenum pname,
1496 GLint *params)
1497{
1498 UNIMPLEMENTED();
1499 return true;
1500}
1501
1502bool ValidateIsFramebufferOES(Context *context, GLuint framebuffer)
1503{
1504 UNIMPLEMENTED();
1505 return true;
1506}
1507
1508bool ValidateIsRenderbufferOES(Context *context, GLuint renderbuffer)
1509{
1510 UNIMPLEMENTED();
1511 return true;
1512}
1513
1514bool ValidateRenderbufferStorageOES(Context *context,
1515 GLenum target,
1516 GLint internalformat,
1517 GLsizei width,
1518 GLsizei height)
1519{
1520 UNIMPLEMENTED();
1521 return true;
1522}
1523
1524// GL_OES_texture_cube_map
1525
1526bool ValidateGetTexGenfvOES(Context *context, GLenum coord, GLenum pname, GLfloat *params)
1527{
1528 UNIMPLEMENTED();
1529 return true;
1530}
1531
1532bool ValidateGetTexGenivOES(Context *context, GLenum coord, GLenum pname, int *params)
1533{
1534 UNIMPLEMENTED();
1535 return true;
1536}
1537
1538bool ValidateGetTexGenxvOES(Context *context, GLenum coord, GLenum pname, GLfixed *params)
1539{
1540 UNIMPLEMENTED();
1541 return true;
1542}
1543
1544bool ValidateTexGenfvOES(Context *context, GLenum coord, GLenum pname, const GLfloat *params)
1545{
1546 UNIMPLEMENTED();
1547 return true;
1548}
1549
1550bool ValidateTexGenivOES(Context *context, GLenum coord, GLenum pname, const GLint *param)
1551{
1552 UNIMPLEMENTED();
1553 return true;
1554}
1555
1556bool ValidateTexGenxvOES(Context *context, GLenum coord, GLenum pname, const GLint *param)
1557{
1558 UNIMPLEMENTED();
1559 return true;
1560}
1561
1562bool ValidateTexGenfOES(Context *context, GLenum coord, GLenum pname, GLfloat param)
1563{
1564 UNIMPLEMENTED();
1565 return true;
1566}
1567
1568bool ValidateTexGeniOES(Context *context, GLenum coord, GLenum pname, GLint param)
1569{
1570 UNIMPLEMENTED();
1571 return true;
1572}
1573
1574bool ValidateTexGenxOES(Context *context, GLenum coord, GLenum pname, GLfixed param)
1575{
1576 UNIMPLEMENTED();
1577 return true;
1578}
Lingfeng Yang01074432018-04-16 10:19:51 -07001579
1580} // namespace gl