Hash :
51320fab
Author :
Date :
2023-07-06T16:01:58
Make most GLES1 entry points lockless These entry points only set context-local state and thus don't require locking. Bug: angleproject:8224 Change-Id: I80223340348d62a56109324ab3e4f935e53419b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4670407 Reviewed-by: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123
//
// Copyright 2023 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// context_local_call_gles.cpp:
// Helpers that set/get state that is entirely locally accessed by the context.
#include "libANGLE/context_local_call_gles_autogen.h"
#include "common/debug.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/queryutils.h"
namespace
{
angle::Mat4 FixedMatrixToMat4(const GLfixed *m)
{
angle::Mat4 matrixAsFloat;
GLfloat *floatData = matrixAsFloat.data();
for (int i = 0; i < 16; i++)
{
floatData[i] = gl::ConvertFixedToFloat(m[i]);
}
return matrixAsFloat;
}
} // namespace
namespace gl
{
void ContextLocalClearColor(Context *context,
GLfloat red,
GLfloat green,
GLfloat blue,
GLfloat alpha)
{
context->getMutableLocalState()->setColorClearValue(red, green, blue, alpha);
}
void ContextLocalClearDepthf(Context *context, GLfloat depth)
{
context->getMutableLocalState()->setDepthClearValue(clamp01(depth));
}
void ContextLocalClearStencil(Context *context, GLint stencil)
{
context->getMutableLocalState()->setStencilClearValue(stencil);
}
void ContextLocalClearColorx(Context *context,
GLfixed red,
GLfixed green,
GLfixed blue,
GLfixed alpha)
{
ContextLocalClearColor(context, ConvertFixedToFloat(red), ConvertFixedToFloat(green),
ConvertFixedToFloat(blue), ConvertFixedToFloat(alpha));
}
void ContextLocalClearDepthx(Context *context, GLfixed depth)
{
ContextLocalClearDepthf(context, ConvertFixedToFloat(depth));
}
void ContextLocalColorMask(Context *context,
GLboolean red,
GLboolean green,
GLboolean blue,
GLboolean alpha)
{
context->getMutableLocalState()->setColorMask(ConvertToBool(red), ConvertToBool(green),
ConvertToBool(blue), ConvertToBool(alpha));
context->onContextLocalColorMaskChange();
}
void ContextLocalColorMaski(Context *context,
GLuint index,
GLboolean r,
GLboolean g,
GLboolean b,
GLboolean a)
{
context->getMutableLocalState()->setColorMaskIndexed(ConvertToBool(r), ConvertToBool(g),
ConvertToBool(b), ConvertToBool(a), index);
context->onContextLocalColorMaskChange();
}
void ContextLocalDepthMask(Context *context, GLboolean flag)
{
context->getMutableLocalState()->setDepthMask(ConvertToBool(flag));
}
void ContextLocalDisable(Context *context, GLenum cap)
{
context->getMutableLocalState()->setEnableFeature(cap, false);
context->onContextLocalCapChange();
}
void ContextLocalDisablei(Context *context, GLenum target, GLuint index)
{
context->getMutableLocalState()->setEnableFeatureIndexed(target, false, index);
context->onContextLocalCapChange();
}
void ContextLocalEnable(Context *context, GLenum cap)
{
context->getMutableLocalState()->setEnableFeature(cap, true);
context->onContextLocalCapChange();
}
void ContextLocalEnablei(Context *context, GLenum target, GLuint index)
{
context->getMutableLocalState()->setEnableFeatureIndexed(target, true, index);
context->onContextLocalCapChange();
}
void ContextLocalActiveTexture(Context *context, GLenum texture)
{
context->getMutableLocalState()->setActiveSampler(texture - GL_TEXTURE0);
}
void ContextLocalCullFace(Context *context, CullFaceMode mode)
{
context->getMutableLocalState()->setCullMode(mode);
}
void ContextLocalDepthFunc(Context *context, GLenum func)
{
context->getMutableLocalState()->setDepthFunc(func);
}
void ContextLocalDepthRangef(Context *context, GLfloat zNear, GLfloat zFar)
{
context->getMutableLocalState()->setDepthRange(clamp01(zNear), clamp01(zFar));
}
void ContextLocalDepthRangex(Context *context, GLfixed zNear, GLfixed zFar)
{
ContextLocalDepthRangef(context, ConvertFixedToFloat(zNear), ConvertFixedToFloat(zFar));
}
void ContextLocalFrontFace(Context *context, GLenum mode)
{
context->getMutableLocalState()->setFrontFace(mode);
}
void ContextLocalLineWidth(Context *context, GLfloat width)
{
context->getMutableLocalState()->setLineWidth(width);
}
void ContextLocalLineWidthx(Context *context, GLfixed width)
{
ContextLocalLineWidth(context, ConvertFixedToFloat(width));
}
void ContextLocalPolygonOffset(Context *context, GLfloat factor, GLfloat units)
{
context->getMutableLocalState()->setPolygonOffsetParams(factor, units, 0.0f);
}
void ContextLocalPolygonOffsetClamp(Context *context, GLfloat factor, GLfloat units, GLfloat clamp)
{
context->getMutableLocalState()->setPolygonOffsetParams(factor, units, clamp);
}
void ContextLocalPolygonOffsetx(Context *context, GLfixed factor, GLfixed units)
{
ContextLocalPolygonOffsetClamp(context, ConvertFixedToFloat(factor), ConvertFixedToFloat(units),
0.0f);
}
void ContextLocalSampleCoverage(Context *context, GLfloat value, GLboolean invert)
{
context->getMutableLocalState()->setSampleCoverageParams(clamp01(value), ConvertToBool(invert));
}
void ContextLocalSampleCoveragex(Context *context, GLclampx value, GLboolean invert)
{
ContextLocalSampleCoverage(context, ConvertFixedToFloat(value), invert);
}
void ContextLocalScissor(Context *context, GLint x, GLint y, GLsizei width, GLsizei height)
{
context->getMutableLocalState()->setScissorParams(x, y, width, height);
}
void ContextLocalVertexAttrib1f(Context *context, GLuint index, GLfloat x)
{
GLfloat vals[4] = {x, 0, 0, 1};
context->getMutableLocalState()->setVertexAttribf(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttrib1fv(Context *context, GLuint index, const GLfloat *values)
{
GLfloat vals[4] = {values[0], 0, 0, 1};
context->getMutableLocalState()->setVertexAttribf(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttrib2f(Context *context, GLuint index, GLfloat x, GLfloat y)
{
GLfloat vals[4] = {x, y, 0, 1};
context->getMutableLocalState()->setVertexAttribf(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttrib2fv(Context *context, GLuint index, const GLfloat *values)
{
GLfloat vals[4] = {values[0], values[1], 0, 1};
context->getMutableLocalState()->setVertexAttribf(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttrib3f(Context *context, GLuint index, GLfloat x, GLfloat y, GLfloat z)
{
GLfloat vals[4] = {x, y, z, 1};
context->getMutableLocalState()->setVertexAttribf(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttrib3fv(Context *context, GLuint index, const GLfloat *values)
{
GLfloat vals[4] = {values[0], values[1], values[2], 1};
context->getMutableLocalState()->setVertexAttribf(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttrib4f(Context *context,
GLuint index,
GLfloat x,
GLfloat y,
GLfloat z,
GLfloat w)
{
GLfloat vals[4] = {x, y, z, w};
context->getMutableLocalState()->setVertexAttribf(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttrib4fv(Context *context, GLuint index, const GLfloat *values)
{
context->getMutableLocalState()->setVertexAttribf(index, values);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttribI4i(Context *context, GLuint index, GLint x, GLint y, GLint z, GLint w)
{
GLint vals[4] = {x, y, z, w};
context->getMutableLocalState()->setVertexAttribi(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttribI4iv(Context *context, GLuint index, const GLint *values)
{
context->getMutableLocalState()->setVertexAttribi(index, values);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttribI4ui(Context *context,
GLuint index,
GLuint x,
GLuint y,
GLuint z,
GLuint w)
{
GLuint vals[4] = {x, y, z, w};
context->getMutableLocalState()->setVertexAttribu(index, vals);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalVertexAttribI4uiv(Context *context, GLuint index, const GLuint *values)
{
context->getMutableLocalState()->setVertexAttribu(index, values);
context->onContextLocalDefaultVertexAttributeChange();
}
void ContextLocalViewport(Context *context, GLint x, GLint y, GLsizei width, GLsizei height)
{
context->getMutableLocalState()->setViewportParams(x, y, width, height);
}
void ContextLocalSampleMaski(Context *context, GLuint maskNumber, GLbitfield mask)
{
context->getMutableLocalState()->setSampleMaskParams(maskNumber, mask);
}
void ContextLocalMinSampleShading(Context *context, GLfloat value)
{
context->getMutableLocalState()->setMinSampleShading(value);
}
void ContextLocalPrimitiveBoundingBox(Context *context,
GLfloat minX,
GLfloat minY,
GLfloat minZ,
GLfloat minW,
GLfloat maxX,
GLfloat maxY,
GLfloat maxZ,
GLfloat maxW)
{
context->getMutableLocalState()->setBoundingBox(minX, minY, minZ, minW, maxX, maxY, maxZ, maxW);
}
void ContextLocalLogicOp(Context *context, LogicalOperation opcode)
{
context->getMutableGLES1State()->setLogicOp(opcode);
}
void ContextLocalLogicOpANGLE(Context *context, LogicalOperation opcode)
{
context->getMutableLocalState()->setLogicOp(opcode);
}
void ContextLocalPolygonMode(Context *context, GLenum face, PolygonMode mode)
{
ASSERT(face == GL_FRONT_AND_BACK);
context->getMutableLocalState()->setPolygonMode(mode);
}
void ContextLocalPolygonModeNV(Context *context, GLenum face, PolygonMode mode)
{
ContextLocalPolygonMode(context, face, mode);
}
void ContextLocalProvokingVertex(Context *context, ProvokingVertexConvention provokeMode)
{
context->getMutableLocalState()->setProvokingVertex(provokeMode);
}
void ContextLocalCoverageModulation(Context *context, GLenum components)
{
context->getMutableLocalState()->setCoverageModulation(components);
}
void ContextLocalClipControl(Context *context, ClipOrigin origin, ClipDepthMode depth)
{
context->getMutableLocalState()->setClipControl(origin, depth);
}
void ContextLocalShadingRate(Context *context, GLenum rate)
{
context->getMutableLocalState()->setShadingRate(rate);
}
void ContextLocalBlendColor(Context *context,
GLfloat red,
GLfloat green,
GLfloat blue,
GLfloat alpha)
{
context->getMutableLocalState()->setBlendColor(red, green, blue, alpha);
}
void ContextLocalBlendEquation(Context *context, GLenum mode)
{
context->getMutableLocalState()->setBlendEquation(mode, mode);
context->onContextLocalBlendEquationChange();
}
void ContextLocalBlendEquationi(Context *context, GLuint buf, GLenum mode)
{
context->getMutableLocalState()->setBlendEquationIndexed(mode, mode, buf);
context->onContextLocalBlendEquationChange();
}
void ContextLocalBlendEquationSeparate(Context *context, GLenum modeRGB, GLenum modeAlpha)
{
context->getMutableLocalState()->setBlendEquation(modeRGB, modeAlpha);
context->onContextLocalBlendEquationChange();
}
void ContextLocalBlendEquationSeparatei(Context *context,
GLuint buf,
GLenum modeRGB,
GLenum modeAlpha)
{
context->getMutableLocalState()->setBlendEquationIndexed(modeRGB, modeAlpha, buf);
context->onContextLocalBlendEquationChange();
}
void ContextLocalBlendFunc(Context *context, GLenum sfactor, GLenum dfactor)
{
context->getMutableLocalState()->setBlendFactors(sfactor, dfactor, sfactor, dfactor);
}
void ContextLocalBlendFunci(Context *context, GLuint buf, GLenum src, GLenum dst)
{
context->getMutableLocalState()->setBlendFactorsIndexed(src, dst, src, dst, buf);
if (context->getState().noSimultaneousConstantColorAndAlphaBlendFunc())
{
context->onContextLocalBlendFuncIndexedChange();
}
}
void ContextLocalBlendFuncSeparate(Context *context,
GLenum srcRGB,
GLenum dstRGB,
GLenum srcAlpha,
GLenum dstAlpha)
{
context->getMutableLocalState()->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
void ContextLocalBlendFuncSeparatei(Context *context,
GLuint buf,
GLenum srcRGB,
GLenum dstRGB,
GLenum srcAlpha,
GLenum dstAlpha)
{
context->getMutableLocalState()->setBlendFactorsIndexed(srcRGB, dstRGB, srcAlpha, dstAlpha,
buf);
if (context->getState().noSimultaneousConstantColorAndAlphaBlendFunc())
{
context->onContextLocalBlendFuncIndexedChange();
}
}
void ContextLocalStencilFunc(Context *context, GLenum func, GLint ref, GLuint mask)
{
ContextLocalStencilFuncSeparate(context, GL_FRONT_AND_BACK, func, ref, mask);
}
void ContextLocalStencilFuncSeparate(Context *context,
GLenum face,
GLenum func,
GLint ref,
GLuint mask)
{
GLint clampedRef = gl::clamp(ref, 0, std::numeric_limits<uint8_t>::max());
if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
{
context->getMutableLocalState()->setStencilParams(func, clampedRef, mask);
}
if (face == GL_BACK || face == GL_FRONT_AND_BACK)
{
context->getMutableLocalState()->setStencilBackParams(func, clampedRef, mask);
}
context->onContextLocalStencilStateChange();
}
void ContextLocalStencilMask(Context *context, GLuint mask)
{
ContextLocalStencilMaskSeparate(context, GL_FRONT_AND_BACK, mask);
}
void ContextLocalStencilMaskSeparate(Context *context, GLenum face, GLuint mask)
{
if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
{
context->getMutableLocalState()->setStencilWritemask(mask);
}
if (face == GL_BACK || face == GL_FRONT_AND_BACK)
{
context->getMutableLocalState()->setStencilBackWritemask(mask);
}
context->onContextLocalStencilStateChange();
}
void ContextLocalStencilOp(Context *context, GLenum fail, GLenum zfail, GLenum zpass)
{
ContextLocalStencilOpSeparate(context, GL_FRONT_AND_BACK, fail, zfail, zpass);
}
void ContextLocalStencilOpSeparate(Context *context,
GLenum face,
GLenum fail,
GLenum zfail,
GLenum zpass)
{
if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
{
context->getMutableLocalState()->setStencilOperations(fail, zfail, zpass);
}
if (face == GL_BACK || face == GL_FRONT_AND_BACK)
{
context->getMutableLocalState()->setStencilBackOperations(fail, zfail, zpass);
}
}
void ContextLocalPixelStorei(Context *context, GLenum pname, GLint param)
{
switch (pname)
{
case GL_UNPACK_ALIGNMENT:
context->getMutableLocalState()->setUnpackAlignment(param);
break;
case GL_PACK_ALIGNMENT:
context->getMutableLocalState()->setPackAlignment(param);
break;
case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
context->getMutableLocalState()->setPackReverseRowOrder(param != 0);
break;
case GL_UNPACK_ROW_LENGTH:
ASSERT((context->getClientMajorVersion() >= 3) ||
context->getExtensions().unpackSubimageEXT);
context->getMutableLocalState()->setUnpackRowLength(param);
break;
case GL_UNPACK_IMAGE_HEIGHT:
ASSERT(context->getClientMajorVersion() >= 3);
context->getMutableLocalState()->setUnpackImageHeight(param);
break;
case GL_UNPACK_SKIP_IMAGES:
ASSERT(context->getClientMajorVersion() >= 3);
context->getMutableLocalState()->setUnpackSkipImages(param);
break;
case GL_UNPACK_SKIP_ROWS:
ASSERT((context->getClientMajorVersion() >= 3) ||
context->getExtensions().unpackSubimageEXT);
context->getMutableLocalState()->setUnpackSkipRows(param);
break;
case GL_UNPACK_SKIP_PIXELS:
ASSERT((context->getClientMajorVersion() >= 3) ||
context->getExtensions().unpackSubimageEXT);
context->getMutableLocalState()->setUnpackSkipPixels(param);
break;
case GL_PACK_ROW_LENGTH:
ASSERT((context->getClientMajorVersion() >= 3) ||
context->getExtensions().packSubimageNV);
context->getMutableLocalState()->setPackRowLength(param);
break;
case GL_PACK_SKIP_ROWS:
ASSERT((context->getClientMajorVersion() >= 3) ||
context->getExtensions().packSubimageNV);
context->getMutableLocalState()->setPackSkipRows(param);
break;
case GL_PACK_SKIP_PIXELS:
ASSERT((context->getClientMajorVersion() >= 3) ||
context->getExtensions().packSubimageNV);
context->getMutableLocalState()->setPackSkipPixels(param);
break;
default:
UNREACHABLE();
return;
}
}
void ContextLocalHint(Context *context, GLenum target, GLenum mode)
{
switch (target)
{
case GL_GENERATE_MIPMAP_HINT:
context->getMutableLocalState()->setGenerateMipmapHint(mode);
break;
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
context->getMutableLocalState()->setFragmentShaderDerivativeHint(mode);
break;
case GL_PERSPECTIVE_CORRECTION_HINT:
case GL_POINT_SMOOTH_HINT:
case GL_LINE_SMOOTH_HINT:
case GL_FOG_HINT:
context->getMutableGLES1State()->setHint(target, mode);
break;
case GL_TEXTURE_FILTERING_HINT_CHROMIUM:
context->getMutableLocalState()->setTextureFilteringHint(mode);
break;
default:
UNREACHABLE();
return;
}
}
GLboolean ContextLocalIsEnabled(Context *context, GLenum cap)
{
return context->getState().localState().getEnableFeature(cap);
}
GLboolean ContextLocalIsEnabledi(Context *context, GLenum target, GLuint index)
{
return context->getState().localState().getEnableFeatureIndexed(target, index);
}
void ContextLocalPatchParameteri(Context *context, GLenum pname, GLint value)
{
switch (pname)
{
case GL_PATCH_VERTICES:
context->getMutableLocalState()->setPatchVertices(value);
break;
default:
break;
}
}
void ContextLocalAlphaFunc(Context *context, AlphaTestFunc func, GLfloat ref)
{
context->getMutableGLES1State()->setAlphaTestParameters(func, ref);
}
void ContextLocalAlphaFuncx(Context *context, AlphaTestFunc func, GLfixed ref)
{
ContextLocalAlphaFunc(context, func, ConvertFixedToFloat(ref));
}
void ContextLocalClipPlanef(Context *context, GLenum p, const GLfloat *eqn)
{
context->getMutableGLES1State()->setClipPlane(p - GL_CLIP_PLANE0, eqn);
}
void ContextLocalClipPlanex(Context *context, GLenum plane, const GLfixed *equation)
{
const GLfloat equationf[4] = {
ConvertFixedToFloat(equation[0]),
ConvertFixedToFloat(equation[1]),
ConvertFixedToFloat(equation[2]),
ConvertFixedToFloat(equation[3]),
};
ContextLocalClipPlanef(context, plane, equationf);
}
void ContextLocalColor4f(Context *context, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
{
context->getMutableGLES1State()->setCurrentColor({red, green, blue, alpha});
}
void ContextLocalColor4ub(Context *context, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
{
ContextLocalColor4f(context, normalizedToFloat<uint8_t>(red), normalizedToFloat<uint8_t>(green),
normalizedToFloat<uint8_t>(blue), normalizedToFloat<uint8_t>(alpha));
}
void ContextLocalColor4x(Context *context, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
{
ContextLocalColor4f(context, ConvertFixedToFloat(red), ConvertFixedToFloat(green),
ConvertFixedToFloat(blue), ConvertFixedToFloat(alpha));
}
void ContextLocalFogf(Context *context, GLenum pname, GLfloat param)
{
ContextLocalFogfv(context, pname, ¶m);
}
void ContextLocalFogfv(Context *context, GLenum pname, const GLfloat *params)
{
SetFogParameters(context->getMutableGLES1State(), pname, params);
}
void ContextLocalFogx(Context *context, GLenum pname, GLfixed param)
{
if (GetFogParameterCount(pname) == 1)
{
GLfloat paramf = pname == GL_FOG_MODE ? ConvertToGLenum(param) : ConvertFixedToFloat(param);
ContextLocalFogfv(context, pname, ¶mf);
}
else
{
UNREACHABLE();
}
}
void ContextLocalFogxv(Context *context, GLenum pname, const GLfixed *params)
{
int paramCount = GetFogParameterCount(pname);
if (paramCount > 0)
{
GLfloat paramsf[4];
for (int i = 0; i < paramCount; i++)
{
paramsf[i] =
pname == GL_FOG_MODE ? ConvertToGLenum(params[i]) : ConvertFixedToFloat(params[i]);
}
ContextLocalFogfv(context, pname, paramsf);
}
else
{
UNREACHABLE();
}
}
void ContextLocalFrustumf(Context *context,
GLfloat l,
GLfloat r,
GLfloat b,
GLfloat t,
GLfloat n,
GLfloat f)
{
context->getMutableGLES1State()->multMatrix(angle::Mat4::Frustum(l, r, b, t, n, f));
}
void ContextLocalFrustumx(Context *context,
GLfixed l,
GLfixed r,
GLfixed b,
GLfixed t,
GLfixed n,
GLfixed f)
{
ContextLocalFrustumf(context, ConvertFixedToFloat(l), ConvertFixedToFloat(r),
ConvertFixedToFloat(b), ConvertFixedToFloat(t), ConvertFixedToFloat(n),
ConvertFixedToFloat(f));
}
void ContextLocalGetClipPlanef(Context *context, GLenum plane, GLfloat *equation)
{
context->getState().gles1().getClipPlane(plane - GL_CLIP_PLANE0, equation);
}
void ContextLocalGetClipPlanex(Context *context, GLenum plane, GLfixed *equation)
{
GLfloat equationf[4] = {};
ContextLocalGetClipPlanef(context, plane, equationf);
for (int i = 0; i < 4; i++)
{
equation[i] = ConvertFloatToFixed(equationf[i]);
}
}
void ContextLocalGetLightfv(Context *context, GLenum light, LightParameter pname, GLfloat *params)
{
GetLightParameters(context->getMutableGLES1State(), light, pname, params);
}
void ContextLocalGetLightxv(Context *context, GLenum light, LightParameter pname, GLfixed *params)
{
GLfloat paramsf[4];
ContextLocalGetLightfv(context, light, pname, paramsf);
for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
{
params[i] = ConvertFloatToFixed(paramsf[i]);
}
}
void ContextLocalGetMaterialfv(Context *context,
GLenum face,
MaterialParameter pname,
GLfloat *params)
{
GetMaterialParameters(context->getMutableGLES1State(), face, pname, params);
}
void ContextLocalGetMaterialxv(Context *context,
GLenum face,
MaterialParameter pname,
GLfixed *params)
{
GLfloat paramsf[4];
ContextLocalGetMaterialfv(context, face, pname, paramsf);
for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
{
params[i] = ConvertFloatToFixed(paramsf[i]);
}
}
void ContextLocalGetTexEnvfv(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
GLfloat *params)
{
GetTextureEnv(context->getState().localState().getActiveSampler(),
context->getMutableGLES1State(), target, pname, params);
}
void ContextLocalGetTexEnviv(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
GLint *params)
{
GLfloat paramsf[4];
ContextLocalGetTexEnvfv(context, target, pname, paramsf);
ConvertTextureEnvToInt(pname, paramsf, params);
}
void ContextLocalGetTexEnvxv(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
GLfixed *params)
{
GLfloat paramsf[4];
ContextLocalGetTexEnvfv(context, target, pname, paramsf);
ConvertTextureEnvToFixed(pname, paramsf, params);
}
void ContextLocalLightModelf(Context *context, GLenum pname, GLfloat param)
{
ContextLocalLightModelfv(context, pname, ¶m);
}
void ContextLocalLightModelfv(Context *context, GLenum pname, const GLfloat *params)
{
SetLightModelParameters(context->getMutableGLES1State(), pname, params);
}
void ContextLocalLightModelx(Context *context, GLenum pname, GLfixed param)
{
ContextLocalLightModelf(context, pname, ConvertFixedToFloat(param));
}
void ContextLocalLightModelxv(Context *context, GLenum pname, const GLfixed *param)
{
GLfloat paramsf[4];
for (unsigned int i = 0; i < GetLightModelParameterCount(pname); i++)
{
paramsf[i] = ConvertFixedToFloat(param[i]);
}
ContextLocalLightModelfv(context, pname, paramsf);
}
void ContextLocalLightf(Context *context, GLenum light, LightParameter pname, GLfloat param)
{
ContextLocalLightfv(context, light, pname, ¶m);
}
void ContextLocalLightfv(Context *context,
GLenum light,
LightParameter pname,
const GLfloat *params)
{
SetLightParameters(context->getMutableGLES1State(), light, pname, params);
}
void ContextLocalLightx(Context *context, GLenum light, LightParameter pname, GLfixed param)
{
ContextLocalLightf(context, light, pname, ConvertFixedToFloat(param));
}
void ContextLocalLightxv(Context *context,
GLenum light,
LightParameter pname,
const GLfixed *params)
{
GLfloat paramsf[4];
for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
{
paramsf[i] = ConvertFixedToFloat(params[i]);
}
ContextLocalLightfv(context, light, pname, paramsf);
}
void ContextLocalLoadIdentity(Context *context)
{
context->getMutableGLES1State()->loadMatrix(angle::Mat4());
}
void ContextLocalLoadMatrixf(Context *context, const GLfloat *m)
{
context->getMutableGLES1State()->loadMatrix(angle::Mat4(m));
}
void ContextLocalLoadMatrixx(Context *context, const GLfixed *m)
{
context->getMutableGLES1State()->loadMatrix(FixedMatrixToMat4(m));
}
void ContextLocalMaterialf(Context *context, GLenum face, MaterialParameter pname, GLfloat param)
{
ContextLocalMaterialfv(context, face, pname, ¶m);
}
void ContextLocalMaterialfv(Context *context,
GLenum face,
MaterialParameter pname,
const GLfloat *params)
{
SetMaterialParameters(context->getMutableGLES1State(), face, pname, params);
}
void ContextLocalMaterialx(Context *context, GLenum face, MaterialParameter pname, GLfixed param)
{
ContextLocalMaterialf(context, face, pname, ConvertFixedToFloat(param));
}
void ContextLocalMaterialxv(Context *context,
GLenum face,
MaterialParameter pname,
const GLfixed *param)
{
GLfloat paramsf[4];
for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
{
paramsf[i] = ConvertFixedToFloat(param[i]);
}
ContextLocalMaterialfv(context, face, pname, paramsf);
}
void ContextLocalMatrixMode(Context *context, MatrixType mode)
{
context->getMutableGLES1State()->setMatrixMode(mode);
}
void ContextLocalMultMatrixf(Context *context, const GLfloat *m)
{
context->getMutableGLES1State()->multMatrix(angle::Mat4(m));
}
void ContextLocalMultMatrixx(Context *context, const GLfixed *m)
{
context->getMutableGLES1State()->multMatrix(FixedMatrixToMat4(m));
}
void ContextLocalMultiTexCoord4f(Context *context,
GLenum target,
GLfloat s,
GLfloat t,
GLfloat r,
GLfloat q)
{
unsigned int unit = target - GL_TEXTURE0;
ASSERT(target >= GL_TEXTURE0 &&
unit < context->getState().localState().getCaps().maxMultitextureUnits);
context->getMutableGLES1State()->setCurrentTextureCoords(unit, {s, t, r, q});
}
void ContextLocalMultiTexCoord4x(Context *context,
GLenum texture,
GLfixed s,
GLfixed t,
GLfixed r,
GLfixed q)
{
ContextLocalMultiTexCoord4f(context, texture, ConvertFixedToFloat(s), ConvertFixedToFloat(t),
ConvertFixedToFloat(r), ConvertFixedToFloat(q));
}
void ContextLocalNormal3f(Context *context, GLfloat nx, GLfloat ny, GLfloat nz)
{
context->getMutableGLES1State()->setCurrentNormal({nx, ny, nz});
}
void ContextLocalNormal3x(Context *context, GLfixed nx, GLfixed ny, GLfixed nz)
{
ContextLocalNormal3f(context, ConvertFixedToFloat(nx), ConvertFixedToFloat(ny),
ConvertFixedToFloat(nz));
}
void ContextLocalOrthof(Context *context,
GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat zNear,
GLfloat zFar)
{
context->getMutableGLES1State()->multMatrix(
angle::Mat4::Ortho(left, right, bottom, top, zNear, zFar));
}
void ContextLocalOrthox(Context *context,
GLfixed left,
GLfixed right,
GLfixed bottom,
GLfixed top,
GLfixed zNear,
GLfixed zFar)
{
ContextLocalOrthof(context, ConvertFixedToFloat(left), ConvertFixedToFloat(right),
ConvertFixedToFloat(bottom), ConvertFixedToFloat(top),
ConvertFixedToFloat(zNear), ConvertFixedToFloat(zFar));
}
void ContextLocalPointParameterf(Context *context, PointParameter pname, GLfloat param)
{
ContextLocalPointParameterfv(context, pname, ¶m);
}
void ContextLocalPointParameterfv(Context *context, PointParameter pname, const GLfloat *params)
{
SetPointParameter(context->getMutableGLES1State(), pname, params);
}
void ContextLocalPointParameterx(Context *context, PointParameter pname, GLfixed param)
{
ContextLocalPointParameterf(context, pname, ConvertFixedToFloat(param));
}
void ContextLocalPointParameterxv(Context *context, PointParameter pname, const GLfixed *params)
{
GLfloat paramsf[4] = {};
for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
{
paramsf[i] = ConvertFixedToFloat(params[i]);
}
ContextLocalPointParameterfv(context, pname, paramsf);
}
void ContextLocalPointSize(Context *context, GLfloat size)
{
SetPointSize(context->getMutableGLES1State(), size);
}
void ContextLocalPointSizex(Context *context, GLfixed size)
{
ContextLocalPointSize(context, ConvertFixedToFloat(size));
}
void ContextLocalPopMatrix(Context *context)
{
context->getMutableGLES1State()->popMatrix();
}
void ContextLocalPushMatrix(Context *context)
{
context->getMutableGLES1State()->pushMatrix();
}
void ContextLocalRotatef(Context *context, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{
context->getMutableGLES1State()->multMatrix(
angle::Mat4::Rotate(angle, angle::Vector3(x, y, z)));
}
void ContextLocalRotatex(Context *context, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
{
ContextLocalRotatef(context, ConvertFixedToFloat(angle), ConvertFixedToFloat(x),
ConvertFixedToFloat(y), ConvertFixedToFloat(z));
}
void ContextLocalScalef(Context *context, GLfloat x, GLfloat y, GLfloat z)
{
context->getMutableGLES1State()->multMatrix(angle::Mat4::Scale(angle::Vector3(x, y, z)));
}
void ContextLocalScalex(Context *context, GLfixed x, GLfixed y, GLfixed z)
{
ContextLocalScalef(context, ConvertFixedToFloat(x), ConvertFixedToFloat(y),
ConvertFixedToFloat(z));
}
void ContextLocalShadeModel(Context *context, ShadingModel model)
{
context->getMutableGLES1State()->setShadeModel(model);
}
void ContextLocalTexEnvf(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
GLfloat param)
{
ContextLocalTexEnvfv(context, target, pname, ¶m);
}
void ContextLocalTexEnvfv(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
const GLfloat *params)
{
SetTextureEnv(context->getState().localState().getActiveSampler(),
context->getMutableGLES1State(), target, pname, params);
}
void ContextLocalTexEnvi(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
GLint param)
{
ContextLocalTexEnviv(context, target, pname, ¶m);
}
void ContextLocalTexEnviv(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
const GLint *params)
{
GLfloat paramsf[4] = {};
ConvertTextureEnvFromInt(pname, params, paramsf);
ContextLocalTexEnvfv(context, target, pname, paramsf);
}
void ContextLocalTexEnvx(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
GLfixed param)
{
ContextLocalTexEnvxv(context, target, pname, ¶m);
}
void ContextLocalTexEnvxv(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
const GLfixed *params)
{
GLfloat paramsf[4] = {};
ConvertTextureEnvFromFixed(pname, params, paramsf);
ContextLocalTexEnvfv(context, target, pname, paramsf);
}
void ContextLocalTranslatef(Context *context, GLfloat x, GLfloat y, GLfloat z)
{
context->getMutableGLES1State()->multMatrix(angle::Mat4::Translate(angle::Vector3(x, y, z)));
}
void ContextLocalTranslatex(Context *context, GLfixed x, GLfixed y, GLfixed z)
{
ContextLocalTranslatef(context, ConvertFixedToFloat(x), ConvertFixedToFloat(y),
ConvertFixedToFloat(z));
}
} // namespace gl