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

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

Issue 9570023: Fails glLinkProgram if two glBindAttribLocation conflicts. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
Index: gpu/command_buffer/service/program_manager.cc
===================================================================
--- gpu/command_buffer/service/program_manager.cc (revision 124489)
+++ gpu/command_buffer/service/program_manager.cc (working copy)
@@ -5,6 +5,7 @@
#include "gpu/command_buffer/service/program_manager.h"
#include <algorithm>
+#include <set>
#include "base/basictypes.h"
#include "base/logging.h"
@@ -168,6 +169,10 @@
set_log_info("missing shaders");
return;
}
+ if (DetectAttribLocationBindingConflicts()) {
+ set_log_info("glBindAttribLocation() conflicts");
+ return;
+ }
glLinkProgram(service_id());
GLint success = 0;
@@ -442,6 +447,31 @@
return true;
}
+bool ProgramManager::ProgramInfo::DetectAttribLocationBindingConflicts() const {
+ std::set<GLint> location_binding_used;
+ for (std::map<std::string, GLint>::const_iterator it =
+ bind_attrib_location_map_.begin();
+ it != bind_attrib_location_map_.end(); ++it) {
+ // Find out if an attribute is declared in this program's shaders.
+ bool active = false;
+ for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
+ if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid())
+ continue;
+ if (attached_shaders_[ii]->GetAttribInfo(it->first)) {
+ active = true;
+ break;
+ }
+ }
+ if (active) {
+ std::pair<std::set<GLint>::iterator, bool> result =
+ location_binding_used.insert(it->second);
+ if (!result.second)
+ return true;
+ }
+ }
+ return false;
+}
+
static uint32 ComputeOffset(const void* start, const void* position) {
return static_cast<const uint8*>(position) -
static_cast<const uint8*>(start);

Powered by Google App Engine
This is Rietveld 408576698