Not not allow the app to query uniform locations of basic types with "[0]"…

Not not allow the app to query uniform locations of basic types with "[0]" appended to the uniform name. TRAC #22865 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2295 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2a9a9d23
...@@ -223,7 +223,7 @@ TextureType ProgramBinary::getSamplerTextureType(SamplerType type, unsigned int ...@@ -223,7 +223,7 @@ TextureType ProgramBinary::getSamplerTextureType(SamplerType type, unsigned int
GLint ProgramBinary::getUniformLocation(std::string name) GLint ProgramBinary::getUniformLocation(std::string name)
{ {
unsigned int subscript = 0; unsigned int subscript = GL_INVALID_INDEX;
// Strip any trailing array operator and retrieve the subscript // Strip any trailing array operator and retrieve the subscript
size_t open = name.find_last_of('['); size_t open = name.find_last_of('[');
...@@ -237,10 +237,16 @@ GLint ProgramBinary::getUniformLocation(std::string name) ...@@ -237,10 +237,16 @@ GLint ProgramBinary::getUniformLocation(std::string name)
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++)
{ {
if (mUniformIndex[location].name == name && if (mUniformIndex[location].name == name)
mUniformIndex[location].element == subscript)
{ {
return location; const int index = mUniformIndex[location].index;
const bool isArray = mUniforms[index]->isArray();
if ((isArray && mUniformIndex[location].element == subscript) ||
(subscript == GL_INVALID_INDEX))
{
return location;
}
} }
} }
......
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