blob: 0b7e033c6a4be5df32f9fc66266232b962cc032e [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
Geoff Lang0a73dd82014-11-19 16:18:08 -05007#ifndef COMPILER_TRANSLATOR_VARIABLEINFO_H_
8#define COMPILER_TRANSLATOR_VARIABLEINFO_H_
zmo@google.comfd747b82011-04-23 01:30:07 +00009
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 Mo94ac7b72014-10-15 18:22:08 -070014class TSymbolTable;
15
Jamie Madilla2fbb842014-09-03 09:40:47 -040016namespace sh
17{
18
Zhenyao Mo74da9f22013-09-23 14:57:01 -040019// Traverses intermediate tree to collect all attributes, uniforms, varyings.
Jamie Madill23a8a432014-07-09 13:27:42 -040020class CollectVariables : public TIntermTraverser
21{
22 public:
Jamie Madilla2fbb842014-09-03 09:40:47 -040023 CollectVariables(std::vector<Attribute> *attribs,
24 std::vector<Attribute> *outputVariables,
25 std::vector<Uniform> *uniforms,
26 std::vector<Varying> *varyings,
27 std::vector<InterfaceBlock> *interfaceBlocks,
Zhenyao Mo94ac7b72014-10-15 18:22:08 -070028 ShHashFunction64 hashFunction,
29 const TSymbolTable &symbolTable);
alokp@chromium.org07620a52010-09-23 17:53:56 +000030
Jamie Madill4667c452014-07-08 15:02:36 -040031 virtual void visitSymbol(TIntermSymbol *symbol);
32 virtual bool visitAggregate(Visit, TIntermAggregate *node);
Jamie Madillb547ddf2014-08-25 16:20:46 -040033 virtual bool visitBinary(Visit visit, TIntermBinary *binaryNode);
alokp@chromium.org07620a52010-09-23 17:53:56 +000034
Jamie Madill23a8a432014-07-09 13:27:42 -040035 private:
Jamie Madilld5512cd2014-07-10 17:50:08 -040036 template <typename VarT>
37 void visitVariable(const TIntermSymbol *variable, std::vector<VarT> *infoList) const;
38
39 template <typename VarT>
40 void visitInfoList(const TIntermSequence &sequence, std::vector<VarT> *infoList) const;
41
Jamie Madilla2fbb842014-09-03 09:40:47 -040042 std::vector<Attribute> *mAttribs;
43 std::vector<Attribute> *mOutputVariables;
44 std::vector<Uniform> *mUniforms;
45 std::vector<Varying> *mVaryings;
46 std::vector<InterfaceBlock> *mInterfaceBlocks;
Jamie Madilld5512cd2014-07-10 17:50:08 -040047
Jamie Madilla2fbb842014-09-03 09:40:47 -040048 std::map<std::string, InterfaceBlockField *> mInterfaceBlockFields;
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000049
Jamie Madill55def582015-05-04 11:24:57 -040050 bool mDepthRangeAdded;
Zhenyao Mod2d340b2013-09-23 14:57:05 -040051 bool mPointCoordAdded;
52 bool mFrontFacingAdded;
53 bool mFragCoordAdded;
54
Gregoire Payen de La Garanderieb3dced22015-01-12 14:54:55 +000055 bool mInstanceIDAdded;
Zhenyao Mo94ac7b72014-10-15 18:22:08 -070056 bool mPositionAdded;
57 bool mPointSizeAdded;
Erik Dahlströmea7a2122014-11-17 16:15:57 +010058 bool mLastFragDataAdded;
Zhenyao Mo94ac7b72014-10-15 18:22:08 -070059
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000060 ShHashFunction64 mHashFunction;
Zhenyao Mo94ac7b72014-10-15 18:22:08 -070061
62 const TSymbolTable &mSymbolTable;
alokp@chromium.org07620a52010-09-23 17:53:56 +000063};
64
Zhenyao Mo409078f2014-10-28 13:23:18 -070065// Expand struct uniforms to flattened lists of split variables
66void ExpandUniforms(const std::vector<Uniform> &compact,
67 std::vector<ShaderVariable> *expanded);
Jamie Madilla2fbb842014-09-03 09:40:47 -040068
69}
Jamie Madill23a8a432014-07-09 13:27:42 -040070
Geoff Lang0a73dd82014-11-19 16:18:08 -050071#endif // COMPILER_TRANSLATOR_VARIABLEINFO_H_