validationES1.cpp (71936B)
1 // 2 // Copyright 2018 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // validationES1.cpp: Validation functions for OpenGL ES 1.0 entry point parameters 8 9 #include "libANGLE/validationES1_autogen.h" 10 11 #include "common/debug.h" 12 #include "libANGLE/Context.h" 13 #include "libANGLE/ErrorStrings.h" 14 #include "libANGLE/GLES1State.h" 15 #include "libANGLE/queryconversions.h" 16 #include "libANGLE/queryutils.h" 17 #include "libANGLE/validationES.h" 18 19 #define ANGLE_VALIDATE_IS_GLES1(context, entryPoint) \ 20 do \ 21 { \ 22 if (context->getClientType() != EGL_OPENGL_API && context->getClientMajorVersion() > 1) \ 23 { \ 24 context->validationError(entryPoint, GL_INVALID_OPERATION, kGLES1Only); \ 25 return false; \ 26 } \ 27 } while (0) 28 29 namespace gl 30 { 31 using namespace err; 32 33 bool ValidateAlphaFuncCommon(const Context *context, 34 angle::EntryPoint entryPoint, 35 AlphaTestFunc func) 36 { 37 switch (func) 38 { 39 case AlphaTestFunc::AlwaysPass: 40 case AlphaTestFunc::Equal: 41 case AlphaTestFunc::Gequal: 42 case AlphaTestFunc::Greater: 43 case AlphaTestFunc::Lequal: 44 case AlphaTestFunc::Less: 45 case AlphaTestFunc::Never: 46 case AlphaTestFunc::NotEqual: 47 return true; 48 default: 49 context->validationError(entryPoint, GL_INVALID_ENUM, kEnumInvalid); 50 return false; 51 } 52 } 53 54 bool ValidateClientStateCommon(const Context *context, 55 angle::EntryPoint entryPoint, 56 ClientVertexArrayType arrayType) 57 { 58 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 59 switch (arrayType) 60 { 61 case ClientVertexArrayType::Vertex: 62 case ClientVertexArrayType::Normal: 63 case ClientVertexArrayType::Color: 64 case ClientVertexArrayType::TextureCoord: 65 return true; 66 case ClientVertexArrayType::PointSize: 67 if (!context->getExtensions().pointSizeArrayOES) 68 { 69 context->validationError(entryPoint, GL_INVALID_ENUM, 70 kPointSizeArrayExtensionNotEnabled); 71 return false; 72 } 73 return true; 74 default: 75 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidClientState); 76 return false; 77 } 78 } 79 80 bool ValidateBuiltinVertexAttributeCommon(const Context *context, 81 angle::EntryPoint entryPoint, 82 ClientVertexArrayType arrayType, 83 GLint size, 84 VertexAttribType type, 85 GLsizei stride, 86 const void *pointer) 87 { 88 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 89 90 if (stride < 0) 91 { 92 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidVertexPointerStride); 93 return false; 94 } 95 96 int minSize = 1; 97 int maxSize = 4; 98 99 switch (arrayType) 100 { 101 case ClientVertexArrayType::Vertex: 102 case ClientVertexArrayType::TextureCoord: 103 minSize = 2; 104 maxSize = 4; 105 break; 106 case ClientVertexArrayType::Normal: 107 minSize = 3; 108 maxSize = 3; 109 break; 110 case ClientVertexArrayType::Color: 111 minSize = 4; 112 maxSize = 4; 113 break; 114 case ClientVertexArrayType::PointSize: 115 if (!context->getExtensions().pointSizeArrayOES) 116 { 117 context->validationError(entryPoint, GL_INVALID_ENUM, 118 kPointSizeArrayExtensionNotEnabled); 119 return false; 120 } 121 122 minSize = 1; 123 maxSize = 1; 124 break; 125 default: 126 UNREACHABLE(); 127 return false; 128 } 129 130 if (size < minSize || size > maxSize) 131 { 132 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidVertexPointerSize); 133 return false; 134 } 135 136 switch (type) 137 { 138 case VertexAttribType::Byte: 139 if (arrayType == ClientVertexArrayType::PointSize) 140 { 141 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidVertexPointerType); 142 return false; 143 } 144 break; 145 case VertexAttribType::Short: 146 if (arrayType == ClientVertexArrayType::PointSize || 147 arrayType == ClientVertexArrayType::Color) 148 { 149 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidVertexPointerType); 150 return false; 151 } 152 break; 153 case VertexAttribType::Fixed: 154 case VertexAttribType::Float: 155 break; 156 case VertexAttribType::UnsignedByte: 157 if (arrayType != ClientVertexArrayType::Color) 158 { 159 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidVertexPointerType); 160 return false; 161 } 162 break; 163 default: 164 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidVertexPointerType); 165 return false; 166 } 167 168 return true; 169 } 170 171 bool ValidateLightCaps(const Context *context, angle::EntryPoint entryPoint, GLenum light) 172 { 173 if (light < GL_LIGHT0 || light >= GL_LIGHT0 + context->getCaps().maxLights) 174 { 175 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidLight); 176 return false; 177 } 178 179 return true; 180 } 181 182 bool ValidateLightCommon(const Context *context, 183 angle::EntryPoint entryPoint, 184 GLenum light, 185 LightParameter pname, 186 const GLfloat *params) 187 { 188 189 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 190 191 if (!ValidateLightCaps(context, entryPoint, light)) 192 { 193 return false; 194 } 195 196 switch (pname) 197 { 198 case LightParameter::Ambient: 199 case LightParameter::Diffuse: 200 case LightParameter::Specular: 201 case LightParameter::Position: 202 case LightParameter::SpotDirection: 203 return true; 204 case LightParameter::SpotExponent: 205 if (params[0] < 0.0f || params[0] > 128.0f) 206 { 207 context->validationError(entryPoint, GL_INVALID_VALUE, kLightParameterOutOfRange); 208 return false; 209 } 210 return true; 211 case LightParameter::SpotCutoff: 212 if (params[0] == 180.0f) 213 { 214 return true; 215 } 216 if (params[0] < 0.0f || params[0] > 90.0f) 217 { 218 context->validationError(entryPoint, GL_INVALID_VALUE, kLightParameterOutOfRange); 219 return false; 220 } 221 return true; 222 case LightParameter::ConstantAttenuation: 223 case LightParameter::LinearAttenuation: 224 case LightParameter::QuadraticAttenuation: 225 if (params[0] < 0.0f) 226 { 227 context->validationError(entryPoint, GL_INVALID_VALUE, kLightParameterOutOfRange); 228 return false; 229 } 230 return true; 231 default: 232 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidLightParameter); 233 return false; 234 } 235 } 236 237 bool ValidateLightSingleComponent(const Context *context, 238 angle::EntryPoint entryPoint, 239 GLenum light, 240 LightParameter pname, 241 GLfloat param) 242 { 243 if (!ValidateLightCommon(context, entryPoint, light, pname, ¶m)) 244 { 245 return false; 246 } 247 248 if (GetLightParameterCount(pname) > 1) 249 { 250 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidLightParameter); 251 return false; 252 } 253 254 return true; 255 } 256 257 bool ValidateMaterialCommon(const Context *context, 258 angle::EntryPoint entryPoint, 259 GLenum face, 260 MaterialParameter pname, 261 const GLfloat *params) 262 { 263 switch (pname) 264 { 265 case MaterialParameter::Ambient: 266 case MaterialParameter::AmbientAndDiffuse: 267 case MaterialParameter::Diffuse: 268 case MaterialParameter::Specular: 269 case MaterialParameter::Emission: 270 return true; 271 case MaterialParameter::Shininess: 272 if (params[0] < 0.0f || params[0] > 128.0f) 273 { 274 context->validationError(entryPoint, GL_INVALID_VALUE, 275 kMaterialParameterOutOfRange); 276 return false; 277 } 278 return true; 279 default: 280 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidMaterialParameter); 281 return false; 282 } 283 } 284 285 bool ValidateMaterialSetting(const Context *context, 286 angle::EntryPoint entryPoint, 287 GLenum face, 288 MaterialParameter pname, 289 const GLfloat *params) 290 { 291 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 292 293 if (face != GL_FRONT_AND_BACK) 294 { 295 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidMaterialFace); 296 return false; 297 } 298 299 return ValidateMaterialCommon(context, entryPoint, face, pname, params); 300 } 301 302 bool ValidateMaterialQuery(const Context *context, 303 angle::EntryPoint entryPoint, 304 GLenum face, 305 MaterialParameter pname) 306 { 307 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 308 309 if (face != GL_FRONT && face != GL_BACK) 310 { 311 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidMaterialFace); 312 return false; 313 } 314 315 GLfloat validateParams[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 316 317 return ValidateMaterialCommon(context, entryPoint, face, pname, validateParams); 318 } 319 320 bool ValidateMaterialSingleComponent(const Context *context, 321 angle::EntryPoint entryPoint, 322 GLenum face, 323 MaterialParameter pname, 324 GLfloat param) 325 { 326 if (!ValidateMaterialSetting(context, entryPoint, face, pname, ¶m)) 327 { 328 return false; 329 } 330 331 if (GetMaterialParameterCount(pname) > 1) 332 { 333 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidMaterialParameter); 334 return false; 335 } 336 337 return true; 338 } 339 340 bool ValidateLightModelCommon(const Context *context, angle::EntryPoint entryPoint, GLenum pname) 341 { 342 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 343 switch (pname) 344 { 345 case GL_LIGHT_MODEL_AMBIENT: 346 case GL_LIGHT_MODEL_TWO_SIDE: 347 return true; 348 default: 349 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidLightModelParameter); 350 return false; 351 } 352 } 353 354 bool ValidateLightModelSingleComponent(const Context *context, 355 angle::EntryPoint entryPoint, 356 GLenum pname) 357 { 358 if (!ValidateLightModelCommon(context, entryPoint, pname)) 359 { 360 return false; 361 } 362 363 switch (pname) 364 { 365 case GL_LIGHT_MODEL_TWO_SIDE: 366 return true; 367 default: 368 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidLightModelParameter); 369 return false; 370 } 371 } 372 373 bool ValidateClipPlaneCommon(const Context *context, angle::EntryPoint entryPoint, GLenum plane) 374 { 375 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 376 377 if (plane < GL_CLIP_PLANE0 || plane >= GL_CLIP_PLANE0 + context->getCaps().maxClipPlanes) 378 { 379 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidClipPlane); 380 return false; 381 } 382 383 return true; 384 } 385 386 bool ValidateFogCommon(const Context *context, 387 angle::EntryPoint entryPoint, 388 GLenum pname, 389 const GLfloat *params) 390 { 391 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 392 393 switch (pname) 394 { 395 case GL_FOG_MODE: 396 { 397 GLenum modeParam = static_cast<GLenum>(params[0]); 398 switch (modeParam) 399 { 400 case GL_EXP: 401 case GL_EXP2: 402 case GL_LINEAR: 403 return true; 404 default: 405 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidFogMode); 406 return false; 407 } 408 } 409 case GL_FOG_START: 410 case GL_FOG_END: 411 case GL_FOG_COLOR: 412 break; 413 case GL_FOG_DENSITY: 414 if (params[0] < 0.0f) 415 { 416 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidFogDensity); 417 return false; 418 } 419 break; 420 default: 421 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidFogParameter); 422 return false; 423 } 424 return true; 425 } 426 427 bool ValidateTexEnvCommon(const Context *context, 428 angle::EntryPoint entryPoint, 429 TextureEnvTarget target, 430 TextureEnvParameter pname, 431 const GLfloat *params) 432 { 433 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 434 435 switch (target) 436 { 437 case TextureEnvTarget::Env: 438 switch (pname) 439 { 440 case TextureEnvParameter::Mode: 441 { 442 TextureEnvMode mode = FromGLenum<TextureEnvMode>(ConvertToGLenum(params[0])); 443 switch (mode) 444 { 445 case TextureEnvMode::Add: 446 case TextureEnvMode::Blend: 447 case TextureEnvMode::Combine: 448 case TextureEnvMode::Decal: 449 case TextureEnvMode::Modulate: 450 case TextureEnvMode::Replace: 451 break; 452 default: 453 context->validationError(entryPoint, GL_INVALID_VALUE, 454 kInvalidTextureEnvMode); 455 return false; 456 } 457 break; 458 } 459 case TextureEnvParameter::CombineRgb: 460 case TextureEnvParameter::CombineAlpha: 461 { 462 TextureCombine combine = FromGLenum<TextureCombine>(ConvertToGLenum(params[0])); 463 switch (combine) 464 { 465 case TextureCombine::Add: 466 case TextureCombine::AddSigned: 467 case TextureCombine::Interpolate: 468 case TextureCombine::Modulate: 469 case TextureCombine::Replace: 470 case TextureCombine::Subtract: 471 break; 472 case TextureCombine::Dot3Rgb: 473 case TextureCombine::Dot3Rgba: 474 if (pname == TextureEnvParameter::CombineAlpha) 475 { 476 context->validationError(entryPoint, GL_INVALID_VALUE, 477 kInvalidTextureCombine); 478 return false; 479 } 480 break; 481 default: 482 context->validationError(entryPoint, GL_INVALID_VALUE, 483 kInvalidTextureCombine); 484 return false; 485 } 486 break; 487 } 488 case TextureEnvParameter::Src0Rgb: 489 case TextureEnvParameter::Src1Rgb: 490 case TextureEnvParameter::Src2Rgb: 491 case TextureEnvParameter::Src0Alpha: 492 case TextureEnvParameter::Src1Alpha: 493 case TextureEnvParameter::Src2Alpha: 494 { 495 TextureSrc combine = FromGLenum<TextureSrc>(ConvertToGLenum(params[0])); 496 switch (combine) 497 { 498 case TextureSrc::Constant: 499 case TextureSrc::Previous: 500 case TextureSrc::PrimaryColor: 501 case TextureSrc::Texture: 502 break; 503 default: 504 context->validationError(entryPoint, GL_INVALID_VALUE, 505 kInvalidTextureCombineSrc); 506 return false; 507 } 508 break; 509 } 510 case TextureEnvParameter::Op0Rgb: 511 case TextureEnvParameter::Op1Rgb: 512 case TextureEnvParameter::Op2Rgb: 513 case TextureEnvParameter::Op0Alpha: 514 case TextureEnvParameter::Op1Alpha: 515 case TextureEnvParameter::Op2Alpha: 516 { 517 TextureOp operand = FromGLenum<TextureOp>(ConvertToGLenum(params[0])); 518 switch (operand) 519 { 520 case TextureOp::SrcAlpha: 521 case TextureOp::OneMinusSrcAlpha: 522 break; 523 case TextureOp::SrcColor: 524 case TextureOp::OneMinusSrcColor: 525 if (pname == TextureEnvParameter::Op0Alpha || 526 pname == TextureEnvParameter::Op1Alpha || 527 pname == TextureEnvParameter::Op2Alpha) 528 { 529 context->validationError(entryPoint, GL_INVALID_VALUE, 530 kInvalidTextureCombine); 531 return false; 532 } 533 break; 534 default: 535 context->validationError(entryPoint, GL_INVALID_VALUE, 536 kInvalidTextureCombineOp); 537 return false; 538 } 539 break; 540 } 541 case TextureEnvParameter::RgbScale: 542 case TextureEnvParameter::AlphaScale: 543 if (params[0] != 1.0f && params[0] != 2.0f && params[0] != 4.0f) 544 { 545 context->validationError(entryPoint, GL_INVALID_VALUE, 546 kInvalidTextureEnvScale); 547 return false; 548 } 549 break; 550 case TextureEnvParameter::Color: 551 break; 552 default: 553 context->validationError(entryPoint, GL_INVALID_ENUM, 554 kInvalidTextureEnvParameter); 555 return false; 556 } 557 break; 558 case TextureEnvTarget::PointSprite: 559 if (!context->getExtensions().pointSpriteOES) 560 { 561 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidTextureEnvTarget); 562 return false; 563 } 564 switch (pname) 565 { 566 case TextureEnvParameter::PointCoordReplace: 567 break; 568 default: 569 context->validationError(entryPoint, GL_INVALID_ENUM, 570 kInvalidTextureEnvParameter); 571 return false; 572 } 573 break; 574 default: 575 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidTextureEnvTarget); 576 return false; 577 } 578 return true; 579 } 580 581 bool ValidateGetTexEnvCommon(const Context *context, 582 angle::EntryPoint entryPoint, 583 TextureEnvTarget target, 584 TextureEnvParameter pname) 585 { 586 GLfloat validateParams[4] = {}; 587 switch (pname) 588 { 589 case TextureEnvParameter::Mode: 590 ConvertPackedEnum(TextureEnvMode::Add, validateParams); 591 break; 592 case TextureEnvParameter::CombineRgb: 593 case TextureEnvParameter::CombineAlpha: 594 ConvertPackedEnum(TextureCombine::Add, validateParams); 595 break; 596 case TextureEnvParameter::Src0Rgb: 597 case TextureEnvParameter::Src1Rgb: 598 case TextureEnvParameter::Src2Rgb: 599 case TextureEnvParameter::Src0Alpha: 600 case TextureEnvParameter::Src1Alpha: 601 case TextureEnvParameter::Src2Alpha: 602 ConvertPackedEnum(TextureSrc::Constant, validateParams); 603 break; 604 case TextureEnvParameter::Op0Rgb: 605 case TextureEnvParameter::Op1Rgb: 606 case TextureEnvParameter::Op2Rgb: 607 case TextureEnvParameter::Op0Alpha: 608 case TextureEnvParameter::Op1Alpha: 609 case TextureEnvParameter::Op2Alpha: 610 ConvertPackedEnum(TextureOp::SrcAlpha, validateParams); 611 break; 612 case TextureEnvParameter::RgbScale: 613 case TextureEnvParameter::AlphaScale: 614 case TextureEnvParameter::PointCoordReplace: 615 validateParams[0] = 1.0f; 616 break; 617 default: 618 break; 619 } 620 621 return ValidateTexEnvCommon(context, entryPoint, target, pname, validateParams); 622 } 623 624 bool ValidatePointParameterCommon(const Context *context, 625 angle::EntryPoint entryPoint, 626 PointParameter pname, 627 const GLfloat *params) 628 { 629 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 630 631 switch (pname) 632 { 633 case PointParameter::PointSizeMin: 634 case PointParameter::PointSizeMax: 635 case PointParameter::PointFadeThresholdSize: 636 case PointParameter::PointDistanceAttenuation: 637 for (unsigned int i = 0; i < GetPointParameterCount(pname); i++) 638 { 639 if (params[i] < 0.0f) 640 { 641 context->validationError(entryPoint, GL_INVALID_VALUE, 642 kInvalidPointParameterValue); 643 return false; 644 } 645 } 646 break; 647 default: 648 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPointParameter); 649 return false; 650 } 651 652 return true; 653 } 654 655 bool ValidatePointSizeCommon(const Context *context, angle::EntryPoint entryPoint, GLfloat size) 656 { 657 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 658 659 if (size <= 0.0f) 660 { 661 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidPointSizeValue); 662 return false; 663 } 664 665 return true; 666 } 667 668 bool ValidateDrawTexCommon(const Context *context, 669 angle::EntryPoint entryPoint, 670 float width, 671 float height) 672 { 673 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 674 675 if (width <= 0.0f || height <= 0.0f) 676 { 677 context->validationError(entryPoint, GL_INVALID_VALUE, kNonPositiveDrawTextureDimension); 678 return false; 679 } 680 681 return true; 682 } 683 684 } // namespace gl 685 686 namespace gl 687 { 688 689 bool ValidateAlphaFunc(const Context *context, 690 angle::EntryPoint entryPoint, 691 AlphaTestFunc func, 692 GLfloat ref) 693 { 694 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 695 return ValidateAlphaFuncCommon(context, entryPoint, func); 696 } 697 698 bool ValidateAlphaFuncx(const Context *context, 699 angle::EntryPoint entryPoint, 700 AlphaTestFunc func, 701 GLfixed ref) 702 { 703 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 704 return ValidateAlphaFuncCommon(context, entryPoint, func); 705 } 706 707 bool ValidateClearColorx(const Context *context, 708 angle::EntryPoint entryPoint, 709 GLfixed red, 710 GLfixed green, 711 GLfixed blue, 712 GLfixed alpha) 713 { 714 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 715 return true; 716 } 717 718 bool ValidateClearDepthx(const Context *context, angle::EntryPoint entryPoint, GLfixed depth) 719 { 720 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 721 return true; 722 } 723 724 bool ValidateClientActiveTexture(const Context *context, 725 angle::EntryPoint entryPoint, 726 GLenum texture) 727 { 728 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 729 return ValidateMultitextureUnit(context, entryPoint, texture); 730 } 731 732 bool ValidateClipPlanef(const Context *context, 733 angle::EntryPoint entryPoint, 734 GLenum plane, 735 const GLfloat *eqn) 736 { 737 return ValidateClipPlaneCommon(context, entryPoint, plane); 738 } 739 740 bool ValidateClipPlanex(const Context *context, 741 angle::EntryPoint entryPoint, 742 GLenum plane, 743 const GLfixed *equation) 744 { 745 return ValidateClipPlaneCommon(context, entryPoint, plane); 746 } 747 748 bool ValidateColor4f(const Context *context, 749 angle::EntryPoint entryPoint, 750 GLfloat red, 751 GLfloat green, 752 GLfloat blue, 753 GLfloat alpha) 754 { 755 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 756 return true; 757 } 758 759 bool ValidateColor4ub(const Context *context, 760 angle::EntryPoint entryPoint, 761 GLubyte red, 762 GLubyte green, 763 GLubyte blue, 764 GLubyte alpha) 765 { 766 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 767 return true; 768 } 769 770 bool ValidateColor4x(const Context *context, 771 angle::EntryPoint entryPoint, 772 GLfixed red, 773 GLfixed green, 774 GLfixed blue, 775 GLfixed alpha) 776 { 777 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 778 return true; 779 } 780 781 bool ValidateColorPointer(const Context *context, 782 angle::EntryPoint entryPoint, 783 GLint size, 784 VertexAttribType type, 785 GLsizei stride, 786 const void *pointer) 787 { 788 return ValidateBuiltinVertexAttributeCommon(context, entryPoint, ClientVertexArrayType::Color, 789 size, type, stride, pointer); 790 } 791 792 bool ValidateCullFace(const Context *context, angle::EntryPoint entryPoint, GLenum mode) 793 { 794 UNIMPLEMENTED(); 795 return true; 796 } 797 798 bool ValidateDepthRangex(const Context *context, angle::EntryPoint entryPoint, GLfixed n, GLfixed f) 799 { 800 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 801 if (context->isWebGL() && n > f) 802 { 803 context->validationError(entryPoint, GL_INVALID_OPERATION, kInvalidDepthRange); 804 return false; 805 } 806 807 return true; 808 } 809 810 bool ValidateDisableClientState(const Context *context, 811 angle::EntryPoint entryPoint, 812 ClientVertexArrayType arrayType) 813 { 814 return ValidateClientStateCommon(context, entryPoint, arrayType); 815 } 816 817 bool ValidateEnableClientState(const Context *context, 818 angle::EntryPoint entryPoint, 819 ClientVertexArrayType arrayType) 820 { 821 return ValidateClientStateCommon(context, entryPoint, arrayType); 822 } 823 824 bool ValidateFogf(const Context *context, angle::EntryPoint entryPoint, GLenum pname, GLfloat param) 825 { 826 return ValidateFogCommon(context, entryPoint, pname, ¶m); 827 } 828 829 bool ValidateFogfv(const Context *context, 830 angle::EntryPoint entryPoint, 831 GLenum pname, 832 const GLfloat *params) 833 { 834 return ValidateFogCommon(context, entryPoint, pname, params); 835 } 836 837 bool ValidateFogx(const Context *context, angle::EntryPoint entryPoint, GLenum pname, GLfixed param) 838 { 839 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 840 GLfloat asFloat = 841 pname == GL_FOG_MODE ? static_cast<GLfloat>(param) : ConvertFixedToFloat(param); 842 return ValidateFogCommon(context, entryPoint, pname, &asFloat); 843 } 844 845 bool ValidateFogxv(const Context *context, 846 angle::EntryPoint entryPoint, 847 GLenum pname, 848 const GLfixed *params) 849 { 850 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 851 unsigned int paramCount = GetFogParameterCount(pname); 852 GLfloat paramsf[4] = {}; 853 854 if (pname == GL_FOG_MODE) 855 { 856 paramsf[0] = static_cast<GLfloat>(params[0]); 857 } 858 else 859 { 860 for (unsigned int i = 0; i < paramCount; i++) 861 { 862 paramsf[i] = ConvertFixedToFloat(params[i]); 863 } 864 } 865 866 return ValidateFogCommon(context, entryPoint, pname, paramsf); 867 } 868 869 bool ValidateFrustumf(const Context *context, 870 angle::EntryPoint entryPoint, 871 GLfloat l, 872 GLfloat r, 873 GLfloat b, 874 GLfloat t, 875 GLfloat n, 876 GLfloat f) 877 { 878 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 879 if (l == r || b == t || n == f || n <= 0.0f || f <= 0.0f) 880 { 881 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidProjectionMatrix); 882 return false; 883 } 884 return true; 885 } 886 887 bool ValidateFrustumx(const Context *context, 888 angle::EntryPoint entryPoint, 889 GLfixed l, 890 GLfixed r, 891 GLfixed b, 892 GLfixed t, 893 GLfixed n, 894 GLfixed f) 895 { 896 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 897 if (l == r || b == t || n == f || n <= 0 || f <= 0) 898 { 899 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidProjectionMatrix); 900 return false; 901 } 902 return true; 903 } 904 905 bool ValidateGetBufferParameteriv(const Context *context, 906 angle::EntryPoint entryPoint, 907 GLenum target, 908 GLenum pname, 909 const GLint *params) 910 { 911 UNIMPLEMENTED(); 912 return true; 913 } 914 915 bool ValidateGetClipPlanef(const Context *context, 916 angle::EntryPoint entryPoint, 917 GLenum plane, 918 const GLfloat *equation) 919 { 920 return ValidateClipPlaneCommon(context, entryPoint, plane); 921 } 922 923 bool ValidateGetClipPlanex(const Context *context, 924 angle::EntryPoint entryPoint, 925 GLenum plane, 926 const GLfixed *equation) 927 { 928 return ValidateClipPlaneCommon(context, entryPoint, plane); 929 } 930 931 bool ValidateGetFixedv(const Context *context, 932 angle::EntryPoint entryPoint, 933 GLenum pname, 934 const GLfixed *params) 935 { 936 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 937 GLenum nativeType; 938 unsigned int numParams = 0; 939 return ValidateStateQuery(context, entryPoint, pname, &nativeType, &numParams); 940 } 941 942 bool ValidateGetLightfv(const Context *context, 943 angle::EntryPoint entryPoint, 944 GLenum light, 945 LightParameter pname, 946 const GLfloat *params) 947 { 948 GLfloat validateParams[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 949 return ValidateLightCommon(context, entryPoint, light, pname, validateParams); 950 } 951 952 bool ValidateGetLightxv(const Context *context, 953 angle::EntryPoint entryPoint, 954 GLenum light, 955 LightParameter pname, 956 const GLfixed *params) 957 { 958 GLfloat validateParams[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 959 return ValidateLightCommon(context, entryPoint, light, pname, validateParams); 960 } 961 962 bool ValidateGetMaterialfv(const Context *context, 963 angle::EntryPoint entryPoint, 964 GLenum face, 965 MaterialParameter pname, 966 const GLfloat *params) 967 { 968 return ValidateMaterialQuery(context, entryPoint, face, pname); 969 } 970 971 bool ValidateGetMaterialxv(const Context *context, 972 angle::EntryPoint entryPoint, 973 GLenum face, 974 MaterialParameter pname, 975 const GLfixed *params) 976 { 977 return ValidateMaterialQuery(context, entryPoint, face, pname); 978 } 979 980 bool ValidateGetTexEnvfv(const Context *context, 981 angle::EntryPoint entryPoint, 982 TextureEnvTarget target, 983 TextureEnvParameter pname, 984 const GLfloat *params) 985 { 986 return ValidateGetTexEnvCommon(context, entryPoint, target, pname); 987 } 988 989 bool ValidateGetTexEnviv(const Context *context, 990 angle::EntryPoint entryPoint, 991 TextureEnvTarget target, 992 TextureEnvParameter pname, 993 const GLint *params) 994 { 995 return ValidateGetTexEnvCommon(context, entryPoint, target, pname); 996 } 997 998 bool ValidateGetTexEnvxv(const Context *context, 999 angle::EntryPoint entryPoint, 1000 TextureEnvTarget target, 1001 TextureEnvParameter pname, 1002 const GLfixed *params) 1003 { 1004 return ValidateGetTexEnvCommon(context, entryPoint, target, pname); 1005 } 1006 1007 bool ValidateGetTexParameterxv(const Context *context, 1008 angle::EntryPoint entryPoint, 1009 TextureType target, 1010 GLenum pname, 1011 const GLfixed *params) 1012 { 1013 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1014 1015 if (!ValidateGetTexParameterBase(context, entryPoint, target, pname, nullptr)) 1016 { 1017 return false; 1018 } 1019 1020 return true; 1021 } 1022 1023 bool ValidateLightModelf(const Context *context, 1024 angle::EntryPoint entryPoint, 1025 GLenum pname, 1026 GLfloat param) 1027 { 1028 return ValidateLightModelSingleComponent(context, entryPoint, pname); 1029 } 1030 1031 bool ValidateLightModelfv(const Context *context, 1032 angle::EntryPoint entryPoint, 1033 GLenum pname, 1034 const GLfloat *params) 1035 { 1036 return ValidateLightModelCommon(context, entryPoint, pname); 1037 } 1038 1039 bool ValidateLightModelx(const Context *context, 1040 angle::EntryPoint entryPoint, 1041 GLenum pname, 1042 GLfixed param) 1043 { 1044 return ValidateLightModelSingleComponent(context, entryPoint, pname); 1045 } 1046 1047 bool ValidateLightModelxv(const Context *context, 1048 angle::EntryPoint entryPoint, 1049 GLenum pname, 1050 const GLfixed *param) 1051 { 1052 return ValidateLightModelCommon(context, entryPoint, pname); 1053 } 1054 1055 bool ValidateLightf(const Context *context, 1056 angle::EntryPoint entryPoint, 1057 GLenum light, 1058 LightParameter pname, 1059 GLfloat param) 1060 { 1061 return ValidateLightSingleComponent(context, entryPoint, light, pname, param); 1062 } 1063 1064 bool ValidateLightfv(const Context *context, 1065 angle::EntryPoint entryPoint, 1066 GLenum light, 1067 LightParameter pname, 1068 const GLfloat *params) 1069 { 1070 return ValidateLightCommon(context, entryPoint, light, pname, params); 1071 } 1072 1073 bool ValidateLightx(const Context *context, 1074 angle::EntryPoint entryPoint, 1075 GLenum light, 1076 LightParameter pname, 1077 GLfixed param) 1078 { 1079 return ValidateLightSingleComponent(context, entryPoint, light, pname, 1080 ConvertFixedToFloat(param)); 1081 } 1082 1083 bool ValidateLightxv(const Context *context, 1084 angle::EntryPoint entryPoint, 1085 GLenum light, 1086 LightParameter pname, 1087 const GLfixed *params) 1088 { 1089 GLfloat paramsf[4]; 1090 for (unsigned int i = 0; i < GetLightParameterCount(pname); i++) 1091 { 1092 paramsf[i] = ConvertFixedToFloat(params[i]); 1093 } 1094 1095 return ValidateLightCommon(context, entryPoint, light, pname, paramsf); 1096 } 1097 1098 bool ValidateLineWidthx(const Context *context, angle::EntryPoint entryPoint, GLfixed width) 1099 { 1100 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1101 if (width <= 0) 1102 { 1103 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidWidth); 1104 return false; 1105 } 1106 1107 return true; 1108 } 1109 1110 bool ValidateLoadIdentity(const Context *context, angle::EntryPoint entryPoint) 1111 { 1112 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1113 return true; 1114 } 1115 1116 bool ValidateLoadMatrixf(const Context *context, angle::EntryPoint entryPoint, const GLfloat *m) 1117 { 1118 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1119 return true; 1120 } 1121 1122 bool ValidateLoadMatrixx(const Context *context, angle::EntryPoint entryPoint, const GLfixed *m) 1123 { 1124 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1125 return true; 1126 } 1127 1128 bool ValidateLogicOp(const Context *context, angle::EntryPoint entryPoint, LogicalOperation opcode) 1129 { 1130 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1131 return ValidateLogicOpCommon(context, entryPoint, opcode); 1132 } 1133 1134 bool ValidateMaterialf(const Context *context, 1135 angle::EntryPoint entryPoint, 1136 GLenum face, 1137 MaterialParameter pname, 1138 GLfloat param) 1139 { 1140 return ValidateMaterialSingleComponent(context, entryPoint, face, pname, param); 1141 } 1142 1143 bool ValidateMaterialfv(const Context *context, 1144 angle::EntryPoint entryPoint, 1145 GLenum face, 1146 MaterialParameter pname, 1147 const GLfloat *params) 1148 { 1149 return ValidateMaterialSetting(context, entryPoint, face, pname, params); 1150 } 1151 1152 bool ValidateMaterialx(const Context *context, 1153 angle::EntryPoint entryPoint, 1154 GLenum face, 1155 MaterialParameter pname, 1156 GLfixed param) 1157 { 1158 return ValidateMaterialSingleComponent(context, entryPoint, face, pname, 1159 ConvertFixedToFloat(param)); 1160 } 1161 1162 bool ValidateMaterialxv(const Context *context, 1163 angle::EntryPoint entryPoint, 1164 GLenum face, 1165 MaterialParameter pname, 1166 const GLfixed *params) 1167 { 1168 GLfloat paramsf[4]; 1169 1170 for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++) 1171 { 1172 paramsf[i] = ConvertFixedToFloat(params[i]); 1173 } 1174 1175 return ValidateMaterialSetting(context, entryPoint, face, pname, paramsf); 1176 } 1177 1178 bool ValidateMatrixMode(const Context *context, angle::EntryPoint entryPoint, MatrixType mode) 1179 { 1180 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1181 switch (mode) 1182 { 1183 case MatrixType::Projection: 1184 case MatrixType::Modelview: 1185 case MatrixType::Texture: 1186 return true; 1187 default: 1188 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidMatrixMode); 1189 return false; 1190 } 1191 } 1192 1193 bool ValidateMultMatrixf(const Context *context, angle::EntryPoint entryPoint, const GLfloat *m) 1194 { 1195 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1196 return true; 1197 } 1198 1199 bool ValidateMultMatrixx(const Context *context, angle::EntryPoint entryPoint, const GLfixed *m) 1200 { 1201 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1202 return true; 1203 } 1204 1205 bool ValidateMultiTexCoord4f(const Context *context, 1206 angle::EntryPoint entryPoint, 1207 GLenum target, 1208 GLfloat s, 1209 GLfloat t, 1210 GLfloat r, 1211 GLfloat q) 1212 { 1213 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1214 return ValidateMultitextureUnit(context, entryPoint, target); 1215 } 1216 1217 bool ValidateMultiTexCoord4x(const Context *context, 1218 angle::EntryPoint entryPoint, 1219 GLenum target, 1220 GLfixed s, 1221 GLfixed t, 1222 GLfixed r, 1223 GLfixed q) 1224 { 1225 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1226 return ValidateMultitextureUnit(context, entryPoint, target); 1227 } 1228 1229 bool ValidateNormal3f(const Context *context, 1230 angle::EntryPoint entryPoint, 1231 GLfloat nx, 1232 GLfloat ny, 1233 GLfloat nz) 1234 { 1235 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1236 return true; 1237 } 1238 1239 bool ValidateNormal3x(const Context *context, 1240 angle::EntryPoint entryPoint, 1241 GLfixed nx, 1242 GLfixed ny, 1243 GLfixed nz) 1244 { 1245 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1246 return true; 1247 } 1248 1249 bool ValidateNormalPointer(const Context *context, 1250 angle::EntryPoint entryPoint, 1251 VertexAttribType type, 1252 GLsizei stride, 1253 const void *pointer) 1254 { 1255 return ValidateBuiltinVertexAttributeCommon(context, entryPoint, ClientVertexArrayType::Normal, 1256 3, type, stride, pointer); 1257 } 1258 1259 bool ValidateOrthof(const Context *context, 1260 angle::EntryPoint entryPoint, 1261 GLfloat l, 1262 GLfloat r, 1263 GLfloat b, 1264 GLfloat t, 1265 GLfloat n, 1266 GLfloat f) 1267 { 1268 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1269 // [OpenGL ES 1.1.12] section 2.10.2 page 31: 1270 // If l is equal to r, b is equal to t, or n is equal to f, the 1271 // error INVALID VALUE results. 1272 if (l == r || b == t || n == f) 1273 { 1274 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidProjectionMatrix); 1275 return false; 1276 } 1277 return true; 1278 } 1279 1280 bool ValidateOrthox(const Context *context, 1281 angle::EntryPoint entryPoint, 1282 GLfixed l, 1283 GLfixed r, 1284 GLfixed b, 1285 GLfixed t, 1286 GLfixed n, 1287 GLfixed f) 1288 { 1289 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1290 if (l == r || b == t || n == f) 1291 { 1292 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidProjectionMatrix); 1293 return false; 1294 } 1295 return true; 1296 } 1297 1298 bool ValidatePointParameterf(const Context *context, 1299 angle::EntryPoint entryPoint, 1300 PointParameter pname, 1301 GLfloat param) 1302 { 1303 unsigned int paramCount = GetPointParameterCount(pname); 1304 if (paramCount != 1) 1305 { 1306 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPointParameter); 1307 return false; 1308 } 1309 1310 return ValidatePointParameterCommon(context, entryPoint, pname, ¶m); 1311 } 1312 1313 bool ValidatePointParameterfv(const Context *context, 1314 angle::EntryPoint entryPoint, 1315 PointParameter pname, 1316 const GLfloat *params) 1317 { 1318 return ValidatePointParameterCommon(context, entryPoint, pname, params); 1319 } 1320 1321 bool ValidatePointParameterx(const Context *context, 1322 angle::EntryPoint entryPoint, 1323 PointParameter pname, 1324 GLfixed param) 1325 { 1326 unsigned int paramCount = GetPointParameterCount(pname); 1327 if (paramCount != 1) 1328 { 1329 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPointParameter); 1330 return false; 1331 } 1332 1333 GLfloat paramf = ConvertFixedToFloat(param); 1334 return ValidatePointParameterCommon(context, entryPoint, pname, ¶mf); 1335 } 1336 1337 bool ValidatePointParameterxv(const Context *context, 1338 angle::EntryPoint entryPoint, 1339 PointParameter pname, 1340 const GLfixed *params) 1341 { 1342 GLfloat paramsf[4] = {}; 1343 for (unsigned int i = 0; i < GetPointParameterCount(pname); i++) 1344 { 1345 paramsf[i] = ConvertFixedToFloat(params[i]); 1346 } 1347 return ValidatePointParameterCommon(context, entryPoint, pname, paramsf); 1348 } 1349 1350 bool ValidatePointSize(const Context *context, angle::EntryPoint entryPoint, GLfloat size) 1351 { 1352 return ValidatePointSizeCommon(context, entryPoint, size); 1353 } 1354 1355 bool ValidatePointSizex(const Context *context, angle::EntryPoint entryPoint, GLfixed size) 1356 { 1357 return ValidatePointSizeCommon(context, entryPoint, ConvertFixedToFloat(size)); 1358 } 1359 1360 bool ValidatePolygonOffsetx(const Context *context, 1361 angle::EntryPoint entryPoint, 1362 GLfixed factor, 1363 GLfixed units) 1364 { 1365 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1366 return true; 1367 } 1368 1369 bool ValidatePopMatrix(const Context *context, angle::EntryPoint entryPoint) 1370 { 1371 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1372 const auto &stack = context->getState().gles1().currentMatrixStack(); 1373 if (stack.size() == 1) 1374 { 1375 context->validationError(entryPoint, GL_STACK_UNDERFLOW, kMatrixStackUnderflow); 1376 return false; 1377 } 1378 return true; 1379 } 1380 1381 bool ValidatePushMatrix(const Context *context, angle::EntryPoint entryPoint) 1382 { 1383 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1384 const auto &stack = context->getState().gles1().currentMatrixStack(); 1385 if (stack.size() == stack.max_size()) 1386 { 1387 context->validationError(entryPoint, GL_STACK_OVERFLOW, kMatrixStackOverflow); 1388 return false; 1389 } 1390 return true; 1391 } 1392 1393 bool ValidateRotatef(const Context *context, 1394 angle::EntryPoint entryPoint, 1395 GLfloat angle, 1396 GLfloat x, 1397 GLfloat y, 1398 GLfloat z) 1399 { 1400 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1401 return true; 1402 } 1403 1404 bool ValidateRotatex(const Context *context, 1405 angle::EntryPoint entryPoint, 1406 GLfixed angle, 1407 GLfixed x, 1408 GLfixed y, 1409 GLfixed z) 1410 { 1411 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1412 return true; 1413 } 1414 1415 bool ValidateSampleCoveragex(const Context *context, 1416 angle::EntryPoint entryPoint, 1417 GLclampx value, 1418 GLboolean invert) 1419 { 1420 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1421 return true; 1422 } 1423 1424 bool ValidateScalef(const Context *context, 1425 angle::EntryPoint entryPoint, 1426 GLfloat x, 1427 GLfloat y, 1428 GLfloat z) 1429 { 1430 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1431 return true; 1432 } 1433 1434 bool ValidateScalex(const Context *context, 1435 angle::EntryPoint entryPoint, 1436 GLfixed x, 1437 GLfixed y, 1438 GLfixed z) 1439 { 1440 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1441 return true; 1442 } 1443 1444 bool ValidateShadeModel(const Context *context, angle::EntryPoint entryPoint, ShadingModel mode) 1445 { 1446 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1447 switch (mode) 1448 { 1449 case ShadingModel::Flat: 1450 case ShadingModel::Smooth: 1451 return true; 1452 default: 1453 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidShadingModel); 1454 return false; 1455 } 1456 } 1457 1458 bool ValidateTexCoordPointer(const Context *context, 1459 angle::EntryPoint entryPoint, 1460 GLint size, 1461 VertexAttribType type, 1462 GLsizei stride, 1463 const void *pointer) 1464 { 1465 return ValidateBuiltinVertexAttributeCommon( 1466 context, entryPoint, ClientVertexArrayType::TextureCoord, size, type, stride, pointer); 1467 } 1468 1469 bool ValidateTexEnvf(const Context *context, 1470 angle::EntryPoint entryPoint, 1471 TextureEnvTarget target, 1472 TextureEnvParameter pname, 1473 GLfloat param) 1474 { 1475 return ValidateTexEnvCommon(context, entryPoint, target, pname, ¶m); 1476 } 1477 1478 bool ValidateTexEnvfv(const Context *context, 1479 angle::EntryPoint entryPoint, 1480 TextureEnvTarget target, 1481 TextureEnvParameter pname, 1482 const GLfloat *params) 1483 { 1484 return ValidateTexEnvCommon(context, entryPoint, target, pname, params); 1485 } 1486 1487 bool ValidateTexEnvi(const Context *context, 1488 angle::EntryPoint entryPoint, 1489 TextureEnvTarget target, 1490 TextureEnvParameter pname, 1491 GLint param) 1492 { 1493 GLfloat paramf = static_cast<GLfloat>(param); 1494 return ValidateTexEnvCommon(context, entryPoint, target, pname, ¶mf); 1495 } 1496 1497 bool ValidateTexEnviv(const Context *context, 1498 angle::EntryPoint entryPoint, 1499 TextureEnvTarget target, 1500 TextureEnvParameter pname, 1501 const GLint *params) 1502 { 1503 GLfloat paramsf[4]; 1504 for (unsigned int i = 0; i < GetTextureEnvParameterCount(pname); i++) 1505 { 1506 paramsf[i] = static_cast<GLfloat>(params[i]); 1507 } 1508 return ValidateTexEnvCommon(context, entryPoint, target, pname, paramsf); 1509 } 1510 1511 bool ValidateTexEnvx(const Context *context, 1512 angle::EntryPoint entryPoint, 1513 TextureEnvTarget target, 1514 TextureEnvParameter pname, 1515 GLfixed param) 1516 { 1517 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1518 GLfloat paramsf[4] = {}; 1519 ConvertTextureEnvFromFixed(pname, ¶m, paramsf); 1520 return ValidateTexEnvCommon(context, entryPoint, target, pname, paramsf); 1521 } 1522 1523 bool ValidateTexEnvxv(const Context *context, 1524 angle::EntryPoint entryPoint, 1525 TextureEnvTarget target, 1526 TextureEnvParameter pname, 1527 const GLfixed *params) 1528 { 1529 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1530 GLfloat paramsf[4] = {}; 1531 ConvertTextureEnvFromFixed(pname, params, paramsf); 1532 return ValidateTexEnvCommon(context, entryPoint, target, pname, paramsf); 1533 } 1534 1535 bool ValidateTexParameterBaseForGLfixed(const Context *context, 1536 angle::EntryPoint entryPoint, 1537 TextureType target, 1538 GLenum pname, 1539 GLsizei bufSize, 1540 bool vectorParams, 1541 const GLfixed *params) 1542 { 1543 // Convert GLfixed parameter for GL_TEXTURE_MAX_ANISOTROPY_EXT independently 1544 // since it compares against 1 and maxTextureAnisotropy instead of just 0 1545 // (other values are fine to leave unconverted since they only check positive or negative or 1546 // are used as enums) 1547 GLfloat paramValue; 1548 if (pname == GL_TEXTURE_MAX_ANISOTROPY_EXT) 1549 { 1550 paramValue = ConvertFixedToFloat(static_cast<GLfixed>(params[0])); 1551 } 1552 else 1553 { 1554 paramValue = static_cast<GLfloat>(params[0]); 1555 } 1556 return ValidateTexParameterBase(context, entryPoint, target, pname, bufSize, vectorParams, 1557 ¶mValue); 1558 } 1559 1560 bool ValidateTexParameterx(const Context *context, 1561 angle::EntryPoint entryPoint, 1562 TextureType target, 1563 GLenum pname, 1564 GLfixed param) 1565 { 1566 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1567 return ValidateTexParameterBaseForGLfixed(context, entryPoint, target, pname, -1, false, 1568 ¶m); 1569 } 1570 1571 bool ValidateTexParameterxv(const Context *context, 1572 angle::EntryPoint entryPoint, 1573 TextureType target, 1574 GLenum pname, 1575 const GLfixed *params) 1576 { 1577 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1578 return ValidateTexParameterBaseForGLfixed(context, entryPoint, target, pname, -1, true, params); 1579 } 1580 1581 bool ValidateTranslatef(const Context *context, 1582 angle::EntryPoint entryPoint, 1583 GLfloat x, 1584 GLfloat y, 1585 GLfloat z) 1586 { 1587 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1588 return true; 1589 } 1590 1591 bool ValidateTranslatex(const Context *context, 1592 angle::EntryPoint entryPoint, 1593 GLfixed x, 1594 GLfixed y, 1595 GLfixed z) 1596 { 1597 ANGLE_VALIDATE_IS_GLES1(context, entryPoint); 1598 return true; 1599 } 1600 1601 bool ValidateVertexPointer(const Context *context, 1602 angle::EntryPoint entryPoint, 1603 GLint size, 1604 VertexAttribType type, 1605 GLsizei stride, 1606 const void *pointer) 1607 { 1608 return ValidateBuiltinVertexAttributeCommon(context, entryPoint, ClientVertexArrayType::Vertex, 1609 size, type, stride, pointer); 1610 } 1611 1612 bool ValidateDrawTexfOES(const Context *context, 1613 angle::EntryPoint entryPoint, 1614 GLfloat x, 1615 GLfloat y, 1616 GLfloat z, 1617 GLfloat width, 1618 GLfloat height) 1619 { 1620 return ValidateDrawTexCommon(context, entryPoint, width, height); 1621 } 1622 1623 bool ValidateDrawTexfvOES(const Context *context, 1624 angle::EntryPoint entryPoint, 1625 const GLfloat *coords) 1626 { 1627 return ValidateDrawTexCommon(context, entryPoint, coords[3], coords[4]); 1628 } 1629 1630 bool ValidateDrawTexiOES(const Context *context, 1631 angle::EntryPoint entryPoint, 1632 GLint x, 1633 GLint y, 1634 GLint z, 1635 GLint width, 1636 GLint height) 1637 { 1638 return ValidateDrawTexCommon(context, entryPoint, static_cast<GLfloat>(width), 1639 static_cast<GLfloat>(height)); 1640 } 1641 1642 bool ValidateDrawTexivOES(const Context *context, angle::EntryPoint entryPoint, const GLint *coords) 1643 { 1644 return ValidateDrawTexCommon(context, entryPoint, static_cast<GLfloat>(coords[3]), 1645 static_cast<GLfloat>(coords[4])); 1646 } 1647 1648 bool ValidateDrawTexsOES(const Context *context, 1649 angle::EntryPoint entryPoint, 1650 GLshort x, 1651 GLshort y, 1652 GLshort z, 1653 GLshort width, 1654 GLshort height) 1655 { 1656 return ValidateDrawTexCommon(context, entryPoint, static_cast<GLfloat>(width), 1657 static_cast<GLfloat>(height)); 1658 } 1659 1660 bool ValidateDrawTexsvOES(const Context *context, 1661 angle::EntryPoint entryPoint, 1662 const GLshort *coords) 1663 { 1664 return ValidateDrawTexCommon(context, entryPoint, static_cast<GLfloat>(coords[3]), 1665 static_cast<GLfloat>(coords[4])); 1666 } 1667 1668 bool ValidateDrawTexxOES(const Context *context, 1669 angle::EntryPoint entryPoint, 1670 GLfixed x, 1671 GLfixed y, 1672 GLfixed z, 1673 GLfixed width, 1674 GLfixed height) 1675 { 1676 return ValidateDrawTexCommon(context, entryPoint, ConvertFixedToFloat(width), 1677 ConvertFixedToFloat(height)); 1678 } 1679 1680 bool ValidateDrawTexxvOES(const Context *context, 1681 angle::EntryPoint entryPoint, 1682 const GLfixed *coords) 1683 { 1684 return ValidateDrawTexCommon(context, entryPoint, ConvertFixedToFloat(coords[3]), 1685 ConvertFixedToFloat(coords[4])); 1686 } 1687 1688 bool ValidateCurrentPaletteMatrixOES(const Context *context, 1689 angle::EntryPoint entryPoint, 1690 GLuint matrixpaletteindex) 1691 { 1692 UNIMPLEMENTED(); 1693 return true; 1694 } 1695 1696 bool ValidateLoadPaletteFromModelViewMatrixOES(const Context *context, angle::EntryPoint entryPoint) 1697 { 1698 UNIMPLEMENTED(); 1699 return true; 1700 } 1701 1702 bool ValidateMatrixIndexPointerOES(const Context *context, 1703 angle::EntryPoint entryPoint, 1704 GLint size, 1705 GLenum type, 1706 GLsizei stride, 1707 const void *pointer) 1708 { 1709 UNIMPLEMENTED(); 1710 return true; 1711 } 1712 1713 bool ValidateWeightPointerOES(const Context *context, 1714 angle::EntryPoint entryPoint, 1715 GLint size, 1716 GLenum type, 1717 GLsizei stride, 1718 const void *pointer) 1719 { 1720 UNIMPLEMENTED(); 1721 return true; 1722 } 1723 1724 bool ValidatePointSizePointerOES(const Context *context, 1725 angle::EntryPoint entryPoint, 1726 VertexAttribType type, 1727 GLsizei stride, 1728 const void *pointer) 1729 { 1730 return ValidateBuiltinVertexAttributeCommon( 1731 context, entryPoint, ClientVertexArrayType::PointSize, 1, type, stride, pointer); 1732 } 1733 1734 bool ValidateQueryMatrixxOES(const Context *context, 1735 angle::EntryPoint entryPoint, 1736 const GLfixed *mantissa, 1737 const GLint *exponent) 1738 { 1739 UNIMPLEMENTED(); 1740 return true; 1741 } 1742 1743 bool ValidateGenFramebuffersOES(const Context *context, 1744 angle::EntryPoint entryPoint, 1745 GLsizei n, 1746 const FramebufferID *framebuffers) 1747 { 1748 if (!context->getExtensions().framebufferObjectOES) 1749 { 1750 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1751 return false; 1752 } 1753 1754 return ValidateGenOrDelete(context, entryPoint, n); 1755 } 1756 1757 bool ValidateDeleteFramebuffersOES(const Context *context, 1758 angle::EntryPoint entryPoint, 1759 GLsizei n, 1760 const FramebufferID *framebuffers) 1761 { 1762 if (!context->getExtensions().framebufferObjectOES) 1763 { 1764 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1765 return false; 1766 } 1767 1768 return ValidateGenOrDelete(context, entryPoint, n); 1769 } 1770 1771 bool ValidateGenRenderbuffersOES(const Context *context, 1772 angle::EntryPoint entryPoint, 1773 GLsizei n, 1774 const RenderbufferID *renderbuffers) 1775 { 1776 if (!context->getExtensions().framebufferObjectOES) 1777 { 1778 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1779 return false; 1780 } 1781 1782 return ValidateGenOrDelete(context, entryPoint, n); 1783 } 1784 1785 bool ValidateDeleteRenderbuffersOES(const Context *context, 1786 angle::EntryPoint entryPoint, 1787 GLsizei n, 1788 const RenderbufferID *renderbuffers) 1789 { 1790 if (!context->getExtensions().framebufferObjectOES) 1791 { 1792 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1793 return false; 1794 } 1795 1796 return ValidateGenOrDelete(context, entryPoint, n); 1797 } 1798 1799 bool ValidateBindFramebufferOES(const Context *context, 1800 angle::EntryPoint entryPoint, 1801 GLenum target, 1802 FramebufferID framebuffer) 1803 { 1804 if (!context->getExtensions().framebufferObjectOES) 1805 { 1806 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1807 return false; 1808 } 1809 1810 return ValidateBindFramebufferBase(context, entryPoint, target, framebuffer); 1811 } 1812 1813 bool ValidateBindRenderbufferOES(const Context *context, 1814 angle::EntryPoint entryPoint, 1815 GLenum target, 1816 RenderbufferID renderbuffer) 1817 { 1818 if (!context->getExtensions().framebufferObjectOES) 1819 { 1820 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1821 return false; 1822 } 1823 1824 return ValidateBindRenderbufferBase(context, entryPoint, target, renderbuffer); 1825 } 1826 1827 bool ValidateCheckFramebufferStatusOES(const Context *context, 1828 angle::EntryPoint entryPoint, 1829 GLenum target) 1830 { 1831 if (!context->getExtensions().framebufferObjectOES) 1832 { 1833 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1834 return false; 1835 } 1836 1837 if (!ValidFramebufferTarget(context, target)) 1838 { 1839 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidFramebufferTarget); 1840 return false; 1841 } 1842 1843 return true; 1844 } 1845 1846 bool ValidateFramebufferRenderbufferOES(const Context *context, 1847 angle::EntryPoint entryPoint, 1848 GLenum target, 1849 GLenum attachment, 1850 GLenum rbtarget, 1851 RenderbufferID renderbuffer) 1852 { 1853 if (!context->getExtensions().framebufferObjectOES) 1854 { 1855 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1856 return false; 1857 } 1858 1859 return ValidateFramebufferRenderbufferBase(context, entryPoint, target, attachment, rbtarget, 1860 renderbuffer); 1861 } 1862 1863 bool ValidateFramebufferTexture2DOES(const Context *context, 1864 angle::EntryPoint entryPoint, 1865 GLenum target, 1866 GLenum attachment, 1867 TextureTarget textarget, 1868 TextureID texture, 1869 GLint level) 1870 { 1871 if (!context->getExtensions().framebufferObjectOES) 1872 { 1873 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1874 return false; 1875 } 1876 1877 if (level != 0) 1878 { 1879 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidFramebufferTextureLevel); 1880 return false; 1881 } 1882 1883 if (!ValidateFramebufferTextureBase(context, entryPoint, target, attachment, texture, level)) 1884 { 1885 return false; 1886 } 1887 1888 if (texture.value != 0) 1889 { 1890 Texture *tex = context->getTexture(texture); 1891 ASSERT(tex); 1892 1893 const Caps &caps = context->getCaps(); 1894 1895 switch (textarget) 1896 { 1897 case TextureTarget::_2D: 1898 { 1899 if (level > log2(caps.max2DTextureSize)) 1900 { 1901 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidMipLevel); 1902 return false; 1903 } 1904 if (tex->getType() != TextureType::_2D) 1905 { 1906 context->validationError(entryPoint, GL_INVALID_OPERATION, 1907 kInvalidTextureTarget); 1908 return false; 1909 } 1910 } 1911 break; 1912 1913 case TextureTarget::CubeMapNegativeX: 1914 case TextureTarget::CubeMapNegativeY: 1915 case TextureTarget::CubeMapNegativeZ: 1916 case TextureTarget::CubeMapPositiveX: 1917 case TextureTarget::CubeMapPositiveY: 1918 case TextureTarget::CubeMapPositiveZ: 1919 { 1920 if (!context->getExtensions().textureCubeMapOES) 1921 { 1922 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidTextureTarget); 1923 return false; 1924 } 1925 1926 if (level > log2(caps.maxCubeMapTextureSize)) 1927 { 1928 context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidMipLevel); 1929 return false; 1930 } 1931 if (tex->getType() != TextureType::CubeMap) 1932 { 1933 context->validationError(entryPoint, GL_INVALID_OPERATION, 1934 kTextureTargetMismatch); 1935 return false; 1936 } 1937 } 1938 break; 1939 1940 default: 1941 context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidTextureTarget); 1942 return false; 1943 } 1944 } 1945 1946 return true; 1947 } 1948 1949 bool ValidateGenerateMipmapOES(const Context *context, 1950 angle::EntryPoint entryPoint, 1951 TextureType target) 1952 { 1953 if (!context->getExtensions().framebufferObjectOES) 1954 { 1955 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1956 return false; 1957 } 1958 1959 return ValidateGenerateMipmapBase(context, entryPoint, target); 1960 } 1961 1962 bool ValidateGetFramebufferAttachmentParameterivOES(const Context *context, 1963 angle::EntryPoint entryPoint, 1964 GLenum target, 1965 GLenum attachment, 1966 GLenum pname, 1967 const GLint *params) 1968 { 1969 if (!context->getExtensions().framebufferObjectOES) 1970 { 1971 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1972 return false; 1973 } 1974 1975 return ValidateGetFramebufferAttachmentParameterivBase(context, entryPoint, target, attachment, 1976 pname, nullptr); 1977 } 1978 1979 bool ValidateGetRenderbufferParameterivOES(const Context *context, 1980 angle::EntryPoint entryPoint, 1981 GLenum target, 1982 GLenum pname, 1983 const GLint *params) 1984 { 1985 if (!context->getExtensions().framebufferObjectOES) 1986 { 1987 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 1988 return false; 1989 } 1990 1991 return ValidateGetRenderbufferParameterivBase(context, entryPoint, target, pname, nullptr); 1992 } 1993 1994 bool ValidateIsFramebufferOES(const Context *context, 1995 angle::EntryPoint entryPoint, 1996 FramebufferID framebuffer) 1997 { 1998 if (!context->getExtensions().framebufferObjectOES) 1999 { 2000 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 2001 return false; 2002 } 2003 2004 return true; 2005 } 2006 2007 bool ValidateIsRenderbufferOES(const Context *context, 2008 angle::EntryPoint entryPoint, 2009 RenderbufferID renderbuffer) 2010 { 2011 if (!context->getExtensions().framebufferObjectOES) 2012 { 2013 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 2014 return false; 2015 } 2016 2017 return true; 2018 } 2019 2020 bool ValidateRenderbufferStorageOES(const Context *context, 2021 angle::EntryPoint entryPoint, 2022 GLenum target, 2023 GLenum internalformat, 2024 GLsizei width, 2025 GLsizei height) 2026 { 2027 if (!context->getExtensions().framebufferObjectOES) 2028 { 2029 context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled); 2030 return false; 2031 } 2032 2033 return ValidateRenderbufferStorageParametersBase(context, entryPoint, target, 0, internalformat, 2034 width, height); 2035 } 2036 2037 // GL_OES_texture_cube_map 2038 2039 bool ValidateGetTexGenfvOES(const Context *context, 2040 angle::EntryPoint entryPoint, 2041 GLenum coord, 2042 GLenum pname, 2043 const GLfloat *params) 2044 { 2045 UNIMPLEMENTED(); 2046 return true; 2047 } 2048 2049 bool ValidateGetTexGenivOES(const Context *context, 2050 angle::EntryPoint entryPoint, 2051 GLenum coord, 2052 GLenum pname, 2053 const int *params) 2054 { 2055 UNIMPLEMENTED(); 2056 return true; 2057 } 2058 2059 bool ValidateGetTexGenxvOES(const Context *context, 2060 angle::EntryPoint entryPoint, 2061 GLenum coord, 2062 GLenum pname, 2063 const GLfixed *params) 2064 { 2065 UNIMPLEMENTED(); 2066 return true; 2067 } 2068 2069 bool ValidateTexGenfvOES(const Context *context, 2070 angle::EntryPoint entryPoint, 2071 GLenum coord, 2072 GLenum pname, 2073 const GLfloat *params) 2074 { 2075 UNIMPLEMENTED(); 2076 return true; 2077 } 2078 2079 bool ValidateTexGenivOES(const Context *context, 2080 angle::EntryPoint entryPoint, 2081 GLenum coord, 2082 GLenum pname, 2083 const GLint *param) 2084 { 2085 UNIMPLEMENTED(); 2086 return true; 2087 } 2088 2089 bool ValidateTexGenxvOES(const Context *context, 2090 angle::EntryPoint entryPoint, 2091 GLenum coord, 2092 GLenum pname, 2093 const GLint *param) 2094 { 2095 UNIMPLEMENTED(); 2096 return true; 2097 } 2098 2099 bool ValidateTexGenfOES(const Context *context, 2100 angle::EntryPoint entryPoint, 2101 GLenum coord, 2102 GLenum pname, 2103 GLfloat param) 2104 { 2105 UNIMPLEMENTED(); 2106 return true; 2107 } 2108 2109 bool ValidateTexGeniOES(const Context *context, 2110 angle::EntryPoint entryPoint, 2111 GLenum coord, 2112 GLenum pname, 2113 GLint param) 2114 { 2115 UNIMPLEMENTED(); 2116 return true; 2117 } 2118 2119 bool ValidateTexGenxOES(const Context *context, 2120 angle::EntryPoint entryPoint, 2121 GLenum coord, 2122 GLenum pname, 2123 GLfixed param) 2124 { 2125 UNIMPLEMENTED(); 2126 return true; 2127 } 2128 2129 } // namespace gl