src/compiler/translator/ParseContext.cpp


Log

Author Commit Date CI Message
Qin Jiajia 19f2f9eb 2018-12-07T15:10:48 Mark variable to call 'length()' as statically used Bug: angleproject:3008 Change-Id: I8779706c667f49fddb0a741f5bf31c4af54db3e7 Reviewed-on: https://chromium-review.googlesource.com/c/1367404 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jiajia Qin <jiajia.qin@intel.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>
Geoff Lang 6aab06e0 2018-11-20T14:04:11 Don't allow unary operators on void types. BUG=900058 Change-Id: Ice8976ddd9cbc9c90162cf7fae2b8f91ddcfcef3 Reviewed-on: https://chromium-review.googlesource.com/c/1344590 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Jamie Madill c3bef3e7 2018-10-03T07:35:09 Allow 'defined' in define in non-WebGL. This is needed to pass dEQP conformance. Several of the harder dEQP tests around this behaviour are excluded from the mustpass list. This is presumably because the behaviours weren't implemented portably. Nevertheless we need to support conformant behaviour for GLES 2.0 Contexts for the most simple uses. This also leaves the error behaviour intact for WebGL specs. Bug: angleproject:1335 Change-Id: Ia80b4f71475efa928488ee6c2ee35c566d4602d4 Reviewed-on: https://chromium-review.googlesource.com/c/1242013 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 1dfd8ae2 2018-10-01T15:59:59 Improve test coverage of constant folding Clean up some TODOs in the code as well as add tests to make sure that ANGLE treats expressions indexing into constant arrays as constant expressions in different contexts. This complements the existing tests in ConstantFoldingTest. BUG=angleproject:2298 TEST=angle_unittests Change-Id: I779bf03891f7d06f14d293e69101c05d7dbf57b6 Reviewed-on: https://chromium-review.googlesource.com/1254067 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho a78092cb 2018-09-26T14:16:13 Support ESSL 3.00 EXT_blend_func_extended shaders This adds support for the index layout qualifier that's used in EXT_blend_func_extended to set whether a fragment output should be bound to the primary or secondary blend source color. Output locations are now validated correctly so that two outputs can have the same location as long as they have a different index. Some tests are fixed to allow this. BUG=angleproject:1085 TEST=angle_unittests Change-Id: I1de3ad1406398952287791eca367562bed59d380 Reviewed-on: https://chromium-review.googlesource.com/1245982 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jiawei Shao a6a7842f 2018-06-28T08:32:54 ES31: Support atomic functions on D3D11 - Part I This patch is the first one of the implementation of atomic functions in D3D11. There are mainly two differences in the usage of GLSL and HLSL atomic functions: 1. All GLSL atomic functions have return values, which all represent the original value of the shared or ssbo variable; while all HLSL atomic functions don't, and the original value can be stored in the last parameter of the function call. 2. For HLSL atomic functions, the last parameter that stores the original value is optional except for InterlockedExchange and InterlockedCompareExchange. Missing original_value in the call of InterlockedExchange and InterlockedCompareExchange results in a compile error from HLSL compiler. To handle these differences, we plan to implement the translation in two steps: 1. Support direct translations from GLSL atomic functions to HLSL ones. Direct translation can only handle the following two situations: (1) The sentence is a GLSL atomic function call without requesting a return value and it is not atomicExchange or atomicCompSwap: e.g. GLSL: atomicAdd(mem, value); -> HLSL: InterlockedAdd(mem, value); (2) The sentence is a simple assignment expression: its right is a GLSL atomic function call and its left is a declared variable. e.g. GLSL: oldValue = atomicAdd(mem, value); -> HLSL: InterlockedAdd(mem, value, oldValue); 2. Support atomic functions in the situations that don't support direct translations. We will modify the intermediate tree to make direct translation work on all these situations. e.g. atomicExchange(mem, value); -> int oldValue; oldValue = atomicExchange(mem, value); int oldValue = atomicAdd(mem, value); -> int oldValue; oldValue = atomicAdd(mem, value); return atomicAdd(mem, value); -> int temp; temp = atomicAdd(mem, value); return temp; for (i = 0; i < atomicAdd(mem, value); ++i) -> int temp; temp = atomicAdd(mem, value); for (i = 0; i < temp; ++i) { ... temp = atomicAdd(mem, value); } int result = isTrue ? atomicAdd(mem, value) : 0; -> int result; if (isTrue) { result = atomicAdd(mem, value); } else { result = 0; } This patch completes Step 1 which mainly focus on the translation from GLSL atomic functions to HLSL ones. BUG=angleproject:2682 TEST=angle_end2end_tests Change-Id: I3b655b6e286dad4fd97f255f7fe87521c94db30c Reviewed-on: https://chromium-review.googlesource.com/1121835 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill b779b12c 2018-06-20T11:46:43 Add kEmptyImmutableString. We can use this instead of ImmutableString(""). Bug: angleproject:2665 Change-Id: I8b3d5d3075838b9f2caa1627071202e48a5fdc83 Reviewed-on: https://chromium-review.googlesource.com/1108085 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Luc Ferron <lucferron@chromium.org>
Olli Etuaho 1a3bbaa8 2018-01-25T11:41:31 Use ImmutableString instead of TString in QualifierTypes This avoids unnecessary pool allocations when generating errors. Most of the returned strings are static. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ia9b26898d499985d61e629fddde7aded4714eddf Reviewed-on: https://chromium-review.googlesource.com/885818 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 72e3589c 2018-06-20T11:43:08 Refactor debug output of types Instead of passing around strings from TType::getCompleteString(), add a stream operator to InfoSinkBase that takes a TType. This makes the compiler executable a few kilobytes smaller and will help with getting rid of TString altogether. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I31a6693b40a28824b3959e19ad3c0a2ce0f0a35f Reviewed-on: https://chromium-review.googlesource.com/1107712 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill f5557acc 2018-06-15T09:46:58 translator: Store symbol type in TField. This allows us to keep a separate symbol type for each field in a struct. This can allow us to assign internal names to struct types. It could also allow us to add internal fields to user defined stucts. Bug: angleproject:2665 Change-Id: I6a129107d9db66c54b98b07684c3ead5801712ba Reviewed-on: https://chromium-review.googlesource.com/1101565 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 50cf2be0 2018-06-15T09:46:57 Reformat some style in touched files. This was triggered by running the code generation script. Bug: angleproject:2665 Change-Id: Id639c78eb618182ee1859678590cf0f559b572c2 Reviewed-on: https://chromium-review.googlesource.com/1101564 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Luc Ferron <lucferron@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Geoff Lang 197d5294 2018-04-25T14:29:00 Wrap all preprocessor code in the angle namespace. BUG=836820 BUG=801364 Change-Id: I08b6a2f9f12b689e09df6efd916c313e71e8a051 Reviewed-on: https://chromium-review.googlesource.com/1028581 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
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 5fec7ab2 2018-04-04T11:58:33 Identify functions by unique id in BuiltInFunctionEmulator Now that unique ids of all builtins are compile-time constants, we can use them to look up functions in BuiltInFunctionEmulator. This is simpler than using a custom struct with the name and parameters for identifying functions. This requires that we store a reference to a TFunction in those TIntermUnary nodes that were created based on a function. This decreases shader_translator binary size by about 6 KB on Windows. BUG=angleproject:2267 BUG=chromium:823856 TEST=angle_unittests Change-Id: Idd5a00c772c6f26dd36fdbbfbe161d22ab27c2fe Reviewed-on: https://chromium-review.googlesource.com/995372 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 7b7d2e6a 2018-03-23T16:37:36 Remove createAssign: only called once This will make it easier to add tracking of static reads. BUG=angleproject:2262 TEST=angle_unittests Change-Id: I23e0587c022c45ac62434a2a0d8170e8978d1c24 Reviewed-on: https://chromium-review.googlesource.com/983916 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho daf120b4 2018-03-20T14:21:10 Clean up checkCanBeLValue Clarify the code so that it will be easier to add marking statically written variables here. BUG=angleproject:2262 TEST=angle_unittests Change-Id: I821bde29beb89e0f3b0f99dc187d2840f8cd0f9b Reviewed-on: https://chromium-review.googlesource.com/977963 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
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 d4bd963f 2018-03-08T16:32:44 Don't use TIntermSymbol nodes for function parameters Parameter nodes are not needed - it's simpler to just create a TVariable object for each parameter when the TFunction is initialized. With this change we also store only one object per each parameter type used in built-in functions, instead of one array of TConstParameter entries for each unique parameter sequence. This simplifies code and reduces binary size and compiler memory use. Compiler perf does not seem to be significantly affected. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I2b82400dd594731074309f92a705e75135a4c82c Reviewed-on: https://chromium-review.googlesource.com/955589 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 2bfe9f6b 2018-03-02T16:53:29 Use function id to group functions in ParseContext This way we can do numeric comparisons instead of string comparisons. The effect on compiler perf test scores is fairly marginal, but this reduces binary size by a few kilobytes, and there may be a larger effect on shaders calling a lot of texture functions. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I077db97b16b16b70b7e18ee037e06d7450d08dc9 Reviewed-on: https://chromium-review.googlesource.com/947952 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho d05f964b 2018-03-05T12:13:26 Last case in switch statement can't be empty in ESSL 3.10 This is based on recent discussion in Khronos, though public specs have not yet been updated to reflect this. BUG=angleproject:2388 TEST=angle_unittests Change-Id: I66a0d03b3c2bb9740772a813b543f8f6c6bb2a28 Reviewed-on: https://chromium-review.googlesource.com/947977 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 28cf920e 2018-03-02T15:54:56 Fix checking texture function offset There was a mistake in one of the texture offset function names being checked. Fix it and add a test making sure that a similar mistake cannot slip in again. BUG=angleproject:2387 TEST=angle_unittests Change-Id: I2dddfbdc2836f9e7e94ca6573a8f3689eecf7eb2 Reviewed-on: https://chromium-review.googlesource.com/946254 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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>
Qin Jiajia 76bf01d7 2018-02-22T14:11:34 Fix that readonly buffer variable can be assigned This change will add memory qualifier checking for binaryNode in case the memory qualifier information is lost. BUG=angleproject:1951 TEST=angle_unittests Change-Id: I3f0cfd7d8a059753cf3c982ee0a977b4b0fd0128 Reviewed-on: https://chromium-review.googlesource.com/929877 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@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 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 697bf65c 2018-02-16T11:50:54 Avoid redundant symbol lookup when parsing functions The lexical phase looks up symbols when it encounters an identifier. Instead of duplicating this work when parsing non-constructor functions, we now store the symbol looked up in the lexical phase in TFunctionLookup. This improves scores of the real world shader compiler perf test by 1-2%. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Idc99776571313d8b654910f9daaf9bf34a048228 Reviewed-on: https://chromium-review.googlesource.com/923725 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>
Nico Weber b5db2b49 2018-02-12T15:31:56 Enable -Wimplicit-fallthrough for ANGLE. Also teach MSVC that ANGLE_CRASH() can't return. Also fix instances of the warning in build configurations where UNREACHABLE() can return (e.g. release without dcheck_always_on or debug). If the UNREACHABLE()s are truly unreachable, this change has no behavior change. Bug: chromium:810767 Change-Id: I68f3587cf3e268c3ef634dce7ae3d70399859d0f Reviewed-on: https://chromium-review.googlesource.com/914842 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Commit-Queue: Nico Weber <thakis@chromium.org>
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>
Nico Weber 41b072b6 2018-02-09T10:01:32 Prepare for -Wimplicit-fallthrough in ANGLE. Disable the warning for flex-generated output, which contains lots of intentional fallthrough. Fixes a bug where GL_SAMPLE_ALPHA_TO_ONE_EXT would fall through to GL_COVERAGE_MODULATION_CHROMIUM and hence behave like that. Fixes a bug in the D3D9 state management where invalidating DIRTY_BIT_POLYGON_OFFSET would also invalidate the stencil bits. One somewhat common incorrect pattern in ANGLE is nested switch statements that look like so: switch (a) { case a1: switch (b) { case b1: ... break; } case a2: ... } The assumption here seems to be that the breakk exits the outer case (here a1), while it in fact only exits the inner switch, so that we fall through to a2. In most places, I fixed this by adding an explicit `break` after the inner switch. This fixes a bug wher GL_PATH_JOIN_STYLE_CHROMIUM would fall through to GL_PATH_MITER_LIMIT_CHROMIUM in validation (but since the join style enum is always > 0, this happened to not have an effect in practice). This also fixes 87 bugs in GetLoadFunctionsMap() where invalid values would previously return an unrelated function map instead of the empty load function map. Bug: chromium:810767 Change-Id: Ib51388c73fbfc229160e2c10f8fb9364cc7c996c Reviewed-on: https://chromium-review.googlesource.com/911529 Commit-Queue: Nico Weber <thakis@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
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 95ed1947 2018-02-01T14:01:19 Add a class for function lookups Using a purpose-built class for function lookups instead of using a combination of TFunction and a struct container for the this node and arguments makes the code clearer. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I3f345d836abeaa7f84cc46b4b840fd06c7e2e1a7 Reviewed-on: https://chromium-review.googlesource.com/897363 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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 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 0e99b7a3 2018-01-12T12:05:48 Prevent changing AST expression type from outside TIntermNode classes now contain all the logic for setting node types. Changing the constant values of constant union nodes from outside is also not necessary anymore. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ic10d41b1e5f93152df440a655057591dc1b783b0 Reviewed-on: https://chromium-review.googlesource.com/863626 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@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 ea22b7a5 2018-01-04T17:09:11 Constant fold array indexing and comparison A virtual function to get the constant value of an AST node is added to TIntermTyped. This way a constant value can be retrieved conveniently from multiple different types of nodes. TIntermSymbol nodes pointing to a const variable can return the value associated with the variable, constructor nodes can build a constant value from their arguments, and indexing nodes can index into a constant array. This enables constant folding operations on constant arrays, while making sure that large amounts of data are not duplicated in the output shader. When folding an operation makes sense, the values of the arguments can be retrieved by using the new TIntermTyped::getConstantValue(). When folding an operation would result in duplicating data, the AST can just be left to be written out as is. For example, if the code contains a constant array of arrays, indexing into individual elements of the inner arrays can be folded, but indexing the top level array is left in place and not replaced with duplicated array literals. Constant folding is supported for indexing and comparisons of arrays. In case constant arrays are only referenced through foldable operations, the variable declarations will be pruned from the AST by the RemoveUnreferencedVariables step. BUG=angleproject:2298 TEST=angle_unittests Change-Id: I5b3be237b7e9fdba56aa9bf0a41b691f4d8f01eb Reviewed-on: https://chromium-review.googlesource.com/850973 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho c74ec1a5 2018-01-09T15:23:28 Record gl_in array size in a symbol in ParseContext Instead of referring to the gl_in symbol in the symbol table, create a gl_in symbol with the right array size once the array size is known. This makes the type of TIntermSymbol nodes pointing to gl_in consistent with the variable type. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I31673d33526a91f8d069ee8d7d2f181a49665fd0 Reviewed-on: https://chromium-review.googlesource.com/857004 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 765924f0 2018-01-04T12:48:36 Fold ternary and comma ops only after parsing is done In case folding a ternary op or a comma op would change the qualifier of the expression, the folding is deferred to a separate traversal step. After this there are no more cases where the type of a TIntermSymbol node needs to differ from the type of the variable it is referring to. There are still some cases where some parts of TIntermSymbol type are changed while keeping the TVariable type the same though, like when assigning array size to gl_PerVertex nodes or sanitizing qualifiers of struct declarations. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: I1501c8d361f5f765f43ca810d1b7248d9e2c5986 Reviewed-on: https://chromium-review.googlesource.com/850672 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 8b5e8fdb 2017-12-15T14:59:15 Replace remaining usage of TName with TSymbol TName used to contain just a subset of the information stored in TSymbol. It makes more sense to use TSymbol directly instead of converting it to TName. This also improves type safety a bit by making some functions only take in TVariable or TFunction instead of the more generic TName. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Icb46923c25d33ebbbbc06ddc487da25957dda771 Reviewed-on: https://chromium-review.googlesource.com/829143 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiawei Shao 492b5f51 2017-12-13T09:39:27 ES31: Support struct arrays as Geometry Shader inputs This patch adds the support of struct arrays as valid geometry shader user-defined inputs. Struct arrays are accepted as geometry shader inputs to match the vertex shader outputs that are also declared as structs. BUG=angleproject:1941 TEST=angle_unittests Change-Id: I0b5d545b10e9dda576a1c96d7c93ec2450611e9e Reviewed-on: https://chromium-review.googlesource.com/823622 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
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 f095799b 2017-12-22T11:10:04 Fix accessing the name of a nested struct definition When generating an error message about the struct nesting limit, the code should make sure that the struct definitions are not nested. While nested struct definitions by themselves are also an error, they're not a syntax error so parsing will continue after encountering them. This fixes a regression from commit: Don't allocate name strings for empty symbols. BUG=chromium:797156 TEST=angle_unittests Change-Id: I4149fbe874c0e7ec90e690aec078ccaf7313eab0 Reviewed-on: https://chromium-review.googlesource.com/842643 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho b6af22b5 2017-12-15T14:05:44 Store TVariable* in TIntermSymbol instead of storing id This is an intermediate step to only storing a TVariable * in TIntermSymbol instead of copying the name. This makes it possible to get a constant value out of a TIntermSymbol without doing a symbol table lookup. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ibff588241a4ad4ac330063296273288b20a072c9 Reviewed-on: https://chromium-review.googlesource.com/829142 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho beb6dc74 2017-12-14T16:03:03 Always use TFunction instead of TFunctionSymbolInfo This reduces unnecessary memory allocations and conversions between different objects containing the same data. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I87316509ab1cd6d36756ff6af7fa2b5c5a76a8ea Reviewed-on: https://chromium-review.googlesource.com/827134 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 1bb8528c 2017-12-14T13:39:53 Remove TFunctionSymbolInfo from TIntermAggregate All the information stored in TFunctionSymbolInfo was duplicated from the TFunction that the aggregate node pointed to. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I1f5574ab0416e5cae00c3dae6fc11d2fe1fa128c Reviewed-on: https://chromium-review.googlesource.com/827065 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 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 a2d98141 2017-12-15T14:18:55 Fix allowing non-constant ternary global initializer Check the qualifier of a node resulting from the folding of a ternary node correctly. The folded node might even be a TIntermConstantUnion with a non-constant qualifier. BUG=angleproject:2285 TEST=angle_unittests Change-Id: I74516e44ce9d78bc54093a5b58d14cf33a57e6e5 Reviewed-on: https://chromium-review.googlesource.com/829138 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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>
Jiawei Shao bd924af1 2017-11-16T15:28:04 ES31: Remove support of GL_OES_geometry_shader in compiler This patch intends to remove the support of GL_OES_geometry_shader in ANGLE compiler. To make the implementation simpler, currently we decide to only support "GL_EXT_geometry_shader" as the extension string of geometry shader in ANGLE. This patch also updates all the related shaders in angle_unittests into R"()" format. BUG=angleproject:1941 TEST=angle_unittests Change-Id: Ife9858abeedfb46b02c5c2fb1cda16fa27198511 Reviewed-on: https://chromium-review.googlesource.com/773451 Commit-Queue: Corentin Wallez <cwallez@chromium.org> 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 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 12a18ad3 2017-12-01T16:59:47 Simplify interface block instance recording Instead of storing instance names as part of TInterfaceBlock, store instance names only in interface block instance symbols. Wherever the instance name is needed it can be fetched from the instance symbol. BUG=angleproject:2267 TEST=angle_end2end_tests Change-Id: Ia265e4db7901eebec57c9c3769d84c17651a35ba Reviewed-on: https://chromium-review.googlesource.com/803221 Reviewed-by: Jamie Madill <jmadill@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 d5f44c98 2017-11-29T17:15:40 Simplify parsing struct field declarators This removes the dummy type that was attached to struct declarators while parsing. This makes TParseContext::addStructDeclaratorList in particular simpler to understand. The new TDeclarator data type is the parsed representation of the struct_declarator grammar rule. It is completely immutable. The name and location stored in TField can also be qualified as constant now. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I2834f87fc0eee0bdb7673ef495a55fb463023c55 Reviewed-on: https://chromium-review.googlesource.com/797033 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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>
Olli Etuaho f13cadd8 2017-11-28T10:53:09 Fix checking negative index when indexing matrix/vector It's important that the test against the maximum of the valid range is only done if the index is positive, so the sanitized index value is guaranteed to end up in the valid range. This fixes a regression from commit "Add GLSL support for runtime-sized arrays in SSBOs". BUG=chromium:789029 TEST=angle_unittests Change-Id: Ic7125e383a64e46994b072df6d7e642432c521af Reviewed-on: https://chromium-review.googlesource.com/792935 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Kai Ninomiya 57ea533f 2017-11-22T14:04:48 TType: Store array sizes vector as a pointer. This makes TType a literal type, and thus is something that could be constexpr. Work started by jmadill here: https://crrev.com/c/776278 Bug: angleproject:1432 Change-Id: I707ddf81eaf029f49d62d2836b7166d265cbdfa1 Reviewed-on: https://chromium-review.googlesource.com/786316 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho ebee5b3b 2017-11-23T12:56:32 Add GLSL support for runtime-sized arrays in SSBOs The GLSL parser now allows a runtime-sized array as the last member in a shader storage block. Clamping indexing against the memory bounds is done by determining the array length at runtime. Runtime-sized arrays are used in dEQP tests for many compute shader tests, so these now work on the OpenGL backend. BUG=angleproject:1951 TEST=angle_unittests, dEQP-GLES31.functional.shaders.linkage.shader_storage_block.* dEQP-GLES31.functional.shaders.builtin_functions.*compute* Change-Id: Ibecca24623ca8e4723af6f0e0421fe9711ea828d Reviewed-on: https://chromium-review.googlesource.com/787976 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 7881cfdf 2017-08-23T18:00:21 Add parsing of arrays of arrays This changes the grammar so that multiple array sizes can be chained together, and adds arrays of arrays support to TPublicType. In TPublicType the array sizes are stored using a pointer to a vector, a plain vector won't work due to bison restrictions. A larger subset of program interface query tests now pass. Some are still failing due to unrelated bugs. BUG=angleproject:2125 TEST=angle_unittests, angle_end2end_tests, dEQP-GLES31.functional.shaders.arrays_of_arrays.* dEQP-GLES31.functional.uniform_location.nested_array.* dEQP-GLES31.functional.program_interface_query.* dEQP-GLES31.functional.ubo.*level*array.* Change-Id: Iee16477a3752b953f5068c0473a2ed62fead8155 Reviewed-on: https://chromium-review.googlesource.com/633944 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Jamie Madill 2f294c9a 2017-11-20T14:47:26 Add constructors for TMemoryQualifier and TLayoutQualifier. These replace the ::create methods, to facilitate constexpr versions. Also adds a constructor of WorkGroupSize that can be made to be constexpr. Bug: angleproject:1432 Change-Id: I413d1a56102c94d6a383775110a2b850a7532ea0 Reviewed-on: https://chromium-review.googlesource.com/776279 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Jiajia Qin a3106c58 2017-11-03T09:39:39 ES31: Add atomic memory functions BUG=angleproject:1442 TEST=angle_unittests, angle_end2end_tests dEQP-GLES31.functional.compute.shared_var.atomic* dEQP-GLES31.functional.compute.basic.shared_atomic_op* dEQP-GLES31.functional.ssbo.atomic.* Change-Id: I82b54fde3a852d3bd917b1e19680baa1c28fce4d Reviewed-on: https://chromium-review.googlesource.com/765061 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez 1d33c219 2017-11-13T10:21:39 Fix standalone mac compilation BUG= Change-Id: I225bd1693f595a64179b8e500cb1e7101fd2e197 Reviewed-on: https://chromium-review.googlesource.com/766472 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 7af63727 2017-11-13T15:03:40 Fix nullptr dereference on struct parameter error Function parameter name string does not necessarily exist, so it's better to use the function name as the token in the error message. BUG=chromium:784158 TEST=angle_unittests Change-Id: I8f3b8604fd702bdc9486b8d721a5f60de1ff3fa7 Reviewed-on: https://chromium-review.googlesource.com/765972 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 703671e9 2017-11-08T17:47:18 Unify extension behavior checks Some supportsExtension and isExtensionEnabled checks are now turned into checkCanUseExtension checks. Using checkCanUseExtension is preferable so that warnings are generated correctly when an extension is used and a warn directive is present. isExtensionEnabled is still used in some places where an error message about the extension could be confusing, particularly when a core spec version adds support for something that is also present in an extension. Also make it possible to disable ARB_texture_rectangle extension using an extension directive. ARB_texture_rectangle extension functionality is enabled by default in GLSL when the extension is supported. BUG=angleproject:2238 TEST=angle_unittests Change-Id: I7455293412ff469f54bc7da79df146e7bc127379 Reviewed-on: https://chromium-review.googlesource.com/760737 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiawei Shao 0e883134 2017-10-26T09:53:50 ES31: Support EXT_geometry_shader in GLSL compiler This patch intends to support "EXT_geometry_shader" as a valid extension string in ANGLE GLSL compiler. We decide to support it because in dEQP-GLES31 all geometry shader related tests are using "EXT_geometry_shader" instead of "OES_geometry_shader". 1. Support new extension string "EXT_geometry_shader" 2. Enable geometry shader layout qualifiers with EXT_geometry_shader 3. Enable geometry shader builtins with EXT_geometry_shader BUG=angleproject:1941 TEST=angle_unittests Change-Id: Iaedd01a9100ccf56243c957db36ff0c983d17060 Reviewed-on: https://chromium-review.googlesource.com/737933 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ef7fb388 2017-11-07T16:33:49 Size const unsized arrays without an initializer The array size for unsized arrays needs to be sanitized in all cases, since subsequent checks on array indexing depend on all arrays being sized. BUG=chromium:781729 TEST=angle_unittests Change-Id: I3af6c08bb249a19f7c2ef169c877a2b863eb31d3 Reviewed-on: https://chromium-review.googlesource.com/757101 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho d80f2944 2017-11-06T12:44:45 Struct definition not allowed as function parameter type Struct definitions are not allowed as a function parameter type now. This is specified in ESSL 3.00.6 section 12.10. ESSL 3.00.6 section 6.1.1 contradicts this, but that seems like a mistake, it's been fixed in subsequent spec versions. BUG=angleproject:2225 TEST=angle_unittests Change-Id: I6b97d120c440f0c0a45d31bbfaf292fb497160ce Reviewed-on: https://chromium-review.googlesource.com/754606 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b8ee9dd3 2017-10-30T12:43:27 Validate empty statements in switch statements Even an empty statement like ";" is a statement according to the grammar. They should not be allowed in switch statements before the first case statement, but on the other hand a switch statement that has just an empty statement after the last statement is valid. Now the parser creates AST nodes from empty statements so that we can validate switch statements correctly. However, they are pruned shortly after parsing completes in PruneNoOps, so they don't affect further processing of the AST. BUG=angleproject:2181 TEST=angle_unittests Change-Id: I1085056fc34b146142546fc5f2b7f3124b910ab9 Reviewed-on: https://chromium-review.googlesource.com/743621 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 722bfb51 2017-10-26T17:00:11 Fix detecting duplicate field names in structures Previously field names that were listed in the first declarator list inside a struct declaration were not checked against each other. BUG=angleproject:2204 TEST=angle_unittests Change-Id: Ibf821d45556f6dfe0223dae673644f6795daf4cb Reviewed-on: https://chromium-review.googlesource.com/739825 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 55bc905f 2017-10-25T17:33:06 Always consider type arrayness for atomic counters Atomic counter arrays may be declared with various different syntax - the array size may be declared as a part of the type or as a part of the declarator. Take this into account when determining whether atomic counter offsets overlap. BUG=angleproject:1729 TEST=angle_unittests Change-Id: I7435ded9401c4c1caab22c22d83fd2ad301df768 Reviewed-on: https://chromium-review.googlesource.com/738140 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Qin Jiajia ca68d988 2017-09-18T16:41:56 ES31: Add std430 support for OpenGL backend BUG=angleproject:1920 TEST=angle_unittests Change-Id: Ie8e171abec053c2c5dca93d6e79db534f74520e7 Reviewed-on: https://chromium-review.googlesource.com/737532 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 4ddae359 2017-10-26T16:20:18 Use array_specifier in struct declarator parsing This will make implementing arrays of arrays simpler for struct members as well. Similar refactoring was already done for other types of array declarations. BUG=angleproject:2125 TEST=angle_unittests Change-Id: I0483c3a7c006d37090c7c972cb3d7763d3909c8f Reviewed-on: https://chromium-review.googlesource.com/739824 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 9cd7163e 2017-10-26T14:43:20 Fix setting array sizes on a constructor Take any array sizes that have been explicitly specified in the shader text into account, and only set the ones that are unsized according to the arguments. BUG=angleproject:2125 TEST=angle_unittests Change-Id: I37d08a86c25f7cd4f3ce5689f2c9fad444e7d5ad Reviewed-on: https://chromium-review.googlesource.com/738141 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 454c34cb 2017-10-25T16:35:56 Accept valid geometry shader inputs regardless of syntax Before, only the following style of declarations were accepted: in float f[]; Now also these styles are accepted: in float[] f; in float f[], g[]; BUG=angleproject:2201 TEST=angle_unittests Change-Id: I0af7d355a5e06a67ceef2d6bd69af7e23c180a04 Reviewed-on: https://chromium-review.googlesource.com/738234 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 55bde916 2017-10-25T13:41:13 Parse array specifier with a separate grammar rule This brings the grammar closer to the GLSL ES 3.10 spec. Some corner cases related to handling unsized arrays are fixed. BUG=angleproject:2125 TEST=angle_unittests, angle_end2end_tests Change-Id: I9bcf87b17b97da0e2ec2954d32037c272fde3080 Reviewed-on: https://chromium-review.googlesource.com/738233 Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiawei Shao 8e4b355b 2017-08-30T14:20:58 ES31: Implement Geometry Shader inputs and outputs This patch intends to implement Geometry Shader inputs and outputs in ANGLE GLSL compiler. 1. Only accept arrays as the inputs of a Geometry Shader. 2. Allow unsized arrays as the inputs of a Geometry Shader after a valid input primitive declaration and assign size to them. 3. Implement Geometry Shader outputs. 4. Allow Geometry Shader inputs and outputs using interpolation qualifiers ('flat', 'smooth', 'centroid'). 5. Allow using 'location' layout qualifier on Geometry Shader inputs and outputs. BUG=angleproject:1941 TEST=angle_unittests Change-Id: Ia7e250277c61f45c8479437b567c2831ff26b433 Reviewed-on: https://chromium-review.googlesource.com/650211 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho cbcb96fc 2017-10-19T14:14:06 Fix switch/case last case validation for ESSL 3.10 No statement should be required after the last case label of a switch statement in ESSL 3.10. The validation is still kept for ESSL 3.00 for dEQP compatibility. If the dEQP tests are changed in the future, we might consider just issuing a warning regardless of shader version. BUG=angleproject:2189 TEST=angle_unittests Change-Id: Ic53e71e0176668a7dbffa315712885846e217f03 Reviewed-on: https://chromium-review.googlesource.com/727802 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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 923ecef6 2017-10-11T12:01:38 Fix switch statement validation corner cases The grammar needs to generate AST nodes even for no-op statements, since they might be the last statement in a switch statement that is required for switch statement validity. Change the grammar to generate nodes from empty blocks and empty declarations. We also need to do some further processing of the AST. This is because PruneEmptyDeclarations will still remove empty declarations, and at least the NVIDIA driver GLSL compiler doesn't accept some types of no-op statements as the last statement inside a switch statement. So after parsing has finished we do rudimentary dead code elimination to remove dead cases from the end of switch statements. BUG=angleproject:2181 TEST=angle_unittests Change-Id: I586f2e4a3ac2171e65f1f0ccb7a7de220e3cc225 Reviewed-on: https://chromium-review.googlesource.com/712574 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Jiawei Shao 4cc89e2b 2017-08-31T14:25:54 ES31: Enable 'location' layout qualifier on shader interfaces in compiler This patch enables 'location' layout qualifier for vertex outputs and fragment shader inputs when the shader version is 3.1 in ANGLE GLSL compiler and adds the check on location conflicts for these varyings. According to GLSL ES 3.1 SPEC (Chapter 4.4.1 and Chapter 4.4.2), 'location' layout qualifier is allowed on both inputs and outputs of vertex and fragment shaders. 'location' layout qualifier on shader interfaces is only valid on shaders whose version is 3.1 and above. According to GLSL ES 3.0 SPEC, vertex shader cannot have output layout qualifiers (Chapter 4.3.8.2) and fragment shader cannot have input layout qualifiers (Chapter 4.3.8.1). The 'location' qualifier on varyings is used in the shader interface matching defined in OpenGL ES 3.1. (OpenGL ES 3.1 SPEC Chapter 7.4.1). This new link rule will be added to Program.cpp in another patch. For the OpenGL ES 3.1 extension GL_OES_geometry_shader, according to GL_OES_shader_io_blocks SPEC (Chapter 4.4.1 and Chapter 4.4.2), 'location' layout qualifier is both valid on geometry shader inputs and outputs. This feature will be implemented together with other rules on geometry shader inputs and outputs. BUG=angleproject:2144 TEST=angle_unittests Change-Id: I62d85f7144c177448321c2db36ed7aaeaa1fb205 Reviewed-on: https://chromium-review.googlesource.com/645366 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Martin Radev 84aa2dcf 2017-09-11T15:51:02 Add textureGather and textureGatherOffset The patch adds new built-ins and extends the semantic parser to add support for textureGather and textureGatherOffset. BUG=angleproject:1442 TEST=angle_unittests TEST=angle_deqp_gles31_tests.exe --deqp-case=dEQP-GLES31.functional.texture.gather* --deqp-egl-display-type=angle-gl Change-Id: Iaf98c3420fbd61193072fdec8f5a61ac4c574101 Reviewed-on: https://chromium-review.googlesource.com/660124 Commit-Queue: Martin Radev <mradev@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho bb5a7e29 2017-08-30T13:03:12 Allow length() on arbitrary array expressions This is required to pass some dEQP GLES 3.1 tests for arrays of arrays, and WebGL conformance tests were also recently fixed to require this behavior. The intent of the GLSL ES spec was not to restrict usage of length(). In practice GL drivers don't implement array length() on expressions with side effects correctly in all cases. HLSL doesn't have an array length operator either. Because of this we always remove array length ops from the AST before output. BUG=angleproject:2142 TEST=angle_unittests, angle_end2end_tests, WebGL conformance tests Change-Id: I863a92e83ac5315b013af9a5626348482bad72b3 Reviewed-on: https://chromium-review.googlesource.com/643190 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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>
Olli Etuaho ec3a9cbb 2017-09-07T12:18:01 Only support GL_OVR_multiview extension variant The WebGL spec proposal was changed so that only GL_OVR_multiview extension name is supported, instead of having two variants OVR_multiview and OVR_multiview2. We're only supporting the WebGL version of the shader extension, so we drop compiler support for GL_OVR_multiview2. Shader restrictions were also removed from the WebGL spec, so no special validation for how ViewID_OVR gets used is needed. Tests that were testing for the shader restrictions are either removed or changed from negative tests to positive tests. BUG=angleproject:1669 TEST=angle_unittests Change-Id: I83f92b879376d41b727b5aca419fd75fb6f53477 Reviewed-on: https://chromium-review.googlesource.com/654608 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho bb2bbfbb 2017-08-24T15:43:33 Refactor GLSL array length method parsing This prepares for accepting arbitrary expressions as the "this" node of the array length method. BUG=angleproject:2142 TEST=angle_unittests Change-Id: I728adb6e76d2779dedbabfaeec7d096872e0d00d Reviewed-on: https://chromium-review.googlesource.com/633945 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jiawei Shao e8ef2bc4 2017-08-29T13:38:57 Add compile error on using inputs with interpolation qualifier as l-value This patch intends to fix a compile error in ANGLE GLSL compiler when parsing an expression with inputs which has interpolation qualifiers ('flat', 'smooth' and 'centroid'). The compiler should report a compile error when a shader input with interpolation qualifier is used as a l-value. BUG=angleproject:2140 TEST=angle_unittests Change-Id: I7c059d53bf001ac31d34519a98e5289797833ce7 Reviewed-on: https://chromium-review.googlesource.com/640075 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiawei Shao 7e1197e0 2017-08-24T15:48:38 Fix crash when indexing unsupported interface blocks by variable This patch intends to fix a compiler crash when indexing an unsupported interface blocks. We should not use UNREACHABLE() here because the compiler will continue parsing when this kind of error is generated. Instead, we use an ASSERT to ensure the compile error must have been reported before when the parsing reaches here. BUG=chromium:758159 Change-Id: I4bc63316d156d51f721123fe963106d1e81d8d32 Reviewed-on: https://chromium-review.googlesource.com/631797 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: 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>
Olli Etuaho e080387e 2017-08-23T15:30:23 Refactor array element type checks Remove checks that would never fail, and refactor the functions into more self-contained checks. For example, it doesn't make sense to check the qualifier from the part of the type that doesn't contain the qualifier. This prepares for adding the parsing of arrays of arrays. BUG=angleproject:2125 TEST=angle_unittests Change-Id: I1144bee35d2b04c7cb22e2bb7e17307298e35f8c Reviewed-on: https://chromium-review.googlesource.com/629016 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 96f6adfa 2017-08-16T11:18:54 Add support for arrays of arrays in AST processing Data concerning arrays of arrays is added in TType. Parsing arrays of arrays and support for arrays of arrays in TPublicType are still left to be implemented later. ShaderVariable interface for arrays of arrays is also left to be implemented later. We rely on existing test coverage to make sure that arrays of arrays are not accidentally exposed. BUG=angleproject:2125 TEST=angle_unittests, angle_end2end_tests, angle_deqp_gles31_tests Change-Id: Ie17d5ac9b8d33958e9126dc0fb40bf1c81ddeec9 Reviewed-on: https://chromium-review.googlesource.com/616146 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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>
Shao b18c33e9 2017-08-16T12:37:51 Remove arraySize in TInterfaceBlock This patch intends to remove the field 'arraySize' in TInterfaceBlock. The field 'arraySize' in TInterfaceBlock is redundant because: 1. If the interface block has instance name, it is recorded as one symbol as a whole, and its array size is recorded in the TType of the symbol. 2. If the interface block doesn't have instance name, its members are recorded separately, and it cannot be declared as an interface block array. This patch can make the implementation of Geometry Shader easier when we set array size to the built-in interface block 'gl_in' and other user-defined unsized input interface blocks during the compilation of a Geometry Shader. BUG=angleproject:1941 TEST=angle_end2end_test Change-Id: I9a51aab9b8f9ea7e88af157505c092426cee7e6e Reviewed-on: https://chromium-review.googlesource.com/615759 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 85d624a5 2017-08-07T13:42:33 Fix null pointer dereference in redeclaration error message When a function parameter name conflicts with another, the pointer returned to ParseContext will be null. BUG=chromium:745242 TEST=angle_unittests Change-Id: Ie53bb06b0c6660e382d85aeda41f3a1b7df5a917 Reviewed-on: https://chromium-review.googlesource.com/603368 Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Shao b5cc1198 2017-07-06T10:47:20 ES31: Add Geometry Shader layout qualifiers in GLSL compiler This patch intends to implement Geometry Shader layout qualifiers required in OpenGL ES 3.1 extension GL_OES_geometry_shader in ANGLE GLSL compiler. 1. Add support to the shader type GL_GEOMETRY_SHADER_OES. 2. Implement Geometry Shader layout qualifiers in the GLSL compiler: (1) Add support to OpenGL ES 3.1 extension "GL_OES_geometry_shader". (2) Add validations of the input and output primitive declarations in the Geometry Shader layout declarations. (3) Add 'invocations' and 'max_vertices' support in the Geometry Shader layout declarations 3. Add unit tests to cover all the new features added in this patch. BUG=angleproject:1941 TEST=angle_unittests Change-Id: Ie693e11f8a00dab3552626ed63e9336c7fbd3cb8 Reviewed-on: https://chromium-review.googlesource.com/560647 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>