From a637e55f6ffbfe27cd0a0fa9ca61636e137f2336 Mon Sep 17 00:00:00 2001 From: "daniel@transgaming.com" Date: Thu, 29 Apr 2010 03:39:08 +0000 Subject: [PATCH] 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 --- src/compiler/OutputHLSL.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp index b4c52966d..70553ac2f 100644 --- a/src/compiler/OutputHLSL.cpp +++ b/src/compiler/OutputHLSL.cpp @@ -2004,7 +2004,28 @@ TString OutputHLSL::typeString(const TType &type) { 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 @@ bool OutputHLSL::CompareConstructor::operator()(const Constructor &x, const Cons 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;