src/compiler/translator/SymbolTable.h


Log

Author Commit Date CI Message
Jamie Madill 68945f1c 2019-10-24T12:55:09 Enable "-Wredundant-parens". This one is also required by Skia. It's purely for consistency and code readability. Bug: angleproject:4046 Change-Id: I9ed418a0bf6c7661f0970fef6da7088ca6ae6204 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1877478 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill a905cbcd 2019-09-19T23:05:39 Compact built-in symbol table. Should reduce the binary size bloat from the perfect hashing. Local testing on Windows shows a significant size reduction. Bug: chromium:998535 Change-Id: I411cc5a917036d2239d15353d760f44e40faa26c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1814725 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill c37d2370 2019-09-19T18:54:40 Reland "Refactor built-in symbol table." This is a reland of 59d982c0dcad580ccbf4e29f32ffa3ea9a280122 Original change's description: > Refactor built-in symbol table. > > In preparation for reducing binary size. Shortend a bunch of strings > and symbol prefixes so the autogen file will be more compact. > > Bug: chromium:998535 > Change-Id: If1bedaaacc06dce9678d432055ffa0c9215a8dbd > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1814724 > Reviewed-by: Tim Van Patten <timvp@google.com> > Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> > Commit-Queue: Jamie Madill <jmadill@chromium.org> Bug: chromium:998535 Change-Id: Iebc5b1b5e1a084257fba3c50026cc62df5a879b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1817499 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Zhenyao Mo f585c2fb 2019-09-21T02:12:37 Revert "Refactor built-in symbol table." This reverts commit 59d982c0dcad580ccbf4e29f32ffa3ea9a280122. Reason for revert: crbug.com/1006501 Original change's description: > Refactor built-in symbol table. > > In preparation for reducing binary size. Shortend a bunch of strings > and symbol prefixes so the autogen file will be more compact. > > Bug: chromium:998535 > Change-Id: If1bedaaacc06dce9678d432055ffa0c9215a8dbd > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1814724 > Reviewed-by: Tim Van Patten <timvp@google.com> > Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> > Commit-Queue: Jamie Madill <jmadill@chromium.org> TBR=timvp@google.com,jonahr@google.com,jmadill@chromium.org Change-Id: Ie540da8ea4429e075a3284183e5a004cbcf1307b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:998535,chromium:1006501 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1817497 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 59d982c0 2019-09-19T18:54:40 Refactor built-in symbol table. In preparation for reducing binary size. Shortend a bunch of strings and symbol prefixes so the autogen file will be more compact. Bug: chromium:998535 Change-Id: If1bedaaacc06dce9678d432055ffa0c9215a8dbd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1814724 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Clemen Deng 56db3789 2019-08-01T17:09:53 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: Geoff Lang <geofflang@chromium.org>
Clemen Deng 486f381f 2019-07-18T15:47:31 Add desktop GL built-in functions to symbol table Added GL built-in functions to symbol table autogeneration Built-in lookup now checks against spec and returns GL symbols when appropriate. Bug: angleproject:3719 Change-Id: I74786150f6063b40e13aebcb2eb9ea35e4ecaa53 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1731550 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Clemen Deng <clemendeng@google.com>
Stuart Morgan 9d737966 2019-08-14T12:25:12 Standardize copyright notices to project style For all "ANGLE Project" copyrights, standardize to the format specified by the style guide. Changes: - "Copyright (c)" and "Copyright(c)" changed to just "Copyright". - Removed the second half of date ranges ("Y1Y1-Y2Y2"->"Y1Y1"). - Fixed a small number of files that had no copyright date using the initial commit year from the version control history. - Fixed one instance of copyright being "The ANGLE Project" rather than "The ANGLE Project Authors" These changes are applied both to the copyright of source file, and where applicable to copyright statements that are generated by templates. BUG=angleproject:3811 Change-Id: I973dd65e4ef9deeba232d5be74c768256a0eb2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1754397 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Clemen Deng 592539fd 2019-07-10T13:15:59 Implicit conversions for Desktop GL shaders Need to support implicit conversions between types for GL shaders Other small fixes to support GL shaders Bug: angleproject:3673 Change-Id: I5341cb7195054ccc4cd36aad5dc8c801c7e1a14f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1698649 Commit-Queue: Clemen Deng <clemendeng@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 84c11c53 2018-07-11T10:12:39 Vulkan: Implement sampler structs as function args. Bug: angleproject:2494 Change-Id: Ia8e374846427b7140ab2565ae5b9b18409a76d96 Reviewed-on: https://chromium-review.googlesource.com/1117323 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 71a151fd 2018-06-26T16:07:42 Vulkan: Use TSymbolTable in ExtractStructSamplers. This will enable more code reuse when handling sampler struct as function arguments. We can add the sampler structs to the symbol table stack when they are function arguments. Bug: angleproject:2494 Change-Id: I9eeb1d3822e34cd43535e1b16a98864545755d22 Reviewed-on: https://chromium-review.googlesource.com/1117322 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 76b2c385 2018-03-19T15:51:29 Store invariant declarations in variable metadata This is simpler than storing the information in symbol table levels. Invariant declarations can only be present at the global scope, so storing the information per level is not required. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Idb07d734950c8a0a8bda5b2380e181902f9eb633 Reviewed-on: https://chromium-review.googlesource.com/1007060 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 59c5b897 2018-04-03T11:44:50 Validate gl_FragData and gl_FragColor access after parsing After this simply declaring both variables invariant is not treated as static use. This simplifies ParseContext a bit, but the effect on compiler performance tests seems marginal. BUG=angleproject:2450 TEST=angle_unittests Change-Id: Ib90cb1d2bd1331542d1cd37732f24efb7833036a Reviewed-on: https://chromium-review.googlesource.com/992112 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 94bbed1e 2018-03-20T14:44:53 Collect static use information during parsing We now collect metadata for variables in the symbol table. The metadata is stored in a map using the variable unique id as a key, so we can store the variables themselves as constexpr while still having dynamic metadata. For now we collect whether a variable is statically read or written. This can be used to more accurately determine whether a variable is statically used, but can also enable more optimizations in the future, such as pruning variables that are never read or folding variables that are never written after initialization. The collection is done during parsing, so that nothing is pruned from the AST before the static use is recorded. Static writes are flagged in ParseContext::checkCanBeLValue, as that function is already called for all variables that are written. Static reads are flagged whenever there's an operation that requires a variable to be read. This includes: * Unary and binary math ops * Comma ops * Ternary ops * Assignments * Returning the variable * Passing the variable as an in or inout argument to a function * Using the variable as a constructor argument * Using the variable as an if statement condition * Using the variable as a loop condition or expression * Using the variable as an index * Using the variable as a switch statement init expression In case there are statements that simply refer to a variable without doing operations on it, the variable is being treated as statically read. Examples of such statements: my_var; my_arr[2]; These are a bit of a corner case, but it makes sense to treat them as static use for validation purposes. Collecting correct static use information costs us a bit of compiler performance, but the regression is on the order of just a few percent in the compiler perf tests. BUG=angleproject:2262 TEST=angle_unittests, angle_end2end_tests Change-Id: Ib0d7add7e4a7d11bffeb2a4861eeea982c562234 Reviewed-on: https://chromium-review.googlesource.com/977964 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 115b2c4a 2018-03-15T17:46:29 Remove desktop GLSL builtins from symbol lookups Desktop GLSL builtins can be accessed through functions in BuiltIn_autogen.h. They don't need to be included in symbol table lookups. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I8ba188a0d2584353e34159c2732c9e2bd420c168 Reviewed-on: https://chromium-review.googlesource.com/964447 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b391ec40 2018-03-12T17:04:59 Generate code for looking up built-ins Instead of storing built-ins in a std::unordered_map, we now generate a series of switch statements using the hash value of the look-up string. This works similarly to earlier implementation of looking up unmangled built-ins. Those built-ins that need to be initialized at run-time are stored as member variables of TSymbolTable. This increases compiler init performance significantly, as well as increasing compiler perf test scores around 1-2%. Binary size is larger than before though. BUG=angleproject:2267 TEST=angle_unittests Change-Id: If1dcd36f0d2b30c2ed315cdcf6e831ae9fe70c94 Reviewed-on: https://chromium-review.googlesource.com/960031 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 391bda23 2018-02-23T11:43:14 Generate code for initializing built-in variables gen_builtin_symbols.py now generates code for initializing built-in variable symbols as well. Some of the variable symbols are static, but some of them also get initialized dynamically based on values in ShBuiltInResources. The static symbols have get functions in a header file so they can be referenced from AST traversers as well without doing a lookup. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: Ida7f3aeb06d2bce0f737f1483b1bd5833aeddd2e Reviewed-on: https://chromium-review.googlesource.com/911768 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 065aa863 2018-02-22T15:30:27 Generate code for unmangled name lookup Instead of using an std::map at each symbol table level, use the gen_builtin_symbols.py script to build a function to query unmangled names. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I4f1cf1df1f50fe9d909f3249150ee002ee6efb61 Reviewed-on: https://chromium-review.googlesource.com/931885 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 140152e7 2018-02-08T14:46:44 Statically allocate built-in function symbols A script gen_builtin_symbols.py now generates code for initializing built-in function symbols. The TFunction objects are initialized at C++ compile time. The source file used for the functions is in a format that's similar to how functions are given out in the GLSL spec, so it is easy to maintain. The function symbols are still inserted to the symbol table levels same as before. Getting rid of inserting the symbols at runtime is intended to be done as follow-up. This speeds up angle_unittests on Linux in release mode by a bit less than half, and in debug mode by more than half. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I11c9de98c74d28e7e8cdf024516e2f6ee30ca33e Reviewed-on: https://chromium-review.googlesource.com/924155 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 437664b4 2018-02-28T15:38:14 Clean up TSymbolTable entry points TSymbolTable API can be cleaned up further now that we have separate logic for inserting builtins and user-defined symbols. BUG=angleprojec:2267 TEST=angle_unittests Change-Id: I7a228891ecdf4696e50868b9e7dfc2a50b5d8e92 Reviewed-on: https://chromium-review.googlesource.com/941301 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 7c8567a3 2018-02-20T15:44:07 Always add most extension symbols to symbol table An error will be generated either way if the extension symbols are used incorrectly since each use of an extension function or variable checks whether the extension is enabled. We now also track extension in unmangled built-in names, so that redefining built-ins of extensions that are not enabled can be supported. This includes refactoring the shader extension tests to share a common helper class ShaderExtensionTest. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I9cc5e9bd62fa07796e69256a6a9a493531a62446 Reviewed-on: https://chromium-review.googlesource.com/926526 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho e80825ef 2018-02-16T10:24:53 Simplify built-in function node initialization Built-ins with no math op associated with them now have the op code EOpCallBuiltInFunction set. This makes initializing built-in function nodes simpler, since they can always get the op code from the function symbol. We also no longer look for functions in inner scopes, only from the global scope and from built-in functions. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I55a2642f34bb3c8b8f13183c95fa509ec3b9cfdb Reviewed-on: https://chromium-review.googlesource.com/923724 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho defe3937 2018-02-13T11:56:09 Store invariant varying names as ImmutableString This gets rid of a few extra ImmutableString to std::string conversions which makes the code clearer. There doesn't seem to be any significant effect on performance. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I36ebbc8a4130ab8f9d6194feca83ec5dcbc95f78 Reviewed-on: https://chromium-review.googlesource.com/916141 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho e5fe7aad 2018-01-29T12:06:11 Store builtin symbols as const pointers To do this we need two types of symbol table levels: A level for built-ins and a level for user-defined symbols. User-defined symbols are non-const because function symbols created based on function prototypes are changed when the function definition is parsed. On the other hand, we want to make built-in symbols constexpr, so we should only handle them through const pointers. This also gets rid of extra empty precision stack levels. Only one level is needed to store predefined precisions. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I9f14b24c2cfce272f22c16e7a8dfb653b849cbeb Reviewed-on: https://chromium-review.googlesource.com/892879 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 29bda815 2018-01-26T17:37:36 Move symbol table initialization to SymbolTable.cpp This is needed in order to make symbol table symbols statically allocated. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ia2d44fb30d49dc5d5c67643fe01280c89127a3c3 Reviewed-on: https://chromium-review.googlesource.com/889299 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho fbb1c792 2018-01-19T16:26:59 Store symbol names as a ImmutableString This will enable compile-time initialization of built-in symbols as well as reducing copying strings. Most of the code that deals with names is changed to use ImmutableString where it makes sense to avoid conversions. The lexer/parser now allocate const char pointers into pool memory instead of allocating TStrings. These are then converted to ImmutableString upon entering TParseContext. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: I244d6271ea1ecf7150d4f89dfa388a7745a1150c Reviewed-on: https://chromium-review.googlesource.com/881561 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 37b697ed 2018-01-29T12:19:27 Only return symbol from TSymbolTable::find Whether the symbol is built-in can be easily determined from the SymbolType stored in the symbol, it doesn't need to be returned separately. The sameScope value that could be returned from TSymbolTable::find was never used, so that can be removed as well. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I06958741ebec67d496f830a83b4f6f1359632f45 Reviewed-on: https://chromium-review.googlesource.com/891021 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho dd21ecf8 2018-01-10T12:42:09 Add const qualification to symbol accesses All accesses to built-in symbols now happen through const-qualified pointers. This also encapsulates TSymbolTableLevel inside TSymbolTable. This prepares for statically allocating built-in symbols. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I473014d978daa765b4a733d761d6c08b28288776 Reviewed-on: https://chromium-review.googlesource.com/859959 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 342b83d4 2018-01-10T13:24:01 Don't copy unmangled built-in names This optimizes memory and CPU use of symbol table initialization. This was measured to make a debug build of angle_unittests run around 10% faster on Windows. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Icd5272c6cfc0d5122550c403621bfa5944c92a83 Reviewed-on: https://chromium-review.googlesource.com/859958 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b60d30f7 2018-01-16T12:31:06 Make TVariable type immutable This enables using constexpr types for built-in variables and some of the variables created in AST transformations. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ie85b3c9872a071a7c023ced013b14ad91cff7cee Reviewed-on: https://chromium-review.googlesource.com/868134 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 2c9cc8b6 2018-01-09T16:13:02 Don't duplicate symbol type information in AST nodes Function prototype nodes and symbol nodes already refer to symbols that have type information, so the type doesn't need to be copied to the TInterm* AST node classes. Now type is only stored in those AST node classes that represent other types of expressions. They use a new TIntermExpression base class for this. Since now we may use the TType from builtin symbols directly instead of copying it, building the mangled names of types in the correct memory pool is also required. The code now realizes the types of built-in variables when they get added to the symbol table. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ic8d7fc912937cb8abb1e306e58c63bb9c146aae9 Reviewed-on: https://chromium-review.googlesource.com/857005 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho d4529f30 2017-12-12T13:06:40 Define symbol classes in a separate file The plan is to use symbols more also outside the symbol table, so it makes sense to define the symbol classes in a separate header file. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I94167415ef43ba9bd9126ca32d9c498e1437f3f8 Reviewed-on: https://chromium-review.googlesource.com/822414 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ae4dbf32 2017-12-08T20:49:00 Don't allocate name strings for empty symbols This removes unnecessary memory allocations. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ide575ea19ab2f8e9fc93092490f1352efa6024a3 Reviewed-on: https://chromium-review.googlesource.com/817415 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 195be942 2017-12-04T23:40:14 Always create TVariables for TIntermSymbol nodes TIntermSymbol nodes are now constructed based on a specific TVariable. This makes sure that all TIntermSymbol nodes that are created to refer to a specific temporary in an AST transform will have consistent data. The TVariable objects are not necessarily added to the symbol table levels - just those variables that can be referred to by their name during parsing need to be reachable through there. In the future this can be taken a step further so that TIntermSymbol nodes just to point to a TVariable instead of duplicating the information. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I4e7bcdb0637cd3b588d3c202ef02f4b7bd7954a1 Reviewed-on: https://chromium-review.googlesource.com/811925 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 9d4d7f06 2017-12-07T17:11:41 Classify TSymbols using an enum Symbols can be either built-ins, user-defined, nameless, or for ANGLE's internal use. In addition we currently use TFunction symbols that are not yet resolved - they might later resolve to either a built-in or a user-defined function. Record this information in each TSymbol so that TSymbol contains sufficient information for deciding how to format symbol names in output. The goal is to eventually replace current uses of TName with pointers to different TSymbol objects. So far only built-ins and user-defined symbols have associated TSymbol objects, but that will be expanded to cover ANGLE's internal symbols as well. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I927ce023fe257cc236da82c127700f3bd72bfe96 Reviewed-on: https://chromium-review.googlesource.com/816952 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho d5f1afb5 2017-12-04T15:42:59 Make TSymbol immutable There's still an exception for changing the names of structures, but otherwise the data stored in the TSymbol base class is never changed. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I5b3f44cd365320ad09b46d2cfa3654a7d3f4bbc3 Reviewed-on: https://chromium-review.googlesource.com/806556 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 378c3a51 2017-12-04T11:32:13 Clean up storing interface blocks in the symbol table Merge TInterfaceBlock with TInterfaceBlockName, so that there are no duplicate data structures for interface blocks. This is similar to the refactoring that was already done to structs. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I67d2af6ccbe5344bddf9c99030d118fe532fbbd8 Reviewed-on: https://chromium-review.googlesource.com/805819 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 035419fa 2017-11-28T14:27:15 Clean up storing struct types in the symbol table Instead of storing struct symbols as TVariable objects, store them as TStructure objects. This way struct type symbols don't need to store bogus data that's associated with arbitrary types, and on the other hand the name and unique id of struct types are only stored in a single place. This change is a refactoring with no effect on generated output. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I173793e0cc77a890cdac6868d72d9f275ac9461a Reviewed-on: https://chromium-review.googlesource.com/793814 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 5d69db12 2017-11-24T16:51:15 Reset symbol unique id counter between compilations This guarantees identical compilation results on different compilations using the same compiler instance, guards against overflow, and is useful as a building block for tracking more symbol information in the symbol table. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ib5a7cec2fff6712ead969d935d238d28a87fd4a7 Reviewed-on: https://chromium-review.googlesource.com/796795 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 54a29ffd 2017-11-28T17:35:20 Refactor TSymbol to follow naming conventions This will make it easier to make TStructure inherit from TSymbol. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I73a5a25234c7f965b6970891821ee9d6f0a23aca Reviewed-on: https://chromium-review.googlesource.com/793812 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Kai Ninomiya d4556dfc 2017-09-27T16:45:22 Reland 'Adds TUnorderedMap and uses it for tLevel in TSymbolTableLevel.' Reland of https://crrev.com/c/526672 Bug: 697758 Change-Id: I410e4774c4ad85595eb8789603901878b209c857 Reviewed-on: https://chromium-review.googlesource.com/688296 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Olli Etuaho 2d88e9bc 2017-07-21T16:52:03 Guarantee that symbol nodes get unique ids The code is refactored so that symbol nodes can only be initialized with an unique id object. This prevents accidentally forgetting to create an id for a symbol node. This opens up possibilities for future optimization: For example the names and types of symbols could be stored in a central location inside the SymbolTable, and TIntermSymbol nodes would only need to store the symbol id. The symbol id could be used to look up the name and type of the node. BUG=angleproject:1490 TEST=angle_unittests Change-Id: Ib8c8675d31493037a5a28c7b36bb9d1113cc10f6 Reviewed-on: https://chromium-review.googlesource.com/580955 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 2a1e8f95 2017-07-14T11:49:36 Refer to GLSL extensions through TExtension enum Extensions are now referred to by enum values instead of strings most of the time. This gets rid of unnecessary copying of strings. The code is easier to work with than before as typoing the extension enum names will be caught by the compiler. BUG=angleproject:2147 TEST=angle_unittests Change-Id: Ifa61b9f86ef03211188fc23bc23a5ce4e4d8c390 Reviewed-on: https://chromium-review.googlesource.com/571002 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiawei Shao d27f5c8d 2017-08-23T09:38:08 ES31: Implement GL_OES_geometry_shader built-ins in GLSL compiler This patch intends to implement all built-in constants, variables and functions defined in OpenGL ES 3.1 extension GL_OES_geometry_shader in ANGLE GLSL compiler. 1. Add all built-in constants defined in GL_OES_geometry_shader. 2. Add built-in functions EmitVertex() and EndPrimitive() required in Geometry Shader. 3. Add built-in variables gl_PrimitiveIDIn and gl_InvocationID to Geometry Shader. 4. Add built-in variables gl_PrimitiveID and gl_Layer to both Geometry Shader and Fragment Shader when GL_OES_geometry_shader is enabled. BUG=angleproject:1941 TEST=angle_unittests Change-Id: I92821553ed0efee2ccb77fead6e065e7799819d0 Reviewed-on: https://chromium-review.googlesource.com/627670 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jiawei Shao d8105a03 2017-08-08T09:54:36 ES31: Implement gl_in in Geometry Shader This patch intends to implement geometry shader built-in interface block instance gl_in defined in GL_OES_geometry_shader. 1. Add the definition of gl_in and its interface block gl_PerVertex into the symbol table. 2. Support gl_Position as a member of gl_in. 3. Set the array size of gl_in when a valid input primitive type is known. 4. Add check that it should be a compile error to index gl_in or call length() on gl_in without a valid input primitive declaration. This patch also adds unit tests to cover all these new features. BUG=angleproject:1941 TEST=angle_unittests Change-Id: I8da20c943b29c9ce904834625b396aab6302e1e1 Reviewed-on: https://chromium-review.googlesource.com/605059 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 977ee7eb 2017-07-21T11:38:27 Add gl_ViewportIndex to the symbol table gl_ViewportIndex is a GLSL built-in that's needed to implement instanced multiview. It is a bit of a special case: it only exists in desktop GLSL and not ESSL, and it shouldn't be exposed to the parser. We add a new level to the symbol table that's hidden from the parser to make adding this kind of builtins in AST transforms consistent with the way ESSL builtins are supported. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I51b2d983950b38c8e85e4b6ed00c6b39f9b3cb03 Reviewed-on: https://chromium-review.googlesource.com/580953 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho a5e693af 2017-07-13T16:07:26 Make unique id counter a member of TSymbolTable This makes unique id counting thread-safe. BUG=angleproject:624 TEST=angle_unittests Change-Id: Ie0f2c7e574470b39750d37d2181c790bc874b275 Reviewed-on: https://chromium-review.googlesource.com/570419 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 0f68463f 2017-07-13T12:42:15 Clean up inserting variables to symbol table This makes the TSymbolTable interface cleaner and prepares for making unique id counting thread-safe. BUG=angleproject:624 TEST=angle_unittests Change-Id: Ief99c9fc777603de28ba1517e351bc8a00633590 Reviewed-on: https://chromium-review.googlesource.com/570418 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Yuly Novikov af01a064 2017-06-28T00:16:27 Revert "Adds TUnorderedMap and uses it for tLevel in TSymbolTableLevel." This reverts commit c14348a2589e5d995f63019433175545ba90040b. Reason for revert: crashes in murmurhash on Nexus 6 See https://build.chromium.org/p/chromium.gpu.fyi/builders/Android%20Release%20%28Nexus%206%29/builds/7865 Original change's description: > Adds TUnorderedMap and uses it for tLevel in TSymbolTableLevel. > > Change-Id: I27ba7a41c599ef6f7fe68b22c27bd2a40175ddf9 > Reviewed-on: https://chromium-review.googlesource.com/526672 > Commit-Queue: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> TBR=jmadill@chromium.org,kbr@chromium.org,bajones@chromium.org,kainino@chromium.org,lethalantidote@chromium.org Change-Id: Id4a428430c6d286b910790ba7c30503c98ce728f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/551235 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
CJ Dimeglio c14348a2 2017-06-05T23:03:28 Adds TUnorderedMap and uses it for tLevel in TSymbolTableLevel. Change-Id: I27ba7a41c599ef6f7fe68b22c27bd2a40175ddf9 Reviewed-on: https://chromium-review.googlesource.com/526672 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho cce8965d 2017-06-19T16:04:09 Remove most of the remaining logic from glslang.y Move most of the logic in glslang.y to ParseContext. This will make it easier to change the code in the future. Only a few specific bits of logic are kept in glslang.y: * Disabling a parsing rule when a given shading language version is being parsed. This makes it easier to check the grammar against the grammar in the GLSL ES specs. * Scoping calls that need to be paired with another call. It's much easier to check these for correctness when the paired calls are next to each other. BUG=angleproject:911 TEST=angle_unittests Change-Id: I52f42a1fc0f28463ca4b237dc6e88345e5173064 Reviewed-on: https://chromium-review.googlesource.com/539640 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Yunchao He 4f285443 2017-04-21T12:15:49 Refactoring: replace NULL by nullptr for pointers (2nd CL). This CL mainly handles the pointer comparisons (== or !=). BUG=angleproject:2001 Change-Id: I25ac3b61032e7ad91459a1c6541cadc87cf9b160 Reviewed-on: https://chromium-review.googlesource.com/483935 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho f2209f74 2017-04-01T12:45:55 Clean up function name mangling code Fix a few incorrect comments about mangled names, and refactor generating mangled names from function call nodes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I3ee68c4c0982f1a9c28d8e87aafa19f19559bbf8 Reviewed-on: https://chromium-review.googlesource.com/465826 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ec9232bd 2017-03-27T17:01:37 Store unmangled function names in the AST This makes the code simpler across the board. There are a few cases where mangled names still need to be generated in AST traversers, but they are outweighed by much leaner output code for all function nodes. BUG=angleproject:1490 TEST=angle_unittests, angle_end2end_tests Change-Id: Id3638e0fca6019bbbe6fc5e1b7763870591da2d8 Reviewed-on: https://chromium-review.googlesource.com/461077 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho fe48632f 2017-03-21T09:30:54 Prefer identifying functions by using symbol ids The shader translator code is now structured in a way that ensures that all function definition, function prototype and function call nodes store the integer symbol id for the function. This is guaranteed regardless of whether the function node is added while parsing or as a result of an AST transformation. TIntermAggregate nodes, which include function calls and constructors can now only be created by calling one of the TIntermAggregate::Create*() functions to ensure they have all the necessary properties. This makes it possible to keep track of functions using integer ids instead of their mangled name strings when generating the call graph and when using TLValueTrackingTraverser. This commit includes a few other small cleanups to the CallDAG class as well. BUG=angleproject:1490 TEST=angle_unittests, angle_end2end_tests Change-Id: Idd1013506cbe4c3380e20d90524a9cd09b890259 Reviewed-on: https://chromium-review.googlesource.com/459603 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho af6fc1b4 2017-01-26T17:45:35 Make aggregate node creation more robust Now aggregate nodes are always built with their return type, op and arguments set. They'll determine their qualifier and precision automatically. This fixes setting of gotPrecisionFromChildren in a few cases. This will also make it easier to split TIntermAggregate further into specialized classes if that is desired. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I1fbe0c75679c517a22d44dfc1ea160ad7a7fdfda Reviewed-on: https://chromium-review.googlesource.com/433468 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 01d0ad08 2017-01-22T14:51:23 Add symbol table function to get TFunction for a built-in op Built-in function parameter qualifiers are stored in the symbol table. Some AST traversers need the qualifier information for ops to determine whether a node is being written to. Add an utility function that maps a TIntermAggregate node to a symbol table entry, so that the traversers can get to this information in a convenient way. This will be necessary for adding more built-ins that have out parameters from ESSL 3.10. BUG=angleproject:1730 TEST=angle_unittests Change-Id: I4bc622d70b2326a04cc858ff1258c22320c590dc Reviewed-on: https://chromium-review.googlesource.com/431109 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 492cfab2 2017-01-20T21:18:29 Use GetOperatorString when initializing symbol table This will make it easier to add more built-in functions. BUG=angleproject:1730 TEST=angle_unittests Change-Id: I5219a83e964b6ee15c690e108313960a873dd8e5 Reviewed-on: https://chromium-review.googlesource.com/431031 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Martin Radev d7c5b0aa 2016-07-27T14:04:43 Add support for barriers in the compiler The patch adds support for barriers in vertex, fragment and compute shaders. BUG:angleproject:1442 TEST:angle_unittests Change-Id: Ic85c3337911851a93a3f56bd935774181600eddd Reviewed-on: https://chromium-review.googlesource.com/380641 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Martin Radev da6254bf 2016-12-14T17:00:36 Keep track of shader built-in declarations separately per ESSL version The patch decouples the list of unmangled built-ins' names into levels based on the ESSL version they are from. This is required because ESSL31 and above built-ins' names should not conflict with user-declared functions in ESSL3 shaders. BUG=angleproject:1666 TEST=angle_unittest Change-Id: I731918a058629c7b6d9d15eb7eac19ce47280315 Reviewed-on: https://chromium-review.googlesource.com/420324 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill d7b1ab58 2016-12-12T14:42:19 Fix up translator style. Using git cl format. BUG=angleproject:650 Change-Id: I7d3f98d2b0dcfb0a8de6c35327db74e55c28d761 Reviewed-on: https://chromium-review.googlesource.com/419059 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Zhenyao Mo d7490967 2016-11-09T15:49:51 Fix linkage.html failures on Mac. The failure is due to when we initialize variables to 0, we re-create the struct TType, and it contains a different unique id from the original struct TType, thus leading to a different hashed name. BUG=chromium:641129 TEST=webgl_conformance,webgl2_conformance Change-Id: I267b97fa496f55ea59dacee93af8f6a90f3e66cb Reviewed-on: https://chromium-review.googlesource.com/409602 Commit-Queue: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 45bcc784 2016-11-07T13:58:48 translator: Scope all classes with "sh". I was seeing an odd problem with our PoolAlloc conflicting with the glslang/Vulkan TIntermNode, so the fix was to move everything to a separate namespace. The bison grammars are also regenerated. No functional changes. BUG=angleproject:1576 Change-Id: I959c7afe4c092f0d458432c07b4dcee4d39513f3 Reviewed-on: https://chromium-review.googlesource.com/408267 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 476197f9 2016-10-11T13:59:08 Clean up TSymbol initialization Now TSymbol objects always get their id when they are constructed. The id cannot be changed after the TSymbol is created. This makes it simpler to insert both mangled and unmangled versions of a function to the symbol table. These can now both share the same TSymbol object, unlike before, when inserting the same symbol twice would have changed its symbol id. This requires changes to function definition parsing: function definition nodes now share any symbol created by previous prototype declarations of the function. The parameters on the symbol get set to the parameters in the function definition header. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I8e600e9b5e5de27d64b85c5042cfd23ff02abe63 Reviewed-on: https://chromium-review.googlesource.com/396838 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Martin Radev 4a9cd800 2016-09-01T16:51:51 Refactor type_specifier_nonarray parsing to reduce code repetition When type_specifier_nonarray gets parsed the scope gets saved into TType and the code becomes repetitive. Setting of the scope is moved to type_specifier_no_prec as it occurs less times. BUG=angleproject:911 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: I6da5fe7bc2d60ba2996221af71b719b818f5e9b1 Reviewed-on: https://chromium-review.googlesource.com/380535 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Qiankun Miao f69682be 2016-08-16T14:50:42 Add unittests to verify invariant doesn't leak This is a followup CL of https://chromium-review.googlesource.com/366720. Unittests is added to check invariant status does not leak across shaders. This CL also moves mInvariantVaryings and mGlobalInvariant from TSymbolTable to TSymbolTableLevel. So at the end of a compilation, the levels pop, and the settings will be cleared and will not affect the next compilation. Change-Id: I1199fade7a637276ab149ab9a599621b9977298b Reviewed-on: https://chromium-review.googlesource.com/370844 Commit-Queue: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Qiankun Miao 583c4d2a 2016-08-05T17:58:40 Invariant qualifier should not leak across shaders Change-Id: I2a35899bffd28767b8bc638f415857636d4ad8ef Reviewed-on: https://chromium-review.googlesource.com/366720 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Martin Radev e93d24ef 2016-07-28T12:06:05 Add es3.1 shader constants The patch adds all shader built-in constants. BUG=angleproject:1442 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: I81cae479d6506a8faa2dce023d5fcc2c1291d521 Reviewed-on: https://chromium-review.googlesource.com/364460 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Kenneth Russell 8bad46d4 2016-07-01T19:52:52 The global invariant pragma must not leak across compilations. BUG=chromium:625363 TEST=conformance/glsl/bugs/global-invariant-does-not-leak-across-shaders.html Change-Id: I66389352b92211f4d7967772f68470c8e93405bd Reviewed-on: https://chromium-review.googlesource.com/358515 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Zhenyao Mo 7e1200b4 2016-07-05T02:25:13 Revert "The global invariant pragma must not leak across compilations." This reverts commit ae2e19188cf0a9b035a27143f585df10e72ffabd. Change-Id: I017ba4ba9baa633793d7bdd9691c580ed7016cde Reviewed-on: https://chromium-review.googlesource.com/358410 Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Kenneth Russell ae2e1918 2016-07-01T19:52:52 The global invariant pragma must not leak across compilations. BUG=chromium:625363 TEST=conformance/glsl/bugs/global-invariant-does-not-leak-across-shaders.html Change-Id: Ie8d38e44837fc87bb4c94e76e779ad41e8b79957 Reviewed-on: https://chromium-review.googlesource.com/358203 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho c4a96d67 2015-07-23T17:37:39 Names of built-in functions cannot be redeclared as functions With ESSL 3.00, names of built-in functions cannot be redeclared as functions, and therefore an error needs to be generated if a built-in function is overloaded. This is fixed by inserting unmangled built-ins into a special set in the symbol table and checking if function declarations match any of the built-ins in the set. The regular symbol table structures can't be used for storing the unmangled names because that interferes with name hashing in OutputGLSL. Credit goes to Arun Patole, apatole@nvidia.com for initially investigating this issue and developing the first version of the patch. BUG=angleproject:1066 TEST=angle_unittests, dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function* (2 tests started passing with this change) Change-Id: I28c8325f5a3a8f4a97226b0dfdbb9762724fa609 Reviewed-on: https://chromium-review.googlesource.com/328994 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 5d653186 2016-01-04T14:43:28 Disallow multiple function prototypes in ESSL 1.00 The same function can't be declared twice in ESSL 1.00. In ESSL 3.00 this is allowed. A function prototype following the definition of that function is not interpreted as redeclaration, and the shader compiler continues to allow this. BUG=angleproject:1067 TEST=angle_unittests, dEQP-GLES2.functional.shaders.functions.invalid.double_declare* Change-Id: I6d2ddafd456d378d92839600f19069ad1cd19aff Reviewed-on: https://chromium-review.googlesource.com/320082 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 0980e29d 2015-11-20T14:57:34 Don't accept default precision for uint Default precision can only be specified for float, int and sampler types. Default precision for int also applies to uint and uvec declarations. BUG=angleproject:1221 TEST=angle_unittests Change-Id: I31fdcde80da16e2ea8771838f7c1a6ab4e478194 Reviewed-on: https://chromium-review.googlesource.com/313314 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 5c0e023c 2015-11-11T15:55:59 Qualify stored constant union data with const This prevents accidentally changing data that may be shared between multiple TIntermConstantUnion nodes. Besides making the code less prone to bugs in general, this will make it easier to implement constant folding of array constructors. BUG=541551 TEST=angle_unittests, WebGL conformance tests Change-Id: I4f3059f70b841d9dd0cf20fea4d37684da9cd47e Reviewed-on: https://chromium-review.googlesource.com/312440 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez e5a1f271 2015-08-21T02:58:25 Use override in all the places where it is possible This will avoid -Winconsistent-overrides in the future. Done using the -Wsuggest-override warning of GCC 5.1 BUG= Change-Id: I707a649dc368f5dd1e139fd144370abcac0b6263 Reviewed-on: https://chromium-review.googlesource.com/294920 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Kimmo Kinnunen b18609b9 2015-07-16T14:13:11 Implement ES 2,3 parts of EXT_blend_func_extended for shader translation Exposes gl_SecondaryFragColor, glSecondaryFragData[] and gl_MaxDualSourceDrawBuffers to GLES SL 1.0. Relaxes rules for undefined output locations for GLES SL 3.0 and exposes gl_MaxDualSourceDrawBuffers. If the output GL context is GL ES 2.0 or 3.0: The emulation layer is expected to turn on EXT_blend_func_extended if the output GL context supports it. If the output GL context is GL: The emulation layer is expected to turn on EXT_blend_func_extended if the output GL context supports ARB_blend_func_extended or if GL context is 3.2 or later. If the source shader spec is GLES SL 2.0: The emulation layer is expected to inspect the shader compilation output variables upon linking. If output target is GL SL, the emulation layer should bind color location 0, index 1 to "angle_SecondaryFragColor" if variable "gl_SecondaryFragColorEXT" is used. Alternatively, emulation layer should bind "angle_SecondaryFragData" to locations 0,1,2,3,..., all color index 1, if "gl_SecondaryFragData" array is used. (The caller can not bind the locations or specify output variables.) If the source shader spec is GLES SL 3.0: The emulation layer is expected to do location auto-resolve of the the output variables that have undefined output locations that have not been bound by the caller. (The caller can not use gl_ built-ins, so nothing to do with those.) BUG=angleproject:1085 TEST=angle_unittest Change-Id: I5cafe205b0c29478b0dcd24aa89a7b0000f5d046 Reviewed-on: https://chromium-review.googlesource.com/287580 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Kimmo Kinnunen <kkinnunen@nvidia.com>
Geoff Lang 13e7c7e6 2015-07-30T14:17:29 Revert "Names of built-in functions cannot be redeclared as functions" Causing failures in the WebGL1 test: conformance/glsl/misc/shader-with-non-reserved-words.html This reverts commit b5f88853ea80ea112368bb15999b363db0e4c648. Change-Id: I2105c8040057665abda00435e8c0ff8a83af3645 Reviewed-on: https://chromium-review.googlesource.com/289192 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Arun Patole b5f88853 2015-07-23T17:37:39 Names of built-in functions cannot be redeclared as functions With ESSL 3.00, names of built-in functions cannot be redeclared as functions and therefore overloading or redefining builtin functions is an error. This is fixed by inserting unmangled built-ins into the symbol table and then checking if the new function declaration matches any of the built-in in symbol table. BUG=angleproject:1066 TEST=angle_unittests(new: ParseESSLFunctionsTest), dEQP Tests dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function* (2 tests started passing with this change) Change-Id: I0e027e588664e604f29c130028178315c3e21631 Reviewed-on: https://chromium-review.googlesource.com/287801 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Dmitry Skiba 58832204 2015-07-06T16:11:13 Calculate TFunction::mangledName lazily. This saves us ~15KiB per compiler instance on 32-bit Android. BUG=492725 Change-Id: I9db2998482941b5ab2eb5cb4925cbd1fb58ab4be Reviewed-on: https://chromium-review.googlesource.com/283584 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Dmitry Skiba 7f17a50c 2015-06-22T15:08:39 Store TFunction::returnType by a const pointer. On 32-bit Android this change saves ~30KiB per compiler instance. BUG=492725 Change-Id: I8bea48d57ee7eac0a0ee417035085c0d335aea09 Reviewed-on: https://chromium-review.googlesource.com/281047 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Dmitry Skiba <dskiba@google.com>
Dmitry Skiba efa3d8eb 2015-06-22T14:52:10 Change TSymbolTable::insertBuiltIn() TType* pointers to const. Const types make it possible to implement caching and other optimizations. BUG=492725 Change-Id: I64398bb9effcc909dd052a038acbb5ec0ca730e8 Reviewed-on: https://chromium-review.googlesource.com/281046 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Dmitry Skiba <dskiba@google.com>
Jamie Madill 6ba6eadc 2015-05-04T14:21:21 Rename ConstantUnion to TConstantUnion. This clarified that we're using the Pool allocator/deallocator for this type. BUG=angleproject:993 Change-Id: If8c95f6054d07291e7014be0d4e35766ba2e943b Reviewed-on: https://chromium-review.googlesource.com/269131 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill f0d10f89 2015-03-31T12:56:52 Replace non-copyable macro with a helper class. This class provides a simpler scheme for blocking default copy and assignment operators. It also reduces the amount of code needed since it's inherited to child classes. This also fixes the conflict between our macro and the same-named macro in Chromium code. BUG=angleproject:956 Change-Id: If0dc72aa3f63fbc7b8fa34907418821c64c39e2f Reviewed-on: https://chromium-review.googlesource.com/263257 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org>
Olli Etuaho b2983c95 2015-03-18T14:02:46 Correctly insert unmangled function names to symbol table This fixes detecting some cases of function parameter mismatch (previously a mangled function name corresponding to no function parameters was added to the symbol table for each user-defined function, and this was returned when doing function lookups with no parameters). Also fixes detection of reusing a function name as a variable/struct name. New unit tests are added to ensure that these fixes don't regress. BUG=angleproject:936 TEST=angle_unittests, WebGL conformance tests Change-Id: I2dadde9dcc01c7a4a653c1982c36377b89e6d437 Reviewed-on: https://chromium-review.googlesource.com/260800 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens c9d9b30a 2015-02-20T23:02:15 Set symbol extension at insertion. BUG=angle:926 Change-Id: I4c96ae89c79d720d99bde803541c3158ba4629ab Reviewed-on: https://chromium-review.googlesource.com/251662 Tested-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Nicolas Capens 482907eb 2015-02-23T16:56:33 Set symbol operations at insertion. BUG=angle:926 Change-Id: Ifc8f62ebe1277214a4d3fbd5c56eb5faeff8e389 Reviewed-on: https://chromium-review.googlesource.com/251650 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 2c43325d 2014-12-03T12:36:54 Fix double delete with invariant varyings. The compiler would leave some TString variables lying around after the pool gets released, leading to a potential crash. BUG=angle:846 Change-Id: I484ed9b14bba9bf653f6ed4001ae79f87791b0dd Reviewed-on: https://chromium-review.googlesource.com/232780 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Geoff Lang 0a73dd85 2014-11-19T16:18:08 Fix include guards. BUG=angle:733 Change-Id: I08b2c11c4831f1161c178c1842b10e807185aced Reviewed-on: https://chromium-review.googlesource.com/230831 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Zhenyao Mo 94ac7b78 2014-10-15T18:22:08 Invariant related processing. * Fix a bug in PreProcessor for STDGL pragma. * Record all invariant settings and set them in ShaderVariable. * Write #pragma STDGL invariant(all) in GL BUG=angle:776 TEST=https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/shaders-with-invariance.html Change-Id: Ie28b75480deed79f0c9f26e3b98f1778d1290182 Reviewed-on: https://chromium-review.googlesource.com/223610 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Gus Fernandez 964df49d 2014-10-13T11:54:39 Fix a crash with the WebGL conformance test suite. Undefined behavior caused by an overflowed enum was causing the translator symbol table stack to not get popped correctly when the compiler completed, causing dangling symbols who's storage was reclaimed and reused when the allocation pool was popped. The error occurred in the "shader-with-reserved-words" test, which passes when the compiler fails due to the use of reserved words as identifiers. As such, this test would pass even if the GPU process crashes but further tests in the test suite would fail. BUG=angle::785, 786 Change-Id: I365cb55f962f8dfe409f40532effeb10b8189432 Reviewed-on: https://chromium-review.googlesource.com/223093 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Gus Fernandez <gusfernandez@chromium.org>
Jamie Madill b1a85f48 2014-08-19T15:23:24 Rename compiler intermediate source files. This prevents confusion between "TIntermediate" and "TIntermNode". BUG=angle:711 Change-Id: Ib7a086382a479db3f77bf2ab06ce321aa7b35d13 Reviewed-on: https://chromium-review.googlesource.com/212936 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Zhenyao Mo e740addb 2014-07-18T17:01:01 Add compiler option SH_REGENERATE_STRUCT_NAMES. BUG=angle:701 TEST=webgl conformance tests Change-Id: I13b35900956e7d840d5891a5bab90a400347cd6f Reviewed-on: https://chromium-review.googlesource.com/209229 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Nicolas Capens adfffe46 2014-06-17T02:13:36 Duplicate reused symbol table entries. BUG=angle:651 Change-Id: Ifce3c19d41a0a5a5ca5ee90ede528adf397d1da5 Reviewed-on: https://chromium-review.googlesource.com/204290 Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Jamie Madill 01f85ac8 2014-06-06T11:55:04 Refactor GLSL scoped structure handling. With a unique ID, similar to how we handle scoped structures in the HLSL translator, we can simplify the declared structure check. BUG=angle:618 Change-Id: I5fe61c8d353650ac67a7c7ecdf53a70b91a9b717 Reviewed-on: https://chromium-review.googlesource.com/202500 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill bfa91f47 2014-06-05T15:45:18 Redesign HLSL scoped structures to a unique ID. A unique ID gives a more flexible renaming scheme than our current method of using nested scope identifiers. The reduced complexity allows for fewer points of breakage and fixes an outstanding bug with scoped structures (with added test). BUG=angle:618 Change-Id: I6551248bb9fa2d185ab67248721f898dd50151f0 Reviewed-on: https://chromium-review.googlesource.com/202183 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Zhenyao Mo 9eedea03 2014-05-12T16:02:35 Fix code styles in OutputGLSLBase, SymbolTable, and Types. I came across these three classes in the last CL, so do some cleanup as I touched these classes. BUG= TEST=webgl conformance, no regressions Change-Id: I2819bab5965fcb4917f85c2eded571a7f95ab9a2 Reviewed-on: https://chromium-review.googlesource.com/199423 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Zhenyao Mo ed14b79d 2014-05-08T11:21:07 Shaders should fail compile if a boolean's precision is specified Tested and no regression on WebGL conformance 1.0.3 BUG=angle:628 BUG=368874 TEST=http://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/boolean_precision.html Change-Id: Ie74616c3ab846eea19f4bd4a041fc0f00d55f151 Reviewed-on: https://chromium-review.googlesource.com/198884 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 10567260 2014-04-17T16:40:00 Fix build with Clang. Clang's validation is a bit more thorough than GCC's or MSVC's and picked up a few new errors and warnings. We missed a few default cases in switches and used an improper type for default arguments. BUG=angle:568 Change-Id: I34239c6c5c785ad1e62917fc37c3243f4c5b5f1b Reviewed-on: https://chromium-review.googlesource.com/195472 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>