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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 << "unless the driver is buggy:" | 515 << "unless the driver is buggy:" |
516 << "\n--original-shader--\n" << (source ? *source : std::string()) | 516 << "\n--original-shader--\n" << (source ? *source : std::string()) |
517 << "\n--translated-shader--\n" << shader_src << "\n--info-log--\n" | 517 << "\n--translated-shader--\n" << shader_src << "\n--info-log--\n" |
518 << *shader->log_info(); | 518 << *shader->log_info(); |
519 } | 519 } |
520 } | 520 } |
521 | 521 |
522 bool Program::Link(ShaderManager* manager, | 522 bool Program::Link(ShaderManager* manager, |
523 ShaderTranslator* vertex_translator, | 523 ShaderTranslator* vertex_translator, |
524 ShaderTranslator* fragment_translator, | 524 ShaderTranslator* fragment_translator, |
| 525 Program::VaryingsPackingOption varyings_packing_option, |
525 const ShaderCacheCallback& shader_callback) { | 526 const ShaderCacheCallback& shader_callback) { |
526 ClearLinkStatus(); | 527 ClearLinkStatus(); |
527 if (!CanLink()) { | 528 if (!CanLink()) { |
528 set_log_info("missing shaders"); | 529 set_log_info("missing shaders"); |
529 return false; | 530 return false; |
530 } | 531 } |
531 if (DetectAttribLocationBindingConflicts()) { | 532 if (DetectAttribLocationBindingConflicts()) { |
532 set_log_info("glBindAttribLocation() conflicts"); | 533 set_log_info("glBindAttribLocation() conflicts"); |
533 return false; | 534 return false; |
534 } | 535 } |
535 if (DetectUniformsMismatch()) { | 536 if (DetectUniformsMismatch()) { |
536 set_log_info("Uniforms with the same name but different type/precision"); | 537 set_log_info("Uniforms with the same name but different type/precision"); |
537 return false; | 538 return false; |
538 } | 539 } |
539 if (DetectVaryingsMismatch()) { | 540 if (DetectVaryingsMismatch()) { |
540 set_log_info("Varyings with the same name but different type, " | 541 set_log_info("Varyings with the same name but different type, " |
541 "or statically used varyings in fragment shader are not " | 542 "or statically used varyings in fragment shader are not " |
542 "declared in vertex shader"); | 543 "declared in vertex shader"); |
543 return false; | 544 return false; |
544 } | 545 } |
545 if (DetectGlobalNameConflicts()) { | 546 if (DetectGlobalNameConflicts()) { |
546 set_log_info("Name conflicts between an uniform and an attribute"); | 547 set_log_info("Name conflicts between an uniform and an attribute"); |
547 return false; | 548 return false; |
548 } | 549 } |
549 if (!CheckVaryingsPacking()) { | 550 if (!CheckVaryingsPacking(varyings_packing_option)) { |
550 set_log_info("Varyings over maximum register limit"); | 551 set_log_info("Varyings over maximum register limit"); |
551 return false; | 552 return false; |
552 } | 553 } |
553 | 554 |
554 TimeTicks before_time = TimeTicks::HighResNow(); | 555 TimeTicks before_time = TimeTicks::HighResNow(); |
555 bool link = true; | 556 bool link = true; |
556 ProgramCache* cache = manager_->program_cache_; | 557 ProgramCache* cache = manager_->program_cache_; |
557 if (cache) { | 558 if (cache) { |
558 DCHECK(attached_shaders_[0]->signature_source() && | 559 DCHECK(attached_shaders_[0]->signature_source() && |
559 attached_shaders_[1]->signature_source()); | 560 attached_shaders_[1]->signature_source()); |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 for (ShaderTranslator::VariableMap::const_iterator iter = | 1078 for (ShaderTranslator::VariableMap::const_iterator iter = |
1078 attribs->begin(); iter != attribs->end(); ++iter) { | 1079 attribs->begin(); iter != attribs->end(); ++iter) { |
1079 for (int ii = 0; ii < 2; ++ii) { | 1080 for (int ii = 0; ii < 2; ++ii) { |
1080 if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) | 1081 if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) |
1081 return true; | 1082 return true; |
1082 } | 1083 } |
1083 } | 1084 } |
1084 return false; | 1085 return false; |
1085 } | 1086 } |
1086 | 1087 |
1087 bool Program::CheckVaryingsPacking() const { | 1088 bool Program::CheckVaryingsPacking( |
| 1089 Program::VaryingsPackingOption option) const { |
1088 DCHECK(attached_shaders_[0] && | 1090 DCHECK(attached_shaders_[0] && |
1089 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && | 1091 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && |
1090 attached_shaders_[1] && | 1092 attached_shaders_[1] && |
1091 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER); | 1093 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER); |
1092 const ShaderTranslator::VariableMap* vertex_varyings = | 1094 const ShaderTranslator::VariableMap* vertex_varyings = |
1093 &(attached_shaders_[0]->varying_map()); | 1095 &(attached_shaders_[0]->varying_map()); |
1094 const ShaderTranslator::VariableMap* fragment_varyings = | 1096 const ShaderTranslator::VariableMap* fragment_varyings = |
1095 &(attached_shaders_[1]->varying_map()); | 1097 &(attached_shaders_[1]->varying_map()); |
1096 | 1098 |
1097 std::map<std::string, ShVariableInfo> combined_map; | 1099 std::map<std::string, ShVariableInfo> combined_map; |
1098 | 1100 |
1099 for (ShaderTranslator::VariableMap::const_iterator iter = | 1101 for (ShaderTranslator::VariableMap::const_iterator iter = |
1100 fragment_varyings->begin(); | 1102 fragment_varyings->begin(); |
1101 iter != fragment_varyings->end(); ++iter) { | 1103 iter != fragment_varyings->end(); ++iter) { |
1102 if (!iter->second.static_use) | 1104 if (!iter->second.static_use && option == kCountOnlyStaticallyUsed) |
1103 continue; | 1105 continue; |
1104 if (!IsBuiltInVarying(iter->first)) { | 1106 if (!IsBuiltInVarying(iter->first)) { |
1105 ShaderTranslator::VariableMap::const_iterator vertex_iter = | 1107 ShaderTranslator::VariableMap::const_iterator vertex_iter = |
1106 vertex_varyings->find(iter->first); | 1108 vertex_varyings->find(iter->first); |
1107 if (vertex_iter == vertex_varyings->end() || | 1109 if (vertex_iter == vertex_varyings->end() || |
1108 !vertex_iter->second.static_use) | 1110 (!vertex_iter->second.static_use && |
| 1111 option == kCountOnlyStaticallyUsed)) |
1109 continue; | 1112 continue; |
1110 } | 1113 } |
1111 | 1114 |
1112 ShVariableInfo var; | 1115 ShVariableInfo var; |
1113 var.type = static_cast<ShDataType>(iter->second.type); | 1116 var.type = static_cast<ShDataType>(iter->second.type); |
1114 var.size = iter->second.size; | 1117 var.size = iter->second.size; |
1115 combined_map[iter->first] = var; | 1118 combined_map[iter->first] = var; |
1116 } | 1119 } |
1117 | 1120 |
1118 if (combined_map.size() == 0) | 1121 if (combined_map.size() == 0) |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 DCHECK(program); | 1350 DCHECK(program); |
1348 program->ClearUniforms(&zero_); | 1351 program->ClearUniforms(&zero_); |
1349 } | 1352 } |
1350 | 1353 |
1351 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { | 1354 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { |
1352 return index + element * 0x10000; | 1355 return index + element * 0x10000; |
1353 } | 1356 } |
1354 | 1357 |
1355 } // namespace gles2 | 1358 } // namespace gles2 |
1356 } // namespace gpu | 1359 } // namespace gpu |
OLD | NEW |