Home | History | Annotate | Download | only in translator
      1 //
      2 // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 #ifndef COMPILER_VARIABLE_INFO_H_
      8 #define COMPILER_VARIABLE_INFO_H_
      9 
     10 #include <GLSLANG/ShaderLang.h>
     11 
     12 #include "compiler/translator/IntermNode.h"
     13 
     14 namespace sh
     15 {
     16 
     17 // Traverses intermediate tree to collect all attributes, uniforms, varyings.
     18 class CollectVariables : public TIntermTraverser
     19 {
     20   public:
     21     CollectVariables(std::vector<Attribute> *attribs,
     22                      std::vector<Attribute> *outputVariables,
     23                      std::vector<Uniform> *uniforms,
     24                      std::vector<Varying> *varyings,
     25                      std::vector<InterfaceBlock> *interfaceBlocks,
     26                      ShHashFunction64 hashFunction);
     27 
     28     virtual void visitSymbol(TIntermSymbol *symbol);
     29     virtual bool visitAggregate(Visit, TIntermAggregate *node);
     30     virtual bool visitBinary(Visit visit, TIntermBinary *binaryNode);
     31 
     32   private:
     33     template <typename VarT>
     34     void visitVariable(const TIntermSymbol *variable, std::vector<VarT> *infoList) const;
     35 
     36     template <typename VarT>
     37     void visitInfoList(const TIntermSequence &sequence, std::vector<VarT> *infoList) const;
     38 
     39     std::vector<Attribute> *mAttribs;
     40     std::vector<Attribute> *mOutputVariables;
     41     std::vector<Uniform> *mUniforms;
     42     std::vector<Varying> *mVaryings;
     43     std::vector<InterfaceBlock> *mInterfaceBlocks;
     44 
     45     std::map<std::string, InterfaceBlockField *> mInterfaceBlockFields;
     46 
     47     bool mPointCoordAdded;
     48     bool mFrontFacingAdded;
     49     bool mFragCoordAdded;
     50 
     51     ShHashFunction64 mHashFunction;
     52 };
     53 
     54 // Expand struct variables to flattened lists of split variables
     55 template <typename VarT>
     56 void ExpandVariables(const std::vector<VarT> &compact,
     57                      std::vector<ShaderVariable> *expanded);
     58 
     59 }
     60 
     61 #endif  // COMPILER_VARIABLE_INFO_H_
     62