Commit 56db3789 by Clemen Deng Committed by Commit Bot

Use flat arrays instead of switches for function lookups

Current implementation of built in function lookup uses autogenerated switch statements. Instead, use the perfect hash mapping to have the lookup use arrays instead. This will improve runtime performance. Bug: angleproject:3805 Change-Id: I6d0ba62d79abd53a7fe818fe675282800781f256 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1756883 Commit-Queue: Clemen Deng <clemendeng@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 552f5fcb
{ {
"src/compiler/translator/ImmutableString_autogen.cpp": "src/compiler/translator/ImmutableString_autogen.cpp":
"0a96956b0168817b28032a567f606940", "81004ecca353bdce6999ba864615e10f",
"src/compiler/translator/ParseContext_autogen.h": "src/compiler/translator/ParseContext_autogen.h":
"48f878f5878e8ab239af7c14e5878b62", "48f878f5878e8ab239af7c14e5878b62",
"src/compiler/translator/SymbolTable_autogen.cpp": "src/compiler/translator/SymbolTable_autogen.cpp":
"e215cb47f2d21e9c2b4b4c8a224fda9d", "e101aa202c0397caf48482853bb90d02",
"src/compiler/translator/SymbolTable_autogen.h": "src/compiler/translator/SymbolTable_autogen.h":
"bdb3c8eab0d48267a2f264e3af635e1a", "3b7cc472d076136a048d6b6f9c28460c",
"src/compiler/translator/builtin_function_declarations.txt": "src/compiler/translator/builtin_function_declarations.txt":
"583e23ceaca8d2baeb07694049b68644", "fc9b0b050448d015482c9f13cab1df67",
"src/compiler/translator/builtin_variables.json": "src/compiler/translator/builtin_variables.json":
"802417116fe4b1391b2d80ad04479cf8", "34906b1c84fe40824e412607f9f1c501",
"src/compiler/translator/gen_builtin_symbols.py": "src/compiler/translator/gen_builtin_symbols.py":
"f8f1c8cc208f5f1bb64cf6921e28e966", "a671720ef20bf7d7a7f719a42f9ae7b6",
"src/compiler/translator/tree_util/BuiltIn_autogen.h": "src/compiler/translator/tree_util/BuiltIn_autogen.h":
"80a911c6701baded2fd8d5567c605669", "80a911c6701baded2fd8d5567c605669",
"src/tests/compiler_tests/ImmutableString_test_autogen.cpp": "src/tests/compiler_tests/ImmutableString_test_autogen.cpp":
"c7c54d5374ccf145a11bd91035b92a5c" "181c3209ad287d1a9477313ea0332445"
} }
\ No newline at end of file
...@@ -126,10 +126,9 @@ class ImmutableString ...@@ -126,10 +126,9 @@ class ImmutableString
} }
}; };
// This hash encodes the opening parentheses location (if any), name length and whether the name // Perfect hash functions
// contains { or [ characters in addition to a 19-bit hash. This way the hash is more useful for
// lookups. The string passed in should be at most 63 characters.
uint32_t mangledNameHash() const; uint32_t mangledNameHash() const;
uint32_t unmangledNameHash() const;
private: private:
const char *mData; const char *mData;
......
...@@ -24,351 +24,342 @@ std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str) ...@@ -24,351 +24,342 @@ std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str)
namespace namespace
{ {
constexpr int kT1[] = {4292, 1592, 4573, 298, 3173, 3569, 4869, 2125, 2112, 3198, 1733, 4935, 1772, constexpr int mangledkT1[] = {2719, 2955, 3884, 1726, 3262, 1871, 1439, 3101, 2584, 1304,
748, 1729, 1297, 5087, 4525, 3739, 1397, 1435, 466, 1338, 2385, 2143, 3818, 2473, 443, 3851, 132, 300, 2929, 3304, 3930, 1779, 3960,
437, 3614, 1476, 2658, 4988, 848, 4735, 2113, 4485, 1905, 4677}; 2114, 1454, 2489, 1923, 1745, 972, 1092, 2973, 152, 822,
constexpr int kT2[] = {773, 2979, 1124, 532, 4590, 1371, 3189, 659, 1450, 705, 1406, 47, 1843, 1230, 1001, 1930, 4008, 2050, 1350, 758};
4783, 3189, 4836, 2299, 303, 782, 2482, 1161, 4792, 2767, 463, 598, 2055, constexpr int mangledkT2[] = {383, 1244, 2085, 3708, 251, 2282, 2314, 3643, 1561, 1995,
2768, 4489, 4232, 1677, 1321, 501, 3971, 2039, 2368, 485, 353}; 2797, 953, 2676, 1891, 1011, 1052, 2494, 2853, 1193, 1625,
constexpr int kG[] = { 4065, 1572, 3492, 1910, 4194, 4013, 546, 2118, 14, 929,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2264, 3644, 1570, 1400, 1304, 3634, 2163};
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, constexpr int mangledkG[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3926, 0, 0, 0, 0, 0, 0, 0,
0, 1819, 0, 1432, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2146, 0,
0, 0, 0, 0, 0, 0, 0, 1731, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2678, 0, 0, 0, 0, 0, 15, 0, 1063, 0, 0,
0, 0, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2530, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3799, 0,
0, 1215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1018, 0, 0, 0, 0, 0, 3221, 3061, 1661, 0, 0, 0, 0, 0, 0, 0, 2529,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1526, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3657, 0, 188, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3654, 0, 0, 0, 0, 0, 0, 0, 0, 338, 0, 1270, 0, 0, 2040, 0, 0,
0, 4390, 0, 0, 0, 0, 0, 0, 0, 0, 651, 462, 0, 0, 0, 518, 1910, 0, 4154, 0, 0, 0, 0, 1859, 0, 0, 1758, 0, 0, 0, 3306, 0,
0, 0, 4759, 0, 0, 2301, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2755, 0, 0, 0, 0, 0, 0, 504, 0, 0, 0, 0, 0, 0, 3818,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1263, 0, 141, 0, 0, 0, 244, 0, 1353, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 862, 0, 0, 0, 0, 0, 0, 2786, 0, 2047, 0, 556, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 184, 0, 0, 186, 1240, 0, 0, 0, 0, 0, 0, 0, 0, 1431, 0, 0, 3740, 0, 0, 78, 0, 2694,
0, 5080, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4926, 431, 0, 0, 0, 0, 923, 0, 0, 0, 0, 0, 960, 1327, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 4103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 874, 0, 0, 633, 2581, 0, 2612, 0, 0, 366, 3236, 0, 0, 0, 0, 1640, 0, 0,
0, 0, 629, 0, 0, 0, 0, 0, 0, 4796, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3910, 694, 3979, 0, 0, 268,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 334, 0, 4437, 0, 1824, 3802, 0, 0, 2900, 0, 2145, 0, 0, 1062, 0, 0, 518, 0, 0, 0, 0,
0, 0, 1136, 0, 0, 0, 0, 0, 0, 883, 0, 0, 2978, 0, 0, 0, 0, 0, 3990, 0, 0, 0, 1188, 0, 0, 0, 0, 0, 0, 0, 0, 0,
695, 0, 0, 0, 0, 0, 0, 0, 0, 583, 0, 282, 0, 0, 0, 0, 3789, 0, 0, 1447, 0, 1955, 1174, 0, 0, 0, 2940, 2811, 593, 0, 0, 2477,
0, 0, 0, 0, 2848, 0, 0, 0, 0, 5022, 0, 0, 0, 4122, 4340, 0, 0, 677, 0, 0, 1756, 0, 0, 429, 0, 0, 0, 0, 1560, 0, 0, 0,
3830, 0, 0, 0, 0, 0, 2272, 0, 0, 0, 1768, 0, 0, 4024, 0, 0, 1289, 0, 0, 0, 0, 2167, 2850, 0, 0, 0, 877, 0, 1978, 0, 0, 0,
0, 0, 0, 0, 0, 4603, 2203, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1750, 0, 0, 0, 847, 0, 0, 0, 634, 0,
0, 0, 0, 0, 0, 0, 2278, 0, 0, 0, 2046, 918, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 0, 2442, 3012, 0, 3889, 3525, 0, 0, 0,
4553, 0, 0, 1808, 0, 0, 0, 0, 0, 0, 0, 2334, 1739, 0, 0, 440, 0, 2078, 0, 0, 3687, 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1773, 0, 0, 1880, 0, 0, 656, 0, 0, 379, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 1738, 0,
385, 0, 2244, 0, 0, 0, 0, 1792, 0, 0, 4806, 0, 2325, 0, 1550, 0, 0, 0, 0, 2796, 169, 0, 11, 2179, 0, 3234, 0, 0, 0, 0, 0, 368,
0, 0, 0, 0, 0, 0, 2472, 0, 4596, 0, 430, 0, 0, 360, 0, 0, 742, 0, 0, 911, 0, 0, 986, 0, 0, 1758, 0, 0, 899, 2142, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1672, 1301, 0, 1406, 0, 0, 2130, 0, 0, 0, 0, 0, 387, 0, 1528, 0, 0, 141, 0, 0, 2132, 0, 3603, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 1440, 668, 0, 351, 0, 619,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 514, 0, 1010, 0, 0, 0, 0, 2439, 3012, 0, 3914, 0, 0, 0, 0, 0, 4063, 0, 1732, 0, 0,
0, 5017, 0, 0, 0, 1490, 552, 0, 0, 0, 0, 0, 1029, 0, 0, 0, 0, 0, 0, 1045, 0, 0, 0, 2136, 0, 0, 4154, 0, 0, 0, 0, 0,
652, 0, 0, 0, 0, 0, 0, 2464, 0, 3943, 0, 0, 0, 0, 0, 959, 0, 4101, 0, 1479, 0, 831, 3082, 834, 0, 0, 0, 1963, 0, 33, 316, 2098,
235, 4679, 0, 0, 0, 0, 1534, 4602, 0, 0, 2012, 4094, 0, 0, 0, 0, 2847, 1715, 0, 0, 0, 1197, 0, 0, 0, 0, 0, 0, 0, 0, 0, 305,
0, 1021, 0, 4868, 1419, 0, 2590, 1630, 0, 0, 1523, 1253, 761, 1105, 1737, 0, 0, 3994, 0, 307, 0, 0, 0, 0, 2827, 998, 0, 0, 0, 0, 3390, 536,
0, 0, 0, 0, 0, 438, 0, 0, 4717, 0, 4493, 1766, 0, 0, 0, 0, 961, 1033, 0, 0, 0, 0, 0, 749, 227, 1715, 4104, 1944, 0, 0, 0, 0,
0, 0, 4923, 0, 1190, 0, 0, 0, 0, 0, 0, 0, 1127, 4967, 0, 3999, 0, 0, 0, 0, 0, 0, 0, 3763, 0, 0, 0, 2450, 3015, 0, 0, 0,
0, 0, 0, 0, 0, 2178, 0, 0, 0, 3138, 1947, 0, 0, 0, 0, 0, 1442, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 617, 0, 0, 0, 0,
0, 0, 2687, 0, 910, 851, 0, 0, 5041, 0, 0, 0, 0, 0, 0, 0, 1744, 0, 1931, 0, 0, 0, 0, 0, 0, 0, 146, 0, 2120, 0, 0, 555,
295, 2216, 1680, 0, 0, 0, 0, 0, 0, 533, 1264, 1084, 0, 0, 0, 0, 0, 0, 0, 534, 2107, 2292, 829, 0, 0, 0, 241, 419, 3799, 0, 35, 0,
0, 0, 0, 0, 1592, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2013, 0, 1065, 0, 0, 0, 0, 0, 0, 0, 0, 1703,
0, 0, 0, 0, 3919, 0, 0, 0, 0, 0, 0, 3918, 0, 1314, 0, 0, 0, 0, 785, 0, 3489, 0, 0, 0, 1551, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 4545, 136, 2906, 0, 2082, 3908, 0, 0, 126, 502, 0, 3011, 0, 3005, 2780, 0, 405, 0, 0, 3022, 744, 0, 2807, 0, 2861,
0, 0, 0, 1055, 0, 0, 0, 0, 0, 0, 0, 334, 1154, 0, 0, 0, 4184, 3067, 1952, 0, 0, 0, 0, 3558, 2525, 2628, 0, 1052, 0, 2785, 0, 0,
0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 4027, 0, 0, 0, 0, 3516, 0, 0, 0, 0, 0, 522, 2369, 2169, 0, 3285, 0, 0, 0, 3711, 0,
0, 0, 0, 0, 2891, 0, 0, 0, 1540, 1225, 0, 0, 0, 122, 0, 0, 973, 1768, 1750, 0, 3573, 1934, 0, 927, 0, 750, 1952, 0, 548, 0, 781, 1343,
0, 0, 3866, 857, 1003, 4959, 0, 0, 347, 0, 1185, 0, 1323, 2918, 0, 3920, 0, 1862, 0, 0, 0, 0, 0, 898, 0, 1184, 0, 0, 0, 0, 1580, 2245,
762, 0, 5089, 0, 0, 3236, 0, 4253, 4838, 2189, 0, 0, 0, 2312, 2824, 0, 0, 3966, 0, 2764, 0, 2642, 0, 0, 3176, 0, 0, 0, 1937, 0, 0, 1497,
0, 893, 275, 1775, 595, 1509, 0, 3551, 1639, 4083, 290, 115, 0, 0, 2156, 0, 4051, 3352, 0, 0, 1698, 859, 961, 1237, 2570, 3024, 0, 0, 0, 2091, 0, 635,
0, 0, 0, 0, 0, 3752, 0, 0, 0, 0, 3262, 260, 0, 0, 0, 0, 3109, 3297, 0, 1259, 0, 1132, 0, 733, 3472, 0, 2044, 0, 2667, 0, 0, 315,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 4935, 0, 0, 0, 526, 0, 586, 194, 0, 0, 0, 0, 0, 2067, 4078, 3243, 0, 3157,
1851, 4776, 0, 0, 4643, 294, 0, 0, 4578, 0, 3763, 1349, 605, 0, 1630, 0, 0, 0, 0, 3852, 252, 0, 412, 0, 0, 0, 0, 1060, 0, 0, 1068, 2310,
0, 2044, 0, 5042, 1429, 0, 1679, 0, 0, 0, 0, 0, 0, 0, 0, 2003, 0, 0, 0, 3588, 0, 0, 715, 0, 1361, 0, 0, 0, 1983, 0, 638, 0,
0, 1315, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 523, 0, 0, 1936, 2162, 671, 0, 427, 216, 4108, 0, 3513, 1635, 632, 1518, 611, 4195, 1168,
5059, 0, 0, 0, 0, 0, 0, 0, 105, 357, 0, 0, 920, 0, 2848, 0, 0, 0, 0, 2317, 0, 0, 3903, 3840, 0, 0, 0, 0, 4068, 0, 0, 0,
2912, 4941, 0, 0, 578, 1170, 0, 64, 0, 0, 1291, 0, 0, 0, 908, 0, 0, 0, 1118, 2737, 0, 0, 0, 2641, 512, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 4024, 1845, 0, 2291, 0, 1876, 0, 1745, 1132, 0, 0, 2537, 0, 1000, 519, 2026, 0, 3920, 0, 4037, 0, 3275, 0, 0, 0, 919,
0, 0, 0, 588, 0, 0, 0, 1404, 3350, 0, 0, 0, 0, 0, 4650, 0, 0, 1016, 0, 0, 586, 4137, 0, 1283, 0, 0, 0, 2547, 0, 0, 3614, 0,
0, 0, 0, 0, 0, 735, 1805, 0, 0, 0, 4180, 0, 0, 0, 3635, 0, 0, 0, 0, 0, 0, 0, 2661, 0, 0, 0, 681, 0, 0, 0, 34, 0,
0, 0, 1422, 0, 1882, 0, 0, 0, 233, 0, 0, 0, 0, 0, 167, 0, 3298, 0, 0, 0, 0, 4114, 523, 951, 405, 2961, 0, 0, 614, 443, 0, 780,
0, 0, 1525, 0, 1881, 428, 0, 0, 2315, 5057, 0, 0, 0, 3737, 0, 209, 0, 0, 426, 1827, 0, 0, 0, 1334, 0, 0, 0, 0, 0, 182, 3585, 0,
195, 0, 684, 1590, 0, 4127, 1049, 0, 0, 0, 0, 1246, 4585, 0, 0, 1478, 0, 0, 3137, 297, 0, 0, 0, 1558, 3435, 0, 0, 0, 0, 0, 1607, 0,
0, 0, 1622, 0, 4898, 134, 0, 0, 0, 4573, 0, 0, 0, 0, 0, 3052, 3748, 320, 2186, 3194, 0, 734, 1474, 163, 1705, 0, 0, 1954, 0, 0, 2882, 3153,
0, 0, 0, 0, 0, 1169, 4981, 0, 0, 2277, 3719, 0, 0, 0, 526, 212, 1352, 0, 0, 435, 0, 0, 0, 0, 2332, 0, 0, 0, 0, 762, 131, 0,
0, 3673, 0, 0, 0, 4709, 0, 0, 530, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, 4047, 0, 1088, 0, 0, 0, 0, 0, 0, 0,
269, 0, 2226, 0, 606, 0, 0, 3583, 0, 0, 4042, 0, 0, 0, 0, 0, 0, 3220, 0, 1535, 0, 0, 0, 2917, 0, 290, 1873, 0, 0, 0, 388, 3031,
4014, 0, 0, 0, 0, 0, 825, 0, 0, 2952, 3782, 4842, 0, 0, 0, 0, 1272, 978, 0, 0, 0, 0, 0, 0, 0, 574, 2662, 0, 165, 0, 2100, 0,
0, 0, 0, 0, 0, 2537, 0, 0, 2524, 0, 2604, 0, 678, 0, 2045, 0, 1943, 0, 3604, 1663, 745, 3807, 224, 401, 0, 0, 0, 0, 0, 0, 3406, 1127,
0, 1058, 0, 0, 4883, 2302, 0, 0, 2665, 0, 0, 1641, 1811, 4687, 1033, 0, 0, 0, 0, 1149, 2423, 0, 495, 0, 688, 0, 3544, 0, 0, 0, 1627, 0,
0, 0, 511, 0, 0, 0, 0, 0, 0, 765, 0, 4156, 0, 1758, 0, 0, 0, 0, 0, 0, 2057, 0, 3379, 19, 2744, 0, 0, 0, 0, 0, 1316, 409,
4987, 1642, 0, 0, 2761, 0, 0, 0, 0, 1289, 0, 2195, 3143, 0, 2384, 313, 1243, 0, 0, 0, 1050, 1302, 548, 0, 0, 0, 0, 2046, 0, 0, 0, 0,
0, 0, 2989, 0, 0, 0, 1511, 1461, 0, 0, 2201, 0, 838, 0, 0, 0, 1579, 0, 0, 0, 787, 1722, 1415, 0, 0, 0, 1528, 919, 0, 0, 516, 0,
0, 2349, 320, 3184, 0, 0, 0, 0, 922, 234, 0, 0, 4996, 0, 1626, 129, 3063, 2254, 0, 0, 1573, 0, 376, 0, 0, 0, 0, 0, 27, 0, 0, 0,
1462, 0, 203, 0, 1072, 0, 1597, 0, 0, 531, 0, 0, 3903, 0, 4587, 1156, 0, 0, 0, 0, 0, 0, 0, 0, 4111, 1475, 0, 0, 0, 0, 0, 518,
0, 0, 0, 0, 0, 0, 1172, 0, 4621, 0, 0, 0, 0, 0, 0, 4545, 0, 1435, 0, 3053, 0, 765, 0, 1088, 2966, 525, 0, 0, 0, 0, 0, 1301,
0, 0, 0, 0, 1449, 1501, 1464, 0, 0, 4367, 0, 0, 1180, 2207, 0, 0, 3265, 0, 0, 919, 0, 0, 0, 0, 0, 0, 0, 2215, 3413, 0, 0, 0,
1149, 0, 3586, 0, 1301, 567, 0, 0, 0, 0, 0, 0, 0, 365, 0, 0, 0, 1326, 1071, 0, 0, 1429, 0, 0, 4015, 2036, 1105, 0, 0, 0, 478, 1296,
1311, 4729, 0, 0, 312, 0, 0, 0, 0, 0, 4283, 0, 1616, 0, 4708, 656, 0, 1669, 162, 3002, 3028, 0, 0, 1518, 2042, 705, 0, 0, 2602, 0, 0, 0,
1761, 0, 0, 4898, 1480, 3168, 0, 1498, 0, 1864, 0, 0, 0, 4471, 0, 79, 0, 0, 2062, 2834, 0, 0, 581, 3053, 0, 0, 3624, 0, 0, 3854, 0, 0,
0, 1315, 627, 0, 0, 4163, 0, 534, 1307, 2121, 0, 0, 805, 1726, 0, 0, 0, 0, 0, 1132, 0, 4104, 0, 0, 1272, 0, 0, 197, 0, 1224, 0, 0,
0, 0, 0, 0, 0, 3947, 0, 4636, 0, 0, 0, 0, 0, 4315, 376, 0, 723, 0, 0, 0, 0, 0, 617, 0, 0, 3745, 0, 1219, 3585, 0, 0, 0,
0, 0, 0, 0, 814, 4927, 4654, 4721, 0, 0, 2679, 453, 0, 256, 180, 0, 0, 0, 3781, 0, 0, 0, 0, 3223, 45, 0, 0, 0, 0, 876, 0, 334,
0, 2352, 2528, 2534, 0, 1397, 0, 822, 0, 854, 0, 1328, 0, 0, 1946, 365, 732, 1608, 0, 0, 0, 553, 2825, 2838, 1965, 0, 0, 0, 251, 469, 3114, 1427,
2246, 0, 699, 0, 0, 0, 1382, 0, 0, 0, 0, 0, 0, 2199, 690, 0, 3612, 0, 0, 432, 0, 558, 926, 0, 58, 2450, 0, 2196, 0, 3898, 3456, 0,
0, 0, 0, 1609, 0, 4896, 4405, 757, 0, 3653, 0, 0, 96, 0, 0, 1067, 1459, 2827, 0, 4188, 0, 0, 1206, 0, 0, 2311, 27, 0, 0, 0, 0, 2637,
0, 0, 2451, 0, 0, 0, 0, 0, 0, 962, 0, 1320, 0, 79, 0, 0, 823, 4143, 249, 0, 1413, 0, 38, 2359, 0, 0, 0, 747, 1177, 1563, 0, 0,
0, 0, 0, 0, 0, 633, 1098, 1513, 0, 0, 0, 0, 0, 2977, 725, 99, 3804, 758, 0, 0, 3389, 0, 979, 0, 0, 3761, 866, 5, 0, 1812, 0, 1079,
952, 1757, 3515, 4653, 0, 1339, 0, 4605, 0, 0, 4466, 4266, 0, 1088, 4487, 0, 0, 0, 0, 2714, 0, 44, 0, 0, 0, 0, 1568, 3865, 3655, 0, 2143, 476,
0, 2713, 1730, 118, 0, 4590, 0, 0, 0, 0, 390, 0, 1267, 0, 0, 0, 1138, 1285, 3533, 3928, 3874, 3491, 3941, 0, 1018, 0, 382, 0, 3893, 1198, 1627, 0,
0, 1047, 0, 0, 0, 0, 0, 0, 0, 27, 1085, 0, 0, 0, 2294, 3386, 0, 0, 0, 695, 2610, 1474, 876, 0, 0, 2004, 0, 0, 1739, 3777, 1274, 1526,
0, 0, 0, 3829, 1335, 0, 0, 0, 0, 0, 0, 4604, 0, 0, 0, 0, 0, 2375, 0, 0, 0, 0, 0, 3835, 0, 745, 3854, 3723, 602, 0, 439, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1853, 0, 0, 0, 2104, 4081, 1038, 4109, 0, 3838, 776, 0, 4064, 1222, 0, 0,
0, 4759, 1485, 2075, 0, 4615, 0, 0, 4393, 4663, 2297, 0, 4400, 767, 0, 2644, 0, 2158, 416, 358, 1123, 0, 3376, 2878, 857, 0, 0, 0, 0, 3025, 3314, 0,
0, 0, 0, 369, 1878, 0, 4297, 1424, 2783, 0, 0, 1993, 0, 0, 1089, 0, 0, 0, 2040, 0, 0, 0, 0, 505, 3939, 0, 0, 0, 1445, 7, 328, 0,
1366, 0, 117, 2074, 917, 0, 0, 0, 1058, 0, 0, 0, 260, 4469, 0, 739, 0, 0, 0, 242, 0, 3779, 0, 0, 3117, 1432, 0, 0, 0, 1274, 4079, 1656,
791, 0, 0, 0, 623, 0, 2816, 0, 0, 624, 0, 148, 545, 0, 0, 0, 0, 0, 0, 0, 0, 1104, 1772, 1358, 0, 0, 0, 0, 4168, 3799, 3833, 105,
0, 4436, 2667, 0, 1843, 0, 0, 0, 0, 0, 0, 0, 4940, 0, 0, 0, 0, 2404, 444, 0, 885, 3650, 4010, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 284, 0, 0, 704, 811, 0, 0, 1213, 0, 0, 0, 0, 897, 0, 3313, 0, 0, 906, 3358, 390, 110, 0, 0, 0, 915, 1803, 2653, 3402, 0,
0, 2283, 3155, 162, 0, 4361, 0, 0, 0, 1152, 1349, 779, 3600, 900, 1454, 2107, 2506, 0, 2510, 855, 474, 0, 1452, 1407, 628, 1782, 0, 0, 2019, 0, 0, 1105,
885, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1238, 1270, 1690, 4678, 2145, 0, 3584, 0, 3382, 0, 0, 1851, 814, 829, 1314, 0, 28, 570, 0, 0, 744, 162,
0, 0, 0, 802, 0, 0, 101, 4842, 0, 0, 0, 0, 2201, 578, 0, 988, 0, 0, 3777, 2924, 0, 0, 1754, 3382, 4195, 0, 3455, 824, 0, 0, 2007, 816,
236, 3189, 0, 0, 445, 182, 670, 3851, 0, 0, 0, 0, 0, 0, 0, 3236, 1685, 1659, 913, 627, 6, 0, 0, 0, 0, 0, 0, 3311, 0, 2226, 0, 1774,
5074, 0, 0, 0, 0, 0, 1748, 1691, 0, 0, 4213, 892, 0, 2152, 0, 158, 1147, 0, 459, 1272, 0, 0, 3962, 0, 1434, 303, 0, 1549, 0, 74, 0, 0,
0, 0, 0, 1681, 0, 4552, 0, 0, 0, 0, 0, 0, 0, 0, 1720, 0, 0, 1438, 179, 0, 4087, 997, 0, 0, 3727, 2113, 1043, 0, 1008, 0, 0, 0,
0, 0, 0, 262, 0, 1502, 0, 0, 3731, 0, 2303, 0, 0, 0, 0, 868, 605, 2444, 2987, 0, 1442, 0, 3972, 0, 226, 622, 890, 482, 1073, 1732, 0, 0,
0, 0, 0, 4839, 0, 2208, 3256, 382, 2642, 0, 0, 4064, 0, 165, 0, 0, 1196, 2616, 3697, 0, 0, 0, 0, 3306, 0, 1801, 0, 0, 0, 0, 924, 2621,
0, 4688, 0, 0, 361, 0, 70, 4819, 4711, 0, 0, 0, 1154, 2660, 4482, 296, 2080, 0, 0, 0, 0, 1746, 594, 3712, 0, 0, 0, 0, 3668, 1035, 4043, 1569,
75, 4445, 0, 4697, 0, 257, 0, 0, 0, 530, 0, 755, 0, 2177, 0, 0, 451, 1747, 1196, 0, 3921, 2483, 0, 2903, 1849, 643, 0, 4044, 0, 1673, 0, 0,
0, 0, 0, 4826, 4496, 0, 0, 0, 0, 589, 0, 0, 1269, 0, 0, 0, 0, 2021, 0, 1762, 1908, 3862, 929, 1651, 0, 0, 420, 0, 0, 1714, 0, 1330,
0, 0, 0, 0, 2255, 0, 1757, 0, 1029, 0, 0, 3256, 0, 0, 0, 0, 1334, 0, 1346, 1002, 0, 952, 1631, 1549, 3407, 773, 1015, 0, 1664, 825, 941, 0,
1774, 0, 0, 690, 0, 0, 0, 723, 0, 0, 0, 517, 3904, 680, 656, 0, 0, 20, 0, 3592, 225, 750, 0, 154, 2959, 0, 2211, 3384, 0, 0, 3041, 1241,
0, 0, 0, 0, 0, 0, 1037, 0, 0, 751, 0, 0, 0, 0, 873, 1033, 1790, 198, 0, 1516, 1750, 3752, 0, 282, 172, 0, 0, 0, 3333, 1015, 0, 388,
4598, 0, 4586, 0, 3060, 59, 2835, 3530, 1595, 0, 1586, 0, 266, 2212, 63, 3124, 1798, 0, 0, 259, 0, 0, 0, 1991, 321, 0, 1334, 763, 347, 0, 479, 0,
0, 0, 0, 3298, 0, 0, 0, 0, 0, 4240, 1827, 0, 0, 0, 1413, 1656, 1836, 0, 0, 1337, 1130, 0, 3703, 1825, 0, 3687, 0, 1710, 0, 543, 0, 3443,
93, 2169, 0, 2523, 1579, 0, 0, 2609, 0, 2027, 2390, 0, 0, 2496, 0, 0, 0, 4052, 0, 0, 154, 78, 0, 0, 2518, 3070, 1731, 0, 0, 2256, 1372, 2683,
1074, 72, 864, 0, 0, 0, 0, 1743, 1282, 0, 0, 0, 0, 527, 0, 0, 100, 1797, 2604, 1508, 0, 0, 0, 2043, 0, 0, 3679, 2695, 0, 0, 0, 1648,
0, 117, 0, 2286, 876, 0, 0, 0, 0, 4093, 0, 0, 0, 3956, 0, 1941, 2445, 3159, 356, 0, 1942, 0, 0, 3781, 480, 0, 0, 986, 3449, 1528, 1358, 3104,
0, 0, 0, 322, 556, 3519, 1986, 0, 0, 0, 0, 0, 1011, 2053, 0, 0, 1247, 0, 0, 0, 0, 0, 1390, 638, 0, 1021, 1910, 0, 2553, 0, 442, 2002,
1253, 0, 0, 1921, 558, 0, 1399, 219, 1850, 0, 2126, 3638, 0, 0, 0, 0, 0, 600, 0, 0, 0, 0, 1784, 715, 0, 1622, 0, 619, 0, 0, 0, 0,
0, 0, 676, 1290, 289, 115, 198, 0, 67, 3869, 4497, 0, 0, 3958, 0, 0, 3801, 1909, 3053, 1929, 0, 0, 0, 1181, 0, 3039, 174, 4101, 0, 4187, 0, 0,
1815, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 291, 0, 0, 201, 928, 1451, 3063, 0, 2909, 736, 0, 0, 0, 0, 193, 673, 0, 3843,
0, 0, 0, 0, 0, 0, 645, 936, 4793, 1926, 0, 0, 0, 0, 1339, 0, 1042, 0, 2823, 0, 3185, 2065, 4013, 3793, 242, 183, 3343, 1603, 2083, 1143, 1284, 0,
4922, 3430, 3614, 212, 667, 0, 0, 0, 1565, 0, 4660, 0, 979, 4016, 795, 0, 320, 7, 805, 0, 0, 1923, 1403, 0, 865, 0, 1087, 539, 0, 3242, 0, 0,
1412, 0, 0, 0, 0, 1347, 464, 396, 0, 0, 3899, 0, 0, 7, 0, 0, 3031, 0, 0, 1317, 2788, 2268, 3913, 0, 447, 0, 0, 3307, 0, 0, 0, 0,
0, 4130, 4123, 159, 0, 4810, 0, 0, 416, 2236, 0, 0, 1028, 0, 0, 0, 1970, 1103, 0, 1950, 0, 0, 0, 404, 0, 0, 0, 0, 0, 368, 0, 771,
35, 0, 1919, 0, 1009, 0, 464, 1128, 333, 0, 1507, 220, 0, 0, 0, 1771, 4074, 1521, 1930, 0, 1, 1509, 0, 0, 0, 397, 588, 1660, 1151, 2283, 0, 0,
0, 2131, 0, 3755, 1460, 1970, 0, 0, 0, 0, 0, 0, 0, 1884, 2926, 1103, 1328, 1911, 0, 0, 2914, 417, 689, 3907, 1629, 0, 464, 2921, 0, 0, 1200, 0,
0, 0, 0, 2875, 0, 0, 0, 2521, 2079, 600, 0, 110, 0, 0, 1639, 0, 0, 3467, 750, 1383, 2616, 0, 419, 0, 1312, 0, 0, 3524, 3983, 0, 0, 0,
2739, 3722, 2248, 0, 879, 0, 1145, 0, 1415, 0, 0, 963, 0, 0, 0, 0, 0, 2055, 3857, 3587, 0, 0, 2066, 721, 4124, 0, 4095, 1230, 0, 0, 2603, 0,
0, 0, 647, 0, 4350, 700, 507, 0, 1638, 0, 5023, 0, 0, 0, 0, 0, 518, 50, 1788, 1304, 0, 205, 3732, 0, 0, 1913, 0, 0, 1747, 3574, 258, 0,
0, 0, 0, 0, 586, 0, 1310, 2572, 0, 0, 0, 0, 597, 0, 832, 0, 0, 1848, 2906, 3944, 986, 2330, 0, 1715, 0, 0, 2668, 3448, 1192, 0, 0, 3960,
423, 4698, 1782, 1501, 0, 0, 1157, 0, 0, 0, 0, 0, 0, 789, 878, 0, 104, 1592, 1340, 0, 0, 575, 2508, 0, 0, 1035, 0, 2222, 2563, 0, 0, 937,
0, 2293, 0, 0, 231, 942, 2499, 474, 3392, 0, 0, 2319, 0, 2968, 0, 0, 0, 1787, 2081, 0, 450, 2009, 125, 1555, 0, 0, 0, 0, 0, 2529, 955, 3982,
370, 0, 0, 0, 2885, 3363, 2689, 0, 1830, 0, 0, 5032, 0, 0, 0, 0, 274, 0, 1748, 482, 1113, 11, 3428, 885, 0, 3706, 844, 1287, 0, 0, 96, 3318,
3127, 0, 290, 0, 2089, 0, 0, 1268, 0, 0, 0, 0, 0, 279, 2178, 0, 0, 1882, 0, 0, 3255, 3328, 1893, 0, 0, 170, 2122, 907, 1307, 1042, 1776, 2044,
0, 0, 0, 4327, 1278, 1706, 3, 1715, 339, 4666, 1136, 0, 732, 4523, 1047, 216, 0, 0, 0, 0, 1880, 1420, 3132, 2939, 1222, 0, 0, 321, 0, 318, 84, 3420,
0, 1391, 0, 4410, 0, 0, 4112, 4526, 1385, 0, 158, 86, 3927, 1661, 969, 0, 0, 0, 1232, 1366, 4134, 0, 877, 0, 0, 99, 674, 1784, 0, 0, 0, 0,
1623, 0, 1774, 0, 0, 0, 0, 0, 0, 0, 1366, 0, 0, 0, 377, 657, 692, 0, 0, 0, 1907, 2239, 365, 170, 0, 0, 0, 0, 2134, 2251, 2117, 1532,
1242, 0, 1518, 0, 2715, 0, 0, 0, 0, 0, 1421, 748, 0, 0, 0, 119, 0, 3192, 0, 0, 0, 898, 2221, 3837, 0, 1850, 0, 1420, 3573, 939, 0, 2406,
4053, 2861, 0, 0, 958, 0, 0, 1734, 1999, 10, 4095, 0, 0, 0, 0, 0, 0, 735, 3200, 1262, 2733, 0, 1629, 1465, 0, 1126, 0, 0, 4042, 3701, 1614, 3195,
3601, 261, 1081, 3018, 4431, 0, 3687, 0, 463, 0, 0, 0, 0, 211, 0, 0, 0, 1845, 1416, 0, 1902, 0, 0, 1759, 2813, 101, 261, 2218, 3195, 1354, 0, 868,
0, 1186, 2768, 1220, 0, 0, 0, 0, 0, 641, 3580, 0, 543, 182, 0, 0, 0, 0, 2234, 2076, 75, 0, 869, 0, 0, 3068, 0, 2099, 0, 0, 1747, 0,
0, 0, 1931, 735, 293, 1423, 1714, 2306, 1747, 0, 2478, 4798, 0, 0, 0, 0, 0, 0, 0, 472, 0, 0, 2967, 0, 954, 524, 2202, 0, 0, 639, 0, 0,
3002, 0, 2167, 0, 0, 0, 0, 642, 662, 1170, 4000, 0, 296, 0, 4830, 1879, 3790, 3763, 0, 3045, 0, 0, 0, 1964, 746, 487, 422, 0, 1466, 0, 4171, 1473,
826, 0, 0, 0, 1489, 0, 3835, 0, 394, 2059, 0, 0, 0, 178, 0, 0, 88, 1501, 21, 1093, 0, 0, 3594, 1226, 999, 46, 2620, 0, 4196, 0, 0, 0,
0, 3591, 2056, 2815, 0, 0, 0, 0, 1268, 0, 0, 0, 0, 3932, 176, 0, 3491, 1487, 626, 3800, 0, 1017, 3361, 1074, 0, 2749, 0, 0, 3239, 1122, 952, 122,
47, 196, 0, 0, 0, 308, 929, 0, 4913, 997, 1166, 1063, 0, 2318, 87, 0, 0, 793, 3861, 1472, 0, 0, 112, 746, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3559, 0, 571, 2099, 716, 921, 0, 0, 0, 1633, 1642, 0, 761, 211, 0, 0, 394, 301, 0, 3940, 926, 0, 325, 1708, 1552, 2796, 1202, 3744, 237, 1880, 0,
2015, 0, 1998, 3960, 0, 0, 0, 0, 459, 4419, 4463, 0, 5038, 3072, 0, 0, 0, 1976, 0, 2184, 188, 217, 2117, 3513, 2334, 802, 3437, 0, 566, 3375, 672, 0,
0, 976, 1497, 5071, 1022, 0, 1740, 284, 515, 0, 1556, 0, 0, 1735, 605, 0, 1107, 3042, 1090, 0, 0, 0, 0, 0, 615, 0, 1504, 0, 1539, 0, 0, 3988,
1420, 0, 0, 0, 2039, 95, 1637, 195, 1862, 1375, 1142, 0, 0, 0, 0, 4550, 1948, 3805, 0, 242, 3649, 1681, 0, 0, 877, 1782, 1453, 1514, 0, 3056, 1964, 0,
0, 0, 0, 0, 2501, 657, 3003, 0, 0, 0, 0, 1985, 749, 0, 0, 0, 0, 0, 1137, 0, 0, 641, 1094, 2141, 0, 4004, 1042, 437, 0, 2200, 1239, 3848,
1174, 1078, 692, 0, 75, 1129, 979, 0, 0, 0, 2110, 0, 0, 972, 2374, 534, 337, 1011, 0, 1301, 22, 0, 0, 0, 3518, 3747, 0, 1675, 3868, 1620, 0, 3313,
0, 0, 0, 1660, 0, 234, 1402, 1227, 0, 0, 362, 0, 0, 1468, 275, 1168, 3375, 0, 0, 169, 2648, 0, 0, 0, 534, 0, 2393, 0, 1708, 0, 0, 1543,
0, 4701, 0, 0, 0, 0, 4903, 2139, 1404, 0, 0, 405, 0, 1156, 0, 0, 4017, 849, 4082, 3179, 2992, 0, 0, 790, 0, 0, 0, 240, 0, 1590, 3946, 0,
0, 0, 336, 3043, 0, 0, 0, 0, 0, 1281, 264, 4375, 3148, 0, 2265, 447, 0, 901, 0, 0, 1072, 0, 0, 4082, 0, 580, 2673, 1521, 3817, 0, 0, 0,
0, 2321, 0, 4928, 4437, 352, 0, 0, 0, 0, 2143, 0, 2490, 0, 0, 0, 2124, 0, 4099, 0, 2127, 1834, 1354, 4081, 0, 0, 718, 1699, 0, 3752, 0, 3418,
0, 2083, 0, 0, 398, 484, 1027, 1821, 0, 0, 2180, 948, 0, 0, 215, 2902, 0, 0, 0, 0, 89, 1371, 0, 3211, 0, 0, 0, 0, 0, 3291, 3936, 0,
0, 0, 0, 0, 475, 1286, 1766, 0, 989, 408, 1409, 0, 5020, 1042, 115, 0, 655, 0, 1690, 0, 2957, 3665, 1797, 260, 0, 0, 0, 0, 1460, 0, 0, 2545,
0, 1532, 675, 455, 1994, 0, 1380, 0, 3976, 0, 2734, 0, 4745, 0, 96, 0, 4035, 0, 1079, 0, 3927, 2264, 808, 408, 1743, 1647, 437, 103, 0, 0, 0, 91,
132, 617, 0, 0, 0, 1837, 401, 1112, 3942, 4986, 4593, 2055, 498, 1499, 4045, 0, 44, 2086, 1969, 0, 0, 0, 3659, 1685, 1853, 715, 0, 0, 0, 0, 0, 3729,
0, 5046, 327, 0, 0, 292, 0, 2055, 0, 2336, 0, 0, 0, 4697, 1519, 2176, 2033, 0, 3103, 0, 968, 507, 3254, 0, 395, 0, 0, 713, 0, 0, 0, 0,
0, 2054, 0, 0, 0, 878, 0, 0, 4365, 0, 0, 0, 0, 4590, 373, 3773, 443, 1615, 188, 1073, 0, 2244, 2942, 3028, 393, 0, 1887, 3154, 1267, 147, 0, 732,
1049, 0, 3695, 4019, 0, 0, 599, 0, 0, 0, 197, 0, 692, 0, 130, 0, 1294, 3746, 0, 0, 1804, 456, 203, 560, 3839, 0, 0, 0, 1111, 0, 296, 1895,
178, 0, 0, 0, 1106, 0, 1851, 0, 975, 261, 710, 1112, 3723, 1196, 1422, 510, 0, 0, 0, 1403, 211, 1343, 0, 0, 811, 2599, 0, 389, 113, 0, 2006, 0,
0, 3643, 3929, 0, 3965, 1343, 3381, 0, 0, 1413, 1206, 589, 0, 0, 0, 3972, 3570, 0, 0, 1524, 0, 0, 2100, 541, 0, 1118, 4012, 1427, 548, 0, 0, 0,
1265, 1330, 157, 0, 1763, 877, 3213, 737, 0, 0, 0, 0, 1473, 0, 3071, 0, 980, 3603, 0, 3076, 314, 0, 0, 0, 0, 1265, 0, 1527, 3779, 0, 1568, 3960,
1102, 3205, 2962, 1754, 0, 0, 0, 0, 0, 0, 0, 907, 0, 0, 3996, 0, 0, 2924, 0, 923, 181, 0, 1236, 1315, 1287, 0, 3548, 2919, 1517, 0, 1968, 0,
0, 3345, 0, 0, 0, 0, 25, 4591, 0, 0, 2573, 0, 0, 628, 4843, 472, 0, 0, 0, 0, 0, 0, 1257, 0, 0, 945, 1365, 0, 191, 2323, 1969, 150,
441, 216, 961, 3104, 748, 4360, 0, 0, 0, 0, 0, 0, 0, 939, 415, 2886, 1569, 0, 505, 0, 218, 0, 0, 0, 0, 0, 1132, 917, 0, 3405, 0, 0,
4143, 168, 881, 0, 874, 0, 873, 0, 4043, 0, 0, 600, 0, 4814, 0, 0, 0, 0, 2460, 607, 787, 1367, 0, 298, 0, 0, 0, 3058, 636, 1333, 1958, 2745,
1315, 1191, 0, 0, 0, 0, 2391, 0, 0, 1515, 4740, 0, 0, 0, 0, 2026, 0, 0, 0, 0, 361, 487, 0, 0, 1404, 0, 0, 0, 92, 979, 2156, 0,
0, 301, 3904, 0, 1732, 831, 0, 0, 0, 627, 39, 0, 0, 2689, 591, 853, 0, 1870, 3330, 0, 1056, 0, 851, 4167, 0, 0, 0, 2671, 0, 4153, 4094, 583,
0, 4747, 0, 0, 0, 4900, 415, 0, 0, 532, 1484, 0, 4651, 567, 3660, 0, 0, 1196, 3386, 1149, 757, 0, 3577, 58, 3160, 0, 152, 4120, 1014, 1857, 0, 0,
0, 163, 0, 2362, 0, 3781, 24, 0, 0, 2006, 0, 0, 0, 1587, 2951, 0, 0, 0, 0, 565, 0, 2257, 1844, 0, 0, 0, 3895, 4008, 0, 2090, 189, 0,
0, 2057, 0, 0, 2238, 0, 4944, 1703, 0, 2475, 4900, 33, 976, 4866, 0, 0, 2126, 0, 0, 0, 0, 0, 699, 340, 0, 0, 3468, 0, 2560, 0, 3039, 345,
0, 1740, 773, 3391, 0, 0, 3826, 705, 0, 0, 0, 1971, 2, 1912, 0, 0, 1407, 535, 1182, 1582, 0, 1980, 622, 1096, 1242, 2743, 0, 3728, 0, 0, 0, 862,
0, 0, 1727, 0, 328, 0, 0, 1617, 0, 0, 823, 4792, 5030, 2050, 0, 707, 1890, 725, 1525, 1353, 391, 2963, 1533, 3669, 539, 683, 0, 3722, 0, 0, 0, 0,
0, 0, 0, 3511, 0, 0, 0, 0, 2100, 0, 18, 1810, 928, 2269, 0, 0, 1210, 3635, 3621, 3379, 235, 2850, 0, 0, 0, 1244, 0, 0, 0, 202, 31, 1214,
3245, 0, 0, 2197, 1572, 0, 0, 0, 0, 1143, 0, 0, 2200, 1564, 531, 1429, 3943, 0, 0, 3683, 0, 1623, 0, 1689, 0, 2290, 379, 646, 0, 0, 0, 0,
0, 5022, 0, 4544, 0, 0, 413, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1334, 0, 0, 356, 488, 811, 0, 821, 0, 0, 1957, 0, 0, 0, 0,
918, 865, 0, 1857, 1476, 1721, 2331, 1537, 194, 0, 1730, 1299, 4135, 1799, 364, 733, 894, 0, 0, 0, 0, 1563, 863, 0, 2492, 260, 0, 3471, 294, 369, 1786, 0,
780, 0, 1696, 1722, 5032, 0, 0, 719, 0, 0, 1676, 0, 1789, 0, 0, 0, 3652, 2809, 3063, 2078, 1703, 0, 439, 703, 269, 1573, 0, 3936, 835, 478, 853, 0,
0, 4900, 0, 0, 4812, 1462, 2223, 0, 0, 0, 0, 37, 0, 0, 0, 1338, 0, 3400, 2005, 591, 0, 1621, 0, 1618, 0, 941, 0, 0, 1463, 2648, 0, 1725,
0, 0, 576, 0, 1342, 0, 0, 0, 853, 4376, 0, 4452, 4034, 4375, 1017, 0, 0, 0, 0, 4124, 0, 158, 1095, 0, 2774, 1117, 0, 238, 0, 0, 193, 1669,
0, 4862, 1957, 3924, 375, 1158, 1086, 1989, 0, 3487, 0, 1993, 0, 608, 0, 365, 1883, 1629, 0, 1053, 3724, 2544, 0, 0, 0, 2303, 0, 1179, 593, 0, 1764, 3298,
4583, 2187, 1176, 0, 0, 0, 0, 494, 0, 2241, 0, 0, 0, 0, 4076, 11, 0, 1467, 2817, 1379, 226, 1045, 0, 0, 2258, 101, 3834, 0, 0, 0, 1037, 1187,
0, 4541, 58, 912, 1440, 1503, 1435, 0, 1245, 614, 3526, 0, 0, 0, 1812, 0, 1939, 95, 0, 0, 4012, 20, 0, 3858, 0, 1020, 1265, 0, 3873, 0, 792, 1955,
0, 1166, 1632, 0, 5016, 1108, 0, 1152, 14, 0, 0, 1704, 0, 1403, 0, 338, 1414, 4035, 127, 0, 843, 145, 2295, 0, 3395, 0, 3710, 1027, 3566, 266, 1103, 3282,
3819, 4322, 3707, 38, 0, 934, 1992, 0, 0, 2232, 1464, 1845, 0, 1977, 0, 782, 0, 0, 0, 1259, 1700, 0, 812, 0, 1062, 1125, 0, 1619, 0, 1548, 1229, 0,
0, 0, 0, 0, 845, 0, 2085, 860, 621, 0, 4891, 0, 0, 1941, 0, 0, 1530, 0, 3151, 0, 3815, 0, 0, 0, 2786, 1824, 3905, 3041, 0, 258, 1168, 0,
0, 831, 0, 0, 0, 0, 966, 0, 0, 1622, 0, 0, 0, 0, 0, 0, 524, 3063, 497, 1989, 1553, 802, 0, 2884, 2795, 603, 0, 1235, 827, 0, 0, 0,
2280, 0, 642, 3111, 0, 0, 0, 0, 0, 0, 0, 0, 3266, 820, 3458, 0, 608, 1351, 0, 1625, 0, 0, 0, 135, 1541, 0, 1348, 0, 0, 1624, 2415, 942,
0, 0, 2173, 2140, 258, 354, 2123, 66, 71, 0, 1525, 0, 0, 0, 0, 2253, 0, 0, 1438, 0, 2083, 949, 0, 0, 3961, 106, 3750, 3482, 0, 1487, 0, 0,
0, 0, 202, 0, 0, 0, 1522, 0, 4362, 0, 1242, 0, 0, 0, 665, 0, 3280, 0, 0, 937, 2393, 0, 495, 3233, 0, 1059, 15, 1724, 135, 1060, 1317, 2253,
0, 519, 0, 0, 4666, 0, 0, 0, 2208, 0, 5057, 2081, 621, 0, 0, 0, 3412, 81, 350, 0, 0, 1082, 1844, 0, 179, 781, 0, 2197, 0, 3815, 1441, 0,
3354, 0, 1991, 599, 0, 2852, 0, 0, 0, 0, 0, 0, 0, 4568, 1567, 0, 0, 1503, 0, 0, 3184, 0, 0, 0, 3652, 0, 0, 0, 0, 0, 0, 443,
0, 35, 491, 2164, 0, 0, 0, 0, 0, 1495, 0, 4721, 4494, 0, 222, 1801, 0, 1500, 0, 174, 0, 0, 1835, 0, 1560, 3486, 3881, 0, 114, 0, 1151, 1172,
3465, 0, 4420, 0, 0, 3638, 790, 684, 0, 750, 3350, 4442, 0, 1042, 0, 0, 0, 2247, 3438, 4001, 0, 4141, 2614, 0, 4171, 4128, 0, 0, 2689, 0, 1574, 1309,
3915, 134, 2284, 955, 3025, 0, 0, 0, 0, 2255, 1951, 1444, 0, 937, 3399, 4603, 712, 0, 1653, 0, 0, 2542, 1586, 0, 0, 0, 0, 0, 525, 3832, 730, 105,
1526, 0, 4562, 2213, 2263, 0, 0, 606, 1937, 0, 1145, 925, 0, 1174, 340, 2140, 3645, 245, 0, 736, 3598, 318, 0, 772, 960, 1951, 1144, 1345, 364, 765, 0, 2882,
0, 0, 1179, 2457, 0, 985, 0, 4697, 0, 0, 3173, 664, 984, 618, 0, 0, 116, 0, 67, 984, 2948, 0, 359, 0, 0, 3472, 700, 1317, 0, 204, 0, 0,
4727, 1266, 0, 0, 0, 4101, 2289, 4742, 1116, 0, 4671, 0, 657, 4131, 0, 0, 0, 1828, 926, 0, 2654, 2439, 0, 0, 1446, 734, 0, 82, 848, 2400, 0, 0,
763, 1731, 2963, 0, 4663, 169, 756, 1454, 1694, 1053, 1986, 0, 3583, 284, 992, 2934, 416, 0, 1172, 0, 2967, 0, 282, 0, 0, 0, 855, 169, 3869, 1485, 1374, 0,
97, 0, 1968, 0, 2623, 4668, 3960, 0, 1654, 1273, 2516, 3052, 0, 1320, 4423, 0, 1294, 1705, 0, 1055, 0, 1072, 0, 1211, 0, 1568, 0, 2105, 0, 1733, 0, 2187,
0, 0, 0, 1709, 1492, 4834, 544, 0, 0, 0, 4787, 0, 262, 0, 454, 1063, 0, 3134, 0, 881, 610, 0, 896, 0, 3, 3388, 238, 1207, 0, 0, 0, 709,
3317, 393, 0, 0, 839, 0, 0, 0, 1779, 0, 0, 0, 553, 3933, 0, 0, 0, 0, 0, 0, 2210, 0, 0, 0, 0, 0, 661, 0, 237, 0, 1026, 0,
0, 1437, 0, 0, 0, 921, 0, 0, 4619, 0, 2524, 0, 0, 0, 0, 711, 0, 1998, 0, 0, 1225, 1071, 0, 0, 0, 2576, 0, 1103, 3258, 2489, 1986, 640,
0, 1050, 0, 0, 421, 0, 0, 895, 5063, 0, 0, 402, 0, 1193, 0, 2314, 989, 60, 0, 0, 0, 579, 0, 0, 1616, 1855, 4204, 0, 0, 0, 901, 0,
1263, 1777, 0, 5089, 0, 223, 2430, 0, 875, 0, 1384, 0, 3722, 4574, 4280, 0, 2733, 0, 920, 1694, 761, 0, 0, 0, 886, 1862, 1532, 1613, 2566, 860, 0, 0,
0, 2343, 0, 1438, 0, 3369, 0, 0, 0, 141, 687, 0, 625, 3039, 1737, 0, 0, 0, 0, 3752, 37, 0, 0, 0, 0, 311, 4022, 649, 487, 0, 1519, 3577,
0, 3141, 288, 4121, 0, 116, 376, 3061, 2296, 0, 1580, 793, 145, 0, 0, 0, 1108, 0, 1060, 1884, 774, 0, 1102, 0, 201, 0, 171, 0, 245, 830, 3550, 0,
1548, 4738, 0, 1400, 0, 1276, 0, 1528, 5006, 0, 2317, 2043, 4500, 4905, 0, 0, 0, 964, 1086, 0, 1534, 709, 0, 0, 0, 0, 1919, 0, 1606, 1829, 3207, 3809,
0, 0, 0, 2666, 2345, 0, 460, 1777, 684, 1054, 0, 1161, 4738, 0, 4655, 0, 883, 1523, 0, 1554, 0, 627, 960, 0, 216, 0, 0, 2129, 0, 1789, 0, 0,
4867, 5007, 211, 285, 0, 3769, 502, 0, 4891, 0, 3337, 1454, 1729, 557, 0, 0, 1331, 1665, 0, 3490, 0, 3383, 0, 0, 3913, 3396, 3731, 411, 0, 0, 0, 0,
1445, 430, 1829, 103, 0, 0, 0, 0, 1887, 0, 1254, 0, 0, 1543, 0, 404, 393, 0, 3546, 3555, 2042, 2055, 1441, 840, 1566, 2818, 0, 0, 1325, 0, 0, 0,
0, 4759, 0, 3950, 152, 422, 0, 0, 4855, 221, 4852, 5060, 419, 1281, 658, 4101, 0, 0, 0, 3967, 3633, 0, 3378, 0, 0, 1194, 0, 0, 0, 2366, 3010, 0,
0, 5010, 0, 1011, 0, 143, 1210, 4725, 0, 3742, 1141, 0, 0, 0, 2000, 1218, 1170, 0, 814, 0, 2831, 857, 0, 1466, 22, 1028, 845, 1199, 0, 2027, 3598, 0,
0, 0, 4917, 4855, 3545, 191, 1006, 1561, 1085, 2623, 2694, 0, 0, 2040, 1319, 5012, 2005, 1777, 697, 8, 140, 12, 3608, 3119, 0, 1495, 571, 1716, 0, 1164, 1933, 4144,
0, 4691, 0, 0, 229, 1083, 168, 3386, 3675, 0, 2101, 0, 0, 454, 2282, 2179, 1353, 0, 0, 0, 108, 1661, 414, 0, 0, 813, 0, 1345, 1506, 0, 0, 0,
0, 0, 4680, 1577, 0, 3012, 0, 0, 1978, 1783, 236, 0, 2229, 0, 0, 2320, 0, 0, 1729, 796, 1901, 0, 1084, 0, 0, 0, 1601, 0, 1134, 0, 1379, 2446,
0, 0, 0, 0, 1267, 2193, 0, 1553, 0, 4700, 1494, 0, 0, 0, 0, 0, 0, 3131, 550, 3623, 2991, 696, 0, 0, 0, 0, 118, 0, 268, 0, 2478, 362,
63, 784, 2218, 0, 0, 1437, 0, 1699, 0, 1559, 0, 812, 0, 1996, 1995, 126, 2607, 2521, 956, 0, 0, 0, 0, 916, 0, 0, 0, 1159, 0, 0, 981, 0,
0, 1841, 0, 0, 0, 1889, 0, 720, 139, 3614, 5005, 0, 1370, 727, 1360, 4116, 2665, 4136, 2825, 235, 1567, 0, 0, 0, 0, 1515, 0, 199, 3945, 3557, 561, 730,
893, 1044, 351, 491, 4795, 0, 0, 3566, 0, 199, 0, 0, 4423, 1286, 0, 4260, 669, 0, 327, 560, 1762, 1119, 1762, 2497, 1712, 1657, 0, 2874, 0, 0, 62, 0,
1350, 0, 0, 495, 1488, 1655, 0, 608, 0, 0, 146, 0, 1131, 0, 725, 4827, 380, 0, 3258, 1331, 1752, 155, 0, 0, 1127, 977, 1098, 1583, 3781, 0, 898, 0,
0, 3222, 161, 0, 0, 510, 307, 319, 481, 0, 0, 0, 3016, 502, 402, 112, 1794, 0, 0, 42, 2109, 1540, 3643, 0, 781, 0, 891, 1174, 1021, 2057, 2745, 3512,
0, 1960, 0, 0, 0, 5046, 4263, 210, 0, 0, 1434, 3677, 75, 0, 3689, 449, 0, 0, 0, 2673, 1352, 1332, 4150, 0, 3778, 2352, 0, 0, 330, 0, 0, 2516,
0, 4803, 0, 0, 0, 0, 1623, 0, 0, 991, 2005, 1484, 417, 736, 4435, 0, 2844, 0, 3250, 1641, 0, 93, 1045, 1265, 470, 928, 2668, 1553, 0, 0, 340, 944,
0, 0, 2076, 0, 0, 1041, 2622, 0, 96, 0, 0, 0, 4618, 0, 0, 2335, 1436, 2486, 0, 0, 3190, 0, 2778, 2224, 960, 2626, 1874, 0, 0, 0, 1942, 3019,
0, 3751, 1408, 5002, 465, 27, 0, 0, 0, 0, 871, 0, 0, 7, 5006, 0, 73, 905, 0, 3585, 372, 697, 0, 1620, 0, 2541, 2048, 661, 0, 1590, 4078, 0,
39, 0, 383, 0, 3316, 2288, 0, 0, 0, 1332, 0, 0, 0, 2089, 0, 3981, 195, 3461, 1630, 776, 135, 1357, 0, 828, 255, 2326, 0, 4162, 3244, 0, 430, 3752,
0, 980, 540, 2200, 0, 812, 644, 4281, 1788, 4740, 160, 942, 1600, 0, 1485, 2473, 1405, 3362, 313, 0, 0, 1637, 0, 1632, 0, 907, 0, 2182, 1187, 3224, 0, 1456,
0, 395, 516, 103, 0, 1528, 2029, 2094, 681, 3331, 1102, 821, 994, 1315, 823, 2010, 3018, 0, 0, 0, 0, 3602, 0, 0, 828, 1320, 201, 1570, 1784, 0, 0, 0,
1563, 1323, 1535, 0, 2298, 1573, 0, 0, 553, 621, 1096, 0, 3085, 4752, 693, 0, 2009, 3763, 3258, 0, 0, 0, 1568, 1026, 2794, 0, 675, 1852, 0, 0, 176, 0,
1151, 2075, 1229, 1786, 0, 0, 1025, 1688, 4674, 5036, 0, 525, 341, 1247, 0, 0, 4078, 1846, 360, 2249, 1745, 549, 0, 1141, 1062, 2069, 0, 4096, 1070, 2440, 987, 0,
0, 2901, 698, 2072, 0, 0, 0, 2325, 0, 944, 4064, 1104, 0, 0, 0, 650, 0, 0, 0, 2539, 3712, 4164, 1689, 0, 655, 2108, 543, 1394, 3389, 576, 246, 1379,
0, 1324, 0, 649, 1644, 1016, 1535, 0, 468, 5082, 4451, 3644, 2935, 0, 4321, 0, 3556, 0, 58, 2390, 0, 0, 0, 1347, 989, 1170, 1049, 0, 290, 300, 3076, 3691,
0, 2128, 0, 995, 1084, 144, 0, 0, 0, 3993, 4158, 1843, 0, 2253, 993, 697, 0, 140, 3363, 3757, 2094, 0, 0, 2537, 1655, 3695, 1029, 2029, 1003, 0, 223, 4022,
1367, 1349, 4452, 0, 0, 1008, 3459, 0, 1704, 0, 0, 548, 0, 3732, 854, 1519, 617, 599, 0, 0, 1543, 463, 1320, 0, 1543, 506, 1495, 4200, 0, 1490, 471, 1544,
0, 287, 0, 1566, 373, 0, 432, 709, 661, 0, 0, 106, 0, 3599, 51, 0, 253, 1555, 1748, 770, 0, 910, 1302, 1471, 0, 1581, 1243, 147, 1785, 2532, 2073, 624,
2118, 0, 302, 0, 633, 0, 3749, 2332, 0, 0, 0, 0, 4980, 1785, 1382, 189, 0, 390, 0, 0, 0, 131, 2981, 0, 1654, 0, 0, 2075, 0, 0, 3459, 1129,
1842, 4122, 1861, 0, 1952, 491, 0, 1730, 0, 0, 4656, 194, 1917, 2358, 0, 4537, 2197, 0, 885, 2812, 0, 1141, 712, 0, 0, 507, 138, 0, 0, 0, 311, 2789,
448, 0, 0, 4903, 4438, 0, 0, 2558, 0, 1803, 0, 0, 1954, 3484, 0, 0, 1593, 0, 484, 0, 1025, 730, 0, 562, 368, 2012, 2084, 3266, 974, 28, 1297, 0,
750, 967, 608, 0, 3442, 0, 0, 949, 3542, 1257, 837, 4187, 2153, 52, 0, 0, 0, 554, 3968, 592, 1707, 3952, 378, 344, 3953, 1949, 1649, 1203, 0, 855, 1184, 0,
0, 0, 0, 2132, 1082, 3915, 0, 2884, 97, 0, 0, 2783, 2931, 304, 577, 0, 0, 830, 1027, 78, 962, 1956, 1157, 2425, 1215, 0, 2064, 3283, 457, 1541, 2448, 0,
0, 1074, 2052, 873, 0, 1619, 3362, 0, 592, 0, 0, 2562, 446, 3929, 0, 0, 1729, 2026, 0, 0, 3251, 4085, 642, 0, 1395, 1905, 561, 1657, 2911, 0, 257, 1571,
606, 394, 4774, 761, 974, 0, 3529, 0, 180, 4732, 0, 2056, 3255, 1687, 544, 1863, 0, 702, 1959, 0, 723, 974, 1439, 1701, 4146, 0, 3223, 3251, 58, 4174, 84, 0,
1359, 3946, 2186, 0, 0, 0, 0, 0, 0, 3024, 1127, 4895, 470, 315, 0, 0, 0, 184, 0, 0, 1346, 0, 474, 0, 0, 2969, 0, 262, 653, 3307, 1196, 0,
2865, 0, 98, 0, 0, 1747, 324, 0, 781, 2095, 0, 0, 0, 0, 488, 0, 1646, 1570, 0, 532, 3472, 0, 1082, 0, 0, 902, 806, 1955, 1437, 0, 1571, 2087,
0, 162, 407, 3144, 2194, 0, 863, 0, 0, 693, 3953, 0, 0, 0, 0, 3389, 0, 0, 0, 0, 989, 1251, 670, 3088, 0, 2826, 126, 953, 883, 1617, 29, 2433,
2736, 5001, 923, 115, 0, 0, 0, 2049, 4447, 978, 140, 0, 1163, 0, 0, 1780, 3934, 49, 259, 0, 633, 1128, 0, 13, 800, 3710, 0, 1747, 0, 1335, 340, 1665,
0, 335, 0, 1443, 4253, 3000, 237, 270, 1171, 751, 0, 544, 1448, 1916, 3985, 1593, 2867, 596, 0, 0, 1562, 834, 0, 0, 1106, 0, 214, 1089, 1482, 563, 1057, 0,
1329, 2332, 672, 1101, 5023, 407, 1793, 0, 1778, 1683, 4403, 0, 1393, 0, 0, 5062, 0, 299, 822, 2953, 0, 0, 2363, 0, 0, 90, 4110, 0, 0, 447, 1000, 0,
1279, 1696, 4218, 0, 3989, 0, 4257, 0, 4230, 0, 2312, 1928, 0, 0, 0, 2962, 3614, 1623, 0, 0, 0, 1455, 1362, 1598, 0, 1242, 1256, 1421, 0, 3228, 0, 0,
0, 0, 3996, 271, 0, 0, 0, 0, 0, 0, 527, 1544, 0, 23, 0, 4577, 0, 842, 644, 1273, 0, 0, 1496, 0, 682, 0, 2848, 0, 3132, 282, 496, 863,
663, 332, 1615, 0, 0, 1419, 0, 0, 550, 1618, 1570, 0, 529, 3817, 0, 0, 317, 2237, 1338, 0, 2009, 0, 2337, 0, 0, 716, 0, 3232, 1395, 65, 2974, 1924,
4677, 1305, 3477, 125, 0, 2206, 5045, 459, 1700, 0, 0, 875, 430, 1238, 192, 2901, 166, 0, 0, 1408, 346, 1478, 145, 1625, 4108, 458, 1414, 3191, 3576, 0, 0, 1880,
1995, 563, 0, 0, 727, 4313, 1244, 0, 561, 0, 3651, 0, 0, 0, 1249, 0, 0, 0, 0, 0, 1119, 0, 2010, 0, 3534, 3006, 3166, 0, 0, 3230, 0, 2874,
0, 0, 0, 5002, 4660, 0, 3220, 897, 2285, 617, 4625, 0, 1218, 3826, 412, 0, 0, 2460, 1910, 0, 0, 2390, 3976, 1812, 2064, 0, 3288, 0, 238, 0, 962, 3904,
0, 792, 0, 0, 4304, 351, 0, 2803, 0, 0, 1045, 0, 218, 1243, 0, 0, 464, 4026, 3899, 0, 2095, 0, 391, 640, 1720, 1946, 3045, 0, 769, 87, 1673, 1807,
4323, 0, 3484, 2117, 0, 0, 0, 0, 855, 1235, 1834, 4054, 0, 426, 1498, 796, 3500, 0, 3493, 1264, 0, 1609, 3771, 0, 4180, 0, 0, 0, 1851, 2314, 194, 2836,
55, 0, 421, 0, 4966, 2921, 777, 0, 3751, 1902, 3999, 0, 0, 0, 1564, 0, 2028, 3790, 0, 0, 0, 0, 0, 750, 1581, 0, 1009, 1744, 0, 0, 0, 1258,
389, 1322, 3425, 1207, 0, 0, 270, 2256, 0, 0, 1106, 0, 198, 923, 1896, 0, 831, 843, 0, 419, 522, 527, 1040, 752, 0, 1359, 0, 2638, 0, 3415, 0, 0,
0, 1034, 2313, 2270, 4432, 905, 1447, 3141, 0, 0, 1773, 0, 0, 0, 1558, 372, 0, 130, 0, 1033, 0, 22, 1368, 0, 672, 267, 3401, 0, 86, 1717, 1574, 308,
249, 0, 2138, 0, 5075, 620, 0, 0, 1, 4410, 4630, 0, 542, 398, 0, 0, 1859};
4677, 735, 0, 15, 0, 1551, 390, 0, 0, 3914, 877, 392, 1166, 3572, 0, 0,
1041, 121, 4063, 1693, 0, 1542, 1067, 0, 1873, 612, 0, 0, 1439, 0, 1330, 0,
3746, 1272, 4399, 1223, 2216, 2080, 1482, 0, 2070, 0, 1634, 812, 0, 20, 4942, 5022,
1155, 4246, 1075, 1271, 1094, 0, 1628, 1918, 4913, 413, 0, 0, 0, 4958, 0, 1461,
273, 4628, 3261, 411, 0, 0, 2882, 3801, 535, 3565, 429, 0, 3998, 4260, 4769, 741,
626, 4061, 2104, 0, 667, 0, 1171, 3024, 632, 1160, 0, 796, 0, 513, 1812, 1328,
1506, 3742, 0, 180, 2298, 1657, 1870, 0, 572, 0, 0, 1752, 0, 0, 906, 179,
584, 0, 0, 0, 0, 0, 1574, 0, 2388, 0, 575, 1868, 2891, 0, 162, 2590,
231, 0, 0, 0, 0, 0, 1552, 0, 2660, 3575, 3598, 0, 482, 1373, 2570, 1191,
0, 916, 1202, 2144, 1821, 0, 1608, 1652, 3630, 0, 0, 0, 0, 0, 0, 4120,
107, 0, 0, 0, 0, 489, 4743, 0, 0, 0, 1200, 1122, 0, 914, 4183, 3414,
582, 4040, 646, 0, 45, 0, 0, 0, 0, 2067, 0, 1625, 1147, 452, 1296, 0,
0, 10, 1055, 932, 2032, 849, 866, 0, 2008, 4718, 2227, 1764, 0, 541, 1802, 50,
0, 214, 0, 450, 177, 731, 0, 1132, 809, 0, 0, 1684, 1094, 0, 667, 1012,
0, 0, 4697, 0, 0, 0, 0, 764, 0, 0, 2204, 707, 4872, 0, 0, 0,
0, 917, 598, 353, 354, 0, 2064, 0, 5070, 1411, 4843, 1181, 0, 53, 2239, 0,
2244, 986, 0, 0, 0, 242, 1372, 467, 0, 2190, 4634, 339, 0, 0, 0, 4724,
0, 130, 3878, 914, 0, 0, 1733, 4886, 0, 118, 457, 0, 0, 1625, 0, 4495,
0, 5071, 2927, 2114, 0, 749, 0, 989, 2322, 606, 0, 1195, 1188, 3304, 0, 3216,
137, 0, 4943, 0, 0, 2632, 4973, 310, 2464, 1967, 4015, 872, 4960, 0, 0, 0,
518, 0, 77, 0, 607, 0, 434, 0, 1516, 4172, 1709, 1248, 0, 165, 1668, 219,
1458, 1340, 1367, 0, 0, 0, 2324, 2812, 0, 0, 2654, 444, 1800, 1678, 0, 872,
0, 4484, 1983, 894, 4464, 1352, 1683, 367, 2163, 0, 0, 64, 0, 4907, 1427, 876,
459, 0, 776, 0, 0, 3454, 0, 1277, 0, 2211, 84, 0, 560, 724, 0, 414,
0, 1711, 839, 3090, 3940, 4508, 0, 843, 1302, 0, 0, 500, 0, 0, 2482, 1020,
0, 951, 1872, 546, 4092, 2249, 0, 0, 0, 5032, 0, 104, 1004, 0, 425, 982,
0, 501, 764, 57, 0, 1621, 4707, 0, 0, 1791, 0, 1346, 2213, 0, 1899, 0,
981, 1141, 0, 0, 0, 122, 1369, 0, 1432, 0, 1310, 4756, 0, 0, 4984, 0,
0, 212, 0, 2115, 0, 0, 2209, 2588, 0, 0, 925, 0, 399, 0, 4015, 0,
0, 0, 1881, 0, 0, 1184, 1728, 431, 344, 2010, 1272, 4460, 0, 1932, 1452, 1031,
147, 0, 0, 3026, 0, 4481, 2608, 0, 0, 0, 581, 0, 2032, 4242, 817, 0,
0, 0, 2021, 547, 0, 1192, 2482, 4942, 0, 0, 0, 0, 1177, 978, 575, 113,
2261, 1409, 0, 1601, 4523, 902, 0, 4722, 1988, 0, 159, 2194, 1389, 469, 3603, 4822,
1192, 0, 0, 1780, 852, 2453, 1504, 0, 0, 676, 0, 0, 1285, 9, 0, 0,
764, 767, 0, 0, 0, 200, 0, 622, 2312, 0, 0, 1502, 806, 1973, 108, 2840,
1127, 876, 0, 994, 0, 0, 4584, 718, 985, 1129, 319, 0, 2603, 505, 0, 0,
0, 1315, 0, 3926, 830, 0, 1873, 0, 2575, 0, 0, 0, 2250, 0, 0, 0,
4006, 1033, 480, 0, 1287, 0, 4706, 975, 0, 987, 4732, 4444, 0, 0, 565, 2262,
0, 0, 2171, 1119, 0, 2965, 961, 1800, 1438, 761, 3925, 2162, 1896, 4609, 0, 0,
0, 811, 0, 0, 0, 0, 0, 641, 0, 3378, 1623, 0, 0, 0, 0, 1530,
0, 939, 1986, 0, 0, 1138, 1718, 1658, 2274, 1413, 1149, 721, 40, 0, 0, 940,
68, 4284, 0, 0, 1259, 2161, 809, 4730, 874, 271, 4942, 1360, 0, 1053, 0, 307,
1511, 0, 2124, 0, 0, 0, 0, 1352, 0, 1182, 164, 1598, 122, 0, 4716, 0,
0, 0, 3850, 0, 0, 4923, 1615, 2264, 1875, 3993, 17, 0, 2183, 2937, 1861, 205,
4060, 4955, 913, 0, 2843, 0, 331, 4891, 0, 3931, 40, 2125, 4489, 770, 0, 1939,
210, 4756, 51, 1648, 2214, 0, 745, 0, 1535, 1253, 1141, 0, 0, 0, 0, 231,
1645, 0, 175, 2081, 0, 0, 0, 0, 930, 0, 2274, 137, 965, 2323, 0, 0,
5083, 0, 2061, 1705, 0, 600, 0, 0, 0, 3063, 1490, 455, 0, 0, 0, 2233,
876, 1125, 1362, 0, 256, 0, 4001, 0, 0, 279, 0, 0, 0, 0, 0, 4728,
4743, 1287, 0, 1799, 4349, 0, 0, 0, 4207, 59, 265, 2495, 924, 3104, 2276, 1205,
0, 4503, 0, 0, 0, 0, 0, 0, 0, 4229, 0, 0, 1583, 0, 0, 18,
0, 1929, 1301, 1097, 0, 1282, 170, 0, 0, 1975, 973, 1548, 0, 1843, 727, 2126,
0, 0, 0, 4132, 0, 774, 92};
int HashG(const char *key, const int *T) int MangledHashG(const char *key, const int *T)
{ {
int sum = 0; int sum = 0;
for (int i = 0; key[i] != '\0'; i++) for (int i = 0; key[i] != '\0'; i++)
{ {
sum += T[i] * key[i]; sum += T[i] * key[i];
sum %= 5095; sum %= 4209;
} }
return kG[sum]; return mangledkG[sum];
} }
int PerfectHash(const char *key) int MangledPerfectHash(const char *key)
{ {
if (strlen(key) > 37) if (strlen(key) > 37)
return 0; return 0;
return (HashG(key, kT1) + HashG(key, kT2)) % 5095; return (MangledHashG(key, mangledkT1) + MangledHashG(key, mangledkT2)) % 4209;
}
constexpr int unmangledkT1[] = {9, 1, 58, 119, 163, 183, 256, 133, 308, 258, 318, 25, 17,
153, 50, 219, 51, 187, 41, 19, 41, 321, 197, 5, 306, 230};
constexpr int unmangledkT2[] = {275, 243, 153, 329, 122, 53, 291, 152, 285, 154, 277, 272, 275,
37, 143, 113, 122, 164, 310, 151, 163, 178, 240, 308, 36, 167};
constexpr int unmangledkG[] = {
0, 0, 0, 254, 0, 0, 0, 201, 0, 0, 0, 0, 0, 181, 0, 207, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 0, 173, 0, 240, 179, 0, 0, 0, 0, 38, 0, 195,
296, 0, 0, 0, 0, 58, 0, 300, 183, 143, 45, 294, 90, 0, 0, 288, 0, 166, 0,
0, 7, 24, 0, 0, 225, 0, 179, 0, 252, 0, 0, 207, 0, 38, 101, 0, 0, 284,
0, 23, 222, 79, 299, 1, 113, 0, 77, 138, 128, 0, 177, 33, 197, 150, 0, 27, 319,
193, 0, 65, 143, 69, 0, 298, 300, 0, 135, 230, 0, 0, 9, 0, 0, 278, 314, 0,
0, 0, 67, 0, 0, 23, 0, 218, 0, 0, 280, 182, 206, 76, 0, 0, 0, 186, 123,
5, 53, 0, 0, 0, 116, 188, 179, 0, 107, 276, 0, 0, 73, 297, 287, 284, 0, 142,
196, 262, 256, 169, 231, 35, 0, 0, 0, 165, 204, 106, 199, 48, 0, 0, 90, 0, 251,
295, 132, 0, 259, 0, 141, 0, 0, 0, 0, 74, 111, 51, 323, 253, 0, 0, 18, 145,
278, 36, 311, 0, 0, 16, 277, 267, 0, 117, 0, 82, 0, 189, 0, 63, 158, 78, 136,
19, 75, 315, 0, 281, 86, 0, 313, 265, 304, 289, 139, 129, 221, 257, 153, 137, 0, 220,
231, 65, 157, 99, 2, 0, 1, 109, 5, 238, 132, 204, 0, 42, 224, 329, 0, 0, 203,
82, 0, 102, 173, 0, 188, 47, 0, 41, 111, 136, 202, 62, 0, 0, 72, 131, 0, 0,
270, 195, 136, 0, 244, 0, 166, 146, 106, 5, 24, 168, 0, 55, 79, 204, 153, 0, 158,
0, 0, 325, 0, 0, 204, 155, 199, 112, 0, 305, 61, 58, 251, 0, 194, 0, 108, 150,
2, 34, 144, 157, 275, 0, 120, 199, 230, 11, 85, 180, 0, 255, 284, 39, 156, 124, 12,
177, 0, 34, 0, 10, 176, 0, 44};
int UnmangledHashG(const char *key, const int *T)
{
int sum = 0;
for (int i = 0; key[i] != '\0'; i++)
{
sum += T[i] * key[i];
sum %= 331;
}
return unmangledkG[sum];
}
int UnmangledPerfectHash(const char *key)
{
if (strlen(key) > 26)
return 0;
return (UnmangledHashG(key, unmangledkT1) + UnmangledHashG(key, unmangledkT2)) % 331;
} }
} // namespace } // namespace
...@@ -392,7 +383,12 @@ const size_t ImmutableString::FowlerNollVoHash<8>::kFnvOffsetBasis = ...@@ -392,7 +383,12 @@ const size_t ImmutableString::FowlerNollVoHash<8>::kFnvOffsetBasis =
uint32_t ImmutableString::mangledNameHash() const uint32_t ImmutableString::mangledNameHash() const
{ {
return PerfectHash(data()); return MangledPerfectHash(data());
}
uint32_t ImmutableString::unmangledNameHash() const
{
return UnmangledPerfectHash(data());
} }
} // namespace sh } // namespace sh
...@@ -133,7 +133,7 @@ bool TSymbolTable::setGlInArraySize(unsigned int inputArraySize) ...@@ -133,7 +133,7 @@ bool TSymbolTable::setGlInArraySize(unsigned int inputArraySize)
{ {
return mGlInVariableWithArraySize->getType().getOutermostArraySize() == inputArraySize; return mGlInVariableWithArraySize->getType().getOutermostArraySize() == inputArraySize;
} }
const TInterfaceBlock *glPerVertex = mVar_gl_PerVertex; const TInterfaceBlock *glPerVertex = static_cast<const TInterfaceBlock *>(mVar_gl_PerVertex);
TType *glInType = new TType(glPerVertex, EvqPerVertexIn, TLayoutQualifier::Create()); TType *glInType = new TType(glPerVertex, EvqPerVertexIn, TLayoutQualifier::Create());
glInType->makeArray(inputArraySize); glInType->makeArray(inputArraySize);
mGlInVariableWithArraySize = mGlInVariableWithArraySize =
...@@ -149,12 +149,12 @@ TVariable *TSymbolTable::getGlInVariableWithArraySize() const ...@@ -149,12 +149,12 @@ TVariable *TSymbolTable::getGlInVariableWithArraySize() const
const TVariable *TSymbolTable::gl_FragData() const const TVariable *TSymbolTable::gl_FragData() const
{ {
return mVar_gl_FragData; return static_cast<const TVariable *>(mVar_gl_FragData);
} }
const TVariable *TSymbolTable::gl_SecondaryFragDataEXT() const const TVariable *TSymbolTable::gl_SecondaryFragDataEXT() const
{ {
return mVar_gl_SecondaryFragDataEXT; return static_cast<const TVariable *>(mVar_gl_SecondaryFragDataEXT);
} }
TSymbolTable::VariableMetadata *TSymbolTable::getOrCreateVariableMetadata(const TVariable &variable) TSymbolTable::VariableMetadata *TSymbolTable::getOrCreateVariableMetadata(const TVariable &variable)
......
...@@ -41,6 +41,17 @@ ...@@ -41,6 +41,17 @@
#include "compiler/translator/Symbol.h" #include "compiler/translator/Symbol.h"
#include "compiler/translator/SymbolTable_autogen.h" #include "compiler/translator/SymbolTable_autogen.h"
enum class Shader
{
ALL,
FRAGMENT, // GL_FRAGMENT_SHADER
VERTEX, // GL_VERTEX_SHADER
COMPUTE, // GL_COMPUTE_SHADER
GEOMETRY, // GL_GEOMETRY_SHADER
GEOMETRY_EXT, // GL_GEOMETRY_SHADER_EXT
NOT_COMPUTE
};
namespace sh namespace sh
{ {
...@@ -51,6 +62,107 @@ struct UnmangledBuiltIn ...@@ -51,6 +62,107 @@ struct UnmangledBuiltIn
TExtension extension; TExtension extension;
}; };
using VarPointer = TSymbol *(TSymbolTableBase::*);
using ValidateExtension = int(ShBuiltInResources::*);
struct SymbolEntry
{
constexpr SymbolEntry(ImmutableString &&name,
const TSymbol *symbol,
VarPointer var,
int esslVersion,
int glslVersion,
Shader shaderType,
const TSymbol *esslExtSymbol,
VarPointer esslExtVar,
int esslExtVersion,
Shader esslExtShaderType,
ValidateExtension esslExtension,
const TSymbol *glslExtSymbol,
VarPointer glslExtVar,
int glslExtVersion,
Shader glslExtShaderType,
ValidateExtension glslExtension,
const TSymbol *esslExtSymbol2 = nullptr,
VarPointer esslExtVar2 = nullptr,
int esslExtVersion2 = -1,
Shader esslExtShaderType2 = Shader::ALL,
ValidateExtension esslExtension2 = nullptr)
: name(std::move(name)),
symbol(symbol),
var(var),
esslVersion(esslVersion),
glslVersion(glslVersion),
shaderType(shaderType),
esslExtSymbol(esslExtSymbol),
esslExtVar(esslExtVar),
esslExtVersion(esslExtVersion),
esslExtShaderType(esslExtShaderType),
esslExtension(esslExtension),
glslExtSymbol(glslExtSymbol),
glslExtVar(glslExtVar),
glslExtVersion(glslExtVersion),
glslExtShaderType(glslExtShaderType),
glslExtension(glslExtension),
esslExtSymbol2(esslExtSymbol2),
esslExtVar2(esslExtVar2),
esslExtVersion2(esslExtVersion2),
esslExtShaderType2(esslExtShaderType2),
esslExtension2(esslExtension2)
{}
ImmutableString name;
const TSymbol *symbol;
VarPointer var;
int esslVersion;
int glslVersion;
Shader shaderType;
const TSymbol *esslExtSymbol;
VarPointer esslExtVar;
int esslExtVersion;
Shader esslExtShaderType;
ValidateExtension esslExtension;
const TSymbol *glslExtSymbol;
VarPointer glslExtVar;
int glslExtVersion;
Shader glslExtShaderType;
ValidateExtension glslExtension;
const TSymbol *esslExtSymbol2;
VarPointer esslExtVar2;
int esslExtVersion2;
Shader esslExtShaderType2;
ValidateExtension esslExtension2;
};
struct UnmangledEntry
{
constexpr UnmangledEntry(ImmutableString &&name,
const UnmangledBuiltIn *esslUnmangled,
const UnmangledBuiltIn *glslUnmangled,
int esslVersion,
int glslVersion,
Shader shaderType)
: name(std::move(name)),
esslUnmangled(esslUnmangled),
glslUnmangled(glslUnmangled),
esslVersion(esslVersion),
glslVersion(glslVersion),
shaderType(shaderType)
{}
ImmutableString name;
const UnmangledBuiltIn *esslUnmangled;
const UnmangledBuiltIn *glslUnmangled;
int esslVersion;
int glslVersion;
Shader shaderType;
};
class TSymbolTable : angle::NonCopyable, TSymbolTableBase class TSymbolTable : angle::NonCopyable, TSymbolTableBase
{ {
public: public:
...@@ -161,6 +273,12 @@ class TSymbolTable : angle::NonCopyable, TSymbolTableBase ...@@ -161,6 +273,12 @@ class TSymbolTable : angle::NonCopyable, TSymbolTableBase
VariableMetadata *getOrCreateVariableMetadata(const TVariable &variable); VariableMetadata *getOrCreateVariableMetadata(const TVariable &variable);
const TSymbol *getSymbol(SymbolEntry entry, const ImmutableString &name, int version) const;
const UnmangledBuiltIn *getUnmangled(UnmangledEntry entry,
const ImmutableString &name,
int version) const;
std::vector<std::unique_ptr<TSymbolTableLevel>> mTable; std::vector<std::unique_ptr<TSymbolTableLevel>> mTable;
// There's one precision stack level for predefined precisions and then one level for each scope // There's one precision stack level for predefined precisions and then one level for each scope
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -17,60 +17,60 @@ namespace sh ...@@ -17,60 +17,60 @@ namespace sh
class TSymbolTableBase class TSymbolTableBase
{ {
protected: public:
TSymbolTableBase() = default; TSymbolTableBase() = default;
TStructure *mVar_gl_DepthRangeParameters = nullptr; TSymbol *mVar_gl_DepthRangeParameters = nullptr;
TVariable *mVar_gl_DepthRange = nullptr; TSymbol *mVar_gl_DepthRange = nullptr;
TVariable *mVar_gl_MaxVertexAttribs = nullptr; TSymbol *mVar_gl_MaxVertexAttribs = nullptr;
TVariable *mVar_gl_MaxVertexUniformVectors = nullptr; TSymbol *mVar_gl_MaxVertexUniformVectors = nullptr;
TVariable *mVar_gl_MaxVertexTextureImageUnits = nullptr; TSymbol *mVar_gl_MaxVertexTextureImageUnits = nullptr;
TVariable *mVar_gl_MaxCombinedTextureImageUnits = nullptr; TSymbol *mVar_gl_MaxCombinedTextureImageUnits = nullptr;
TVariable *mVar_gl_MaxTextureImageUnits = nullptr; TSymbol *mVar_gl_MaxTextureImageUnits = nullptr;
TVariable *mVar_gl_MaxFragmentUniformVectors = nullptr; TSymbol *mVar_gl_MaxFragmentUniformVectors = nullptr;
TVariable *mVar_gl_MaxVaryingVectors = nullptr; TSymbol *mVar_gl_MaxVaryingVectors = nullptr;
TVariable *mVar_gl_MaxDrawBuffers = nullptr; TSymbol *mVar_gl_MaxDrawBuffers = nullptr;
TVariable *mVar_gl_MaxDualSourceDrawBuffersEXT = nullptr; TSymbol *mVar_gl_MaxDualSourceDrawBuffersEXT = nullptr;
TVariable *mVar_gl_MaxVertexOutputVectors = nullptr; TSymbol *mVar_gl_MaxVertexOutputVectors = nullptr;
TVariable *mVar_gl_MaxFragmentInputVectors = nullptr; TSymbol *mVar_gl_MaxFragmentInputVectors = nullptr;
TVariable *mVar_gl_MinProgramTexelOffset = nullptr; TSymbol *mVar_gl_MinProgramTexelOffset = nullptr;
TVariable *mVar_gl_MaxProgramTexelOffset = nullptr; TSymbol *mVar_gl_MaxProgramTexelOffset = nullptr;
TVariable *mVar_gl_MaxImageUnits = nullptr; TSymbol *mVar_gl_MaxImageUnits = nullptr;
TVariable *mVar_gl_MaxVertexImageUniforms = nullptr; TSymbol *mVar_gl_MaxVertexImageUniforms = nullptr;
TVariable *mVar_gl_MaxFragmentImageUniforms = nullptr; TSymbol *mVar_gl_MaxFragmentImageUniforms = nullptr;
TVariable *mVar_gl_MaxComputeImageUniforms = nullptr; TSymbol *mVar_gl_MaxComputeImageUniforms = nullptr;
TVariable *mVar_gl_MaxCombinedImageUniforms = nullptr; TSymbol *mVar_gl_MaxCombinedImageUniforms = nullptr;
TVariable *mVar_gl_MaxCombinedShaderOutputResources = nullptr; TSymbol *mVar_gl_MaxCombinedShaderOutputResources = nullptr;
TVariable *mVar_gl_MaxComputeWorkGroupCount = nullptr; TSymbol *mVar_gl_MaxComputeWorkGroupCount = nullptr;
TVariable *mVar_gl_MaxComputeWorkGroupSize = nullptr; TSymbol *mVar_gl_MaxComputeWorkGroupSize = nullptr;
TVariable *mVar_gl_MaxComputeUniformComponents = nullptr; TSymbol *mVar_gl_MaxComputeUniformComponents = nullptr;
TVariable *mVar_gl_MaxComputeTextureImageUnits = nullptr; TSymbol *mVar_gl_MaxComputeTextureImageUnits = nullptr;
TVariable *mVar_gl_MaxComputeAtomicCounters = nullptr; TSymbol *mVar_gl_MaxComputeAtomicCounters = nullptr;
TVariable *mVar_gl_MaxComputeAtomicCounterBuffers = nullptr; TSymbol *mVar_gl_MaxComputeAtomicCounterBuffers = nullptr;
TVariable *mVar_gl_MaxVertexAtomicCounters = nullptr; TSymbol *mVar_gl_MaxVertexAtomicCounters = nullptr;
TVariable *mVar_gl_MaxFragmentAtomicCounters = nullptr; TSymbol *mVar_gl_MaxFragmentAtomicCounters = nullptr;
TVariable *mVar_gl_MaxCombinedAtomicCounters = nullptr; TSymbol *mVar_gl_MaxCombinedAtomicCounters = nullptr;
TVariable *mVar_gl_MaxAtomicCounterBindings = nullptr; TSymbol *mVar_gl_MaxAtomicCounterBindings = nullptr;
TVariable *mVar_gl_MaxVertexAtomicCounterBuffers = nullptr; TSymbol *mVar_gl_MaxVertexAtomicCounterBuffers = nullptr;
TVariable *mVar_gl_MaxFragmentAtomicCounterBuffers = nullptr; TSymbol *mVar_gl_MaxFragmentAtomicCounterBuffers = nullptr;
TVariable *mVar_gl_MaxCombinedAtomicCounterBuffers = nullptr; TSymbol *mVar_gl_MaxCombinedAtomicCounterBuffers = nullptr;
TVariable *mVar_gl_MaxAtomicCounterBufferSize = nullptr; TSymbol *mVar_gl_MaxAtomicCounterBufferSize = nullptr;
TVariable *mVar_gl_MaxGeometryInputComponents = nullptr; TSymbol *mVar_gl_MaxGeometryInputComponents = nullptr;
TVariable *mVar_gl_MaxGeometryOutputComponents = nullptr; TSymbol *mVar_gl_MaxGeometryOutputComponents = nullptr;
TVariable *mVar_gl_MaxGeometryImageUniforms = nullptr; TSymbol *mVar_gl_MaxGeometryImageUniforms = nullptr;
TVariable *mVar_gl_MaxGeometryTextureImageUnits = nullptr; TSymbol *mVar_gl_MaxGeometryTextureImageUnits = nullptr;
TVariable *mVar_gl_MaxGeometryOutputVertices = nullptr; TSymbol *mVar_gl_MaxGeometryOutputVertices = nullptr;
TVariable *mVar_gl_MaxGeometryTotalOutputComponents = nullptr; TSymbol *mVar_gl_MaxGeometryTotalOutputComponents = nullptr;
TVariable *mVar_gl_MaxGeometryUniformComponents = nullptr; TSymbol *mVar_gl_MaxGeometryUniformComponents = nullptr;
TVariable *mVar_gl_MaxGeometryAtomicCounters = nullptr; TSymbol *mVar_gl_MaxGeometryAtomicCounters = nullptr;
TVariable *mVar_gl_MaxGeometryAtomicCounterBuffers = nullptr; TSymbol *mVar_gl_MaxGeometryAtomicCounterBuffers = nullptr;
TVariable *mVar_gl_FragData = nullptr; TSymbol *mVar_gl_FragData = nullptr;
TVariable *mVar_gl_SecondaryFragDataEXT = nullptr; TSymbol *mVar_gl_SecondaryFragDataEXT = nullptr;
TVariable *mVar_gl_FragDepthEXT = nullptr; TSymbol *mVar_gl_FragDepthEXT = nullptr;
TVariable *mVar_gl_LastFragData = nullptr; TSymbol *mVar_gl_LastFragData = nullptr;
TVariable *mVar_gl_LastFragDataNV = nullptr; TSymbol *mVar_gl_LastFragDataNV = nullptr;
TInterfaceBlock *mVar_gl_PerVertex = nullptr; TSymbol *mVar_gl_PerVertex = nullptr;
TVariable *mVar_gl_in = nullptr; TSymbol *mVar_gl_in = nullptr;
TVariable *mVar_gl_PositionGS = nullptr; TSymbol *mVar_gl_PositionGS = nullptr;
}; };
} // namespace sh } // namespace sh
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// Groups can have metadata related to the group itself. This is given at the end of the GROUP // Groups can have metadata related to the group itself. This is given at the end of the GROUP
// BEGIN line in JSON object format. // BEGIN line in JSON object format.
// Example: // Example:
// GROUP BEGIN <group name> {"condition": "shaderType == GL_FRAGMENT_SHADER"} // GROUP BEGIN <group name> {"shader_type": "FRAGMENT"}
// GROUP END <group name> // GROUP END <group name>
// //
// Defaults: // Defaults:
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
// "suffix" // "suffix"
// string, suffix that is used to disambiguate C++ variable names created based on the // string, suffix that is used to disambiguate C++ variable names created based on the
// function name from C++ keywords, or disambiguate two functions with the same name. // function name from C++ keywords, or disambiguate two functions with the same name.
// "extension" // "essl_extension"
// string, ESSL extension where the function is defined.
// "glsl_extension"
// string, GLSL extension where the function is defined. // string, GLSL extension where the function is defined.
// "hasSideEffects" // "hasSideEffects"
// boolean, can be used to mark a function as having side effects even if it has op other // boolean, can be used to mark a function as having side effects even if it has op other
...@@ -263,7 +265,7 @@ GROUP BEGIN Geometric ...@@ -263,7 +265,7 @@ GROUP BEGIN Geometric
genDType refract(genDType, genDType, float); genDType refract(genDType, genDType, float);
GROUP END Geometric GROUP END Geometric
GROUP BEGIN GeometricVS {"condition": "shaderType == GL_VERTEX_SHADER"} GROUP BEGIN GeometricVS {"shader_type": "VERTEX"}
DEFAULT METADATA {"glsl_level": "COMMON_BUILTINS", "op": "CallBuiltInFunction"} DEFAULT METADATA {"glsl_level": "COMMON_BUILTINS", "op": "CallBuiltInFunction"}
vec4 ftransform(); vec4 ftransform();
GROUP END GeometricVS GROUP END GeometricVS
...@@ -403,12 +405,12 @@ GROUP BEGIN EGL_image_external ...@@ -403,12 +405,12 @@ GROUP BEGIN EGL_image_external
GROUP END EGL_image_external GROUP END EGL_image_external
GROUP BEGIN ARB_texture_rectangle GROUP BEGIN ARB_texture_rectangle
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "extension": "ARB_texture_rectangle"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "ARB_texture_rectangle"}
vec4 texture2DRect(sampler2DRect, vec2); vec4 texture2DRect(sampler2DRect, vec2);
vec4 texture2DRectProj(sampler2DRect, vec3); vec4 texture2DRectProj(sampler2DRect, vec3);
vec4 texture2DRectProj(sampler2DRect, vec4); vec4 texture2DRectProj(sampler2DRect, vec4);
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "ARB_texture_rectangle"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "ARB_texture_rectangle"}
// We don't have a rectangle texture extension for OpenGL ES however based on the behavior of // We don't have a rectangle texture essl_extension for OpenGL ES however based on the behavior of
// rectangle texture in desktop OpenGL, they should be sampled with a "texture" overload in // rectangle texture in desktop OpenGL, they should be sampled with a "texture" overload in
// GLSL version that have such an overload. This is the case for ESSL3 and above. // GLSL version that have such an overload. This is the case for ESSL3 and above.
vec4 texture(sampler2DRect, vec2); vec4 texture(sampler2DRect, vec2);
...@@ -419,14 +421,14 @@ GROUP END ARB_texture_rectangle ...@@ -419,14 +421,14 @@ GROUP END ARB_texture_rectangle
// The *Grad* variants are new to both vertex and fragment shaders; the fragment // The *Grad* variants are new to both vertex and fragment shaders; the fragment
// shader specific pieces are added separately below. // shader specific pieces are added separately below.
GROUP BEGIN EXT_shader_texture_lod GROUP BEGIN EXT_shader_texture_lod
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "extension": "EXT_shader_texture_lod"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "EXT_shader_texture_lod"}
vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2); vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);
vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2); vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);
vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2); vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);
vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3); vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3);
GROUP END EXT_shader_texture_lod GROUP END EXT_shader_texture_lod
GROUP BEGIN TextureFirstVersionsFS {"condition": "shaderType == GL_FRAGMENT_SHADER"} GROUP BEGIN TextureFirstVersionsFS {"shader_type": "FRAGMENT"}
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "glsl_level": "COMMON_BUILTINS", "op": "CallBuiltInFunction"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "glsl_level": "COMMON_BUILTINS", "op": "CallBuiltInFunction"}
vec4 texture2D(sampler2D, vec2, float); vec4 texture2D(sampler2D, vec2, float);
vec4 texture2DProj(sampler2D, vec3, float); vec4 texture2DProj(sampler2D, vec3, float);
...@@ -446,28 +448,28 @@ GROUP BEGIN TextureFirstVersionsFS {"condition": "shaderType == GL_FRAGMENT_SHAD ...@@ -446,28 +448,28 @@ GROUP BEGIN TextureFirstVersionsFS {"condition": "shaderType == GL_FRAGMENT_SHAD
vec4 shadow2DProj(sampler2DShadow, vec4, float); vec4 shadow2DProj(sampler2DShadow, vec4, float);
GROUP END TextureFirstVersionsFS GROUP END TextureFirstVersionsFS
GROUP BEGIN TextureFirstVersionsFSExt {"condition": "shaderType == GL_FRAGMENT_SHADER"} GROUP BEGIN TextureFirstVersionsFSExt {"shader_type": "FRAGMENT"}
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "auto", "extension": "OES_standard_derivatives", "hasSideEffects": "true", "suffix": "Ext"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "auto", "essl_extension": "OES_standard_derivatives", "hasSideEffects": "true", "suffix": "Ext"}
genType dFdx(genType); genType dFdx(genType);
genType dFdy(genType); genType dFdy(genType);
genType fwidth(genType); genType fwidth(genType);
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "extension": "EXT_shader_texture_lod"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "EXT_shader_texture_lod"}
vec4 texture2DLodEXT(sampler2D, vec2, float); vec4 texture2DLodEXT(sampler2D, vec2, float);
vec4 texture2DProjLodEXT(sampler2D, vec3, float); vec4 texture2DProjLodEXT(sampler2D, vec3, float);
vec4 texture2DProjLodEXT(sampler2D, vec4, float); vec4 texture2DProjLodEXT(sampler2D, vec4, float);
vec4 textureCubeLodEXT(samplerCube, vec3, float); vec4 textureCubeLodEXT(samplerCube, vec3, float);
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "extension": "OES_texture_3D"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "OES_texture_3D"}
vec4 texture3D(sampler3D, vec3); vec4 texture3D(sampler3D, vec3);
vec4 texture3DProj(sampler3D, vec4); vec4 texture3DProj(sampler3D, vec4);
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "extension": "OES_texture_3D"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "OES_texture_3D"}
vec4 texture3D(sampler3D, vec3, float); vec4 texture3D(sampler3D, vec3, float);
vec4 texture3DProj(sampler3D, vec4, float); vec4 texture3DProj(sampler3D, vec4, float);
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "extension": "OES_texture_3D"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "OES_texture_3D"}
vec4 texture3DLod(sampler3D, vec3, float); vec4 texture3DLod(sampler3D, vec3, float);
vec4 texture3DProjLod(sampler3D, vec4, float); vec4 texture3DProjLod(sampler3D, vec4, float);
GROUP END TextureFirstVersionsFSExt GROUP END TextureFirstVersionsFSExt
GROUP BEGIN TextureFirstVersionsVS {"condition": "shaderType == GL_VERTEX_SHADER"} GROUP BEGIN TextureFirstVersionsVS {"shader_type": "VERTEX"}
DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "glsl_level": "COMMON_BUILTINS", "op": "CallBuiltInFunction"} DEFAULT METADATA {"essl_level": "ESSL1_BUILTINS", "glsl_level": "COMMON_BUILTINS", "op": "CallBuiltInFunction"}
vec4 texture2DLod(sampler2D, vec2, float); vec4 texture2DLod(sampler2D, vec2, float);
vec4 texture2DProjLod(sampler2D, vec3, float); vec4 texture2DProjLod(sampler2D, vec3, float);
...@@ -629,7 +631,7 @@ GROUP BEGIN TextureSizeMS ...@@ -629,7 +631,7 @@ GROUP BEGIN TextureSizeMS
GROUP END TextureSizeMS GROUP END TextureSizeMS
GROUP BEGIN TextureSizeMSExt GROUP BEGIN TextureSizeMSExt
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "ANGLE_texture_multisample", "suffix": "Ext"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "ANGLE_texture_multisample", "suffix": "Ext"}
ivec2 textureSize(gsampler2DMS); ivec2 textureSize(gsampler2DMS);
GROUP END TextureSizeMSExt GROUP END TextureSizeMSExt
...@@ -639,7 +641,7 @@ GROUP BEGIN TextureSizeMSArray ...@@ -639,7 +641,7 @@ GROUP BEGIN TextureSizeMSArray
GROUP END TextureSizeMSArray GROUP END TextureSizeMSArray
GROUP BEGIN TextureSizeMSArrayExt GROUP BEGIN TextureSizeMSArrayExt
DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "op": "CallBuiltInFunction", "extension": "OES_texture_storage_multisample_2d_array", "suffix": "Ext"} DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "OES_texture_storage_multisample_2d_array", "suffix": "Ext"}
ivec3 textureSize(gsampler2DMSArray); ivec3 textureSize(gsampler2DMSArray);
GROUP END TextureSizeMSArrayExt GROUP END TextureSizeMSArrayExt
...@@ -649,7 +651,7 @@ GROUP BEGIN TexelFetchMS ...@@ -649,7 +651,7 @@ GROUP BEGIN TexelFetchMS
GROUP END TexelFetchMS GROUP END TexelFetchMS
GROUP BEGIN TexelFetchMSExt GROUP BEGIN TexelFetchMSExt
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "ANGLE_texture_multisample", "suffix": "Ext"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "ANGLE_texture_multisample", "suffix": "Ext"}
gvec4 texelFetch(gsampler2DMS, ivec2, int); gvec4 texelFetch(gsampler2DMS, ivec2, int);
GROUP END TexelFetchMSExt GROUP END TexelFetchMSExt
...@@ -659,11 +661,11 @@ GROUP BEGIN TexelFetchMSArray ...@@ -659,11 +661,11 @@ GROUP BEGIN TexelFetchMSArray
GROUP END TexelFetchMSArray GROUP END TexelFetchMSArray
GROUP BEGIN TexelFetchMSArrayExt GROUP BEGIN TexelFetchMSArrayExt
DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "op": "CallBuiltInFunction", "extension": "OES_texture_storage_multisample_2d_array", "suffix": "Ext"} DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "OES_texture_storage_multisample_2d_array", "suffix": "Ext"}
gvec4 texelFetch(gsampler2DMSArray, ivec3, int); gvec4 texelFetch(gsampler2DMSArray, ivec3, int);
GROUP END TexelFetchMSArrayExt GROUP END TexelFetchMSArrayExt
GROUP BEGIN TextureBias {"condition": "shaderType == GL_FRAGMENT_SHADER"} GROUP BEGIN TextureBias {"shader_type": "FRAGMENT"}
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "glsl_level": "GLSL1_3_BUILTINS", "op": "CallBuiltInFunction"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "glsl_level": "GLSL1_3_BUILTINS", "op": "CallBuiltInFunction"}
gvec4 texture(gsampler2D, vec2, float); gvec4 texture(gsampler2D, vec2, float);
gvec4 texture(gsampler3D, vec3, float); gvec4 texture(gsampler3D, vec3, float);
...@@ -684,17 +686,17 @@ GROUP BEGIN TextureBias {"condition": "shaderType == GL_FRAGMENT_SHADER"} ...@@ -684,17 +686,17 @@ GROUP BEGIN TextureBias {"condition": "shaderType == GL_FRAGMENT_SHADER"}
gvec4 textureProj(gsampler1D, vec2, float); gvec4 textureProj(gsampler1D, vec2, float);
gvec4 textureProj(gsampler1D, vec4, float); gvec4 textureProj(gsampler1D, vec4, float);
float textureProj(sampler1DShadow, vec4, float); float textureProj(sampler1DShadow, vec4, float);
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "OES_EGL_image_external_essl3"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "OES_EGL_image_external_essl3"}
vec4 texture(samplerExternalOES, vec2, float); vec4 texture(samplerExternalOES, vec2, float);
vec4 textureProj(samplerExternalOES, vec3, float); vec4 textureProj(samplerExternalOES, vec3, float);
vec4 textureProj(samplerExternalOES, vec4, float); vec4 textureProj(samplerExternalOES, vec4, float);
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "EXT_YUV_target"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "EXT_YUV_target"}
vec4 texture(samplerExternal2DY2YEXT, vec2, float); vec4 texture(samplerExternal2DY2YEXT, vec2, float);
vec4 textureProj(samplerExternal2DY2YEXT, vec3, float); vec4 textureProj(samplerExternal2DY2YEXT, vec3, float);
vec4 textureProj(samplerExternal2DY2YEXT, vec4, float); vec4 textureProj(samplerExternal2DY2YEXT, vec4, float);
GROUP END TextureBias GROUP END TextureBias
GROUP BEGIN TextureQueryLod {"condition": "shaderType == GL_FRAGMENT_SHADER"} GROUP BEGIN TextureQueryLod {"shader_type": "FRAGMENT"}
DEFAULT METADATA {"glsl_level": "GLSL4_BUILTINS", "op": "CallBuiltInFunction"} DEFAULT METADATA {"glsl_level": "GLSL4_BUILTINS", "op": "CallBuiltInFunction"}
vec2 textureQueryLod(gsampler1D, float); vec2 textureQueryLod(gsampler1D, float);
vec2 textureQueryLod(gsampler2D, vec2); vec2 textureQueryLod(gsampler2D, vec2);
...@@ -802,7 +804,7 @@ GROUP BEGIN TextureOffsetNoBias {"queryFunction": true} ...@@ -802,7 +804,7 @@ GROUP BEGIN TextureOffsetNoBias {"queryFunction": true}
float textureProjGradOffset(sampler1DShadow, vec4, float, float, int); float textureProjGradOffset(sampler1DShadow, vec4, float, float, int);
GROUP END TextureOffsetNoBias GROUP END TextureOffsetNoBias
GROUP BEGIN TextureOffsetBias {"queryFunction": true, "condition": "shaderType == GL_FRAGMENT_SHADER"} GROUP BEGIN TextureOffsetBias {"queryFunction": true, "shader_type": "FRAGMENT"}
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "glsl_level": "GLSL1_3_BUILTINS", "op": "CallBuiltInFunction"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "glsl_level": "GLSL1_3_BUILTINS", "op": "CallBuiltInFunction"}
gvec4 textureOffset(gsampler2D, vec2, ivec2, float); gvec4 textureOffset(gsampler2D, vec2, ivec2, float);
gvec4 textureOffset(gsampler3D, vec3, ivec3, float); gvec4 textureOffset(gsampler3D, vec3, ivec3, float);
...@@ -825,7 +827,7 @@ GROUP BEGIN TextureOffsetBias {"queryFunction": true, "condition": "shaderType = ...@@ -825,7 +827,7 @@ GROUP BEGIN TextureOffsetBias {"queryFunction": true, "condition": "shaderType =
GROUP END TextureOffsetBias GROUP END TextureOffsetBias
GROUP BEGIN EGL_image_external_essl3 GROUP BEGIN EGL_image_external_essl3
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "OES_EGL_image_external_essl3"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "OES_EGL_image_external_essl3"}
vec4 texture(samplerExternalOES, vec2); vec4 texture(samplerExternalOES, vec2);
vec4 textureProj(samplerExternalOES, vec3); vec4 textureProj(samplerExternalOES, vec3);
vec4 textureProj(samplerExternalOES, vec4); vec4 textureProj(samplerExternalOES, vec4);
...@@ -834,7 +836,7 @@ GROUP BEGIN EGL_image_external_essl3 ...@@ -834,7 +836,7 @@ GROUP BEGIN EGL_image_external_essl3
GROUP END EGL_image_external_essl3 GROUP END EGL_image_external_essl3
GROUP BEGIN EXT_yuv_target GROUP BEGIN EXT_yuv_target
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "extension": "EXT_YUV_target"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "op": "CallBuiltInFunction", "essl_extension": "EXT_YUV_target"}
vec4 texture(samplerExternal2DY2YEXT, vec2); vec4 texture(samplerExternal2DY2YEXT, vec2);
vec4 textureProj(samplerExternal2DY2YEXT, vec3); vec4 textureProj(samplerExternal2DY2YEXT, vec3);
vec4 textureProj(samplerExternal2DY2YEXT, vec4); vec4 textureProj(samplerExternal2DY2YEXT, vec4);
...@@ -897,7 +899,7 @@ GROUP BEGIN TextureGather {"queryFunction": true} ...@@ -897,7 +899,7 @@ GROUP BEGIN TextureGather {"queryFunction": true}
GROUP END Offset GROUP END Offset
GROUP END TextureGather GROUP END TextureGather
GROUP BEGIN DerivativesFS {"condition": "shaderType == GL_FRAGMENT_SHADER"} GROUP BEGIN DerivativesFS {"shader_type": "FRAGMENT"}
DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "glsl_level": "COMMON_BUILTINS", "op": "auto", "hasSideEffects": "true"} DEFAULT METADATA {"essl_level": "ESSL3_BUILTINS", "glsl_level": "COMMON_BUILTINS", "op": "auto", "hasSideEffects": "true"}
genType dFdx(genType); genType dFdx(genType);
genType dFdy(genType); genType dFdy(genType);
...@@ -911,7 +913,7 @@ GROUP BEGIN DerivativesFS {"condition": "shaderType == GL_FRAGMENT_SHADER"} ...@@ -911,7 +913,7 @@ GROUP BEGIN DerivativesFS {"condition": "shaderType == GL_FRAGMENT_SHADER"}
genType fwidthCoarse(genType); genType fwidthCoarse(genType);
GROUP END DerivativesFS GROUP END DerivativesFS
GROUP BEGIN InterpolationFS {"condition": "shaderType == GL_FRAGMENT_SHADER"} GROUP BEGIN InterpolationFS {"shader_type": "FRAGMENT"}
DEFAULT METADATA {"glsl_level": "GLSL4_BUILTINS", "op": "CallBuiltInFunction"} DEFAULT METADATA {"glsl_level": "GLSL4_BUILTINS", "op": "CallBuiltInFunction"}
float interpolateAtCentroid(float); float interpolateAtCentroid(float);
vec2 interpolateAtCentroid(vec2); vec2 interpolateAtCentroid(vec2);
...@@ -1042,7 +1044,7 @@ GROUP BEGIN Barrier ...@@ -1042,7 +1044,7 @@ GROUP BEGIN Barrier
void memoryBarrierImage(); void memoryBarrierImage();
GROUP END Barrier GROUP END Barrier
GROUP BEGIN ESSL310CS {"condition": "shaderType == GL_COMPUTE_SHADER"} GROUP BEGIN ESSL310CS {"shader_type": "COMPUTE"}
DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "glsl_level": "GLSL4_BUILTINS", "op": "auto", "hasSideEffects": true} DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "glsl_level": "GLSL4_BUILTINS", "op": "auto", "hasSideEffects": true}
void barrier(); void barrier();
DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "glsl_level": "GLSL4_3_BUILTINS", "op": "auto", "hasSideEffects": true} DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "glsl_level": "GLSL4_3_BUILTINS", "op": "auto", "hasSideEffects": true}
...@@ -1050,13 +1052,13 @@ GROUP BEGIN ESSL310CS {"condition": "shaderType == GL_COMPUTE_SHADER"} ...@@ -1050,13 +1052,13 @@ GROUP BEGIN ESSL310CS {"condition": "shaderType == GL_COMPUTE_SHADER"}
void groupMemoryBarrier(); void groupMemoryBarrier();
GROUP END ESSL310CS GROUP END ESSL310CS
GROUP BEGIN ESSL310GS {"condition": "shaderType == GL_GEOMETRY_SHADER_EXT"} GROUP BEGIN ESSL310GS {"shader_type": "GEOMETRY_EXT"}
DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "op": "auto", "extension": "EXT_geometry_shader", "hasSideEffects": true} DEFAULT METADATA {"essl_level": "ESSL3_1_BUILTINS", "op": "auto", "essl_extension": "EXT_geometry_shader", "hasSideEffects": true}
void EmitVertex(); void EmitVertex();
void EndPrimitive(); void EndPrimitive();
GROUP END ESSL310GS GROUP END ESSL310GS
GROUP BEGIN GLSLGS {"condition": "shaderType == GL_GEOMETRY_SHADER"} GROUP BEGIN GLSLGS {"shader_type": "GEOMETRY"}
DEFAULT METADATA {"glsl_level": "GLSL4_BUILTINS", "op": "CallBuiltInFunction", "hasSideEffects": "true"} DEFAULT METADATA {"glsl_level": "GLSL4_BUILTINS", "op": "CallBuiltInFunction", "hasSideEffects": "true"}
void EmitStreamVertex(int); void EmitStreamVertex(int);
void EndStreamPrimitive(int); void EndStreamPrimitive(int);
......
...@@ -11,16 +11,17 @@ ...@@ -11,16 +11,17 @@
" properties:", " properties:",
" variables: Object mapping variable names to variable properties.", " variables: Object mapping variable names to variable properties.",
" subgroups: Object with more groups that fall under the top-level group.", " subgroups: Object with more groups that fall under the top-level group.",
" condition: C++ code determining when these variables should be found from", " shader_type: The type of shader this variable is supported in",
" the symbol table.",
" Each variable can have the following properties:", " Each variable can have the following properties:",
" level: Symbol table level where the variable is contained.", " essl_level: ESSL symbol table level where the variable is contained.",
" glsl_level: GLSL symbol table level where the variable is contained.",
" type: Object with properties of the type. Can be substituted with initDynamicType.", " type: Object with properties of the type. Can be substituted with initDynamicType.",
" initDynamicType: Template string with C++ code for initializing a TType * with the", " initDynamicType: Template string with C++ code for initializing a TType * with the",
" name {type_name}. The name will be replaced when generating code.", " name {type_name}. The name will be replaced when generating code.",
" May refer to names of previously listed structs or interface", " May refer to names of previously listed structs or interface",
" blocks.", " blocks.",
" extension: Optional. Name of the extension where this variable is from.", " essl_extension: Optional. Name of the ESSL extension where this variable is from.",
" glsl_extension: Optional. Name of the GLSL extension where this variable is from.",
" value: Optional. String that has one valid value: 'resources'. Denotes that the", " value: Optional. String that has one valid value: 'resources'. Denotes that the",
" value of the variable should be based on the field of ShBuiltInResources", " value of the variable should be based on the field of ShBuiltInResources",
" with the same name as the variable.", " with the same name as the variable.",
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
"variables":{ "variables":{
"gl_DepthRangeParameters":{ "gl_DepthRangeParameters":{
"class":"TStructure", "class":"TStructure",
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"fields":{ "fields":{
"near":{ "near":{
"basic":"Float", "basic":"Float",
...@@ -58,7 +59,7 @@ ...@@ -58,7 +59,7 @@
} }
}, },
"gl_DepthRange":{ "gl_DepthRange":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"initDynamicType":"TType *{type_name} = new TType(gl_DepthRangeParameters, false); {type_name}->setQualifier(EvqUniform);" "initDynamicType":"TType *{type_name} = new TType(gl_DepthRangeParameters, false); {type_name}->setQualifier(EvqUniform);"
} }
} }
...@@ -66,7 +67,7 @@ ...@@ -66,7 +67,7 @@
"Constants":{ "Constants":{
"variables":{ "variables":{
"gl_MaxVertexAttribs":{ "gl_MaxVertexAttribs":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -75,7 +76,7 @@ ...@@ -75,7 +76,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxVertexUniformVectors":{ "gl_MaxVertexUniformVectors":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -84,7 +85,7 @@ ...@@ -84,7 +85,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxVertexTextureImageUnits":{ "gl_MaxVertexTextureImageUnits":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -93,7 +94,7 @@ ...@@ -93,7 +94,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxCombinedTextureImageUnits":{ "gl_MaxCombinedTextureImageUnits":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -102,7 +103,7 @@ ...@@ -102,7 +103,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxTextureImageUnits":{ "gl_MaxTextureImageUnits":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -111,7 +112,7 @@ ...@@ -111,7 +112,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxFragmentUniformVectors":{ "gl_MaxFragmentUniformVectors":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -120,7 +121,7 @@ ...@@ -120,7 +121,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxVaryingVectors":{ "gl_MaxVaryingVectors":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -129,7 +130,7 @@ ...@@ -129,7 +130,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxDrawBuffers":{ "gl_MaxDrawBuffers":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -138,18 +139,18 @@ ...@@ -138,18 +139,18 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxDualSourceDrawBuffersEXT":{ "gl_MaxDualSourceDrawBuffersEXT":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_blend_func_extended", "essl_extension":"EXT_blend_func_extended",
"value":"resources", "value":"resources",
"valueKey":"MaxDualSourceDrawBuffers" "valueKey":"MaxDualSourceDrawBuffers"
}, },
"gl_MaxVertexOutputVectors":{ "gl_MaxVertexOutputVectors":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -158,7 +159,7 @@ ...@@ -158,7 +159,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxFragmentInputVectors":{ "gl_MaxFragmentInputVectors":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -167,7 +168,7 @@ ...@@ -167,7 +168,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MinProgramTexelOffset":{ "gl_MinProgramTexelOffset":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -176,7 +177,7 @@ ...@@ -176,7 +177,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxProgramTexelOffset":{ "gl_MaxProgramTexelOffset":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -185,7 +186,7 @@ ...@@ -185,7 +186,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxImageUnits":{ "gl_MaxImageUnits":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -194,7 +195,7 @@ ...@@ -194,7 +195,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxVertexImageUniforms":{ "gl_MaxVertexImageUniforms":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -203,7 +204,7 @@ ...@@ -203,7 +204,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxFragmentImageUniforms":{ "gl_MaxFragmentImageUniforms":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -212,7 +213,7 @@ ...@@ -212,7 +213,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxComputeImageUniforms":{ "gl_MaxComputeImageUniforms":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -221,7 +222,7 @@ ...@@ -221,7 +222,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxCombinedImageUniforms":{ "gl_MaxCombinedImageUniforms":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -230,7 +231,7 @@ ...@@ -230,7 +231,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxCombinedShaderOutputResources":{ "gl_MaxCombinedShaderOutputResources":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -239,7 +240,7 @@ ...@@ -239,7 +240,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxComputeWorkGroupCount":{ "gl_MaxComputeWorkGroupCount":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -249,7 +250,7 @@ ...@@ -249,7 +250,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxComputeWorkGroupSize":{ "gl_MaxComputeWorkGroupSize":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -259,7 +260,7 @@ ...@@ -259,7 +260,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxComputeUniformComponents":{ "gl_MaxComputeUniformComponents":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -268,7 +269,7 @@ ...@@ -268,7 +269,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxComputeTextureImageUnits":{ "gl_MaxComputeTextureImageUnits":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -277,7 +278,7 @@ ...@@ -277,7 +278,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxComputeAtomicCounters":{ "gl_MaxComputeAtomicCounters":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -286,7 +287,7 @@ ...@@ -286,7 +287,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxComputeAtomicCounterBuffers":{ "gl_MaxComputeAtomicCounterBuffers":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -295,7 +296,7 @@ ...@@ -295,7 +296,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxVertexAtomicCounters":{ "gl_MaxVertexAtomicCounters":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -304,7 +305,7 @@ ...@@ -304,7 +305,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxFragmentAtomicCounters":{ "gl_MaxFragmentAtomicCounters":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -313,7 +314,7 @@ ...@@ -313,7 +314,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxCombinedAtomicCounters":{ "gl_MaxCombinedAtomicCounters":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -322,7 +323,7 @@ ...@@ -322,7 +323,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxAtomicCounterBindings":{ "gl_MaxAtomicCounterBindings":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -331,7 +332,7 @@ ...@@ -331,7 +332,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxVertexAtomicCounterBuffers":{ "gl_MaxVertexAtomicCounterBuffers":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -340,7 +341,7 @@ ...@@ -340,7 +341,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxFragmentAtomicCounterBuffers":{ "gl_MaxFragmentAtomicCounterBuffers":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -349,7 +350,7 @@ ...@@ -349,7 +350,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxCombinedAtomicCounterBuffers":{ "gl_MaxCombinedAtomicCounterBuffers":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -358,7 +359,7 @@ ...@@ -358,7 +359,7 @@
"value":"resources" "value":"resources"
}, },
"gl_MaxAtomicCounterBufferSize":{ "gl_MaxAtomicCounterBufferSize":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
...@@ -371,93 +372,93 @@ ...@@ -371,93 +372,93 @@
"EXTGeometryShader":{ "EXTGeometryShader":{
"variables":{ "variables":{
"gl_MaxGeometryInputComponents":{ "gl_MaxGeometryInputComponents":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryOutputComponents":{ "gl_MaxGeometryOutputComponents":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryImageUniforms":{ "gl_MaxGeometryImageUniforms":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryTextureImageUnits":{ "gl_MaxGeometryTextureImageUnits":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryOutputVertices":{ "gl_MaxGeometryOutputVertices":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryTotalOutputComponents":{ "gl_MaxGeometryTotalOutputComponents":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryUniformComponents":{ "gl_MaxGeometryUniformComponents":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryAtomicCounters":{ "gl_MaxGeometryAtomicCounters":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
}, },
"gl_MaxGeometryAtomicCounterBuffers":{ "gl_MaxGeometryAtomicCounterBuffers":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"Medium", "precision":"Medium",
"qualifier":"Const" "qualifier":"Const"
}, },
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"value":"resources" "value":"resources"
} }
} }
...@@ -465,10 +466,10 @@ ...@@ -465,10 +466,10 @@
} }
}, },
"FragShader":{ "FragShader":{
"condition":"shaderType == GL_FRAGMENT_SHADER", "shader_type": "FRAGMENT",
"variables":{ "variables":{
"gl_FragCoord":{ "gl_FragCoord":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"Medium", "precision":"Medium",
...@@ -477,14 +478,14 @@ ...@@ -477,14 +478,14 @@
} }
}, },
"gl_FrontFacing":{ "gl_FrontFacing":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Bool", "basic":"Bool",
"qualifier":"FrontFacing" "qualifier":"FrontFacing"
} }
}, },
"gl_PointCoord":{ "gl_PointCoord":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"Medium", "precision":"Medium",
...@@ -493,7 +494,7 @@ ...@@ -493,7 +494,7 @@
} }
}, },
"gl_FragColor":{ "gl_FragColor":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"Medium", "precision":"Medium",
...@@ -502,11 +503,11 @@ ...@@ -502,11 +503,11 @@
} }
}, },
"gl_FragData":{ "gl_FragData":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqFragData, 4); if (spec != SH_WEBGL2_SPEC && spec != SH_WEBGL3_SPEC) {{ {type_name}->makeArray(resources.MaxDrawBuffers); }} else {{ {type_name}->makeArray(1u); }}" "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqFragData, 4); if (spec != SH_WEBGL2_SPEC && spec != SH_WEBGL3_SPEC) {{ {type_name}->makeArray(resources.MaxDrawBuffers); }} else {{ {type_name}->makeArray(1u); }}"
}, },
"gl_FragDepth":{ "gl_FragDepth":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"High", "precision":"High",
...@@ -516,11 +517,10 @@ ...@@ -516,11 +517,10 @@
}, },
"subgroups":{ "subgroups":{
"EXTBlendFuncExtended":{ "EXTBlendFuncExtended":{
"condition":"mResources.EXT_blend_func_extended",
"variables":{ "variables":{
"gl_SecondaryFragColorEXT":{ "gl_SecondaryFragColorEXT":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"extension":"EXT_blend_func_extended", "essl_extension":"EXT_blend_func_extended",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"Medium", "precision":"Medium",
...@@ -529,38 +529,35 @@ ...@@ -529,38 +529,35 @@
} }
}, },
"gl_SecondaryFragDataEXT":{ "gl_SecondaryFragDataEXT":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"extension":"EXT_blend_func_extended", "essl_extension":"EXT_blend_func_extended",
"initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1); {type_name}->makeArray(resources.MaxDualSourceDrawBuffers);" "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1); {type_name}->makeArray(resources.MaxDualSourceDrawBuffers);"
} }
} }
}, },
"EXTFragDepth":{ "EXTFragDepth":{
"condition":"mResources.EXT_frag_depth",
"variables":{ "variables":{
"gl_FragDepthEXT":{ "gl_FragDepthEXT":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"extension":"EXT_frag_depth", "essl_extension":"EXT_frag_depth",
"initDynamicType":"TType *{type_name} = new TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepthEXT, 1);" "initDynamicType":"TType *{type_name} = new TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepthEXT, 1);"
} }
} }
}, },
"EXTShaderFramebufferFetch":{ "EXTShaderFramebufferFetch":{
"condition":"mResources.EXT_shader_framebuffer_fetch",
"variables":{ "variables":{
"gl_LastFragData":{ "gl_LastFragData":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"extension":"EXT_shader_framebuffer_fetch", "essl_extension":"EXT_shader_framebuffer_fetch",
"initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1); {type_name}->makeArray(resources.MaxDrawBuffers);" "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1); {type_name}->makeArray(resources.MaxDrawBuffers);"
} }
} }
}, },
"NVShaderFramebufferFetch":{ "NVShaderFramebufferFetch":{
"condition":"mResources.NV_shader_framebuffer_fetch",
"variables":{ "variables":{
"gl_LastFragColor":{ "gl_LastFragColor":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"extension":"NV_shader_framebuffer_fetch", "essl_extension":"NV_shader_framebuffer_fetch",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"Medium", "precision":"Medium",
...@@ -569,19 +566,18 @@ ...@@ -569,19 +566,18 @@
} }
}, },
"gl_LastFragData":{ "gl_LastFragData":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"suffix":"NV", "suffix":"NV",
"extension":"NV_shader_framebuffer_fetch", "essl_extension":"NV_shader_framebuffer_fetch",
"initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1); {type_name}->makeArray(resources.MaxDrawBuffers);" "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1); {type_name}->makeArray(resources.MaxDrawBuffers);"
} }
} }
}, },
"ARMShaderFramebufferFetch":{ "ARMShaderFramebufferFetch":{
"condition":"mResources.ARM_shader_framebuffer_fetch",
"variables":{ "variables":{
"gl_LastFragColorARM":{ "gl_LastFragColorARM":{
"level":"ESSL1_BUILTINS", "essl_level":"ESSL1_BUILTINS",
"extension":"ARM_shader_framebuffer_fetch", "essl_extension":"ARM_shader_framebuffer_fetch",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"Medium", "precision":"Medium",
...@@ -592,11 +588,10 @@ ...@@ -592,11 +588,10 @@
} }
}, },
"GeometryShaderSupported":{ "GeometryShaderSupported":{
"condition":"mResources.EXT_geometry_shader",
"variables":{ "variables":{
"gl_PrimitiveID":{ "gl_PrimitiveID":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -604,8 +599,8 @@ ...@@ -604,8 +599,8 @@
} }
}, },
"gl_Layer":{ "gl_Layer":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -617,10 +612,10 @@ ...@@ -617,10 +612,10 @@
} }
}, },
"VertexShader":{ "VertexShader":{
"condition":"shaderType == GL_VERTEX_SHADER", "shader_type": "VERTEX",
"variables":{ "variables":{
"gl_Position":{ "gl_Position":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"High", "precision":"High",
...@@ -629,7 +624,7 @@ ...@@ -629,7 +624,7 @@
} }
}, },
"gl_PointSize":{ "gl_PointSize":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"type":{ "type":{
"basic":"Float", "basic":"Float",
"precision":"Medium", "precision":"Medium",
...@@ -637,7 +632,7 @@ ...@@ -637,7 +632,7 @@
} }
}, },
"gl_InstanceID":{ "gl_InstanceID":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -645,7 +640,7 @@ ...@@ -645,7 +640,7 @@
} }
}, },
"gl_VertexID":{ "gl_VertexID":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -654,7 +649,7 @@ ...@@ -654,7 +649,7 @@
}, },
"gl_ViewportIndex":{ "gl_ViewportIndex":{
"comment":"For internal use by ANGLE - not exposed to the parser.", "comment":"For internal use by ANGLE - not exposed to the parser.",
"level":"GLSL_BUILTINS", "essl_level":"GLSL_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -664,7 +659,7 @@ ...@@ -664,7 +659,7 @@
"gl_Layer":{ "gl_Layer":{
"suffix":"VS", "suffix":"VS",
"comment":"gl_Layer exists in other shader stages in ESSL, but not in vertex shader so far.", "comment":"gl_Layer exists in other shader stages in ESSL, but not in vertex shader so far.",
"level":"GLSL_BUILTINS", "essl_level":"GLSL_BUILTINS",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -674,13 +669,12 @@ ...@@ -674,13 +669,12 @@
}, },
"subgroups":{ "subgroups":{
"ANGLEMultiDraw":{ "ANGLEMultiDraw":{
"condition": "mResources.ANGLE_multi_draw",
"subgroups":{ "subgroups":{
"ESSL3":{ "ESSL3":{
"variables":{ "variables":{
"gl_DrawID":{ "gl_DrawID":{
"level":"COMMON_BUILTINS", "essl_level":"COMMON_BUILTINS",
"extension":"ANGLE_multi_draw", "essl_extension":"ANGLE_multi_draw",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -692,13 +686,12 @@ ...@@ -692,13 +686,12 @@
} }
}, },
"ANGLEBaseVertexBaseInstance":{ "ANGLEBaseVertexBaseInstance":{
"condition": "mResources.ANGLE_base_vertex_base_instance",
"subgroups":{ "subgroups":{
"ESSL3":{ "ESSL3":{
"variables":{ "variables":{
"gl_BaseVertex":{ "gl_BaseVertex":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"extension":"ANGLE_base_vertex_base_instance", "essl_extension":"ANGLE_base_vertex_base_instance",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -706,8 +699,8 @@ ...@@ -706,8 +699,8 @@
} }
}, },
"gl_BaseInstance":{ "gl_BaseInstance":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"extension":"ANGLE_base_vertex_base_instance", "essl_extension":"ANGLE_base_vertex_base_instance",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -721,10 +714,10 @@ ...@@ -721,10 +714,10 @@
} }
}, },
"ComputeShader":{ "ComputeShader":{
"condition":"shaderType == GL_COMPUTE_SHADER", "shader_type": "COMPUTE",
"variables":{ "variables":{
"gl_NumWorkGroups":{ "gl_NumWorkGroups":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"UInt", "basic":"UInt",
"precision":"Undefined", "precision":"Undefined",
...@@ -733,7 +726,7 @@ ...@@ -733,7 +726,7 @@
} }
}, },
"gl_WorkGroupSize":{ "gl_WorkGroupSize":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"UInt", "basic":"UInt",
"precision":"Undefined", "precision":"Undefined",
...@@ -742,7 +735,7 @@ ...@@ -742,7 +735,7 @@
} }
}, },
"gl_WorkGroupID":{ "gl_WorkGroupID":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"UInt", "basic":"UInt",
"precision":"Undefined", "precision":"Undefined",
...@@ -751,7 +744,7 @@ ...@@ -751,7 +744,7 @@
} }
}, },
"gl_LocalInvocationID":{ "gl_LocalInvocationID":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"UInt", "basic":"UInt",
"precision":"Undefined", "precision":"Undefined",
...@@ -760,7 +753,7 @@ ...@@ -760,7 +753,7 @@
} }
}, },
"gl_GlobalInvocationID":{ "gl_GlobalInvocationID":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"UInt", "basic":"UInt",
"precision":"Undefined", "precision":"Undefined",
...@@ -769,7 +762,7 @@ ...@@ -769,7 +762,7 @@
} }
}, },
"gl_LocalInvocationIndex":{ "gl_LocalInvocationIndex":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"type":{ "type":{
"basic":"UInt", "basic":"UInt",
"precision":"Undefined", "precision":"Undefined",
...@@ -779,11 +772,11 @@ ...@@ -779,11 +772,11 @@
} }
}, },
"GeometryShader":{ "GeometryShader":{
"condition":"shaderType == GL_GEOMETRY_SHADER_EXT", "shader_type": "GEOMETRY_EXT",
"variables":{ "variables":{
"gl_PrimitiveIDIn":{ "gl_PrimitiveIDIn":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -791,8 +784,8 @@ ...@@ -791,8 +784,8 @@
} }
}, },
"gl_InvocationID":{ "gl_InvocationID":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -801,8 +794,8 @@ ...@@ -801,8 +794,8 @@
}, },
"gl_PrimitiveID":{ "gl_PrimitiveID":{
"suffix":"GS", "suffix":"GS",
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -811,8 +804,8 @@ ...@@ -811,8 +804,8 @@
}, },
"gl_Layer":{ "gl_Layer":{
"suffix":"GS", "suffix":"GS",
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"type":{ "type":{
"basic":"Int", "basic":"Int",
"precision":"High", "precision":"High",
...@@ -820,8 +813,8 @@ ...@@ -820,8 +813,8 @@
} }
}, },
"gl_PerVertex":{ "gl_PerVertex":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"class":"TInterfaceBlock", "class":"TInterfaceBlock",
"fields":{ "fields":{
"gl_Position":{ "gl_Position":{
...@@ -833,8 +826,8 @@ ...@@ -833,8 +826,8 @@
} }
}, },
"gl_in":{ "gl_in":{
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"initDynamicType":"TType *{type_name} = new TType(gl_PerVertex, EvqPerVertexIn, TLayoutQualifier::Create()); {type_name}->makeArray(0u);", "initDynamicType":"TType *{type_name} = new TType(gl_PerVertex, EvqPerVertexIn, TLayoutQualifier::Create()); {type_name}->makeArray(0u);",
"comment":"The array size of gl_in is undefined until we get a valid input primitive declaration." "comment":"The array size of gl_in is undefined until we get a valid input primitive declaration."
} }
...@@ -844,8 +837,8 @@ ...@@ -844,8 +837,8 @@
"variables":{ "variables":{
"gl_PerVertex":{ "gl_PerVertex":{
"suffix":"OutBlock", "suffix":"OutBlock",
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"private":true, "private":true,
"class":"TInterfaceBlock", "class":"TInterfaceBlock",
"fields":{ "fields":{
...@@ -859,8 +852,8 @@ ...@@ -859,8 +852,8 @@
}, },
"gl_Position":{ "gl_Position":{
"suffix":"GS", "suffix":"GS",
"level":"ESSL3_1_BUILTINS", "essl_level":"ESSL3_1_BUILTINS",
"extension":"EXT_geometry_shader", "essl_extension":"EXT_geometry_shader",
"initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpHigh, EvqPosition, 4); {type_name}->setInterfaceBlock(gl_PerVertexOutBlock);" "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpHigh, EvqPosition, 4); {type_name}->setInterfaceBlock(gl_PerVertexOutBlock);"
} }
} }
...@@ -868,12 +861,13 @@ ...@@ -868,12 +861,13 @@
} }
}, },
"Multiview":{ "Multiview":{
"condition":"mResources.OVR_multiview && shaderType != GL_COMPUTE_SHADER", "shader_type": "NOT_COMPUTE",
"subgroups":{ "subgroups":{
"ESSL3":{ "ESSL3":{
"variables":{ "variables":{
"gl_ViewID_OVR":{ "gl_ViewID_OVR":{
"level":"ESSL3_BUILTINS", "essl_level":"ESSL3_BUILTINS",
"essl_extension":"OVR_multiview",
"type":{ "type":{
"basic":"UInt", "basic":"UInt",
"precision":"High", "precision":"High",
......
...@@ -52,28 +52,52 @@ std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str) ...@@ -52,28 +52,52 @@ std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str)
namespace namespace
{{ {{
constexpr int kT1[] = {{{S1}}}; constexpr int mangledkT1[] = {{{mangled_S1}}};
constexpr int kT2[] = {{{S2}}}; constexpr int mangledkT2[] = {{{mangled_S2}}};
constexpr int kG[] = {{{G}}}; constexpr int mangledkG[] = {{{mangled_G}}};
int HashG(const char *key, const int *T) int MangledHashG(const char *key, const int *T)
{{ {{
int sum = 0; int sum = 0;
for (int i = 0; key[i] != '\\0'; i++) for (int i = 0; key[i] != '\\0'; i++)
{{ {{
sum += T[i] * key[i]; sum += T[i] * key[i];
sum %= {NG}; sum %= {mangled_NG};
}} }}
return kG[sum]; return mangledkG[sum];
}} }}
int PerfectHash(const char *key) int MangledPerfectHash(const char *key)
{{ {{
if (strlen(key) > {NS}) if (strlen(key) > {mangled_NS})
return 0; return 0;
return (HashG(key, kT1) + HashG(key, kT2)) % {NG}; return (MangledHashG(key, mangledkT1) + MangledHashG(key, mangledkT2)) % {mangled_NG};
}}
constexpr int unmangledkT1[] = {{{unmangled_S1}}};
constexpr int unmangledkT2[] = {{{unmangled_S2}}};
constexpr int unmangledkG[] = {{{unmangled_G}}};
int UnmangledHashG(const char *key, const int *T)
{{
int sum = 0;
for (int i = 0; key[i] != '\\0'; i++)
{{
sum += T[i] * key[i];
sum %= {unmangled_NG};
}}
return unmangledkG[sum];
}}
int UnmangledPerfectHash(const char *key)
{{
if (strlen(key) > {unmangled_NS})
return 0;
return (UnmangledHashG(key, unmangledkT1) + UnmangledHashG(key, unmangledkT2)) % {unmangled_NG};
}} }}
}} }}
...@@ -97,7 +121,12 @@ const size_t ImmutableString::FowlerNollVoHash<8>::kFnvOffsetBasis = ...@@ -97,7 +121,12 @@ const size_t ImmutableString::FowlerNollVoHash<8>::kFnvOffsetBasis =
uint32_t ImmutableString::mangledNameHash() const uint32_t ImmutableString::mangledNameHash() const
{{ {{
return PerfectHash(data()); return MangledPerfectHash(data());
}}
uint32_t ImmutableString::unmangledNameHash() const
{{
return UnmangledPerfectHash(data());
}} }}
}} // namespace sh }} // namespace sh
...@@ -122,6 +151,7 @@ namespace sh ...@@ -122,6 +151,7 @@ namespace sh
TEST(ImmutableStringTest, ScriptGeneratedHashesMatch) TEST(ImmutableStringTest, ScriptGeneratedHashesMatch)
{{ {{
{script_generated_hash_tests} {script_generated_hash_tests}
{unmangled_script_generated_hash_tests}
}} }}
}} // namespace sh }} // namespace sh
...@@ -189,7 +219,7 @@ namespace sh ...@@ -189,7 +219,7 @@ namespace sh
class TSymbolTableBase class TSymbolTableBase
{{ {{
protected: public:
TSymbolTableBase() = default; TSymbolTableBase() = default;
{declare_member_variables} {declare_member_variables}
}}; }};
...@@ -273,6 +303,15 @@ namespace BuiltInFunction ...@@ -273,6 +303,15 @@ namespace BuiltInFunction
}} // namespace BuiltInFunction }} // namespace BuiltInFunction
namespace BuiltInArray
{{
constexpr SymbolEntry mangled[] = {{ {mangled_array} }};
constexpr UnmangledEntry unmangled[] = {{ {unmangled_array} }};
}}
void TSymbolTable::initializeBuiltInVariables(sh::GLenum shaderType, void TSymbolTable::initializeBuiltInVariables(sh::GLenum shaderType,
ShShaderSpec spec, ShShaderSpec spec,
const ShBuiltInResources &resources) const ShBuiltInResources &resources)
...@@ -281,25 +320,136 @@ void TSymbolTable::initializeBuiltInVariables(sh::GLenum shaderType, ...@@ -281,25 +320,136 @@ void TSymbolTable::initializeBuiltInVariables(sh::GLenum shaderType,
{init_member_variables} {init_member_variables}
}} }}
namespace {{
bool CheckESSLVersion(int expected, int actual)
{{
// Not supported
if (expected == -1)
return false;
// Only ESSL100
if (expected == 100)
return actual == 100;
return actual >= expected;
}}
bool CheckGLSLVersion(int expected, int actual)
{{
// Not supported
if (expected == -1)
return false;
return actual >= expected;
}}
bool CheckShaderType(Shader expected, GLenum actual)
{{
switch(expected)
{{
case Shader::ALL:
return true;
case Shader::FRAGMENT:
return actual == GL_FRAGMENT_SHADER;
case Shader::VERTEX:
return actual == GL_VERTEX_SHADER;
case Shader::COMPUTE:
return actual == GL_COMPUTE_SHADER;
case Shader::GEOMETRY:
return actual == GL_GEOMETRY_SHADER;
case Shader::GEOMETRY_EXT:
return actual == GL_GEOMETRY_SHADER_EXT;
case Shader::NOT_COMPUTE:
return actual != GL_COMPUTE_SHADER;
default:
UNREACHABLE();
return false;
}}
}}
}}
const TSymbol *TSymbolTable::getSymbol(SymbolEntry entry, const ImmutableString &name, int version) const
{{
if (entry.name != name)
{{
return nullptr;
}}
if ((entry.symbol || entry.var) && CheckShaderType(entry.shaderType, mShaderType))
{{
// Non-extension symbol or variable
if (!IsDesktopGLSpec(mShaderSpec) && CheckESSLVersion(entry.esslVersion, version))
{{
return entry.symbol ? entry.symbol : this->*(entry.var);
}}
if (IsDesktopGLSpec(mShaderSpec) && CheckGLSLVersion(entry.glslVersion, version))
{{
return entry.symbol ? entry.symbol : this->*(entry.var);
}}
}}
if (entry.esslExtension && mResources.*(entry.esslExtension) && !IsDesktopGLSpec(mShaderSpec) &&
CheckESSLVersion(entry.esslExtVersion, version) &&
CheckShaderType(entry.esslExtShaderType, mShaderType))
{{
return entry.esslExtSymbol ? entry.esslExtSymbol : this->*(entry.esslExtVar);
}}
if (entry.glslExtension && mResources.*(entry.glslExtension) && IsDesktopGLSpec(mShaderSpec) &&
CheckGLSLVersion(entry.glslExtVersion, version) &&
CheckShaderType(entry.glslExtShaderType, mShaderType))
{{
return entry.glslExtSymbol ? entry.glslExtSymbol : this->*(entry.glslExtVar);
}}
if (entry.esslExtension2 && mResources.*(entry.esslExtension2) && !IsDesktopGLSpec(mShaderSpec) &&
CheckESSLVersion(entry.esslExtVersion2, version) &&
CheckShaderType(entry.esslExtShaderType2, mShaderType))
{{
return entry.esslExtSymbol2 ? entry.esslExtSymbol2 : this->*(entry.esslExtVar2);
}}
return nullptr;
}}
const TSymbol *TSymbolTable::findBuiltIn(const ImmutableString &name, const TSymbol *TSymbolTable::findBuiltIn(const ImmutableString &name,
int shaderVersion) const int shaderVersion) const
{{ {{
if (name.length() > {max_mangled_name_length}) if (name.length() > {max_mangled_name_length})
return nullptr;
uint32_t nameHash = name.mangledNameHash();
if (nameHash >= {num_mangled_names})
return nullptr;
return getSymbol(BuiltInArray::mangled[nameHash], name, shaderVersion);
}}
const UnmangledBuiltIn *TSymbolTable::getUnmangled(UnmangledEntry entry, const ImmutableString &name, int version) const
{{
if (!CheckShaderType(entry.shaderType, mShaderType))
{{ {{
return nullptr; return nullptr;
}} }}
uint32_t nameHash = name.mangledNameHash(); if (entry.name == name)
{get_builtin} {{
if (!IsDesktopGLSpec(mShaderSpec) && CheckESSLVersion(entry.esslVersion, version))
{{
return entry.esslUnmangled;
}}
if (IsDesktopGLSpec(mShaderSpec) && CheckGLSLVersion(entry.glslVersion, version))
{{
return entry.glslUnmangled;
}}
}}
return nullptr;
}} }}
const UnmangledBuiltIn *TSymbolTable::getUnmangledBuiltInForShaderVersion(const ImmutableString &name, int shaderVersion) const UnmangledBuiltIn *TSymbolTable::getUnmangledBuiltInForShaderVersion(const ImmutableString &name, int shaderVersion)
{{ {{
if (name.length() > {max_unmangled_name_length}) if (name.length() > {max_unmangled_name_length})
{{
return nullptr; return nullptr;
}}
uint32_t nameHash = name.mangledNameHash(); uint32_t nameHash = name.unmangledNameHash();
{get_unmangled_builtin} if (nameHash >= {num_unmangled_names})
return nullptr;
return getUnmangled(BuiltInArray::unmangled[nameHash], name, shaderVersion);
}} }}
}} // namespace sh }} // namespace sh
...@@ -335,8 +485,6 @@ namespace BuiltInGroup ...@@ -335,8 +485,6 @@ namespace BuiltInGroup
""" """
parsed_variables = None
basic_types_enumeration = [ basic_types_enumeration = [
'Void', 'Void',
'Float', 'Float',
...@@ -457,180 +605,299 @@ glsl_levels = [ ...@@ -457,180 +605,299 @@ glsl_levels = [
'GLSL4_6_BUILTINS', 'GLSL4_5_BUILTINS', 'GLSL4_4_BUILTINS', 'GLSL4_3_BUILTINS', 'GLSL4_6_BUILTINS', 'GLSL4_5_BUILTINS', 'GLSL4_4_BUILTINS', 'GLSL4_3_BUILTINS',
'GLSL4_2_BUILTINS', 'GLSL4_1_BUILTINS', 'GLSL4_BUILTINS', 'GLSL3_3_BUILTINS', 'GLSL4_2_BUILTINS', 'GLSL4_1_BUILTINS', 'GLSL4_BUILTINS', 'GLSL3_3_BUILTINS',
'GLSL1_5_BUILTINS', 'GLSL1_4_BUILTINS', 'GLSL1_3_BUILTINS', 'GLSL1_2_BUILTINS', 'GLSL1_5_BUILTINS', 'GLSL1_4_BUILTINS', 'GLSL1_3_BUILTINS', 'GLSL1_2_BUILTINS',
'GLSL1_1_BUILTINS', 'COMMON_BUILTINS' 'COMMON_BUILTINS'
] ]
def get_essl_shader_version_condition_for_level(level): def get_essl_shader_version_for_level(level):
if level == 'ESSL3_1_BUILTINS': if level == None:
return 'shaderVersion >= 310' return '-1'
elif level == 'ESSL3_1_BUILTINS':
return '310'
elif level == 'ESSL3_BUILTINS': elif level == 'ESSL3_BUILTINS':
return 'shaderVersion >= 300' return '300'
elif level == 'ESSL1_BUILTINS': elif level == 'ESSL1_BUILTINS':
return 'shaderVersion == 100' return '100'
elif level == 'COMMON_BUILTINS': elif level == 'COMMON_BUILTINS':
return '' return '0'
else: else:
raise Exception('Unsupported symbol table level') raise Exception('Unsupported symbol table level')
def get_glsl_shader_version_condition_for_level(level): def get_glsl_shader_version_for_level(level):
if level == 'GLSL1_1_BUILTINS': if level == None:
return 'shaderVersion == 110' return '-1'
elif level == 'GLSL1_2_BUILTINS': elif level == 'GLSL1_2_BUILTINS':
return 'shaderVersion >= 120' return '120'
elif level == 'GLSL1_3_BUILTINS': elif level == 'GLSL1_3_BUILTINS':
return 'shaderVersion >= 130' return '130'
elif level == 'GLSL1_4_BUILTINS': elif level == 'GLSL1_4_BUILTINS':
return 'shaderVersion >= 140' return '140'
elif level == 'GLSL1_5_BUILTINS': elif level == 'GLSL1_5_BUILTINS':
return 'shaderVersion >= 150' return '150'
elif level == 'GLSL3_3_BUILTINS': elif level == 'GLSL3_3_BUILTINS':
return 'shaderVersion >= 330' return '330'
elif level == 'GLSL4_BUILTINS': elif level == 'GLSL4_BUILTINS':
return 'shaderVersion >= 400' return '400'
elif level == 'GLSL4_1_BUILTINS': elif level == 'GLSL4_1_BUILTINS':
return 'shaderVersion >= 410' return '410'
elif level == 'GLSL4_2_BUILTINS': elif level == 'GLSL4_2_BUILTINS':
return 'shaderVersion >= 420' return '420'
elif level == 'GLSL4_3_BUILTINS': elif level == 'GLSL4_3_BUILTINS':
return 'shaderVersion >= 430' return '430'
elif level == 'GLSL4_4_BUILTINS': elif level == 'GLSL4_4_BUILTINS':
return 'shaderVersion >= 440' return '440'
elif level == 'GLSL4_5_BUILTINS': elif level == 'GLSL4_5_BUILTINS':
return 'shaderVersion >= 450' return '450'
elif level == 'GLSL4_6_BUILTINS': elif level == 'GLSL4_6_BUILTINS':
return 'shaderVersion >= 460' return '460'
elif level == 'COMMON_BUILTINS': elif level == 'COMMON_BUILTINS':
return '' return '0'
else: else:
raise Exception('Unsupported symbol table level') raise Exception('Unsupported symbol table level')
def get_specific_switch_code(level_dict, hashfn, script_generated_hash_tests):
code = []
for condition, objs in level_dict.iteritems():
if len(objs) > 0:
if condition != 'NO_CONDITION':
condition_header = ' if ({condition})\n {{'.format(condition=condition)
code.append(condition_header.replace('shaderType', 'mShaderType'))
switch = {}
for name, obj in objs.iteritems():
name_hash = mangledNameHash(name, hashfn, script_generated_hash_tests)
if name_hash not in switch:
switch[name_hash] = []
switch[name_hash].append(obj['hash_matched_code'])
code.append('switch(nameHash) {')
for name_hash, obj in sorted(switch.iteritems()):
code.append('case 0x' + ('%08x' % name_hash) + 'u:\n{')
code += obj
code.append('break;\n}')
code.append('}')
if condition != 'NO_CONDITION':
code.append('}')
return code
class GroupedList: class GroupedList:
""""Class for storing a list of objects grouped by symbol table level and condition.""" """"Class for storing a list of objects grouped by symbol table level and condition."""
def __init__(self): def __init__(self, hashfn, num_names):
self.objs = OrderedDict() self.objs = OrderedDict()
self.max_name_length = 0 self.max_name_length = 0
# We need to add all the levels here instead of lazily since they must be in a specific order. self.hashfn = hashfn
self.objs['essl'] = OrderedDict() self.num_names = num_names
for l in essl_levels:
self.objs['essl'][l] = OrderedDict() def add_obj(self,
self.objs['glsl'] = OrderedDict() essl_level,
for l in glsl_levels: glsl_level,
self.objs['glsl'][l] = OrderedDict() shader_type,
name,
def add_obj(self, essl_level, glsl_level, condition, name, obj): obj,
if essl_level: essl_extension,
if essl_level not in essl_levels: glsl_extension,
raise Exception('Unexpected essl level: ' + str(essl_level)) script_generated_hash_tests,
if condition not in self.objs['essl'][essl_level]: var_obj=False):
self.objs['essl'][essl_level][condition] = OrderedDict() if essl_level and essl_level not in essl_levels:
self.objs['essl'][essl_level][condition][name] = obj raise Exception('Unexpected essl level: ' + str(essl_level))
if len(name) > self.max_name_length: if glsl_level and glsl_level not in glsl_levels:
self.max_name_length = len(name) raise Exception('Unexpected glsl level: ' + str(glsl_level))
if len(name) > self.max_name_length:
if glsl_level: self.max_name_length = len(name)
if glsl_level not in glsl_levels:
raise Exception('Unexpected glsl level: ' + str(glsl_level)) name_hash = mangledNameHash(name, self.hashfn, script_generated_hash_tests, False)
if condition not in self.objs['glsl'][glsl_level]: if name_hash not in self.objs:
self.objs['glsl'][glsl_level][condition] = OrderedDict() self.objs[name_hash] = OrderedDict()
self.objs['glsl'][glsl_level][condition][name] = obj
if len(name) > self.max_name_length: self.objs[name_hash]['name'] = name
self.max_name_length = len(name)
if essl_extension == 'UNDEFINED' and glsl_extension == 'UNDEFINED':
def has_key(self, essl_level, glsl_level, condition, name):
if essl_level:
if essl_level not in essl_levels:
raise Exception('Unexpected essl level: ' + str(essl_level))
if condition not in self.objs['essl'][essl_level]:
return False
if name not in self.objs['essl'][essl_level][condition]:
return False
if glsl_level:
if glsl_level not in glsl_levels:
raise Exception('Unexpected glsl level: ' + str(glsl_level))
if condition not in self.objs['glsl'][glsl_level]:
return False
if name not in self.objs['glsl'][glsl_level][condition]:
return False
return True
def get(self, essl_level, glsl_level, condition, name):
if self.has_key(essl_level, glsl_level, condition, name):
if essl_level: if essl_level:
return self.objs['essl'][essl_level][condition][name] self.objs[name_hash]['essl_level'] = essl_level
if glsl_level: if glsl_level:
return self.objs['glsl'][glsl_level][condition][name] self.objs[name_hash]['glsl_level'] = glsl_level
return None if var_obj:
self.objs[name_hash]['var'] = obj
else:
self.objs[name_hash]['obj'] = obj
self.objs[name_hash]['shader_type'] = shader_type
if essl_extension != 'UNDEFINED':
if (var_obj and 'essl_ext_var' in self.objs[name_hash] and
self.objs[name_hash]['essl_ext_var'] != obj) or (
not var_obj and 'essl_ext_obj' in self.objs[name_hash] and
self.objs[name_hash]['essl_ext_obj'] != obj):
# Adding a variable that is part of two ESSL extensions
if essl_extension != 'UNDEFINED':
self.objs[name_hash]['essl_extension2'] = essl_extension
self.objs[name_hash]['essl_ext_level2'] = essl_level
if var_obj:
self.objs[name_hash]['essl_ext_var2'] = obj
else:
self.objs[name_hash]['essl_ext_obj2'] = obj
self.objs[name_hash]['essl_ext_shader_type2'] = shader_type
else:
self.objs[name_hash]['essl_extension'] = essl_extension
self.objs[name_hash]['essl_ext_level'] = essl_level
if var_obj:
self.objs[name_hash]['essl_ext_var'] = obj
else:
self.objs[name_hash]['essl_ext_obj'] = obj
self.objs[name_hash]['essl_ext_shader_type'] = shader_type
if glsl_extension != 'UNDEFINED':
self.objs[name_hash]['glsl_extension'] = glsl_extension
self.objs[name_hash]['glsl_ext_level'] = glsl_level
if var_obj:
self.objs[name_hash]['glsl_ext_var'] = obj
else:
self.objs[name_hash]['glsl_ext_obj'] = obj
self.objs[name_hash]['glsl_ext_shader_type'] = shader_type
def get_max_name_length(self): def get_max_name_length(self):
return self.max_name_length return self.max_name_length
def get_switch_code(self, hashfn, script_generated_hash_tests): def get_array(self):
code = [] code = []
code.append('if (!IsDesktopGLSpec(mShaderSpec))\n {') for hash_val in range(0, self.num_names):
for level in essl_levels: if hash_val in self.objs:
if len(self.objs['essl'][level]) == 0: obj_data = self.objs[hash_val]
continue
level_condition = get_essl_shader_version_condition_for_level(level) data = []
if level_condition != '': data.append('ImmutableString("{name}")'.format(name=obj_data['name']))
code.append('if ({condition})\n {{'.format(condition=level_condition))
symbol = obj_data['obj'] if 'obj' in obj_data else 'nullptr'
code.extend( var = '&TSymbolTableBase::{}'.format(
get_specific_switch_code(self.objs['essl'][level], hashfn, obj_data['var']) if 'var' in obj_data else 'nullptr'
script_generated_hash_tests)) essl_level = obj_data['essl_level'] if 'essl_level' in obj_data else None
glsl_level = obj_data['glsl_level'] if 'glsl_level' in obj_data else None
essl_version = get_essl_shader_version_for_level(essl_level)
glsl_version = get_glsl_shader_version_for_level(glsl_level)
shader_type = 'Shader::' + obj_data[
'shader_type'] if 'shader_type' in obj_data and obj_data[
'shader_type'] != 'NONE' else 'Shader::ALL'
data.append(symbol)
data.append(var)
data.append(essl_version)
data.append(glsl_version)
data.append(shader_type)
essl_ext_symbol = obj_data[
'essl_ext_obj'] if 'essl_ext_obj' in obj_data else 'nullptr'
essl_ext_var = '&TSymbolTableBase::{}'.format(
obj_data['essl_ext_var']) if 'essl_ext_var' in obj_data else 'nullptr'
essl_ext_version = get_essl_shader_version_for_level(
obj_data['essl_ext_level']) if 'essl_extension' in obj_data else '-1'
essl_ext_shader_type = 'Shader::' + obj_data[
'essl_ext_shader_type'] if 'essl_ext_shader_type' in obj_data and obj_data[
'essl_ext_shader_type'] != 'NONE' else 'Shader::ALL'
essl_extension = '&ShBuiltInResources::{}'.format(
obj_data['essl_extension']) if 'essl_extension' in obj_data else 'nullptr'
data.append(essl_ext_symbol)
data.append(essl_ext_var)
data.append(essl_ext_version)
data.append(essl_ext_shader_type)
data.append(essl_extension)
glsl_ext_symbol = obj_data[
'glsl_ext_obj'] if 'glsl_ext_obj' in obj_data else 'nullptr'
glsl_ext_var = '&TSymbolTableBase::{}'.format(
obj_data['glsl_ext_var']) if 'glsl_ext_var' in obj_data else 'nullptr'
glsl_ext_version = get_glsl_shader_version_for_level(
obj_data['glsl_ext_level']) if 'glsl_extension' in obj_data else '-1'
glsl_ext_shader_type = 'Shader::' + obj_data[
'glsl_ext_shader_type'] if 'glsl_ext_shader_type' in obj_data and obj_data[
'glsl_ext_shader_type'] != 'NONE' else 'Shader::ALL'
glsl_extension = '&ShBuiltInResources::{}'.format(
obj_data['glsl_extension']) if 'glsl_extension' in obj_data else 'nullptr'
data.append(glsl_ext_symbol)
data.append(glsl_ext_var)
data.append(glsl_ext_version)
data.append(glsl_ext_shader_type)
data.append(glsl_extension)
if 'essl_extension2' in obj_data:
essl_ext_symbol2 = obj_data[
'essl_ext_obj2'] if 'essl_ext_obj2' in obj_data else 'nullptr'
essl_ext_var2 = '&TSymbolTableBase::{}'.format(
obj_data['essl_ext_var2']) if 'essl_ext_var2' in obj_data else 'nullptr'
essl_ext_version2 = get_essl_shader_version_for_level(
obj_data['essl_ext_level2'])
essl_ext_shader_type2 = 'Shader::' + obj_data[
'essl_ext_shader_type2'] if 'essl_ext_shader_type2' in obj_data and obj_data[
'essl_ext_shader_type2'] != 'NONE' else 'Shader::ALL'
essl_extension2 = '&ShBuiltInResources::{}'.format(obj_data['essl_extension2'])
data.append(essl_ext_symbol2)
data.append(essl_ext_var2)
data.append(essl_ext_version2)
data.append(essl_ext_shader_type2)
data.append(essl_extension2)
code.append('SymbolEntry(' + ', '.join(data) + ')')
else:
code.append("""SymbolEntry(ImmutableString(""),
nullptr, nullptr, -1, -1, Shader::ALL,
nullptr, nullptr, -1, Shader::ALL, nullptr,
nullptr, nullptr, -1, Shader::ALL, nullptr)""")
return ', '.join(code)
if level_condition != '':
code.append('}')
code.append('}\nelse\n{') class UnmangledGroupedList:
""""Class for storing a list of unmangled objects grouped by symbol table level and condition."""
for level in glsl_levels: def __init__(self, hashfn, num_names):
if len(self.objs['glsl'][level]) == 0: self.objs = OrderedDict()
continue self.max_name_length = 0
level_condition = get_glsl_shader_version_condition_for_level(level) self.hashfn = hashfn
if level_condition != '': self.num_names = num_names
code.append('if ({condition})\n {{'.format(condition=level_condition))
def add_obj(self, essl_level, glsl_level, shader_type, name, essl_obj, glsl_obj,
essl_extension, glsl_extension, essl_unmangled_builtin_declaration,
glsl_unmangled_builtin_declaration, unmangled_script_generated_hash_tests):
if essl_level and essl_level not in essl_levels:
raise Exception('Unexpected essl level: ' + str(essl_level))
if glsl_level and glsl_level not in glsl_levels:
raise Exception('Unexpected glsl level: ' + str(glsl_level))
if len(name) > self.max_name_length:
self.max_name_length = len(name)
name_hash = mangledNameHash(name, self.hashfn, unmangled_script_generated_hash_tests, True)
self.objs[name_hash] = OrderedDict()
self.objs[name_hash]['name'] = name
self.objs[name_hash]['essl_level'] = essl_level
self.objs[name_hash]['glsl_level'] = glsl_level
self.objs[name_hash]['shader_type'] = shader_type
self.objs[name_hash]['essl_obj'] = essl_obj
self.objs[name_hash]['glsl_obj'] = glsl_obj
self.objs[name_hash]['essl_extension'] = essl_extension
self.objs[name_hash]['glsl_extension'] = glsl_extension
self.objs[name_hash]['essl_declaration'] = essl_unmangled_builtin_declaration
self.objs[name_hash]['glsl_declaration'] = glsl_unmangled_builtin_declaration
def has_key(self, essl_level, glsl_level, shader_type, name):
name_hash = mangledNameHash(name, self.hashfn, None, True, False)
if name_hash not in self.objs:
return False
entry = self.objs[name_hash]
if entry['essl_level'] != essl_level:
return False
if entry['glsl_level'] != glsl_level:
return False
if entry['shader_type'] != shader_type:
return False
return True
code.extend( def get(self, essl_level, glsl_level, shader_type, name):
get_specific_switch_code(self.objs['glsl'][level], hashfn, if self.has_key(essl_level, glsl_level, shader_type, name):
script_generated_hash_tests)) name_hash = mangledNameHash(name, self.hashfn, None, True, False)
return self.objs[name_hash]
return None
if level_condition != '': def get_max_name_length(self):
code.append('}') return self.max_name_length
code.append('}') def get_array(self, unmangled_builtin_declarations):
code.append('return nullptr;') code = []
return '\n'.join(code) for hash_val in range(0, self.num_names):
obj_data = self.objs[hash_val]
essl_level = obj_data['essl_level']
glsl_level = obj_data['glsl_level']
shader_type = 'Shader::' + obj_data['shader_type'] if obj_data[
'shader_type'] != 'NONE' else 'Shader::ALL'
data = []
data.append('ImmutableString("{name}")'.format(name=obj_data['name']))
data.append(obj_data['essl_obj'])
data.append(obj_data['glsl_obj'])
data.append(get_essl_shader_version_for_level(essl_level))
data.append(get_glsl_shader_version_for_level(glsl_level))
data.append(shader_type)
code.append('UnmangledEntry(' + ', '.join(data) + ')')
unmangled_builtin_declarations.add(obj_data['essl_declaration'])
unmangled_builtin_declarations.add(obj_data['glsl_declaration'])
return ', '.join(code)
class TType: class TType:
...@@ -717,6 +984,7 @@ class TType: ...@@ -717,6 +984,7 @@ class TType:
return self return self
def parse_type(self, glsl_header_type): def parse_type(self, glsl_header_type):
# TODO(http://anglebug.com/3833): handle readonly, writeonly qualifiers
if glsl_header_type.startswith('readonly writeonly '): if glsl_header_type.startswith('readonly writeonly '):
type_obj = self.parse_type(glsl_header_type[19:]) type_obj = self.parse_type(glsl_header_type[19:])
type_obj['qualifier'] = 'Readonly Writeonly' type_obj['qualifier'] = 'Readonly Writeonly'
...@@ -763,8 +1031,8 @@ class TType: ...@@ -763,8 +1031,8 @@ class TType:
'v': 'Void' 'v': 'Void'
} }
# textureGatherOffsets in GLSL has an ivec2[4] parameter that this needs to parse # TODO(http://anglebug.com/3833): textureGatherOffsets in GLSL has an ivec2[4] parameter
# treating it as a mat4x2 # Need to parse, currently treating it as mat4x2
vec_re = re.compile(r'^([iudb]?)vec([234]?)((\[[234]\])?)$') vec_re = re.compile(r'^([iudb]?)vec([234]?)((\[[234]\])?)$')
vec_match = vec_re.match(glsl_header_type) vec_match = vec_re.match(glsl_header_type)
if vec_match: if vec_match:
...@@ -902,27 +1170,32 @@ def get_parsed_functions(functions_txt_filename): ...@@ -902,27 +1170,32 @@ def get_parsed_functions(functions_txt_filename):
return parsed_functions return parsed_functions
def mangledNameHash(str, hashfn, script_generated_hash_tests, save_test=True): def mangledNameHash(str, hashfn, script_generated_hash_tests, unmangled, save_test=True):
hash = hashfn.hash(str) hash = hashfn.hash(str)
if save_test: if save_test:
sanity_check = ' ASSERT_EQ(0x{hash}u, ImmutableString("{str}").mangledNameHash());'.format( sanity_check = ''
hash=('%08x' % hash), str=str) if unmangled:
sanity_check = ' ASSERT_EQ(0x{hash}u, ImmutableString("{str}").unmangledNameHash());'.format(
hash=('%08x' % hash), str=str)
else:
sanity_check = ' ASSERT_EQ(0x{hash}u, ImmutableString("{str}").mangledNameHash());'.format(
hash=('%08x' % hash), str=str)
script_generated_hash_tests.update({sanity_check: None}) script_generated_hash_tests.update({sanity_check: None})
return hash return hash
def get_function_names(group, mangled_names): def get_function_names(group, mangled_names, unmangled_names):
if 'functions' in group: if 'functions' in group:
for function_props in group['functions']: for function_props in group['functions']:
function_name = function_props['name'] function_name = function_props['name']
mangled_names.append(function_name) unmangled_names.append(function_name)
function_variants = gen_function_variants(function_props) function_variants = gen_function_variants(function_props)
for function_props in function_variants: for function_props in function_variants:
parameters = get_parameters(function_props) parameters = get_parameters(function_props)
mangled_names.append(get_function_mangled_name(function_name, parameters)) mangled_names.append(get_function_mangled_name(function_name, parameters))
if 'subgroups' in group: if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems(): for subgroup_name, subgroup in group['subgroups'].iteritems():
get_function_names(subgroup, mangled_names) get_function_names(subgroup, mangled_names, unmangled_names)
def get_variable_names(group, mangled_names): def get_variable_names(group, mangled_names):
...@@ -940,9 +1213,15 @@ def get_suffix(props): ...@@ -940,9 +1213,15 @@ def get_suffix(props):
return '' return ''
def get_extension(props): def get_essl_extension(props):
if 'extension' in props: if 'essl_extension' in props:
return props['extension'] return props['essl_extension']
return 'UNDEFINED'
def get_glsl_extension(props):
if 'glsl_extension' in props:
return props['glsl_extension']
return 'UNDEFINED' return 'UNDEFINED'
...@@ -1106,11 +1385,12 @@ def gen_function_variants(function_props): ...@@ -1106,11 +1385,12 @@ def gen_function_variants(function_props):
def process_single_function_group( def process_single_function_group(
condition, group_name, group, parameter_declarations, name_declarations, shader_type, group_name, group, parameter_declarations, name_declarations,
unmangled_function_if_statements, unmangled_builtin_declarations, unmangled_function_if_statements, unmangled_builtin_declarations,
defined_function_variants, builtin_id_declarations, builtin_id_definitions, defined_function_variants, builtin_id_declarations, builtin_id_definitions,
defined_parameter_names, variable_declarations, function_declarations, defined_parameter_names, variable_declarations, function_declarations,
script_generated_hash_tests, get_builtin_if_statements): script_generated_hash_tests, unmangled_script_generated_hash_tests,
get_builtin_if_statements):
global id_counter global id_counter
if 'functions' not in group: if 'functions' not in group:
...@@ -1120,13 +1400,19 @@ def process_single_function_group( ...@@ -1120,13 +1400,19 @@ def process_single_function_group(
function_name = function_props['name'] function_name = function_props['name']
essl_level = function_props['essl_level'] if 'essl_level' in function_props else None essl_level = function_props['essl_level'] if 'essl_level' in function_props else None
glsl_level = function_props['glsl_level'] if 'glsl_level' in function_props else None glsl_level = function_props['glsl_level'] if 'glsl_level' in function_props else None
extension = get_extension(function_props) essl_extension = get_essl_extension(function_props)
glsl_extension = get_glsl_extension(function_props)
extension = essl_extension if essl_extension != 'UNDEFINED' else glsl_extension
template_args = { template_args = {
'name': function_name, 'name': function_name,
'name_with_suffix': function_name + get_suffix(function_props), 'name_with_suffix': function_name + get_suffix(function_props),
'essl_level': essl_level, 'essl_level': essl_level,
'glsl_level': glsl_level, 'glsl_level': glsl_level,
'extension': extension, 'essl_extension': essl_extension,
'glsl_extension': glsl_extension,
# This assumes that functions cannot be part of an ESSL and GLSL extension
# Will need to update after adding GLSL extension functions if this is not the case
'extension': essl_extension if essl_extension != 'UNDEFINED' else glsl_extension,
'op': get_op(function_name, function_props), 'op': get_op(function_name, function_props),
'known_to_not_have_side_effects': get_known_to_not_have_side_effects(function_props) 'known_to_not_have_side_effects': get_known_to_not_have_side_effects(function_props)
} }
...@@ -1138,28 +1424,32 @@ def process_single_function_group( ...@@ -1138,28 +1424,32 @@ def process_single_function_group(
if not name_declaration in name_declarations: if not name_declaration in name_declarations:
name_declarations.add(name_declaration) name_declarations.add(name_declaration)
template_unmangled_if = """if (name == BuiltInName::{name_with_suffix}) essl_obj = '&UnmangledBuiltIns::{essl_extension}'.format(**template_args)
{{ glsl_obj = '&UnmangledBuiltIns::{glsl_extension}'.format(**template_args)
return &UnmangledBuiltIns::{extension}; unmangled_builtin_no_shader_type = unmangled_function_if_statements.get(
}}""" essl_level, glsl_level, 'NONE', function_name)
unmangled_if = template_unmangled_if.format(**template_args) if unmangled_builtin_no_shader_type != None and unmangled_builtin_no_shader_type[
unmangled_builtin_no_condition = unmangled_function_if_statements.get( 'essl_extension'] == 'UNDEFINED' and unmangled_builtin_no_shader_type[
essl_level, glsl_level, 'NO_CONDITION', function_name) 'glsl_extension'] == 'UNDEFINED':
if unmangled_builtin_no_condition != None and unmangled_builtin_no_condition[ # We already have this unmangled name without a shader type nor extension on the same level.
'extension'] == 'UNDEFINED': # No need to add a duplicate with a type.
# We already have this unmangled name without a condition nor extension on the same level. No need to add a duplicate with a condition.
pass pass
elif (not unmangled_function_if_statements.has_key( elif (not unmangled_function_if_statements.has_key(
essl_level, glsl_level, condition, function_name)) or extension == 'UNDEFINED': essl_level, glsl_level, shader_type, function_name)) or (
# We don't have this unmangled builtin recorded yet or we might replace an unmangled builtin from an extension with one from core. unmangled_builtin_no_shader_type and
unmangled_function_if_statements.add_obj(essl_level, glsl_level, condition, ((essl_extension == 'UNDEFINED' and
function_name, { unmangled_builtin_no_shader_type['essl_extension'] != 'UNDEFINED') or
'hash_matched_code': unmangled_if, (glsl_extension == 'UNDEFINED' and
'extension': extension unmangled_builtin_no_shader_type['glsl_extension'] != 'UNDEFINED'))):
}) # We don't have this unmangled builtin recorded yet or we replace an unmangled builtin from an extension with one from core.
unmangled_builtin_declarations.add( essl_unmangled_builtin_declaration = 'constexpr const UnmangledBuiltIn {essl_extension}(TExtension::{essl_extension});'.format(
'constexpr const UnmangledBuiltIn {extension}(TExtension::{extension});'.format( **template_args)
**template_args)) glsl_unmangled_builtin_declaration = 'constexpr const UnmangledBuiltIn {glsl_extension}(TExtension::{glsl_extension});'.format(
**template_args)
unmangled_function_if_statements.add_obj(
essl_level, glsl_level, shader_type, function_name, essl_obj, glsl_obj,
essl_extension, glsl_extension, essl_unmangled_builtin_declaration,
glsl_unmangled_builtin_declaration, unmangled_script_generated_hash_tests)
for function_props in function_variants: for function_props in function_variants:
template_args['id'] = id_counter template_args['id'] = id_counter
...@@ -1174,17 +1464,12 @@ def process_single_function_group( ...@@ -1174,17 +1464,12 @@ def process_single_function_group(
template_args['human_readable_name'] = get_function_human_readable_name( template_args['human_readable_name'] = get_function_human_readable_name(
template_args['name_with_suffix'], parameters) template_args['name_with_suffix'], parameters)
template_args['mangled_name_length'] = len(template_args['mangled_name']) template_args['mangled_name_length'] = len(template_args['mangled_name'])
template_args['extension_condition'] = ' && mResources.{extension}'.format(
**template_args) if template_args['extension'] != 'UNDEFINED' else ''
template_mangled_if = """if (name == BuiltInName::{unique_name}{extension_condition}) obj = '&BuiltInFunction::function_{unique_name}'.format(**template_args)
{{ get_builtin_if_statements.add_obj(
return &BuiltInFunction::function_{unique_name}; essl_level, glsl_level, shader_type, template_args['mangled_name'], obj,
}}""" template_args['essl_extension'], template_args['glsl_extension'],
mangled_if = template_mangled_if.format(**template_args) script_generated_hash_tests)
get_builtin_if_statements.add_obj(essl_level, glsl_level, condition,
template_args['mangled_name'],
{'hash_matched_code': mangled_if})
if template_args['unique_name'] in defined_function_variants: if template_args['unique_name'] in defined_function_variants:
continue continue
...@@ -1232,9 +1517,6 @@ def process_single_function_group( ...@@ -1232,9 +1517,6 @@ def process_single_function_group(
template_function_declaration = 'constexpr const TFunction function_{unique_name}(BuiltInId::{human_readable_name}, BuiltInName::{name_with_suffix}, TExtension::{extension}, BuiltInParameters::{parameters_var_name}, {param_count}, {return_type}, EOp{op}, {known_to_not_have_side_effects});' template_function_declaration = 'constexpr const TFunction function_{unique_name}(BuiltInId::{human_readable_name}, BuiltInName::{name_with_suffix}, TExtension::{extension}, BuiltInParameters::{parameters_var_name}, {param_count}, {return_type}, EOp{op}, {known_to_not_have_side_effects});'
function_declarations.append(template_function_declaration.format(**template_args)) function_declarations.append(template_function_declaration.format(**template_args))
template_mangled_name_declaration = 'constexpr const ImmutableString {unique_name}("{mangled_name}");'
name_declarations.add(template_mangled_name_declaration.format(**template_args))
id_counter += 1 id_counter += 1
...@@ -1243,20 +1525,22 @@ def process_function_group(group_name, group, parameter_declarations, name_decla ...@@ -1243,20 +1525,22 @@ def process_function_group(group_name, group, parameter_declarations, name_decla
defined_function_variants, builtin_id_declarations, defined_function_variants, builtin_id_declarations,
builtin_id_definitions, defined_parameter_names, variable_declarations, builtin_id_definitions, defined_parameter_names, variable_declarations,
function_declarations, script_generated_hash_tests, function_declarations, script_generated_hash_tests,
get_builtin_if_statements, is_in_group_definitions): unmangled_script_generated_hash_tests, get_builtin_if_statements,
is_in_group_definitions):
global id_counter global id_counter
first_id = id_counter first_id = id_counter
condition = 'NO_CONDITION' shader_type = 'NONE'
if 'condition' in group: if 'shader_type' in group:
condition = group['condition'] shader_type = group['shader_type']
process_single_function_group( process_single_function_group(shader_type, group_name, group, parameter_declarations,
condition, group_name, group, parameter_declarations, name_declarations, name_declarations, unmangled_function_if_statements,
unmangled_function_if_statements, unmangled_builtin_declarations, unmangled_builtin_declarations, defined_function_variants,
defined_function_variants, builtin_id_declarations, builtin_id_definitions, builtin_id_declarations, builtin_id_definitions,
defined_parameter_names, variable_declarations, function_declarations, defined_parameter_names, variable_declarations,
script_generated_hash_tests, get_builtin_if_statements) function_declarations, script_generated_hash_tests,
unmangled_script_generated_hash_tests, get_builtin_if_statements)
if 'subgroups' in group: if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems(): for subgroup_name, subgroup in group['subgroups'].iteritems():
...@@ -1265,7 +1549,8 @@ def process_function_group(group_name, group, parameter_declarations, name_decla ...@@ -1265,7 +1549,8 @@ def process_function_group(group_name, group, parameter_declarations, name_decla
unmangled_function_if_statements, unmangled_builtin_declarations, unmangled_function_if_statements, unmangled_builtin_declarations,
defined_function_variants, builtin_id_declarations, builtin_id_definitions, defined_function_variants, builtin_id_declarations, builtin_id_definitions,
defined_parameter_names, variable_declarations, function_declarations, defined_parameter_names, variable_declarations, function_declarations,
script_generated_hash_tests, get_builtin_if_statements, is_in_group_definitions) script_generated_hash_tests, unmangled_script_generated_hash_tests,
get_builtin_if_statements, is_in_group_definitions)
if 'queryFunction' in group: if 'queryFunction' in group:
template_args = {'first_id': first_id, 'last_id': id_counter - 1, 'group_name': group_name} template_args = {'first_id': first_id, 'last_id': id_counter - 1, 'group_name': group_name}
...@@ -1303,23 +1588,39 @@ def prune_parameters_arrays(parameter_declarations, function_declarations): ...@@ -1303,23 +1588,39 @@ def prune_parameters_arrays(parameter_declarations, function_declarations):
] ]
def process_single_variable_group(condition, group_name, group, builtin_id_declarations, def process_single_variable_group(shader_type, group_name, group, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables, builtin_id_definitions, name_declarations, init_member_variables,
get_variable_declarations, get_builtin_if_statements, get_variable_declarations, get_builtin_if_statements,
declare_member_variables, variable_declarations, declare_member_variables, variable_declarations,
get_variable_definitions, variable_name_count): get_variable_definitions, script_generated_hash_tests):
global id_counter global id_counter
if 'variables' not in group: if 'variables' not in group:
return return
for variable_name, props in group['variables'].iteritems(): for variable_name, props in group['variables'].iteritems():
level = props['level'] essl_level = props['essl_level'] if 'essl_level' in props else None
glsl_level = props['glsl_level'] if 'glsl_level' in props else None
template_args = { template_args = {
'id': id_counter, 'id':
'name': variable_name, id_counter,
'name_with_suffix': variable_name + get_suffix(props), 'name':
'level': props['level'], variable_name,
'extension': get_extension(props), 'name_with_suffix':
'class': 'TVariable' variable_name + get_suffix(props),
'essl_level':
essl_level,
'glsl_level':
glsl_level,
'essl_extension':
get_essl_extension(props),
'glsl_extension':
get_glsl_extension(props),
# This assumes that variables cannot be part of an ESSL and GLSL extension
# Will need to update after adding GLSL extension variables if this is not the case
'extension':
get_essl_extension(props)
if get_essl_extension(props) != 'UNDEFINED' else get_glsl_extension(props),
'class':
'TVariable'
} }
template_builtin_id_declaration = ' static constexpr const TSymbolUniqueId {name_with_suffix} = TSymbolUniqueId({id});' template_builtin_id_declaration = ' static constexpr const TSymbolUniqueId {name_with_suffix} = TSymbolUniqueId({id});'
...@@ -1382,7 +1683,7 @@ def process_single_variable_group(condition, group_name, group, builtin_id_decla ...@@ -1382,7 +1683,7 @@ def process_single_variable_group(condition, group_name, group, builtin_id_decla
{{ {{
TConstantUnion *unionArray = new TConstantUnion[{object_size}]; TConstantUnion *unionArray = new TConstantUnion[{object_size}];
unionArray[0].setIConst({value}); unionArray[0].setIConst({value});
mVar_{name_with_suffix}->shareConstPointer(unionArray); static_cast<TVariable *>(mVar_{name_with_suffix})->shareConstPointer(unionArray);
}}""" }}"""
if template_args['object_size'] > 1: if template_args['object_size'] > 1:
template_init_variable = """ mVar_{name_with_suffix} = new TVariable(BuiltInId::{name_with_suffix}, BuiltInName::{name}, SymbolType::BuiltIn, TExtension::{extension}, {type}); template_init_variable = """ mVar_{name_with_suffix} = new TVariable(BuiltInId::{name_with_suffix}, BuiltInName::{name}, SymbolType::BuiltIn, TExtension::{extension}, {type});
...@@ -1392,7 +1693,7 @@ def process_single_variable_group(condition, group_name, group, builtin_id_decla ...@@ -1392,7 +1693,7 @@ def process_single_variable_group(condition, group_name, group, builtin_id_decla
{{ {{
unionArray[index].setIConst({value}[index]); unionArray[index].setIConst({value}[index]);
}} }}
mVar_{name_with_suffix}->shareConstPointer(unionArray); static_cast<TVariable *>(mVar_{name_with_suffix})->shareConstPointer(unionArray);
}}""" }}"""
else: else:
...@@ -1413,90 +1714,55 @@ def process_single_variable_group(condition, group_name, group, builtin_id_decla ...@@ -1413,90 +1714,55 @@ def process_single_variable_group(condition, group_name, group, builtin_id_decla
get_variable_definitions.append( get_variable_definitions.append(
template_get_variable_definition.format(**template_args)) template_get_variable_definition.format(**template_args))
if level != 'GLSL_BUILTINS': if essl_level != 'GLSL_BUILTINS':
template_name_if = """if (name == BuiltInName::{name}) obj = '&BuiltInVariable::kVar_{name_with_suffix}'.format(**template_args)
{{ # TODO(clemendeng@google.com): Add GLSL level once GLSL built-in vars are added
return &BuiltInVariable::kVar_{name_with_suffix}; get_builtin_if_statements.add_obj(
}}""" essl_level, 'COMMON_BUILTINS', shader_type, template_args['name'], obj,
name_if = template_name_if.format(**template_args) template_args['essl_extension'], template_args['glsl_extension'],
get_builtin_if_statements.add_obj(level, 'COMMON_BUILTINS', condition, script_generated_hash_tests)
template_args['name'],
{'hash_matched_code': name_if})
if is_member: if is_member:
get_condition = condition
init_conditionally = (
condition != 'NO_CONDITION' and variable_name_count[variable_name] == 1)
if init_conditionally:
# Instead of having the condition if statement at lookup, it's cheaper to have it at initialization time.
init_member_variables.append(
' if ({condition})\n {{'.format(condition=condition))
template_args[
'condition_comment'] = '\n // Only initialized if {condition}'.format(
condition=condition)
get_condition = 'NO_CONDITION'
else:
template_args['condition_comment'] = ''
init_member_variables.append(template_init_variable.format(**template_args)) init_member_variables.append(template_init_variable.format(**template_args))
if init_conditionally:
init_member_variables.append(' }')
template_declare_member_variable = '{class} *mVar_{name_with_suffix} = nullptr;' template_declare_member_variable = 'TSymbol *mVar_{name_with_suffix} = nullptr;'
declare_member_variables.append( declare_member_variables.append(
template_declare_member_variable.format(**template_args)) template_declare_member_variable.format(**template_args))
template_name_if = """if (name == BuiltInName::{name}) obj = 'mVar_{name_with_suffix}'.format(**template_args)
{{{condition_comment}
return mVar_{name_with_suffix};
}}"""
name_if = template_name_if.format(**template_args)
get_builtin_if_statements.add_obj(level, 'COMMON_BUILTINS', get_condition,
variable_name, {'hash_matched_code': name_if})
id_counter += 1
# TODO(clemendeng@google.com): Add GLSL level once GLSL built-in vars are added
get_builtin_if_statements.add_obj(
essl_level, 'COMMON_BUILTINS', shader_type, template_args['name'], obj,
template_args['essl_extension'], template_args['glsl_extension'],
script_generated_hash_tests, True)
def count_variable_names(group, variable_name_count): id_counter += 1
if 'variables' in group:
for name in group['variables'].iterkeys():
if name not in variable_name_count:
variable_name_count[name] = 1
else:
variable_name_count[name] += 1
if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems():
count_variable_names(subgroup, variable_name_count)
def process_variable_group(parent_condition, group_name, group, builtin_id_declarations, def process_variable_group(shader_type, group_name, group, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables, builtin_id_definitions, name_declarations, init_member_variables,
get_variable_declarations, get_builtin_if_statements, get_variable_declarations, get_builtin_if_statements,
declare_member_variables, variable_declarations, declare_member_variables, variable_declarations,
get_variable_definitions, variable_name_count): get_variable_definitions, script_generated_hash_tests):
global id_counter global id_counter
condition = 'NO_CONDITION'
if 'condition' in group:
condition = group['condition']
if parent_condition != 'NO_CONDITION': if 'shader_type' in group:
if condition == 'NO_CONDITION': shader_type = group['shader_type']
condition = parent_condition
else:
condition = '({cond1}) && ({cond2})'.format(cond1=parent_condition, cond2=condition)
process_single_variable_group(condition, group_name, group, builtin_id_declarations, process_single_variable_group(shader_type, group_name, group, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables, builtin_id_definitions, name_declarations, init_member_variables,
get_variable_declarations, get_builtin_if_statements, get_variable_declarations, get_builtin_if_statements,
declare_member_variables, variable_declarations, declare_member_variables, variable_declarations,
get_variable_definitions, variable_name_count) get_variable_definitions, script_generated_hash_tests)
if 'subgroups' in group: if 'subgroups' in group:
for subgroup_name, subgroup in group['subgroups'].iteritems(): for subgroup_name, subgroup in group['subgroups'].iteritems():
process_variable_group( process_variable_group(
condition, subgroup_name, subgroup, builtin_id_declarations, shader_type, subgroup_name, subgroup, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables, builtin_id_definitions, name_declarations, init_member_variables,
get_variable_declarations, get_builtin_if_statements, declare_member_variables, get_variable_declarations, get_builtin_if_statements, declare_member_variables,
variable_declarations, get_variable_definitions, variable_name_count) variable_declarations, get_variable_definitions, script_generated_hash_tests)
def main(): def main():
...@@ -1562,24 +1828,16 @@ def main(): ...@@ -1562,24 +1828,16 @@ def main():
declare_member_variables = [] declare_member_variables = []
init_member_variables = [] init_member_variables = []
# Code for querying builtins.
get_builtin_if_statements = GroupedList()
# Declarations of UnmangledBuiltIn objects # Declarations of UnmangledBuiltIn objects
unmangled_builtin_declarations = set() unmangled_builtin_declarations = set()
# Code for querying builtin function unmangled names.
unmangled_function_if_statements = GroupedList()
# Code for testing that script-generated hashes match with runtime computed hashes. # Code for testing that script-generated hashes match with runtime computed hashes.
script_generated_hash_tests = OrderedDict() script_generated_hash_tests = OrderedDict()
unmangled_script_generated_hash_tests = OrderedDict()
# Functions for testing whether a builtin belongs in group. # Functions for testing whether a builtin belongs in group.
is_in_group_definitions = [] is_in_group_definitions = []
# Counts of variables with a certain name string:
variable_name_count = {}
# Declarations of parameter arrays for builtin TFunctions. Map from C++ variable name to the full # Declarations of parameter arrays for builtin TFunctions. Map from C++ variable name to the full
# declaration. # declaration.
parameter_declarations = {} parameter_declarations = {}
...@@ -1601,43 +1859,59 @@ def main(): ...@@ -1601,43 +1859,59 @@ def main():
json.dump( json.dump(
parsed_functions, outfile, indent=4, separators=(',', ': '), default=serialize_obj) parsed_functions, outfile, indent=4, separators=(',', ': '), default=serialize_obj)
parsed_variables = None
with open(variables_json_filename) as f: with open(variables_json_filename) as f:
parsed_variables = json.load(f, object_pairs_hook=OrderedDict) parsed_variables = json.load(f, object_pairs_hook=OrderedDict)
# This script uses a perfect hash function to avoid dealing with collisions # This script uses a perfect hash function to avoid dealing with collisions
names = [] mangled_names = []
unmangled_names = []
for group_name, group in parsed_functions.iteritems(): for group_name, group in parsed_functions.iteritems():
get_function_names(group, names) get_function_names(group, mangled_names, unmangled_names)
for group_name, group in parsed_variables.iteritems(): for group_name, group in parsed_variables.iteritems():
get_variable_names(group, names) get_variable_names(group, mangled_names)
# Remove duplicates
names = list(dict.fromkeys(names)) # Hashing mangled names
names_dict = dict(zip(names, range(1, len(names) + 1))) mangled_names = list(dict.fromkeys(mangled_names))
num_mangled_names = len(mangled_names)
mangled_names_dict = dict(zip(mangled_names, range(0, len(mangled_names))))
# Generate the perfect hash function
f1, f2, mangled_G = generate_hash(mangled_names_dict, Hash2)
mangled_hashfn = HashFunction(f1, f2, mangled_G)
mangled_S1 = f1.salt
mangled_S2 = f2.salt
# Array for querying mangled builtins
get_builtin_if_statements = GroupedList(mangled_hashfn, num_mangled_names)
# Hashing unmangled names
unmangled_names = list(dict.fromkeys(unmangled_names))
num_unmangled_names = len(unmangled_names)
unmangled_names_dict = dict(zip(unmangled_names, range(0, len(unmangled_names))))
# Generate the perfect hash function # Generate the perfect hash function
f1, f2, G = generate_hash(names_dict, Hash2) f1, f2, unmangled_G = generate_hash(unmangled_names_dict, Hash2)
hashfn = HashFunction(f1, f2, G) unmangled_hashfn = HashFunction(f1, f2, unmangled_G)
S1 = f1.salt unmangled_S1 = f1.salt
S2 = f2.salt unmangled_S2 = f2.salt
# Array for querying unmangled builtins
unmangled_function_if_statements = UnmangledGroupedList(unmangled_hashfn, num_unmangled_names)
for group_name, group in parsed_functions.iteritems(): for group_name, group in parsed_functions.iteritems():
process_function_group( process_function_group(group_name, group, parameter_declarations, name_declarations,
group_name, group, parameter_declarations, name_declarations, unmangled_function_if_statements, unmangled_builtin_declarations,
unmangled_function_if_statements, unmangled_builtin_declarations, defined_function_variants, builtin_id_declarations,
defined_function_variants, builtin_id_declarations, builtin_id_definitions, builtin_id_definitions, defined_parameter_names,
defined_parameter_names, variable_declarations, function_declarations, variable_declarations, function_declarations,
script_generated_hash_tests, get_builtin_if_statements, is_in_group_definitions) script_generated_hash_tests, unmangled_script_generated_hash_tests,
get_builtin_if_statements, is_in_group_definitions)
parameter_declarations = prune_parameters_arrays(parameter_declarations, function_declarations) parameter_declarations = prune_parameters_arrays(parameter_declarations, function_declarations)
for group_name, group in parsed_variables.iteritems(): for group_name, group in parsed_variables.iteritems():
count_variable_names(group, variable_name_count) process_variable_group('NONE', group_name, group, builtin_id_declarations,
for group_name, group in parsed_variables.iteritems():
process_variable_group('NO_CONDITION', group_name, group, builtin_id_declarations,
builtin_id_definitions, name_declarations, init_member_variables, builtin_id_definitions, name_declarations, init_member_variables,
get_variable_declarations, get_builtin_if_statements, get_variable_declarations, get_builtin_if_statements,
declare_member_variables, variable_declarations, declare_member_variables, variable_declarations,
get_variable_definitions, variable_name_count) get_variable_definitions, script_generated_hash_tests)
output_strings = { output_strings = {
'script_name': 'script_name':
...@@ -1668,32 +1942,48 @@ def main(): ...@@ -1668,32 +1942,48 @@ def main():
'\n'.join(sorted(get_variable_declarations)), '\n'.join(sorted(get_variable_declarations)),
'get_variable_definitions': 'get_variable_definitions':
'\n'.join(sorted(get_variable_definitions)), '\n'.join(sorted(get_variable_definitions)),
'unmangled_builtin_declarations':
'\n'.join(sorted(unmangled_builtin_declarations)),
'declare_member_variables': 'declare_member_variables':
'\n'.join(declare_member_variables), '\n'.join(declare_member_variables),
'init_member_variables': 'init_member_variables':
'\n'.join(init_member_variables), '\n'.join(init_member_variables),
'get_unmangled_builtin': 'mangled_array':
unmangled_function_if_statements.get_switch_code(hashfn, script_generated_hash_tests), get_builtin_if_statements.get_array(),
'get_builtin': 'unmangled_array':
get_builtin_if_statements.get_switch_code(hashfn, script_generated_hash_tests), unmangled_function_if_statements.get_array(unmangled_builtin_declarations),
'max_unmangled_name_length': 'max_unmangled_name_length':
unmangled_function_if_statements.get_max_name_length(), unmangled_function_if_statements.get_max_name_length(),
'max_mangled_name_length': 'max_mangled_name_length':
get_builtin_if_statements.get_max_name_length(), get_builtin_if_statements.get_max_name_length(),
'num_unmangled_names':
num_unmangled_names,
'num_mangled_names':
num_mangled_names,
'unmangled_builtin_declarations':
'\n'.join(sorted(unmangled_builtin_declarations)),
'script_generated_hash_tests': 'script_generated_hash_tests':
'\n'.join(script_generated_hash_tests.iterkeys()), '\n'.join(script_generated_hash_tests.iterkeys()),
'S1': 'unmangled_script_generated_hash_tests':
str(S1).replace('[', ' ').replace(']', ' '), '\n'.join(unmangled_script_generated_hash_tests.iterkeys()),
'S2': 'mangled_S1':
str(S2).replace('[', ' ').replace(']', ' '), str(mangled_S1).replace('[', ' ').replace(']', ' '),
'G': 'mangled_S2':
str(G).replace('[', ' ').replace(']', ' '), str(mangled_S2).replace('[', ' ').replace(']', ' '),
'NG': 'mangled_G':
len(G), str(mangled_G).replace('[', ' ').replace(']', ' '),
'NS': 'mangled_NG':
len(S1) len(mangled_G),
'mangled_NS':
len(mangled_S1),
'unmangled_S1':
str(unmangled_S1).replace('[', ' ').replace(']', ' '),
'unmangled_S2':
str(unmangled_S2).replace('[', ' ').replace(']', ' '),
'unmangled_G':
str(unmangled_G).replace('[', ' ').replace(']', ' '),
'unmangled_NG':
len(unmangled_G),
'unmangled_NS':
len(unmangled_S1)
} }
with open('ImmutableString_autogen.cpp', 'wt') as outfile_cpp: with open('ImmutableString_autogen.cpp', 'wt') as outfile_cpp:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment