Fixes double-decoration when getUniformLocation is called from defineUniform.

TRAC #12437 This fixes the WebGL Teapot Per Pixel sample rendering Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@329 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8f05d1aa
...@@ -239,7 +239,7 @@ void Program::setSamplerDirty(unsigned int samplerIndex, bool dirty) ...@@ -239,7 +239,7 @@ void Program::setSamplerDirty(unsigned int samplerIndex, bool dirty)
else UNREACHABLE(); else UNREACHABLE();
} }
GLint Program::getUniformLocation(const char *name) GLint Program::getUniformLocation(const char *name, bool decorated)
{ {
std::string nameStr(name); std::string nameStr(name);
int subscript = 0; int subscript = 0;
...@@ -252,7 +252,10 @@ GLint Program::getUniformLocation(const char *name) ...@@ -252,7 +252,10 @@ GLint Program::getUniformLocation(const char *name)
subscript = atoi(subscrStr.c_str()); subscript = atoi(subscrStr.c_str());
} }
nameStr = decorate(nameStr); if (!decorated)
{
nameStr = decorate(nameStr);
}
unsigned int numUniforms = mUniformIndex.size(); unsigned int numUniforms = mUniformIndex.size();
for (unsigned int location = 0; location < numUniforms; location++) for (unsigned int location = 0; location < numUniforms; location++)
...@@ -1494,14 +1497,16 @@ void Program::link() ...@@ -1494,14 +1497,16 @@ void Program::link()
return; return;
} }
mDepthRangeNearLocation = getUniformLocation("gl_DepthRange.near"); // these uniforms are searched as already-decorated because gl_ and dx_
mDepthRangeFarLocation = getUniformLocation("gl_DepthRange.far"); // are reserved prefixes, and do not receive additional decoration
mDepthRangeDiffLocation = getUniformLocation("gl_DepthRange.diff"); mDepthRangeNearLocation = getUniformLocation("gl_DepthRange.near", true);
mDxDepthLocation = getUniformLocation("dx_Depth"); mDepthRangeFarLocation = getUniformLocation("gl_DepthRange.far", true);
mDxWindowLocation = getUniformLocation("dx_Window"); mDepthRangeDiffLocation = getUniformLocation("gl_DepthRange.diff", true);
mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize"); mDxDepthLocation = getUniformLocation("dx_Depth", true);
mDxFrontCCWLocation = getUniformLocation("dx_FrontCCW"); mDxWindowLocation = getUniformLocation("dx_Window", true);
mDxPointsOrLinesLocation = getUniformLocation("dx_PointsOrLines"); mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize", true);
mDxFrontCCWLocation = getUniformLocation("dx_FrontCCW", true);
mDxPointsOrLinesLocation = getUniformLocation("dx_PointsOrLines", true);
mLinked = true; // Success mLinked = true; // Success
} }
...@@ -1671,7 +1676,7 @@ bool Program::defineUniform(const D3DXCONSTANT_DESC &constantDescription, std::s ...@@ -1671,7 +1676,7 @@ bool Program::defineUniform(const D3DXCONSTANT_DESC &constantDescription, std::s
} }
// Check if already defined // Check if already defined
GLint location = getUniformLocation(name.c_str()); GLint location = getUniformLocation(name.c_str(), true);
GLenum type = uniform->type; GLenum type = uniform->type;
if (location >= 0) if (location >= 0)
......
...@@ -77,7 +77,7 @@ class Program ...@@ -77,7 +77,7 @@ class Program
bool isSamplerDirty(unsigned int samplerIndex) const; bool isSamplerDirty(unsigned int samplerIndex) const;
void setSamplerDirty(unsigned int samplerIndex, bool dirty); void setSamplerDirty(unsigned int samplerIndex, bool dirty);
GLint getUniformLocation(const char *name); GLint getUniformLocation(const char *name, bool decorated);
bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v); bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
bool setUniform2fv(GLint location, GLsizei count, const GLfloat *v); bool setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
bool setUniform3fv(GLint location, GLsizei count, const GLfloat *v); bool setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
......
...@@ -2967,7 +2967,7 @@ int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) ...@@ -2967,7 +2967,7 @@ int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
return error(GL_INVALID_OPERATION, -1); return error(GL_INVALID_OPERATION, -1);
} }
return programObject->getUniformLocation(name); return programObject->getUniformLocation(name, false);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
......
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