blob: 3c7f2a5f84f2638e537ade3af922fdafacfaf06f [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
alokp@chromium.org07620a52010-09-23 17:53:56 +000010#include "GLSLANG/ShaderLang.h"
11#include "compiler/intermediate.h"
12
13// Provides information about a variable.
14// It is currently being used to store info about active attribs and uniforms.
15struct TVariableInfo {
gman@chromium.org8d804792012-10-17 21:33:48 +000016 TVariableInfo(ShDataType type, int size);
17 TVariableInfo();
18
alokp@chromium.org07620a52010-09-23 17:53:56 +000019 TPersistString name;
zmo@google.comfd747b82011-04-23 01:30:07 +000020 TPersistString mappedName;
alokp@chromium.org4888ceb2010-10-01 21:13:12 +000021 ShDataType type;
alokp@chromium.org07620a52010-09-23 17:53:56 +000022 int size;
Zhenyao Mo74da9f22013-09-23 14:57:01 -040023 TPrecision precision;
Zhenyao Mod2d340b2013-09-23 14:57:05 -040024 bool staticUse;
alokp@chromium.org07620a52010-09-23 17:53:56 +000025};
26typedef std::vector<TVariableInfo> TVariableInfoList;
27
Zhenyao Mo74da9f22013-09-23 14:57:01 -040028// Traverses intermediate tree to collect all attributes, uniforms, varyings.
29class CollectVariables : public TIntermTraverser {
alokp@chromium.org07620a52010-09-23 17:53:56 +000030public:
Zhenyao Mo74da9f22013-09-23 14:57:01 -040031 CollectVariables(TVariableInfoList& attribs,
32 TVariableInfoList& uniforms,
33 TVariableInfoList& varyings,
34 ShHashFunction64 hashFunction);
alokp@chromium.org07620a52010-09-23 17:53:56 +000035
36 virtual void visitSymbol(TIntermSymbol*);
alokp@chromium.orgee76f6a2010-09-27 19:28:55 +000037 virtual bool visitAggregate(Visit, TIntermAggregate*);
alokp@chromium.org07620a52010-09-23 17:53:56 +000038
39private:
40 TVariableInfoList& mAttribs;
41 TVariableInfoList& mUniforms;
Zhenyao Mo74da9f22013-09-23 14:57:01 -040042 TVariableInfoList& mVaryings;
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
daniel@transgaming.com5cb728c2011-05-17 18:34:24 +000051#endif // COMPILER_VARIABLE_INFO_H_