src/tests/test_utils/ConstantFoldingTest.h


Log

Author Commit Date CI Message
Tom Sepez a02670d6 2025-08-26T20:41:16 Move unsafe buffers inside header guard macros While this is exactly opposite of what Chromium has chosen to do, there is an issue with clang-format trying to indent preprocessor directives four spaces relative to include guard. This is because Angle's .clang-format file specifies IndentPPDirectives: AfterHash but Chromium's does not. The current placement is sufficient to throw off clang-format's guard detection since the guard macro no longer covers the entire file. Bug: b/436880895 Change-Id: Ic6b99c8cef6213939cdf9b42af8730e1eb423065 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6885892 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Auto-Submit: Tom Sepez <tsepez@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Tom Sepez 25390156 2025-08-21T00:13:19 Suppress unsafe buffers on a file-by-file basis in src/ [1 of N] In this CL, we suppress many files but stop short of actually enabling the warning by not removing the line from the unsafe_buffers_paths.txt file. That will happen in a follow-on CL, along with resolving any stragglers missed here. This is mostly a manual change so as to familiarize myself with the kinds of issues faced by the Angle codebase when applying buffer safety warnings. -- Re-generate affected hashes. -- Clang-format applied to all changed files. -- Add a few missing .reserve() calls to vectors as noticed. -- Fix some mismatches between file names and header comments. -- Be more consistent with header comment format (blank lines and trailing //-only lines when a filename comment adjoins license boilerplate). Bug: b/436880895 Change-Id: I3bde5cc2059acbe8345057289214f1a26f1c34aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6869022 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Akihiko Odaki bec220f6 2022-11-01T22:05:30 Translator: Fix operand component specifications Before this change, TIntermConstantUnion::foldUnaryComponentWise always used the first operand component for some operators. Use the operand component corresponding to the result component. Bug: angleproject:7801 Change-Id: I99a941a9eee0c10a4bcb3f515aa5cbf5accc0d52 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3996520 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Auto-Submit: 小田喜陽彦 <akihiko.odaki@gmail.com> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Stuart Morgan 9d737966 2019-08-14T12:25:12 Standardize copyright notices to project style For all "ANGLE Project" copyrights, standardize to the format specified by the style guide. Changes: - "Copyright (c)" and "Copyright(c)" changed to just "Copyright". - Removed the second half of date ranges ("Y1Y1-Y2Y2"->"Y1Y1"). - Fixed a small number of files that had no copyright date using the initial commit year from the version control history. - Fixed one instance of copyright being "The ANGLE Project" rather than "The ANGLE Project Authors" These changes are applied both to the copyright of source file, and where applicable to copyright statements that are generated by templates. BUG=angleproject:3811 Change-Id: I973dd65e4ef9deeba232d5be74c768256a0eb2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1754397 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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>
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 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 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 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 cccf2b00 2017-07-05T14:50:54 Reorganize AST traversal utility code Define TIntermTraverser and TIntermLValueTrackingTraverser in a separate header file. hash() function is moved out from TIntermTraverser as it is not related to the core functionality of traversing and transforming ASTs. Also reorganize some traversers to follow common conventions: - Intermediate output is now in OutputTree.h/.cpp - Max tree depth check is now in IsASTDepthBelowLimit.h/.cpp BUG=angleproject:1490 TEST=angle_unittests Change-Id: Id4968aa9d4e24d0c5bac90dc147fc9f310de0184 Reviewed-on: https://chromium-review.googlesource.com/559531 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 9250cb24 2017-01-21T10:51:27 Add ESSL 3.10 integer math built-ins This adds built-ins found in ESSL 3.10 section 8.8 Integer functions. This includes constant folding support for functions that may be constant folded, and support for both GLSL and HLSL output. In HLSL several of the functions need to be emulated. The precision qualification for the return value of some of these functions is determined by special rules, that are now part of type promotion for TIntermUnary nodes and determining the type of TIntermAggregate nodes. BUG=angleproject:1730 TEST=angle_unittests TEST=dEQP-GLES31.functional.shaders.builtin_functions.integer.* Change-Id: Ib0056c17671c42b6496c2f0ef059b99f8f25c122 Reviewed-on: https://chromium-review.googlesource.com/431310 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 72fc5547 2016-12-19T19:53:29 Add a ShaderCompileTreeTest base class to use in compiler tests The test class provides facilities for parsing test shader source into an AST and determining compile status. Compilation flags change for some of the tests, but this should only have a minor effect on code coverage - mostly affecting non-core parts such as intermediate output. BUG=angleproject:1673 TEST=angle_unittests Change-Id: I7d0900ef490e021272a27c4b0c938bfee02abf39 Reviewed-on: https://chromium-review.googlesource.com/422367 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 2d73665d 2016-11-30T10:37:49 Handle constant folding arithmetic involving infinity Constant folding arithmetic operations that involve infinity are now handled correctly in the cases where the result is infinity or zero. The implementation mostly relies on C++ to implement IEEE float arithmetic correctly so that unnecessary overhead is avoided. Constant folding arithmetic operations that result in overflow now issue a warning but result in infinity. This is not mandated by the spec but is a reasonable choice since it is the behavior of the default IEEE rounding mode. Constant folding arithmetic operations that result in NaN in IEEE will generate a warning but the NaN is kept. This is also not mandated by the spec, but is among the allowed behaviors. There's no special handling for ESSL 1.00. ESSL 1.00 doesn't really have the concept of NaN, but since it is not feasible to control generating NaNs at shader run time either way, it should not be a big issue if constant folding may generate them as well. TEST=angle_unittests BUG=chromium:661857 Change-Id: I06116c6fdd02f224939d4a651e4e62f2fd4c98a8 Reviewed-on: https://chromium-review.googlesource.com/414911 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 08d4aa93 2016-11-23T16:15:49 Refactor constant folding tests The constant folding test classes are moved into a separate file in test_utils. This will enable adding multiple test files that use constant folding test classes, so that constant folding tests can be organized better. TEST=angle_unittests BUG=chromium:661857 Change-Id: I00bf25a4b941bdc1364ff5aa9bee2d571e4b0ea0 Reviewed-on: https://chromium-review.googlesource.com/414910 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>