Undecorate uniform names when computing max length

TRAC #12050 Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@200 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 63691867
...@@ -1342,7 +1342,7 @@ Uniform *Program::createUniform(const D3DXCONSTANT_DESC &constantDescription, st ...@@ -1342,7 +1342,7 @@ Uniform *Program::createUniform(const D3DXCONSTANT_DESC &constantDescription, st
return 0; return 0;
} }
// This methods needs to match OutputHLSL::decorate // This method needs to match OutputHLSL::decorate
std::string Program::decorate(const std::string &string) std::string Program::decorate(const std::string &string)
{ {
if (string.substr(0, 3) != "gl_" && string.substr(0, 3) != "dx_") if (string.substr(0, 3) != "gl_" && string.substr(0, 3) != "dx_")
...@@ -1355,6 +1355,18 @@ std::string Program::decorate(const std::string &string) ...@@ -1355,6 +1355,18 @@ std::string Program::decorate(const std::string &string)
} }
} }
std::string Program::undecorate(const std::string &string)
{
if (string.substr(0, 1) == "_")
{
return string.substr(1);
}
else
{
return string;
}
}
bool Program::applyUniform1bv(GLint location, GLsizei count, const GLboolean *v) bool Program::applyUniform1bv(GLint location, GLsizei count, const GLboolean *v)
{ {
BOOL *vector = new BOOL[count]; BOOL *vector = new BOOL[count];
...@@ -2118,14 +2130,9 @@ void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, G ...@@ -2118,14 +2130,9 @@ void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, G
if (bufsize > 0) if (bufsize > 0)
{ {
const char *string = mUniforms[uniform]->name.c_str(); std::string string = undecorate(mUniforms[uniform]->name);
if(string[0] == '_') // Undecorate
{
string++;
}
strncpy(name, string, bufsize); strncpy(name, string.c_str(), bufsize);
name[bufsize - 1] = '\0'; name[bufsize - 1] = '\0';
if (length) if (length)
...@@ -2162,7 +2169,7 @@ GLint Program::getActiveUniformMaxLength() ...@@ -2162,7 +2169,7 @@ GLint Program::getActiveUniformMaxLength()
{ {
if (!mUniforms[uniformIndex]->name.empty() && mUniforms[uniformIndex]->name.substr(0, 3) != "dx_") if (!mUniforms[uniformIndex]->name.empty() && mUniforms[uniformIndex]->name.substr(0, 3) != "dx_")
{ {
maxLength = std::max((int)(mUniforms[uniformIndex]->name.length() + 1), maxLength); maxLength = std::max((int)(undecorate(mUniforms[uniformIndex]->name).length() + 1), maxLength);
} }
} }
......
...@@ -136,7 +136,6 @@ class Program ...@@ -136,7 +136,6 @@ class Program
bool defineUniform(const D3DXHANDLE &constantHandle, const D3DXCONSTANT_DESC &constantDescription, std::string name = ""); bool defineUniform(const D3DXHANDLE &constantHandle, const D3DXCONSTANT_DESC &constantDescription, std::string name = "");
bool defineUniform(const D3DXCONSTANT_DESC &constantDescription, std::string &name); bool defineUniform(const D3DXCONSTANT_DESC &constantDescription, std::string &name);
Uniform *createUniform(const D3DXCONSTANT_DESC &constantDescription, std::string &name); Uniform *createUniform(const D3DXCONSTANT_DESC &constantDescription, std::string &name);
static std::string decorate(const std::string &string); // Prepend an underscore
bool applyUniform1bv(GLint location, GLsizei count, const GLboolean *v); bool applyUniform1bv(GLint location, GLsizei count, const GLboolean *v);
bool applyUniform2bv(GLint location, GLsizei count, const GLboolean *v); bool applyUniform2bv(GLint location, GLsizei count, const GLboolean *v);
bool applyUniform3bv(GLint location, GLsizei count, const GLboolean *v); bool applyUniform3bv(GLint location, GLsizei count, const GLboolean *v);
...@@ -156,6 +155,9 @@ class Program ...@@ -156,6 +155,9 @@ class Program
void appendToInfoLog(const char *info, ...); void appendToInfoLog(const char *info, ...);
void resetInfoLog(); void resetInfoLog();
static std::string decorate(const std::string &string); // Prepend an underscore
static std::string undecorate(const std::string &string); // Remove leading underscore
FragmentShader *mFragmentShader; FragmentShader *mFragmentShader;
VertexShader *mVertexShader; VertexShader *mVertexShader;
......
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