Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1 | // |
| 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 Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 9 | #include "libANGLE/validationES31.h" |
| 10 | |
| 11 | #include "libANGLE/Context.h" |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 12 | #include "libANGLE/ErrorStrings.h" |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 13 | #include "libANGLE/Framebuffer.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 14 | #include "libANGLE/VertexArray.h" |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 15 | #include "libANGLE/validationES.h" |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 16 | #include "libANGLE/validationES2.h" |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 17 | #include "libANGLE/validationES3.h" |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 18 | |
He Yunchao | 11b038b | 2016-11-22 21:24:04 +0800 | [diff] [blame] | 19 | #include "common/utilities.h" |
| 20 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 21 | using namespace angle; |
| 22 | |
| 23 | namespace gl |
| 24 | { |
| 25 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 26 | namespace |
| 27 | { |
| 28 | |
| 29 | bool 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 | |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 46 | bool 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 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 59 | bool ValidateProgramInterface(GLenum programInterface) |
| 60 | { |
| 61 | return (programInterface == GL_ATOMIC_COUNTER_BUFFER || |
| 62 | ValidateNamedProgramInterface(programInterface)); |
| 63 | } |
| 64 | |
| 65 | bool 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 |
| 106 | bool 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 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 248 | bool 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 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 260 | case GL_UNIFORM: |
jchen10 | baf5d94 | 2017-08-28 20:45:48 +0800 | [diff] [blame] | 261 | return (index < static_cast<GLuint>(programObject->getActiveUniformCount())); |
| 262 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 263 | case GL_UNIFORM_BLOCK: |
jchen10 | 58f67be | 2017-10-27 08:59:27 +0800 | [diff] [blame^] | 264 | return (index < programObject->getActiveUniformBlockCount()); |
| 265 | |
| 266 | case GL_ATOMIC_COUNTER_BUFFER: |
| 267 | return (index < programObject->getActiveAtomicCounterBufferCount()); |
| 268 | |
| 269 | // TODO(jie.a.chen@intel.com): more interfaces. |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 270 | case GL_TRANSFORM_FEEDBACK_VARYING: |
| 271 | case GL_BUFFER_VARIABLE: |
| 272 | case GL_SHADER_STORAGE_BLOCK: |
| 273 | UNIMPLEMENTED(); |
| 274 | return false; |
| 275 | |
| 276 | default: |
| 277 | UNREACHABLE(); |
| 278 | return false; |
| 279 | } |
| 280 | } |
| 281 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 282 | } // anonymous namespace |
| 283 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 284 | bool ValidateGetBooleani_v(Context *context, GLenum target, GLuint index, GLboolean *data) |
| 285 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 286 | if (context->getClientVersion() < ES_3_1) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 287 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 288 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 289 | return false; |
| 290 | } |
| 291 | |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 292 | if (!ValidateIndexedStateQuery(context, target, index, nullptr)) |
| 293 | { |
| 294 | return false; |
| 295 | } |
| 296 | |
| 297 | return true; |
| 298 | } |
| 299 | |
| 300 | bool ValidateGetBooleani_vRobustANGLE(Context *context, |
| 301 | GLenum target, |
| 302 | GLuint index, |
| 303 | GLsizei bufSize, |
| 304 | GLsizei *length, |
| 305 | GLboolean *data) |
| 306 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 307 | if (context->getClientVersion() < ES_3_1) |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 308 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 309 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 310 | return false; |
| 311 | } |
| 312 | |
| 313 | if (!ValidateRobustEntryPoint(context, bufSize)) |
| 314 | { |
| 315 | return false; |
| 316 | } |
| 317 | |
| 318 | if (!ValidateIndexedStateQuery(context, target, index, length)) |
| 319 | { |
| 320 | return false; |
| 321 | } |
| 322 | |
| 323 | if (!ValidateRobustBufferSize(context, bufSize, *length)) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 324 | { |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | return true; |
| 329 | } |
| 330 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 331 | bool ValidateDrawIndirectBase(Context *context, GLenum mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 332 | { |
| 333 | if (context->getClientVersion() < ES_3_1) |
| 334 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 335 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 336 | return false; |
| 337 | } |
| 338 | |
| 339 | // Here the third parameter 1 is only to pass the count validation. |
| 340 | if (!ValidateDrawBase(context, mode, 1)) |
| 341 | { |
| 342 | return false; |
| 343 | } |
| 344 | |
| 345 | const State &state = context->getGLState(); |
| 346 | |
| 347 | // An INVALID_OPERATION error is generated if zero is bound to VERTEX_ARRAY_BINDING, |
| 348 | // DRAW_INDIRECT_BUFFER or to any enabled vertex array. |
| 349 | if (!state.getVertexArrayId()) |
| 350 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 351 | context->handleError(InvalidOperation() << "zero is bound to VERTEX_ARRAY_BINDING"); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 352 | return false; |
| 353 | } |
| 354 | |
| 355 | gl::Buffer *drawIndirectBuffer = state.getDrawIndirectBuffer(); |
| 356 | if (!drawIndirectBuffer) |
| 357 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 358 | context->handleError(InvalidOperation() << "zero is bound to DRAW_INDIRECT_BUFFER"); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 359 | return false; |
| 360 | } |
| 361 | |
| 362 | // An INVALID_VALUE error is generated if indirect is not a multiple of the size, in basic |
| 363 | // machine units, of uint. |
| 364 | GLint64 offset = reinterpret_cast<GLint64>(indirect); |
| 365 | if ((static_cast<GLuint>(offset) % sizeof(GLuint)) != 0) |
| 366 | { |
| 367 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 368 | InvalidValue() |
| 369 | << "indirect is not a multiple of the size, in basic machine units, of uint"); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 370 | return false; |
| 371 | } |
| 372 | |
Martin Radev | 14a26ae | 2017-07-24 15:56:29 +0300 | [diff] [blame] | 373 | // ANGLE_multiview spec, revision 1: |
| 374 | // An INVALID_OPERATION is generated by DrawArraysIndirect and DrawElementsIndirect if the |
| 375 | // number of views in the draw framebuffer is greater than 1. |
| 376 | const Framebuffer *drawFramebuffer = context->getGLState().getDrawFramebuffer(); |
| 377 | ASSERT(drawFramebuffer != nullptr); |
| 378 | if (drawFramebuffer->getNumViews() > 1) |
| 379 | { |
| 380 | context->handleError( |
| 381 | InvalidOperation() |
| 382 | << "The number of views in the active draw framebuffer is greater than 1."); |
| 383 | return false; |
| 384 | } |
| 385 | |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 386 | return true; |
| 387 | } |
| 388 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 389 | bool ValidateDrawArraysIndirect(Context *context, GLenum mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 390 | { |
| 391 | const State &state = context->getGLState(); |
| 392 | gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
| 393 | if (curTransformFeedback && curTransformFeedback->isActive() && |
| 394 | !curTransformFeedback->isPaused()) |
| 395 | { |
| 396 | // An INVALID_OPERATION error is generated if transform feedback is active and not paused. |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 397 | context->handleError(InvalidOperation() << "transform feedback is active and not paused."); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 398 | return false; |
| 399 | } |
| 400 | |
| 401 | if (!ValidateDrawIndirectBase(context, mode, indirect)) |
| 402 | return false; |
| 403 | |
| 404 | gl::Buffer *drawIndirectBuffer = state.getDrawIndirectBuffer(); |
| 405 | CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect)); |
| 406 | // In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawArraysIndirectCommand |
| 407 | // which's size is 4 * sizeof(uint). |
| 408 | auto checkedSum = checkedOffset + 4 * sizeof(GLuint); |
| 409 | if (!checkedSum.IsValid() || |
| 410 | checkedSum.ValueOrDie() > static_cast<size_t>(drawIndirectBuffer->getSize())) |
| 411 | { |
| 412 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 413 | InvalidOperation() |
| 414 | << "the command would source data beyond the end of the buffer object."); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 415 | return false; |
| 416 | } |
| 417 | |
| 418 | return true; |
| 419 | } |
| 420 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 421 | bool ValidateDrawElementsIndirect(Context *context, GLenum mode, GLenum type, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 422 | { |
| 423 | if (!ValidateDrawElementsBase(context, type)) |
| 424 | return false; |
| 425 | |
| 426 | const State &state = context->getGLState(); |
| 427 | const VertexArray *vao = state.getVertexArray(); |
| 428 | gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer().get(); |
| 429 | if (!elementArrayBuffer) |
| 430 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 431 | context->handleError(InvalidOperation() << "zero is bound to ELEMENT_ARRAY_BUFFER"); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 432 | return false; |
| 433 | } |
| 434 | |
| 435 | if (!ValidateDrawIndirectBase(context, mode, indirect)) |
| 436 | return false; |
| 437 | |
| 438 | gl::Buffer *drawIndirectBuffer = state.getDrawIndirectBuffer(); |
| 439 | CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect)); |
| 440 | // In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawElementsIndirectCommand |
| 441 | // which's size is 5 * sizeof(uint). |
| 442 | auto checkedSum = checkedOffset + 5 * sizeof(GLuint); |
| 443 | if (!checkedSum.IsValid() || |
| 444 | checkedSum.ValueOrDie() > static_cast<size_t>(drawIndirectBuffer->getSize())) |
| 445 | { |
| 446 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 447 | InvalidOperation() |
| 448 | << "the command would source data beyond the end of the buffer object."); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 449 | return false; |
| 450 | } |
| 451 | |
| 452 | return true; |
| 453 | } |
| 454 | |
He Yunchao | 11b038b | 2016-11-22 21:24:04 +0800 | [diff] [blame] | 455 | bool ValidateGetTexLevelParameterBase(Context *context, |
| 456 | GLenum target, |
| 457 | GLint level, |
| 458 | GLenum pname, |
| 459 | GLsizei *length) |
| 460 | { |
| 461 | if (context->getClientVersion() < ES_3_1) |
| 462 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 463 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
He Yunchao | 11b038b | 2016-11-22 21:24:04 +0800 | [diff] [blame] | 464 | return false; |
| 465 | } |
| 466 | |
| 467 | if (length) |
| 468 | { |
| 469 | *length = 0; |
| 470 | } |
| 471 | |
| 472 | if (!ValidTexLevelDestinationTarget(context, target)) |
| 473 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 474 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget); |
He Yunchao | 11b038b | 2016-11-22 21:24:04 +0800 | [diff] [blame] | 475 | return false; |
| 476 | } |
| 477 | |
| 478 | if (context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target) == |
| 479 | nullptr) |
| 480 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 481 | context->handleError(InvalidEnum() << "No texture bound."); |
He Yunchao | 11b038b | 2016-11-22 21:24:04 +0800 | [diff] [blame] | 482 | return false; |
| 483 | } |
| 484 | |
| 485 | if (!ValidMipLevel(context, target, level)) |
| 486 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 487 | context->handleError(InvalidValue()); |
He Yunchao | 11b038b | 2016-11-22 21:24:04 +0800 | [diff] [blame] | 488 | return false; |
| 489 | } |
| 490 | |
| 491 | switch (pname) |
| 492 | { |
| 493 | case GL_TEXTURE_RED_TYPE: |
| 494 | case GL_TEXTURE_GREEN_TYPE: |
| 495 | case GL_TEXTURE_BLUE_TYPE: |
| 496 | case GL_TEXTURE_ALPHA_TYPE: |
| 497 | case GL_TEXTURE_DEPTH_TYPE: |
| 498 | break; |
| 499 | case GL_TEXTURE_RED_SIZE: |
| 500 | case GL_TEXTURE_GREEN_SIZE: |
| 501 | case GL_TEXTURE_BLUE_SIZE: |
| 502 | case GL_TEXTURE_ALPHA_SIZE: |
| 503 | case GL_TEXTURE_DEPTH_SIZE: |
| 504 | case GL_TEXTURE_STENCIL_SIZE: |
| 505 | case GL_TEXTURE_SHARED_SIZE: |
| 506 | break; |
| 507 | case GL_TEXTURE_INTERNAL_FORMAT: |
| 508 | case GL_TEXTURE_WIDTH: |
| 509 | case GL_TEXTURE_HEIGHT: |
| 510 | case GL_TEXTURE_DEPTH: |
| 511 | break; |
| 512 | case GL_TEXTURE_SAMPLES: |
| 513 | case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS: |
| 514 | break; |
| 515 | case GL_TEXTURE_COMPRESSED: |
| 516 | break; |
| 517 | default: |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 518 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname); |
He Yunchao | 11b038b | 2016-11-22 21:24:04 +0800 | [diff] [blame] | 519 | return false; |
| 520 | } |
| 521 | |
| 522 | if (length) |
| 523 | { |
| 524 | *length = 1; |
| 525 | } |
| 526 | return true; |
| 527 | } |
| 528 | |
| 529 | bool ValidateGetTexLevelParameterfv(Context *context, |
| 530 | GLenum target, |
| 531 | GLint level, |
| 532 | GLenum pname, |
| 533 | GLfloat *params) |
| 534 | { |
| 535 | return ValidateGetTexLevelParameterBase(context, target, level, pname, nullptr); |
| 536 | } |
| 537 | |
| 538 | bool ValidateGetTexLevelParameteriv(Context *context, |
| 539 | GLenum target, |
| 540 | GLint level, |
| 541 | GLenum pname, |
| 542 | GLint *params) |
| 543 | { |
| 544 | return ValidateGetTexLevelParameterBase(context, target, level, pname, nullptr); |
| 545 | } |
| 546 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 547 | bool ValidateTexStorage2DMultiSample(Context *context, |
| 548 | GLenum target, |
| 549 | GLsizei samples, |
| 550 | GLint internalFormat, |
| 551 | GLsizei width, |
| 552 | GLsizei height, |
| 553 | GLboolean fixedSampleLocations) |
| 554 | { |
| 555 | if (context->getClientVersion() < ES_3_1) |
| 556 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 557 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 558 | return false; |
| 559 | } |
| 560 | |
| 561 | if (target != GL_TEXTURE_2D_MULTISAMPLE) |
| 562 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 563 | context->handleError(InvalidEnum() << "Target must be TEXTURE_2D_MULTISAMPLE."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 564 | return false; |
| 565 | } |
| 566 | |
| 567 | if (width < 1 || height < 1) |
| 568 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 569 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeSize); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 570 | return false; |
| 571 | } |
| 572 | |
| 573 | const Caps &caps = context->getCaps(); |
| 574 | if (static_cast<GLuint>(width) > caps.max2DTextureSize || |
| 575 | static_cast<GLuint>(height) > caps.max2DTextureSize) |
| 576 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 577 | context |
| 578 | ->handleError(InvalidValue() |
| 579 | << "Width and height must be less than or equal to GL_MAX_TEXTURE_SIZE."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 580 | return false; |
| 581 | } |
| 582 | |
| 583 | if (samples == 0) |
| 584 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 585 | context->handleError(InvalidValue() << "Samples may not be zero."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 586 | return false; |
| 587 | } |
| 588 | |
| 589 | const TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat); |
| 590 | if (!formatCaps.renderable) |
| 591 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 592 | context->handleError(InvalidEnum() << "SizedInternalformat must be color-renderable, " |
| 593 | "depth-renderable, or stencil-renderable."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 594 | return false; |
| 595 | } |
| 596 | |
| 597 | // The ES3.1 spec(section 8.8) states that an INVALID_ENUM error is generated if internalformat |
| 598 | // is one of the unsized base internalformats listed in table 8.11. |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 599 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(internalFormat); |
| 600 | if (formatInfo.internalFormat == GL_NONE) |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 601 | { |
| 602 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 603 | InvalidEnum() |
| 604 | << "Internalformat is one of the unsupported unsized base internalformats."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 605 | return false; |
| 606 | } |
| 607 | |
| 608 | if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples()) |
| 609 | { |
| 610 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 611 | InvalidOperation() |
| 612 | << "Samples must not be greater than maximum supported value for the format."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 613 | return false; |
| 614 | } |
| 615 | |
| 616 | Texture *texture = context->getTargetTexture(target); |
| 617 | if (!texture || texture->id() == 0) |
| 618 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 619 | context->handleError(InvalidOperation() << "Zero is bound to target."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 620 | return false; |
| 621 | } |
| 622 | |
| 623 | if (texture->getImmutableFormat()) |
| 624 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 625 | context->handleError(InvalidOperation() << "The value of TEXTURE_IMMUTABLE_FORMAT for " |
| 626 | "the texture currently bound to target on " |
| 627 | "the active texture unit is true."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 628 | return false; |
| 629 | } |
| 630 | |
| 631 | return true; |
| 632 | } |
| 633 | |
| 634 | bool ValidateGetMultisamplefv(Context *context, GLenum pname, GLuint index, GLfloat *val) |
| 635 | { |
| 636 | if (context->getClientVersion() < ES_3_1) |
| 637 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 638 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 639 | return false; |
| 640 | } |
| 641 | |
| 642 | if (pname != GL_SAMPLE_POSITION) |
| 643 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 644 | context->handleError(InvalidEnum() << "Pname must be SAMPLE_POSITION."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 645 | return false; |
| 646 | } |
| 647 | |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 648 | Framebuffer *framebuffer = context->getGLState().getDrawFramebuffer(); |
| 649 | |
| 650 | if (index >= static_cast<GLuint>(framebuffer->getSamples(context))) |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 651 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 652 | context->handleError(InvalidValue() << "Index must be less than the value of SAMPLES."); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 653 | return false; |
| 654 | } |
| 655 | |
| 656 | return true; |
| 657 | } |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 658 | |
| 659 | bool ValidationFramebufferParameteri(Context *context, GLenum target, GLenum pname, GLint param) |
| 660 | { |
| 661 | if (context->getClientVersion() < ES_3_1) |
| 662 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 663 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 664 | return false; |
| 665 | } |
| 666 | |
| 667 | if (!ValidFramebufferTarget(target)) |
| 668 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 669 | context->handleError(InvalidEnum() << "Invalid framebuffer target."); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 670 | return false; |
| 671 | } |
| 672 | |
| 673 | switch (pname) |
| 674 | { |
| 675 | case GL_FRAMEBUFFER_DEFAULT_WIDTH: |
| 676 | { |
| 677 | GLint maxWidth = context->getCaps().maxFramebufferWidth; |
| 678 | if (param < 0 || param > maxWidth) |
| 679 | { |
| 680 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 681 | InvalidValue() |
| 682 | << "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_WIDTH."); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 683 | return false; |
| 684 | } |
| 685 | break; |
| 686 | } |
| 687 | case GL_FRAMEBUFFER_DEFAULT_HEIGHT: |
| 688 | { |
| 689 | GLint maxHeight = context->getCaps().maxFramebufferHeight; |
| 690 | if (param < 0 || param > maxHeight) |
| 691 | { |
| 692 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 693 | InvalidValue() |
| 694 | << "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_HEIGHT."); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 695 | return false; |
| 696 | } |
| 697 | break; |
| 698 | } |
| 699 | case GL_FRAMEBUFFER_DEFAULT_SAMPLES: |
| 700 | { |
| 701 | GLint maxSamples = context->getCaps().maxFramebufferSamples; |
| 702 | if (param < 0 || param > maxSamples) |
| 703 | { |
| 704 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 705 | InvalidValue() |
| 706 | << "Params less than 0 or greater than GL_MAX_FRAMEBUFFER_SAMPLES."); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 707 | return false; |
| 708 | } |
| 709 | break; |
| 710 | } |
| 711 | case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS: |
| 712 | { |
| 713 | break; |
| 714 | } |
| 715 | default: |
| 716 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 717 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 718 | return false; |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target); |
| 723 | ASSERT(framebuffer); |
| 724 | if (framebuffer->id() == 0) |
| 725 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 726 | context->handleError(InvalidOperation() << "Default framebuffer is bound to target."); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 727 | return false; |
| 728 | } |
| 729 | return true; |
| 730 | } |
| 731 | |
| 732 | bool ValidationGetFramebufferParameteri(Context *context, |
| 733 | GLenum target, |
| 734 | GLenum pname, |
| 735 | GLint *params) |
| 736 | { |
| 737 | if (context->getClientVersion() < ES_3_1) |
| 738 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 739 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 740 | return false; |
| 741 | } |
| 742 | |
| 743 | if (!ValidFramebufferTarget(target)) |
| 744 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 745 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 746 | return false; |
| 747 | } |
| 748 | |
| 749 | switch (pname) |
| 750 | { |
| 751 | case GL_FRAMEBUFFER_DEFAULT_WIDTH: |
| 752 | case GL_FRAMEBUFFER_DEFAULT_HEIGHT: |
| 753 | case GL_FRAMEBUFFER_DEFAULT_SAMPLES: |
| 754 | case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS: |
| 755 | break; |
| 756 | default: |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 757 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 758 | return false; |
| 759 | } |
| 760 | |
| 761 | const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target); |
| 762 | ASSERT(framebuffer); |
| 763 | |
| 764 | if (framebuffer->id() == 0) |
| 765 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 766 | context->handleError(InvalidOperation() << "Default framebuffer is bound to target."); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 767 | return false; |
| 768 | } |
| 769 | return true; |
| 770 | } |
| 771 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 772 | bool ValidateGetProgramResourceIndex(Context *context, |
| 773 | GLuint program, |
| 774 | GLenum programInterface, |
| 775 | const GLchar *name) |
| 776 | { |
| 777 | if (context->getClientVersion() < ES_3_1) |
| 778 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 779 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 780 | return false; |
| 781 | } |
| 782 | |
| 783 | Program *programObject = GetValidProgram(context, program); |
| 784 | if (programObject == nullptr) |
| 785 | { |
| 786 | return false; |
| 787 | } |
| 788 | |
| 789 | if (!ValidateNamedProgramInterface(programInterface)) |
| 790 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 791 | context->handleError(InvalidEnum() << "Invalid program interface: 0x" << std::hex |
| 792 | << std::uppercase << programInterface); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 793 | return false; |
| 794 | } |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 795 | |
| 796 | return true; |
| 797 | } |
| 798 | |
| 799 | bool ValidateBindVertexBuffer(ValidationContext *context, |
| 800 | GLuint bindingIndex, |
| 801 | GLuint buffer, |
| 802 | GLintptr offset, |
| 803 | GLsizei stride) |
| 804 | { |
| 805 | if (context->getClientVersion() < ES_3_1) |
| 806 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 807 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 808 | return false; |
| 809 | } |
| 810 | |
| 811 | if (!context->isBufferGenerated(buffer)) |
| 812 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 813 | context->handleError(InvalidOperation() << "Buffer is not generated."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 814 | return false; |
| 815 | } |
| 816 | |
| 817 | const Caps &caps = context->getCaps(); |
| 818 | if (bindingIndex >= caps.maxVertexAttribBindings) |
| 819 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 820 | context->handleError(InvalidValue() |
| 821 | << "bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 822 | return false; |
| 823 | } |
| 824 | |
| 825 | if (offset < 0) |
| 826 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 827 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeOffset); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 828 | return false; |
| 829 | } |
| 830 | |
| 831 | if (stride < 0 || stride > caps.maxVertexAttribStride) |
| 832 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 833 | context->handleError(InvalidValue() |
| 834 | << "stride must be between 0 and MAX_VERTEX_ATTRIB_STRIDE."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 835 | return false; |
| 836 | } |
| 837 | |
| 838 | // [OpenGL ES 3.1] Section 10.3.1 page 244: |
| 839 | // An INVALID_OPERATION error is generated if the default vertex array object is bound. |
| 840 | if (context->getGLState().getVertexArrayId() == 0) |
| 841 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 842 | context->handleError(InvalidOperation() << "Default vertex array buffer is bound."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 843 | return false; |
| 844 | } |
| 845 | |
| 846 | return true; |
| 847 | } |
| 848 | |
| 849 | bool ValidateVertexBindingDivisor(ValidationContext *context, GLuint bindingIndex, GLuint divisor) |
| 850 | { |
| 851 | if (context->getClientVersion() < ES_3_1) |
| 852 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 853 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 854 | return false; |
| 855 | } |
| 856 | |
| 857 | const Caps &caps = context->getCaps(); |
| 858 | if (bindingIndex >= caps.maxVertexAttribBindings) |
| 859 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 860 | context->handleError(InvalidValue() |
| 861 | << "bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 862 | return false; |
| 863 | } |
| 864 | |
| 865 | // [OpenGL ES 3.1] Section 10.3.1 page 243: |
| 866 | // An INVALID_OPERATION error is generated if the default vertex array object is bound. |
| 867 | if (context->getGLState().getVertexArrayId() == 0) |
| 868 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 869 | context->handleError(InvalidOperation() << "Default vertex array object is bound."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 870 | return false; |
| 871 | } |
| 872 | |
| 873 | return true; |
| 874 | } |
| 875 | |
| 876 | bool ValidateVertexAttribFormat(ValidationContext *context, |
| 877 | GLuint attribIndex, |
| 878 | GLint size, |
| 879 | GLenum type, |
| 880 | GLuint relativeOffset, |
| 881 | GLboolean pureInteger) |
| 882 | { |
| 883 | if (context->getClientVersion() < ES_3_1) |
| 884 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 885 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 886 | return false; |
| 887 | } |
| 888 | |
| 889 | const Caps &caps = context->getCaps(); |
| 890 | if (relativeOffset > static_cast<GLuint>(caps.maxVertexAttribRelativeOffset)) |
| 891 | { |
| 892 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 893 | InvalidValue() |
| 894 | << "relativeOffset cannot be greater than MAX_VERTEX_ATTRIB_RELATIVE_OFFSET."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 895 | return false; |
| 896 | } |
| 897 | |
| 898 | // [OpenGL ES 3.1] Section 10.3.1 page 243: |
| 899 | // An INVALID_OPERATION error is generated if the default vertex array object is bound. |
| 900 | if (context->getGLState().getVertexArrayId() == 0) |
| 901 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 902 | context->handleError(InvalidOperation() << "Default vertex array object is bound."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 903 | return false; |
| 904 | } |
| 905 | |
| 906 | return ValidateVertexFormatBase(context, attribIndex, size, type, pureInteger); |
| 907 | } |
| 908 | |
| 909 | bool ValidateVertexAttribBinding(ValidationContext *context, |
| 910 | GLuint attribIndex, |
| 911 | GLuint bindingIndex) |
| 912 | { |
| 913 | if (context->getClientVersion() < ES_3_1) |
| 914 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 915 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 916 | return false; |
| 917 | } |
| 918 | |
| 919 | // [OpenGL ES 3.1] Section 10.3.1 page 243: |
| 920 | // An INVALID_OPERATION error is generated if the default vertex array object is bound. |
| 921 | if (context->getGLState().getVertexArrayId() == 0) |
| 922 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 923 | context->handleError(InvalidOperation() << "Default vertex array object is bound."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 924 | return false; |
| 925 | } |
| 926 | |
| 927 | const Caps &caps = context->getCaps(); |
| 928 | if (attribIndex >= caps.maxVertexAttributes) |
| 929 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 930 | ANGLE_VALIDATION_ERR(context, InvalidValue(), IndexExceedsMaxVertexAttribute); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 931 | return false; |
| 932 | } |
| 933 | |
| 934 | if (bindingIndex >= caps.maxVertexAttribBindings) |
| 935 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 936 | context->handleError(InvalidValue() |
| 937 | << "bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS"); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 938 | return false; |
| 939 | } |
| 940 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 941 | return true; |
| 942 | } |
| 943 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 944 | bool ValidateGetProgramResourceName(Context *context, |
| 945 | GLuint program, |
| 946 | GLenum programInterface, |
| 947 | GLuint index, |
| 948 | GLsizei bufSize, |
| 949 | GLsizei *length, |
| 950 | GLchar *name) |
| 951 | { |
| 952 | if (context->getClientVersion() < ES_3_1) |
| 953 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 954 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 955 | return false; |
| 956 | } |
| 957 | |
| 958 | Program *programObject = GetValidProgram(context, program); |
| 959 | if (programObject == nullptr) |
| 960 | { |
| 961 | return false; |
| 962 | } |
| 963 | |
| 964 | if (!ValidateNamedProgramInterface(programInterface)) |
| 965 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 966 | context->handleError(InvalidEnum() << "Invalid program interface: 0x" << std::hex |
| 967 | << std::uppercase << programInterface); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 968 | return false; |
| 969 | } |
| 970 | |
| 971 | if (!ValidateProgramResourceIndex(programObject, programInterface, index)) |
| 972 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 973 | context->handleError(InvalidValue() << "Invalid index: " << index); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 974 | return false; |
| 975 | } |
| 976 | |
| 977 | if (bufSize < 0) |
| 978 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 979 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 980 | return false; |
| 981 | } |
| 982 | |
| 983 | return true; |
| 984 | } |
| 985 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 986 | bool ValidateDispatchCompute(Context *context, |
| 987 | GLuint numGroupsX, |
| 988 | GLuint numGroupsY, |
| 989 | GLuint numGroupsZ) |
| 990 | { |
| 991 | if (context->getClientVersion() < ES_3_1) |
| 992 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 993 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 994 | return false; |
| 995 | } |
| 996 | |
| 997 | const State &state = context->getGLState(); |
| 998 | Program *program = state.getProgram(); |
| 999 | |
| 1000 | if (program == nullptr) |
| 1001 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1002 | context->handleError(InvalidOperation() |
| 1003 | << "No active program object for the compute shader stage."); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 1004 | return false; |
| 1005 | } |
| 1006 | |
| 1007 | if (program->isLinked() == false || program->getAttachedComputeShader() == nullptr) |
| 1008 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1009 | context->handleError( |
| 1010 | InvalidOperation() |
| 1011 | << "Program has not been successfully linked, or program contains no compute shaders."); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 1012 | return false; |
| 1013 | } |
| 1014 | |
| 1015 | const Caps &caps = context->getCaps(); |
| 1016 | if (numGroupsX > caps.maxComputeWorkGroupCount[0]) |
| 1017 | { |
| 1018 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1019 | InvalidValue() << "num_groups_x cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[0]=" |
| 1020 | << caps.maxComputeWorkGroupCount[0]); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 1021 | return false; |
| 1022 | } |
| 1023 | if (numGroupsY > caps.maxComputeWorkGroupCount[1]) |
| 1024 | { |
| 1025 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1026 | InvalidValue() << "num_groups_y cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[1]=" |
| 1027 | << caps.maxComputeWorkGroupCount[1]); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 1028 | return false; |
| 1029 | } |
| 1030 | if (numGroupsZ > caps.maxComputeWorkGroupCount[2]) |
| 1031 | { |
| 1032 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1033 | InvalidValue() << "num_groups_z cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[2]=" |
| 1034 | << caps.maxComputeWorkGroupCount[2]); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 1035 | return false; |
| 1036 | } |
| 1037 | |
| 1038 | return true; |
| 1039 | } |
| 1040 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1041 | bool ValidateBindImageTexture(Context *context, |
| 1042 | GLuint unit, |
| 1043 | GLuint texture, |
| 1044 | GLint level, |
| 1045 | GLboolean layered, |
| 1046 | GLint layer, |
| 1047 | GLenum access, |
| 1048 | GLenum format) |
| 1049 | { |
| 1050 | GLuint maxImageUnits = context->getCaps().maxImageUnits; |
| 1051 | if (unit >= maxImageUnits) |
| 1052 | { |
| 1053 | context->handleError(InvalidValue() |
| 1054 | << "unit cannot be greater than or equal than MAX_IMAGE_UNITS = " |
| 1055 | << maxImageUnits); |
| 1056 | return false; |
| 1057 | } |
| 1058 | |
| 1059 | if (level < 0) |
| 1060 | { |
| 1061 | context->handleError(InvalidValue() << "level is negative."); |
| 1062 | return false; |
| 1063 | } |
| 1064 | |
| 1065 | if (layer < 0) |
| 1066 | { |
| 1067 | context->handleError(InvalidValue() << "layer is negative."); |
| 1068 | return false; |
| 1069 | } |
| 1070 | |
| 1071 | if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE) |
| 1072 | { |
| 1073 | context->handleError(InvalidEnum() << "access is not one of the supported tokens."); |
| 1074 | return false; |
| 1075 | } |
| 1076 | |
| 1077 | switch (format) |
| 1078 | { |
| 1079 | case GL_RGBA32F: |
| 1080 | case GL_RGBA16F: |
| 1081 | case GL_R32F: |
| 1082 | case GL_RGBA32UI: |
| 1083 | case GL_RGBA16UI: |
| 1084 | case GL_RGBA8UI: |
| 1085 | case GL_R32UI: |
| 1086 | case GL_RGBA32I: |
| 1087 | case GL_RGBA16I: |
| 1088 | case GL_RGBA8I: |
| 1089 | case GL_R32I: |
| 1090 | case GL_RGBA8: |
| 1091 | case GL_RGBA8_SNORM: |
| 1092 | break; |
| 1093 | default: |
| 1094 | context->handleError(InvalidValue() |
| 1095 | << "format is not one of supported image unit formats."); |
| 1096 | return false; |
| 1097 | } |
| 1098 | |
| 1099 | if (texture != 0) |
| 1100 | { |
| 1101 | Texture *tex = context->getTexture(texture); |
| 1102 | |
| 1103 | if (tex == nullptr) |
| 1104 | { |
| 1105 | context->handleError(InvalidValue() |
| 1106 | << "texture is not the name of an existing texture object."); |
| 1107 | return false; |
| 1108 | } |
| 1109 | |
| 1110 | if (!tex->getImmutableFormat()) |
| 1111 | { |
| 1112 | context->handleError(InvalidOperation() |
| 1113 | << "texture is not the name of an immutable texture object."); |
| 1114 | return false; |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | return true; |
| 1119 | } |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 1120 | |
| 1121 | bool ValidateGetProgramResourceLocation(Context *context, |
| 1122 | GLuint program, |
| 1123 | GLenum programInterface, |
| 1124 | const GLchar *name) |
| 1125 | { |
| 1126 | if (context->getClientVersion() < ES_3_1) |
| 1127 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 1128 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 1129 | return false; |
| 1130 | } |
| 1131 | |
| 1132 | Program *programObject = GetValidProgram(context, program); |
| 1133 | if (programObject == nullptr) |
| 1134 | { |
| 1135 | return false; |
| 1136 | } |
| 1137 | |
| 1138 | if (!programObject->isLinked()) |
| 1139 | { |
| 1140 | context->handleError(InvalidOperation() << "Program is not successfully linked."); |
| 1141 | return false; |
| 1142 | } |
| 1143 | |
| 1144 | if (!ValidateLocationProgramInterface(programInterface)) |
| 1145 | { |
| 1146 | context->handleError(InvalidEnum() << "Invalid program interface."); |
| 1147 | return false; |
| 1148 | } |
| 1149 | return true; |
| 1150 | } |
| 1151 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 1152 | bool ValidateGetProgramResourceiv(Context *context, |
| 1153 | GLuint program, |
| 1154 | GLenum programInterface, |
| 1155 | GLuint index, |
| 1156 | GLsizei propCount, |
| 1157 | const GLenum *props, |
| 1158 | GLsizei bufSize, |
| 1159 | GLsizei *length, |
| 1160 | GLint *params) |
| 1161 | { |
| 1162 | if (context->getClientVersion() < ES_3_1) |
| 1163 | { |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 1164 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 1165 | return false; |
| 1166 | } |
| 1167 | |
| 1168 | Program *programObject = GetValidProgram(context, program); |
| 1169 | if (programObject == nullptr) |
| 1170 | { |
| 1171 | return false; |
| 1172 | } |
| 1173 | if (!ValidateProgramInterface(programInterface)) |
| 1174 | { |
| 1175 | context->handleError(InvalidEnum() << "Invalid program interface."); |
| 1176 | return false; |
| 1177 | } |
| 1178 | if (propCount <= 0) |
| 1179 | { |
| 1180 | context->handleError(InvalidValue() << "Invalid propCount."); |
| 1181 | return false; |
| 1182 | } |
| 1183 | if (bufSize < 0) |
| 1184 | { |
| 1185 | context->handleError(InvalidValue() << "Invalid bufSize."); |
| 1186 | return false; |
| 1187 | } |
| 1188 | if (!ValidateProgramResourceIndex(programObject, programInterface, index)) |
| 1189 | { |
| 1190 | context->handleError(InvalidValue() << "Invalid index: " << index); |
| 1191 | return false; |
| 1192 | } |
| 1193 | for (GLsizei i = 0; i < propCount; i++) |
| 1194 | { |
| 1195 | if (!ValidateProgramResourceProperty(props[i])) |
| 1196 | { |
| 1197 | context->handleError(InvalidEnum() << "Invalid prop."); |
| 1198 | return false; |
| 1199 | } |
| 1200 | if (!ValidateProgramResourcePropertyByInterface(props[i], programInterface)) |
| 1201 | { |
| 1202 | context->handleError(InvalidOperation() << "Not an allowed prop for interface"); |
| 1203 | return false; |
| 1204 | } |
| 1205 | } |
| 1206 | return true; |
| 1207 | } |
| 1208 | |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 1209 | bool ValidateGetProgramInterfaceiv(Context *context, |
| 1210 | GLuint program, |
| 1211 | GLenum programInterface, |
| 1212 | GLenum pname, |
| 1213 | GLint *params) |
| 1214 | { |
| 1215 | if (context->getClientVersion() < ES_3_1) |
| 1216 | { |
| 1217 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
| 1218 | return false; |
| 1219 | } |
| 1220 | |
| 1221 | Program *programObject = GetValidProgram(context, program); |
| 1222 | if (programObject == nullptr) |
| 1223 | { |
| 1224 | return false; |
| 1225 | } |
| 1226 | |
| 1227 | if (!ValidateProgramInterface(programInterface)) |
| 1228 | { |
| 1229 | context->handleError(InvalidEnum() << "Invalid program interface."); |
| 1230 | return false; |
| 1231 | } |
| 1232 | |
| 1233 | switch (pname) |
| 1234 | { |
| 1235 | case GL_ACTIVE_RESOURCES: |
| 1236 | case GL_MAX_NAME_LENGTH: |
| 1237 | case GL_MAX_NUM_ACTIVE_VARIABLES: |
| 1238 | break; |
| 1239 | |
| 1240 | default: |
| 1241 | context->handleError(InvalidEnum() << "Unknown property of program interface."); |
| 1242 | return false; |
| 1243 | } |
| 1244 | |
| 1245 | if (pname == GL_MAX_NAME_LENGTH && programInterface == GL_ATOMIC_COUNTER_BUFFER) |
| 1246 | { |
| 1247 | context->handleError(InvalidOperation() |
| 1248 | << "Active atomic counter resources are not assigned name strings."); |
| 1249 | return false; |
| 1250 | } |
| 1251 | |
| 1252 | if (pname == GL_MAX_NUM_ACTIVE_VARIABLES) |
| 1253 | { |
| 1254 | switch (programInterface) |
| 1255 | { |
| 1256 | case GL_ATOMIC_COUNTER_BUFFER: |
| 1257 | case GL_SHADER_STORAGE_BLOCK: |
| 1258 | case GL_UNIFORM_BLOCK: |
| 1259 | break; |
| 1260 | |
| 1261 | default: |
| 1262 | context->handleError( |
| 1263 | InvalidOperation() |
| 1264 | << "MAX_NUM_ACTIVE_VARIABLES requires a buffer or block interface."); |
| 1265 | return false; |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | return true; |
| 1270 | } |
| 1271 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1272 | static bool ValidateGenOrDeleteES31(Context *context, GLint n) |
| 1273 | { |
| 1274 | if (context->getClientVersion() < ES_3_1) |
| 1275 | { |
| 1276 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
| 1277 | return false; |
| 1278 | } |
| 1279 | |
| 1280 | return ValidateGenOrDelete(context, n); |
| 1281 | } |
| 1282 | |
| 1283 | bool ValidateGenProgramPipelines(Context *context, GLint n, GLuint *) |
| 1284 | { |
| 1285 | return ValidateGenOrDeleteES31(context, n); |
| 1286 | } |
| 1287 | |
| 1288 | bool ValidateDeleteProgramPipelines(Context *context, GLint n, const GLuint *) |
| 1289 | { |
| 1290 | return ValidateGenOrDeleteES31(context, n); |
| 1291 | } |
| 1292 | |
| 1293 | bool ValidateBindProgramPipeline(Context *context, GLuint pipeline) |
| 1294 | { |
| 1295 | if (context->getClientVersion() < ES_3_1) |
| 1296 | { |
| 1297 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
| 1298 | return false; |
| 1299 | } |
| 1300 | |
| 1301 | if (!context->isProgramPipelineGenerated(pipeline)) |
| 1302 | { |
| 1303 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ObjectNotGenerated); |
| 1304 | return false; |
| 1305 | } |
| 1306 | |
| 1307 | return true; |
| 1308 | } |
| 1309 | |
| 1310 | bool ValidateIsProgramPipeline(Context *context, GLuint pipeline) |
| 1311 | { |
| 1312 | if (context->getClientVersion() < ES_3_1) |
| 1313 | { |
| 1314 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
| 1315 | return false; |
| 1316 | } |
| 1317 | |
| 1318 | return true; |
| 1319 | } |
| 1320 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 1321 | bool ValidateSampleMaski(Context *context, GLuint maskNumber) |
| 1322 | { |
| 1323 | if (context->getClientVersion() < ES_3_1) |
| 1324 | { |
| 1325 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES31Required); |
| 1326 | return false; |
| 1327 | } |
| 1328 | |
| 1329 | if (maskNumber >= context->getCaps().maxSampleMaskWords) |
| 1330 | { |
| 1331 | ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidSampleMaskNumber); |
| 1332 | return false; |
| 1333 | } |
| 1334 | |
| 1335 | return true; |
| 1336 | } |
| 1337 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1338 | } // namespace gl |