Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4173)

Unified Diff: gpu/command_buffer/service/shader_manager.cc

Issue 619723008: Switch to use ANGLE's new APIs to query shader variables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win build fix Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/shader_manager.h ('k') | gpu/command_buffer/service/shader_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2707b90b92de4105d6b8c9f1dad28a0663158f0e 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,17 @@ 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 {
+ // Vertex attributes can't be arrays or structs (GLSL ES 3.00.4, section
+ // 4.3.4, "Input Variables"), so |name| is the top level name used as
+ // the AttributeMap key.
+ AttributeMap::const_iterator it = attrib_map_.find(name);
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 +134,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;
}
« no previous file with comments | « gpu/command_buffer/service/shader_manager.h ('k') | gpu/command_buffer/service/shader_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698