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

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
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 #include <set>
8 9
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
13 #include "gpu/command_buffer/common/gles2_cmd_format.h" 14 #include "gpu/command_buffer/common/gles2_cmd_format.h"
14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
15 16
16 namespace gpu { 17 namespace gpu {
17 namespace gles2 { 18 namespace gles2 {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 162 }
162 valid_ = true; 163 valid_ = true;
163 } 164 }
164 165
165 void ProgramManager::ProgramInfo::Link() { 166 void ProgramManager::ProgramInfo::Link() {
166 ClearLinkStatus(); 167 ClearLinkStatus();
167 if (!CanLink()) { 168 if (!CanLink()) {
168 set_log_info("missing shaders"); 169 set_log_info("missing shaders");
169 return; 170 return;
170 } 171 }
172 if (DetectAttribLocationBindingConflicts()) {
173 set_log_info("glBindAttribLocation() conflicts");
174 return;
175 }
171 176
172 glLinkProgram(service_id()); 177 glLinkProgram(service_id());
173 GLint success = 0; 178 GLint success = 0;
174 glGetProgramiv(service_id(), GL_LINK_STATUS, &success); 179 glGetProgramiv(service_id(), GL_LINK_STATUS, &success);
175 if (success) { 180 if (success) {
176 Update(); 181 Update();
177 } else { 182 } else {
178 UpdateLogInfo(); 183 UpdateLogInfo();
179 } 184 }
180 } 185 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 440
436 bool ProgramManager::ProgramInfo::CanLink() const { 441 bool ProgramManager::ProgramInfo::CanLink() const {
437 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { 442 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
438 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) { 443 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) {
439 return false; 444 return false;
440 } 445 }
441 } 446 }
442 return true; 447 return true;
443 } 448 }
444 449
450 bool ProgramManager::ProgramInfo::DetectAttribLocationBindingConflicts() const {
451 std::set<GLint> location_binding_used;
452 for (std::map<std::string, GLint>::const_iterator it =
453 bind_attrib_location_map_.begin();
454 it != bind_attrib_location_map_.end(); ++it) {
455 // Find out if an attribute is declared in this program's shaders.
456 bool active = false;
457 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) {
458 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid())
459 continue;
460 if (attached_shaders_[ii]->GetAttribInfo(it->first)) {
461 active = true;
462 break;
463 }
464 }
465 if (active) {
466 std::pair<std::set<GLint>::iterator, bool> result =
467 location_binding_used.insert(it->second);
468 if (!result.second)
469 return true;
470 }
471 }
472 return false;
473 }
474
445 static uint32 ComputeOffset(const void* start, const void* position) { 475 static uint32 ComputeOffset(const void* start, const void* position) {
446 return static_cast<const uint8*>(position) - 476 return static_cast<const uint8*>(position) -
447 static_cast<const uint8*>(start); 477 static_cast<const uint8*>(start);
448 } 478 }
449 479
450 void ProgramManager::ProgramInfo::GetProgramInfo( 480 void ProgramManager::ProgramInfo::GetProgramInfo(
451 ProgramManager* manager, CommonDecoder::Bucket* bucket) const { 481 ProgramManager* manager, CommonDecoder::Bucket* bucket) const {
452 // NOTE: It seems to me the math in here does not need check for overflow 482 // 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 483 // 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 484 // 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 } 679 }
650 680
651 GLint ProgramManager::UnswizzleLocation(GLint v) const { 681 GLint ProgramManager::UnswizzleLocation(GLint v) const {
652 return v < 0 ? v : Swizzle(v - uniform_swizzle_); 682 return v < 0 ? v : Swizzle(v - uniform_swizzle_);
653 } 683 }
654 684
655 } // namespace gles2 685 } // namespace gles2
656 } // namespace gpu 686 } // namespace gpu
657 687
658 688
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | gpu/command_buffer/service/program_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698