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
parent 3aa7420b
...@@ -2004,7 +2004,28 @@ TString OutputHLSL::typeString(const TType &type) ...@@ -2004,7 +2004,28 @@ TString OutputHLSL::typeString(const TType &type)
{ {
if (type.getBasicType() == EbtStruct) 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()) else if (type.isMatrix())
{ {
...@@ -2113,6 +2134,11 @@ bool OutputHLSL::CompareConstructor::operator()(const Constructor &x, const Cons ...@@ -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) void OutputHLSL::addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters)
{ {
if (name == "")
{
return; // Anonymous structures don't have constructors
}
Constructor constructor; Constructor constructor;
constructor.type = type; constructor.type = type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment