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/client/program_info_manager.h" | 5 #include "gpu/command_buffer/client/program_info_manager.h" |
6 | 6 |
7 namespace { | 7 namespace { |
8 | 8 |
9 template<typename T> static T LocalGetAs( | 9 template<typename T> static T LocalGetAs( |
10 const std::vector<int8>& data, uint32 offset, size_t size) { | 10 const std::vector<int8>& data, uint32 offset, size_t size) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // See "OpenGL ES 3.0.0, Section 2.11.3 Program Objects." | 153 // See "OpenGL ES 3.0.0, Section 2.11.3 Program Objects." |
154 if (info.name == name || | 154 if (info.name == name || |
155 (info.is_array && | 155 (info.is_array && |
156 info.name.compare(0, info.name.size() - 3, name) == 0)) { | 156 info.name.compare(0, info.name.size() - 3, name) == 0)) { |
157 return ii; | 157 return ii; |
158 } | 158 } |
159 } | 159 } |
160 return GL_INVALID_INDEX; | 160 return GL_INVALID_INDEX; |
161 } | 161 } |
162 | 162 |
| 163 GLint ProgramInfoManager::Program::GetFragDataIndex( |
| 164 const std::string& name) const { |
| 165 auto iter = frag_data_indices_.find(name); |
| 166 if (iter == frag_data_indices_.end()) |
| 167 return -1; |
| 168 return iter->second; |
| 169 } |
| 170 |
| 171 void ProgramInfoManager::Program::CacheFragDataIndex(const std::string& name, |
| 172 GLint index) { |
| 173 frag_data_indices_[name] = index; |
| 174 } |
| 175 |
163 GLint ProgramInfoManager::Program::GetFragDataLocation( | 176 GLint ProgramInfoManager::Program::GetFragDataLocation( |
164 const std::string& name) const { | 177 const std::string& name) const { |
165 base::hash_map<std::string, GLint>::const_iterator iter = | 178 base::hash_map<std::string, GLint>::const_iterator iter = |
166 frag_data_locations_.find(name); | 179 frag_data_locations_.find(name); |
167 if (iter == frag_data_locations_.end()) | 180 if (iter == frag_data_locations_.end()) |
168 return -1; | 181 return -1; |
169 return iter->second; | 182 return iter->second; |
170 } | 183 } |
171 | 184 |
172 void ProgramInfoManager::Program::CacheFragDataLocation( | 185 void ProgramInfoManager::Program::CacheFragDataLocation( |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 { | 731 { |
719 base::AutoLock auto_lock(lock_); | 732 base::AutoLock auto_lock(lock_); |
720 Program* info = GetProgramInfo(gl, program, kES2); | 733 Program* info = GetProgramInfo(gl, program, kES2); |
721 if (info) { | 734 if (info) { |
722 return info->GetUniformLocation(name); | 735 return info->GetUniformLocation(name); |
723 } | 736 } |
724 } | 737 } |
725 return gl->GetUniformLocationHelper(program, name); | 738 return gl->GetUniformLocationHelper(program, name); |
726 } | 739 } |
727 | 740 |
| 741 GLint ProgramInfoManager::GetFragDataIndex(GLES2Implementation* gl, |
| 742 GLuint program, |
| 743 const char* name) { |
| 744 // TODO(zmo): make FragData indexes part of the ProgramInfo that are |
| 745 // fetched from the service side. See crbug.com/452104. |
| 746 { |
| 747 base::AutoLock auto_lock(lock_); |
| 748 Program* info = GetProgramInfo(gl, program, kNone); |
| 749 if (info) { |
| 750 GLint possible_index = info->GetFragDataIndex(name); |
| 751 if (possible_index != -1) |
| 752 return possible_index; |
| 753 } |
| 754 } |
| 755 GLint index = gl->GetFragDataIndexEXTHelper(program, name); |
| 756 if (index != -1) { |
| 757 base::AutoLock auto_lock(lock_); |
| 758 Program* info = GetProgramInfo(gl, program, kNone); |
| 759 if (info) { |
| 760 info->CacheFragDataIndex(name, index); |
| 761 } |
| 762 } |
| 763 return index; |
| 764 } |
| 765 |
728 GLint ProgramInfoManager::GetFragDataLocation( | 766 GLint ProgramInfoManager::GetFragDataLocation( |
729 GLES2Implementation* gl, GLuint program, const char* name) { | 767 GLES2Implementation* gl, GLuint program, const char* name) { |
730 // TODO(zmo): make FragData locations part of the ProgramInfo that are | 768 // TODO(zmo): make FragData locations part of the ProgramInfo that are |
731 // fetched altogether from the service side. See crbug.com/452104. | 769 // fetched altogether from the service side. See crbug.com/452104. |
732 { | 770 { |
733 base::AutoLock auto_lock(lock_); | 771 base::AutoLock auto_lock(lock_); |
734 Program* info = GetProgramInfo(gl, program, kNone); | 772 Program* info = GetProgramInfo(gl, program, kNone); |
735 if (info) { | 773 if (info) { |
736 GLint possible_loc = info->GetFragDataLocation(name); | 774 GLint possible_loc = info->GetFragDataLocation(name); |
737 if (possible_loc != -1) | 775 if (possible_loc != -1) |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 } | 1032 } |
995 return true; | 1033 return true; |
996 } | 1034 } |
997 } | 1035 } |
998 return gl->GetUniformIndicesHelper(program, count, names, indices); | 1036 return gl->GetUniformIndicesHelper(program, count, names, indices); |
999 } | 1037 } |
1000 | 1038 |
1001 } // namespace gles2 | 1039 } // namespace gles2 |
1002 } // namespace gpu | 1040 } // namespace gpu |
1003 | 1041 |
OLD | NEW |