1 //
2 // Copyright 2019 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 // validationES32.cpp: Validation functions for OpenGL ES 3.2 entry point parameters
8
9 #include "libANGLE/validationES32_autogen.h"
10
11 #include "libANGLE/Context.h"
12 #include "libANGLE/ErrorStrings.h"
13 #include "libANGLE/Framebuffer.h"
14 #include "libANGLE/VertexArray.h"
15 #include "libANGLE/validationES.h"
16 #include "libANGLE/validationES2_autogen.h"
17 #include "libANGLE/validationES31.h"
18 #include "libANGLE/validationES31_autogen.h"
19 #include "libANGLE/validationES3_autogen.h"
20
21 #include "common/utilities.h"
22
23 using namespace angle;
24
25 namespace gl
26 {
27 using namespace err;
28
ValidateBlendBarrier(const Context * context)29 bool ValidateBlendBarrier(const Context *context)
30 {
31 return true;
32 }
33
ValidateBlendEquationSeparatei(const Context * context,GLuint buf,GLenum modeRGB,GLenum modeAlpha)34 bool ValidateBlendEquationSeparatei(const Context *context,
35 GLuint buf,
36 GLenum modeRGB,
37 GLenum modeAlpha)
38 {
39 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
40 {
41 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
42 return false;
43 }
44
45 if (!ValidateBlendEquationSeparate(context, modeRGB, modeAlpha))
46 {
47 // error already generated
48 return false;
49 }
50
51 return true;
52 }
53
ValidateBlendEquationi(const Context * context,GLuint buf,GLenum mode)54 bool ValidateBlendEquationi(const Context *context, GLuint buf, GLenum mode)
55 {
56 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
57 {
58 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
59 return false;
60 }
61
62 if (!ValidateBlendEquation(context, mode))
63 {
64 // error already generated
65 return false;
66 }
67
68 return true;
69 }
70
ValidateBlendFuncSeparatei(const Context * context,GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)71 bool ValidateBlendFuncSeparatei(const Context *context,
72 GLuint buf,
73 GLenum srcRGB,
74 GLenum dstRGB,
75 GLenum srcAlpha,
76 GLenum dstAlpha)
77 {
78 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
79 {
80 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
81 return false;
82 }
83
84 if (!ValidateBlendFuncSeparate(context, srcRGB, dstRGB, srcAlpha, dstAlpha))
85 {
86 // error already generated
87 return false;
88 }
89
90 return true;
91 }
92
ValidateBlendFunci(const Context * context,GLuint buf,GLenum src,GLenum dst)93 bool ValidateBlendFunci(const Context *context, GLuint buf, GLenum src, GLenum dst)
94 {
95 if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
96 {
97 context->validationError(GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
98 return false;
99 }
100
101 if (!ValidateBlendFunc(context, src, dst))
102 {
103 // error already generated
104 return false;
105 }
106
107 return true;
108 }
109
ValidateColorMaski(const Context * context,GLuint index,GLboolean r,GLboolean g,GLboolean b,GLboolean a)110 bool ValidateColorMaski(const Context *context,
111 GLuint index,
112 GLboolean r,
113 GLboolean g,
114 GLboolean b,
115 GLboolean a)
116 {
117 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
118 {
119 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
120 return false;
121 }
122
123 return true;
124 }
125
ValidateCopyImageSubData(const Context * context,GLuint srcName,GLenum srcTarget,GLint srcLevel,GLint srcX,GLint srcY,GLint srcZ,GLuint dstName,GLenum dstTarget,GLint dstLevel,GLint dstX,GLint dstY,GLint dstZ,GLsizei srcWidth,GLsizei srcHeight,GLsizei srcDepth)126 bool ValidateCopyImageSubData(const Context *context,
127 GLuint srcName,
128 GLenum srcTarget,
129 GLint srcLevel,
130 GLint srcX,
131 GLint srcY,
132 GLint srcZ,
133 GLuint dstName,
134 GLenum dstTarget,
135 GLint dstLevel,
136 GLint dstX,
137 GLint dstY,
138 GLint dstZ,
139 GLsizei srcWidth,
140 GLsizei srcHeight,
141 GLsizei srcDepth)
142 {
143 if (context->getClientVersion() < ES_3_2)
144 {
145 context->validationError(GL_INVALID_OPERATION, kES32Required);
146 return false;
147 }
148
149 return ValidateCopyImageSubDataBase(context, srcName, srcTarget, srcLevel, srcX, srcY, srcZ,
150 dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth,
151 srcHeight, srcDepth);
152 }
153
ValidateDebugMessageCallback(const Context * context,GLDEBUGPROC callback,const void * userParam)154 bool ValidateDebugMessageCallback(const Context *context,
155 GLDEBUGPROC callback,
156 const void *userParam)
157 {
158 return true;
159 }
160
ValidateDebugMessageControl(const Context * context,GLenum source,GLenum type,GLenum severity,GLsizei count,const GLuint * ids,GLboolean enabled)161 bool ValidateDebugMessageControl(const Context *context,
162 GLenum source,
163 GLenum type,
164 GLenum severity,
165 GLsizei count,
166 const GLuint *ids,
167 GLboolean enabled)
168 {
169 return true;
170 }
171
ValidateDebugMessageInsert(const Context * context,GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar * buf)172 bool ValidateDebugMessageInsert(const Context *context,
173 GLenum source,
174 GLenum type,
175 GLuint id,
176 GLenum severity,
177 GLsizei length,
178 const GLchar *buf)
179 {
180 return true;
181 }
182
ValidateDisablei(const Context * context,GLenum target,GLuint index)183 bool ValidateDisablei(const Context *context, GLenum target, GLuint index)
184 {
185 switch (target)
186 {
187 case GL_BLEND:
188 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
189 {
190 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
191 return false;
192 }
193 break;
194 default:
195 context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
196 return false;
197 }
198 return true;
199 }
200
ValidateDrawElementsBaseVertex(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)201 bool ValidateDrawElementsBaseVertex(const Context *context,
202 PrimitiveMode mode,
203 GLsizei count,
204 DrawElementsType type,
205 const void *indices,
206 GLint basevertex)
207 {
208 return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
209 }
210
ValidateDrawElementsInstancedBaseVertex(const Context * context,PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instancecount,GLint basevertex)211 bool ValidateDrawElementsInstancedBaseVertex(const Context *context,
212 PrimitiveMode mode,
213 GLsizei count,
214 DrawElementsType type,
215 const void *indices,
216 GLsizei instancecount,
217 GLint basevertex)
218 {
219 return ValidateDrawElementsInstancedBase(context, mode, count, type, indices, instancecount);
220 }
221
ValidateDrawRangeElementsBaseVertex(const Context * context,PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)222 bool ValidateDrawRangeElementsBaseVertex(const Context *context,
223 PrimitiveMode mode,
224 GLuint start,
225 GLuint end,
226 GLsizei count,
227 DrawElementsType type,
228 const void *indices,
229 GLint basevertex)
230 {
231 if (end < start)
232 {
233 context->validationError(GL_INVALID_VALUE, kInvalidElementRange);
234 return false;
235 }
236
237 if (!ValidateDrawElementsCommon(context, mode, count, type, indices, 0))
238 {
239 return false;
240 }
241
242 // Skip range checks for no-op calls.
243 if (count <= 0)
244 {
245 return true;
246 }
247
248 return true;
249 }
250
ValidateEnablei(const Context * context,GLenum target,GLuint index)251 bool ValidateEnablei(const Context *context, GLenum target, GLuint index)
252 {
253 switch (target)
254 {
255 case GL_BLEND:
256 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
257 {
258 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
259 return false;
260 }
261 break;
262 default:
263 context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
264 return false;
265 }
266 return true;
267 }
268
ValidateFramebufferTexture(const Context * context,GLenum target,GLenum attachment,TextureID texture,GLint level)269 bool ValidateFramebufferTexture(const Context *context,
270 GLenum target,
271 GLenum attachment,
272 TextureID texture,
273 GLint level)
274 {
275 return true;
276 }
277
ValidateGetDebugMessageLog(const Context * context,GLuint count,GLsizei bufSize,const GLenum * sources,const GLenum * types,const GLuint * ids,const GLenum * severities,const GLsizei * lengths,const GLchar * messageLog)278 bool ValidateGetDebugMessageLog(const Context *context,
279 GLuint count,
280 GLsizei bufSize,
281 const GLenum *sources,
282 const GLenum *types,
283 const GLuint *ids,
284 const GLenum *severities,
285 const GLsizei *lengths,
286 const GLchar *messageLog)
287 {
288 return true;
289 }
290
ValidateGetGraphicsResetStatus(const Context * context)291 bool ValidateGetGraphicsResetStatus(const Context *context)
292 {
293 return true;
294 }
295
ValidateGetObjectLabel(const Context * context,GLenum identifier,GLuint name,GLsizei bufSize,const GLsizei * length,const GLchar * label)296 bool ValidateGetObjectLabel(const Context *context,
297 GLenum identifier,
298 GLuint name,
299 GLsizei bufSize,
300 const GLsizei *length,
301 const GLchar *label)
302 {
303 return true;
304 }
305
ValidateGetObjectPtrLabel(const Context * context,const void * ptr,GLsizei bufSize,const GLsizei * length,const GLchar * label)306 bool ValidateGetObjectPtrLabel(const Context *context,
307 const void *ptr,
308 GLsizei bufSize,
309 const GLsizei *length,
310 const GLchar *label)
311 {
312 return true;
313 }
314
ValidateGetPointerv(const Context * context,GLenum pname,void * const * params)315 bool ValidateGetPointerv(const Context *context, GLenum pname, void *const *params)
316 {
317 Version clientVersion = context->getClientVersion();
318
319 if ((clientVersion == ES_1_0) || (clientVersion == ES_1_1))
320 {
321 switch (pname)
322 {
323 case GL_VERTEX_ARRAY_POINTER:
324 case GL_NORMAL_ARRAY_POINTER:
325 case GL_COLOR_ARRAY_POINTER:
326 case GL_TEXTURE_COORD_ARRAY_POINTER:
327 case GL_POINT_SIZE_ARRAY_POINTER_OES:
328 return true;
329 default:
330 context->validationError(GL_INVALID_ENUM, kInvalidPointerQuery);
331 return false;
332 }
333 }
334 else if (clientVersion == ES_3_2)
335 {
336 switch (pname)
337 {
338 case GL_DEBUG_CALLBACK_FUNCTION:
339 case GL_DEBUG_CALLBACK_USER_PARAM:
340 return true;
341 default:
342 context->validationError(GL_INVALID_ENUM, kInvalidPointerQuery);
343 return false;
344 }
345 }
346 else
347 {
348 context->validationError(GL_INVALID_OPERATION, kES1or32Required);
349 return false;
350 }
351 }
352
ValidateGetSamplerParameterIiv(const Context * context,SamplerID sampler,GLenum pname,const GLint * params)353 bool ValidateGetSamplerParameterIiv(const Context *context,
354 SamplerID sampler,
355 GLenum pname,
356 const GLint *params)
357 {
358 return true;
359 }
360
ValidateGetSamplerParameterIuiv(const Context * context,SamplerID sampler,GLenum pname,const GLuint * params)361 bool ValidateGetSamplerParameterIuiv(const Context *context,
362 SamplerID sampler,
363 GLenum pname,
364 const GLuint *params)
365 {
366 return true;
367 }
368
ValidateGetTexParameterIiv(const Context * context,TextureType targetPacked,GLenum pname,const GLint * params)369 bool ValidateGetTexParameterIiv(const Context *context,
370 TextureType targetPacked,
371 GLenum pname,
372 const GLint *params)
373 {
374 return true;
375 }
376
ValidateGetTexParameterIuiv(const Context * context,TextureType targetPacked,GLenum pname,const GLuint * params)377 bool ValidateGetTexParameterIuiv(const Context *context,
378 TextureType targetPacked,
379 GLenum pname,
380 const GLuint *params)
381 {
382 return true;
383 }
384
ValidateGetnUniformfv(const Context * context,ShaderProgramID program,UniformLocation location,GLsizei bufSize,const GLfloat * params)385 bool ValidateGetnUniformfv(const Context *context,
386 ShaderProgramID program,
387 UniformLocation location,
388 GLsizei bufSize,
389 const GLfloat *params)
390 {
391 return true;
392 }
393
ValidateGetnUniformiv(const Context * context,ShaderProgramID program,UniformLocation location,GLsizei bufSize,const GLint * params)394 bool ValidateGetnUniformiv(const Context *context,
395 ShaderProgramID program,
396 UniformLocation location,
397 GLsizei bufSize,
398 const GLint *params)
399 {
400 return true;
401 }
402
ValidateGetnUniformuiv(const Context * context,ShaderProgramID program,UniformLocation location,GLsizei bufSize,const GLuint * params)403 bool ValidateGetnUniformuiv(const Context *context,
404 ShaderProgramID program,
405 UniformLocation location,
406 GLsizei bufSize,
407 const GLuint *params)
408 {
409 return true;
410 }
411
ValidateIsEnabledi(const Context * context,GLenum target,GLuint index)412 bool ValidateIsEnabledi(const Context *context, GLenum target, GLuint index)
413 {
414 switch (target)
415 {
416 case GL_BLEND:
417 if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
418 {
419 context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
420 return false;
421 }
422 break;
423 default:
424 context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
425 return false;
426 }
427 return true;
428 }
429
ValidateMinSampleShading(const Context * context,GLfloat value)430 bool ValidateMinSampleShading(const Context *context, GLfloat value)
431 {
432 return true;
433 }
434
ValidateObjectLabel(const Context * context,GLenum identifier,GLuint name,GLsizei length,const GLchar * label)435 bool ValidateObjectLabel(const Context *context,
436 GLenum identifier,
437 GLuint name,
438 GLsizei length,
439 const GLchar *label)
440 {
441 return true;
442 }
443
ValidateObjectPtrLabel(const Context * context,const void * ptr,GLsizei length,const GLchar * label)444 bool ValidateObjectPtrLabel(const Context *context,
445 const void *ptr,
446 GLsizei length,
447 const GLchar *label)
448 {
449 return true;
450 }
451
ValidatePatchParameteri(const Context * context,GLenum pname,GLint value)452 bool ValidatePatchParameteri(const Context *context, GLenum pname, GLint value)
453 {
454 return true;
455 }
456
ValidatePopDebugGroup(const Context * context)457 bool ValidatePopDebugGroup(const Context *context)
458 {
459 return true;
460 }
461
ValidatePrimitiveBoundingBox(const Context * context,GLfloat minX,GLfloat minY,GLfloat minZ,GLfloat minW,GLfloat maxX,GLfloat maxY,GLfloat maxZ,GLfloat maxW)462 bool ValidatePrimitiveBoundingBox(const Context *context,
463 GLfloat minX,
464 GLfloat minY,
465 GLfloat minZ,
466 GLfloat minW,
467 GLfloat maxX,
468 GLfloat maxY,
469 GLfloat maxZ,
470 GLfloat maxW)
471 {
472 return true;
473 }
474
ValidatePushDebugGroup(const Context * context,GLenum source,GLuint id,GLsizei length,const GLchar * message)475 bool ValidatePushDebugGroup(const Context *context,
476 GLenum source,
477 GLuint id,
478 GLsizei length,
479 const GLchar *message)
480 {
481 return true;
482 }
483
ValidateReadnPixels(const Context * context,GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,const void * data)484 bool ValidateReadnPixels(const Context *context,
485 GLint x,
486 GLint y,
487 GLsizei width,
488 GLsizei height,
489 GLenum format,
490 GLenum type,
491 GLsizei bufSize,
492 const void *data)
493 {
494 return true;
495 }
496
ValidateSamplerParameterIiv(const Context * context,SamplerID sampler,GLenum pname,const GLint * param)497 bool ValidateSamplerParameterIiv(const Context *context,
498 SamplerID sampler,
499 GLenum pname,
500 const GLint *param)
501 {
502 return true;
503 }
504
ValidateSamplerParameterIuiv(const Context * context,SamplerID sampler,GLenum pname,const GLuint * param)505 bool ValidateSamplerParameterIuiv(const Context *context,
506 SamplerID sampler,
507 GLenum pname,
508 const GLuint *param)
509 {
510 return true;
511 }
512
ValidateTexBuffer(const Context * context,TextureType target,GLenum internalformat,BufferID buffer)513 bool ValidateTexBuffer(const Context *context,
514 TextureType target,
515 GLenum internalformat,
516 BufferID buffer)
517 {
518 if (context->getClientVersion() < ES_3_2)
519 {
520 context->validationError(GL_INVALID_OPERATION, kES32Required);
521 return false;
522 }
523
524 return ValidateTexBufferBase(context, target, internalformat, buffer);
525 }
526
ValidateTexBufferRange(const Context * context,TextureType target,GLenum internalformat,BufferID buffer,GLintptr offset,GLsizeiptr size)527 bool ValidateTexBufferRange(const Context *context,
528 TextureType target,
529 GLenum internalformat,
530 BufferID buffer,
531 GLintptr offset,
532 GLsizeiptr size)
533 {
534 if (context->getClientVersion() < ES_3_2)
535 {
536 context->validationError(GL_INVALID_OPERATION, kES32Required);
537 return false;
538 }
539
540 return ValidateTexBufferRangeBase(context, target, internalformat, buffer, offset, size);
541 }
542
ValidateTexParameterIiv(const Context * context,TextureType targetPacked,GLenum pname,const GLint * params)543 bool ValidateTexParameterIiv(const Context *context,
544 TextureType targetPacked,
545 GLenum pname,
546 const GLint *params)
547 {
548 return true;
549 }
550
ValidateTexParameterIuiv(const Context * context,TextureType targetPacked,GLenum pname,const GLuint * params)551 bool ValidateTexParameterIuiv(const Context *context,
552 TextureType targetPacked,
553 GLenum pname,
554 const GLuint *params)
555 {
556 return true;
557 }
558
ValidateTexStorage3DMultisample(const Context * context,TextureType targetPacked,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLboolean fixedsamplelocations)559 bool ValidateTexStorage3DMultisample(const Context *context,
560 TextureType targetPacked,
561 GLsizei samples,
562 GLenum internalformat,
563 GLsizei width,
564 GLsizei height,
565 GLsizei depth,
566 GLboolean fixedsamplelocations)
567 {
568 return true;
569 }
570
571 } // namespace gl
572