translator: Add sh::OutputVariable type.
This replaces the dual-use of sh::Attribute, which can be a bit
confusing to people expecting a literal output variable.
Currently not used in Chromium, so should be safe to land.
BUG=angleproject:1146
Change-Id: I436f2bc9dc4ddc3709369cb2baa344c6b13a21a2
Reviewed-on: https://chromium-review.googlesource.com/296683
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/VariableInfo.cpp b/src/compiler/translator/VariableInfo.cpp
index a72f74d..07a9dcd 100644
--- a/src/compiler/translator/VariableInfo.cpp
+++ b/src/compiler/translator/VariableInfo.cpp
@@ -129,7 +129,7 @@
}
CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
- std::vector<sh::Attribute> *outputVariables,
+ std::vector<sh::OutputVariable> *outputVariables,
std::vector<sh::Uniform> *uniforms,
std::vector<sh::Varying> *varyings,
std::vector<sh::InterfaceBlock> *interfaceBlocks,
@@ -375,7 +375,7 @@
case EvqFragColor:
if (!mFragColorAdded)
{
- Attribute info;
+ OutputVariable info;
const char kName[] = "gl_FragColor";
info.name = kName;
info.mappedName = kName;
@@ -390,7 +390,7 @@
case EvqFragData:
if (!mFragDataAdded)
{
- Attribute info;
+ OutputVariable info;
const char kName[] = "gl_FragData";
info.name = kName;
info.mappedName = kName;
@@ -408,7 +408,7 @@
case EvqFragDepth:
if (!mFragDepthAdded)
{
- Attribute info;
+ OutputVariable info;
const char kName[] = "gl_FragDepthEXT";
info.name = kName;
info.mappedName = kName;
@@ -426,7 +426,7 @@
case EvqSecondaryFragColorEXT:
if (!mSecondaryFragColorEXTAdded)
{
- Attribute info;
+ OutputVariable info;
const char kName[] = "gl_SecondaryFragColorEXT";
info.name = kName;
info.mappedName = kName;
@@ -441,7 +441,7 @@
case EvqSecondaryFragDataEXT:
if (!mSecondaryFragDataEXTAdded)
{
- Attribute info;
+ OutputVariable info;
const char kName[] = "gl_SecondaryFragDataEXT";
info.name = kName;
info.mappedName = kName;
@@ -508,6 +508,26 @@
template <>
void CollectVariables::visitVariable(const TIntermSymbol *variable,
+ std::vector<OutputVariable> *infoList) const
+{
+ ASSERT(variable);
+ const TType &type = variable->getType();
+ ASSERT(!type.getStruct());
+
+ OutputVariable attribute;
+
+ attribute.type = GLVariableType(type);
+ attribute.precision = GLVariablePrecision(type);
+ attribute.name = variable->getSymbol().c_str();
+ attribute.arraySize = static_cast<unsigned int>(type.getArraySize());
+ attribute.mappedName = TIntermTraverser::hash(variable->getSymbol(), mHashFunction).c_str();
+ attribute.location = variable->getType().getLayoutQualifier().location;
+
+ infoList->push_back(attribute);
+}
+
+template <>
+void CollectVariables::visitVariable(const TIntermSymbol *variable,
std::vector<InterfaceBlock> *infoList) const
{
InterfaceBlock interfaceBlock;