Clean up direct access of ShaderVariable::arraySize
This change is pure refactoring. It's intended to help with adding
support for arrays of arrays.
BUG=angleproject:2125
TEST=angle_unittests
Change-Id: I82881a98c3c476fd6666a551ce6be255ae0de4cf
Reviewed-on: https://chromium-review.googlesource.com/733127
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/CollectVariables.cpp b/src/compiler/translator/CollectVariables.cpp
index 5eccbf2..26378dc 100644
--- a/src/compiler/translator/CollectVariables.cpp
+++ b/src/compiler/translator/CollectVariables.cpp
@@ -353,34 +353,27 @@
info.name = kName;
info.mappedName = kName;
info.type = GL_NONE;
- info.arraySize = 0;
info.precision = GL_NONE;
info.staticUse = true;
- ShaderVariable nearInfo;
+ ShaderVariable nearInfo(GL_FLOAT);
const char kNearName[] = "near";
nearInfo.name = kNearName;
nearInfo.mappedName = kNearName;
- nearInfo.type = GL_FLOAT;
- nearInfo.arraySize = 0;
nearInfo.precision = GL_HIGH_FLOAT;
nearInfo.staticUse = true;
- ShaderVariable farInfo;
+ ShaderVariable farInfo(GL_FLOAT);
const char kFarName[] = "far";
farInfo.name = kFarName;
farInfo.mappedName = kFarName;
- farInfo.type = GL_FLOAT;
- farInfo.arraySize = 0;
farInfo.precision = GL_HIGH_FLOAT;
farInfo.staticUse = true;
- ShaderVariable diffInfo;
+ ShaderVariable diffInfo(GL_FLOAT);
const char kDiffName[] = "diff";
diffInfo.name = kDiffName;
diffInfo.mappedName = kDiffName;
- diffInfo.type = GL_FLOAT;
- diffInfo.arraySize = 0;
diffInfo.precision = GL_HIGH_FLOAT;
diffInfo.staticUse = true;
@@ -447,7 +440,6 @@
info.name = kName;
info.mappedName = kName;
info.type = GL_INT;
- info.arraySize = 0;
info.precision = GL_HIGH_INT; // Defined by spec.
info.staticUse = true;
info.location = -1;
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index b7af2d7..f18fd30 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -1020,7 +1020,7 @@
void TCompiler::initializeGLPosition(TIntermBlock *root)
{
InitVariableList list;
- sh::ShaderVariable var(GL_FLOAT_VEC4, 0);
+ sh::ShaderVariable var(GL_FLOAT_VEC4);
var.name = "gl_Position";
list.push_back(var);
InitializeVariables(root, list, symbolTable, shaderVersion, extensionBehavior);
diff --git a/src/compiler/translator/ShaderVars.cpp b/src/compiler/translator/ShaderVars.cpp
index 7a6e181..d51ca5b 100644
--- a/src/compiler/translator/ShaderVars.cpp
+++ b/src/compiler/translator/ShaderVars.cpp
@@ -34,9 +34,15 @@
{
}
+ShaderVariable::ShaderVariable(GLenum typeIn)
+ : type(typeIn), precision(0), arraySize(0), staticUse(false)
+{
+}
+
ShaderVariable::ShaderVariable(GLenum typeIn, unsigned int arraySizeIn)
: type(typeIn), precision(0), arraySize(arraySizeIn), staticUse(false)
{
+ ASSERT(arraySizeIn != 0);
}
ShaderVariable::~ShaderVariable()