Index: gpu/command_buffer/service/program_manager.cc |
=================================================================== |
--- gpu/command_buffer/service/program_manager.cc (revision 123809) |
+++ gpu/command_buffer/service/program_manager.cc (working copy) |
@@ -168,6 +168,10 @@ |
set_log_info("missing shaders"); |
return; |
} |
+ if (DetectAttribLocationBindingConflicts()) { |
+ set_log_info("glBindAttribLocation() conflicts"); |
+ return; |
+ } |
glLinkProgram(service_id()); |
GLint success = 0; |
@@ -442,6 +446,30 @@ |
return true; |
} |
+bool ProgramManager::ProgramInfo::DetectAttribLocationBindingConflicts() const { |
+ std::map<GLint, int> location_binding_count; |
greggman
2012/03/01 22:49:36
could this just be std::set<GLint>?
|
+ 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) { |
greggman
2012/03/01 22:49:36
If location_binding_count is a set then this would
|
+ if (location_binding_count.count(it->second) > 0) |
+ return true; |
+ location_binding_count[it->second] = 1; |
+ } |
+ } |
+ return false; |
+} |
+ |
static uint32 ComputeOffset(const void* start, const void* position) { |
return static_cast<const uint8*>(position) - |
static_cast<const uint8*>(start); |