src/compiler/translator/tree_util/IntermTraverse.cpp


Log

Author Commit Date CI Message
Shahbaz Youssefi 9d0e2851 2021-09-01T00:42:58 Fix SeparateDeclarations vs struct specifiers Bug: chromium:1237696 Change-Id: I3b00f3797800e814ca83226a8e4f25b2a43cc641 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3133824 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 800e82c6 2021-08-23T11:05:23 Translator: Validate precisions When declaring a variable, a struct field, function parameter etc, there's a precision necessarily applied to the entity being declared. AST Validation is added to enforce this. Intermediate nodes derive their precision from these entities automatically. Consistency of intermediate nodes is not validated. This is because AST transformations replace a node with a transformed one, and that may not have the same precision. Take the following code: mediump float x = ...; mediump float y = ...; ... x + y ... and assume is transformed as such: highp float driver_uniform; ... (x * driver_uniform) + y ... The addition was originally done in mediump, but would seemingly need to be done in highp after transformation. There are a number of options here: - Make sure that when nodes are replaced, the precision is unaffected. This can be intrusive, requiring temp variables. - Bubble up the new precision - Accept the discrepancy ANGLE opts for the last option, which actually respects the original shader's intended precision for operations, even if some transformation needs to temporarily evaluate an expression at a higher precision. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Ibcde3a230de159157783b1c6d5ef1cd63ceb4d8f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3114027 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 0e1c90cf 2021-07-21T10:24:26 Translator: Validate function parameter qualifiers This change cleans up a confusion in EvqConst and EvqConstReadOnly, where the former was frequently used instead of the latter for function parameters. The change makes the following renames to make the intent of the relevant qualifiers clearer: EvqIn -> EvqParamIn EvqOut -> EvqParamOut EvqInOut -> EvqParamInOut EvqConstReadOnly -> EvqParamConst Bug: angleproject:4889 Change-Id: Idedd32c08a91de069b91b1657d6b783dddece04a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3041622 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi dc59772e 2021-06-22T22:37:26 Vulkan: SPIR-V Gen: Support switch With the infrastructure to support this in place, switch is simply implemented as a conditional with multiple blocks. Each block either ends with a branch to the merge block or the next block, implementing fallthrough. Bug: angleproject:4889 Change-Id: I5831531d918ac06648cced7707d1d48ffeb6b1b0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2983559 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 3f9dcb00 2021-06-12T01:37:32 Translator: Prune trivial dead code Code after discard, return, break and continue is discarded with this change. This simplifies SPIR-V generation as no code is allowed after a branch instruction and no special handling is necessary after this change. Bug: angleproject:4889 Change-Id: Ife9c8de8a6d0db9d682561daf44366aad9b1cf61 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2957811 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 77831a6d 2021-05-31T22:41:58 Vulkan: SPIR-V Gen: If-else blocks This change implements if-else blocks as well as a few simple binary operations (equality, less-than etc). It builds on prior work to generate the function in separate blocks and introduces a "conditionals" stack to support nesting of if-else blocks, switches and loops. Bug: angleproject:4889 Change-Id: If7694000487811837ed5946753568b41d67199f0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2929660 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi be873929 2021-05-26T21:55:50 Vulkan: SPIR-V Gen: Handle constants and constructors This change translates constants and constructors (minus type casting). With this change, shaders such as gl_Position = vec4(aposition, 0, 1); are translated correctly. Bug: angleproject:4889 Change-Id: I4463717cf880c6d05db179b98691d5cabc1a2d7c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2920192 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 249cb200 2019-12-03T11:10:06 Translator: Rename TIntermInvariantDeclaration to ..GlobalQualifier.. This is to support the upcoming `precise` keyword. Bug: angleproject:3569 Change-Id: Idbcc8fd6f261757dbbf81b381e7a2dae938d8101 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1947451 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 859ca039 2019-10-24T12:55:08 Enable "-Wshadow-field". This warning verifies we don't give variables names that shadow fields. This is another good warning to enable that Skia requires. This CL also fixes a small number of points in code that used this bad pattern. We have to disable the warning for Glslang for now. Bug: angleproject:4046 Change-Id: I072a686e3023b60cfafa778525fe712ce1fb5a50 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1877476 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 472c74c6 2019-08-19T16:32:13 Translator: Allow tree validation in children of TCompiler This is to be able to perform validation inside TranslatorVulkan, even if it's through ASSERTs. Additionally, every transformation is changed such that they do their validation themselves. TIntermTraverser::updateTree() performs the validation, which indirectly validates many of three tree transformations. Some of the more ancient transformations that don't use this function directly call TCompiler::validateAST. Bug: angleproject:2733 Change-Id: Ie4af029d34e053c5ad1dc8c2c2568eecd625d344 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1761149 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
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>
Shahbaz Youssefi c13ca2af 2019-07-17T15:46:29 Vulkan: Allow more than one atomic counter buffer binding dEQP assumes there are more than one atomic counter buffers available. This is technically not a requirement by the standard, but nevertheless could be what applications expect as well. This change adds support for multiple atomic counter buffer bindings. This is done by declaring an array of storage buffers for the atomic counter buffers (instead of declaring only one) and passing the (binding, offset) pair around to functions instead of just the offset. The atomic counter is found by indexing `binding` into the storage buffer array first before indexing `offset` into its `uint[]`. ProgramVk's default uniform collection is also fixed not to include atomic counter uniforms. A remaining issue is that atomic counter buffer offsets don't have alignment requirements in GLES, but Vulkan does for storage buffers. Similar to emulated transform feedback buffer offsets, these should be sent to the shader through uniform values. This will be done in a follow up change. Bug: angleproject:3566 Change-Id: I5600225c24c38f1a8ecf5c64388073055733197d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1707931 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jeff Gilbert a96b79f9 2019-07-26T17:33:16 Explicitly instantiate TIntermTraverser::traverse(TIntermNode *). (on behalf of RewriteAtomicFunctionExpressions) The compile will occasionally choose to inline all instances of this function, and therefore not export this entrypoint into the object file, leaving other TUs (RewriteAtomicFunctionExpressions) with missing link symbols. Bug: angleproject:3752 Change-Id: Ida778bcd897a85567680911a88aae88a3797aa93 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1721954 Commit-Queue: Jeff Gilbert <jgilbert@mozilla.com> 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>
Bryan Bernhart c55aefe3 2018-08-28T19:59:00 ES31: Support atomic functions on D3D11 - Part III This patch is the third one to support atomic functions on D3D11. In this patch we enable support for atomic function returns outside of assignments (e.g. part of arithmetic operations or to index into arrays) and when used directly initialize a variable. Note that we are still missing the functionality to be tag loops with [allow_uav_condition] as required by InterlockedCompareExchange. BUG=angleproject:2682 TEST=angle_end2end_tests Change-Id: Ia409ebb10621fd5c514cf6c76f366a320a9d9fc1 Reviewed-on: https://chromium-review.googlesource.com/1208317 Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Jamie Madill 1283ef62 2018-07-12T10:15:42 translator: Add TIntermPreprocessorDirective. This new node type can be used to inject preprocessor directives into the intermediate tree. Outputting the preprocessor directive is easy for the GLSL back-end. This can be used to implement workarounds such as the OpenGL line rasterization rules on Vulkan. Also fixes the build that was broken on Win/x64 with a prior change and makes more methods in IntermNode.h const. Bug: angleproject:2598 Change-Id: Ifd6d0ac7912ccf2137997bb9a0187fd063023d5e Reviewed-on: https://chromium-review.googlesource.com/1133420 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho c9c259cc 2018-06-13T11:03:22 Add a shared traverse() function for most node types The traversal logic for many node types is essentially the same. Use a single traverse() function for all simple node types instead of having different ones for each node type. Special traversal code is only needed for those node types where the traversal logic is overridden in specific traversers or which do special bookkeeping. This makes traverser behavior a bit more consistent: InVisit calls are now done for all node types, including if/else, ternary and loop nodes. Also false returned from visit function will always skip traversing the next children of that node. This reduces shader_translator binary size on Windows by 8 kilobytes. The added helper functions will also make it easier to implement alternative more efficient traversers. Unfortunately this also regresses compiler perf tests by around 2-3%. BUG=angleproject:2662 TEST=angle_unittests, angle_end2end_tests Change-Id: I3cb1256297b66e1db4b133b8fb84a24c349a9e29 Reviewed-on: https://chromium-review.googlesource.com/1133009 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 93279812 2018-06-13T11:22:15 Remove unnecessary checks when traversing nodes All children of binary and ternary nodes are guaranteed to be non-null. We don't need to check for their existence when traversing the tree. BUG=angleproject:2662 TEST=angle_unittests Change-Id: I5575058e7213d0c4b4554ca616b4298e535842d6 Reviewed-on: https://chromium-review.googlesource.com/1098670 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho f462ac1b 2018-06-13T10:22:43 Remove TIntermRaw It's not used anywhere and removing it will make changing traversal code a bit simpler. BUG=angleproject:2662 TEST=angle_unittests Change-Id: I4a430a09ceb538c8b0e5d1bb0a95f3fd7657c276 Reviewed-on: https://chromium-review.googlesource.com/1098671 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 4002e92a 2018-04-04T16:55:34 Guard traversers used during parsing against stack overflow Traversers used during parsing can be vulnerable to stack overflow since the AST has not yet been validated for max depth. Make sure to check for traversal depth in traversers used during parsing. We set the maximum traversal depth in ValidateGlobalInitializer and ValidateSwitchStatementList to 256, which matches the default value for validating general AST complexity. The depth check is on regardless of compiler options. In case the traversers go over the maximum traversal depth, they fail validation. BUG=angleproject:2453 TEST=angle_unittests Change-Id: I89ba576e8ef69663ba35d7b9050a6da319f1757c Reviewed-on: https://chromium-review.googlesource.com/995795 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
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>