Decorate (and undecorate) struct fields too (when not built-in).

Trac #20510 Issue=316,317 Authored-by: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1027 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent fc74c375
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 1020
#define BUILD_REVISION 1027
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -897,7 +897,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
case EOpIndexDirectStruct:
if (visit == InVisit)
{
out << "." + node->getType().getFieldName();
out << "." + decorateField(node->getType().getFieldName(), node->getLeft()->getType());
return false;
}
......@@ -973,9 +973,9 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
const TType *fieldType = (*fields)[i].type;
node->getLeft()->traverse(this);
out << "." + fieldType->getFieldName() + " == ";
out << "." + decorateField(fieldType->getFieldName(), node->getLeft()->getType()) + " == ";
node->getRight()->traverse(this);
out << "." + fieldType->getFieldName();
out << "." + decorateField(fieldType->getFieldName(), node->getLeft()->getType());
if (i < fields->size() - 1)
{
......@@ -2012,7 +2012,7 @@ TString OutputHLSL::typeString(const TType &type)
{
const TType &field = *fields[i].type;
string += " " + typeString(field) + " " + field.getFieldName() + arrayString(field) + ";\n";
string += " " + typeString(field) + " " + decorate(field.getFieldName()) + arrayString(field) + ";\n";
}
string += "} ";
......@@ -2135,7 +2135,7 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
{
const TType &field = *fields[i].type;
structure += " " + typeString(field) + " " + field.getFieldName() + arrayString(field) + ";\n";
structure += " " + typeString(field) + " " + decorateField(field.getFieldName(), type) + arrayString(field) + ";\n";
}
structure += "};\n";
......@@ -2434,4 +2434,14 @@ TString OutputHLSL::decorateUniform(const TString &string, const TType &type)
return decorate(string);
}
TString OutputHLSL::decorateField(const TString &string, const TType &structure)
{
if (structure.getTypeName().compare(0, 3, "gl_") != 0)
{
return decorate(string);
}
return string;
}
}
......@@ -33,6 +33,7 @@ class OutputHLSL : public TIntermTraverser
static TString initializer(const TType &type);
static TString decorate(const TString &string); // Prepends an underscore to avoid naming clashes
static TString decorateUniform(const TString &string, const TType &type);
static TString decorateField(const TString &string, const TType &structure);
protected:
void header();
......
......@@ -2031,16 +2031,26 @@ std::string Program::decorateAttribute(const std::string &name)
std::string Program::undecorateUniform(const std::string &_name)
{
if (_name[0] == '_')
std::string name = _name;
// Remove any structure field decoration
size_t pos = 0;
while ((pos = name.find("._", pos)) != std::string::npos)
{
return _name.substr(1);
name.replace(pos, 2, ".");
}
else if (_name.compare(0, 3, "ar_") == 0)
// Remove the leading decoration
if (name[0] == '_')
{
return _name.substr(3);
return name.substr(1);
}
else if (name.compare(0, 3, "ar_") == 0)
{
return name.substr(3);
}
return _name;
return name;
}
void Program::applyUniformnbv(Uniform *targetUniform, GLsizei count, int width, const GLboolean *v)
......
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