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

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

Issue 10894023: Merge 152707 - Fix Uniform Name Parsing (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1229/src/
Patch Set: Created 8 years, 3 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 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (!IsValid()) { 569 if (!IsValid()) {
570 set_log_info("program not linked"); 570 set_log_info("program not linked");
571 return; 571 return;
572 } 572 }
573 glValidateProgram(service_id()); 573 glValidateProgram(service_id());
574 UpdateLogInfo(); 574 UpdateLogInfo();
575 } 575 }
576 576
577 GLint ProgramManager::ProgramInfo::GetUniformFakeLocation( 577 GLint ProgramManager::ProgramInfo::GetUniformFakeLocation(
578 const std::string& name) const { 578 const std::string& name) const {
579 bool getting_array_location = false;
580 size_t open_pos = std::string::npos;
581 int index = 0;
582 if (!GLES2Util::ParseUniformName(
583 name, &open_pos, &index, &getting_array_location)) {
584 return -1;
585 }
579 for (GLuint ii = 0; ii < uniform_infos_.size(); ++ii) { 586 for (GLuint ii = 0; ii < uniform_infos_.size(); ++ii) {
580 const UniformInfo& info = uniform_infos_[ii]; 587 const UniformInfo& info = uniform_infos_[ii];
581 if (!info.IsValid()) { 588 if (!info.IsValid()) {
582 continue; 589 continue;
583 } 590 }
584 if (info.name == name || 591 if (info.name == name ||
585 (info.is_array && 592 (info.is_array &&
586 info.name.compare(0, info.name.size() - 3, name) == 0)) { 593 info.name.compare(0, info.name.size() - 3, name) == 0)) {
587 return info.fake_location_base; 594 return info.fake_location_base;
588 } else if (info.is_array && 595 } else if (getting_array_location && info.is_array) {
589 name.size() >= 3 && name[name.size() - 1] == ']') {
590 // Look for an array specification. 596 // Look for an array specification.
591 size_t open_pos = name.find_last_of('['); 597 size_t open_pos_2 = info.name.find_last_of('[');
592 if (open_pos != std::string::npos && 598 if (open_pos_2 == open_pos &&
593 open_pos < name.size() - 2 &&
594 info.name.size() > open_pos &&
595 name.compare(0, open_pos, info.name, 0, open_pos) == 0) { 599 name.compare(0, open_pos, info.name, 0, open_pos) == 0) {
596 GLint index = 0; 600 if (index >= 0 && index < info.size) {
597 size_t last = name.size() - 1;
598 bool bad = false;
599 for (size_t pos = open_pos + 1; pos < last; ++pos) {
600 int8 digit = name[pos] - '0';
601 if (digit < 0 || digit > 9) {
602 bad = true;
603 break;
604 }
605 index = index * 10 + digit;
606 }
607 if (!bad && index >= 0 && index < info.size) {
608 return ProgramManager::MakeFakeLocation( 601 return ProgramManager::MakeFakeLocation(
609 info.fake_location_base, index); 602 info.fake_location_base, index);
610 } 603 }
611 } 604 }
612 } 605 }
613 } 606 }
614 return -1; 607 return -1;
615 } 608 }
616 609
617 GLint ProgramManager::ProgramInfo::GetAttribLocation( 610 GLint ProgramManager::ProgramInfo::GetAttribLocation(
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 info->ClearUniforms(&zero_); 1142 info->ClearUniforms(&zero_);
1150 } 1143 }
1151 } 1144 }
1152 1145
1153 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { 1146 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) {
1154 return index + element * 0x10000; 1147 return index + element * 0x10000;
1155 } 1148 }
1156 1149
1157 } // namespace gles2 1150 } // namespace gles2
1158 } // namespace gpu 1151 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils_unittest.cc ('k') | gpu/command_buffer/service/program_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698