Commit a3fe2b4e by Jamie Madill

Update non-default constructors in shadervars.h.

Most of these constructors are unused. Remove the unused ones, and change the usage of existing constructors to be consistent. BUG=angle:466,697 Change-Id: I455dd314036e1dfcb8c4690bab577b81dd0e060c Reviewed-on: https://chromium-review.googlesource.com/208355Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarNicolas Capens <capn@chromium.org>
parent f8bdfebc
......@@ -44,10 +44,9 @@ struct ShaderVariable
staticUse(false)
{}
ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
ShaderVariable(GLenum typeIn, unsigned int arraySizeIn)
: type(typeIn),
precision(precisionIn),
name(nameIn),
precision(0),
arraySize(arraySizeIn),
staticUse(false)
{}
......@@ -65,12 +64,7 @@ struct ShaderVariable
struct Uniform : public ShaderVariable
{
Uniform()
{}
Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn)
{}
Uniform() {}
bool isStruct() const { return !fields.empty(); }
......@@ -83,11 +77,6 @@ struct Attribute : public ShaderVariable
: location(-1)
{}
Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
location(locationIn)
{}
int location;
};
......@@ -97,11 +86,6 @@ struct InterfaceBlockField : public ShaderVariable
: isRowMajorMatrix(false)
{}
InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
isRowMajorMatrix(isRowMajorMatrix)
{}
bool isStruct() const { return !fields.empty(); }
bool isRowMajorMatrix;
......@@ -114,11 +98,6 @@ struct Varying : public ShaderVariable
: interpolation(INTERPOLATION_SMOOTH)
{}
Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
{}
bool isStruct() const { return !fields.empty(); }
InterpolationType interpolation;
......@@ -135,14 +114,6 @@ struct InterfaceBlock
staticUse(false)
{}
InterfaceBlock(const char *name, unsigned int arraySize)
: name(name),
arraySize(arraySize),
layout(BLOCKLAYOUT_SHARED),
isRowMajorLayout(false),
staticUse(false)
{}
std::string name;
std::string mappedName;
unsigned int arraySize;
......
......@@ -29,6 +29,18 @@
namespace sh
{
static sh::Attribute MakeAttributeFromType(const TType &type, const TString &name)
{
sh::Attribute attributeVar;
attributeVar.type = GLVariableType(type);
attributeVar.precision = GLVariablePrecision(type);
attributeVar.name = name.c_str();
attributeVar.arraySize = static_cast<unsigned int>(type.getArraySize());
attributeVar.location = type.getLayoutQualifier().location;
return attributeVar;
}
TString OutputHLSL::TextureFunction::name() const
{
TString name = "gl_texture";
......@@ -335,8 +347,7 @@ void OutputHLSL::header()
attributes += "static " + TypeString(type) + " " + Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n";
sh::Attribute attributeVar(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
(unsigned int)type.getArraySize(), type.getLayoutQualifier().location);
sh::Attribute attributeVar = MakeAttributeFromType(type, name);
mActiveAttributes.push_back(attributeVar);
}
......@@ -370,13 +381,11 @@ void OutputHLSL::header()
{
const TString &variableName = outputVariableIt->first;
const TType &variableType = outputVariableIt->second->getType();
const TLayoutQualifier &layoutQualifier = variableType.getLayoutQualifier();
out << "static " + TypeString(variableType) + " out_" + variableName + ArrayString(variableType) +
" = " + initializer(variableType) + ";\n";
sh::Attribute outputVar(GLVariableType(variableType), GLVariablePrecision(variableType), variableName.c_str(),
(unsigned int)variableType.getArraySize(), layoutQualifier.location);
sh::Attribute outputVar = MakeAttributeFromType(variableType, variableName);
mActiveOutputVariables.push_back(outputVar);
}
}
......
......@@ -468,7 +468,7 @@ int ShCheckVariablesWithinPackingLimits(
std::vector<sh::ShaderVariable> variables;
for (size_t ii = 0; ii < varInfoArraySize; ++ii)
{
sh::ShaderVariable var(varInfoArray[ii].type, (sh::GLenum)0, "", varInfoArray[ii].size);
sh::ShaderVariable var(varInfoArray[ii].type, varInfoArray[ii].size);
variables.push_back(var);
}
VariablePacker packer;
......
......@@ -162,7 +162,10 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn
unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize());
unsigned int activeRegister = mInterfaceBlockRegister;
InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize);
InterfaceBlock activeBlock;
activeBlock.name = interfaceBlock.name().c_str();
activeBlock.arraySize = arraySize;
for (unsigned int typeIndex = 0; typeIndex < fieldList.size(); typeIndex++)
{
const TField &field = *fieldList[typeIndex];
......
......@@ -63,11 +63,6 @@ static sh::GLenum nonSqMatTypes[] = {
GL_FLOAT_MAT4x3
};
static sh::ShaderVariable SimpleVar(GLenum type, unsigned int size)
{
return sh::ShaderVariable(type, GL_NONE, "", size == 1 ? 0 : size);
}
TEST(VariablePacking, Pack) {
VariablePacker packer;
std::vector<sh::ShaderVariable> vars;
......@@ -81,18 +76,18 @@ TEST(VariablePacking, Pack) {
int num_components_per_row = VariablePacker::GetNumComponentsPerRow(type);
// Check 1 of the type.
vars.clear();
vars.push_back(SimpleVar(type, 1));
vars.push_back(sh::ShaderVariable(type, 0));
EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
// Check exactly the right amount of 1 type as an array.
int num_vars = kMaxRows / num_rows;
vars.clear();
vars.push_back(SimpleVar(type, num_vars));
vars.push_back(sh::ShaderVariable(type, num_vars == 1 ? 0 : num_vars));
EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
// test too many
vars.clear();
vars.push_back(SimpleVar(type, num_vars + 1));
vars.push_back(sh::ShaderVariable(type, num_vars == 0 ? 0 : (num_vars + 1)));
EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
// Check exactly the right amount of 1 type as individual vars.
......@@ -100,26 +95,26 @@ TEST(VariablePacking, Pack) {
((num_components_per_row > 2) ? 1 : (4 / num_components_per_row));
vars.clear();
for (int ii = 0; ii < num_vars; ++ii) {
vars.push_back(SimpleVar(type, 1));
vars.push_back(sh::ShaderVariable(type, 0));
}
EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
// Check 1 too many.
vars.push_back(SimpleVar(type, 1));
vars.push_back(sh::ShaderVariable(type, 0));
EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
}
// Test example from GLSL ES 3.0 spec chapter 11.
vars.clear();
vars.push_back(SimpleVar(GL_FLOAT_VEC4, 1));
vars.push_back(SimpleVar(GL_FLOAT_MAT3, 1));
vars.push_back(SimpleVar(GL_FLOAT_MAT3, 1));
vars.push_back(SimpleVar(GL_FLOAT_VEC2, 6));
vars.push_back(SimpleVar(GL_FLOAT_VEC2, 4));
vars.push_back(SimpleVar(GL_FLOAT_VEC2, 1));
vars.push_back(SimpleVar(GL_FLOAT, 3));
vars.push_back(SimpleVar(GL_FLOAT, 2));
vars.push_back(SimpleVar(GL_FLOAT, 1));
vars.push_back(sh::ShaderVariable(GL_FLOAT_VEC4, 0));
vars.push_back(sh::ShaderVariable(GL_FLOAT_MAT3, 0));
vars.push_back(sh::ShaderVariable(GL_FLOAT_MAT3, 0));
vars.push_back(sh::ShaderVariable(GL_FLOAT_VEC2, 6));
vars.push_back(sh::ShaderVariable(GL_FLOAT_VEC2, 4));
vars.push_back(sh::ShaderVariable(GL_FLOAT_VEC2, 0));
vars.push_back(sh::ShaderVariable(GL_FLOAT, 3));
vars.push_back(sh::ShaderVariable(GL_FLOAT, 2));
vars.push_back(sh::ShaderVariable(GL_FLOAT, 0));
EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
}
......@@ -157,12 +152,12 @@ TEST(VariablePacking, NonSquareMats) {
int squareSize = std::max(rows, cols);
std::vector<sh::ShaderVariable> vars;
vars.push_back(SimpleVar(type, 1));
vars.push_back(sh::ShaderVariable(type, 0));
// Fill columns
for (int row = 0; row < squareSize; row++) {
for (int col = squareSize; col < 4; ++col) {
vars.push_back(SimpleVar(GL_FLOAT, 1));
vars.push_back(sh::ShaderVariable(GL_FLOAT, 0));
}
}
......@@ -171,7 +166,7 @@ TEST(VariablePacking, NonSquareMats) {
EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(squareSize, vars));
// and one scalar and packing should fail
vars.push_back(SimpleVar(GL_FLOAT, 1));
vars.push_back(sh::ShaderVariable(GL_FLOAT, 0));
EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(squareSize, vars));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment