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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 valid_ = true; 162 valid_ = true;
163 } 163 }
164 164
165 void ProgramManager::ProgramInfo::Link() { 165 void ProgramManager::ProgramInfo::Link() {
166 ClearLinkStatus(); 166 ClearLinkStatus();
167 if (!CanLink()) { 167 if (!CanLink()) {
168 set_log_info("missing shaders"); 168 set_log_info("missing shaders");
169 return; 169 return;
170 } 170 }
171 if (DetectAttribLocationBindingConflicts()) {
172 set_log_info("glBindAttribLocation() conflicts");
173 return;
174 }
171 175
172 glLinkProgram(service_id()); 176 glLinkProgram(service_id());
173 GLint success = 0; 177 GLint success = 0;
174 glGetProgramiv(service_id(), GL_LINK_STATUS, &success); 178 glGetProgramiv(service_id(), GL_LINK_STATUS, &success);
175 if (success) { 179 if (success) {
176 Update(); 180 Update();
177 } else { 181 } else {
178 UpdateLogInfo(); 182 UpdateLogInfo();
179 } 183 }
180 } 184 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 439
436 bool ProgramManager::ProgramInfo::CanLink() const { 440 bool ProgramManager::ProgramInfo::CanLink() const {
437 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { 441 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
438 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) { 442 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) {
439 return false; 443 return false;
440 } 444 }
441 } 445 }
442 return true; 446 return true;
443 } 447 }
444 448
449 bool ProgramManager::ProgramInfo::DetectAttribLocationBindingConflicts() const {
450 std::map<GLint, int> location_binding_count;
greggman 2012/03/01 22:49:36 could this just be std::set<GLint>?
451 for (std::map<std::string, GLint>::const_iterator it =
452 bind_attrib_location_map_.begin();
453 it != bind_attrib_location_map_.end(); ++it) {
454 // Find out if an attribute is declared in this program's shaders.
455 bool active = false;
456 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
457 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid())
458 continue;
459 if (attached_shaders_[ii]->GetAttribInfo(it->first)) {
460 active = true;
461 break;
462 }
463 }
464 if (active) {
greggman 2012/03/01 22:49:36 If location_binding_count is a set then this would
465 if (location_binding_count.count(it->second) > 0)
466 return true;
467 location_binding_count[it->second] = 1;
468 }
469 }
470 return false;
471 }
472
445 static uint32 ComputeOffset(const void* start, const void* position) { 473 static uint32 ComputeOffset(const void* start, const void* position) {
446 return static_cast<const uint8*>(position) - 474 return static_cast<const uint8*>(position) -
447 static_cast<const uint8*>(start); 475 static_cast<const uint8*>(start);
448 } 476 }
449 477
450 void ProgramManager::ProgramInfo::GetProgramInfo( 478 void ProgramManager::ProgramInfo::GetProgramInfo(
451 ProgramManager* manager, CommonDecoder::Bucket* bucket) const { 479 ProgramManager* manager, CommonDecoder::Bucket* bucket) const {
452 // NOTE: It seems to me the math in here does not need check for overflow 480 // NOTE: It seems to me the math in here does not need check for overflow
453 // because the data being calucated from has various small limits. The max 481 // because the data being calucated from has various small limits. The max
454 // number of attribs + uniforms is somewhere well under 1024. The maximum size 482 // number of attribs + uniforms is somewhere well under 1024. The maximum size
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 } 677 }
650 678
651 GLint ProgramManager::UnswizzleLocation(GLint v) const { 679 GLint ProgramManager::UnswizzleLocation(GLint v) const {
652 return v < 0 ? v : Swizzle(v - uniform_swizzle_); 680 return v < 0 ? v : Swizzle(v - uniform_swizzle_);
653 } 681 }
654 682
655 } // namespace gles2 683 } // namespace gles2
656 } // namespace gpu 684 } // namespace gpu
657 685
658 686
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698