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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 } | 551 } |
552 } | 552 } |
553 | 553 |
554 if (link) { | 554 if (link) { |
555 CompileAttachedShaders(); | 555 CompileAttachedShaders(); |
556 | 556 |
557 if (!CanLink()) { | 557 if (!CanLink()) { |
558 set_log_info("invalid shaders"); | 558 set_log_info("invalid shaders"); |
559 return false; | 559 return false; |
560 } | 560 } |
561 if (DetectShaderVersionMismatch()) { | |
562 set_log_info("Versions of linked shaders have to match."); | |
563 return false; | |
564 } | |
561 if (DetectAttribLocationBindingConflicts()) { | 565 if (DetectAttribLocationBindingConflicts()) { |
562 set_log_info("glBindAttribLocation() conflicts"); | 566 set_log_info("glBindAttribLocation() conflicts"); |
563 return false; | 567 return false; |
564 } | 568 } |
565 std::string conflicting_name; | 569 std::string conflicting_name; |
566 if (DetectUniformsMismatch(&conflicting_name)) { | 570 if (DetectUniformsMismatch(&conflicting_name)) { |
567 std::string info_log = "Uniforms with the same name but different " | 571 std::string info_log = "Uniforms with the same name but different " |
568 "type/precision: " + conflicting_name; | 572 "type/precision: " + conflicting_name; |
569 set_log_info(ProcessLogInfo(info_log).c_str()); | 573 set_log_info(ProcessLogInfo(info_log).c_str()); |
570 return false; | 574 return false; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1027 | 1031 |
1028 bool Program::CanLink() const { | 1032 bool Program::CanLink() const { |
1029 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | 1033 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { |
1030 if (!attached_shaders_[ii].get() || !attached_shaders_[ii]->valid()) { | 1034 if (!attached_shaders_[ii].get() || !attached_shaders_[ii]->valid()) { |
1031 return false; | 1035 return false; |
1032 } | 1036 } |
1033 } | 1037 } |
1034 return true; | 1038 return true; |
1035 } | 1039 } |
1036 | 1040 |
1041 bool Program::DetectShaderVersionMismatch() const { | |
1042 int version = Shader::kUndefinedShaderVersion; | |
1043 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | |
1044 Shader* shader = attached_shaders_[ii].get(); | |
1045 if (shader) { | |
1046 if (version != Shader::kUndefinedShaderVersion && | |
1047 shader->shader_version() != version) { | |
1048 return true; | |
Zhenyao Mo
2015/05/06 17:57:42
This is based on the assumption that kMaxAttachedS
oetuaho-nv
2015/05/07 08:02:41
I don't see how this would be based on that assump
Jamie Madill
2015/05/07 11:27:54
Yes, I think it's sufficient to detect any mismatc
Zhenyao Mo
2015/05/07 14:33:08
You are right. I misread the code.
| |
1049 } | |
1050 version = shader->shader_version(); | |
1051 DCHECK(version != Shader::kUndefinedShaderVersion); | |
1052 } | |
1053 } | |
1054 return false; | |
1055 } | |
1056 | |
1037 bool Program::DetectAttribLocationBindingConflicts() const { | 1057 bool Program::DetectAttribLocationBindingConflicts() const { |
1038 std::set<GLint> location_binding_used; | 1058 std::set<GLint> location_binding_used; |
1039 for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); | 1059 for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); |
1040 it != bind_attrib_location_map_.end(); ++it) { | 1060 it != bind_attrib_location_map_.end(); ++it) { |
1041 // Find out if an attribute is statically used in this program's shaders. | 1061 // Find out if an attribute is statically used in this program's shaders. |
1042 const sh::Attribute* attrib = NULL; | 1062 const sh::Attribute* attrib = NULL; |
1043 const std::string* mapped_name = GetAttribMappedName(it->first); | 1063 const std::string* mapped_name = GetAttribMappedName(it->first); |
1044 if (!mapped_name) | 1064 if (!mapped_name) |
1045 continue; | 1065 continue; |
1046 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | 1066 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1745 DCHECK(program); | 1765 DCHECK(program); |
1746 program->ClearUniforms(&zero_); | 1766 program->ClearUniforms(&zero_); |
1747 } | 1767 } |
1748 | 1768 |
1749 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { | 1769 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { |
1750 return index + element * 0x10000; | 1770 return index + element * 0x10000; |
1751 } | 1771 } |
1752 | 1772 |
1753 } // namespace gles2 | 1773 } // namespace gles2 |
1754 } // namespace gpu | 1774 } // namespace gpu |
OLD | NEW |