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

Side by Side Diff: gpu/command_buffer/service/program_manager.cc

Issue 6242006: Fix for gl programs. An unsuccessful link should report... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 30 matching lines...) Expand all
41 static const char kInvalidPrefix[] = { 'g', 'l', '_' }; 41 static const char kInvalidPrefix[] = { 'g', 'l', '_' };
42 return (length >= sizeof(kInvalidPrefix) && 42 return (length >= sizeof(kInvalidPrefix) &&
43 memcmp(name, kInvalidPrefix, sizeof(kInvalidPrefix)) == 0); 43 memcmp(name, kInvalidPrefix, sizeof(kInvalidPrefix)) == 0);
44 } 44 }
45 45
46 ProgramManager::ProgramInfo::ProgramInfo(GLuint service_id) 46 ProgramManager::ProgramInfo::ProgramInfo(GLuint service_id)
47 : use_count_(0), 47 : use_count_(0),
48 max_attrib_name_length_(0), 48 max_attrib_name_length_(0),
49 max_uniform_name_length_(0), 49 max_uniform_name_length_(0),
50 service_id_(service_id), 50 service_id_(service_id),
51 valid_(false) { 51 valid_(false),
52 link_status_(false) {
52 } 53 }
53 54
54 void ProgramManager::ProgramInfo::Reset() { 55 void ProgramManager::ProgramInfo::Reset() {
55 valid_ = false; 56 valid_ = false;
57 link_status_ = false;
56 max_uniform_name_length_ = 0; 58 max_uniform_name_length_ = 0;
57 max_attrib_name_length_ = 0; 59 max_attrib_name_length_ = 0;
58 attrib_infos_.clear(); 60 attrib_infos_.clear();
59 uniform_infos_.clear(); 61 uniform_infos_.clear();
60 sampler_indices_.clear(); 62 sampler_indices_.clear();
61 attrib_location_to_index_map_.clear(); 63 attrib_location_to_index_map_.clear();
62 uniform_location_to_index_map_.clear(); 64 uniform_location_to_index_map_.clear();
63 UpdateLogInfo(); 65 UpdateLogInfo();
64 } 66 }
65 67
66 void ProgramManager::ProgramInfo::UpdateLogInfo() { 68 void ProgramManager::ProgramInfo::UpdateLogInfo() {
67 GLint max_len = 0; 69 GLint max_len = 0;
68 glGetProgramiv(service_id_, GL_INFO_LOG_LENGTH, &max_len); 70 glGetProgramiv(service_id_, GL_INFO_LOG_LENGTH, &max_len);
69 scoped_array<char> temp(new char[max_len]); 71 scoped_array<char> temp(new char[max_len]);
70 GLint len = 0; 72 GLint len = 0;
71 glGetProgramInfoLog(service_id_, max_len, &len, temp.get()); 73 glGetProgramInfoLog(service_id_, max_len, &len, temp.get());
72 DCHECK(max_len == 0 || len < max_len); 74 DCHECK(max_len == 0 || len < max_len);
73 DCHECK(len == 0 || temp[len] == '\0'); 75 DCHECK(len == 0 || temp[len] == '\0');
74 set_log_info(std::string(temp.get(), len)); 76 set_log_info(std::string(temp.get(), len));
75 } 77 }
76 78
77 void ProgramManager::ProgramInfo::Update() { 79 void ProgramManager::ProgramInfo::Update() {
78 Reset(); 80 Reset();
81 link_status_ = true;
79 GLint num_attribs = 0; 82 GLint num_attribs = 0;
80 GLint max_len = 0; 83 GLint max_len = 0;
81 GLint max_location = -1; 84 GLint max_location = -1;
82 glGetProgramiv(service_id_, GL_ACTIVE_ATTRIBUTES, &num_attribs); 85 glGetProgramiv(service_id_, GL_ACTIVE_ATTRIBUTES, &num_attribs);
83 glGetProgramiv(service_id_, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_len); 86 glGetProgramiv(service_id_, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_len);
84 // TODO(gman): Should we check for error? 87 // TODO(gman): Should we check for error?
85 scoped_array<char> name_buffer(new char[max_len]); 88 scoped_array<char> name_buffer(new char[max_len]);
86 for (GLint ii = 0; ii < num_attribs; ++ii) { 89 for (GLint ii = 0; ii < num_attribs; ++ii) {
87 GLsizei length = 0; 90 GLsizei length = 0;
88 GLsizei size = 0; 91 GLsizei size = 0;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 *params = max_attrib_name_length_ + 1; 333 *params = max_attrib_name_length_ + 1;
331 break; 334 break;
332 case GL_ACTIVE_UNIFORMS: 335 case GL_ACTIVE_UNIFORMS:
333 *params = uniform_infos_.size(); 336 *params = uniform_infos_.size();
334 break; 337 break;
335 case GL_ACTIVE_UNIFORM_MAX_LENGTH: 338 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
336 // Notice +1 to accomodate NULL terminator. 339 // Notice +1 to accomodate NULL terminator.
337 *params = max_uniform_name_length_ + 1; 340 *params = max_uniform_name_length_ + 1;
338 break; 341 break;
339 case GL_LINK_STATUS: 342 case GL_LINK_STATUS:
340 *params = valid_; 343 *params = link_status_;
341 break; 344 break;
342 case GL_INFO_LOG_LENGTH: 345 case GL_INFO_LOG_LENGTH:
343 // Notice +1 to accomodate NULL terminator. 346 // Notice +1 to accomodate NULL terminator.
344 *params = log_info_.size() + 1; 347 *params = log_info_.size() + 1;
345 break; 348 break;
346 case GL_VALIDATE_STATUS: 349 case GL_VALIDATE_STATUS:
347 if (!CanLink()) { 350 if (!CanLink()) {
348 *params = GL_FALSE; 351 *params = GL_FALSE;
349 } else { 352 } else {
350 glGetProgramiv(service_id_, pname, params); 353 glGetProgramiv(service_id_, pname, params);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 DCHECK(shader_manager); 483 DCHECK(shader_manager);
481 DCHECK(info); 484 DCHECK(info);
482 info->DecUseCount(); 485 info->DecUseCount();
483 RemoveProgramInfoIfUnused(shader_manager, info); 486 RemoveProgramInfoIfUnused(shader_manager, info);
484 } 487 }
485 488
486 } // namespace gles2 489 } // namespace gles2
487 } // namespace gpu 490 } // namespace gpu
488 491
489 492
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