src/compiler/translator/SymbolTable.cpp


Log

Author Commit Date CI Message
Kimmo Kinnunen 12584049 2024-10-21T14:04:55 Make SimplifyLoopConditions testable Add ShCompileOptions::simplifyLoopConditions, so that tests can turn it on. Later edits to simplify loop condition logic are simpler to review when the testing related edits are landed separately. Test the feature by having ESSL as the input and ESSL as the natural output, to reflect how AST changes. To make the test expectations more deterministic across code changes, change SymbolTable::kLastBuiltInId to SymbolTable::kFirstUserDefinedSymbolId. This is simpler as no code needs to know exact last built in id, so we can just ensure that the user defined symbol ids do not clash with the builtin ids. Bug: angleproject:374585769 Change-Id: Iea0efb8ac2878691d0fd5ff5cfe9a49ac754515d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5946724 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Shahbaz Youssefi a8138547 2024-10-09T23:33:24 Translator: Support GL_ARM_shader_framebuffer_fetch_depth_stencil Bug: angleproject:352364582 Change-Id: I46ce6d75a76bdf04a9e8feea1a480e8a0badba2a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5924140 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi b16d105f 2024-10-03T10:25:32 Remove Desktop GL front-end support For Desktop GL applications, please use Zink! Bug: angleproject:370937467 Change-Id: Ie734634bb62a2e98c80e1b32d8b3d34624da3c04 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5905428 Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 96f44329 2024-03-25T14:16:10 Revert "Remove few redundant ImmutableString to std::string conversions" This reverts commit ebb94b807f184f2d36cb0843c429667cd80e0675. Reason for revert: Needs a different implementation of std::string::size() to pass C++17 compilers. Original change's description: > Remove few redundant ImmutableString to std::string conversions > > Maybe removes few strlen calls. > > Bug: angleproject:8614 > Change-Id: I4fbb5f6abb8e8d21ff44a34975bab379127a0a11 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5372715 > Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> > Commit-Queue: Geoff Lang <geofflang@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> Bug: angleproject:8614 Change-Id: I1a635b74674a2e1b635972bb4372c43340527a2f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5391900 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Kimmo Kinnunen ebb94b80 2024-03-16T09:11:51 Remove few redundant ImmutableString to std::string conversions Maybe removes few strlen calls. Bug: angleproject:8614 Change-Id: I4fbb5f6abb8e8d21ff44a34975bab379127a0a11 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5372715 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Sean Risser b96d1955 2023-01-20T16:06:34 Implement GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch allows fragment shaders to read gl_LastFragColorARM. The extension is similar to GL_EXT_shader_framebuffer_fetch, but is more limited in its capabilities. GL_ARM_shader_framebuffer_fetch was removed from HasFramebufferFetch() because it acts differently from GL_EXT_shader_framebuffer_fetch in significant enough ways that it should not be included in that single-use function. Tests: FramebufferFetchES31.*_ARM Bug: b/242419750 Bug: angleproject:7882 Change-Id: Id3a25c8ee50ca3e2a4c30a2261f507b0b53511ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4083108 Commit-Queue: Sean Risser <srisser@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi ebe943e2 2021-07-29T11:19:33 Vulkan: SPIR-V Gen: Fix gl_Clip/CullDistance These built-ins can be redeclared in the shader. The translator took these redeclarations (and gl_LastFragData) as UserDefined symbols. There were a number of hacks such as in name generation and CollectVariables, to special-case these redeclarations. This change instead makes sure that these variables continue to be considered built-ins with the appropriate qualifiers. A number of fixes are made accordingly: - Hacks are removed. - In fragment shaders, ANGLEClipDistance was initialized with gl_ClipDistance for further use by the shader. The code generation however mistakenly produced `gl_ClipDistance[0] = ANGLEClipDistance[0];`, which caused compilation failures by glslang, but passed the tests accidentally because they expected link failures (see next item). - CollectVariables is fixed to correctly collect gl_Clip/CullDistance in fragment shaders; previously they were collected as output varyings, and therefore the aforementioned link error was not produced in the tests after the compilation error was fixed. Additional fixes: - The transformation of gl_Clip/CullDistance was always ever done on one of them due to misplaced breaks in the loop that detected their presence. - The transformation of gl_CullDistance was skipped when it was not redeclared. Validation is added to make sure these built-ins always have the correct qualifier even when redeclared. SPIR-V gen support for these variables have been fixed as well. Bug: angleproject:4889 Change-Id: Ic8bf2c508357035cb937ef41a28ae22ffc533ebe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3059921 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 8b869a95 2021-06-13T01:09:27 Translator: Generate Ops for all built-in functions EOpCallBuiltInFunction is removed in this change, as well as the "op": "auto" property in builtin_function_declarations.txt. Instead, gen_builtin_symbols.py automatically generates Ops for every built-in function and generates the TOperator enum accordingly. This simplifies SPIR-V code generation by allowing switches to be used on operators instead of string comparisons. Bug: angleproject:4589 Bug: angleproject:4889 Change-Id: Ia351524400b0e12a10a5572e27e9b88c6ec2e61c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2958869 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill e670fc72 2021-01-18T15:51:42 Implement shader compiler changes for Tessellation. Numerous rule changes to support validating Tessellation Control and Evaluation shaders. New per-patch inputs and output variable support. Includes a new traverser step that validates barrier function calls. Functionality changes upcoming in http://crrev.com/c/2568234 Bug: angleproject:3572 Change-Id: If8da1c21d30efa12c60ed0d6c3f8cf0b27e4c86f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633936 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com>
Geoff Lang 7e815c77 2020-07-08T13:43:40 Implement EXT_shadow_samplers Bug: angleproject:4863,b/161716126 Change-Id: I6beb45d91f59a851787c9f40b40266fb985198d5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2288330 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: back sept 10 - Jamie Madill <jmadill@chromium.org>
Jamie Madill 155947fc 2019-10-24T12:55:11 Enable "-Wconditional-uninitialized". This is a final warning used by Skia. Bug: angleproject:4046 Change-Id: I3970e30e4bd2aef07cddadd7322ef120ac857493 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1877481 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>
Tobin Ehlis e9421b2c 2019-04-08T15:16:56 Vulkan:Only apply invariant pragma to output vars The "#pragma STDGL invariant(all)" directive should only be applied to shader output vars. This change also removes the workaround SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT which is no longer needed. This change fixes two tests that were incorrectly assuming that the pragma would be applied to inputs: GLSLTest.InvariantAll[Both|In]. Bug: angleproject:1293 Bug: angleproject:3285 Change-Id: I4eb03fa89fbc7c560150ee0cc32382024b0cb3e3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1558678 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tobin Ehlis <tobine@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
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 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 c26214de 2018-03-16T10:43:11 Move AST utilities to a subdirectory Move AST related utilities to compiler/translator/tree_util. BUG=angleproject:2409 TEST=angle_unittests Change-Id: I7567c2f6f2710292029263257c7ac26e2a144ac8 Reviewed-on: https://chromium-review.googlesource.com/966032 Reviewed-by: Jamie Madill <jmadill@chromium.org> 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 e600c0aa 2018-03-02T11:23:29 Use non-human-readable mangled names for types The new mangled name format is as follows: The first character is a hex digit from 0 to F that encodes vector or matrix size. For scalars, structs etc. the character is 0. Then, if it's a struct, the mangled name continues with "{s", followed by mangled names of fields, and ends with "}". If it's an interface block, the mangled name continues with "{i", followed by mangled names of fields, and ends with "}". If it's anything else, the second alphabetic character encodes the basic type. Characters are assigned to basic types in the enumeration order. If it's an array, the mangled name has a suffix [array_size]. This saves a few kilobytes from the binary size. The effect on symbol lookup speed seems mostly marginal. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I26e65dcb48c3478df9a719ffff9c15f2fd12e293 Reviewed-on: https://chromium-review.googlesource.com/945910 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
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 f7f0b8c3 2018-02-21T20:02:23 Rename operator enums so they can be autogenerated Camel casing is removed from the enums where it differs from the GLSL spec. This way it's easier to autogenerate code for built-in functions mapped to operators. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I2490d5d0e8ffb45eba343f225f76779e63381a65 Reviewed-on: https://chromium-review.googlesource.com/929361 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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 029e8ca7 2018-02-16T14:06:49 Add a constexpr constructor for TFunction Access to TFunction parameters is now handled through two new members: a pointer to a parameter array and a parameter count. There's still also a vector pointer in TFunction for adding function parameters one by one. This is used when parsing user-defined functions. TEST=angle_unittests BUG=angleproject:2267 Change-Id: I86987ae56b7cf37f010d0651e9861789050aec2b Reviewed-on: https://chromium-review.googlesource.com/923987 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b92f92a7 2018-02-15T19:14:59 Clean up dead insertion of unmangled symbols Unmangled names of built-ins are not inserted to the symbol table in a normal way, so the function to do that is not needed. BUG=angleproject:2267 TEST=compile ANGLE Change-Id: I68bae9a1f762ecc69ab31f04458a38c941b9d74c Reviewed-on: https://chromium-review.googlesource.com/922202 Reviewed-by: Jamie Madill <jmadill@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 2d8e432a 2018-01-22T14:12:46 Add ImmutableString to encapsulate some compiler strings The new ImmutableString class is intended to be used instead of plain const char pointers to pool-allocated or static memory. It has the following advantages over using plain const char pointers: 1. It makes it clear when a string is guaranteed to be safe to pass around inside the compiler. 2. It can be compared with a comparison operator rather than using strcmp, which is easier to read. 3. It records the length of the stored string, which enables faster copies and comparisons in some cases. 4. ImmutableStrings could be implicitly converted from std::strings when a pool-allocated string is required. This is robust and convenient. C++17 has a similar class std::string_view, but our code style doesn't allow it yet. We also couldn't use it as is if we require properties 1 and 4 from above, but would rather need to inherit or wrap it in a custom class. Eventually all current usage of TString could be replaced with ImmutableString. For now, use it for unmangled built-in names. TEST=angle_unittests BUG=angleproject:2267 Change-Id: Id60c7b544032e06460e1b99837e429bc84dc4367 Reviewed-on: https://chromium-review.googlesource.com/881020 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 68981eb5 2018-01-23T17:46:12 Track parameter qualifiers of functions in call nodes We now add a reference to TFunction to all TIntermAggregate nodes where it is possible, including built-in ops. We also make sure that internal TFunctions added in traversers have correct parameter qualifiers. This makes TLValueTrackingTraverser much simpler. Instead of storing traversed functions or looking up builtin functions from the symbol table, determining which function parameters are out parameters can now be done simply by looking it up from the function symbol associated with the aggregate node. Symbol instances are no longer deleted when a symbol table level goes out of scope, and TFunction destructor no longer clears the parameters. They're all either statically allocated or pool allocated, so this does not result in leaks. TEST=angle_unittests BUG=angleproject:2267 Change-Id: I57e5570da5b5a69a98a8778da3c2dc82b6284738 Reviewed-on: https://chromium-review.googlesource.com/881324 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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 bed35d76 2017-12-20T16:36:26 Don't query names of empty symbols This makes it possible to return a reference from TSymbol::name() instead of a pointer. This is safer since it completely avoids the possibility of a nullptr dereference. An assert is making sure that the function is not being called for empty symbols. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I44279f65989dbb828322843fc0216ba84d91dedf Reviewed-on: https://chromium-review.googlesource.com/836894 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 0c37100d 2017-12-13T17:00:25 Always create TFunctions for function call nodes This simplifies code and ensures that nodes get consistent data. In the future function call nodes could have a pointer to the TFunction instead of converting the same information into a different data structure. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: Ic0c24bb86b44b9bcc4a5da7f6b03701081a3af5c Reviewed-on: https://chromium-review.googlesource.com/824606 Reviewed-by: Jamie Madill <jmadill@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>
Kai Ninomiya 030017a4 2017-12-06T14:06:53 Mark StaticType related functions as constexpr Fixes compilation on some versions of GCC and probably Clang. Follow-up to http://crrev.com/c/786317 Bug: angleproject:1432 Change-Id: I3fc3ad0f65492f9543eb27fcdce6ca29a9ad06e5 Reviewed-on: https://chromium-review.googlesource.com/812220 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
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>
Kai Ninomiya 614dd0f5 2017-11-22T14:04:48 Replace TCache with static TType instances Replaces TCache with (static generation + static/dynamic lookups) of TType instances, using compile-time template and constexpr magic. Work started by jmadill here: https://crrev.com/c/776280 With more contributions from jmadill here: https://crrev.com/c/801494 Bug: angleproject:1432 Change-Id: I07181543f8fee4b2606cdd2d0738351e83d4ce57 Reviewed-on: https://chromium-review.googlesource.com/786317 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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>
Jamie Madill 902e8c18 2017-11-18T09:34:16 Reland "Make TType store a const char * for mangled name." This is a reland of dc7bffd06b526bbffd3d1c1ddbd6c763a2cc7287 Reland fixes the memory regression by not calling new, instead calling the pool allocator directly. Original change's description: > Make TType store a const char * for mangled name. > > We would only ever use the c_str value from the mangled name. This > makes it easier to make constexpr TTypes. > > Bug: angleproject:1432 > Change-Id: I147b3a85f9b8b2453e2d7f4a713d767b22036cc9 > Reviewed-on: https://chromium-review.googlesource.com/776277 > Commit-Queue: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Kai Ninomiya <kainino@chromium.org> Bug: angleproject:1432 Change-Id: I1aaeea883186b9061955d55f2fa77d27f5d9b725 Reviewed-on: https://chromium-review.googlesource.com/782406 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill c7965001 2017-11-20T23:29:11 Revert "Make TType store a const char * for mangled name." This reverts commit dc7bffd06b526bbffd3d1c1ddbd6c763a2cc7287. Reason for revert: Causes a memory leak, detected by ASAN bot: https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/494713 Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x847aa2 in operator new(unsigned long) /b/build/slave/linux_upload_clang/build/src/third_party/llvm/compiler-rt/lib/asan/asan_new_delete.cc:92:3 #1 0x193a833 in sh::TType::buildMangledName() const third_party/angle/src/compiler/translator/Types.cpp:545:21 #2 0x193d2e8 in getMangledName third_party/angle/src/compiler/translator/Types.cpp:751:24 #3 0x193d2e8 in sh::TType::realize() third_party/angle/src/compiler/translator/Types.cpp:759 #4 0x1834474 in sh::TCache::getType(sh::TBasicType, sh::TPrecision, sh::TQualifier, unsigned char, unsigned char) third_party/angle/src/compiler/translator/Cache.cpp:89:11 #5 0x1859ac7 in getType third_party/angle/src/compiler/translator/Cache.h:36:16 #6 0x1859ac7 in sh::InsertBuiltInFunctions(unsigned int, ShShaderSpec, ShBuiltInResources const&, sh::TSymbolTable&) third_party/angle/src/compiler/translator/Initialize.cpp:28 Bug: angleproject:1432 Original change's description: > Make TType store a const char * for mangled name. > > We would only ever use the c_str value from the mangled name. This > makes it easier to make constexpr TTypes. > > Bug: angleproject:1432 > Change-Id: I147b3a85f9b8b2453e2d7f4a713d767b22036cc9 > Reviewed-on: https://chromium-review.googlesource.com/776277 > Commit-Queue: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Kai Ninomiya <kainino@chromium.org> TBR=jmadill@chromium.org,kainino@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: angleproject:1432 Change-Id: Ib112a2ce9871a4f4afc53101ac1a3ddd166008cf Reviewed-on: https://chromium-review.googlesource.com/780420 Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill dc7bffd0 2017-11-18T09:34:16 Make TType store a const char * for mangled name. We would only ever use the c_str value from the mangled name. This makes it easier to make constexpr TTypes. Bug: angleproject:1432 Change-Id: I147b3a85f9b8b2453e2d7f4a713d767b22036cc9 Reviewed-on: https://chromium-review.googlesource.com/776277 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 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>
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 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 1ecd14b8 2017-01-26T13:54:15 Fold user-definedness of function nodes into TOperator Whether a function call is user-defined is not orthogonal to TOperator associated with the call node - other ops than function calls can't be user-defined. Because of this it makes sense to store the user- definedness by having different TOperator enums for different types of calls. This patch also tags internal helper functions that have a raw definition outside the AST with a separate TOperator enum. This way they can be handled with logic that is easy to understand. Before this, function calls like this left the user-defined bit unset, despite not really being built-ins either. The EmulatePrecision traverser uses this. This is also something that could be used to clean up built-in emulation in the future. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I597fcd9789d0cc22b689ef3ce5a0cc3f621d4859 Reviewed-on: https://chromium-review.googlesource.com/433443 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 9250cb24 2017-01-21T10:51:27 Add ESSL 3.10 integer math built-ins This adds built-ins found in ESSL 3.10 section 8.8 Integer functions. This includes constant folding support for functions that may be constant folded, and support for both GLSL and HLSL output. In HLSL several of the functions need to be emulated. The precision qualification for the return value of some of these functions is determined by special rules, that are now part of type promotion for TIntermUnary nodes and determining the type of TIntermAggregate nodes. BUG=angleproject:1730 TEST=angle_unittests TEST=dEQP-GLES31.functional.shaders.builtin_functions.integer.* Change-Id: Ib0056c17671c42b6496c2f0ef059b99f8f25c122 Reviewed-on: https://chromium-review.googlesource.com/431310 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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>
JiangYizhou 4021932f 2016-12-09T09:50:51 translator: Add ES3.1 multisample texture support. Implement shader objects, [iu]sampler2DMS, textureSize(gsampler2DMS). as well as texelFetch(gsampler2DMS,P,sample) for the glsl. BUG=angleproject:1590 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: I781023f7bec34ad0264af69f34bb182b50bd1fbd Reviewed-on: https://chromium-review.googlesource.com/423175 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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>
Martin Radev 2cc85b3b 2016-08-05T16:22:53 Add support for images in the compiler The patch adds support for GLSL ES 3.1 image types. Internal format layout qualifiers for images are added. Support for the readonly and writeonly qualifiers are added. The other memory qualifiers are omitted as to make the patch simpler. Tests are added which check for correct and incorrect usage of images, internal format layout and memory qualifiers. BUG=angleproject:1442 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: Ie4d3acb2a195de11b405ad54110a04c4c1de0b7e Reviewed-on: https://chromium-review.googlesource.com/378855 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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 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>
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 183d7e24 2015-11-20T15:59:09 Remove predefined precision qualifiers from ESSL3 samplers New sampler types in ESSL3 should not have default precision qualifiers. This is specified in ESSL 3.00.4 section 4.5.4. BUG=angleproject:1222 TEST=angle_unittests Change-Id: I9c8e7a5fbb4278db80de79bcaeebaf23e64242a0 Reviewed-on: https://chromium-review.googlesource.com/312048 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Cooper Partin 149e6e69 2015-08-07T16:18:18 Fixed compiler warning C4458 'declaration of variable hides class member'. BUG=angleproject:1119 Change-Id: Ibc7cfdea72abe402cbfa1c10e0ada7576fa1cfa2 Reviewed-on: https://chromium-review.googlesource.com/292052 Tested-by: Cooper Partin <coopp@microsoft.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
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 01971113 2015-07-10T14:54:00 Cache TTypes. *re-land with build fix for Win/Release* This change saves us ~70KiB per compiler with just ~3KiB of cache. BUG=492725 Change-Id: I4382c55b2480f70b00c5d117fcb7e0c51d0dfbb4 Reviewed-on: https://chromium-review.googlesource.com/284735 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Dmitry Skiba <dskiba@google.com> Reviewed-by: Alexis Hétu <sugoi@chromium.org>
Jamie Madill 53b76107 2015-07-10T18:52:58 Revert "Cache TTypes." Unused variable warning in Release: warning C4189: 'MaxEnumValue' : local variable is initialized but not referenced I'll handle fixing this. BUG=492725 This reverts commit b25d14e4b39ee273fad3bb585c3a3a929b3f794c. Change-Id: I502fc5288d5d3c48ecd43f84acdf66b7e300ad22 Reviewed-on: https://chromium-review.googlesource.com/284863 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Dmitry Skiba b25d14e4 2015-06-23T17:43:14 Cache TTypes. This change saves us ~70KiB per compiler with just ~3KiB of cache. BUG=492725 Change-Id: I7b8053c032c9c68f646162baf61abf6db3afe52e Reviewed-on: https://chromium-review.googlesource.com/284003 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@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>
Jamie Madill 2f232370 2015-07-07T21:57:55 Revert "Cache TTypes." Lots of compile errors. BUG=492725 This reverts commit 5377720aae042c5bfae0e8a37032c90dc3ab78cf. Change-Id: I64889b99b1f1f48d39b87ebb668f6a32a3abac45 Reviewed-on: https://chromium-review.googlesource.com/283945 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Dmitry Skiba 5377720a 2015-06-23T17:43:14 Cache TTypes. This change saves us ~70KiB per compiler with just ~3KiB of cache. BUG=492725 Change-Id: I2ee748f7271b1afe0834083cbff6f0b84104aa53 Reviewed-on: https://chromium-review.googlesource.com/281411 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Dmitry Skiba <dskiba@google.com>
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>