blob: 3771819c8bc1157841d090898993fb4eee3c71e8 [file] [log] [blame]
alokp@chromium.org07620a52010-09-23 17:53:56 +00001//
zmo@google.comfd747b82011-04-23 01:30:07 +00002// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org07620a52010-09-23 17:53:56 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
zmo@google.comfd747b82011-04-23 01:30:07 +00007#ifndef COMPILER_VARIABLE_INFO_H_
8#define COMPILER_VARIABLE_INFO_H_
9
Geoff Lang17732822013-08-29 13:46:49 -040010#include "compiler/translator/intermediate.h"
Jamie Madilla718c1e2014-07-02 15:31:22 -040011#include "common/shadervars.h"
alokp@chromium.org07620a52010-09-23 17:53:56 +000012
Zhenyao Mo74da9f22013-09-23 14:57:01 -040013// Traverses intermediate tree to collect all attributes, uniforms, varyings.
Jamie Madill23a8a432014-07-09 13:27:42 -040014class CollectVariables : public TIntermTraverser
15{
16 public:
Jamie Madilla718c1e2014-07-02 15:31:22 -040017 CollectVariables(std::vector<sh::Attribute> *attribs,
Jamie Madilld5512cd2014-07-10 17:50:08 -040018 std::vector<sh::Attribute> *outputVariables,
Jamie Madilla718c1e2014-07-02 15:31:22 -040019 std::vector<sh::Uniform> *uniforms,
20 std::vector<sh::Varying> *varyings,
Jamie Madilld5512cd2014-07-10 17:50:08 -040021 std::vector<sh::InterfaceBlock> *interfaceBlocks,
Zhenyao Mo74da9f22013-09-23 14:57:01 -040022 ShHashFunction64 hashFunction);
alokp@chromium.org07620a52010-09-23 17:53:56 +000023
Jamie Madill4667c452014-07-08 15:02:36 -040024 virtual void visitSymbol(TIntermSymbol *symbol);
25 virtual bool visitAggregate(Visit, TIntermAggregate *node);
alokp@chromium.org07620a52010-09-23 17:53:56 +000026
Jamie Madill23a8a432014-07-09 13:27:42 -040027 private:
Jamie Madilld5512cd2014-07-10 17:50:08 -040028 template <typename VarT>
29 void visitVariable(const TIntermSymbol *variable, std::vector<VarT> *infoList) const;
30
31 template <typename VarT>
32 void visitInfoList(const TIntermSequence &sequence, std::vector<VarT> *infoList) const;
33
Jamie Madilla718c1e2014-07-02 15:31:22 -040034 std::vector<sh::Attribute> *mAttribs;
Jamie Madilld5512cd2014-07-10 17:50:08 -040035 std::vector<sh::Attribute> *mOutputVariables;
Jamie Madilla718c1e2014-07-02 15:31:22 -040036 std::vector<sh::Uniform> *mUniforms;
37 std::vector<sh::Varying> *mVaryings;
Jamie Madilld5512cd2014-07-10 17:50:08 -040038 std::vector<sh::InterfaceBlock> *mInterfaceBlocks;
39
40 std::map<std::string, sh::InterfaceBlockField *> mInterfaceBlockFields;
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000041
Zhenyao Mod2d340b2013-09-23 14:57:05 -040042 bool mPointCoordAdded;
43 bool mFrontFacingAdded;
44 bool mFragCoordAdded;
45
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000046 ShHashFunction64 mHashFunction;
alokp@chromium.org07620a52010-09-23 17:53:56 +000047};
48
Jamie Madill23a8a432014-07-09 13:27:42 -040049// Expand struct variables to flattened lists of split variables
50// Implemented for sh::Varying and sh::Uniform.
51template <typename VarT>
52void ExpandVariables(const std::vector<VarT> &compact, std::vector<VarT> *expanded);
53
daniel@transgaming.com5cb728c2011-05-17 18:34:24 +000054#endif // COMPILER_VARIABLE_INFO_H_