summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
authorzmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-07 00:14:56 +0000
committerzmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-07 00:14:56 +0000
commit68dcb1fc0970a34de49d71d26af25928910b9477 (patch)
tree87d0a6bde40eedbd273714b5c750e70a97161c03 /gpu/command_buffer/service
parent3ab612746af9bfa1f7d502b7851330423f71c672 (diff)
downloadchromium_src-68dcb1fc0970a34de49d71d26af25928910b9477.zip
chromium_src-68dcb1fc0970a34de49d71d26af25928910b9477.tar.gz
chromium_src-68dcb1fc0970a34de49d71d26af25928910b9477.tar.bz2
Hanlde long attribute name mapping in bindAttribLocation.
BUG=122466 TEST=gl-bind-attrib-location-long-names-test.html in webgl conformance tests R=gman Review URL: https://chromiumcodereview.appspot.com/10018001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131216 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc8
-rw-r--r--gpu/command_buffer/service/program_manager.cc26
-rw-r--r--gpu/command_buffer/service/program_manager.h10
-rw-r--r--gpu/command_buffer/service/shader_manager.cc12
-rw-r--r--gpu/command_buffer/service/shader_manager.h4
5 files changed, 58 insertions, 2 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 1f3ac6f..cfb274a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -3770,6 +3770,14 @@ void GLES2DecoderImpl::DoBindAttribLocation(
SetGLError(GL_INVALID_VALUE, "glBindAttribLocation: Invalid character");
return;
}
+ if (ProgramManager::IsInvalidPrefix(name, strlen(name))) {
+ SetGLError(GL_INVALID_OPERATION, "glBindAttribLocation: reserved prefix");
+ return;
+ }
+ if (index >= group_->max_vertex_attribs()) {
+ SetGLError(GL_INVALID_VALUE, "glBindAttribLocation: index out of range");
+ return;
+ }
ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
program, "glBindAttribLocation");
if (!info) {
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index d34a181..e40d23a 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -167,6 +167,16 @@ void ProgramManager::ProgramInfo::Update() {
valid_ = true;
}
+void ProgramManager::ProgramInfo::ExecuteBindAttribLocationCalls() {
+ for (std::map<std::string, GLint>::const_iterator it =
+ bind_attrib_location_map_.begin();
+ it != bind_attrib_location_map_.end(); ++it) {
+ const std::string* mapped_name = GetAttribMappedName(it->first);
+ if (mapped_name && *mapped_name != it->first)
+ glBindAttribLocation(service_id_, it->second, mapped_name->c_str());
+ }
+}
+
void ProgramManager::ProgramInfo::Link() {
ClearLinkStatus();
if (!CanLink()) {
@@ -177,7 +187,7 @@ void ProgramManager::ProgramInfo::Link() {
set_log_info("glBindAttribLocation() conflicts");
return;
}
-
+ ExecuteBindAttribLocationCalls();
glLinkProgram(service_id());
GLint success = 0;
glGetProgramiv(service_id(), GL_LINK_STATUS, &success);
@@ -267,6 +277,20 @@ const ProgramManager::ProgramInfo::UniformInfo*
return NULL;
}
+const std::string* ProgramManager::ProgramInfo::GetAttribMappedName(
+ const std::string& original_name) const {
+ for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
+ ShaderManager::ShaderInfo* shader_info = attached_shaders_[ii].get();
+ if (shader_info) {
+ const std::string* mapped_name =
+ shader_info->GetAttribMappedName(original_name);
+ if (mapped_name)
+ return mapped_name;
+ }
+ }
+ return NULL;
+}
+
// Note: This is only valid to call right after a program has been linked
// successfully.
void ProgramManager::ProgramInfo::GetCorrectedVariableInfo(
diff --git a/gpu/command_buffer/service/program_manager.h b/gpu/command_buffer/service/program_manager.h
index 7315b68..232db91 100644
--- a/gpu/command_buffer/service/program_manager.h
+++ b/gpu/command_buffer/service/program_manager.h
@@ -108,6 +108,10 @@ class GPU_EXPORT ProgramManager {
&uniform_infos_[index] : NULL;
}
+ // If the original name is not found, return NULL.
+ const std::string* GetAttribMappedName(
+ const std::string& original_name) const;
+
// Gets the fake location of a uniform by name.
GLint GetUniformFakeLocation(const std::string& name) const;
@@ -207,6 +211,12 @@ class GPU_EXPORT ProgramManager {
// Updates the program log info from GL
void UpdateLogInfo();
+ // If long attribate names are mapped during shader translation, call
+ // glBindAttribLocation() again with the mapped names.
+ // This is called right before the glLink() call, but after shaders are
+ // translated.
+ void ExecuteBindAttribLocationCalls();
+
const UniformInfo* AddUniformInfo(
GLsizei size, GLenum type, GLint location,
const std::string& name, const std::string& original_name);
diff --git a/gpu/command_buffer/service/shader_manager.cc b/gpu/command_buffer/service/shader_manager.cc
index c703955..0d30f52 100644
--- a/gpu/command_buffer/service/shader_manager.cc
+++ b/gpu/command_buffer/service/shader_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -53,6 +53,16 @@ const ShaderManager::ShaderInfo::VariableInfo*
return it != attrib_map_.end() ? &it->second : NULL;
}
+const std::string* ShaderManager::ShaderInfo::GetAttribMappedName(
+ const std::string& original_name) const {
+ for (VariableMap::const_iterator it = attrib_map_.begin();
+ it != attrib_map_.end(); ++it) {
+ if (it->second.name == original_name)
+ return &(it->first);
+ }
+ return NULL;
+}
+
const ShaderManager::ShaderInfo::VariableInfo*
ShaderManager::ShaderInfo::GetUniformInfo(
const std::string& name) const {
diff --git a/gpu/command_buffer/service/shader_manager.h b/gpu/command_buffer/service/shader_manager.h
index 04b431a..9b6fad2 100644
--- a/gpu/command_buffer/service/shader_manager.h
+++ b/gpu/command_buffer/service/shader_manager.h
@@ -66,6 +66,10 @@ class GPU_EXPORT ShaderManager {
const VariableInfo* GetAttribInfo(const std::string& name) const;
const VariableInfo* GetUniformInfo(const std::string& name) const;
+ // If the original_name is not found, return NULL.
+ const std::string* GetAttribMappedName(
+ const std::string& original_name) const;
+
const std::string* log_info() const {
return log_info_.get();
}