blob: 10d1cbeaf12fbf9b48746276bf8a3391a8afea29 [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
865bool ValidateShadeModel(Context *context, GLenum mode)
866{
867 UNIMPLEMENTED();
868 return true;
869}
870
871bool ValidateTexCoordPointer(Context *context,
872 GLint size,
873 GLenum type,
874 GLsizei stride,
875 const void *pointer)
876{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700877 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::TextureCoord, size,
878 type, stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500879}
880
881bool ValidateTexEnvf(Context *context, GLenum target, GLenum pname, GLfloat param)
882{
883 UNIMPLEMENTED();
884 return true;
885}
886
887bool ValidateTexEnvfv(Context *context, GLenum target, GLenum pname, const GLfloat *params)
888{
889 UNIMPLEMENTED();
890 return true;
891}
892
893bool ValidateTexEnvi(Context *context, GLenum target, GLenum pname, GLint param)
894{
895 UNIMPLEMENTED();
896 return true;
897}
898
899bool ValidateTexEnviv(Context *context, GLenum target, GLenum pname, const GLint *params)
900{
901 UNIMPLEMENTED();
902 return true;
903}
904
905bool ValidateTexEnvx(Context *context, GLenum target, GLenum pname, GLfixed param)
906{
907 UNIMPLEMENTED();
908 return true;
909}
910
911bool ValidateTexEnvxv(Context *context, GLenum target, GLenum pname, const GLfixed *params)
912{
913 UNIMPLEMENTED();
914 return true;
915}
916
Corentin Wallezf0e89be2017-11-08 14:00:32 -0800917bool ValidateTexParameterx(Context *context, TextureType target, GLenum pname, GLfixed param)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500918{
919 UNIMPLEMENTED();
920 return true;
921}
922
Corentin Wallezf0e89be2017-11-08 14:00:32 -0800923bool ValidateTexParameterxv(Context *context,
924 TextureType target,
925 GLenum pname,
926 const GLfixed *params)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500927{
928 UNIMPLEMENTED();
929 return true;
930}
931
932bool ValidateTranslatef(Context *context, GLfloat x, GLfloat y, GLfloat z)
933{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700934 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500935 return true;
936}
937
938bool ValidateTranslatex(Context *context, GLfixed x, GLfixed y, GLfixed z)
939{
Lingfeng Yangbb5ce5c2018-04-09 08:08:46 -0700940 ANGLE_VALIDATE_IS_GLES1(context);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500941 return true;
942}
943
944bool ValidateVertexPointer(Context *context,
945 GLint size,
946 GLenum type,
947 GLsizei stride,
948 const void *pointer)
949{
Lingfeng Yangabb09f12018-04-16 10:43:53 -0700950 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::Vertex, size, type,
951 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500952}
953
954bool ValidateDrawTexfOES(Context *context,
955 GLfloat x,
956 GLfloat y,
957 GLfloat z,
958 GLfloat width,
959 GLfloat height)
960{
961 UNIMPLEMENTED();
962 return true;
963}
964
965bool ValidateDrawTexfvOES(Context *context, const GLfloat *coords)
966{
967 UNIMPLEMENTED();
968 return true;
969}
970
971bool ValidateDrawTexiOES(Context *context, GLint x, GLint y, GLint z, GLint width, GLint height)
972{
973 UNIMPLEMENTED();
974 return true;
975}
976
977bool ValidateDrawTexivOES(Context *context, const GLint *coords)
978{
979 UNIMPLEMENTED();
980 return true;
981}
982
983bool ValidateDrawTexsOES(Context *context,
984 GLshort x,
985 GLshort y,
986 GLshort z,
987 GLshort width,
988 GLshort height)
989{
990 UNIMPLEMENTED();
991 return true;
992}
993
994bool ValidateDrawTexsvOES(Context *context, const GLshort *coords)
995{
996 UNIMPLEMENTED();
997 return true;
998}
999
1000bool ValidateDrawTexxOES(Context *context,
1001 GLfixed x,
1002 GLfixed y,
1003 GLfixed z,
1004 GLfixed width,
1005 GLfixed height)
1006{
1007 UNIMPLEMENTED();
1008 return true;
1009}
1010
1011bool ValidateDrawTexxvOES(Context *context, const GLfixed *coords)
1012{
1013 UNIMPLEMENTED();
1014 return true;
1015}
1016
1017bool ValidateCurrentPaletteMatrixOES(Context *context, GLuint matrixpaletteindex)
1018{
1019 UNIMPLEMENTED();
1020 return true;
1021}
1022
1023bool ValidateLoadPaletteFromModelViewMatrixOES(Context *context)
1024{
1025 UNIMPLEMENTED();
1026 return true;
1027}
1028
1029bool ValidateMatrixIndexPointerOES(Context *context,
1030 GLint size,
1031 GLenum type,
1032 GLsizei stride,
1033 const void *pointer)
1034{
1035 UNIMPLEMENTED();
1036 return true;
1037}
1038
1039bool ValidateWeightPointerOES(Context *context,
1040 GLint size,
1041 GLenum type,
1042 GLsizei stride,
1043 const void *pointer)
1044{
1045 UNIMPLEMENTED();
1046 return true;
1047}
1048
1049bool ValidatePointSizePointerOES(Context *context, GLenum type, GLsizei stride, const void *pointer)
1050{
Lingfeng Yangabb09f12018-04-16 10:43:53 -07001051 return ValidateBuiltinVertexAttributeCommon(context, ClientVertexArrayType::PointSize, 1, type,
1052 stride, pointer);
Geoff Lang2aaa7b42018-01-12 17:17:27 -05001053}
1054
1055bool ValidateQueryMatrixxOES(Context *context, GLfixed *mantissa, GLint *exponent)
1056{
1057 UNIMPLEMENTED();
1058 return true;
1059}
Lingfeng Yanga0648782018-03-12 14:45:25 -07001060
1061bool ValidateGenFramebuffersOES(Context *context, GLsizei n, GLuint *framebuffers)
1062{
1063 UNIMPLEMENTED();
1064 return true;
1065}
1066
1067bool ValidateDeleteFramebuffersOES(Context *context, GLsizei n, const GLuint *framebuffers)
1068{
1069 UNIMPLEMENTED();
1070 return true;
1071}
1072
1073bool ValidateGenRenderbuffersOES(Context *context, GLsizei n, GLuint *renderbuffers)
1074{
1075 UNIMPLEMENTED();
1076 return true;
1077}
1078
1079bool ValidateDeleteRenderbuffersOES(Context *context, GLsizei n, const GLuint *renderbuffers)
1080{
1081 UNIMPLEMENTED();
1082 return true;
1083}
1084
1085bool ValidateBindFramebufferOES(Context *context, GLenum target, GLuint framebuffer)
1086{
1087 UNIMPLEMENTED();
1088 return true;
1089}
1090
1091bool ValidateBindRenderbufferOES(Context *context, GLenum target, GLuint renderbuffer)
1092{
1093 UNIMPLEMENTED();
1094 return true;
1095}
1096
1097bool ValidateCheckFramebufferStatusOES(Context *context, GLenum target)
1098{
1099 UNIMPLEMENTED();
1100 return true;
1101}
1102
1103bool ValidateFramebufferRenderbufferOES(Context *context,
1104 GLenum target,
1105 GLenum attachment,
1106 GLenum rbtarget,
1107 GLuint renderbuffer)
1108{
1109 UNIMPLEMENTED();
1110 return true;
1111}
1112
1113bool ValidateFramebufferTexture2DOES(Context *context,
1114 GLenum target,
1115 GLenum attachment,
1116 TextureTarget textarget,
1117 GLuint texture,
1118 GLint level)
1119{
1120 UNIMPLEMENTED();
1121 return true;
1122}
1123
1124bool ValidateGenerateMipmapOES(Context *context, TextureType target)
1125{
1126 UNIMPLEMENTED();
1127 return true;
1128}
1129
1130bool ValidateGetFramebufferAttachmentParameterivOES(Context *context,
1131 GLenum target,
1132 GLenum attachment,
1133 GLenum pname,
1134 GLint *params)
1135{
1136 UNIMPLEMENTED();
1137 return true;
1138}
1139
1140bool ValidateGetRenderbufferParameterivOES(Context *context,
1141 GLenum target,
1142 GLenum pname,
1143 GLint *params)
1144{
1145 UNIMPLEMENTED();
1146 return true;
1147}
1148
1149bool ValidateIsFramebufferOES(Context *context, GLuint framebuffer)
1150{
1151 UNIMPLEMENTED();
1152 return true;
1153}
1154
1155bool ValidateIsRenderbufferOES(Context *context, GLuint renderbuffer)
1156{
1157 UNIMPLEMENTED();
1158 return true;
1159}
1160
1161bool ValidateRenderbufferStorageOES(Context *context,
1162 GLenum target,
1163 GLint internalformat,
1164 GLsizei width,
1165 GLsizei height)
1166{
1167 UNIMPLEMENTED();
1168 return true;
1169}
1170
1171// GL_OES_texture_cube_map
1172
1173bool ValidateGetTexGenfvOES(Context *context, GLenum coord, GLenum pname, GLfloat *params)
1174{
1175 UNIMPLEMENTED();
1176 return true;
1177}
1178
1179bool ValidateGetTexGenivOES(Context *context, GLenum coord, GLenum pname, int *params)
1180{
1181 UNIMPLEMENTED();
1182 return true;
1183}
1184
1185bool ValidateGetTexGenxvOES(Context *context, GLenum coord, GLenum pname, GLfixed *params)
1186{
1187 UNIMPLEMENTED();
1188 return true;
1189}
1190
1191bool ValidateTexGenfvOES(Context *context, GLenum coord, GLenum pname, const GLfloat *params)
1192{
1193 UNIMPLEMENTED();
1194 return true;
1195}
1196
1197bool ValidateTexGenivOES(Context *context, GLenum coord, GLenum pname, const GLint *param)
1198{
1199 UNIMPLEMENTED();
1200 return true;
1201}
1202
1203bool ValidateTexGenxvOES(Context *context, GLenum coord, GLenum pname, const GLint *param)
1204{
1205 UNIMPLEMENTED();
1206 return true;
1207}
1208
1209bool ValidateTexGenfOES(Context *context, GLenum coord, GLenum pname, GLfloat param)
1210{
1211 UNIMPLEMENTED();
1212 return true;
1213}
1214
1215bool ValidateTexGeniOES(Context *context, GLenum coord, GLenum pname, GLint param)
1216{
1217 UNIMPLEMENTED();
1218 return true;
1219}
1220
1221bool ValidateTexGenxOES(Context *context, GLenum coord, GLenum pname, GLfixed param)
1222{
1223 UNIMPLEMENTED();
1224 return true;
1225}
Lingfeng Yang01074432018-04-16 10:19:51 -07001226
1227} // namespace gl