Pass varyings to the GLES API from the translator using a direct pointer.
Instead of parsing them indirectly from HLSL, the pointer will allow us to more flexibly
support new types, especially compound types such as structures.
TRAC #23754
Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index aa32292..972d10a 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -205,6 +205,11 @@
return mActiveAttributes;
}
+const std::vector<Varying> &OutputHLSL::getVaryings() const
+{
+ return mActiveVaryings;
+}
+
int OutputHLSL::vectorSize(const TType &type) const
{
int elementSize = type.isMatrix() ? type.getCols() : 1;
@@ -612,6 +617,8 @@
// Program linking depends on this exact format
varyings += "static " + interpolationString(type.getQualifier()) + " " + typeString(type) + " " +
decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
+
+ declareVaryingToList(type, name, mActiveVaryings);
}
for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin(); attribute != mReferencedAttributes.end(); attribute++)
@@ -3636,6 +3643,30 @@
}
}
+void OutputHLSL::declareVaryingToList(const TType &type, const TString &name, std::vector<Varying>& fieldsOut)
+{
+ const TStructure *structure = type.getStruct();
+
+ if (!structure)
+ {
+ Varying varying(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize());
+ fieldsOut.push_back(varying);
+ }
+ else
+ {
+ Varying structVarying(GL_NONE, GL_NONE, name.c_str(), (unsigned int)type.getArraySize());
+ const TFieldList &fields = structure->fields();
+
+ for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
+ {
+ const TField &field = *fields[fieldIndex];
+ declareVaryingToList(*field.type(), field.name(), structVarying.fields);
+ }
+
+ fieldsOut.push_back(structVarying);
+ }
+}
+
void OutputHLSL::declareUniform(const TType &type, const TString &name, int index)
{
declareUniformToList(type, name, index, mActiveUniforms);