blob: b9ff8ef07d475f8e5636725f3832d7faab990db5 [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
Jamie Madill13cfd272014-07-17 14:16:28 -040010#include <GLSLANG/ShaderVars.h>
11
Geoff Lang17732822013-08-29 13:46:49 -040012#include "compiler/translator/intermediate.h"
alokp@chromium.org07620a52010-09-23 17:53:56 +000013
Zhenyao Mo74da9f22013-09-23 14:57:01 -040014// Traverses intermediate tree to collect all attributes, uniforms, varyings.
Jamie Madill23a8a432014-07-09 13:27:42 -040015class CollectVariables : public TIntermTraverser
16{
17 public:
Jamie Madilla718c1e2014-07-02 15:31:22 -040018 CollectVariables(std::vector<sh::Attribute> *attribs,
Jamie Madilld5512cd2014-07-10 17:50:08 -040019 std::vector<sh::Attribute> *outputVariables,
Jamie Madilla718c1e2014-07-02 15:31:22 -040020 std::vector<sh::Uniform> *uniforms,
21 std::vector<sh::Varying> *varyings,
Jamie Madilld5512cd2014-07-10 17:50:08 -040022 std::vector<sh::InterfaceBlock> *interfaceBlocks,
Zhenyao Mo74da9f22013-09-23 14:57:01 -040023 ShHashFunction64 hashFunction);
alokp@chromium.org07620a52010-09-23 17:53:56 +000024
Jamie Madill4667c452014-07-08 15:02:36 -040025 virtual void visitSymbol(TIntermSymbol *symbol);
26 virtual bool visitAggregate(Visit, TIntermAggregate *node);
alokp@chromium.org07620a52010-09-23 17:53:56 +000027
Jamie Madill23a8a432014-07-09 13:27:42 -040028 private:
Jamie Madilld5512cd2014-07-10 17:50:08 -040029 template <typename VarT>
30 void visitVariable(const TIntermSymbol *variable, std::vector<VarT> *infoList) const;
31
32 template <typename VarT>
33 void visitInfoList(const TIntermSequence &sequence, std::vector<VarT> *infoList) const;
34
Jamie Madilla718c1e2014-07-02 15:31:22 -040035 std::vector<sh::Attribute> *mAttribs;
Jamie Madilld5512cd2014-07-10 17:50:08 -040036 std::vector<sh::Attribute> *mOutputVariables;
Jamie Madilla718c1e2014-07-02 15:31:22 -040037 std::vector<sh::Uniform> *mUniforms;
38 std::vector<sh::Varying> *mVaryings;
Jamie Madilld5512cd2014-07-10 17:50:08 -040039 std::vector<sh::InterfaceBlock> *mInterfaceBlocks;
40
41 std::map<std::string, sh::InterfaceBlockField *> mInterfaceBlockFields;
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000042
Zhenyao Mod2d340b2013-09-23 14:57:05 -040043 bool mPointCoordAdded;
44 bool mFrontFacingAdded;
45 bool mFragCoordAdded;
46
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000047 ShHashFunction64 mHashFunction;
alokp@chromium.org07620a52010-09-23 17:53:56 +000048};
49
Jamie Madill23a8a432014-07-09 13:27:42 -040050// Expand struct variables to flattened lists of split variables
51// Implemented for sh::Varying and sh::Uniform.
52template <typename VarT>
53void ExpandVariables(const std::vector<VarT> &compact, std::vector<VarT> *expanded);
54
daniel@transgaming.com5cb728c2011-05-17 18:34:24 +000055#endif // COMPILER_VARIABLE_INFO_H_