Add a GetVariableInfo helper method.
This method replaces the similar logic in storing uniforms,
varyings, and interface blocks when collecting variable info.
We can also re-use this method for both GLSL and HLSL programs.
BUG=angle:466
Change-Id: Ie6c13abe0f09f38b2f9b36e117caae4833eaccbf
Reviewed-on: https://chromium-review.googlesource.com/206566
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <capn@chromium.org>
diff --git a/src/compiler/translator/util.h b/src/compiler/translator/util.h
index 4dbaf3c..7eac07b 100644
--- a/src/compiler/translator/util.h
+++ b/src/compiler/translator/util.h
@@ -7,6 +7,8 @@
#ifndef COMPILER_UTIL_H
#define COMPILER_UTIL_H
+#include <stack>
+
#include "compiler/translator/Types.h"
#include "angle_gl.h"
#include "common/shadervars.h"
@@ -32,6 +34,33 @@
InterpolationType GetInterpolationType(TQualifier qualifier);
TString ArrayString(const TType &type);
+template <typename VarT>
+class GetVariableTraverser
+{
+ public:
+ void traverse(const TType &type, const TString &name);
+
+ protected:
+ GetVariableTraverser(std::vector<VarT> *output);
+
+ // Must be overloaded
+ virtual void visitVariable(VarT *newVar) = 0;
+
+ private:
+ std::stack<std::vector<VarT> *> mOutputStack;
+};
+
+struct GetInterfaceBlockFieldTraverser : public GetVariableTraverser<InterfaceBlockField>
+{
+ public:
+ GetInterfaceBlockFieldTraverser(std::vector<InterfaceBlockField> *output, bool isRowMajorMatrix);
+
+ private:
+ virtual void visitVariable(InterfaceBlockField *newField);
+
+ bool mIsRowMajorMatrix;
+};
+
}
#endif // COMPILER_UTIL_H