blob: b4b18863571b2d83b9ae40ef0adf2835b4db45b0 [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
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);
Jamie Madillb547ddf2014-08-25 16:20:46 -040027 virtual bool visitBinary(Visit visit, TIntermBinary *binaryNode);
alokp@chromium.org07620a52010-09-23 17:53:56 +000028
Jamie Madill23a8a432014-07-09 13:27:42 -040029 private:
Jamie Madilld5512cd2014-07-10 17:50:08 -040030 template <typename VarT>
31 void visitVariable(const TIntermSymbol *variable, std::vector<VarT> *infoList) const;
32
33 template <typename VarT>
34 void visitInfoList(const TIntermSequence &sequence, std::vector<VarT> *infoList) const;
35
Jamie Madilla718c1e2014-07-02 15:31:22 -040036 std::vector<sh::Attribute> *mAttribs;
Jamie Madilld5512cd2014-07-10 17:50:08 -040037 std::vector<sh::Attribute> *mOutputVariables;
Jamie Madilla718c1e2014-07-02 15:31:22 -040038 std::vector<sh::Uniform> *mUniforms;
39 std::vector<sh::Varying> *mVaryings;
Jamie Madilld5512cd2014-07-10 17:50:08 -040040 std::vector<sh::InterfaceBlock> *mInterfaceBlocks;
41
42 std::map<std::string, sh::InterfaceBlockField *> mInterfaceBlockFields;
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000043
Zhenyao Mod2d340b2013-09-23 14:57:05 -040044 bool mPointCoordAdded;
45 bool mFrontFacingAdded;
46 bool mFragCoordAdded;
47
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000048 ShHashFunction64 mHashFunction;
alokp@chromium.org07620a52010-09-23 17:53:56 +000049};
50
Jamie Madill23a8a432014-07-09 13:27:42 -040051// Expand struct variables to flattened lists of split variables
Jamie Madill23a8a432014-07-09 13:27:42 -040052template <typename VarT>
Jamie Madill42bcf322014-08-25 16:20:46 -040053void ExpandVariables(const std::vector<VarT> &compact,
54 std::vector<sh::ShaderVariable> *expanded);
Jamie Madill23a8a432014-07-09 13:27:42 -040055
daniel@transgaming.com5cb728c2011-05-17 18:34:24 +000056#endif // COMPILER_VARIABLE_INFO_H_