Support matrix attributes
TRAC #11095
Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch
Author: Andrew Lewycky
git-svn-id: https://angleproject.googlecode.com/svn/trunk@195 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 06d715d..9d1fa54 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -73,6 +73,14 @@
return mBody;
}
+int OutputHLSL::vectorSize(const TType &type) const
+{
+ int elementSize = type.isMatrix() ? type.getNominalSize() : 1;
+ int arraySize = type.isArray() ? type.getArraySize() : 1;
+
+ return elementSize * arraySize;
+}
+
void OutputHLSL::header()
{
EShLanguage language = mContext.language;
@@ -255,7 +263,7 @@
attributeInput += " " + typeString(type) + " " + decorate(name) + arrayString(type) + " : TEXCOORD" + str(semanticIndex) + ";\n";
attributeGlobals += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
- semanticIndex += type.isArray() ? type.getArraySize() : 1;
+ semanticIndex += vectorSize(type);
}
}
else if (qualifier == EvqVaryingOut || qualifier == EvqInvariantVaryingOut)
@@ -690,7 +698,9 @@
{
if (mReferencedAttributes.find(name.c_str()) != mReferencedAttributes.end())
{
- out << " " + decorate(name) + " = input." + decorate(name) + ";\n";
+ const char *transpose = type.isMatrix() ? "transpose" : "";
+
+ out << " " + decorate(name) + " = " + transpose + "(input." + decorate(name) + ");\n";
}
}
}