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

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

Issue 153173002: Add a gpu driver bug workaround to count in all varyings in packing check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 "gl_FrontFacing", 110 "gl_FrontFacing",
111 "gl_PointCoord" 111 "gl_PointCoord"
112 }; 112 };
113 for (size_t ii = 0; ii < arraysize(kBuiltInVaryings); ++ii) { 113 for (size_t ii = 0; ii < arraysize(kBuiltInVaryings); ++ii) {
114 if (name == kBuiltInVaryings[ii]) 114 if (name == kBuiltInVaryings[ii])
115 return true; 115 return true;
116 } 116 }
117 return false; 117 return false;
118 } 118 }
119 119
120 bool IsGpuDriverBugWorkaroundsDisabled() {
121 return CommandLine::ForCurrentProcess()->HasSwitch(
122 switches::kDisableGpuDriverBugWorkarounds);
123 }
124
120 } // anonymous namespace. 125 } // anonymous namespace.
121 126
122 Program::UniformInfo::UniformInfo() 127 Program::UniformInfo::UniformInfo()
123 : size(0), 128 : size(0),
124 type(GL_NONE), 129 type(GL_NONE),
125 fake_location_base(0), 130 fake_location_base(0),
126 is_array(false) { 131 is_array(false) {
127 } 132 }
128 133
129 Program::UniformInfo::UniformInfo( 134 Program::UniformInfo::UniformInfo(
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 "not declared in vertex shader: " + conflicting_name; 551 "not declared in vertex shader: " + conflicting_name;
547 set_log_info(ProcessLogInfo(info_log).c_str()); 552 set_log_info(ProcessLogInfo(info_log).c_str());
548 return false; 553 return false;
549 } 554 }
550 if (DetectGlobalNameConflicts(&conflicting_name)) { 555 if (DetectGlobalNameConflicts(&conflicting_name)) {
551 std::string info_log = "Name conflicts between an uniform and an " 556 std::string info_log = "Name conflicts between an uniform and an "
552 "attribute: " + conflicting_name; 557 "attribute: " + conflicting_name;
553 set_log_info(ProcessLogInfo(info_log).c_str()); 558 set_log_info(ProcessLogInfo(info_log).c_str());
554 return false; 559 return false;
555 } 560 }
556 if (!CheckVaryingsPacking()) { 561 VaryingsPackingOption option = kCountOnlyStaticallyUsed;
562 if (!IsGpuDriverBugWorkaroundsDisabled() &&
Ken Russell (switch to Gerrit) 2014/02/04 00:34:37 It seems unfortunate to me that the Program object
Zhenyao Mo 2014/02/06 21:54:05 Refactored, so done.
563 feature_info &&
564 feature_info->workarounds().count_all_in_varyings_packing)
565 option = kCountAll;
566 if (!CheckVaryingsPacking(option)) {
557 set_log_info("Varyings over maximum register limit"); 567 set_log_info("Varyings over maximum register limit");
558 return false; 568 return false;
559 } 569 }
560 570
561 TimeTicks before_time = TimeTicks::HighResNow(); 571 TimeTicks before_time = TimeTicks::HighResNow();
562 bool link = true; 572 bool link = true;
563 ProgramCache* cache = manager_->program_cache_; 573 ProgramCache* cache = manager_->program_cache_;
564 if (cache) { 574 if (cache) {
565 DCHECK(attached_shaders_[0]->signature_source() && 575 DCHECK(attached_shaders_[0]->signature_source() &&
566 attached_shaders_[1]->signature_source()); 576 attached_shaders_[1]->signature_source());
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 for (int ii = 0; ii < 2; ++ii) { 1101 for (int ii = 0; ii < 2; ++ii) {
1092 if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) { 1102 if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) {
1093 *conflicting_name = iter->first; 1103 *conflicting_name = iter->first;
1094 return true; 1104 return true;
1095 } 1105 }
1096 } 1106 }
1097 } 1107 }
1098 return false; 1108 return false;
1099 } 1109 }
1100 1110
1101 bool Program::CheckVaryingsPacking() const { 1111 bool Program::CheckVaryingsPacking(
1112 Program::VaryingsPackingOption option) const {
1102 DCHECK(attached_shaders_[0] && 1113 DCHECK(attached_shaders_[0] &&
1103 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && 1114 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER &&
1104 attached_shaders_[1] && 1115 attached_shaders_[1] &&
1105 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER); 1116 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER);
1106 const ShaderTranslator::VariableMap* vertex_varyings = 1117 const ShaderTranslator::VariableMap* vertex_varyings =
1107 &(attached_shaders_[0]->varying_map()); 1118 &(attached_shaders_[0]->varying_map());
1108 const ShaderTranslator::VariableMap* fragment_varyings = 1119 const ShaderTranslator::VariableMap* fragment_varyings =
1109 &(attached_shaders_[1]->varying_map()); 1120 &(attached_shaders_[1]->varying_map());
1110 1121
1111 std::map<std::string, ShVariableInfo> combined_map; 1122 std::map<std::string, ShVariableInfo> combined_map;
1112 1123
1113 for (ShaderTranslator::VariableMap::const_iterator iter = 1124 for (ShaderTranslator::VariableMap::const_iterator iter =
1114 fragment_varyings->begin(); 1125 fragment_varyings->begin();
1115 iter != fragment_varyings->end(); ++iter) { 1126 iter != fragment_varyings->end(); ++iter) {
1116 if (!iter->second.static_use) 1127 if (!iter->second.static_use && option == kCountOnlyStaticallyUsed)
1117 continue; 1128 continue;
1118 if (!IsBuiltInVarying(iter->first)) { 1129 if (!IsBuiltInVarying(iter->first)) {
1119 ShaderTranslator::VariableMap::const_iterator vertex_iter = 1130 ShaderTranslator::VariableMap::const_iterator vertex_iter =
1120 vertex_varyings->find(iter->first); 1131 vertex_varyings->find(iter->first);
1121 if (vertex_iter == vertex_varyings->end() || 1132 if (vertex_iter == vertex_varyings->end() ||
1122 !vertex_iter->second.static_use) 1133 (!vertex_iter->second.static_use &&
1134 option == kCountOnlyStaticallyUsed))
1123 continue; 1135 continue;
1124 } 1136 }
1125 1137
1126 ShVariableInfo var; 1138 ShVariableInfo var;
1127 var.type = static_cast<ShDataType>(iter->second.type); 1139 var.type = static_cast<ShDataType>(iter->second.type);
1128 var.size = iter->second.size; 1140 var.size = iter->second.size;
1129 combined_map[iter->first] = var; 1141 combined_map[iter->first] = var;
1130 } 1142 }
1131 1143
1132 if (combined_map.size() == 0) 1144 if (combined_map.size() == 0)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 manager_->StopTracking(this); 1256 manager_->StopTracking(this);
1245 manager_ = NULL; 1257 manager_ = NULL;
1246 } 1258 }
1247 } 1259 }
1248 1260
1249 1261
1250 ProgramManager::ProgramManager(ProgramCache* program_cache, 1262 ProgramManager::ProgramManager(ProgramCache* program_cache,
1251 uint32 max_varying_vectors) 1263 uint32 max_varying_vectors)
1252 : program_count_(0), 1264 : program_count_(0),
1253 have_context_(true), 1265 have_context_(true),
1254 disable_workarounds_(
1255 CommandLine::ForCurrentProcess()->HasSwitch(
1256 switches::kDisableGpuDriverBugWorkarounds)),
1257 program_cache_(program_cache), 1266 program_cache_(program_cache),
1258 max_varying_vectors_(max_varying_vectors) { } 1267 max_varying_vectors_(max_varying_vectors) { }
1259 1268
1260 ProgramManager::~ProgramManager() { 1269 ProgramManager::~ProgramManager() {
1261 DCHECK(programs_.empty()); 1270 DCHECK(programs_.empty());
1262 } 1271 }
1263 1272
1264 void ProgramManager::Destroy(bool have_context) { 1273 void ProgramManager::Destroy(bool have_context) {
1265 have_context_ = have_context; 1274 have_context_ = have_context;
1266 programs_.clear(); 1275 programs_.clear();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 Program* program) { 1365 Program* program) {
1357 DCHECK(shader_manager); 1366 DCHECK(shader_manager);
1358 DCHECK(program); 1367 DCHECK(program);
1359 DCHECK(IsOwned(program)); 1368 DCHECK(IsOwned(program));
1360 program->DecUseCount(); 1369 program->DecUseCount();
1361 RemoveProgramInfoIfUnused(shader_manager, program); 1370 RemoveProgramInfoIfUnused(shader_manager, program);
1362 } 1371 }
1363 1372
1364 void ProgramManager::ClearUniforms(Program* program) { 1373 void ProgramManager::ClearUniforms(Program* program) {
1365 DCHECK(program); 1374 DCHECK(program);
1366 if (!disable_workarounds_) { 1375 if (!IsGpuDriverBugWorkaroundsDisabled()) {
Ken Russell (switch to Gerrit) 2014/02/04 00:34:37 Tying together these two bug workarounds (needing
Zhenyao Mo 2014/02/06 21:54:05 A previous CL fixed the ClearUniforms workaround a
1367 program->ClearUniforms(&zero_); 1376 program->ClearUniforms(&zero_);
1368 } 1377 }
1369 } 1378 }
1370 1379
1371 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { 1380 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) {
1372 return index + element * 0x10000; 1381 return index + element * 0x10000;
1373 } 1382 }
1374 1383
1375 } // namespace gles2 1384 } // namespace gles2
1376 } // namespace gpu 1385 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698