Hash :
56e9bfff
Author :
Date :
2025-06-19T00:00:00
GL: Remove obsolete macOS workarounds Bug: angleproject:427600175 Change-Id: I8bfc062b71f1a34de09cbf76b504293ccd081fe0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6676022 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
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 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186
//
// Copyright 2002 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.
//
#ifndef GLSLANG_SHADERLANG_H_
#define GLSLANG_SHADERLANG_H_
#include <stddef.h>
#include "KHR/khrplatform.h"
#include <array>
#include <map>
#include <set>
#include <string>
#include <vector>
//
// This is the platform independent interface between an OGL driver
// and the shading language compiler.
//
// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
#include "ShaderVars.h"
// Version number for shader translation API.
// It is incremented every time the API changes.
#define ANGLE_SH_VERSION 378
enum ShShaderSpec
{
SH_GLES2_SPEC,
SH_WEBGL_SPEC,
SH_GLES3_SPEC,
SH_WEBGL2_SPEC,
SH_GLES3_1_SPEC,
SH_WEBGL3_SPEC,
SH_GLES3_2_SPEC,
};
enum ShShaderOutput
{
// NULL output for testing.
SH_NULL_OUTPUT,
// ESSL output only supported in some configurations.
SH_ESSL_OUTPUT,
// GLSL output only supported in some configurations.
SH_GLSL_COMPATIBILITY_OUTPUT,
// Note: GL introduced core profiles in 1.5.
SH_GLSL_130_OUTPUT,
SH_GLSL_140_OUTPUT,
SH_GLSL_150_CORE_OUTPUT,
SH_GLSL_330_CORE_OUTPUT,
SH_GLSL_400_CORE_OUTPUT,
SH_GLSL_410_CORE_OUTPUT,
SH_GLSL_420_CORE_OUTPUT,
SH_GLSL_430_CORE_OUTPUT,
SH_GLSL_440_CORE_OUTPUT,
SH_GLSL_450_CORE_OUTPUT,
// Prefer using these to specify HLSL output type:
SH_HLSL_3_0_OUTPUT, // D3D 9
SH_HLSL_4_1_OUTPUT, // D3D 11
// Output SPIR-V for the Vulkan backend.
SH_SPIRV_VULKAN_OUTPUT,
// Output for MSL
SH_MSL_METAL_OUTPUT,
// Output for WGSL
SH_WGSL_OUTPUT,
};
struct ShCompileOptionsMetal
{
// Direct-to-metal backend constants:
// Binding index for driver uniforms:
int driverUniformsBindingIndex = 0;
// Binding index for default uniforms:
int defaultUniformsBindingIndex = 0;
// Binding index for UBO's argument buffer
int UBOArgumentBufferBindingIndex = 0;
bool generateShareableShaders = false;
// Insert asm("") instructions into loop bodies, telling the compiler that all loops have side
// effects and cannot be optimized out.
bool injectAsmStatementIntoLoopBodies = false;
};
// For ANGLE_shader_pixel_local_storage.
// Instructs the compiler which pixel local storage configuration to generate code for.
enum class ShPixelLocalStorageType : uint8_t
{
NotSupported,
ImageLoadStore,
FramebufferFetch,
};
// For ANGLE_shader_pixel_local_storage.
// Used to track the PLS format at each binding index in a shader.
enum class ShPixelLocalStorageFormat : uint8_t
{
NotPLS, // Indicates that no PLS uniform was declared at the binding index in question.
RGBA8,
RGBA8I,
RGBA8UI,
R32F,
R32UI,
};
// For ANGLE_shader_pixel_local_storage_coherent.
// Instructs the compiler which fragment synchronization method to use, if any.
enum class ShFragmentSynchronizationType : uint8_t
{
NotSupported, // Fragments cannot be ordered or synchronized.
Automatic, // Fragments are automatically raster-ordered and synchronized.
FragmentShaderInterlock_NV_GL,
FragmentShaderOrdering_INTEL_GL,
FragmentShaderInterlock_ARB_GL, // Also compiles to SPV_EXT_fragment_shader_interlock.
RasterizerOrderViews_D3D,
RasterOrderGroups_Metal,
InvalidEnum,
EnumCount = InvalidEnum,
};
struct ShPixelLocalStorageOptions
{
ShPixelLocalStorageType type = ShPixelLocalStorageType::NotSupported;
// For ANGLE_shader_pixel_local_storage_coherent.
ShFragmentSynchronizationType fragmentSyncType = ShFragmentSynchronizationType::NotSupported;
// ShPixelLocalStorageType::ImageLoadStore only: Can we use rgba8/rgba8i/rgba8ui image formats?
// Or do we need to manually pack and unpack from r32i/r32ui?
bool supportsNativeRGBA8ImageFormats = false;
// anglebug.com/42266263 -- Metal [[raster_order_group()]] does not work for read_write textures
// on AMD when the render pass doesn't have a color attachment on slot 0. To work around this we
// attach one of the PLS textures to GL_COLOR_ATTACHMENT0, if there isn't one already.
bool renderPassNeedsAMDRasterOrderGroupsWorkaround = false;
};
struct ShCompileOptions
{
ShCompileOptions();
ShCompileOptions(const ShCompileOptions &other);
ShCompileOptions &operator=(const ShCompileOptions &other);
// Translates intermediate tree to glsl, hlsl, msl, or SPIR-V binary. Can be queried by
// calling sh::GetObjectCode().
uint64_t objectCode : 1;
// Whether debug info should be output in the shader.
uint64_t outputDebugInfo : 1;
// Tracks the source path for shaders. Can be queried with getSourcePath().
uint64_t sourcePath : 1;
// Whether the internal representation of the AST should be output.
uint64_t intermediateTree : 1;
// If requested, validates the AST after every transformation. Useful for debugging.
uint64_t validateAST : 1;
// Validates loop and indexing in the shader to ensure that they do not exceed the minimum
// functionality mandated in GLSL 1.0 spec, Appendix A, Section 4 and 5. There is no need to
// specify this parameter when compiling for WebGL - it is implied.
uint64_t validateLoopIndexing : 1;
// Emits #line directives in HLSL.
uint64_t lineDirectives : 1;
// Due to spec difference between GLSL 4.1 or lower and ESSL3, some platforms (for example, Mac
// OSX core profile) require a variable's "invariant"/"centroid" qualifiers to match between
// vertex and fragment shader. A simple solution to allow such shaders to link is to omit the
// two qualifiers. AMD driver in Linux requires invariant qualifier to match between vertex and
// fragment shaders, while ESSL3 disallows invariant qualifier in fragment shader and GLSL >=
// 4.2 doesn't require invariant qualifier to match between shaders. Remove invariant qualifier
// from vertex shader to workaround AMD driver bug.
// Note that the two flags take effect on ESSL3 input shaders translated to GLSL 4.1 or lower
// and to GLSL 4.2 or newer on Linux AMD.
// TODO(zmo): This is not a good long-term solution. Simply dropping these qualifiers may break
// some developers' content. A more complex workaround of dynamically generating, compiling, and
// re-linking shaders that use these qualifiers should be implemented.
uint64_t removeInvariantAndCentroidForESSL3 : 1;
// This flag works around bug in Intel Mac drivers related to abs(i) where i is an integer.
uint64_t emulateAbsIntFunction : 1;
// Enforce the GLSL 1.017 Appendix A section 7 packing restrictions. This flag only enforces
// (and can only enforce) the packing restrictions for uniform variables in both vertex and
// fragment shaders. ShCheckVariablesWithinPackingLimits() lets embedders enforce the packing
// restrictions for varying variables during program link time.
uint64_t enforcePackingRestrictions : 1;
// This flag ensures all indirect (expression-based) array indexing is clamped to the bounds of
// the array. This ensures, for example, that you cannot read off the end of a uniform, whether
// an array vec234, or mat234 type.
uint64_t clampIndirectArrayBounds : 1;
// This flag limits the complexity of an expression.
uint64_t limitExpressionComplexity : 1;
// This flag limits the depth of the call stack.
uint64_t limitCallStackDepth : 1;
// This flag initializes gl_Position to vec4(0,0,0,0) at the beginning of the vertex shader's
// main(), and has no effect in the fragment shader. It is intended as a workaround for drivers
// which incorrectly fail to link programs if gl_Position is not written.
uint64_t initGLPosition : 1;
// This flag replaces
// "a && b" with "a ? b : false",
// "a || b" with "a ? true : b".
// This is to work around a MacOSX driver bug that |b| is executed independent of |a|'s value.
uint64_t unfoldShortCircuit : 1;
// This flag initializes output variables to 0 at the beginning of main(). It is to avoid
// undefined behaviors.
uint64_t initOutputVariables : 1;
// This flag scalarizes vec/ivec/bvec/mat constructor args. It is intended as a workaround for
// Linux/Mac driver bugs.
uint64_t scalarizeVecAndMatConstructorArgs : 1;
// This flag overwrites a struct name with a unique prefix. It is intended as a workaround for
// drivers that do not handle struct scopes correctly, including all Mac drivers and Linux AMD.
uint64_t regenerateStructNames : 1;
// This flag works around a bug in the HLSL compiler optimizer that folds certain constant pow
// expressions incorrectly. Only applies to the HLSL back-end. It works by expanding the integer
// pow expressions into a series of multiplies.
uint64_t expandSelectHLSLIntegerPowExpressions : 1;
// Flatten "#pragma STDGL invariant(all)" into the declarations of varying variables and
// built-in GLSL variables. This compiler option is enabled automatically when needed.
uint64_t flattenPragmaSTDGLInvariantAll : 1;
// Some drivers do not take into account the base level of the texture in the results of the
// HLSL GetDimensions builtin. This flag instructs the compiler to manually add the base level
// offsetting.
uint64_t HLSLGetDimensionsIgnoresBaseLevel : 1;
// This flag works around an issue in translating GLSL function texelFetchOffset on INTEL
// drivers. It works by translating texelFetchOffset into texelFetch.
uint64_t rewriteTexelFetchOffsetToTexelFetch : 1;
// This flag works around condition bug of for and while loops in Intel Mac OSX drivers.
// Condition calculation is not correct. Rewrite it from "CONDITION" to "CONDITION && true".
uint64_t addAndTrueToLoopCondition : 1;
// This flag works around a bug in evaluating unary minus operator on integer on some INTEL
// drivers. It works by translating -(int) into ~(int) + 1.
uint64_t rewriteIntegerUnaryMinusOperator : 1;
// This flag works around a bug in evaluating isnan() on some INTEL D3D and Mac OSX drivers. It
// works by using an expression to emulate this function.
uint64_t emulateIsnanFloatFunction : 1;
// This flag will use all uniforms of unused std140 and shared uniform blocks at the beginning
// of the vertex/fragment shader's main(). It is intended as a workaround for Mac drivers with
// shader version 4.10. In those drivers, they will treat unused std140 and shared uniform
// blocks' members as inactive. However, WebGL2.0 based on OpenGL ES3.0.4 requires all members
// of a named uniform block declared with a shared or std140 layout qualifier to be considered
// active. The uniform block itself is also considered active.
uint64_t useUnusedStandardSharedBlocks : 1;
// This flag works around a bug in evaluating atan(y, x) on some NVIDIA OpenGL drivers. It
// works by using an expression to emulate this function.
uint64_t emulateAtan2FloatFunction : 1;
// Set to initialize uninitialized local and global temporary variables. Should only be used
// with GLSL output. In HLSL output variables are initialized regardless of if this flag is set.
uint64_t initializeUninitializedLocals : 1;
// The flag modifies the shader in the following way:
//
// Every occurrence of gl_InstanceID is replaced by the global temporary variable InstanceID.
// Every occurrence of gl_ViewID_OVR is replaced by the varying variable ViewID_OVR.
// At the beginning of the body of main() in a vertex shader the following initializers are
// added:
// ViewID_OVR = uint(gl_InstanceID) % num_views;
// InstanceID = gl_InstanceID / num_views;
// ViewID_OVR is added as a varying variable to both the vertex and fragment shaders.
uint64_t initializeBuiltinsForInstancedMultiview : 1;
// With the flag enabled the GLSL/ESSL vertex shader is modified to include code for viewport
// selection in the following way:
// - Code to enable the extension ARB_shader_viewport_layer_array/NV_viewport_array2 is
// included.
// - Code to select the viewport index or layer is inserted at the beginning of main after
// ViewID_OVR's initialization.
// - A declaration of the uniform multiviewBaseViewLayerIndex.
// Note: The initializeBuiltinsForInstancedMultiview flag also has to be enabled to have the
// temporary variable ViewID_OVR declared and initialized.
uint64_t selectViewInNvGLSLVertexShader : 1;
// If the flag is enabled, gl_PointSize is clamped to the maximum point size specified in
// ShBuiltInResources in vertex shaders.
uint64_t clampPointSize : 1;
// This flag indicates whether advanced blend equation should be emulated. Currently only
// implemented for the Vulkan backend.
uint64_t addAdvancedBlendEquationsEmulation : 1;
// Don't use loops to initialize uninitialized variables. Only has an effect if some kind of
// variable initialization is turned on.
uint64_t dontUseLoopsToInitializeVariables : 1;
// Don't use D3D constant register zero when allocating space for uniforms. This is targeted to
// work around a bug in NVIDIA D3D driver version 388.59 where in very specific cases the driver
// would not handle constant register zero correctly. Only has an effect on HLSL translation.
uint64_t skipD3DConstantRegisterZero : 1;
// Clamp gl_FragDepth to the range [0.0, 1.0] in case it is statically used.
uint64_t clampFragDepth : 1;
// Rewrite expressions like "v.x = z = expression;". Works around a bug in NVIDIA OpenGL drivers
// prior to version 397.31.
uint64_t rewriteRepeatedAssignToSwizzled : 1;
// Rewrite gl_DrawID as a uniform int
uint64_t emulateGLDrawID : 1;
// This flag initializes shared variables to 0. It is to avoid ompute shaders being able to
// read undefined values that could be coming from another webpage/application.
uint64_t initSharedVariables : 1;
// Forces the value returned from an atomic operations to be always be resolved. This is
// targeted to workaround a bug in NVIDIA D3D driver where the return value from
// RWByteAddressBuffer.InterlockedAdd does not get resolved when used in the .yzw components of
// a RWByteAddressBuffer.Store operation. Only has an effect on HLSL translation.
// http://anglebug.com/42261924
uint64_t forceAtomicValueResolution : 1;
// Rewrite gl_BaseVertex and gl_BaseInstance as uniform int
uint64_t emulateGLBaseVertexBaseInstance : 1;
// Workaround for a driver bug with nested switches.
uint64_t wrapSwitchInIfTrue : 1;
// This flag controls how to translate WEBGL_video_texture sampling function.
uint64_t takeVideoTextureAsExternalOES : 1;
// This flag works around a inconsistent behavior in Mac AMD driver where gl_VertexID doesn't
// include base vertex value. It replaces gl_VertexID with (gl_VertexID + angle_BaseVertex) when
// angle_BaseVertex is available.
uint64_t addBaseVertexToVertexID : 1;
// This works around the dynamic lvalue indexing of swizzled vectors on various platforms.
uint64_t removeDynamicIndexingOfSwizzledVector : 1;
// This flag works around a slow fxc compile performance issue with dynamic uniform indexing.
uint64_t allowTranslateUniformBlockToStructuredBuffer : 1;
// This flag allows us to add a decoration for layout(yuv) in shaders.
uint64_t addVulkanYUVLayoutQualifier : 1;
// This flag allows disabling ARB_texture_rectangle on a per-compile basis. This is necessary
// for WebGL contexts becuase ARB_texture_rectangle may be necessary for the WebGL
// implementation internally but shouldn't be exposed to WebGL user code.
uint64_t disableARBTextureRectangle : 1;
// This flag works around a driver bug by rewriting uses of row-major matrices as column-major
// in ESSL 3.00 and greater shaders.
uint64_t rewriteRowMajorMatrices : 1;
// Drop any explicit precision qualifiers from shader.
uint64_t ignorePrecisionQualifiers : 1;
// Ask compiler to generate code for depth correction to conform to the Vulkan clip space. If
// VK_EXT_depth_clip_control is supported, this code is not generated, saving a uniform look up.
uint64_t addVulkanDepthCorrection : 1;
uint64_t forceShaderPrecisionHighpToMediump : 1;
// Ask compiler to generate Vulkan transform feedback emulation support code.
uint64_t addVulkanXfbEmulationSupportCode : 1;
// Ask compiler to generate Vulkan transform feedback support code when using the
// VK_EXT_transform_feedback extension.
uint64_t addVulkanXfbExtensionSupportCode : 1;
// This flag initializes fragment shader's output variables to zero at the beginning of the
// fragment shader's main(). It is intended as a workaround for drivers which get context lost
// if gl_FragColor is not written.
uint64_t initFragmentOutputVariables : 1;
// Always write explicit location layout qualifiers for fragment outputs.
uint64_t explicitFragmentLocations : 1;
// Add round() after applying dither. This works around a Qualcomm quirk where values can get
// ceil()ed instead.
uint64_t roundOutputAfterDithering : 1;
// issuetracker.google.com/274859104 add OpQuantizeToF16 instruction to cast
// mediump floating-point values to 16 bit. ARM compiler utilized RelaxedPrecision
// to minimize type case and keep a mediump float as 32 bit when assigning it with
// a highp floating-point value. It is possible that GLSL shader code is comparing
// two meiump values, but ARM compiler is comparing a 32 bit value with a 16 bit value,
// causing the comparison to fail.
uint64_t castMediumpFloatTo16Bit : 1;
// anglebug.com/42265995: packUnorm4x8 fails on Pixel 4 if it is not passed a highp vec4.
// TODO(anglebug.com/42265995): This workaround is currently only applied for pixel local
// storage. We may want to apply it generally.
uint64_t passHighpToPackUnormSnormBuiltins : 1;
// Use an integer uniform to pass a bitset of enabled clip distances.
uint64_t emulateClipDistanceState : 1;
// Use a uniform to emulate GL_CLIP_ORIGIN_EXT state.
uint64_t emulateClipOrigin : 1;
// issuetracker.google.com/266235549 add aliased memory decoration to ssbo if the variable is
// not declared with "restrict" memory qualifier in GLSL
uint64_t aliasedUnlessRestrict : 1;
// Use fragment shaders to compute and set coverage mask based on the alpha value
uint64_t emulateAlphaToCoverage : 1;
// Rescope globals that are only used in one function to be function-local.
uint64_t rescopeGlobalVariables : 1;
// Pre-transform explicit cubemap derivatives for Apple GPUs.
uint64_t preTransformTextureCubeGradDerivatives : 1;
// Workaround for a driver bug with the use of the OpSelect SPIR-V instruction.
uint64_t avoidOpSelectWithMismatchingRelaxedPrecision : 1;
// Whether SPIR-V 1.4 can be emitted. If not set, SPIR-V 1.3 is emitted.
uint64_t emitSPIRV14 : 1;
// Reject shaders with obvious undefined behavior:
//
// - Shader contains easy-to-detect infinite loops
//
uint64_t rejectWebglShadersWithUndefinedBehavior : 1;
// Emulate r32f image with an r32ui image
uint64_t emulateR32fImageAtomicExchange : 1;
// Rewrite for and while loops to loop normal form.
uint64_t simplifyLoopConditions : 1;
// Specify struct in one statement, declare instance in other.
uint64_t separateCompoundStructDeclarations : 1;
// Whether to preserve denorm floats in the lexer or convert to zero
uint64_t preserveDenorms : 1;
// Whether inactive shader variables from the output.
uint64_t removeInactiveVariables : 1;
// Ensure all loops execute side-effects or terminate.
uint64_t ensureLoopForwardProgress : 1;
ShCompileOptionsMetal metal;
ShPixelLocalStorageOptions pls;
};
// The 64 bits hash function. The first parameter is the input string; the
// second parameter is the string length.
using ShHashFunction64 = khronos_uint64_t (*)(const char *, size_t);
//
// Implementation dependent built-in resources (constants and extensions).
// The names for these resources has been obtained by stripping gl_/GL_.
//
struct ShBuiltInResources
{
ShBuiltInResources();
ShBuiltInResources(const ShBuiltInResources &other);
ShBuiltInResources &operator=(const ShBuiltInResources &other);
// Constants.
int MaxVertexAttribs;
int MaxVertexUniformVectors;
int MaxVaryingVectors;
int MaxVertexTextureImageUnits;
int MaxCombinedTextureImageUnits;
int MaxTextureImageUnits;
int MaxFragmentUniformVectors;
int MaxDrawBuffers;
// Extensions.
// Set to 1 to enable the extension, else 0.
int OES_standard_derivatives;
int OES_EGL_image_external;
int OES_EGL_image_external_essl3;
int NV_EGL_stream_consumer_external;
int ARB_texture_rectangle;
int EXT_blend_func_extended;
int EXT_conservative_depth;
int EXT_draw_buffers;
int EXT_frag_depth;
int EXT_shader_texture_lod;
int EXT_shader_framebuffer_fetch;
int EXT_shader_framebuffer_fetch_non_coherent;
int NV_shader_framebuffer_fetch;
int NV_shader_noperspective_interpolation;
int ARM_shader_framebuffer_fetch;
int ARM_shader_framebuffer_fetch_depth_stencil;
int OVR_multiview;
int OVR_multiview2;
int EXT_multisampled_render_to_texture;
int EXT_multisampled_render_to_texture2;
int EXT_YUV_target;
int EXT_geometry_shader;
int OES_geometry_shader;
int OES_shader_io_blocks;
int EXT_shader_io_blocks;
int EXT_gpu_shader5;
int OES_gpu_shader5;
int EXT_shader_non_constant_global_initializers;
int OES_texture_storage_multisample_2d_array;
int OES_texture_3D;
int ANGLE_shader_pixel_local_storage;
int ANGLE_texture_multisample;
int ANGLE_multi_draw;
// TODO(angleproject:3402) remove after chromium side removal to pass compilation
int ANGLE_base_vertex_base_instance;
int WEBGL_video_texture;
int APPLE_clip_distance;
int OES_texture_cube_map_array;
int EXT_texture_cube_map_array;
int EXT_texture_query_lod;
int EXT_texture_shadow_lod;
int EXT_shadow_samplers;
int OES_shader_multisample_interpolation;
int OES_shader_image_atomic;
int EXT_tessellation_shader;
int OES_tessellation_shader;
int OES_texture_buffer;
int EXT_texture_buffer;
int OES_sample_variables;
int EXT_clip_cull_distance;
int ANGLE_clip_cull_distance;
int EXT_primitive_bounding_box;
int OES_primitive_bounding_box;
int EXT_separate_shader_objects;
int ANGLE_base_vertex_base_instance_shader_builtin;
int ANDROID_extension_pack_es31a;
int KHR_blend_equation_advanced;
// Set to 1 to enable replacing GL_EXT_draw_buffers #extension directives
// with GL_NV_draw_buffers in ESSL output. This flag can be used to emulate
// EXT_draw_buffers by using it in combination with GLES3.0 glDrawBuffers
// function. This applies to Tegra K1 devices.
int NV_draw_buffers;
// Set to 1 if highp precision is supported in the ESSL 1.00 version of the
// fragment language. Does not affect versions of the language where highp
// support is mandatory.
// Default is 0.
int FragmentPrecisionHigh;
// GLSL ES 3.0 constants.
int MaxVertexOutputVectors;
int MaxFragmentInputVectors;
int MinProgramTexelOffset;
int MaxProgramTexelOffset;
// Extension constants.
// Value of GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT for OpenGL ES output context.
// Value of GL_MAX_DUAL_SOURCE_DRAW_BUFFERS for OpenGL output context.
// GLES SL version 100 gl_MaxDualSourceDrawBuffersEXT value for EXT_blend_func_extended.
int MaxDualSourceDrawBuffers;
// Value of GL_MAX_VIEWS_OVR.
int MaxViewsOVR;
// Name Hashing.
// Set a 64 bit hash function to enable user-defined name hashing.
// Default is NULL.
ShHashFunction64 HashFunction;
// The maximum complexity an expression can be when limitExpressionComplexity is turned on.
int MaxExpressionComplexity;
// The maximum depth of certain nestable statements (while, switch);
int MaxStatementDepth;
// The maximum depth a call stack can be.
int MaxCallStackDepth;
// The maximum number of parameters a function can have when limitExpressionComplexity is turned
// on.
int MaxFunctionParameters;
// GLES 3.1 constants
// texture gather offset constraints.
int MinProgramTextureGatherOffset;
int MaxProgramTextureGatherOffset;
// maximum number of available image units
int MaxImageUnits;
// OES_sample_variables constant
// maximum number of available samples
int MaxSamples;
// maximum number of image uniforms in a vertex shader
int MaxVertexImageUniforms;
// maximum number of image uniforms in a fragment shader
int MaxFragmentImageUniforms;
// maximum number of image uniforms in a compute shader
int MaxComputeImageUniforms;
// maximum total number of image uniforms in a program
int MaxCombinedImageUniforms;
// maximum number of uniform locations
int MaxUniformLocations;
// maximum number of ssbos and images in a shader
int MaxCombinedShaderOutputResources;
// maximum number of groups in each dimension
std::array<int, 3> MaxComputeWorkGroupCount;
// maximum number of threads per work group in each dimension
std::array<int, 3> MaxComputeWorkGroupSize;
// maximum number of total uniform components
int MaxComputeUniformComponents;
// maximum number of texture image units in a compute shader
int MaxComputeTextureImageUnits;
// maximum number of atomic counters in a compute shader
int MaxComputeAtomicCounters;
// maximum number of atomic counter buffers in a compute shader
int MaxComputeAtomicCounterBuffers;
// maximum number of atomic counters in a vertex shader
int MaxVertexAtomicCounters;
// maximum number of atomic counters in a fragment shader
int MaxFragmentAtomicCounters;
// maximum number of atomic counters in a program
int MaxCombinedAtomicCounters;
// maximum binding for an atomic counter
int MaxAtomicCounterBindings;
// maximum number of atomic counter buffers in a vertex shader
int MaxVertexAtomicCounterBuffers;
// maximum number of atomic counter buffers in a fragment shader
int MaxFragmentAtomicCounterBuffers;
// maximum number of atomic counter buffers in a program
int MaxCombinedAtomicCounterBuffers;
// maximum number of buffer object storage in machine units
int MaxAtomicCounterBufferSize;
// maximum number of uniform block bindings
int MaxUniformBufferBindings;
// maximum number of shader storage buffer bindings
int MaxShaderStorageBufferBindings;
// minimum point size (lower limit from ALIASED_POINT_SIZE_RANGE)
float MinPointSize;
// maximum point size (higher limit from ALIASED_POINT_SIZE_RANGE)
float MaxPointSize;
// EXT_geometry_shader constants
int MaxGeometryUniformComponents;
int MaxGeometryUniformBlocks;
int MaxGeometryInputComponents;
int MaxGeometryOutputComponents;
int MaxGeometryOutputVertices;
int MaxGeometryTotalOutputComponents;
int MaxGeometryTextureImageUnits;
int MaxGeometryAtomicCounterBuffers;
int MaxGeometryAtomicCounters;
int MaxGeometryShaderStorageBlocks;
int MaxGeometryShaderInvocations;
int MaxGeometryImageUniforms;
// EXT_tessellation_shader constants
int MaxTessControlInputComponents;
int MaxTessControlOutputComponents;
int MaxTessControlTextureImageUnits;
int MaxTessControlUniformComponents;
int MaxTessControlTotalOutputComponents;
int MaxTessControlImageUniforms;
int MaxTessControlAtomicCounters;
int MaxTessControlAtomicCounterBuffers;
int MaxTessPatchComponents;
int MaxPatchVertices;
int MaxTessGenLevel;
int MaxTessEvaluationInputComponents;
int MaxTessEvaluationOutputComponents;
int MaxTessEvaluationTextureImageUnits;
int MaxTessEvaluationUniformComponents;
int MaxTessEvaluationImageUniforms;
int MaxTessEvaluationAtomicCounters;
int MaxTessEvaluationAtomicCounterBuffers;
// Subpixel bits used in rasterization.
int SubPixelBits;
// APPLE_clip_distance / EXT_clip_cull_distance / ANGLE_clip_cull_distance constants
int MaxClipDistances;
int MaxCullDistances;
int MaxCombinedClipAndCullDistances;
// ANGLE_shader_pixel_local_storage.
int MaxPixelLocalStoragePlanes;
int MaxCombinedDrawBuffersAndPixelLocalStoragePlanes;
};
//
// ShHandle held by but opaque to the driver. It is allocated,
// managed, and de-allocated by the compiler. Its contents
// are defined by and used by the compiler.
//
// If handle creation fails, 0 will be returned.
//
using ShHandle = void *;
namespace sh
{
using BinaryBlob = std::vector<uint32_t>;
using ShaderBinaryBlob = std::vector<uint8_t>;
//
// Driver must call this first, once, before doing any other compiler operations.
// If the function succeeds, the return value is true, else false.
//
bool Initialize();
//
// Driver should call this at shutdown.
// If the function succeeds, the return value is true, else false.
//
bool Finalize();
//
// Initialize built-in resources with minimum expected values.
// Parameters:
// resources: The object to initialize. Will be comparable with memcmp.
//
void InitBuiltInResources(ShBuiltInResources *resources);
//
// Returns a copy of the current ShBuiltInResources stored in the compiler.
// Parameters:
// handle: Specifies the handle of the compiler to be used.
ShBuiltInResources GetBuiltInResources(const ShHandle handle);
//
// Returns the a concatenated list of the items in ShBuiltInResources as a null-terminated string.
// This function must be updated whenever ShBuiltInResources is changed.
// Parameters:
// handle: Specifies the handle of the compiler to be used.
const std::string &GetBuiltInResourcesString(const ShHandle handle);
//
// Driver calls these to create and destroy compiler objects.
//
// Returns the handle of constructed compiler, null if the requested compiler is not supported.
// Parameters:
// type: Specifies the type of shader - GL_FRAGMENT_SHADER or GL_VERTEX_SHADER.
// spec: Specifies the language spec the compiler must conform to - SH_GLES2_SPEC or SH_WEBGL_SPEC.
// output: Specifies the output code type - for example SH_ESSL_OUTPUT, SH_GLSL_OUTPUT,
// SH_HLSL_3_0_OUTPUT or SH_HLSL_4_1_OUTPUT. Note: Each output type may only
// be supported in some configurations.
// resources: Specifies the built-in resources.
ShHandle ConstructCompiler(sh::GLenum type,
ShShaderSpec spec,
ShShaderOutput output,
const ShBuiltInResources *resources);
void Destruct(ShHandle handle);
//
// Compiles the given shader source.
// If the function succeeds, the return value is true, else false.
// Parameters:
// handle: Specifies the handle of compiler to be used.
// shaderStrings: Specifies an array of pointers to null-terminated strings containing the shader
// source code.
// numStrings: Specifies the number of elements in shaderStrings array.
// compileOptions: A mask of compile options defined above.
bool Compile(const ShHandle handle,
const char *const shaderStrings[],
size_t numStrings,
const ShCompileOptions &compileOptions);
// Clears the results from the previous compilation.
void ClearResults(const ShHandle handle);
// Return the version of the shader language.
int GetShaderVersion(const ShHandle handle);
// Return the currently set language output type.
ShShaderOutput GetShaderOutputType(const ShHandle handle);
// Returns null-terminated information log for a compiled shader.
// Parameters:
// handle: Specifies the compiler
const std::string &GetInfoLog(const ShHandle handle);
// Returns null-terminated object code for a compiled shader. Only valid for output types that
// generate human-readable code (GLSL, ESSL or HLSL).
// Parameters:
// handle: Specifies the compiler
const std::string &GetObjectCode(const ShHandle handle);
// Returns object binary blob for a compiled shader. Only valid for output types that
// generate binary blob (SPIR-V).
// Parameters:
// handle: Specifies the compiler
const BinaryBlob &GetObjectBinaryBlob(const ShHandle handle);
// Returns a full binary for a compiled shader, to be loaded with glShaderBinary during runtime.
// Parameters:
// handle: Specifies the compiler
bool GetShaderBinary(const ShHandle handle,
const char *const shaderStrings[],
size_t numStrings,
const ShCompileOptions &compileOptions,
ShaderBinaryBlob *const binaryOut);
// Returns a (original_name, hash) map containing all the user defined names in the shader,
// including variable names, function names, struct names, and struct field names.
// Parameters:
// handle: Specifies the compiler
const std::map<std::string, std::string> *GetNameHashingMap(const ShHandle handle);
// Shader variable inspection.
// Returns a pointer to a list of variables of the designated type.
// (See ShaderVars.h for type definitions, included above)
// Returns NULL on failure.
// Parameters:
// handle: Specifies the compiler
const std::vector<sh::ShaderVariable> *GetUniforms(const ShHandle handle);
const std::vector<sh::ShaderVariable> *GetVaryings(const ShHandle handle);
const std::vector<sh::ShaderVariable> *GetInputVaryings(const ShHandle handle);
const std::vector<sh::ShaderVariable> *GetOutputVaryings(const ShHandle handle);
const std::vector<sh::ShaderVariable> *GetAttributes(const ShHandle handle);
const std::vector<sh::ShaderVariable> *GetOutputVariables(const ShHandle handle);
const std::vector<sh::InterfaceBlock> *GetInterfaceBlocks(const ShHandle handle);
const std::vector<sh::InterfaceBlock> *GetUniformBlocks(const ShHandle handle);
const std::vector<sh::InterfaceBlock> *GetShaderStorageBlocks(const ShHandle handle);
sh::WorkGroupSize GetComputeShaderLocalGroupSize(const ShHandle handle);
// Returns the number of views specified through the num_views layout qualifier. If num_views is
// not set, the function returns -1.
int GetVertexShaderNumViews(const ShHandle handle);
// Returns the pixel local storage uniform format at each binding index, or "NotPLS" if there is
// not one.
const std::vector<ShPixelLocalStorageFormat> *GetPixelLocalStorageFormats(const ShHandle handle);
// Returns specialization constant usage bits
uint32_t GetShaderSpecConstUsageBits(const ShHandle handle);
// Returns true if the passed in variables pack in maxVectors followingthe packing rules from the
// GLSL 1.017 spec, Appendix A, section 7.
// Returns false otherwise. Also look at the enforcePackingRestrictions flag above.
// Parameters:
// maxVectors: the available rows of registers.
// variables: an array of variables.
bool CheckVariablesWithinPackingLimits(int maxVectors,
const std::vector<sh::ShaderVariable> &variables);
// Gives the compiler-assigned register for a shader storage block.
// The method writes the value to the output variable "indexOut".
// Returns true if it found a valid shader storage block, false otherwise.
// Parameters:
// handle: Specifies the compiler
// shaderStorageBlockName: Specifies the shader storage block
// indexOut: output variable that stores the assigned register
bool GetShaderStorageBlockRegister(const ShHandle handle,
const std::string &shaderStorageBlockName,
unsigned int *indexOut);
// Gives the compiler-assigned register for a uniform block.
// The method writes the value to the output variable "indexOut".
// Returns true if it found a valid uniform block, false otherwise.
// Parameters:
// handle: Specifies the compiler
// uniformBlockName: Specifies the uniform block
// indexOut: output variable that stores the assigned register
bool GetUniformBlockRegister(const ShHandle handle,
const std::string &uniformBlockName,
unsigned int *indexOut);
bool ShouldUniformBlockUseStructuredBuffer(const ShHandle handle,
const std::string &uniformBlockName);
const std::set<std::string> *GetSlowCompilingUniformBlockSet(const ShHandle handle);
// Gives a map from uniform names to compiler-assigned registers in the default uniform block.
// Note that the map contains also registers of samplers that have been extracted from structs.
const std::map<std::string, unsigned int> *GetUniformRegisterMap(const ShHandle handle);
// Sampler, image and atomic counters share registers(t type and u type),
// GetReadonlyImage2DRegisterIndex and GetImage2DRegisterIndex return the first index into
// a range of reserved registers for image2D/iimage2D/uimage2D variables.
// Parameters: handle: Specifies the compiler
unsigned int GetReadonlyImage2DRegisterIndex(const ShHandle handle);
unsigned int GetImage2DRegisterIndex(const ShHandle handle);
// The method records these used function names related with image2D/iimage2D/uimage2D, these
// functions will be dynamically generated.
// Parameters:
// handle: Specifies the compiler
const std::set<std::string> *GetUsedImage2DFunctionNames(const ShHandle handle);
uint8_t GetClipDistanceArraySize(const ShHandle handle);
uint8_t GetCullDistanceArraySize(const ShHandle handle);
GLenum GetGeometryShaderInputPrimitiveType(const ShHandle handle);
GLenum GetGeometryShaderOutputPrimitiveType(const ShHandle handle);
int GetGeometryShaderInvocations(const ShHandle handle);
int GetGeometryShaderMaxVertices(const ShHandle handle);
unsigned int GetShaderSharedMemorySize(const ShHandle handle);
int GetTessControlShaderVertices(const ShHandle handle);
GLenum GetTessGenMode(const ShHandle handle);
GLenum GetTessGenSpacing(const ShHandle handle);
GLenum GetTessGenVertexOrder(const ShHandle handle);
GLenum GetTessGenPointMode(const ShHandle handle);
// Returns a bitset of sh::MetadataFlags. This bundles various bits purely for convenience.
uint32_t GetMetadataFlags(const ShHandle handle);
// Returns the blend equation list supported in the fragment shader. This is a bitset of
// gl::BlendEquationType, and can only include bits from KHR_blend_equation_advanced.
uint32_t GetAdvancedBlendEquations(const ShHandle handle);
//
// Helper function to identify specs that are based on the WebGL spec.
//
inline bool IsWebGLBasedSpec(ShShaderSpec spec)
{
return (spec == SH_WEBGL_SPEC || spec == SH_WEBGL2_SPEC || spec == SH_WEBGL3_SPEC);
}
// Can't prefix with just _ because then we might introduce a double underscore, which is not safe
// in GLSL (ESSL 3.00.6 section 3.8: All identifiers containing a double underscore are reserved for
// use by the underlying implementation). u is short for user-defined.
extern const char kUserDefinedNamePrefix[];
enum class MetadataFlags
{
// Applicable to vertex shaders (technically all pre-rasterization shaders could use this flag,
// but the current and only user is GL, which does not support geometry/tessellation).
HasClipDistance,
// Applicable to fragment shaders
HasDiscard,
EnablesPerSampleShading,
HasInputAttachment0,
// Flag for attachment i is HasInputAttachment0 + i
HasInputAttachment7 = HasInputAttachment0 + 7,
HasDepthInputAttachment,
HasStencilInputAttachment,
// Applicable to geometry shaders
HasValidGeometryShaderInputPrimitiveType,
HasValidGeometryShaderOutputPrimitiveType,
HasValidGeometryShaderMaxVertices,
// Applicable to tessellation shaders
HasValidTessGenMode,
HasValidTessGenSpacing,
HasValidTessGenVertexOrder,
HasValidTessGenPointMode,
InvalidEnum,
EnumCount = InvalidEnum,
};
namespace vk
{
// Specialization constant ids
enum class SpecializationConstantId : uint32_t
{
Dither = 0,
InvalidEnum = 1,
EnumCount = InvalidEnum,
};
enum class SpecConstUsage : uint32_t
{
Dither = 0,
InvalidEnum = 1,
EnumCount = InvalidEnum,
};
enum ColorAttachmentDitherControl
{
// See comments in ContextVk::updateDither and EmulateDithering.cpp
kDitherControlNoDither = 0,
kDitherControlDither4444 = 1,
kDitherControlDither5551 = 2,
kDitherControlDither565 = 3,
};
namespace spirv
{
enum NonSemanticInstruction
{
// The overview instruction containing information such as what predefined ids are present in
// the SPIR-V. Simultaneously, this instruction identifies the location where the
// types/constants/variables section ends and the functions section starts.
kNonSemanticOverview,
// The instruction identifying the entry to the shader, i.e. at the start of main()
kNonSemanticEnter,
// The instruction identifying where vertex or fragment data is output.
// This is before return from main() in vertex, tessellation, and fragment shaders,
// and before OpEmitVertex in geometry shaders.
kNonSemanticOutput,
// The instruction identifying the location where transform feedback emulation should be
// written.
kNonSemanticTransformFeedbackEmulation,
};
// The non-semantic instruction id has many bits available. With kNonSemanticOverview, they are
// used to provide additional overview details. Providing this information in the instruction's
// payload require OpConstants and recovering those, which is unnecessary complexity.
constexpr uint32_t kNonSemanticInstructionBits = 4;
constexpr uint32_t kNonSemanticInstructionMask = 0xF;
constexpr uint32_t kOverviewHasSampleRateShadingMask = 0x10;
constexpr uint32_t kOverviewHasSampleIDMask = 0x20;
constexpr uint32_t kOverviewHasOutputPerVertexMask = 0x40;
enum ReservedIds
{
kIdInvalid = 0,
// =============================================================================================
// Ids that are fixed and are always present in the SPIR-V where applicable. The SPIR-V
// transformer can thus reliably use these ids.
// Global information
kIdNonSemanticInstructionSet,
kIdEntryPoint,
// Basic types
kIdVoid,
kIdFloat,
kIdVec2,
kIdVec3,
kIdVec4,
kIdMat2,
kIdMat3,
kIdMat4,
kIdInt,
kIdIVec4,
kIdUint,
// Common constants
kIdIntZero,
kIdIntOne,
kIdIntTwo,
kIdIntThree,
// Type pointers
kIdIntInputTypePointer,
kIdVec4OutputTypePointer,
kIdIVec4FunctionTypePointer,
kIdOutputPerVertexTypePointer,
// Pre-rotation and Z-correction support
kIdTransformPositionFunction,
kIdInputPerVertexBlockArray,
kIdOutputPerVertexBlockArray,
kIdOutputPerVertexVar,
// Transform feedback support
kIdXfbEmulationGetOffsetsFunction,
kIdXfbEmulationCaptureFunction,
kIdXfbEmulationBufferVarZero,
kIdXfbEmulationBufferVarOne,
kIdXfbEmulationBufferVarTwo,
kIdXfbEmulationBufferVarThree,
// Multisampling support
kIdSampleID,
// =============================================================================================
// ANGLE internal shader variables, which are not produced as ShaderVariables.
// kIdShaderVariablesBegin marks the beginning of these ids. variableId -> info maps in the
// backend can use |variableId - kIdShaderVariablesBegin| as key into a flat array.
//
// Note that for blocks, only the block id is in this section as that is the id used in the
// variableId -> info maps.
kIdShaderVariablesBegin,
// gl_PerVertex
kIdInputPerVertexBlock = kIdShaderVariablesBegin,
kIdOutputPerVertexBlock,
// The driver and default uniform blocks
kIdDriverUniformsBlock,
kIdDefaultUniformsBlock,
// The atomic counter block
kIdAtomicCounterBlock,
// Buffer block used for transform feedback emulation
kIdXfbEmulationBufferBlockZero,
kIdXfbEmulationBufferBlockOne,
kIdXfbEmulationBufferBlockTwo,
kIdXfbEmulationBufferBlockThree,
// Additional varying added to hold untransformed gl_Position for transform feedback capture
kIdXfbExtensionPosition,
// Input attachments used for framebuffer fetch and advanced blend emulation
kIdInputAttachment0,
kIdInputAttachment7 = kIdInputAttachment0 + 7,
kIdDepthInputAttachment,
kIdStencilInputAttachment,
kIdFirstUnreserved,
};
} // namespace spirv
// Packing information for driver uniform's misc field:
// - 1 bit for whether surface rotation results in swapped axes
// - 5 bits for advanced blend equation
// - 6 bits for sample count
// - 8 bits for enabled clip planes
// - 1 bit for whether depth should be transformed to Vulkan clip space
// - 1 bit for whether alpha to coverage is enabled
// - 1 bit for whether the framebuffer is layered
// - 9 bits unused
constexpr uint32_t kDriverUniformsMiscSwapXYMask = 0x1;
constexpr uint32_t kDriverUniformsMiscAdvancedBlendEquationOffset = 1;
constexpr uint32_t kDriverUniformsMiscAdvancedBlendEquationMask = 0x1F;
constexpr uint32_t kDriverUniformsMiscSampleCountOffset = 6;
constexpr uint32_t kDriverUniformsMiscSampleCountMask = 0x3F;
constexpr uint32_t kDriverUniformsMiscEnabledClipPlanesOffset = 12;
constexpr uint32_t kDriverUniformsMiscEnabledClipPlanesMask = 0xFF;
constexpr uint32_t kDriverUniformsMiscTransformDepthOffset = 20;
constexpr uint32_t kDriverUniformsMiscTransformDepthMask = 0x1;
constexpr uint32_t kDriverUniformsMiscAlphaToCoverageOffset = 21;
constexpr uint32_t kDriverUniformsMiscAlphaToCoverageMask = 0x1;
constexpr uint32_t kDriverUniformsMiscLayeredFramebufferOffset = 22;
constexpr uint32_t kDriverUniformsMiscLayeredFramebufferMask = 0x1;
} // namespace vk
namespace mtl
{
// Specialization constant to enable multisampled rendering behavior.
extern const char kMultisampledRenderingConstName[];
// Specialization constant to emulate rasterizer discard.
extern const char kRasterizerDiscardEnabledConstName[];
// Specialization constant to enable depth write in fragment shaders.
extern const char kDepthWriteEnabledConstName[];
// Specialization constant to enable alpha to coverage.
extern const char kEmulateAlphaToCoverageConstName[];
// Specialization constant to write helper sample mask output.
extern const char kWriteHelperSampleMaskConstName[];
// Specialization constant to enable sample mask output.
extern const char kSampleMaskWriteEnabledConstName[];
} // namespace mtl
} // namespace sh
#endif // GLSLANG_SHADERLANG_H_