blob: 30504b7e01aa4f495c09ff039a6b3be58afdb67d [file] [log] [blame]
Martin Radev66fb8202016-07-28 11:45:20 +03001//
2// Copyright (c) 2016 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// validationES31.cpp: Validation functions for OpenGL ES 3.1 entry point parameters
8
Martin Radev66fb8202016-07-28 11:45:20 +03009#include "libANGLE/validationES31.h"
10
11#include "libANGLE/Context.h"
Brandon Jonesafa75152017-07-21 13:11:29 -070012#include "libANGLE/ErrorStrings.h"
JiangYizhouf7bbc8a2016-11-16 09:57:22 +080013#include "libANGLE/Framebuffer.h"
Jamie Madill231c7f52017-04-26 13:45:37 -040014#include "libANGLE/VertexArray.h"
Geoff Lang2e43dbb2016-10-14 12:27:35 -040015#include "libANGLE/validationES.h"
Yunchao Hea336b902017-08-02 16:05:21 +080016#include "libANGLE/validationES2.h"
Geoff Lang2e43dbb2016-10-14 12:27:35 -040017#include "libANGLE/validationES3.h"
Martin Radev66fb8202016-07-28 11:45:20 +030018
He Yunchao11b038b2016-11-22 21:24:04 +080019#include "common/utilities.h"
20
Martin Radev66fb8202016-07-28 11:45:20 +030021using namespace angle;
22
23namespace gl
24{
25
jchen1015015f72017-03-16 13:54:21 +080026namespace
27{
28
29bool ValidateNamedProgramInterface(GLenum programInterface)
30{
31 switch (programInterface)
32 {
33 case GL_UNIFORM:
34 case GL_UNIFORM_BLOCK:
35 case GL_PROGRAM_INPUT:
36 case GL_PROGRAM_OUTPUT:
37 case GL_TRANSFORM_FEEDBACK_VARYING:
38 case GL_BUFFER_VARIABLE:
39 case GL_SHADER_STORAGE_BLOCK:
40 return true;
41 default:
42 return false;
43 }
44}
45
jchen10191381f2017-04-11 13:59:04 +080046bool ValidateLocationProgramInterface(GLenum programInterface)
47{
48 switch (programInterface)
49 {
50 case GL_UNIFORM:
51 case GL_PROGRAM_INPUT:
52 case GL_PROGRAM_OUTPUT:
53 return true;
54 default:
55 return false;
56 }
57}
58
jchen10880683b2017-04-12 16:21:55 +080059bool ValidateProgramInterface(GLenum programInterface)
60{
61 return (programInterface == GL_ATOMIC_COUNTER_BUFFER ||
62 ValidateNamedProgramInterface(programInterface));
63}
64
65bool ValidateProgramResourceProperty(GLenum prop)
66{
67 switch (prop)
68 {
69 case GL_ACTIVE_VARIABLES:
70 case GL_BUFFER_BINDING:
71 case GL_NUM_ACTIVE_VARIABLES:
72
73 case GL_ARRAY_SIZE:
74
75 case GL_ARRAY_STRIDE:
76 case GL_BLOCK_INDEX:
77 case GL_IS_ROW_MAJOR:
78 case GL_MATRIX_STRIDE:
79
80 case GL_ATOMIC_COUNTER_BUFFER_INDEX:
81
82 case GL_BUFFER_DATA_SIZE:
83
84 case GL_LOCATION:
85
86 case GL_NAME_LENGTH:
87
88 case GL_OFFSET:
89
90 case GL_REFERENCED_BY_VERTEX_SHADER:
91 case GL_REFERENCED_BY_FRAGMENT_SHADER:
92 case GL_REFERENCED_BY_COMPUTE_SHADER:
93
94 case GL_TOP_LEVEL_ARRAY_SIZE:
95 case GL_TOP_LEVEL_ARRAY_STRIDE:
96
97 case GL_TYPE:
98 return true;
99
100 default:
101 return false;
102 }
103}
104
105// GLES 3.10 spec: Page 82 -- Table 7.2
106bool ValidateProgramResourcePropertyByInterface(GLenum prop, GLenum programInterface)
107{
108 switch (prop)
109 {
110 case GL_ACTIVE_VARIABLES:
111 case GL_BUFFER_BINDING:
112 case GL_NUM_ACTIVE_VARIABLES:
113 {
114 switch (programInterface)
115 {
116 case GL_ATOMIC_COUNTER_BUFFER:
117 case GL_SHADER_STORAGE_BLOCK:
118 case GL_UNIFORM_BLOCK:
119 return true;
120 default:
121 return false;
122 }
123 }
124
125 case GL_ARRAY_SIZE:
126 {
127 switch (programInterface)
128 {
129 case GL_BUFFER_VARIABLE:
130 case GL_PROGRAM_INPUT:
131 case GL_PROGRAM_OUTPUT:
132 case GL_TRANSFORM_FEEDBACK_VARYING:
133 case GL_UNIFORM:
134 return true;
135 default:
136 return false;
137 }
138 }
139
140 case GL_ARRAY_STRIDE:
141 case GL_BLOCK_INDEX:
142 case GL_IS_ROW_MAJOR:
143 case GL_MATRIX_STRIDE:
144 {
145 switch (programInterface)
146 {
147 case GL_BUFFER_VARIABLE:
148 case GL_UNIFORM:
149 return true;
150 default:
151 return false;
152 }
153 }
154
155 case GL_ATOMIC_COUNTER_BUFFER_INDEX:
156 {
157 if (programInterface == GL_UNIFORM)
158 {
159 return true;
160 }
161 return false;
162 }
163
164 case GL_BUFFER_DATA_SIZE:
165 {
166 switch (programInterface)
167 {
168 case GL_ATOMIC_COUNTER_BUFFER:
169 case GL_SHADER_STORAGE_BLOCK:
170 case GL_UNIFORM_BLOCK:
171 return true;
172 default:
173 return false;
174 }
175 }
176
177 case GL_LOCATION:
178 {
179 return ValidateLocationProgramInterface(programInterface);
180 }
181
182 case GL_NAME_LENGTH:
183 {
184 return ValidateNamedProgramInterface(programInterface);
185 }
186
187 case GL_OFFSET:
188 {
189 switch (programInterface)
190 {
191 case GL_BUFFER_VARIABLE:
192 case GL_UNIFORM:
193 return true;
194 default:
195 return false;
196 }
197 }
198
199 case GL_REFERENCED_BY_VERTEX_SHADER:
200 case GL_REFERENCED_BY_FRAGMENT_SHADER:
201 case GL_REFERENCED_BY_COMPUTE_SHADER:
202 {
203 switch (programInterface)
204 {
205 case GL_ATOMIC_COUNTER_BUFFER:
206 case GL_BUFFER_VARIABLE:
207 case GL_PROGRAM_INPUT:
208 case GL_PROGRAM_OUTPUT:
209 case GL_SHADER_STORAGE_BLOCK:
210 case GL_UNIFORM:
211 case GL_UNIFORM_BLOCK:
212 return true;
213 default:
214 return false;
215 }
216 }
217
218 case GL_TOP_LEVEL_ARRAY_SIZE:
219 case GL_TOP_LEVEL_ARRAY_STRIDE:
220 {
221 if (programInterface == GL_BUFFER_VARIABLE)
222 {
223 return true;
224 }
225 return false;
226 }
227
228 case GL_TYPE:
229 {
230 switch (programInterface)
231 {
232 case GL_BUFFER_VARIABLE:
233 case GL_PROGRAM_INPUT:
234 case GL_PROGRAM_OUTPUT:
235 case GL_TRANSFORM_FEEDBACK_VARYING:
236 case GL_UNIFORM:
237 return true;
238 default:
239 return false;
240 }
241 }
242
243 default:
244 return false;
245 }
246}
247
jchen10fd7c3b52017-03-21 15:36:03 +0800248bool ValidateProgramResourceIndex(const Program *programObject,
249 GLenum programInterface,
250 GLuint index)
251{
252 switch (programInterface)
253 {
254 case GL_PROGRAM_INPUT:
255 return (index < static_cast<GLuint>(programObject->getActiveAttributeCount()));
256
257 case GL_PROGRAM_OUTPUT:
258 return (index < static_cast<GLuint>(programObject->getOutputResourceCount()));
259
jchen10fd7c3b52017-03-21 15:36:03 +0800260 case GL_UNIFORM:
jchen10baf5d942017-08-28 20:45:48 +0800261 return (index < static_cast<GLuint>(programObject->getActiveUniformCount()));
262
Jiajia Qin3a9090f2017-09-27 14:37:04 +0800263 case GL_BUFFER_VARIABLE:
264 return (index < static_cast<GLuint>(programObject->getActiveBufferVariableCount()));
265
266 case GL_SHADER_STORAGE_BLOCK:
267 return (index < static_cast<GLuint>(programObject->getActiveShaderStorageBlockCount()));
268
jchen10fd7c3b52017-03-21 15:36:03 +0800269 case GL_UNIFORM_BLOCK:
jchen1058f67be2017-10-27 08:59:27 +0800270 return (index < programObject->getActiveUniformBlockCount());
271
272 case GL_ATOMIC_COUNTER_BUFFER:
273 return (index < programObject->getActiveAtomicCounterBufferCount());
274
jchen10fd7c3b52017-03-21 15:36:03 +0800275 case GL_TRANSFORM_FEEDBACK_VARYING:
jchen10910a3da2017-11-15 09:40:11 +0800276 return (index < static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()));
jchen10fd7c3b52017-03-21 15:36:03 +0800277
278 default:
279 UNREACHABLE();
280 return false;
281 }
282}
283
Jiajia Qin5451d532017-11-16 17:16:34 +0800284bool ValidateProgramUniform(gl::Context *context,
285 GLenum valueType,
286 GLuint program,
287 GLint location,
288 GLsizei count)
289{
290 // Check for ES31 program uniform entry points
291 if (context->getClientVersion() < Version(3, 1))
292 {
293 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
294 return false;
295 }
296
297 const LinkedUniform *uniform = nullptr;
298 gl::Program *programObject = GetValidProgram(context, program);
299 return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
300 ValidateUniformValue(context, valueType, uniform->type);
301}
302
303bool ValidateProgramUniformMatrix(gl::Context *context,
304 GLenum valueType,
305 GLuint program,
306 GLint location,
307 GLsizei count,
308 GLboolean transpose)
309{
310 // Check for ES31 program uniform entry points
311 if (context->getClientVersion() < Version(3, 1))
312 {
313 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
314 return false;
315 }
316
317 const LinkedUniform *uniform = nullptr;
318 gl::Program *programObject = GetValidProgram(context, program);
319 return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
320 ValidateUniformMatrixValue(context, valueType, uniform->type);
321}
322
323bool ValidateVertexAttribFormatCommon(ValidationContext *context,
324 GLuint attribIndex,
325 GLint size,
326 GLenum type,
327 GLuint relativeOffset,
328 GLboolean pureInteger)
329{
330 if (context->getClientVersion() < ES_3_1)
331 {
332 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
333 return false;
334 }
335
336 const Caps &caps = context->getCaps();
337 if (relativeOffset > static_cast<GLuint>(caps.maxVertexAttribRelativeOffset))
338 {
339 context->handleError(
340 InvalidValue()
341 << "relativeOffset cannot be greater than MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.");
342 return false;
343 }
344
345 // [OpenGL ES 3.1] Section 10.3.1 page 243:
346 // An INVALID_OPERATION error is generated if the default vertex array object is bound.
347 if (context->getGLState().getVertexArrayId() == 0)
348 {
349 context->handleError(InvalidOperation() << "Default vertex array object is bound.");
350 return false;
351 }
352
353 return ValidateVertexFormatBase(context, attribIndex, size, type, pureInteger);
354}
355
jchen1015015f72017-03-16 13:54:21 +0800356} // anonymous namespace
357
Martin Radev66fb8202016-07-28 11:45:20 +0300358bool ValidateGetBooleani_v(Context *context, GLenum target, GLuint index, GLboolean *data)
359{
Geoff Langeb66a6e2016-10-31 13:06:12 -0400360 if (context->getClientVersion() < ES_3_1)
Martin Radev66fb8202016-07-28 11:45:20 +0300361 {
Brandon Jonesafa75152017-07-21 13:11:29 -0700362 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
Martin Radev66fb8202016-07-28 11:45:20 +0300363 return false;
364 }
365
Geoff Lang2e43dbb2016-10-14 12:27:35 -0400366 if (!ValidateIndexedStateQuery(context, target, index, nullptr))
367 {
368 return false;
369 }
370
371 return true;
372}
373
374bool ValidateGetBooleani_vRobustANGLE(Context *context,
375 GLenum target,
376 GLuint index,
377 GLsizei bufSize,
378 GLsizei *length,
379 GLboolean *data)
380{
Geoff Langeb66a6e2016-10-31 13:06:12 -0400381 if (context->getClientVersion() < ES_3_1)
Geoff Lang2e43dbb2016-10-14 12:27:35 -0400382 {
Brandon Jonesafa75152017-07-21 13:11:29 -0700383 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
Geoff Lang2e43dbb2016-10-14 12:27:35 -0400384 return false;
385 }
386
387 if (!ValidateRobustEntryPoint(context, bufSize))
388 {
389 return false;
390 }
391
392 if (!ValidateIndexedStateQuery(context, target, index, length))
393 {
394 return false;
395 }
396
397 if (!ValidateRobustBufferSize(context, bufSize, *length))
Martin Radev66fb8202016-07-28 11:45:20 +0300398 {
399 return false;
400 }
401
402 return true;
403}
404
Jamie Madill876429b2017-04-20 15:46:24 -0400405bool ValidateDrawIndirectBase(Context *context, GLenum mode, const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800406{
407 if (context->getClientVersion() < ES_3_1)
408 {
Brandon Jonesafa75152017-07-21 13:11:29 -0700409 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
Jiajia Qind9671222016-11-29 16:30:31 +0800410 return false;
411 }
412
413 // Here the third parameter 1 is only to pass the count validation.
414 if (!ValidateDrawBase(context, mode, 1))
415 {
416 return false;
417 }
418
419 const State &state = context->getGLState();
420
421 // An INVALID_OPERATION error is generated if zero is bound to VERTEX_ARRAY_BINDING,
422 // DRAW_INDIRECT_BUFFER or to any enabled vertex array.
423 if (!state.getVertexArrayId())
424 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500425 context->handleError(InvalidOperation() << "zero is bound to VERTEX_ARRAY_BINDING");
Jiajia Qind9671222016-11-29 16:30:31 +0800426 return false;
427 }
428
Corentin Wallez336129f2017-10-17 15:55:40 -0400429 gl::Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect);
Jiajia Qind9671222016-11-29 16:30:31 +0800430 if (!drawIndirectBuffer)
431 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500432 context->handleError(InvalidOperation() << "zero is bound to DRAW_INDIRECT_BUFFER");
Jiajia Qind9671222016-11-29 16:30:31 +0800433 return false;
434 }
435
436 // An INVALID_VALUE error is generated if indirect is not a multiple of the size, in basic
437 // machine units, of uint.
438 GLint64 offset = reinterpret_cast<GLint64>(indirect);
439 if ((static_cast<GLuint>(offset) % sizeof(GLuint)) != 0)
440 {
441 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500442 InvalidValue()
443 << "indirect is not a multiple of the size, in basic machine units, of uint");
Jiajia Qind9671222016-11-29 16:30:31 +0800444 return false;
445 }
446
Martin Radev14a26ae2017-07-24 15:56:29 +0300447 // ANGLE_multiview spec, revision 1:
448 // An INVALID_OPERATION is generated by DrawArraysIndirect and DrawElementsIndirect if the
449 // number of views in the draw framebuffer is greater than 1.
450 const Framebuffer *drawFramebuffer = context->getGLState().getDrawFramebuffer();
451 ASSERT(drawFramebuffer != nullptr);
452 if (drawFramebuffer->getNumViews() > 1)
453 {
454 context->handleError(
455 InvalidOperation()
456 << "The number of views in the active draw framebuffer is greater than 1.");
457 return false;
458 }
459
Jiajia Qind9671222016-11-29 16:30:31 +0800460 return true;
461}
462
Jamie Madill876429b2017-04-20 15:46:24 -0400463bool ValidateDrawArraysIndirect(Context *context, GLenum mode, const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800464{
465 const State &state = context->getGLState();
466 gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
467 if (curTransformFeedback && curTransformFeedback->isActive() &&
468 !curTransformFeedback->isPaused())
469 {
470 // An INVALID_OPERATION error is generated if transform feedback is active and not paused.
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500471 context->handleError(InvalidOperation() << "transform feedback is active and not paused.");
Jiajia Qind9671222016-11-29 16:30:31 +0800472 return false;
473 }
474
475 if (!ValidateDrawIndirectBase(context, mode, indirect))
476 return false;
477
Corentin Wallez336129f2017-10-17 15:55:40 -0400478 gl::Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect);
Jiajia Qind9671222016-11-29 16:30:31 +0800479 CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect));
480 // In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawArraysIndirectCommand
481 // which's size is 4 * sizeof(uint).
482 auto checkedSum = checkedOffset + 4 * sizeof(GLuint);
483 if (!checkedSum.IsValid() ||
484 checkedSum.ValueOrDie() > static_cast<size_t>(drawIndirectBuffer->getSize()))
485 {
486 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500487 InvalidOperation()
488 << "the command would source data beyond the end of the buffer object.");
Jiajia Qind9671222016-11-29 16:30:31 +0800489 return false;
490 }
491
492 return true;
493}
494
Jamie Madill876429b2017-04-20 15:46:24 -0400495bool ValidateDrawElementsIndirect(Context *context, GLenum mode, GLenum type, const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800496{
497 if (!ValidateDrawElementsBase(context, type))
498 return false;
499
500 const State &state = context->getGLState();
501 const VertexArray *vao = state.getVertexArray();
502 gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer().get();
503 if (!elementArrayBuffer)
504 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500505 context->handleError(InvalidOperation() << "zero is bound to ELEMENT_ARRAY_BUFFER");
Jiajia Qind9671222016-11-29 16:30:31 +0800506 return false;
507 }
508
509 if (!ValidateDrawIndirectBase(context, mode, indirect))
510 return false;
511
Corentin Wallez336129f2017-10-17 15:55:40 -0400512 gl::Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect);
Jiajia Qind9671222016-11-29 16:30:31 +0800513 CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect));
514 // In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawElementsIndirectCommand
515 // which's size is 5 * sizeof(uint).
516 auto checkedSum = checkedOffset + 5 * sizeof(GLuint);
517 if (!checkedSum.IsValid() ||
518 checkedSum.ValueOrDie() > static_cast<size_t>(drawIndirectBuffer->getSize()))
519 {
520 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500521 InvalidOperation()
522 << "the command would source data beyond the end of the buffer object.");
Jiajia Qind9671222016-11-29 16:30:31 +0800523 return false;
524 }
525
526 return true;
527}
528
Jiajia Qin5451d532017-11-16 17:16:34 +0800529bool ValidateProgramUniform1i(Context *context, GLuint program, GLint location, GLint v0)
530{
531 return ValidateProgramUniform1iv(context, program, location, 1, &v0);
532}
533
534bool ValidateProgramUniform2i(Context *context, GLuint program, GLint location, GLint v0, GLint v1)
535{
536 GLint xy[2] = {v0, v1};
537 return ValidateProgramUniform2iv(context, program, location, 1, xy);
538}
539
540bool ValidateProgramUniform3i(Context *context,
541 GLuint program,
542 GLint location,
543 GLint v0,
544 GLint v1,
545 GLint v2)
546{
547 GLint xyz[3] = {v0, v1, v2};
548 return ValidateProgramUniform3iv(context, program, location, 1, xyz);
549}
550
551bool ValidateProgramUniform4i(Context *context,
552 GLuint program,
553 GLint location,
554 GLint v0,
555 GLint v1,
556 GLint v2,
557 GLint v3)
558{
559 GLint xyzw[4] = {v0, v1, v2, v3};
560 return ValidateProgramUniform4iv(context, program, location, 1, xyzw);
561}
562
563bool ValidateProgramUniform1ui(Context *context, GLuint program, GLint location, GLuint v0)
564{
565 return ValidateProgramUniform1uiv(context, program, location, 1, &v0);
566}
567
568bool ValidateProgramUniform2ui(Context *context,
569 GLuint program,
570 GLint location,
571 GLuint v0,
572 GLuint v1)
573{
574 GLuint xy[2] = {v0, v1};
575 return ValidateProgramUniform2uiv(context, program, location, 1, xy);
576}
577
578bool ValidateProgramUniform3ui(Context *context,
579 GLuint program,
580 GLint location,
581 GLuint v0,
582 GLuint v1,
583 GLuint v2)
584{
585 GLuint xyz[3] = {v0, v1, v2};
586 return ValidateProgramUniform3uiv(context, program, location, 1, xyz);
587}
588
589bool ValidateProgramUniform4ui(Context *context,
590 GLuint program,
591 GLint location,
592 GLuint v0,
593 GLuint v1,
594 GLuint v2,
595 GLuint v3)
596{
597 GLuint xyzw[4] = {v0, v1, v2, v3};
598 return ValidateProgramUniform4uiv(context, program, location, 1, xyzw);
599}
600
601bool ValidateProgramUniform1f(Context *context, GLuint program, GLint location, GLfloat v0)
602{
603 return ValidateProgramUniform1fv(context, program, location, 1, &v0);
604}
605
606bool ValidateProgramUniform2f(Context *context,
607 GLuint program,
608 GLint location,
609 GLfloat v0,
610 GLfloat v1)
611{
612 GLfloat xy[2] = {v0, v1};
613 return ValidateProgramUniform2fv(context, program, location, 1, xy);
614}
615
616bool ValidateProgramUniform3f(Context *context,
617 GLuint program,
618 GLint location,
619 GLfloat v0,
620 GLfloat v1,
621 GLfloat v2)
622{
623 GLfloat xyz[3] = {v0, v1, v2};
624 return ValidateProgramUniform3fv(context, program, location, 1, xyz);
625}
626
627bool ValidateProgramUniform4f(Context *context,
628 GLuint program,
629 GLint location,
630 GLfloat v0,
631 GLfloat v1,
632 GLfloat v2,
633 GLfloat v3)
634{
635 GLfloat xyzw[4] = {v0, v1, v2, v3};
636 return ValidateProgramUniform4fv(context, program, location, 1, xyzw);
637}
638
639bool ValidateProgramUniform1iv(Context *context,
640 GLuint program,
641 GLint location,
642 GLsizei count,
643 const GLint *value)
644{
645 // Check for ES31 program uniform entry points
646 if (context->getClientVersion() < Version(3, 1))
647 {
648 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
649 return false;
650 }
651
652 const LinkedUniform *uniform = nullptr;
653 gl::Program *programObject = GetValidProgram(context, program);
654 return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
655 ValidateUniform1ivValue(context, uniform->type, count, value);
656}
657
658bool ValidateProgramUniform2iv(Context *context,
659 GLuint program,
660 GLint location,
661 GLsizei count,
662 const GLint *value)
663{
664 return ValidateProgramUniform(context, GL_INT_VEC2, program, location, count);
665}
666
667bool ValidateProgramUniform3iv(Context *context,
668 GLuint program,
669 GLint location,
670 GLsizei count,
671 const GLint *value)
672{
673 return ValidateProgramUniform(context, GL_INT_VEC3, program, location, count);
674}
675
676bool ValidateProgramUniform4iv(Context *context,
677 GLuint program,
678 GLint location,
679 GLsizei count,
680 const GLint *value)
681{
682 return ValidateProgramUniform(context, GL_INT_VEC4, program, location, count);
683}
684
685bool ValidateProgramUniform1uiv(Context *context,
686 GLuint program,
687 GLint location,
688 GLsizei count,
689 const GLuint *value)
690{
691 return ValidateProgramUniform(context, GL_UNSIGNED_INT, program, location, count);
692}
693
694bool ValidateProgramUniform2uiv(Context *context,
695 GLuint program,
696 GLint location,
697 GLsizei count,
698 const GLuint *value)
699{
700 return ValidateProgramUniform(context, GL_UNSIGNED_INT_VEC2, program, location, count);
701}
702
703bool ValidateProgramUniform3uiv(Context *context,
704 GLuint program,
705 GLint location,
706 GLsizei count,
707 const GLuint *value)
708{
709 return ValidateProgramUniform(context, GL_UNSIGNED_INT_VEC3, program, location, count);
710}
711
712bool ValidateProgramUniform4uiv(Context *context,
713 GLuint program,
714 GLint location,
715 GLsizei count,
716 const GLuint *value)
717{
718 return ValidateProgramUniform(context, GL_UNSIGNED_INT_VEC4, program, location, count);
719}
720
721bool ValidateProgramUniform1fv(Context *context,
722 GLuint program,
723 GLint location,
724 GLsizei count,
725 const GLfloat *value)
726{
727 return ValidateProgramUniform(context, GL_FLOAT, program, location, count);
728}
729
730bool ValidateProgramUniform2fv(Context *context,
731 GLuint program,
732 GLint location,
733 GLsizei count,
734 const GLfloat *value)
735{
736 return ValidateProgramUniform(context, GL_FLOAT_VEC2, program, location, count);
737}
738
739bool ValidateProgramUniform3fv(Context *context,
740 GLuint program,
741 GLint location,
742 GLsizei count,
743 const GLfloat *value)
744{
745 return ValidateProgramUniform(context, GL_FLOAT_VEC3, program, location, count);
746}
747
748bool ValidateProgramUniform4fv(Context *context,
749 GLuint program,
750 GLint location,
751 GLsizei count,
752 const GLfloat *value)
753{
754 return ValidateProgramUniform(context, GL_FLOAT_VEC4, program, location, count);
755}
756
757bool ValidateProgramUniformMatrix2fv(Context *context,
758 GLuint program,
759 GLint location,
760 GLsizei count,
761 GLboolean transpose,
762 const GLfloat *value)
763{
764 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT2, program, location, count,
765 transpose);
766}
767
768bool ValidateProgramUniformMatrix3fv(Context *context,
769 GLuint program,
770 GLint location,
771 GLsizei count,
772 GLboolean transpose,
773 const GLfloat *value)
774{
775 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT3, program, location, count,
776 transpose);
777}
778
779bool ValidateProgramUniformMatrix4fv(Context *context,
780 GLuint program,
781 GLint location,
782 GLsizei count,
783 GLboolean transpose,
784 const GLfloat *value)
785{
786 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT4, program, location, count,
787 transpose);
788}
789
790bool ValidateProgramUniformMatrix2x3fv(Context *context,
791 GLuint program,
792 GLint location,
793 GLsizei count,
794 GLboolean transpose,
795 const GLfloat *value)
796{
797 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT2x3, program, location, count,
798 transpose);
799}
800
801bool ValidateProgramUniformMatrix3x2fv(Context *context,
802 GLuint program,
803 GLint location,
804 GLsizei count,
805 GLboolean transpose,
806 const GLfloat *value)
807{
808 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT3x2, program, location, count,
809 transpose);
810}
811
812bool ValidateProgramUniformMatrix2x4fv(Context *context,
813 GLuint program,
814 GLint location,
815 GLsizei count,
816 GLboolean transpose,
817 const GLfloat *value)
818{
819 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT2x4, program, location, count,
820 transpose);
821}
822
823bool ValidateProgramUniformMatrix4x2fv(Context *context,
824 GLuint program,
825 GLint location,
826 GLsizei count,
827 GLboolean transpose,
828 const GLfloat *value)
829{
830 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT4x2, program, location, count,
831 transpose);
832}
833
834bool ValidateProgramUniformMatrix3x4fv(Context *context,
835 GLuint program,
836 GLint location,
837 GLsizei count,
838 GLboolean transpose,
839 const GLfloat *value)
840{
841 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT3x4, program, location, count,
842 transpose);
843}
844
845bool ValidateProgramUniformMatrix4x3fv(Context *context,
846 GLuint program,
847 GLint location,
848 GLsizei count,
849 GLboolean transpose,
850 const GLfloat *value)
851{
852 return ValidateProgramUniformMatrix(context, GL_FLOAT_MAT4x3, program, location, count,
853 transpose);
854}
855
He Yunchao11b038b2016-11-22 21:24:04 +0800856bool ValidateGetTexLevelParameterBase(Context *context,
857 GLenum target,
858 GLint level,
859 GLenum pname,
860 GLsizei *length)
861{
862 if (context->getClientVersion() < ES_3_1)
863 {
Brandon Jonesafa75152017-07-21 13:11:29 -0700864 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
He Yunchao11b038b2016-11-22 21:24:04 +0800865 return false;
866 }
867
868 if (length)
869 {
870 *length = 0;
871 }
872
873 if (!ValidTexLevelDestinationTarget(context, target))
874 {
Brandon Jonesafa75152017-07-21 13:11:29 -0700875 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
He Yunchao11b038b2016-11-22 21:24:04 +0800876 return false;
877 }
878
879 if (context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target) ==
880 nullptr)
881 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500882 context->handleError(InvalidEnum() << "No texture bound.");
He Yunchao11b038b2016-11-22 21:24:04 +0800883 return false;
884 }
885
886 if (!ValidMipLevel(context, target, level))
887 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500888 context->handleError(InvalidValue());
He Yunchao11b038b2016-11-22 21:24:04 +0800889 return false;
890 }
891
892 switch (pname)
893 {
894 case GL_TEXTURE_RED_TYPE:
895 case GL_TEXTURE_GREEN_TYPE:
896 case GL_TEXTURE_BLUE_TYPE:
897 case GL_TEXTURE_ALPHA_TYPE:
898 case GL_TEXTURE_DEPTH_TYPE:
899 break;
900 case GL_TEXTURE_RED_SIZE:
901 case GL_TEXTURE_GREEN_SIZE:
902 case GL_TEXTURE_BLUE_SIZE:
903 case GL_TEXTURE_ALPHA_SIZE:
904 case GL_TEXTURE_DEPTH_SIZE:
905 case GL_TEXTURE_STENCIL_SIZE:
906 case GL_TEXTURE_SHARED_SIZE:
907 break;
908 case GL_TEXTURE_INTERNAL_FORMAT:
909 case GL_TEXTURE_WIDTH:
910 case GL_TEXTURE_HEIGHT:
911 case GL_TEXTURE_DEPTH:
912 break;
913 case GL_TEXTURE_SAMPLES:
914 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
915 break;
916 case GL_TEXTURE_COMPRESSED:
917 break;
918 default:
Brandon Jonesafa75152017-07-21 13:11:29 -0700919 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname);
He Yunchao11b038b2016-11-22 21:24:04 +0800920 return false;
921 }
922
923 if (length)
924 {
925 *length = 1;
926 }
927 return true;
928}
929
930bool ValidateGetTexLevelParameterfv(Context *context,
931 GLenum target,
932 GLint level,
933 GLenum pname,
934 GLfloat *params)
935{
936 return ValidateGetTexLevelParameterBase(context, target, level, pname, nullptr);
937}
938
939bool ValidateGetTexLevelParameteriv(Context *context,
940 GLenum target,
941 GLint level,
942 GLenum pname,
943 GLint *params)
944{
945 return ValidateGetTexLevelParameterBase(context, target, level, pname, nullptr);
946}
947
Jiajia Qin5451d532017-11-16 17:16:34 +0800948bool ValidateTexStorage2DMultisample(Context *context,
JiangYizhoubddc46b2016-12-09 09:50:51 +0800949 GLenum target,
950 GLsizei samples,
951 GLint internalFormat,
952 GLsizei width,
953 GLsizei height,
954 GLboolean fixedSampleLocations)
955{
956 if (context->getClientVersion() < ES_3_1)
957 {
Brandon Jonesafa75152017-07-21 13:11:29 -0700958 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
JiangYizhoubddc46b2016-12-09 09:50:51 +0800959 return false;
960 }
961
962 if (target != GL_TEXTURE_2D_MULTISAMPLE)
963 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500964 context->handleError(InvalidEnum() << "Target must be TEXTURE_2D_MULTISAMPLE.");
JiangYizhoubddc46b2016-12-09 09:50:51 +0800965 return false;
966 }
967
968 if (width < 1 || height < 1)
969 {
Brandon Jonesafa75152017-07-21 13:11:29 -0700970 ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize);
JiangYizhoubddc46b2016-12-09 09:50:51 +0800971 return false;
972 }
973
974 const Caps &caps = context->getCaps();
975 if (static_cast<GLuint>(width) > caps.max2DTextureSize ||
976 static_cast<GLuint>(height) > caps.max2DTextureSize)
977 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500978 context
979 ->handleError(InvalidValue()
980 << "Width and height must be less than or equal to GL_MAX_TEXTURE_SIZE.");
JiangYizhoubddc46b2016-12-09 09:50:51 +0800981 return false;
982 }
983
984 if (samples == 0)
985 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500986 context->handleError(InvalidValue() << "Samples may not be zero.");
JiangYizhoubddc46b2016-12-09 09:50:51 +0800987 return false;
988 }
989
990 const TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
991 if (!formatCaps.renderable)
992 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500993 context->handleError(InvalidEnum() << "SizedInternalformat must be color-renderable, "
994 "depth-renderable, or stencil-renderable.");
JiangYizhoubddc46b2016-12-09 09:50:51 +0800995 return false;
996 }
997
998 // The ES3.1 spec(section 8.8) states that an INVALID_ENUM error is generated if internalformat
999 // is one of the unsized base internalformats listed in table 8.11.
Geoff Langca271392017-04-05 12:30:00 -04001000 const InternalFormat &formatInfo = GetSizedInternalFormatInfo(internalFormat);
1001 if (formatInfo.internalFormat == GL_NONE)
JiangYizhoubddc46b2016-12-09 09:50:51 +08001002 {
1003 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001004 InvalidEnum()
1005 << "Internalformat is one of the unsupported unsized base internalformats.");
JiangYizhoubddc46b2016-12-09 09:50:51 +08001006 return false;
1007 }
1008
1009 if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
1010 {
1011 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001012 InvalidOperation()
1013 << "Samples must not be greater than maximum supported value for the format.");
JiangYizhoubddc46b2016-12-09 09:50:51 +08001014 return false;
1015 }
1016
1017 Texture *texture = context->getTargetTexture(target);
1018 if (!texture || texture->id() == 0)
1019 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001020 context->handleError(InvalidOperation() << "Zero is bound to target.");
JiangYizhoubddc46b2016-12-09 09:50:51 +08001021 return false;
1022 }
1023
1024 if (texture->getImmutableFormat())
1025 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001026 context->handleError(InvalidOperation() << "The value of TEXTURE_IMMUTABLE_FORMAT for "
1027 "the texture currently bound to target on "
1028 "the active texture unit is true.");
JiangYizhoubddc46b2016-12-09 09:50:51 +08001029 return false;
1030 }
1031
1032 return true;
1033}
1034
1035bool ValidateGetMultisamplefv(Context *context, GLenum pname, GLuint index, GLfloat *val)
1036{
1037 if (context->getClientVersion() < ES_3_1)
1038 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001039 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
JiangYizhoubddc46b2016-12-09 09:50:51 +08001040 return false;
1041 }
1042
1043 if (pname != GL_SAMPLE_POSITION)
1044 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001045 context->handleError(InvalidEnum() << "Pname must be SAMPLE_POSITION.");
JiangYizhoubddc46b2016-12-09 09:50:51 +08001046 return false;
1047 }
1048
JiangYizhou5b03f472017-01-09 10:22:53 +08001049 Framebuffer *framebuffer = context->getGLState().getDrawFramebuffer();
1050
1051 if (index >= static_cast<GLuint>(framebuffer->getSamples(context)))
JiangYizhoubddc46b2016-12-09 09:50:51 +08001052 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001053 context->handleError(InvalidValue() << "Index must be less than the value of SAMPLES.");
JiangYizhoubddc46b2016-12-09 09:50:51 +08001054 return false;
1055 }
1056
1057 return true;
1058}
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001059
Jiajia Qin5451d532017-11-16 17:16:34 +08001060bool ValidateFramebufferParameteri(Context *context, GLenum target, GLenum pname, GLint param)
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001061{
1062 if (context->getClientVersion() < ES_3_1)
1063 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001064 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001065 return false;
1066 }
1067
Geoff Lange8afa902017-09-27 15:00:43 -04001068 if (!ValidFramebufferTarget(context, target))
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001069 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001070 context->handleError(InvalidEnum() << "Invalid framebuffer target.");
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001071 return false;
1072 }
1073
1074 switch (pname)
1075 {
1076 case GL_FRAMEBUFFER_DEFAULT_WIDTH:
1077 {
1078 GLint maxWidth = context->getCaps().maxFramebufferWidth;
1079 if (param < 0 || param > maxWidth)
1080 {
1081 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001082 InvalidValue()
1083 << "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_WIDTH.");
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001084 return false;
1085 }
1086 break;
1087 }
1088 case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
1089 {
1090 GLint maxHeight = context->getCaps().maxFramebufferHeight;
1091 if (param < 0 || param > maxHeight)
1092 {
1093 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001094 InvalidValue()
1095 << "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_HEIGHT.");
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001096 return false;
1097 }
1098 break;
1099 }
1100 case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
1101 {
1102 GLint maxSamples = context->getCaps().maxFramebufferSamples;
1103 if (param < 0 || param > maxSamples)
1104 {
1105 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001106 InvalidValue()
1107 << "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_SAMPLES.");
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001108 return false;
1109 }
1110 break;
1111 }
1112 case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
1113 {
1114 break;
1115 }
1116 default:
1117 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001118 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname);
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001119 return false;
1120 }
1121 }
1122
1123 const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
1124 ASSERT(framebuffer);
1125 if (framebuffer->id() == 0)
1126 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001127 context->handleError(InvalidOperation() << "Default framebuffer is bound to target.");
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001128 return false;
1129 }
1130 return true;
1131}
1132
Jiajia Qin5451d532017-11-16 17:16:34 +08001133bool ValidateGetFramebufferParameteriv(Context *context, GLenum target, GLenum pname, GLint *params)
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001134{
1135 if (context->getClientVersion() < ES_3_1)
1136 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001137 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001138 return false;
1139 }
1140
Geoff Lange8afa902017-09-27 15:00:43 -04001141 if (!ValidFramebufferTarget(context, target))
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001142 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001143 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget);
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001144 return false;
1145 }
1146
1147 switch (pname)
1148 {
1149 case GL_FRAMEBUFFER_DEFAULT_WIDTH:
1150 case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
1151 case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
1152 case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
1153 break;
1154 default:
Brandon Jonesafa75152017-07-21 13:11:29 -07001155 ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname);
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001156 return false;
1157 }
1158
1159 const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
1160 ASSERT(framebuffer);
1161
1162 if (framebuffer->id() == 0)
1163 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001164 context->handleError(InvalidOperation() << "Default framebuffer is bound to target.");
JiangYizhouf7bbc8a2016-11-16 09:57:22 +08001165 return false;
1166 }
1167 return true;
1168}
1169
jchen1015015f72017-03-16 13:54:21 +08001170bool ValidateGetProgramResourceIndex(Context *context,
1171 GLuint program,
1172 GLenum programInterface,
1173 const GLchar *name)
1174{
1175 if (context->getClientVersion() < ES_3_1)
1176 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001177 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
jchen1015015f72017-03-16 13:54:21 +08001178 return false;
1179 }
1180
1181 Program *programObject = GetValidProgram(context, program);
1182 if (programObject == nullptr)
1183 {
1184 return false;
1185 }
1186
1187 if (!ValidateNamedProgramInterface(programInterface))
1188 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001189 context->handleError(InvalidEnum() << "Invalid program interface: 0x" << std::hex
1190 << std::uppercase << programInterface);
jchen1015015f72017-03-16 13:54:21 +08001191 return false;
1192 }
Shao80957d92017-02-20 21:25:59 +08001193
1194 return true;
1195}
1196
1197bool ValidateBindVertexBuffer(ValidationContext *context,
1198 GLuint bindingIndex,
1199 GLuint buffer,
1200 GLintptr offset,
1201 GLsizei stride)
1202{
1203 if (context->getClientVersion() < ES_3_1)
1204 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001205 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
Shao80957d92017-02-20 21:25:59 +08001206 return false;
1207 }
1208
1209 if (!context->isBufferGenerated(buffer))
1210 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001211 context->handleError(InvalidOperation() << "Buffer is not generated.");
Shao80957d92017-02-20 21:25:59 +08001212 return false;
1213 }
1214
1215 const Caps &caps = context->getCaps();
1216 if (bindingIndex >= caps.maxVertexAttribBindings)
1217 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001218 context->handleError(InvalidValue()
1219 << "bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS.");
Shao80957d92017-02-20 21:25:59 +08001220 return false;
1221 }
1222
1223 if (offset < 0)
1224 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001225 ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
Shao80957d92017-02-20 21:25:59 +08001226 return false;
1227 }
1228
1229 if (stride < 0 || stride > caps.maxVertexAttribStride)
1230 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001231 context->handleError(InvalidValue()
1232 << "stride must be between 0 and MAX_VERTEX_ATTRIB_STRIDE.");
Shao80957d92017-02-20 21:25:59 +08001233 return false;
1234 }
1235
1236 // [OpenGL ES 3.1] Section 10.3.1 page 244:
1237 // An INVALID_OPERATION error is generated if the default vertex array object is bound.
1238 if (context->getGLState().getVertexArrayId() == 0)
1239 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001240 context->handleError(InvalidOperation() << "Default vertex array buffer is bound.");
Shao80957d92017-02-20 21:25:59 +08001241 return false;
1242 }
1243
1244 return true;
1245}
1246
1247bool ValidateVertexBindingDivisor(ValidationContext *context, GLuint bindingIndex, GLuint divisor)
1248{
1249 if (context->getClientVersion() < ES_3_1)
1250 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001251 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
Shao80957d92017-02-20 21:25:59 +08001252 return false;
1253 }
1254
1255 const Caps &caps = context->getCaps();
1256 if (bindingIndex >= caps.maxVertexAttribBindings)
1257 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001258 context->handleError(InvalidValue()
1259 << "bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS.");
Shao80957d92017-02-20 21:25:59 +08001260 return false;
1261 }
1262
1263 // [OpenGL ES 3.1] Section 10.3.1 page 243:
1264 // An INVALID_OPERATION error is generated if the default vertex array object is bound.
1265 if (context->getGLState().getVertexArrayId() == 0)
1266 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001267 context->handleError(InvalidOperation() << "Default vertex array object is bound.");
Shao80957d92017-02-20 21:25:59 +08001268 return false;
1269 }
1270
1271 return true;
1272}
1273
1274bool ValidateVertexAttribFormat(ValidationContext *context,
Jiajia Qin5451d532017-11-16 17:16:34 +08001275 GLuint attribindex,
Shao80957d92017-02-20 21:25:59 +08001276 GLint size,
1277 GLenum type,
Jiajia Qin5451d532017-11-16 17:16:34 +08001278 GLboolean normalized,
1279 GLuint relativeoffset)
Shao80957d92017-02-20 21:25:59 +08001280{
Jiajia Qin5451d532017-11-16 17:16:34 +08001281 return ValidateVertexAttribFormatCommon(context, attribindex, size, type, relativeoffset,
1282 false);
1283}
Shao80957d92017-02-20 21:25:59 +08001284
Jiajia Qin5451d532017-11-16 17:16:34 +08001285bool ValidateVertexAttribIFormat(ValidationContext *context,
1286 GLuint attribindex,
1287 GLint size,
1288 GLenum type,
1289 GLuint relativeoffset)
1290{
1291 return ValidateVertexAttribFormatCommon(context, attribindex, size, type, relativeoffset, true);
Shao80957d92017-02-20 21:25:59 +08001292}
1293
1294bool ValidateVertexAttribBinding(ValidationContext *context,
1295 GLuint attribIndex,
1296 GLuint bindingIndex)
1297{
1298 if (context->getClientVersion() < ES_3_1)
1299 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001300 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
Shao80957d92017-02-20 21:25:59 +08001301 return false;
1302 }
1303
1304 // [OpenGL ES 3.1] Section 10.3.1 page 243:
1305 // An INVALID_OPERATION error is generated if the default vertex array object is bound.
1306 if (context->getGLState().getVertexArrayId() == 0)
1307 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001308 context->handleError(InvalidOperation() << "Default vertex array object is bound.");
Shao80957d92017-02-20 21:25:59 +08001309 return false;
1310 }
1311
1312 const Caps &caps = context->getCaps();
1313 if (attribIndex >= caps.maxVertexAttributes)
1314 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001315 ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMaxVertexAttribute);
Shao80957d92017-02-20 21:25:59 +08001316 return false;
1317 }
1318
1319 if (bindingIndex >= caps.maxVertexAttribBindings)
1320 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001321 context->handleError(InvalidValue()
1322 << "bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS");
Shao80957d92017-02-20 21:25:59 +08001323 return false;
1324 }
1325
jchen1015015f72017-03-16 13:54:21 +08001326 return true;
1327}
1328
jchen10fd7c3b52017-03-21 15:36:03 +08001329bool ValidateGetProgramResourceName(Context *context,
1330 GLuint program,
1331 GLenum programInterface,
1332 GLuint index,
1333 GLsizei bufSize,
1334 GLsizei *length,
1335 GLchar *name)
1336{
1337 if (context->getClientVersion() < ES_3_1)
1338 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001339 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
jchen10fd7c3b52017-03-21 15:36:03 +08001340 return false;
1341 }
1342
1343 Program *programObject = GetValidProgram(context, program);
1344 if (programObject == nullptr)
1345 {
1346 return false;
1347 }
1348
1349 if (!ValidateNamedProgramInterface(programInterface))
1350 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001351 context->handleError(InvalidEnum() << "Invalid program interface: 0x" << std::hex
1352 << std::uppercase << programInterface);
jchen10fd7c3b52017-03-21 15:36:03 +08001353 return false;
1354 }
1355
1356 if (!ValidateProgramResourceIndex(programObject, programInterface, index))
1357 {
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001358 context->handleError(InvalidValue() << "Invalid index: " << index);
jchen10fd7c3b52017-03-21 15:36:03 +08001359 return false;
1360 }
1361
1362 if (bufSize < 0)
1363 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001364 ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
jchen10fd7c3b52017-03-21 15:36:03 +08001365 return false;
1366 }
1367
1368 return true;
1369}
1370
Xinghua Cao2b396592017-03-29 15:36:04 +08001371bool ValidateDispatchCompute(Context *context,
1372 GLuint numGroupsX,
1373 GLuint numGroupsY,
1374 GLuint numGroupsZ)
1375{
1376 if (context->getClientVersion() < ES_3_1)
1377 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001378 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
Xinghua Cao2b396592017-03-29 15:36:04 +08001379 return false;
1380 }
1381
1382 const State &state = context->getGLState();
1383 Program *program = state.getProgram();
1384
Qin Jiajia62fcf622017-11-30 16:16:12 +08001385 if (program == nullptr || !program->hasLinkedComputeShader())
Xinghua Cao2b396592017-03-29 15:36:04 +08001386 {
Qin Jiajia62fcf622017-11-30 16:16:12 +08001387 ANGLE_VALIDATION_ERR(context, InvalidOperation(), NoActiveProgramWithComputeShader);
Xinghua Cao2b396592017-03-29 15:36:04 +08001388 return false;
1389 }
1390
1391 const Caps &caps = context->getCaps();
1392 if (numGroupsX > caps.maxComputeWorkGroupCount[0])
1393 {
1394 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001395 InvalidValue() << "num_groups_x cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[0]="
1396 << caps.maxComputeWorkGroupCount[0]);
Xinghua Cao2b396592017-03-29 15:36:04 +08001397 return false;
1398 }
1399 if (numGroupsY > caps.maxComputeWorkGroupCount[1])
1400 {
1401 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001402 InvalidValue() << "num_groups_y cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[1]="
1403 << caps.maxComputeWorkGroupCount[1]);
Xinghua Cao2b396592017-03-29 15:36:04 +08001404 return false;
1405 }
1406 if (numGroupsZ > caps.maxComputeWorkGroupCount[2])
1407 {
1408 context->handleError(
Yuly Novikovc4d18aa2017-03-09 18:45:02 -05001409 InvalidValue() << "num_groups_z cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[2]="
1410 << caps.maxComputeWorkGroupCount[2]);
Xinghua Cao2b396592017-03-29 15:36:04 +08001411 return false;
1412 }
1413
1414 return true;
1415}
1416
Jiajia Qin5451d532017-11-16 17:16:34 +08001417bool ValidateDispatchComputeIndirect(Context *context, GLintptr indirect)
1418{
Qin Jiajia62fcf622017-11-30 16:16:12 +08001419 if (context->getClientVersion() < ES_3_1)
1420 {
1421 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1422 return false;
1423 }
1424
1425 const State &state = context->getGLState();
1426 Program *program = state.getProgram();
1427
1428 if (program == nullptr || !program->hasLinkedComputeShader())
1429 {
1430 ANGLE_VALIDATION_ERR(context, InvalidOperation(), NoActiveProgramWithComputeShader);
1431 return false;
1432 }
1433
1434 gl::Buffer *dispatchIndirectBuffer = state.getTargetBuffer(BufferBinding::DispatchIndirect);
1435 if (!dispatchIndirectBuffer)
1436 {
1437 ANGLE_VALIDATION_ERR(context, InvalidOperation(), DispatchIndirectBufferNotBound);
1438 return false;
1439 }
1440
1441 if (indirect < 0)
1442 {
1443 ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset);
1444 return false;
1445 }
1446
1447 if ((indirect & (sizeof(GLuint) - 1)) != 0)
1448 {
1449 ANGLE_VALIDATION_ERR(context, InvalidOperation(), OffsetMustBeMultipleOfUint);
1450 return false;
1451 }
1452
1453 CheckedNumeric<GLuint64> checkedOffset(static_cast<GLuint64>(indirect));
1454 auto checkedSum = checkedOffset + static_cast<GLuint64>(3 * sizeof(GLuint));
1455 if (!checkedSum.IsValid() ||
1456 checkedSum.ValueOrDie() > static_cast<GLuint64>(dispatchIndirectBuffer->getSize()))
1457 {
1458 ANGLE_VALIDATION_ERR(context, InvalidOperation(), InsufficientBufferSize);
1459 return false;
1460 }
1461
1462 return true;
Jiajia Qin5451d532017-11-16 17:16:34 +08001463}
1464
Xinghua Cao65ec0b22017-03-28 16:10:52 +08001465bool ValidateBindImageTexture(Context *context,
1466 GLuint unit,
1467 GLuint texture,
1468 GLint level,
1469 GLboolean layered,
1470 GLint layer,
1471 GLenum access,
1472 GLenum format)
1473{
1474 GLuint maxImageUnits = context->getCaps().maxImageUnits;
1475 if (unit >= maxImageUnits)
1476 {
1477 context->handleError(InvalidValue()
1478 << "unit cannot be greater than or equal than MAX_IMAGE_UNITS = "
1479 << maxImageUnits);
1480 return false;
1481 }
1482
1483 if (level < 0)
1484 {
1485 context->handleError(InvalidValue() << "level is negative.");
1486 return false;
1487 }
1488
1489 if (layer < 0)
1490 {
1491 context->handleError(InvalidValue() << "layer is negative.");
1492 return false;
1493 }
1494
1495 if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE)
1496 {
1497 context->handleError(InvalidEnum() << "access is not one of the supported tokens.");
1498 return false;
1499 }
1500
1501 switch (format)
1502 {
1503 case GL_RGBA32F:
1504 case GL_RGBA16F:
1505 case GL_R32F:
1506 case GL_RGBA32UI:
1507 case GL_RGBA16UI:
1508 case GL_RGBA8UI:
1509 case GL_R32UI:
1510 case GL_RGBA32I:
1511 case GL_RGBA16I:
1512 case GL_RGBA8I:
1513 case GL_R32I:
1514 case GL_RGBA8:
1515 case GL_RGBA8_SNORM:
1516 break;
1517 default:
1518 context->handleError(InvalidValue()
1519 << "format is not one of supported image unit formats.");
1520 return false;
1521 }
1522
1523 if (texture != 0)
1524 {
1525 Texture *tex = context->getTexture(texture);
1526
1527 if (tex == nullptr)
1528 {
1529 context->handleError(InvalidValue()
1530 << "texture is not the name of an existing texture object.");
1531 return false;
1532 }
1533
1534 if (!tex->getImmutableFormat())
1535 {
1536 context->handleError(InvalidOperation()
1537 << "texture is not the name of an immutable texture object.");
1538 return false;
1539 }
1540 }
1541
1542 return true;
1543}
jchen10191381f2017-04-11 13:59:04 +08001544
1545bool ValidateGetProgramResourceLocation(Context *context,
1546 GLuint program,
1547 GLenum programInterface,
1548 const GLchar *name)
1549{
1550 if (context->getClientVersion() < ES_3_1)
1551 {
Brandon Jonesafa75152017-07-21 13:11:29 -07001552 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
jchen10191381f2017-04-11 13:59:04 +08001553 return false;
1554 }
1555
1556 Program *programObject = GetValidProgram(context, program);
1557 if (programObject == nullptr)
1558 {
1559 return false;
1560 }
1561
1562 if (!programObject->isLinked())
1563 {
1564 context->handleError(InvalidOperation() << "Program is not successfully linked.");
1565 return false;
1566 }
1567
1568 if (!ValidateLocationProgramInterface(programInterface))
1569 {
1570 context->handleError(InvalidEnum() << "Invalid program interface.");
1571 return false;
1572 }
1573 return true;
1574}
1575
jchen10880683b2017-04-12 16:21:55 +08001576bool ValidateGetProgramResourceiv(Context *context,
1577 GLuint program,
1578 GLenum programInterface,
1579 GLuint index,
1580 GLsizei propCount,
1581 const GLenum *props,
1582 GLsizei bufSize,
1583 GLsizei *length,
1584 GLint *params)
1585{
1586 if (context->getClientVersion() < ES_3_1)
1587 {
jchen10d9cd7b72017-08-30 15:04:25 +08001588 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
jchen10880683b2017-04-12 16:21:55 +08001589 return false;
1590 }
1591
1592 Program *programObject = GetValidProgram(context, program);
1593 if (programObject == nullptr)
1594 {
1595 return false;
1596 }
1597 if (!ValidateProgramInterface(programInterface))
1598 {
1599 context->handleError(InvalidEnum() << "Invalid program interface.");
1600 return false;
1601 }
1602 if (propCount <= 0)
1603 {
1604 context->handleError(InvalidValue() << "Invalid propCount.");
1605 return false;
1606 }
1607 if (bufSize < 0)
1608 {
1609 context->handleError(InvalidValue() << "Invalid bufSize.");
1610 return false;
1611 }
1612 if (!ValidateProgramResourceIndex(programObject, programInterface, index))
1613 {
1614 context->handleError(InvalidValue() << "Invalid index: " << index);
1615 return false;
1616 }
1617 for (GLsizei i = 0; i < propCount; i++)
1618 {
1619 if (!ValidateProgramResourceProperty(props[i]))
1620 {
1621 context->handleError(InvalidEnum() << "Invalid prop.");
1622 return false;
1623 }
1624 if (!ValidateProgramResourcePropertyByInterface(props[i], programInterface))
1625 {
1626 context->handleError(InvalidOperation() << "Not an allowed prop for interface");
1627 return false;
1628 }
1629 }
1630 return true;
1631}
1632
jchen10d9cd7b72017-08-30 15:04:25 +08001633bool ValidateGetProgramInterfaceiv(Context *context,
1634 GLuint program,
1635 GLenum programInterface,
1636 GLenum pname,
1637 GLint *params)
1638{
1639 if (context->getClientVersion() < ES_3_1)
1640 {
1641 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1642 return false;
1643 }
1644
1645 Program *programObject = GetValidProgram(context, program);
1646 if (programObject == nullptr)
1647 {
1648 return false;
1649 }
1650
1651 if (!ValidateProgramInterface(programInterface))
1652 {
1653 context->handleError(InvalidEnum() << "Invalid program interface.");
1654 return false;
1655 }
1656
1657 switch (pname)
1658 {
1659 case GL_ACTIVE_RESOURCES:
1660 case GL_MAX_NAME_LENGTH:
1661 case GL_MAX_NUM_ACTIVE_VARIABLES:
1662 break;
1663
1664 default:
1665 context->handleError(InvalidEnum() << "Unknown property of program interface.");
1666 return false;
1667 }
1668
1669 if (pname == GL_MAX_NAME_LENGTH && programInterface == GL_ATOMIC_COUNTER_BUFFER)
1670 {
1671 context->handleError(InvalidOperation()
1672 << "Active atomic counter resources are not assigned name strings.");
1673 return false;
1674 }
1675
1676 if (pname == GL_MAX_NUM_ACTIVE_VARIABLES)
1677 {
1678 switch (programInterface)
1679 {
1680 case GL_ATOMIC_COUNTER_BUFFER:
1681 case GL_SHADER_STORAGE_BLOCK:
1682 case GL_UNIFORM_BLOCK:
1683 break;
1684
1685 default:
1686 context->handleError(
1687 InvalidOperation()
1688 << "MAX_NUM_ACTIVE_VARIABLES requires a buffer or block interface.");
1689 return false;
1690 }
1691 }
1692
1693 return true;
1694}
1695
Yunchao Hea336b902017-08-02 16:05:21 +08001696static bool ValidateGenOrDeleteES31(Context *context, GLint n)
1697{
1698 if (context->getClientVersion() < ES_3_1)
1699 {
1700 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1701 return false;
1702 }
1703
1704 return ValidateGenOrDelete(context, n);
1705}
1706
1707bool ValidateGenProgramPipelines(Context *context, GLint n, GLuint *)
1708{
1709 return ValidateGenOrDeleteES31(context, n);
1710}
1711
1712bool ValidateDeleteProgramPipelines(Context *context, GLint n, const GLuint *)
1713{
1714 return ValidateGenOrDeleteES31(context, n);
1715}
1716
1717bool ValidateBindProgramPipeline(Context *context, GLuint pipeline)
1718{
1719 if (context->getClientVersion() < ES_3_1)
1720 {
1721 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1722 return false;
1723 }
1724
1725 if (!context->isProgramPipelineGenerated(pipeline))
1726 {
1727 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ObjectNotGenerated);
1728 return false;
1729 }
1730
1731 return true;
1732}
1733
1734bool ValidateIsProgramPipeline(Context *context, GLuint pipeline)
1735{
1736 if (context->getClientVersion() < ES_3_1)
1737 {
1738 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1739 return false;
1740 }
1741
1742 return true;
1743}
1744
Jiajia Qin5451d532017-11-16 17:16:34 +08001745bool ValidateUseProgramStages(Context *context, GLuint pipeline, GLbitfield stages, GLuint program)
1746{
1747 UNIMPLEMENTED();
1748 return false;
1749}
1750
1751bool ValidateActiveShaderProgram(Context *context, GLuint pipeline, GLuint program)
1752{
1753 UNIMPLEMENTED();
1754 return false;
1755}
1756
1757bool ValidateCreateShaderProgramv(Context *context,
1758 GLenum type,
1759 GLsizei count,
1760 const GLchar *const *strings)
1761{
1762 UNIMPLEMENTED();
1763 return false;
1764}
1765
1766bool ValidateGetProgramPipelineiv(Context *context, GLuint pipeline, GLenum pname, GLint *params)
1767{
1768 UNIMPLEMENTED();
1769 return false;
1770}
1771
1772bool ValidateValidateProgramPipeline(Context *context, GLuint pipeline)
1773{
1774 UNIMPLEMENTED();
1775 return false;
1776}
1777
1778bool ValidateGetProgramPipelineInfoLog(Context *context,
1779 GLuint pipeline,
1780 GLsizei bufSize,
1781 GLsizei *length,
1782 GLchar *infoLog)
1783{
1784 UNIMPLEMENTED();
1785 return false;
1786}
1787
1788bool ValidateMemoryBarrier(Context *context, GLbitfield barriers)
1789{
Xinghua Cao89c422a2017-11-29 18:24:20 +08001790 if (context->getClientVersion() < ES_3_1)
1791 {
1792 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1793 return false;
1794 }
1795
1796 if (barriers == GL_ALL_BARRIER_BITS)
1797 {
1798 return true;
1799 }
1800
1801 GLbitfield supported_barrier_bits =
1802 GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT | GL_ELEMENT_ARRAY_BARRIER_BIT | GL_UNIFORM_BARRIER_BIT |
1803 GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL_COMMAND_BARRIER_BIT |
1804 GL_PIXEL_BUFFER_BARRIER_BIT | GL_TEXTURE_UPDATE_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT |
1805 GL_FRAMEBUFFER_BARRIER_BIT | GL_TRANSFORM_FEEDBACK_BARRIER_BIT |
1806 GL_ATOMIC_COUNTER_BARRIER_BIT | GL_SHADER_STORAGE_BARRIER_BIT;
1807 if ((barriers & ~supported_barrier_bits) != 0)
1808 {
1809 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMemoryBarrierBit);
1810 return false;
1811 }
1812
1813 return true;
Jiajia Qin5451d532017-11-16 17:16:34 +08001814}
1815
1816bool ValidateMemoryBarrierByRegion(Context *context, GLbitfield barriers)
1817{
Xinghua Cao89c422a2017-11-29 18:24:20 +08001818 if (context->getClientVersion() < ES_3_1)
1819 {
1820 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1821 return false;
1822 }
1823
1824 if (barriers == GL_ALL_BARRIER_BITS)
1825 {
1826 return true;
1827 }
1828
1829 GLbitfield supported_barrier_bits = GL_ATOMIC_COUNTER_BARRIER_BIT | GL_FRAMEBUFFER_BARRIER_BIT |
1830 GL_SHADER_IMAGE_ACCESS_BARRIER_BIT |
1831 GL_SHADER_STORAGE_BARRIER_BIT |
1832 GL_TEXTURE_FETCH_BARRIER_BIT | GL_UNIFORM_BARRIER_BIT;
1833 if ((barriers & ~supported_barrier_bits) != 0)
1834 {
1835 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMemoryBarrierBit);
1836 return false;
1837 }
1838
1839 return true;
Jiajia Qin5451d532017-11-16 17:16:34 +08001840}
1841
1842bool ValidateSampleMaski(Context *context, GLuint maskNumber, GLbitfield mask)
Jiawei Shaodb342272017-09-27 10:21:45 +08001843{
1844 if (context->getClientVersion() < ES_3_1)
1845 {
1846 ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required);
1847 return false;
1848 }
1849
1850 if (maskNumber >= context->getCaps().maxSampleMaskWords)
1851 {
1852 ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidSampleMaskNumber);
1853 return false;
1854 }
1855
1856 return true;
1857}
1858
Martin Radev66fb8202016-07-28 11:45:20 +03001859} // namespace gl