blob: 5ac4c46baa537c99ad2d2af859bb4b903ada680c [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 Madille294bb82014-07-17 14:16:26 -040010#include <GLSLANG/ShaderLang.h>
Jamie Madill13cfd272014-07-17 14:16:28 -040011
Jamie Madillb1a85f42014-08-19 15:23:24 -040012#include "compiler/translator/IntermNode.h"
alokp@chromium.org07620a52010-09-23 17:53:56 +000013
Jamie Madilla2fbb842014-09-03 09:40:47 -040014namespace sh
15{
16
Zhenyao Mo74da9f22013-09-23 14:57:01 -040017// Traverses intermediate tree to collect all attributes, uniforms, varyings.
Jamie Madill23a8a432014-07-09 13:27:42 -040018class CollectVariables : public TIntermTraverser
19{
20 public:
Jamie Madilla2fbb842014-09-03 09:40:47 -040021 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,
Zhenyao Mo74da9f22013-09-23 14:57:01 -040026 ShHashFunction64 hashFunction);
alokp@chromium.org07620a52010-09-23 17:53:56 +000027
Jamie Madill4667c452014-07-08 15:02:36 -040028 virtual void visitSymbol(TIntermSymbol *symbol);
29 virtual bool visitAggregate(Visit, TIntermAggregate *node);
Jamie Madillb547ddf2014-08-25 16:20:46 -040030 virtual bool visitBinary(Visit visit, TIntermBinary *binaryNode);
alokp@chromium.org07620a52010-09-23 17:53:56 +000031
Jamie Madill23a8a432014-07-09 13:27:42 -040032 private:
Jamie Madilld5512cd2014-07-10 17:50:08 -040033 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
Jamie Madilla2fbb842014-09-03 09:40:47 -040039 std::vector<Attribute> *mAttribs;
40 std::vector<Attribute> *mOutputVariables;
41 std::vector<Uniform> *mUniforms;
42 std::vector<Varying> *mVaryings;
43 std::vector<InterfaceBlock> *mInterfaceBlocks;
Jamie Madilld5512cd2014-07-10 17:50:08 -040044
Jamie Madilla2fbb842014-09-03 09:40:47 -040045 std::map<std::string, InterfaceBlockField *> mInterfaceBlockFields;
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000046
Zhenyao Mod2d340b2013-09-23 14:57:05 -040047 bool mPointCoordAdded;
48 bool mFrontFacingAdded;
49 bool mFragCoordAdded;
50
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000051 ShHashFunction64 mHashFunction;
alokp@chromium.org07620a52010-09-23 17:53:56 +000052};
53
Jamie Madill23a8a432014-07-09 13:27:42 -040054// Expand struct variables to flattened lists of split variables
Jamie Madill23a8a432014-07-09 13:27:42 -040055template <typename VarT>
Jamie Madill42bcf322014-08-25 16:20:46 -040056void ExpandVariables(const std::vector<VarT> &compact,
Jamie Madilla2fbb842014-09-03 09:40:47 -040057 std::vector<ShaderVariable> *expanded);
58
59}
Jamie Madill23a8a432014-07-09 13:27:42 -040060
daniel@transgaming.com5cb728c2011-05-17 18:34:24 +000061#endif // COMPILER_VARIABLE_INFO_H_