src/compiler/translator/DeferGlobalInitializers.cpp


Log

Author Commit Date CI Message
Olli Etuaho 3272a6d3 2016-08-29T17:54:50 Promote and fold indexing nodes similarly to other binary ops Indexing nodes now get their type set in TIntermBinary::promote, same as math and logic ops. They are also constant folded through TIntermBinary::fold() instead of having special functions for constant folding them in ParseContext. Index nodes for struct and interface block member access now always have integer type, instead of sometimes having the type of the field they were used to access. Usage of TIntermBinary constructor is cleaned up so only the constructor that takes in left and right operands is used. The type of TIntermBinary nodes is always determined automatically. Together these changes make the code considerably cleaner. Note that the code for constant folding for array indexing is actually never hit because constant folding array constructors is still intentionally disabled in the code. BUG=angleproject:1490 TEST=angle_unittests Change-Id: Ifcec45257476cdb0d495c7d72e3cf2f83388e8c5 Reviewed-on: https://chromium-review.googlesource.com/377961 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 03d863c8 2016-07-27T18:15:53 translator: Refactor node replacement APIs. BUG=angleproject:851 Change-Id: I50c3b3a4f00b27fed85f09509738513a441c7b5b Reviewed-on: https://chromium-review.googlesource.com/363990 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho d4f4c11b 2016-04-15T15:11:24 Fix deferring global array initialization The initial implementation of DeferGlobalInitializers did not take HLSL corner cases into account. In particular, in case there was a const-qualified array variable with an initializer that contained elements that weren't constant folded, initialization would not be deferred and the global scope of HLSL output would contain a call to angle_construct_into_*(). On the other hand, deferring global initializers was also done in cases where it wasn't necessary. Initializers of non-const qualified array variables that could be written as HLSL literals by HLSL output were unnecessarily deferred. This patch fixes both of these issues: Now all global initializers are potential candidates for deferral instead of just those where the symbol has the EvqGlobal qualifier, and initializers that are constructors taking only constant unions as parameters are not unnecessarily deferred. BUG=angleproject:1205 BUG=541551 TEST=angle_end2end_tests Change-Id: I4027059e0e5f39c8a5a48b5c97a3fceaac6b6f8a Reviewed-on: https://chromium-review.googlesource.com/339201 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 3d932d83 2016-04-12T11:10:30 Defer global initializers when necessary Move global variable initializers that are not constant expressions to a function that gets called at the start of main(). This is done with an AST transformation. This needs to be done because global variable initializers must be constant in native GL, but ANGLE is more lenient with what can be put into ESSL 1.00 global initializers to remain compatible with legacy WebGL content. Non-constant global variable initializers also caused issues in HLSL output, since in HLSL output some types of expressions get unfolded into multiple statements. These include short-circuiting operators and array initialization. To make sure that these cases are covered, any initializers that can't be constant folded are deferred, even if they have the const qualifier. The old deferring mechanism in OutputHLSL is removed in favor of this new AST transformation based approach. BUG=angleproject:819 BUG=angleproject:1205 BUG=angleproject:1350 BUG=596616 TEST=WebGL conformance test conformance/glsl/misc/global-variable-init.html Change-Id: I039cc05d6b8c284baeefbdf7f10062cae4bc5716 Reviewed-on: https://chromium-review.googlesource.com/338291 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>