Edit

kc3-lang/angle/src/compiler/translator/RemoveInvariantDeclaration.cpp

Branch :

  • Show log

    Commit

  • Author : Olli Etuaho
    Date : 2016-12-09 11:30:15
    Hash : bf4e1b73
    Message : Split TIntermInvariantDeclaration from TIntermAggregate This change is pure refactoring and doesn't fix bugs related to invariant declarations. Invariant declarations are supposed to accept a list of identifiers, but this refactoring keeps the current behavior of only accepting a single identifier in an invariant declaration. When the bug will be fixed, the new TIntermInvariantDeclaration class that now has only a single child node can be changed so that it may have multiple children. TIntermAggregate is still used for function calls, function prototypes and function parameter lists. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I3e22092c87e1c06445fd7e123d9922c2fcb59428 Reviewed-on: https://chromium-review.googlesource.com/419415 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>

  • src/compiler/translator/RemoveInvariantDeclaration.cpp
  • //
    // Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    #include "compiler/translator/RemoveInvariantDeclaration.h"
    
    #include "compiler/translator/IntermNode.h"
    
    namespace sh
    {
    
    namespace
    {
    
    // An AST traverser that removes invariant declaration for input in fragment shader
    // when GLSL >= 4.20 and for output in vertex shader when GLSL < 4.2.
    class RemoveInvariantDeclarationTraverser : public TIntermTraverser
    {
      public:
        RemoveInvariantDeclarationTraverser() : TIntermTraverser(true, false, false) {}
    
      private:
        bool visitInvariantDeclaration(Visit visit, TIntermInvariantDeclaration *node) override
        {
            TIntermSequence emptyReplacement;
            mMultiReplacements.push_back(
                NodeReplaceWithMultipleEntry(getParentNode()->getAsBlock(), node, emptyReplacement));
            return false;
        }
    };
    
    }  // anonymous namespace
    
    void RemoveInvariantDeclaration(TIntermNode *root)
    {
        RemoveInvariantDeclarationTraverser traverser;
        root->traverse(&traverser);
        traverser.updateTree();
    }
    
    }  // namespace sh