Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 "gl_FrontFacing", | 109 "gl_FrontFacing", |
| 110 "gl_PointCoord" | 110 "gl_PointCoord" |
| 111 }; | 111 }; |
| 112 for (size_t ii = 0; ii < arraysize(kBuiltInVaryings); ++ii) { | 112 for (size_t ii = 0; ii < arraysize(kBuiltInVaryings); ++ii) { |
| 113 if (name == kBuiltInVaryings[ii]) | 113 if (name == kBuiltInVaryings[ii]) |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool IsGpuDriverBugWorkaroundsDisabled() { | |
| 120 return CommandLine::ForCurrentProcess()->HasSwitch( | |
| 121 switches::kDisableGpuDriverBugWorkarounds); | |
| 122 } | |
|
Ken Russell (switch to Gerrit)
2014/02/06 22:13:30
This function's unused and must be deleted (the un
Zhenyao Mo
2014/02/06 23:42:40
Done.
| |
| 123 | |
| 119 } // anonymous namespace. | 124 } // anonymous namespace. |
| 120 | 125 |
| 121 Program::UniformInfo::UniformInfo() | 126 Program::UniformInfo::UniformInfo() |
| 122 : size(0), | 127 : size(0), |
| 123 type(GL_NONE), | 128 type(GL_NONE), |
| 124 fake_location_base(0), | 129 fake_location_base(0), |
| 125 is_array(false) { | 130 is_array(false) { |
| 126 } | 131 } |
| 127 | 132 |
| 128 Program::UniformInfo::UniformInfo( | 133 Program::UniformInfo::UniformInfo( |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 << "unless the driver is buggy:" | 520 << "unless the driver is buggy:" |
| 516 << "\n--original-shader--\n" << (source ? *source : std::string()) | 521 << "\n--original-shader--\n" << (source ? *source : std::string()) |
| 517 << "\n--translated-shader--\n" << shader_src << "\n--info-log--\n" | 522 << "\n--translated-shader--\n" << shader_src << "\n--info-log--\n" |
| 518 << *shader->log_info(); | 523 << *shader->log_info(); |
| 519 } | 524 } |
| 520 } | 525 } |
| 521 | 526 |
| 522 bool Program::Link(ShaderManager* manager, | 527 bool Program::Link(ShaderManager* manager, |
| 523 ShaderTranslator* vertex_translator, | 528 ShaderTranslator* vertex_translator, |
| 524 ShaderTranslator* fragment_translator, | 529 ShaderTranslator* fragment_translator, |
| 530 Program::VaryingsPackingOption varyings_packing_option, | |
| 525 const ShaderCacheCallback& shader_callback) { | 531 const ShaderCacheCallback& shader_callback) { |
| 526 ClearLinkStatus(); | 532 ClearLinkStatus(); |
| 527 if (!CanLink()) { | 533 if (!CanLink()) { |
| 528 set_log_info("missing shaders"); | 534 set_log_info("missing shaders"); |
| 529 return false; | 535 return false; |
| 530 } | 536 } |
| 531 if (DetectAttribLocationBindingConflicts()) { | 537 if (DetectAttribLocationBindingConflicts()) { |
| 532 set_log_info("glBindAttribLocation() conflicts"); | 538 set_log_info("glBindAttribLocation() conflicts"); |
| 533 return false; | 539 return false; |
| 534 } | 540 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 545 "not declared in vertex shader: " + conflicting_name; | 551 "not declared in vertex shader: " + conflicting_name; |
| 546 set_log_info(ProcessLogInfo(info_log).c_str()); | 552 set_log_info(ProcessLogInfo(info_log).c_str()); |
| 547 return false; | 553 return false; |
| 548 } | 554 } |
| 549 if (DetectGlobalNameConflicts(&conflicting_name)) { | 555 if (DetectGlobalNameConflicts(&conflicting_name)) { |
| 550 std::string info_log = "Name conflicts between an uniform and an " | 556 std::string info_log = "Name conflicts between an uniform and an " |
| 551 "attribute: " + conflicting_name; | 557 "attribute: " + conflicting_name; |
| 552 set_log_info(ProcessLogInfo(info_log).c_str()); | 558 set_log_info(ProcessLogInfo(info_log).c_str()); |
| 553 return false; | 559 return false; |
| 554 } | 560 } |
| 555 if (!CheckVaryingsPacking()) { | 561 if (!CheckVaryingsPacking(varyings_packing_option)) { |
| 556 set_log_info("Varyings over maximum register limit"); | 562 set_log_info("Varyings over maximum register limit"); |
| 557 return false; | 563 return false; |
| 558 } | 564 } |
| 559 | 565 |
| 560 TimeTicks before_time = TimeTicks::HighResNow(); | 566 TimeTicks before_time = TimeTicks::HighResNow(); |
| 561 bool link = true; | 567 bool link = true; |
| 562 ProgramCache* cache = manager_->program_cache_; | 568 ProgramCache* cache = manager_->program_cache_; |
| 563 if (cache) { | 569 if (cache) { |
| 564 DCHECK(attached_shaders_[0]->signature_source() && | 570 DCHECK(attached_shaders_[0]->signature_source() && |
| 565 attached_shaders_[1]->signature_source()); | 571 attached_shaders_[1]->signature_source()); |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 for (int ii = 0; ii < 2; ++ii) { | 1096 for (int ii = 0; ii < 2; ++ii) { |
| 1091 if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) { | 1097 if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) { |
| 1092 *conflicting_name = iter->first; | 1098 *conflicting_name = iter->first; |
| 1093 return true; | 1099 return true; |
| 1094 } | 1100 } |
| 1095 } | 1101 } |
| 1096 } | 1102 } |
| 1097 return false; | 1103 return false; |
| 1098 } | 1104 } |
| 1099 | 1105 |
| 1100 bool Program::CheckVaryingsPacking() const { | 1106 bool Program::CheckVaryingsPacking( |
| 1107 Program::VaryingsPackingOption option) const { | |
| 1101 DCHECK(attached_shaders_[0] && | 1108 DCHECK(attached_shaders_[0] && |
| 1102 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && | 1109 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && |
| 1103 attached_shaders_[1] && | 1110 attached_shaders_[1] && |
| 1104 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER); | 1111 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER); |
| 1105 const ShaderTranslator::VariableMap* vertex_varyings = | 1112 const ShaderTranslator::VariableMap* vertex_varyings = |
| 1106 &(attached_shaders_[0]->varying_map()); | 1113 &(attached_shaders_[0]->varying_map()); |
| 1107 const ShaderTranslator::VariableMap* fragment_varyings = | 1114 const ShaderTranslator::VariableMap* fragment_varyings = |
| 1108 &(attached_shaders_[1]->varying_map()); | 1115 &(attached_shaders_[1]->varying_map()); |
| 1109 | 1116 |
| 1110 std::map<std::string, ShVariableInfo> combined_map; | 1117 std::map<std::string, ShVariableInfo> combined_map; |
| 1111 | 1118 |
| 1112 for (ShaderTranslator::VariableMap::const_iterator iter = | 1119 for (ShaderTranslator::VariableMap::const_iterator iter = |
| 1113 fragment_varyings->begin(); | 1120 fragment_varyings->begin(); |
| 1114 iter != fragment_varyings->end(); ++iter) { | 1121 iter != fragment_varyings->end(); ++iter) { |
| 1115 if (!iter->second.static_use) | 1122 if (!iter->second.static_use && option == kCountOnlyStaticallyUsed) |
| 1116 continue; | 1123 continue; |
| 1117 if (!IsBuiltInVarying(iter->first)) { | 1124 if (!IsBuiltInVarying(iter->first)) { |
| 1118 ShaderTranslator::VariableMap::const_iterator vertex_iter = | 1125 ShaderTranslator::VariableMap::const_iterator vertex_iter = |
| 1119 vertex_varyings->find(iter->first); | 1126 vertex_varyings->find(iter->first); |
| 1120 if (vertex_iter == vertex_varyings->end() || | 1127 if (vertex_iter == vertex_varyings->end() || |
| 1121 !vertex_iter->second.static_use) | 1128 (!vertex_iter->second.static_use && |
| 1129 option == kCountOnlyStaticallyUsed)) | |
| 1122 continue; | 1130 continue; |
| 1123 } | 1131 } |
| 1124 | 1132 |
| 1125 ShVariableInfo var; | 1133 ShVariableInfo var; |
| 1126 var.type = static_cast<ShDataType>(iter->second.type); | 1134 var.type = static_cast<ShDataType>(iter->second.type); |
| 1127 var.size = iter->second.size; | 1135 var.size = iter->second.size; |
| 1128 combined_map[iter->first] = var; | 1136 combined_map[iter->first] = var; |
| 1129 } | 1137 } |
| 1130 | 1138 |
| 1131 if (combined_map.size() == 0) | 1139 if (combined_map.size() == 0) |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 DCHECK(program); | 1368 DCHECK(program); |
| 1361 program->ClearUniforms(&zero_); | 1369 program->ClearUniforms(&zero_); |
| 1362 } | 1370 } |
| 1363 | 1371 |
| 1364 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { | 1372 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { |
| 1365 return index + element * 0x10000; | 1373 return index + element * 0x10000; |
| 1366 } | 1374 } |
| 1367 | 1375 |
| 1368 } // namespace gles2 | 1376 } // namespace gles2 |
| 1369 } // namespace gpu | 1377 } // namespace gpu |
| OLD | NEW |