src/compiler/translator/SeparateArrayInitialization.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>
Olli Etuaho 18b9deb4 2015-11-05T12:14:50 Support writing initializers using HLSL literal syntax Instead of using constructor functions to initialize variables, it is better to use literal initializer syntax provided by HLSL when it is possible. This way shader complexity is reduced and constant array initialization doesn't have to go through as many AST transformations. Before this patch, vec4 initialization would result in the following kind of HLSL: float4 f = float4(1.0, 2.0, 3.0, 4.0); After this patch, it will be: float4 f = {1.0, 2.0, 3.0, 4.0}; Before this patch, vec2 array initialization would result in the following kind of HLSL: float2 f[2] = {0, 0, 0, 0}; angle_construct_into_2_float2(f, float2(1.0, 2.0), float2(3.0, 4.0)); After this patch, it will be: float2 f[2] = {1.0, 2.0, 3.0, 4.0}; BUG=angleproject:1094 BUG=541551 TEST=WebGL conformance tests Change-Id: I9816a8d95a2cba3964922f6b561862d478da6145 Reviewed-on: https://chromium-review.googlesource.com/311160 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b1edc4f5 2015-11-02T17:20:03 Accept const array initialization in shader parsing Array constructors are not folded, unlike all other constant expressions. Change initializer parsing path so that it accepts constant initializers whether they are folded or not. Some parts need to be adapted to work with expressions that are qualified as constant but that are not necessarily folded: 1. Identifier parsing 2. Indexing parsing 3. Field selection parsing 4. HLSL output for variable declarations 5. Determining unary operator result type 6. Determining binary operator result type 7. Determining built-in function call result type 8. Determining ternary operator result type Corner cases that are not supported yet: 1. Using array constructors inside case labels 2. Using array constructors inside array size expressions 3. Detecting when a negative constant expression containing an array constructor is used to index an array In these cases being able to constant fold the expression is essential to validating that the code is correct, so they require a more sophisticated solution. For now we keep the old code that rejects the shader if ANGLE hasn't been able to constant fold the case label or array size. In case of indexing an array with a negative constant expression containing an array constructor, ANGLE will simply treat it as a non-constant expression. BUG=541551 BUG=angleproject:1094 TEST=dEQP-GLES3.functional.shaders.constant_expressions.* (all pass), angle_unittests Change-Id: I0cbc47afd1651a4dece3d68acf7ec72a01fdf047 Reviewed-on: https://chromium-review.googlesource.com/310231 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 822fa84e 2015-04-16T14:26:10 Support array initialization in HLSL output Do this by separating each array initialization into a declaration and an assignment. Array assignment is already supported in HLSL output by replacing it with a function call. The functionality is tested by the struct array constructor tests in dEQP. BUG=angleproject:941 TEST=dEQP-GLES3.functional.shaders.arrays.constructor.* Change-Id: Ida84fc343b767bea8b2d04e91c60cb8197d39039 Reviewed-on: https://chromium-review.googlesource.com/266002 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>