Commit bb3adfa4 by Shahbaz Youssefi Committed by Commit Bot

Rename ShaderVariable::structName to structOrBlockName

Bug: angleproject:3580 Change-Id: Ic53a5267972f153dad2e20948e493e9767a45d16 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2568247 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent df33d561
......@@ -26,7 +26,7 @@
// Version number for shader translation API.
// It is incremented every time the API changes.
#define ANGLE_SH_VERSION 251
#define ANGLE_SH_VERSION 252
enum ShShaderSpec
{
......
......@@ -100,8 +100,8 @@ struct ShaderVariable
unsigned int getExternalSize() const;
bool isStruct() const { return !fields.empty(); }
const std::string &getStructName() const { return structName; }
void setStructName(const std::string &newName) { structName = newName; }
const std::string &getStructName() const { return structOrBlockName; }
void setStructName(const std::string &newName) { structOrBlockName = newName; }
// All of the shader's variables are described using nested data
// structures. This is needed in order to disambiguate similar looking
......@@ -155,10 +155,12 @@ struct ShaderVariable
// necessarily active. GLES 3.0.5 section 2.12.6. GLES 3.1 section 7.3.1.
bool active;
std::vector<ShaderVariable> fields;
// Struct name is used for varyings of struct type. Additionally, it's used with shader I/O
// blocks, in which case it contains the block name.
std::string structName;
std::string mappedStructName;
// structOrBlockName is used for:
//
// - varyings of struct type, in which case it contains the struct name.
// - shader I/O blocks, in which case it contains the block name.
std::string structOrBlockName;
std::string mappedStructOrBlockName;
// Only applies to interface block fields. Kept here for simplicity.
bool isRowMajorLayout;
......
......@@ -673,7 +673,7 @@ void PrintVariable(const std::string &prefix, size_t index, const sh::ShaderVari
std::string structPrefix;
for (size_t i = 0; i < prefix.size(); ++i)
structPrefix += ' ';
printf("%s struct %s\n", structPrefix.c_str(), var.structName.c_str());
printf("%s struct %s\n", structPrefix.c_str(), var.structOrBlockName.c_str());
structPrefix += " field";
for (size_t i = 0; i < var.fields.size(); ++i)
PrintVariable(structPrefix, i, var.fields[i]);
......
......@@ -101,7 +101,7 @@ ShaderVariable *FindShaderIOBlockVariable(const ImmutableString &blockName,
{
for (size_t index = 0; index < infoList->size(); ++index)
{
if (blockName == (*infoList)[index].structName)
if (blockName == (*infoList)[index].structOrBlockName)
return &(*infoList)[index];
}
......@@ -755,7 +755,7 @@ void CollectVariablesTraverser::setFieldOrVariableProperties(const TType &type,
variableOut->type = GL_NONE;
if (structure->symbolType() != SymbolType::Empty)
{
variableOut->structName = structure->name().data();
variableOut->structOrBlockName = structure->name().data();
}
const TFieldList &fields = structure->fields();
......@@ -775,8 +775,8 @@ void CollectVariablesTraverser::setFieldOrVariableProperties(const TType &type,
variableOut->type = GL_NONE;
if (interfaceBlock->symbolType() != SymbolType::Empty)
{
variableOut->structName = interfaceBlock->name().data();
variableOut->mappedStructName =
variableOut->structOrBlockName = interfaceBlock->name().data();
variableOut->mappedStructOrBlockName =
HashName(interfaceBlock->name(), mHashFunction, nullptr).data();
}
const TFieldList &fields = interfaceBlock->fields();
......@@ -859,16 +859,16 @@ void CollectVariablesTraverser::setCommonVariableProperties(const TType &type,
variableOut->mappedName = getMappedName(&variable);
}
// For I/O blocks, additionally store the name of the block as structName. If the variable is
// For I/O blocks, additionally store the name of the block as blockName. If the variable is
// unnamed, this name will be used instead for the purpose of interface matching.
if (isShaderIOBlock)
{
const TInterfaceBlock *interfaceBlock = type.getInterfaceBlock();
ASSERT(interfaceBlock);
variableOut->structName.assign(interfaceBlock->name().data(),
interfaceBlock->name().length());
variableOut->mappedStructName =
variableOut->structOrBlockName.assign(interfaceBlock->name().data(),
interfaceBlock->name().length());
variableOut->mappedStructOrBlockName =
HashName(interfaceBlock->name(), mHashFunction, nullptr).data();
variableOut->isShaderIOBlock = true;
}
......
......@@ -73,8 +73,8 @@ ShaderVariable::ShaderVariable(const ShaderVariable &other)
staticUse(other.staticUse),
active(other.active),
fields(other.fields),
structName(other.structName),
mappedStructName(other.mappedStructName),
structOrBlockName(other.structOrBlockName),
mappedStructOrBlockName(other.mappedStructOrBlockName),
isRowMajorLayout(other.isRowMajorLayout),
location(other.location),
hasImplicitLocation(other.hasImplicitLocation),
......@@ -103,8 +103,8 @@ ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
staticUse = other.staticUse;
active = other.active;
fields = other.fields;
structName = other.structName;
mappedStructName = other.mappedStructName;
structOrBlockName = other.structOrBlockName;
mappedStructOrBlockName = other.mappedStructOrBlockName;
isRowMajorLayout = other.isRowMajorLayout;
flattenedOffsetInParentArrays = other.flattenedOffsetInParentArrays;
location = other.location;
......@@ -129,12 +129,13 @@ bool ShaderVariable::operator==(const ShaderVariable &other) const
if (type != other.type || precision != other.precision || name != other.name ||
mappedName != other.mappedName || arraySizes != other.arraySizes ||
staticUse != other.staticUse || active != other.active ||
fields.size() != other.fields.size() || structName != other.structName ||
mappedStructName != other.mappedStructName || isRowMajorLayout != other.isRowMajorLayout ||
location != other.location || hasImplicitLocation != other.hasImplicitLocation ||
binding != other.binding || imageUnitFormat != other.imageUnitFormat ||
offset != other.offset || readonly != other.readonly || writeonly != other.writeonly ||
index != other.index || yuv != other.yuv || interpolation != other.interpolation ||
fields.size() != other.fields.size() || structOrBlockName != other.structOrBlockName ||
mappedStructOrBlockName != other.mappedStructOrBlockName ||
isRowMajorLayout != other.isRowMajorLayout || location != other.location ||
hasImplicitLocation != other.hasImplicitLocation || binding != other.binding ||
imageUnitFormat != other.imageUnitFormat || offset != other.offset ||
readonly != other.readonly || writeonly != other.writeonly || index != other.index ||
yuv != other.yuv || interpolation != other.interpolation ||
isInvariant != other.isInvariant || isShaderIOBlock != other.isShaderIOBlock ||
isPatch != other.isPatch || texelFetchStaticUse != other.texelFetchStaticUse)
{
......@@ -323,7 +324,7 @@ const sh::ShaderVariable *ShaderVariable::findField(const std::string &fullName,
}
else
{
std::string baseName = isShaderIOBlock ? structName : name;
std::string baseName = isShaderIOBlock ? structOrBlockName : name;
topName = fullName.substr(0, pos);
if (topName != baseName)
{
......@@ -384,7 +385,8 @@ bool ShaderVariable::isSameVariableAtLinkTime(const ShaderVariable &other,
return false;
}
}
if (structName != other.structName || mappedStructName != other.mappedStructName)
if (structOrBlockName != other.structOrBlockName ||
mappedStructOrBlockName != other.mappedStructOrBlockName)
return false;
return true;
}
......@@ -461,7 +463,7 @@ bool ShaderVariable::isSameNameAtLinkTime(const ShaderVariable &other) const
if (isShaderIOBlock)
{
// Shader I/O blocks match by block name.
return structName == other.structName;
return structOrBlockName == other.structOrBlockName;
}
// Otherwise match by name.
......
......@@ -685,7 +685,7 @@ void UpdateInterfaceVariable(std::vector<sh::ShaderVariable> *block, const sh::S
// type field; // produces "Block2.field"
// } block2;
//
const std::string &baseName = var.isShaderIOBlock ? var.structName : var.name;
const std::string &baseName = var.isShaderIOBlock ? var.structOrBlockName : var.name;
const std::string prefix = var.name.empty() ? "" : baseName + ".";
if (!field.isStruct())
......@@ -936,8 +936,8 @@ void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
stream->writeBool(var.staticUse);
stream->writeBool(var.active);
stream->writeInt(var.binding);
stream->writeString(var.structName);
stream->writeString(var.mappedStructName);
stream->writeString(var.structOrBlockName);
stream->writeString(var.mappedStructOrBlockName);
stream->writeInt(var.hasParentArrayIndex() ? var.parentArrayIndex() : -1);
stream->writeInt(var.imageUnitFormat);
......@@ -956,11 +956,11 @@ void LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var)
var->name = stream->readString();
var->mappedName = stream->readString();
stream->readIntVector<unsigned int>(&var->arraySizes);
var->staticUse = stream->readBool();
var->active = stream->readBool();
var->binding = stream->readInt<int>();
var->structName = stream->readString();
var->mappedStructName = stream->readString();
var->staticUse = stream->readBool();
var->active = stream->readBool();
var->binding = stream->readInt<int>();
var->structOrBlockName = stream->readString();
var->mappedStructOrBlockName = stream->readString();
var->setParentArrayIndex(stream->readInt<int>());
var->imageUnitFormat = stream->readInt<GLenum>();
......
......@@ -81,8 +81,8 @@ struct TransformFeedbackVarying : public sh::ShaderVariable
name = parent.name + "." + name;
mappedName = parent.mappedName + "." + mappedName;
}
structName = parent.structName;
mappedStructName = parent.mappedStructName;
structOrBlockName = parent.structOrBlockName;
mappedStructOrBlockName = parent.mappedStructOrBlockName;
}
std::string nameWithArrayIndex() const
......
......@@ -1653,7 +1653,8 @@ bool LinkValidateShaderInterfaceMatching(const std::vector<sh::ShaderVariable> &
// if it is not active. GLSL ES 3.00.6 section 4.3.10.
if (!match && input->staticUse)
{
const std::string &name = input->isShaderIOBlock ? input->structName : input->name;
const std::string &name =
input->isShaderIOBlock ? input->structOrBlockName : input->name;
infoLog << GetShaderTypeString(backShaderType) << " varying " << name
<< " does not match any " << GetShaderTypeString(frontShaderType) << " varying";
return false;
......@@ -1702,7 +1703,7 @@ LinkMismatchError LinkValidateProgramVariables(const sh::ShaderVariable &variabl
return LinkMismatchError::PRECISION_MISMATCH;
}
if (!variable1.isShaderIOBlock && !variable2.isShaderIOBlock &&
variable1.structName != variable2.structName)
variable1.structOrBlockName != variable2.structOrBlockName)
{
return LinkMismatchError::STRUCT_NAME_MISMATCH;
}
......@@ -1738,7 +1739,7 @@ LinkMismatchError LinkValidateProgramVariables(const sh::ShaderVariable &variabl
return LinkMismatchError::FIELD_LOCATION_MISMATCH;
}
if (member1.structName != member2.structName)
if (member1.structOrBlockName != member2.structOrBlockName)
{
return LinkMismatchError::FIELD_STRUCT_NAME_MISMATCH;
}
......
......@@ -708,8 +708,8 @@ std::string Shader::getTransformFeedbackVaryingMappedName(const std::string &tfV
// If it's an I/O block without an instance name, don't include the block name.
if (!varying.isShaderIOBlock || !varying.name.empty())
{
mappedName =
varying.isShaderIOBlock ? varying.mappedStructName : varying.mappedName;
mappedName = varying.isShaderIOBlock ? varying.mappedStructOrBlockName
: varying.mappedName;
mappedName += '.';
}
return mappedName + field->mappedName;
......
......@@ -105,8 +105,8 @@ bool InterfaceVariablesMatch(const sh::ShaderVariable &front, const sh::ShaderVa
}
// Compare names, or if shader I/O blocks, block names.
const std::string &backName = back.isShaderIOBlock ? back.structName : back.name;
const std::string &frontName = front.isShaderIOBlock ? front.structName : front.name;
const std::string &backName = back.isShaderIOBlock ? back.structOrBlockName : back.name;
const std::string &frontName = front.isShaderIOBlock ? front.structOrBlockName : front.name;
return backName == frontName;
}
......@@ -569,8 +569,8 @@ void VaryingPacking::collectUserVaryingField(const ProgramVaryingRef &ref,
{
if (frontField->isShaderIOBlock)
{
frontVarying.parentStructName = input->structName;
frontVarying.parentStructMappedName = input->mappedStructName;
frontVarying.parentStructName = input->structOrBlockName;
frontVarying.parentStructMappedName = input->mappedStructOrBlockName;
}
else
{
......@@ -583,8 +583,8 @@ void VaryingPacking::collectUserVaryingField(const ProgramVaryingRef &ref,
{
if (backField->isShaderIOBlock)
{
backVarying.parentStructName = output->structName;
backVarying.parentStructMappedName = output->mappedStructName;
backVarying.parentStructName = output->structOrBlockName;
backVarying.parentStructMappedName = output->mappedStructOrBlockName;
}
else
{
......@@ -641,8 +641,8 @@ void VaryingPacking::collectUserVaryingFieldTF(const ProgramVaryingRef &ref,
if (frontField->isShaderIOBlock)
{
frontVarying.parentStructName = input->structName;
frontVarying.parentStructMappedName = input->mappedStructName;
frontVarying.parentStructName = input->structOrBlockName;
frontVarying.parentStructMappedName = input->mappedStructOrBlockName;
}
else
{
......@@ -720,7 +720,7 @@ void VaryingPacking::collectVarying(const sh::ShaderVariable &varying,
(*uniqueFullNames)[ref.frontShaderStage].insert(input->name);
if (input->isShaderIOBlock)
{
(*uniqueFullNames)[ref.frontShaderStage].insert(input->structName);
(*uniqueFullNames)[ref.frontShaderStage].insert(input->structOrBlockName);
}
}
if (output)
......@@ -747,7 +747,7 @@ void VaryingPacking::collectTFVarying(const std::string &tfVarying,
if ((*uniqueFullNames)[ref.frontShaderStage].count(tfVarying) > 0 ||
(*uniqueFullNames)[ref.frontShaderStage].count(baseName) > 0 ||
(input->isShaderIOBlock &&
(*uniqueFullNames)[ref.frontShaderStage].count(input->structName) > 0))
(*uniqueFullNames)[ref.frontShaderStage].count(input->structOrBlockName) > 0))
{
return;
}
......@@ -783,7 +783,7 @@ void VaryingPacking::collectTFVarying(const std::string &tfVarying,
}
}
(*uniqueFullNames)[ref.frontShaderStage].insert(input->structName);
(*uniqueFullNames)[ref.frontShaderStage].insert(input->structOrBlockName);
}
else
{
......
......@@ -601,8 +601,8 @@ void SerializeShaderVariable(gl::BinaryOutputStream *bos, const sh::ShaderVariab
{
SerializeShaderVariable(bos, field);
}
bos->writeString(shaderVariable.structName);
bos->writeString(shaderVariable.mappedStructName);
bos->writeString(shaderVariable.structOrBlockName);
bos->writeString(shaderVariable.mappedStructOrBlockName);
bos->writeBool(shaderVariable.isRowMajorLayout);
bos->writeInt(shaderVariable.location);
bos->writeInt(shaderVariable.binding);
......
......@@ -797,7 +797,7 @@ void AssignTransformFeedbackExtensionQualifiers(const gl::ProgramExecutable &pro
if (tfVarying.isShaderIOBlock)
{
if (varying->frontVarying.parentStructName == tfVarying.structName)
if (varying->frontVarying.parentStructName == tfVarying.structOrBlockName)
{
size_t pos = tfVarying.name.find_first_of(".");
std::string fieldName = pos == std::string::npos
......
......@@ -863,7 +863,7 @@ TEST_F(CollectHashedVertexVariablesTest, StructUniform)
EXPECT_FALSE(uniform.isArray());
EXPECT_EQ("u", uniform.name);
EXPECT_EQ("webgl_1", uniform.mappedName);
EXPECT_EQ("sType", uniform.structName);
EXPECT_EQ("sType", uniform.structOrBlockName);
EXPECT_TRUE(uniform.staticUse);
EXPECT_TRUE(uniform.active);
......@@ -907,7 +907,7 @@ TEST_F(CollectHashedVertexVariablesTest, NamelessStructUniform)
EXPECT_FALSE(uniform.isArray());
EXPECT_EQ("u", uniform.name);
EXPECT_EQ("webgl_1", uniform.mappedName);
EXPECT_EQ("", uniform.structName);
EXPECT_EQ("", uniform.structOrBlockName);
EXPECT_TRUE(uniform.staticUse);
EXPECT_TRUE(uniform.active);
......@@ -1044,7 +1044,7 @@ TEST_F(CollectGeometryVariablesTest, CollectGLInFields)
const ShaderVariable &glIn = inVaryings[0];
EXPECT_EQ("gl_in", glIn.name);
EXPECT_EQ("gl_PerVertex", glIn.structName);
EXPECT_EQ("gl_PerVertex", glIn.structOrBlockName);
EXPECT_TRUE(glIn.staticUse);
EXPECT_TRUE(glIn.active);
EXPECT_TRUE(glIn.isBuiltIn());
......@@ -1184,7 +1184,7 @@ TEST_F(CollectGeometryVariablesTest, CollectGLInIndexedByExpression)
{
foundGLIn = true;
EXPECT_TRUE(varying.isShaderIOBlock);
EXPECT_EQ("gl_PerVertex", varying.structName);
EXPECT_EQ("gl_PerVertex", varying.structOrBlockName);
}
else if (varying.name == "gl_InvocationID")
{
......
......@@ -26,14 +26,14 @@ TEST(ShaderVariableTest, FindInfoByMappedName)
// };
// B uni[2];
ShaderVariable uni(0, 2);
uni.name = "uni";
uni.mappedName = "m_uni";
uni.structName = "B";
uni.name = "uni";
uni.mappedName = "m_uni";
uni.structOrBlockName = "B";
{
ShaderVariable a(0, 3);
a.name = "a";
a.mappedName = "m_a";
a.structName = "A";
a.name = "a";
a.mappedName = "m_a";
a.structOrBlockName = "A";
{
ShaderVariable x(GL_FLOAT, 2);
x.name = "x";
......@@ -86,9 +86,9 @@ TEST(ShaderVariableTest, IsSameUniformWithDifferentFieldOrder)
// };
// uniform A uni;
ShaderVariable vx_a;
vx_a.name = "uni";
vx_a.mappedName = "m_uni";
vx_a.structName = "A";
vx_a.name = "uni";
vx_a.mappedName = "m_uni";
vx_a.structOrBlockName = "A";
{
ShaderVariable x(GL_FLOAT);
x.name = "x";
......@@ -107,9 +107,9 @@ TEST(ShaderVariableTest, IsSameUniformWithDifferentFieldOrder)
// };
// uniform A uni;
ShaderVariable fx_a;
fx_a.name = "uni";
fx_a.mappedName = "m_uni";
fx_a.structName = "A";
fx_a.name = "uni";
fx_a.mappedName = "m_uni";
fx_a.structOrBlockName = "A";
{
ShaderVariable y(GL_FLOAT);
y.name = "y";
......@@ -133,9 +133,9 @@ TEST(ShaderVariableTest, IsSameUniformWithDifferentStructNames)
// };
// uniform A uni;
ShaderVariable vx_a;
vx_a.name = "uni";
vx_a.mappedName = "m_uni";
vx_a.structName = "A";
vx_a.name = "uni";
vx_a.mappedName = "m_uni";
vx_a.structOrBlockName = "A";
{
ShaderVariable x(GL_FLOAT);
x.name = "x";
......@@ -168,13 +168,13 @@ TEST(ShaderVariableTest, IsSameUniformWithDifferentStructNames)
fx_a.fields.push_back(y);
}
fx_a.structName = "B";
fx_a.structOrBlockName = "B";
EXPECT_FALSE(vx_a.isSameUniformAtLinkTime(fx_a));
fx_a.structName = "A";
fx_a.structOrBlockName = "A";
EXPECT_TRUE(vx_a.isSameUniformAtLinkTime(fx_a));
fx_a.structName = "";
fx_a.structOrBlockName = "";
EXPECT_FALSE(vx_a.isSameUniformAtLinkTime(fx_a));
}
......
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