Chromium Code Reviews| Index: gpu/command_buffer/service/shader_manager.cc |
| diff --git a/gpu/command_buffer/service/shader_manager.cc b/gpu/command_buffer/service/shader_manager.cc |
| index 189d78bf0a2c4d94a941e0fb062465a18a0a2850..7b314409668dc5b059c28ebc4d402b02bbf75bd9 100644 |
| --- a/gpu/command_buffer/service/shader_manager.cc |
| +++ b/gpu/command_buffer/service/shader_manager.cc |
| @@ -12,6 +12,18 @@ |
| namespace gpu { |
| namespace gles2 { |
| +namespace { |
| + |
| +// Given a variable name | a[0].b.c[0] |, return |a|. |
| +std::string GetTopVariableName(const std::string& fullname) { |
| + size_t pos = fullname.find_first_of("[."); |
| + if (pos == std::string::npos) |
| + return fullname; |
| + return fullname.substr(0, pos); |
| +} |
| + |
| +} // namespace anonymous |
| + |
| Shader::Shader(GLuint service_id, GLenum shader_type) |
| : use_count_(0), |
| service_id_(service_id), |
| @@ -96,15 +108,14 @@ void Shader::MarkAsDeleted() { |
| service_id_ = 0; |
| } |
| -const Shader::VariableInfo* Shader::GetAttribInfo( |
| - const std::string& name) const { |
| - VariableMap::const_iterator it = attrib_map_.find(name); |
| +const sh::Attribute* Shader::GetAttribInfo(const std::string& name) const { |
| + AttributeMap::const_iterator it = attrib_map_.find(GetTopVariableName(name)); |
|
Ken Russell (switch to Gerrit)
2014/10/07 03:35:26
Per comment above: vertex shader inputs can't be a
Zhenyao Mo
2014/10/07 18:23:41
Done.
|
| return it != attrib_map_.end() ? &it->second : NULL; |
| } |
| const std::string* Shader::GetAttribMappedName( |
| const std::string& original_name) const { |
| - for (VariableMap::const_iterator it = attrib_map_.begin(); |
| + for (AttributeMap::const_iterator it = attrib_map_.begin(); |
| it != attrib_map_.end(); ++it) { |
| if (it->second.name == original_name) |
| return &(it->first); |
| @@ -120,15 +131,13 @@ const std::string* Shader::GetOriginalNameFromHashedName( |
| return NULL; |
| } |
| -const Shader::VariableInfo* Shader::GetUniformInfo( |
| - const std::string& name) const { |
| - VariableMap::const_iterator it = uniform_map_.find(name); |
| +const sh::Uniform* Shader::GetUniformInfo(const std::string& name) const { |
| + UniformMap::const_iterator it = uniform_map_.find(GetTopVariableName(name)); |
| return it != uniform_map_.end() ? &it->second : NULL; |
| } |
| -const Shader::VariableInfo* Shader::GetVaryingInfo( |
| - const std::string& name) const { |
| - VariableMap::const_iterator it = varying_map_.find(name); |
| +const sh::Varying* Shader::GetVaryingInfo(const std::string& name) const { |
| + VaryingMap::const_iterator it = varying_map_.find(GetTopVariableName(name)); |
| return it != varying_map_.end() ? &it->second : NULL; |
| } |