blob: ddbfb05c2d1f4ec2042f8eaad179aef96319df95 [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
Geoff Lang17732822013-08-29 13:46:49 -040010#include "compiler/translator/intermediate.h"
Jamie Madilla718c1e2014-07-02 15:31:22 -040011#include "common/shadervars.h"
alokp@chromium.org07620a52010-09-23 17:53:56 +000012
Zhenyao Mo74da9f22013-09-23 14:57:01 -040013// Traverses intermediate tree to collect all attributes, uniforms, varyings.
Jamie Madill23a8a432014-07-09 13:27:42 -040014class CollectVariables : public TIntermTraverser
15{
16 public:
Jamie Madilla718c1e2014-07-02 15:31:22 -040017 CollectVariables(std::vector<sh::Attribute> *attribs,
18 std::vector<sh::Uniform> *uniforms,
19 std::vector<sh::Varying> *varyings,
Zhenyao Mo74da9f22013-09-23 14:57:01 -040020 ShHashFunction64 hashFunction);
alokp@chromium.org07620a52010-09-23 17:53:56 +000021
Jamie Madill4667c452014-07-08 15:02:36 -040022 virtual void visitSymbol(TIntermSymbol *symbol);
23 virtual bool visitAggregate(Visit, TIntermAggregate *node);
alokp@chromium.org07620a52010-09-23 17:53:56 +000024
Jamie Madill23a8a432014-07-09 13:27:42 -040025 private:
Jamie Madilla718c1e2014-07-02 15:31:22 -040026 std::vector<sh::Attribute> *mAttribs;
27 std::vector<sh::Uniform> *mUniforms;
28 std::vector<sh::Varying> *mVaryings;
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000029
Zhenyao Mod2d340b2013-09-23 14:57:05 -040030 bool mPointCoordAdded;
31 bool mFrontFacingAdded;
32 bool mFragCoordAdded;
33
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +000034 ShHashFunction64 mHashFunction;
Jamie Madilla718c1e2014-07-02 15:31:22 -040035
36 template <typename VarT>
Jamie Madill4667c452014-07-08 15:02:36 -040037 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;
alokp@chromium.org07620a52010-09-23 17:53:56 +000041};
42
Jamie Madill23a8a432014-07-09 13:27:42 -040043// Expand struct variables to flattened lists of split variables
44// Implemented for sh::Varying and sh::Uniform.
45template <typename VarT>
46void ExpandVariables(const std::vector<VarT> &compact, std::vector<VarT> *expanded);
47
daniel@transgaming.com5cb728c2011-05-17 18:34:24 +000048#endif // COMPILER_VARIABLE_INFO_H_