Support anonymous structures
TRAC #11809
Signed-off-by: Andrew Lewycky
Signed-off-by: Daniel Koch
Author: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/trunk@216 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index b4c5296..70553ac 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -2004,7 +2004,28 @@
{
if (type.getBasicType() == EbtStruct)
{
- return decorate(type.getTypeName());
+ if (type.getTypeName() != "")
+ {
+ return decorate(type.getTypeName());
+ }
+ else // Anonymous structure, define in place
+ {
+ const TTypeList &fields = *type.getStruct();
+
+ TString string = "struct\n"
+ "{\n";
+
+ for (unsigned int i = 0; i < fields.size(); i++)
+ {
+ const TType &field = *fields[i].type;
+
+ string += " " + typeString(field) + " " + field.getFieldName() + arrayString(field) + ";\n";
+ }
+
+ string += "} ";
+
+ return string;
+ }
}
else if (type.isMatrix())
{
@@ -2113,6 +2134,11 @@
void OutputHLSL::addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters)
{
+ if (name == "")
+ {
+ return; // Anonymous structures don't have constructors
+ }
+
Constructor constructor;
constructor.type = type;