src/compiler/translator/Intermediate.cpp


Log

Author Commit Date CI Message
Olli Etuaho d0bad2c7 2016-09-09T18:01:16 Split ternary node class from TIntermSelection Ternary operator nodes are typed parts of expressions, they always have two children and the children are also guaranteed to be TIntermTyped. "If" selection nodes can't be a part of an expression, they can have either one or two children and the children are code blocks. Due to all of these differences it makes sense to store these using two different AST node classes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I913ab1d806e3cdb5c21106f078cc9c0b6c72ac54 Reviewed-on: https://chromium-review.googlesource.com/384512 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
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 f119a263 2016-08-19T15:54:22 Clean up unary and aggregate math folding Prefer asserts instead of adding internal errors to the compiler log when types of arguments are not as expected or the folding function runs into an operation it can't handle. Neither of these cases should be possible, the checks for correct argument types are solid at this point. In the future, when new built-in functions are added, constant folding support for them should be added as well. foldUnaryWithDifferentReturnType and foldUnaryWithSameReturnType are renamed to foldUnaryNonComponentWise and foldUnaryComponentWise respectively. These names better reflect what these functions are doing. The info sink member is removed from TIntermediate, since TDiagnostics is now passed into the functions that may generate warnings instead. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I6a08abbe29cf23f3a318032fdc46dd3dbaf4410e Reviewed-on: https://chromium-review.googlesource.com/377959 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 3fdec919 2016-08-18T15:08:06 Refactor binary node creation 1. Simplify code by using asserts instead of adding internal errors to log. 2. Add a TIntermBinary constructor that takes left and right operand nodes as parameters. 3. Remove TIntermediate functions with trivial functionality. BUG=angleproject:952 TEST=angle_unittests Change-Id: I2e0e52160c9377d8efcf15f14fd59f01cb41bd83 Reviewed-on: https://chromium-review.googlesource.com/372720 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 244be01a 2016-08-18T15:26:02 Fix struct compound assignment being allowed in GLSL parsing The shader translator used to accept some invalid struct operations, like struct += struct and struct == struct with a different type. Fix this. BUG=angleproject:1476 TEST=angle_unittests Change-Id: Ia2303fc1f740da4d78242e094ee6004b07364973 Reviewed-on: https://chromium-review.googlesource.com/372718 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill a8503cef 2016-07-18T13:47:12 Re-land "GN: Enable chromium_code config instead." Using "no_chromium_code" is a bit less strict, but ANGLE should be able to handle slightly stricter warnings. Re-land with fix for Clang build. BUG=angleproject:1449 Change-Id: I8988287d630a6258f2f9ee90e7bfef5f2d5799cd Reviewed-on: https://chromium-review.googlesource.com/361331 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 5bc93c41 2016-07-18T16:34:42 Revert "GN: Enable chromium_code config instead." Seems to fail the Clang build: ../../third_party/angle/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp(35,60): error: comparison of integers of different signs: 'UINT' (aka 'unsigned int') and 'int' [-Werror,-Wsign-compare] maxSrvMip = (desc.Texture2D.MipLevels == -1) ? INT_MAX : maxSrvMip; ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~ BUG=angleproject:1449 This reverts commit aeb477fbe5fad337815560a0031815f0636471a1. Change-Id: I01baaf082f282c9d80a9c17fd6ffc2b8911313b2 Reviewed-on: https://chromium-review.googlesource.com/361094 Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill aeb477fb 2016-07-15T13:32:37 GN: Enable chromium_code config instead. Using "no_chromium_code" is a bit less strict, but ANGLE should be able to handle slightly stricter warnings. BUG=angleproject:1449 Change-Id: Ifaf77201085dd70cf5ff628b1aa02de55c5e96ba Reviewed-on: https://chromium-review.googlesource.com/360940 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 5c0e023c 2015-11-11T15:55:59 Qualify stored constant union data with const This prevents accidentally changing data that may be shared between multiple TIntermConstantUnion nodes. Besides making the code less prone to bugs in general, this will make it easier to implement constant folding of array constructors. BUG=541551 TEST=angle_unittests, WebGL conformance tests Change-Id: I4f3059f70b841d9dd0cf20fea4d37684da9cd47e Reviewed-on: https://chromium-review.googlesource.com/312440 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 1d122789 2015-11-06T15:35:17 Fix constructor constant folding The previous solution for constant folding constructors was significantly overengineered and partially incorrect. Switch to a much simpler constructor folding function that does not use an AST traverser, but simply iterates over the constant folded parameters of the constructor and doesn't do any unnecessary checks. It also reuses some code for constant folding other built-in functions. This fixes issues with initializing constant matrices with only a single parameter. Instead of copying the first component of the constructor parameter all over the matrix, passing a vec4 or matrix argument now assigns the values correctly. BUG=angleproject:1193 TEST=angle_unittests, WebGL conformance tests Change-Id: I50b10721ea30cb15843fba892c1b1a211f1d72e5 Reviewed-on: https://chromium-review.googlesource.com/311191 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 7c3848e5 2015-11-04T13:19:17 Allow constant folding some non-constant expressions This requires removing the assumption that constant folding implies constness in the constant expression sense from various places in the code. This particularly benefits ternary operators, which can now be simplified if just the condition is a compile-time constant. In the future, the groundwork that is laid here could be used to implement more aggressive constant folding of user-defined functions for example. TEST=angle_unittests BUG=angleproject:851 Change-Id: I0eede806570d56746c3dad1e01aa89a91d66013d Reviewed-on: https://chromium-review.googlesource.com/310750 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 15200047 2015-11-04T16:56:31 Fix issues in comma operator parsing Always qualify comma operator result with EvqTemporary in ESSL3, as specified. Also, it is possible that in the future some expressions are qualified as EvqConst but they'd still have side effects, in which case discarding them when they're the left operand of the comma operator would be wrong. This would be the case if ANGLE allowed "(a = b).length()" for example. For this reason it is better to check whether the left node has side effects, rather than check its const qualification, and only discard it if it doesn't. Also, Intermediate::addComma() never returns null, so there's no need to check the result. BUG=angleproject:1201 TEST=WebGL conformance tests conformance/glsl/misc/sequence-operator-returns-constant.html conformance2/glsl3/sequence-operator-returns-non-constant.html Change-Id: Ibfbd92baa4910b14c0dc8f8a3c3008440d191cd6 Reviewed-on: https://chromium-review.googlesource.com/311171 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
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 43613b03 2015-08-04T11:02:21 Make sure that the AST root is always a sequence node This enables inserting helper functions as an AST transformation. BUG=angleproject:1116 TEST=angle_unittests Change-Id: I169d4d3a726d0e389cb3444fe9dfb4c6c5d80155 Reviewed-on: https://chromium-review.googlesource.com/290513 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Arun Patole 7fa3355f 2015-06-10T15:15:18 Add constant folding support for matrix built-ins This change adds constant folding support for following matrix built-ins: - matrixCompMult, outerProduct, transpose, determinant and inverse. BUG=angleproject:913 TEST=angle_unittests(new: MatrixUtilsTest, ConstantFoldingTest.*Matrix*), dEQP Tests: dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.matrix.* (All 54 tests started passing with this change) Change-Id: I7b9bf04b9a2cbff72c48216cab04df58c5f008d6 Reviewed-on: https://chromium-review.googlesource.com/276574 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho b43846ee 2015-06-02T18:18:57 Unify aggregate operator folding with other constant folding Setting the type for folded aggregate nodes should work in a similar way as other constant folding. Common functionality between the different folding functions is refactored into a single function. TEST=dEQP-GLES3.functional.shaders.constant_expressions.* BUG=angleproject:817 Change-Id: Ie0be561f4a30e52e52d570ff0b2bdb426f6e4f7a Reviewed-on: https://chromium-review.googlesource.com/275186 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 95310b00 2015-06-02T17:43:38 Unify unary operator folding with binary operator folding Implement unary operator folding in a similar way to binary operator folding, so that the code is easier to understand. TEST=dEQP-GLES3.functional.shaders.constant_expressions.* BUG=angleproject:817 Change-Id: I069bdb38f965e1badb3e8f3f954386b205b7bb00 Reviewed-on: https://chromium-review.googlesource.com/275185 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 2c4b746c 2015-06-08T11:30:31 Revert "Revert "Make sure type gets set consistently in folded binary operations"" This patch was originally reverted only because a dependency patch failed a buggy Chromium test. This reverts commit aebd002d00d39858819c58bad1970df121b78e1b. TEST=dEQP-GLES3.functional.shaders.constant_expressions.* BUG=angleproject:817 Change-Id: Ia5acf15518ea89717c0cfe1398cb18ea27be5b19 Reviewed-on: https://chromium-review.googlesource.com/275811 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Arun Patole 1155ddd2 2015-06-05T18:04:36 Revert "Revert "Add constant folding support for geometric built-ins"" Revert of revert as the issue is with the failing test itself. This reverts commit b3da45c12d3eecdd319c0feb4d2b933e144f816a. Change-Id: Ie2003c78527f87cad7f8ead0d87fee75ce032379 Reviewed-on: https://chromium-review.googlesource.com/275487 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill b3da45c1 2015-06-04T19:38:22 Revert "Add constant folding support for geometric built-ins" This is failing gpu_unittests on Mac: ShaderTranslatorTest.BuiltInFunctionEmulation: ../../gpu/command_buffer/service/shader_translator_unittest.cc:314: Failure Value of: strstr(translated_source.c_str(), "webgl_dot_emu") != NULL Actual: false Expected: true Reverting until we can fix the overly-narrow test. BUG=angleproject:913 This reverts commit b50788d11dec046415565af1cc7da334e2979577. Change-Id: I5bd9df83704e771e419339745eceaa43a20bd1e6 Reviewed-on: https://chromium-review.googlesource.com/275320 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill aebd002d 2015-06-04T19:43:44 Revert "Make sure type gets set consistently in folded binary operations" This is blocking the revert of the geometric constant folding patch, which is breaking gpu_unittests and blocking the roll. BUG=angleproject:817 This reverts commit b07aba0798d3bba3118dac78933e73b3f08a601b. Change-Id: Ia00fc45b1ddd9d3c079742dea0627aa12304f93b Reviewed-on: https://chromium-review.googlesource.com/275321 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho b07aba07 2015-05-29T12:19:19 Make sure type gets set consistently in folded binary operations Add a wrapper function that handles creating the folded node and setting the right parameters on it, so that the folding function handles only calculating the folded values. This will fix the precision set to constant folded values in some cases. Previously the precision was always set to be equal to one of the operands to the binary operation, but now both operands are taken into account. Folding binary operations is now in a separate function from folding unary operations. TEST=dEQP-GLES3.functional.shaders.constant_expressions.* BUG=angleproject:817 Change-Id: Id97e765173c6110f49607e21c3fb90019b1ebac7 Reviewed-on: https://chromium-review.googlesource.com/274001 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Arun Patole b50788d1 2015-05-25T19:20:26 Add constant folding support for geometric built-ins * re-land after mac compilation fix (unsupported c++11 initializer) * This change adds constant folding support for following geometric built-ins: - length, distance, dot, cross, normalize, faceforward, reflect and refract. BUG=angleproject:913 TEST=angle_unittests, dEQP Tests dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.geometric.* (56 tests started passing with this change) Change-Id: I236fc0c1af47a63f359564500c711e6bedf1c808 Reviewed-on: https://chromium-review.googlesource.com/274789 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 2f4823bf 2015-06-03T12:39:22 Revert "Add constant folding support for geometric built-ins" Breaks Mac build because of C++11 init syntax: FAILED: /b/build/goma/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/third_party/angle/src/tests/compiler_tests/angle_unittests.ConstantFolding_test.o.d -DV8_DEPRECATION_WARNINGS -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DCHROMIUM_BUILD -DCR_CLANG_REVISION=238013-3 -DCOMPONENT_BUILD -DTOOLKIT_VIEWS=1 -DUSE_LIBJPEG_TURBO=1 -DENABLE_ONE_CLICK_SIGNIN -DENABLE_PRE_SYNC_BACKUP -DENABLE_REMOTING=1 -DENABLE_WEBRTC=1 -DENABLE_MEDIA_ROUTER=1 -DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_NOTIFICATIONS -DENABLE_HIDPI=1 -DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE -DDONT_EMBED_BUILD_METADATA -DDCHECK_ALWAYS_ON=1 -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PLUGIN_INSTALLATION=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_GOOGLE_NOW=1 -DCLD_VERSION=2 -DENABLE_PRINTING=1 -DENABLE_BASIC_PRINTING=1 -DENABLE_PRINT_PREVIEW=1 -DENABLE_SPELLCHECK=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SETTINGS_APP=1 -DENABLE_SUPERVISED_USERS=1 -DENABLE_SERVICE_DISCOVERY=1 -DENABLE_WIFI_BOOTSTRAPPING=1 -DV8_USE_EXTERNAL_STARTUP_DATA -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DSAFE_BROWSING_SERVICE -DGTEST_HAS_POSIX_RE=0 -DGTEST_LANG_CXX11=0 -DGL_APICALL= -DGL_GLEXT_PROTOTYPES= -DEGLAPI= '-DANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ "d3dcompiler_47.dll", "d3dcompiler_46.dll", "d3dcompiler_43.dll" }' -DANGLE_TRANSLATOR_STATIC -DUSE_LIBPCI=1 -DUSE_OPENSSL=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -Igen -I../.. -I../../third_party/angle/include -I../../third_party/angle/src -I../../third_party/angle/src/compiler/preprocessor -I../../third_party/angle/src/tests -Igen/angle -I../../testing/gmock/include -I../../testing/gtest/include -isysroot /Applications/Xcode5.1.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -O0 -gdwarf-2 -fvisibility=hidden -Werror -Wnewline-eof -mmacosx-version-min=10.6 -arch x86_64 -Wall -Wendif-labels -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-selector-type-mismatch -Wpartial-availability -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -Wno-inconsistent-missing-override -std=c++11 -fno-rtti -fno-exceptions -fvisibility-inlines-hidden -fno-threadsafe-statics -Xclang -load -Xclang /b/build/slave/GPU_Mac_Builder__dbg_/build/src/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-templates -fcolor-diagnostics -fno-strict-aliasing -fstack-protector-all -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -c ../../third_party/angle/src/tests/compiler_tests/ConstantFolding_test.cpp -o obj/third_party/angle/src/tests/compiler_tests/angle_unittests.ConstantFolding_test.o ../../third_party/angle/src/tests/compiler_tests/ConstantFolding_test.cpp:210:43: error: no matching constructor for initialization of 'std::vector<float>' ASSERT_FALSE(constantVectorFoundInAST(std::vector<float>{1.0f, 1.0f, 1.0f})); ^ ~~~~~~~~~~~~~~~~~~ BUG=angleproject:913 This reverts commit 2decb4b1557a57a5a74e3ab98d8b25f9fc0f8557. Change-Id: Iaf3c61a0c0ed591c17f50f2e3eafe2debf588c95 Reviewed-on: https://chromium-review.googlesource.com/274917 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Arun Patole 2decb4b1 2015-05-25T19:20:26 Add constant folding support for geometric built-ins This change adds constant folding support for following geometric built-ins: - length, distance, dot, cross, normalize, faceforward, reflect and refract. BUG=angleproject:913 TEST=angle_unittests, dEQP Tests dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.geometric.* (56 tests started passing with this change) Change-Id: I973689554bb8c30ee3ebdf71f1b8a051ceb5e0cf Reviewed-on: https://chromium-review.googlesource.com/273097 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Arun Patole 9d0b1f9b 2015-05-20T14:27:17 Constant fold vector relational built-ins This change adds constant folding support for vector relational built-ins. BUG=angleproject:913 TEST=dEQP Tests dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.vector_relational* (Fixes all 138 tests) Change-Id: I291e332f2afb3ce3d6596e634f509995dbf35164 Reviewed-on: https://chromium-review.googlesource.com/272344 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Arun Patole bf790420 2015-05-18T17:53:04 Add constant folding support for more built-ins This change adds constant folding support for following built-ins: - atan(two arguments), pow, mod, mix, step and smoothstep. BUG=angleproject:913 TEST=dEQP tests Following 80 tests from dEQP-GLES3.functional.shaders.constant_expressions started passing with this change: - builtin_functions.angle_and_trigonometry.atan_separate* - builtin_functions.exponential.pow_* - builtin_functions.common.mod_* - builtin_functions.common.mix_* - builtin_functions.common.step_* - builtin_functions.common.smoothstep_* Change-Id: I70f0a8837a82c480da8cff3f1382c6252a486fe4 Reviewed-on: https://chromium-review.googlesource.com/271753 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 7d7f8c44 2015-05-19T18:38:49 Ensure that conditional blocks and loop bodies are sequence nodes AST transformations such as unfolding logical operations can only create nodes inside sequence (block) nodes. This patch ensures that these AST transformations work even inside conditional blocks and loop bodies that were first parsed as single statements instead of blocks. BUG=angleproject:971 TEST=WebGL conformance tests Change-Id: If98cb7be653ec7b005537b89547f4f4cf1c07c72 Reviewed-on: https://chromium-review.googlesource.com/272141 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Arun Patole 274f0709 2015-05-05T13:33:30 Add constant folding support for min,max and clamp This change adds necessary mechanism to support constant folding of built-ins that take more than one parameter and also adds constant folding support for min, max and clamp built-ins. BUG=angleproject:913 TESTS=dEQP tests (126 tests started passing with this change) dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.min_* dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.max_* dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.clamp_* Change-Id: Iccc9bf503a536f2e3c144627e64572f2f95db9db Reviewed-on: https://chromium-review.googlesource.com/271251 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Geoff Lang 95d34aaf 2015-05-13T19:44:31 Revert "Add constant folding support for min,max and clamp" This reverts commit 1137a2a6b4a68fe3f7497bb9289975b030576372. Change-Id: I1493c2706e5f08a9f0001835e663a147be85a303 Reviewed-on: https://chromium-review.googlesource.com/270782 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Arun Patole 1137a2a6 2015-05-05T13:33:30 Add constant folding support for min,max and clamp This change adds necessary mechanism to support constant folding of built-ins that take more than one parameter and also adds constant folding support for min, max and clamp built-ins. BUG=angleproject:913 TESTS=dEQP tests (126 tests started passing with this change) dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.min_* dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.max_* dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.clamp_* Change-Id: I5d3e96ef2062116cbf164a7a42cba096bd4d5389 Reviewed-on: https://chromium-review.googlesource.com/269317 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill b11e2483 2015-05-04T14:21:22 translator: Fix validation sometimes modifying builtins. When validating some shaders with out-of-bounds array indexes, we would write the sanitized index into the global symbol table. We would then overwrite a wrong value for the builtin. This fixes the WebGL test extensions/webgl-draw-buffers-max-draw-buffers. Also mark const on as many uses ConstantUnion as we can. BUG=angleproject:993 Change-Id: I110efaf1b7b0158b08b704277e3bc2472437902c Reviewed-on: https://chromium-review.googlesource.com/268962 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 6ba6eadc 2015-05-04T14:21:21 Rename ConstantUnion to TConstantUnion. This clarified that we're using the Pool allocator/deallocator for this type. BUG=angleproject:993 Change-Id: If8c95f6054d07291e7014be0d4e35766ba2e943b Reviewed-on: https://chromium-review.googlesource.com/269131 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 2cb7b835 2015-04-23T20:27:44 Clean up binary operation constant folding code Fix mixed up comments, remove unnecessary type conversions, clarify variable names and improve formatting in a few places. TEST=angle_unittests, WebGL conformance tests BUG=angleproject:913 Change-Id: Ice8fe3682d8e97f42747752302a1fba116132df4 Reviewed-on: https://chromium-review.googlesource.com/266843 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 5290174b 2015-04-15T13:42:45 Refactor ternary operator parsing Refactor ternary operator parsing so that validation is done in ParseContext and Intermediate's role is simply to create the node added to the tree. Remove partially bugged checks for null nodes as a part of this - in error cases the parser doesn't typically add null nodes to the tree, but rather always has a fallback to add a dummy node if parsing fails as a method of recovery. When parsing ternary operators it should be guaranteed that none of the parameter nodes is null. Includes a better explanation of why ternary operators are not always folded when only the condition is constant, and a test to make sure this doesn't regress. BUG=angleproject:952 TEST=WebGL conformance tests, angle_unittests Change-Id: Icbcb721b5ab36cf314a16e79f9814aef1f355fa0 Reviewed-on: https://chromium-review.googlesource.com/265643 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho f6c694bc 2015-03-26T14:50:53 Assign built-in function return type in promote() This finishes the refactoring of unary math operation handling so that IntermUnary::promote has the complete code for setting the return type of the node. BUG=angleproject:952 TEST=angle_unittests, WebGL conformance tests Change-Id: I19bd8d53029e24f734c9436eceb446b37e7fcf26 Reviewed-on: https://chromium-review.googlesource.com/262416 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho dca3e796 2015-03-26T13:24:04 Refactor unary math operator handling to clarify responsibilities Shuffle the code around so that each part has a clear responsibility: IntermUnary::promote is responsible for setting the return type of the node, Intermediate::addUnaryMath is responsible for creating the node object, and ParseContext::createUnaryMath is responsible for validating the operand type. This removes duplicated bool type check for logical not. BUG=angleproject:952 TEST=angle_unittests, WebGL conformance tests Change-Id: I9f5a0abb6434ad2730441ea9199ec3f5382ebcda Reviewed-on: https://chromium-review.googlesource.com/262415 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 69c11b5d 2015-03-26T12:59:00 Move validation from Intermediate::addUnaryMath to ParseContext Intermediate should only have logic for creating node objects, validation of parameter types belongs in ParseContext. BUG=angleproject:952 TEST=angle_unittests, WebGL conformance tests Change-Id: Ie90697641fabb2a837ccc4571a93616d63ea64e6 Reviewed-on: https://chromium-review.googlesource.com/262414 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Olli Etuaho 5e5c826c 2015-03-26T14:04:54 Fix float-int conversion return type precision tracking Float-int conversion functions are defined to always return highp values. BUG=angleproject:865 TEST=angle_unittests Change-Id: Idf243b483f7b5edfcb54de2755af11e17c3756d3 Reviewed-on: https://chromium-review.googlesource.com/262413 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Olli Etuaho fc1806e1 2015-03-17T13:03:11 Move most of addBinaryMath from Intermediate to ParseContext Some type checks for binary math will be different based on the shading language version, which is easily accessible in ParseContext. Because of this and also for architectural simplicity it makes more sense to have the checks in ParseContext. BUG=angle:941 TEST=angle_unittests, WebGL conformance tests Change-Id: I92a499f47e1cbc6a7b6391ce0fa04284803e7140 Reviewed-on: https://chromium-review.googlesource.com/260570 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 3c1dfb5a 2015-02-20T11:34:03 Add stubs for switch and case output BUG=angle:921 Change-Id: I58bd645a8d53ef5bad9b680e54c8948d50932fca Reviewed-on: https://chromium-review.googlesource.com/251525 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho a3a36664 2015-02-17T13:46:51 Implement parsing switch statements Put in some groundwork for parsing switch statements and case labels in the parser, including definitions for IntermNode classes. Intermediate functions for adding the statements are stubbed to only generate errors for now. Tested by manually disabling shading language version checks for switch in a Chromium build and checking that the expected errors are generated. BUG=angle:921 Change-Id: I064b3e0c4c1b724a083cf5bc78eebfdd3794eb1b Reviewed-on: https://chromium-review.googlesource.com/250380 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ff805cc3 2015-02-13T10:59:34 Separate integer and float modulus Integer and float modulus are separated into Mod and IMod operator types to make the code clearer and to make GetOperatorString return the correct value for both. Change-Id: Ibfbca2c558bf919b0eab6404d7349f87fe47a18c Reviewed-on: https://chromium-review.googlesource.com/249692 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 31b5fc62 2015-01-16T12:13:36 Add support for bitwise operations in ESSL3 Add support for <<, >>, &, |, ^, and their compound assignment variants <<=, >>=, &=, |=, ^=. Also add support for bitwise not (~). BUG=angle:870 Change-Id: I5e6a835409589556d5d58d58078fdf505cfd8da5 Reviewed-on: https://chromium-review.googlesource.com/241850 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 7700ff65 2015-01-15T12:16:29 Add basic support for ESSL3 vec2 (un)pack functions The functions are emulated on HLSL, and use the native functions on OpenGL 4.2+ and GLES3.0. Emulation for OpenGL versions <= 4.1 is not yet implemented. BUG=angle:865 Change-Id: I6803a1767dacdb3dca12f13924651fd38fcacb75 Reviewed-on: https://chromium-review.googlesource.com/240961 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho d68157fc 2015-01-16T12:24:17 Fix issues related to modulus operator Make sure that "scalar %= vector" is not approved by the compiler, and that % and %= are only exposed on GLES3. BUG=angle:854 Change-Id: I3ac7eb607bd86a6caa905d2bef5d397688ad3fd3 Reviewed-on: https://chromium-review.googlesource.com/241410 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Gregoire Payen de La Garanderie <Gregory.Payen@imgtec.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Gregoire Payen de La Garanderie be954a23 2014-12-23T00:05:28 Implement support for the binary operator '%' in the translator. BUG=angle:854 Change-Id: If116de132dc83d93255749b54c1919a75abcb65c Reviewed-on: https://chromium-review.googlesource.com/236330 Tested-by: Gregoire Payen de La Garanderie <Gregory.Payen@imgtec.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 352beffc 2014-11-19T13:45:55 Remove RemoveAllTreeNodes, since it was a no-op IntermNode operator delete() or any of the IntermNode destructors don't do anything, since all the AST memory is allocated on the PoolAllocator. Because of this, RemoveAllTreeNodes was simply a no-op, and redundant with the PoolAllocator deallocation procedure, and could confuse people reading the code to think that IntermNodes should be deleted individually, when in fact this is not the case. BUG=angle:831 Change-Id: Ie1ccaa51986aabf267280d92a8e76ca9f97a19e5 Reviewed-on: https://chromium-review.googlesource.com/230730 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Zhenyao Mo de1e00e1 2014-10-09T16:55:32 Implement support of unary operator "+" in translator. BUG=angle:779 TEST=conformance/glsl/misc/struct-unary-operators.html Change-Id: Ia827e07dcfc8ad3bbbc078e54336815be9027945 Reviewed-on: https://chromium-review.googlesource.com/222720 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill b1a85f48 2014-08-19T15:23:24 Rename compiler intermediate source files. This prevents confusion between "TIntermediate" and "TIntermNode". BUG=angle:711 Change-Id: Ib7a086382a479db3f77bf2ab06ce321aa7b35d13 Reviewed-on: https://chromium-review.googlesource.com/212936 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Zhenyao Mo e40d1e9c 2014-07-16T17:40:36 Fix style violations. BUG=angle:650 TEST=no behavior change Change-Id: I3096615a181b1ec2c18ce60566c3d6249975b84e Reviewed-on: https://chromium-review.googlesource.com/208569 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens 16004fca 2014-06-11T11:29:11 Eliminate conversion operations. They've been replaced by using constructor nodes, so any code handling conversion operators can be removed. BUG=380353 Change-Id: I70413179e7443efccbf997a5dd0f053c23689589 Reviewed-on: https://chromium-review.googlesource.com/203453 Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens 6ed8d8af 2014-06-11T11:25:20 Produce constructors instead of conversions. GLSL only supports explicit conversion through constructors. Therefore the conversion nodes are redundant. BUG=380353 Change-Id: Id871c34750191dac431bf72aac9afed7b0db7f8e Reviewed-on: https://chromium-review.googlesource.com/203452 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Jamie Madill dd0d3426 2014-03-26T14:01:56 Use a heap-memory traversal to free compiler resources. The stack-memory traversal is prone to stack overflow. See the WebGL conformance test long-expressions-should-not-crash. BUG=angle:584 Change-Id: I02d72bc2e4101b7141d609c50303403ea8298e60 Reviewed-on: https://chromium-review.googlesource.com/191930 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens bd0ea9c7 2014-03-04T13:53:29 Don't attempt to perform constant folding with an uninitialized constant variable. BUG=348205 Change-Id: I9be17832b1a35d2995725ab147977992c2732274 Reviewed-on: https://chromium-review.googlesource.com/188711 Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/189471
Zhenyao Mo 7cab38b5 2013-10-15T12:59:30 Add an option to unfold short circuiting in AST. We replace "a || b" with "a ? true : b", "a && b" with "a ? b : false". This is to work around short circuiting bug in Mac drivers. ANGLEBUG=482 TEST=webgl conformance tests R=alokp@chromium.org, kbr@chromium.org Review URL: https://codereview.appspot.com/14529048 Conflicts: src/build_angle.gypi src/compiler/translator/Compiler.cpp Change-Id: Ic2384a97d58f54294efcb3a012deb2007a9fc658 Reviewed-on: https://chromium-review.googlesource.com/178996 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Tested-by: Shannon Woods <shannonwoods@chromium.org>
Jamie Madill f4b79ba8 2013-11-26T10:38:18 Fix issues with the conditional discard workarounds to do with assignments. The old modifiesState method really checked if an operator was an assignment, so restored that behaviour and use the new side effects detection only for the new code. ANGLEBUG=486 BUG= R=nicolascapens@chromium.org, zmo@chromium.org Review URL: https://codereview.appspot.com/22130043 Change-Id: I84d4e95a0457e63f237a814d80e4f72dd861496b
Jamie Madill 3c9eeb97 2013-11-04T11:09:26 Disable optimizations for shaders with conditional discard in D3D9, and only use expanded short-circuiting conditionals for expressions with potential side-effects. Conservatively assume aggreate and selection operators have side effects for now. BUG= ANGLEBUG=486 R=geofflang@chromium.org, kbr@chromium.org, nicolas@transgaming.com, shannonwoods@chromium.org Review URL: https://codereview.appspot.com/14441075 Conflicts: src/common/version.h src/compiler/translator.vcxproj src/compiler/translator.vcxproj.filters src/compiler/translator/OutputHLSL.cpp src/libGLESv2/ProgramBinary.cpp src/libGLESv2/Shader.cpp src/libGLESv2/Shader.h Change-Id: Iaf9f10b5de7b33c927ef032f3c4fe9d5095f64dd
Geoff Lang 17732823 2013-08-29T13:46:49 Moved the compiler source files into directories based on their project and added a compiler.gypi to generate the compiler projects.