blob: a299065ff7f56f3b64231bdcb4b71f0419442a2f [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"
15#include "libANGLE/queryutils.h"
Lingfeng Yang038dd532018-03-29 17:31:52 -070016#include "libANGLE/validationES.h"
Lingfeng Yang13b708f2018-03-21 12:14:10 -070017
18#define ANGLE_VALIDATE_IS_GLES1(context) \
19 if (context->getClientMajorVersion() > 1) \
20 { \
21 ANGLE_VALIDATION_ERR(context, InvalidOperation(), GLES1Only); \
22 return false; \
23 }
24
Lingfeng Yang01074432018-04-16 10:19:51 -070025namespace gl
Lingfeng Yang13b708f2018-03-21 12:14:10 -070026{
27
Lingfeng Yangabb09f12018-04-16 10:43:53 -070028bool ValidateAlphaFuncCommon(Context *context, AlphaTestFunc func)
Lingfeng Yang13b708f2018-03-21 12:14:10 -070029{
30 switch (func)
31 {
Lingfeng Yangabb09f12018-04-16 10:43:53 -070032 case AlphaTestFunc::AlwaysPass:
33 case AlphaTestFunc::Equal:
34 case AlphaTestFunc::Gequal:
35 case AlphaTestFunc::Greater:
36 case AlphaTestFunc::Lequal:
37 case AlphaTestFunc::Less:
38 case AlphaTestFunc::Never:
39 case AlphaTestFunc::NotEqual:
Lingfeng Yang13b708f2018-03-21 12:14:10 -070040 return true;
41 default:
Lingfeng Yang01074432018-04-16 10:19:51 -070042 ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumNotSupported);
Lingfeng Yang13b708f2018-03-21 12:14:10 -070043 return false;
44 }
45}
46
Lingfeng Yangabb09f12018-04-16 10:43:53 -070047bool ValidateClientStateCommon(Context *context, ClientVertexArrayType arrayType)
Lingfeng Yang01074432018-04-16 10:19:51 -070048{
49 ANGLE_VALIDATE_IS_GLES1(context);
50 switch (arrayType)
51 {
Lingfeng Yangabb09f12018-04-16 10:43:53 -070052 case ClientVertexArrayType::Vertex:
53 case ClientVertexArrayType::Normal:
54 case ClientVertexArrayType::Color:
55 case ClientVertexArrayType::TextureCoord:
Lingfeng Yang01074432018-04-16 10:19:51 -070056 return true;
Lingfeng Yangabb09f12018-04-16 10:43:53 -070057 case ClientVertexArrayType::PointSize:
Lingfeng Yang01074432018-04-16 10:19:51 -070058 if (!context->getExtensions().pointSizeArray)
59 {
60 ANGLE_VALIDATION_ERR(context, InvalidEnum(), PointSizeArrayExtensionNotEnabled);
61 return false;
62 }
63 return true;
64 default:
65 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidClientState);
66 return false;
67 }
68}
69
Lingfeng Yangabb09f12018-04-16 10:43:53 -070070bool ValidateBuiltinVertexAttributeCommon(Context *context,
71 ClientVertexArrayType arrayType,
72 GLint size,
73 GLenum type,
74 GLsizei stride,
75 const void *pointer)
76{
77 ANGLE_VALIDATE_IS_GLES1(context);
78
79 if (stride < 0)
80 {
81 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidVertexPointerStride);
82 return false;
83 }
84
85 int minSize = 1;
86 int maxSize = 4;
87
88 switch (arrayType)
89 {
90 case ClientVertexArrayType::Vertex:
91 case ClientVertexArrayType::TextureCoord:
92 minSize = 2;
93 maxSize = 4;
94 break;
95 case ClientVertexArrayType::Normal:
96 minSize = 3;
97 maxSize = 3;
98 break;
99 case ClientVertexArrayType::Color:
100 minSize = 4;
101 maxSize = 4;
102 break;
103 case ClientVertexArrayType::PointSize:
104 if (!context->getExtensions().pointSizeArray)
105 {
106 ANGLE_VALIDATION_ERR(context, InvalidEnum(), PointSizeArrayExtensionNotEnabled);
107 return false;
108 }
109
110 minSize = 1;
111 maxSize = 1;
112 break;
113 default:
114 UNREACHABLE();
115 return false;
116 }
117
118 if (size < minSize || size > maxSize)
119 {
120 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidVertexPointerSize);
121 return false;
122 }
123
124 switch (type)
125 {
126 case GL_BYTE:
127 if (arrayType == ClientVertexArrayType::PointSize)
128 {
129 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidVertexPointerType);
130 return false;
131 }
132 break;
133 case GL_SHORT:
134 if (arrayType == ClientVertexArrayType::PointSize ||
135 arrayType == ClientVertexArrayType::Color)
136 {
137 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidVertexPointerType);
138 return false;
139 }
140 break;
141 case GL_FIXED:
142 case GL_FLOAT:
143 break;
144 default:
145 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidVertexPointerType);
146 return false;
147 }
148
149 return true;
150}
151
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700152bool ValidateLightCaps(Context *context, GLenum light)
153{
154 if (light < GL_LIGHT0 || light >= GL_LIGHT0 + context->getCaps().maxLights)
155 {
156 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLight);
157 return false;
158 }
159
160 return true;
161}
162
163bool ValidateLightCommon(Context *context,
164 GLenum light,
165 LightParameter pname,
166 const GLfloat *params)
167{
168
169 ANGLE_VALIDATE_IS_GLES1(context);
170
171 if (!ValidateLightCaps(context, light))
172 {
173 return false;
174 }
175
176 switch (pname)
177 {
178 case LightParameter::Ambient:
179 case LightParameter::Diffuse:
180 case LightParameter::Specular:
181 case LightParameter::Position:
182 case LightParameter::SpotDirection:
183 return true;
184 case LightParameter::SpotExponent:
185 if (params[0] < 0.0f || params[0] > 128.0f)
186 {
187 ANGLE_VALIDATION_ERR(context, InvalidValue(), LightParameterOutOfRange);
188 return false;
189 }
190 return true;
191 case LightParameter::SpotCutoff:
192 if (params[0] == 180.0f)
193 {
194 return true;
195 }
196 if (params[0] < 0.0f || params[0] > 90.0f)
197 {
198 ANGLE_VALIDATION_ERR(context, InvalidValue(), LightParameterOutOfRange);
199 return false;
200 }
201 return true;
202 case LightParameter::ConstantAttenuation:
203 case LightParameter::LinearAttenuation:
204 case LightParameter::QuadraticAttenuation:
205 if (params[0] < 0.0f)
206 {
207 ANGLE_VALIDATION_ERR(context, InvalidValue(), LightParameterOutOfRange);
208 return false;
209 }
210 return true;
211 default:
212 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightParameter);
213 return false;
214 }
215}
216
217bool ValidateLightSingleComponent(Context *context,
218 GLenum light,
219 LightParameter pname,
220 GLfloat param)
221{
222 if (!ValidateLightCommon(context, light, pname, &param))
223 {
224 return false;
225 }
226
227 if (GetLightParameterCount(pname) > 1)
228 {
229 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightParameter);
230 return false;
231 }
232
233 return true;
234}
235
236bool ValidateMaterialCommon(Context *context,
237 GLenum face,
238 MaterialParameter pname,
239 const GLfloat *params)
240{
241 ANGLE_VALIDATE_IS_GLES1(context);
242
243 if (face != GL_FRONT_AND_BACK)
244 {
245 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMaterialFace);
246 return false;
247 }
248
249 switch (pname)
250 {
251 case MaterialParameter::Ambient:
252 case MaterialParameter::Diffuse:
253 case MaterialParameter::Specular:
254 case MaterialParameter::Emission:
255 return true;
256 case MaterialParameter::Shininess:
257 if (params[0] < 0.0f || params[0] > 128.0f)
258 {
259 ANGLE_VALIDATION_ERR(context, InvalidValue(), MaterialParameterOutOfRange);
260 return false;
261 }
262 return true;
263 default:
264 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMaterialParameter);
265 return false;
266 }
267}
268
269bool ValidateMaterialSingleComponent(Context *context,
270 GLenum face,
271 MaterialParameter pname,
272 GLfloat param)
273{
274 if (!ValidateMaterialCommon(context, face, pname, &param))
275 {
276 return false;
277 }
278
279 if (GetMaterialParameterCount(pname) > 1)
280 {
281 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMaterialParameter);
282 return false;
283 }
284
285 return true;
286}
287
288bool ValidateLightModelCommon(Context *context, GLenum pname)
289{
290 ANGLE_VALIDATE_IS_GLES1(context);
291 switch (pname)
292 {
293 case GL_LIGHT_MODEL_AMBIENT:
294 case GL_LIGHT_MODEL_TWO_SIDE:
295 return true;
296 default:
297 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightModelParameter);
298 return false;
299 }
300}
301
302bool ValidateLightModelSingleComponent(Context *context, GLenum pname)
303{
304 if (!ValidateLightModelCommon(context, pname))
305 {
306 return false;
307 }
308
309 switch (pname)
310 {
311 case GL_LIGHT_MODEL_TWO_SIDE:
312 return true;
313 default:
314 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidLightModelParameter);
315 return false;
316 }
317}
318
Lingfeng Yang01074432018-04-16 10:19:51 -0700319} // namespace gl
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500320
321namespace gl
322{
323
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700324bool ValidateAlphaFunc(Context *context, AlphaTestFunc func, GLfloat ref)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500325{
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700326 ANGLE_VALIDATE_IS_GLES1(context);
327 return ValidateAlphaFuncCommon(context, func);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500328}
329
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700330bool ValidateAlphaFuncx(Context *context, AlphaTestFunc func, GLfixed ref)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500331{
Lingfeng Yang13b708f2018-03-21 12:14:10 -0700332 ANGLE_VALIDATE_IS_GLES1(context);
333 return ValidateAlphaFuncCommon(context, func);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500334}
335
336bool ValidateClearColorx(Context *context, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
337{
338 UNIMPLEMENTED();
339 return true;
340}
341
342bool ValidateClearDepthx(Context *context, GLfixed depth)
343{
344 UNIMPLEMENTED();
345 return true;
346}
347
348bool ValidateClientActiveTexture(Context *context, GLenum texture)
349{
Lingfeng Yang96310cd2018-03-28 11:56:28 -0700350 ANGLE_VALIDATE_IS_GLES1(context);
Lingfeng Yang038dd532018-03-29 17:31:52 -0700351 return ValidateMultitextureUnit(context, texture);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500352}
353
354bool ValidateClipPlanef(Context *context, GLenum p, const GLfloat *eqn)
355{
356 UNIMPLEMENTED();
357 return true;
358}
359
360bool ValidateClipPlanex(Context *context, GLenum plane, const GLfixed *equation)
361{
362 UNIMPLEMENTED();
363 return true;
364}
365
366bool ValidateColor4f(Context *context, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
367{
Lingfeng Yanga43994c2018-03-29 07:21:41 -0700368 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500369 return true;
370}
371
372bool ValidateColor4ub(Context *context, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
373{
Lingfeng Yanga43994c2018-03-29 07:21:41 -0700374 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500375 return true;
376}
377
378bool ValidateColor4x(Context *context, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
379{
Lingfeng Yanga43994c2018-03-29 07:21:41 -0700380 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500381 return true;
382}
383
384bool ValidateColorPointer(Context *context,
385 GLint size,
386 GLenum type,
387 GLsizei stride,
388 const void *pointer)
389{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700390 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Color, size, type,
391 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500392}
393
394bool ValidateCullFace(Context *context, GLenum mode)
395{
396 UNIMPLEMENTED();
397 return true;
398}
399
400bool ValidateDepthRangex(Context *context, GLfixed n, GLfixed f)
401{
402 UNIMPLEMENTED();
403 return true;
404}
405
Lingfeng Yang01074432018-04-16 10:19:51 -0700406bool ValidateDisableClientState(Context *context, ClientVertexArrayType arrayType)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500407{
Lingfeng Yang01074432018-04-16 10:19:51 -0700408 return ValidateClientStateCommon(context, arrayType);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500409}
410
Lingfeng Yang01074432018-04-16 10:19:51 -0700411bool ValidateEnableClientState(Context *context, ClientVertexArrayType arrayType)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500412{
Lingfeng Yang01074432018-04-16 10:19:51 -0700413 return ValidateClientStateCommon(context, arrayType);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500414}
415
416bool ValidateFogf(Context *context, GLenum pname, GLfloat param)
417{
418 UNIMPLEMENTED();
419 return true;
420}
421
422bool ValidateFogfv(Context *context, GLenum pname, const GLfloat *params)
423{
424 UNIMPLEMENTED();
425 return true;
426}
427
428bool ValidateFogx(Context *context, GLenum pname, GLfixed param)
429{
430 UNIMPLEMENTED();
431 return true;
432}
433
434bool ValidateFogxv(Context *context, GLenum pname, const GLfixed *param)
435{
436 UNIMPLEMENTED();
437 return true;
438}
439
440bool ValidateFrustumf(Context *context,
441 GLfloat l,
442 GLfloat r,
443 GLfloat b,
444 GLfloat t,
445 GLfloat n,
446 GLfloat f)
447{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700448 ANGLE_VALIDATE_IS_GLES1(context);
449 if (l == r || b == t || n == f || n <= 0.0f || f <= 0.0f)
450 {
451 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
452 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500453 return true;
454}
455
456bool ValidateFrustumx(Context *context,
457 GLfixed l,
458 GLfixed r,
459 GLfixed b,
460 GLfixed t,
461 GLfixed n,
462 GLfixed f)
463{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700464 ANGLE_VALIDATE_IS_GLES1(context);
465 if (l == r || b == t || n == f || n <= 0 || f <= 0)
466 {
467 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
468 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500469 return true;
470}
471
472bool ValidateGetBufferParameteriv(Context *context, GLenum target, GLenum pname, GLint *params)
473{
474 UNIMPLEMENTED();
475 return true;
476}
477
478bool ValidateGetClipPlanef(Context *context, GLenum plane, GLfloat *equation)
479{
480 UNIMPLEMENTED();
481 return true;
482}
483
484bool ValidateGetClipPlanex(Context *context, GLenum plane, GLfixed *equation)
485{
486 UNIMPLEMENTED();
487 return true;
488}
489
490bool ValidateGetFixedv(Context *context, GLenum pname, GLfixed *params)
491{
492 UNIMPLEMENTED();
493 return true;
494}
495
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700496bool ValidateGetLightfv(Context *context, GLenum light, LightParameter pname, GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500497{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700498 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
499 return ValidateLightCommon(context, light, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500500}
501
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700502bool ValidateGetLightxv(Context *context, GLenum light, LightParameter pname, GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500503{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700504 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
505 return ValidateLightCommon(context, light, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500506}
507
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700508bool ValidateGetMaterialfv(Context *context, GLenum face, MaterialParameter pname, GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500509{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700510 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
511 return ValidateMaterialCommon(context, face, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500512}
513
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700514bool ValidateGetMaterialxv(Context *context, GLenum face, MaterialParameter pname, GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500515{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700516 GLfloat dummyParams[4] = {0.0f, 0.0f, 0.0f, 0.0f};
517 return ValidateMaterialCommon(context, face, pname, dummyParams);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500518}
519
520bool ValidateGetPointerv(Context *context, GLenum pname, void **params)
521{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700522 ANGLE_VALIDATE_IS_GLES1(context);
523 switch (pname)
524 {
525 case GL_VERTEX_ARRAY_POINTER:
526 case GL_NORMAL_ARRAY_POINTER:
527 case GL_COLOR_ARRAY_POINTER:
528 case GL_TEXTURE_COORD_ARRAY_POINTER:
529 case GL_POINT_SIZE_ARRAY_POINTER_OES:
530 return true;
531 default:
532 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPointerQuery);
533 return false;
534 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500535}
536
537bool ValidateGetTexEnvfv(Context *context, GLenum target, GLenum pname, GLfloat *params)
538{
539 UNIMPLEMENTED();
540 return true;
541}
542
543bool ValidateGetTexEnviv(Context *context, GLenum target, GLenum pname, GLint *params)
544{
545 UNIMPLEMENTED();
546 return true;
547}
548
549bool ValidateGetTexEnvxv(Context *context, GLenum target, GLenum pname, GLfixed *params)
550{
551 UNIMPLEMENTED();
552 return true;
553}
554
Corentin Wallezf0e89be2017-11-08 14:00:32 -0800555bool ValidateGetTexParameterxv(Context *context, TextureType target, GLenum pname, GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500556{
557 UNIMPLEMENTED();
558 return true;
559}
560
561bool ValidateLightModelf(Context *context, GLenum pname, GLfloat param)
562{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700563 return ValidateLightModelSingleComponent(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500564}
565
566bool ValidateLightModelfv(Context *context, GLenum pname, const GLfloat *params)
567{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700568 return ValidateLightModelCommon(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500569}
570
571bool ValidateLightModelx(Context *context, GLenum pname, GLfixed param)
572{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700573 return ValidateLightModelSingleComponent(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500574}
575
576bool ValidateLightModelxv(Context *context, GLenum pname, const GLfixed *param)
577{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700578 return ValidateLightModelCommon(context, pname);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500579}
580
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700581bool ValidateLightf(Context *context, GLenum light, LightParameter pname, GLfloat param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500582{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700583 return ValidateLightSingleComponent(context, light, pname, param);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500584}
585
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700586bool ValidateLightfv(Context *context, GLenum light, LightParameter pname, const GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500587{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700588 return ValidateLightCommon(context, light, pname, params);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500589}
590
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700591bool ValidateLightx(Context *context, GLenum light, LightParameter pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500592{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700593 return ValidateLightSingleComponent(context, light, pname, FixedToFloat(param));
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500594}
595
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700596bool ValidateLightxv(Context *context, GLenum light, LightParameter pname, const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500597{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700598 GLfloat paramsf[4];
599 for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
600 {
601 paramsf[i] = FixedToFloat(params[i]);
602 }
603
604 return ValidateLightCommon(context, light, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500605}
606
607bool ValidateLineWidthx(Context *context, GLfixed width)
608{
609 UNIMPLEMENTED();
610 return true;
611}
612
613bool ValidateLoadIdentity(Context *context)
614{
Lingfeng Yang3a41af62018-04-09 07:28:56 -0700615 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500616 return true;
617}
618
619bool ValidateLoadMatrixf(Context *context, const GLfloat *m)
620{
Lingfeng Yang3a41af62018-04-09 07:28:56 -0700621 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500622 return true;
623}
624
625bool ValidateLoadMatrixx(Context *context, const GLfixed *m)
626{
Lingfeng Yang3a41af62018-04-09 07:28:56 -0700627 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500628 return true;
629}
630
631bool ValidateLogicOp(Context *context, GLenum opcode)
632{
633 UNIMPLEMENTED();
634 return true;
635}
636
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700637bool ValidateMaterialf(Context *context, GLenum face, MaterialParameter pname, GLfloat param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500638{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700639 return ValidateMaterialSingleComponent(context, face, pname, param);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500640}
641
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700642bool ValidateMaterialfv(Context *context,
643 GLenum face,
644 MaterialParameter pname,
645 const GLfloat *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500646{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700647 return ValidateMaterialCommon(context, face, pname, params);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500648}
649
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700650bool ValidateMaterialx(Context *context, GLenum face, MaterialParameter pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500651{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700652 return ValidateMaterialSingleComponent(context, face, pname, FixedToFloat(param));
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500653}
654
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700655bool ValidateMaterialxv(Context *context,
656 GLenum face,
657 MaterialParameter pname,
658 const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500659{
Lingfeng Yangd0febe72018-05-17 22:36:52 -0700660 GLfloat paramsf[4];
661
662 for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
663 {
664 paramsf[i] = FixedToFloat(params[i]);
665 }
666
667 return ValidateMaterialCommon(context, face, pname, paramsf);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500668}
669
Lingfeng Yang00af4632018-04-02 12:42:24 -0700670bool ValidateMatrixMode(Context *context, MatrixType mode)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500671{
Lingfeng Yangd2488ab2018-04-04 09:25:48 -0700672 ANGLE_VALIDATE_IS_GLES1(context);
673 switch (mode)
674 {
675 case MatrixType::Projection:
676 case MatrixType::Modelview:
677 case MatrixType::Texture:
678 return true;
679 default:
680 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMatrixMode);
681 return false;
682 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500683}
684
685bool ValidateMultMatrixf(Context *context, const GLfloat *m)
686{
Lingfeng Yang568fc392018-04-09 07:57:23 -0700687 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500688 return true;
689}
690
691bool ValidateMultMatrixx(Context *context, const GLfixed *m)
692{
Lingfeng Yang568fc392018-04-09 07:57:23 -0700693 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500694 return true;
695}
696
697bool ValidateMultiTexCoord4f(Context *context,
698 GLenum target,
699 GLfloat s,
700 GLfloat t,
701 GLfloat r,
702 GLfloat q)
703{
Lingfeng Yang038dd532018-03-29 17:31:52 -0700704 ANGLE_VALIDATE_IS_GLES1(context);
705 return ValidateMultitextureUnit(context, target);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500706}
707
708bool ValidateMultiTexCoord4x(Context *context,
Lingfeng Yang038dd532018-03-29 17:31:52 -0700709 GLenum target,
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500710 GLfixed s,
711 GLfixed t,
712 GLfixed r,
713 GLfixed q)
714{
Lingfeng Yang038dd532018-03-29 17:31:52 -0700715 ANGLE_VALIDATE_IS_GLES1(context);
716 return ValidateMultitextureUnit(context, target);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500717}
718
719bool ValidateNormal3f(Context *context, GLfloat nx, GLfloat ny, GLfloat nz)
720{
Lingfeng Yang5a7e61b2018-03-29 16:50:32 -0700721 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500722 return true;
723}
724
725bool ValidateNormal3x(Context *context, GLfixed nx, GLfixed ny, GLfixed nz)
726{
Lingfeng Yang5a7e61b2018-03-29 16:50:32 -0700727 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500728 return true;
729}
730
731bool ValidateNormalPointer(Context *context, GLenum type, GLsizei stride, const void *pointer)
732{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700733 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Normal, 3, type,
734 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500735}
736
737bool ValidateOrthof(Context *context,
738 GLfloat l,
739 GLfloat r,
740 GLfloat b,
741 GLfloat t,
742 GLfloat n,
743 GLfloat f)
744{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700745 ANGLE_VALIDATE_IS_GLES1(context);
746 if (l == r || b == t || n == f || n <= 0.0f || f <= 0.0f)
747 {
748 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
749 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500750 return true;
751}
752
753bool ValidateOrthox(Context *context,
754 GLfixed l,
755 GLfixed r,
756 GLfixed b,
757 GLfixed t,
758 GLfixed n,
759 GLfixed f)
760{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700761 ANGLE_VALIDATE_IS_GLES1(context);
762 if (l == r || b == t || n == f || n <= 0 || f <= 0)
763 {
764 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidProjectionMatrix);
765 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500766 return true;
767}
768
769bool ValidatePointParameterf(Context *context, GLenum pname, GLfloat param)
770{
771 UNIMPLEMENTED();
772 return true;
773}
774
775bool ValidatePointParameterfv(Context *context, GLenum pname, const GLfloat *params)
776{
777 UNIMPLEMENTED();
778 return true;
779}
780
781bool ValidatePointParameterx(Context *context, GLenum pname, GLfixed param)
782{
783 UNIMPLEMENTED();
784 return true;
785}
786
787bool ValidatePointParameterxv(Context *context, GLenum pname, const GLfixed *params)
788{
789 UNIMPLEMENTED();
790 return true;
791}
792
793bool ValidatePointSize(Context *context, GLfloat size)
794{
795 UNIMPLEMENTED();
796 return true;
797}
798
799bool ValidatePointSizex(Context *context, GLfixed size)
800{
801 UNIMPLEMENTED();
802 return true;
803}
804
805bool ValidatePolygonOffsetx(Context *context, GLfixed factor, GLfixed units)
806{
807 UNIMPLEMENTED();
808 return true;
809}
810
811bool ValidatePopMatrix(Context *context)
812{
Lingfeng Yange547aac2018-04-05 09:39:20 -0700813 ANGLE_VALIDATE_IS_GLES1(context);
814 const auto &stack = context->getGLState().gles1().currentMatrixStack();
815 if (stack.size() == 1)
816 {
817 ANGLE_VALIDATION_ERR(context, StackUnderflow(), MatrixStackUnderflow);
818 return false;
819 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500820 return true;
821}
822
823bool ValidatePushMatrix(Context *context)
824{
Lingfeng Yange547aac2018-04-05 09:39:20 -0700825 ANGLE_VALIDATE_IS_GLES1(context);
826 const auto &stack = context->getGLState().gles1().currentMatrixStack();
827 if (stack.size() == stack.max_size())
828 {
829 ANGLE_VALIDATION_ERR(context, StackOverflow(), MatrixStackOverflow);
830 return false;
831 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500832 return true;
833}
834
835bool ValidateRotatef(Context *context, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
836{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700837 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500838 return true;
839}
840
841bool ValidateRotatex(Context *context, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
842{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700843 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500844 return true;
845}
846
847bool ValidateSampleCoveragex(Context *context, GLclampx value, GLboolean invert)
848{
849 UNIMPLEMENTED();
850 return true;
851}
852
853bool ValidateScalef(Context *context, GLfloat x, GLfloat y, GLfloat z)
854{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700855 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500856 return true;
857}
858
859bool ValidateScalex(Context *context, GLfixed x, GLfixed y, GLfixed z)
860{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700861 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500862 return true;
863}
864
Lingfeng Yanga0cfa872018-05-30 21:12:17 -0700865bool ValidateShadeModel(Context *context, ShadingModel mode)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500866{
Lingfeng Yanga0cfa872018-05-30 21:12:17 -0700867 ANGLE_VALIDATE_IS_GLES1(context);
868 switch (mode)
869 {
870 case ShadingModel::Flat:
871 case ShadingModel::Smooth:
872 return true;
873 default:
874 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidShadingModel);
875 return false;
876 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500877}
878
879bool ValidateTexCoordPointer(Context *context,
880 GLint size,
881 GLenum type,
882 GLsizei stride,
883 const void *pointer)
884{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700885 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::TextureCoord, size,
886 type, stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500887}
888
889bool ValidateTexEnvf(Context *context, GLenum target, GLenum pname, GLfloat param)
890{
891 UNIMPLEMENTED();
892 return true;
893}
894
895bool ValidateTexEnvfv(Context *context, GLenum target, GLenum pname, const GLfloat *params)
896{
897 UNIMPLEMENTED();
898 return true;
899}
900
901bool ValidateTexEnvi(Context *context, GLenum target, GLenum pname, GLint param)
902{
903 UNIMPLEMENTED();
904 return true;
905}
906
907bool ValidateTexEnviv(Context *context, GLenum target, GLenum pname, const GLint *params)
908{
909 UNIMPLEMENTED();
910 return true;
911}
912
913bool ValidateTexEnvx(Context *context, GLenum target, GLenum pname, GLfixed param)
914{
915 UNIMPLEMENTED();
916 return true;
917}
918
919bool ValidateTexEnvxv(Context *context, GLenum target, GLenum pname, const GLfixed *params)
920{
921 UNIMPLEMENTED();
922 return true;
923}
924
Corentin Wallezf0e89be2017-11-08 14:00:32 -0800925bool ValidateTexParameterx(Context *context, TextureType target, GLenum pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500926{
927 UNIMPLEMENTED();
928 return true;
929}
930
Corentin Wallezf0e89be2017-11-08 14:00:32 -0800931bool ValidateTexParameterxv(Context *context,
932 TextureType target,
933 GLenum pname,
934 const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500935{
936 UNIMPLEMENTED();
937 return true;
938}
939
940bool ValidateTranslatef(Context *context, GLfloat x, GLfloat y, GLfloat z)
941{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700942 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500943 return true;
944}
945
946bool ValidateTranslatex(Context *context, GLfixed x, GLfixed y, GLfixed z)
947{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700948 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500949 return true;
950}
951
952bool ValidateVertexPointer(Context *context,
953 GLint size,
954 GLenum type,
955 GLsizei stride,
956 const void *pointer)
957{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700958 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Vertex, size, type,
959 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500960}
961
962bool ValidateDrawTexfOES(Context *context,
963 GLfloat x,
964 GLfloat y,
965 GLfloat z,
966 GLfloat width,
967 GLfloat height)
968{
969 UNIMPLEMENTED();
970 return true;
971}
972
973bool ValidateDrawTexfvOES(Context *context, const GLfloat *coords)
974{
975 UNIMPLEMENTED();
976 return true;
977}
978
979bool ValidateDrawTexiOES(Context *context, GLint x, GLint y, GLint z, GLint width, GLint height)
980{
981 UNIMPLEMENTED();
982 return true;
983}
984
985bool ValidateDrawTexivOES(Context *context, const GLint *coords)
986{
987 UNIMPLEMENTED();
988 return true;
989}
990
991bool ValidateDrawTexsOES(Context *context,
992 GLshort x,
993 GLshort y,
994 GLshort z,
995 GLshort width,
996 GLshort height)
997{
998 UNIMPLEMENTED();
999 return true;
1000}
1001
1002bool ValidateDrawTexsvOES(Context *context, const GLshort *coords)
1003{
1004 UNIMPLEMENTED();
1005 return true;
1006}
1007
1008bool ValidateDrawTexxOES(Context *context,
1009 GLfixed x,
1010 GLfixed y,
1011 GLfixed z,
1012 GLfixed width,
1013 GLfixed height)
1014{
1015 UNIMPLEMENTED();
1016 return true;
1017}
1018
1019bool ValidateDrawTexxvOES(Context *context, const GLfixed *coords)
1020{
1021 UNIMPLEMENTED();
1022 return true;
1023}
1024
1025bool ValidateCurrentPaletteMatrixOES(Context *context, GLuint matrixpaletteindex)
1026{
1027 UNIMPLEMENTED();
1028 return true;
1029}
1030
1031bool ValidateLoadPaletteFromModelViewMatrixOES(Context *context)
1032{
1033 UNIMPLEMENTED();
1034 return true;
1035}
1036
1037bool ValidateMatrixIndexPointerOES(Context *context,
1038 GLint size,
1039 GLenum type,
1040 GLsizei stride,
1041 const void *pointer)
1042{
1043 UNIMPLEMENTED();
1044 return true;
1045}
1046
1047bool ValidateWeightPointerOES(Context *context,
1048 GLint size,
1049 GLenum type,
1050 GLsizei stride,
1051 const void *pointer)
1052{
1053 UNIMPLEMENTED();
1054 return true;
1055}
1056
1057bool ValidatePointSizePointerOES(Context *context, GLenum type, GLsizei stride, const void *pointer)
1058{
Lingfeng Yangabb09f12018-04-16 10:43:53 -07001059 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::PointSize, 1, type,
1060 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001061}
1062
1063bool ValidateQueryMatrixxOES(Context *context, GLfixed *mantissa, GLint *exponent)
1064{
1065 UNIMPLEMENTED();
1066 return true;
1067}
Lingfeng Yanga0648782018-03-12 14:45:25 -07001068
1069bool ValidateGenFramebuffersOES(Context *context, GLsizei n, GLuint *framebuffers)
1070{
1071 UNIMPLEMENTED();
1072 return true;
1073}
1074
1075bool ValidateDeleteFramebuffersOES(Context *context, GLsizei n, const GLuint *framebuffers)
1076{
1077 UNIMPLEMENTED();
1078 return true;
1079}
1080
1081bool ValidateGenRenderbuffersOES(Context *context, GLsizei n, GLuint *renderbuffers)
1082{
1083 UNIMPLEMENTED();
1084 return true;
1085}
1086
1087bool ValidateDeleteRenderbuffersOES(Context *context, GLsizei n, const GLuint *renderbuffers)
1088{
1089 UNIMPLEMENTED();
1090 return true;
1091}
1092
1093bool ValidateBindFramebufferOES(Context *context, GLenum target, GLuint framebuffer)
1094{
1095 UNIMPLEMENTED();
1096 return true;
1097}
1098
1099bool ValidateBindRenderbufferOES(Context *context, GLenum target, GLuint renderbuffer)
1100{
1101 UNIMPLEMENTED();
1102 return true;
1103}
1104
1105bool ValidateCheckFramebufferStatusOES(Context *context, GLenum target)
1106{
1107 UNIMPLEMENTED();
1108 return true;
1109}
1110
1111bool ValidateFramebufferRenderbufferOES(Context *context,
1112 GLenum target,
1113 GLenum attachment,
1114 GLenum rbtarget,
1115 GLuint renderbuffer)
1116{
1117 UNIMPLEMENTED();
1118 return true;
1119}
1120
1121bool ValidateFramebufferTexture2DOES(Context *context,
1122 GLenum target,
1123 GLenum attachment,
1124 TextureTarget textarget,
1125 GLuint texture,
1126 GLint level)
1127{
1128 UNIMPLEMENTED();
1129 return true;
1130}
1131
1132bool ValidateGenerateMipmapOES(Context *context, TextureType target)
1133{
1134 UNIMPLEMENTED();
1135 return true;
1136}
1137
1138bool ValidateGetFramebufferAttachmentParameterivOES(Context *context,
1139 GLenum target,
1140 GLenum attachment,
1141 GLenum pname,
1142 GLint *params)
1143{
1144 UNIMPLEMENTED();
1145 return true;
1146}
1147
1148bool ValidateGetRenderbufferParameterivOES(Context *context,
1149 GLenum target,
1150 GLenum pname,
1151 GLint *params)
1152{
1153 UNIMPLEMENTED();
1154 return true;
1155}
1156
1157bool ValidateIsFramebufferOES(Context *context, GLuint framebuffer)
1158{
1159 UNIMPLEMENTED();
1160 return true;
1161}
1162
1163bool ValidateIsRenderbufferOES(Context *context, GLuint renderbuffer)
1164{
1165 UNIMPLEMENTED();
1166 return true;
1167}
1168
1169bool ValidateRenderbufferStorageOES(Context *context,
1170 GLenum target,
1171 GLint internalformat,
1172 GLsizei width,
1173 GLsizei height)
1174{
1175 UNIMPLEMENTED();
1176 return true;
1177}
1178
1179// GL_OES_texture_cube_map
1180
1181bool ValidateGetTexGenfvOES(Context *context, GLenum coord, GLenum pname, GLfloat *params)
1182{
1183 UNIMPLEMENTED();
1184 return true;
1185}
1186
1187bool ValidateGetTexGenivOES(Context *context, GLenum coord, GLenum pname, int *params)
1188{
1189 UNIMPLEMENTED();
1190 return true;
1191}
1192
1193bool ValidateGetTexGenxvOES(Context *context, GLenum coord, GLenum pname, GLfixed *params)
1194{
1195 UNIMPLEMENTED();
1196 return true;
1197}
1198
1199bool ValidateTexGenfvOES(Context *context, GLenum coord, GLenum pname, const GLfloat *params)
1200{
1201 UNIMPLEMENTED();
1202 return true;
1203}
1204
1205bool ValidateTexGenivOES(Context *context, GLenum coord, GLenum pname, const GLint *param)
1206{
1207 UNIMPLEMENTED();
1208 return true;
1209}
1210
1211bool ValidateTexGenxvOES(Context *context, GLenum coord, GLenum pname, const GLint *param)
1212{
1213 UNIMPLEMENTED();
1214 return true;
1215}
1216
1217bool ValidateTexGenfOES(Context *context, GLenum coord, GLenum pname, GLfloat param)
1218{
1219 UNIMPLEMENTED();
1220 return true;
1221}
1222
1223bool ValidateTexGeniOES(Context *context, GLenum coord, GLenum pname, GLint param)
1224{
1225 UNIMPLEMENTED();
1226 return true;
1227}
1228
1229bool ValidateTexGenxOES(Context *context, GLenum coord, GLenum pname, GLfixed param)
1230{
1231 UNIMPLEMENTED();
1232 return true;
1233}
Lingfeng Yang01074432018-04-16 10:19:51 -07001234
1235} // namespace gl