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/shader_manager.cc

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: rebase Created 5 years 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
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/shader_manager.h" 5 #include "gpu/command_buffer/service/shader_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Signify the shader has been compiled, whether or not it is valid 62 // Signify the shader has been compiled, whether or not it is valid
63 // is dependent on the |valid_| member variable. 63 // is dependent on the |valid_| member variable.
64 shader_state_ = kShaderStateCompiled; 64 shader_state_ = kShaderStateCompiled;
65 valid_ = false; 65 valid_ = false;
66 66
67 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to 67 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to
68 // glShaderSource and then glCompileShader. 68 // glShaderSource and then glCompileShader.
69 const char* source_for_driver = last_compiled_source_.c_str(); 69 const char* source_for_driver = last_compiled_source_.c_str();
70 ShaderTranslatorInterface* translator = translator_.get(); 70 ShaderTranslatorInterface* translator = translator_.get();
71 if (translator) { 71 if (translator) {
72 bool success = translator->Translate(last_compiled_source_, 72 bool success = translator->Translate(
73 &log_info_, 73 last_compiled_source_, &log_info_, &translated_source_,
74 &translated_source_, 74 &shader_version_, &attrib_map_, &uniform_map_, &varying_map_,
75 &shader_version_, 75 &interface_block_map_, &output_variable_list_, &name_map_);
76 &attrib_map_,
77 &uniform_map_,
78 &varying_map_,
79 &interface_block_map_,
80 &name_map_);
81 if (!success) { 76 if (!success) {
82 return; 77 return;
83 } 78 }
84 source_for_driver = translated_source_.c_str(); 79 source_for_driver = translated_source_.c_str();
85 } 80 }
86 81
87 glShaderSource(service_id_, 1, &source_for_driver, NULL); 82 glShaderSource(service_id_, 1, &source_for_driver, NULL);
88 glCompileShader(service_id_); 83 glCompileShader(service_id_);
89 84
90 if (source_type_ == kANGLE) { 85 if (source_type_ == kANGLE) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 203
209 const std::string* Shader::GetInterfaceBlockMappedName( 204 const std::string* Shader::GetInterfaceBlockMappedName(
210 const std::string& original_name) const { 205 const std::string& original_name) const {
211 for (const auto& key_value : interface_block_map_) { 206 for (const auto& key_value : interface_block_map_) {
212 if (key_value.second.name == original_name) 207 if (key_value.second.name == original_name)
213 return &(key_value.first); 208 return &(key_value.first);
214 } 209 }
215 return NULL; 210 return NULL;
216 } 211 }
217 212
213 const std::string* Shader::GetOutputVariableMappedName(
214 const std::string& original_name) const {
215 for (const auto& value : output_variable_list_) {
216 if (value.name == original_name)
217 return &value.mappedName;
218 }
219 return nullptr;
220 }
221
218 const std::string* Shader::GetOriginalNameFromHashedName( 222 const std::string* Shader::GetOriginalNameFromHashedName(
219 const std::string& hashed_name) const { 223 const std::string& hashed_name) const {
220 NameMap::const_iterator it = name_map_.find(hashed_name); 224 NameMap::const_iterator it = name_map_.find(hashed_name);
221 if (it != name_map_.end()) 225 if (it != name_map_.end())
222 return &(it->second); 226 return &(it->second);
223 return NULL; 227 return NULL;
224 } 228 }
225 229
226 const std::string* Shader::GetMappedName( 230 const std::string* Shader::GetMappedName(
227 const std::string& original_name) const { 231 const std::string& original_name) const {
(...skipping 14 matching lines...) Expand all
242 return it != varying_map_.end() ? &it->second : NULL; 246 return it != varying_map_.end() ? &it->second : NULL;
243 } 247 }
244 248
245 const sh::InterfaceBlock* Shader::GetInterfaceBlockInfo( 249 const sh::InterfaceBlock* Shader::GetInterfaceBlockInfo(
246 const std::string& name) const { 250 const std::string& name) const {
247 InterfaceBlockMap::const_iterator it = 251 InterfaceBlockMap::const_iterator it =
248 interface_block_map_.find(GetTopVariableName(name)); 252 interface_block_map_.find(GetTopVariableName(name));
249 return it != interface_block_map_.end() ? &it->second : NULL; 253 return it != interface_block_map_.end() ? &it->second : NULL;
250 } 254 }
251 255
256 const sh::OutputVariable* Shader::GetOutputVariableInfo(
257 const std::string& name) const {
258 std::string mapped_name = GetTopVariableName(name);
259 // Number of output variables is expected to be so low that
260 // a linear search of a list should be faster than using a map.
261 for (const auto& value : output_variable_list_) {
262 if (value.mappedName == mapped_name)
263 return &value;
264 }
265 return nullptr;
266 }
267
252 ShaderManager::ShaderManager() {} 268 ShaderManager::ShaderManager() {}
253 269
254 ShaderManager::~ShaderManager() { 270 ShaderManager::~ShaderManager() {
255 DCHECK(shaders_.empty()); 271 DCHECK(shaders_.empty());
256 } 272 }
257 273
258 void ShaderManager::Destroy(bool have_context) { 274 void ShaderManager::Destroy(bool have_context) {
259 while (!shaders_.empty()) { 275 while (!shaders_.empty()) {
260 if (have_context) { 276 if (have_context) {
261 Shader* shader = shaders_.begin()->second.get(); 277 Shader* shader = shaders_.begin()->second.get();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 350
335 void ShaderManager::UnuseShader(Shader* shader) { 351 void ShaderManager::UnuseShader(Shader* shader) {
336 DCHECK(shader); 352 DCHECK(shader);
337 DCHECK(IsOwned(shader)); 353 DCHECK(IsOwned(shader));
338 shader->DecUseCount(); 354 shader->DecUseCount();
339 RemoveShader(shader); 355 RemoveShader(shader);
340 } 356 }
341 357
342 } // namespace gles2 358 } // namespace gles2
343 } // namespace gpu 359 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_manager.h ('k') | gpu/command_buffer/service/shader_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698