Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: gpu/command_buffer/service/shader_manager.cc

Issue 2852923004: Remove NameMap from shader translator and shader/program managers (Closed)
Patch Set: remove some TODO(zmo)s Created 3 years, 7 months 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 valid_ = false; 68 valid_ = false;
69 69
70 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to 70 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to
71 // glShaderSource and then glCompileShader. 71 // glShaderSource and then glCompileShader.
72 const char* source_for_driver = last_compiled_source_.c_str(); 72 const char* source_for_driver = last_compiled_source_.c_str();
73 ShaderTranslatorInterface* translator = translator_.get(); 73 ShaderTranslatorInterface* translator = translator_.get();
74 if (translator) { 74 if (translator) {
75 bool success = translator->Translate( 75 bool success = translator->Translate(
76 last_compiled_source_, &log_info_, &translated_source_, 76 last_compiled_source_, &log_info_, &translated_source_,
77 &shader_version_, &attrib_map_, &uniform_map_, &varying_map_, 77 &shader_version_, &attrib_map_, &uniform_map_, &varying_map_,
78 &interface_block_map_, &output_variable_list_, &name_map_); 78 &interface_block_map_, &output_variable_list_);
79 if (!success) { 79 if (!success) {
80 return; 80 return;
81 } 81 }
82 source_for_driver = translated_source_.c_str(); 82 source_for_driver = translated_source_.c_str();
83 } 83 }
84 84
85 glShaderSource(service_id_, 1, &source_for_driver, NULL); 85 glShaderSource(service_id_, 1, &source_for_driver, NULL);
86 glCompileShader(service_id_); 86 glCompileShader(service_id_);
87 87
88 if (source_type_ == kANGLE) { 88 if (source_type_ == kANGLE) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 const std::string& original_name) const { 217 const std::string& original_name) const {
218 for (const auto& value : output_variable_list_) { 218 for (const auto& value : output_variable_list_) {
219 if (value.name == original_name) 219 if (value.name == original_name)
220 return &value.mappedName; 220 return &value.mappedName;
221 } 221 }
222 return nullptr; 222 return nullptr;
223 } 223 }
224 224
225 const std::string* Shader::GetOriginalNameFromHashedName( 225 const std::string* Shader::GetOriginalNameFromHashedName(
226 const std::string& hashed_name) const { 226 const std::string& hashed_name) const {
227 NameMap::const_iterator it = name_map_.find(hashed_name); 227 if (const auto* info = GetAttribInfo(hashed_name)) {
228 if (it != name_map_.end()) 228 return &info->name;
229 return &(it->second);
230 return NULL;
231 }
232
233 const std::string* Shader::GetMappedName(
234 const std::string& original_name) const {
235 for (const auto& key_value : name_map_) {
236 if (key_value.second == original_name)
237 return &(key_value.first);
238 } 229 }
239 return NULL; 230 if (const auto* info = GetUniformInfo(hashed_name)) {
231 return &info->name;
232 }
233 if (const auto* info = GetVaryingInfo(hashed_name)) {
234 return &info->name;
235 }
236 if (const auto* info = GetInterfaceBlockInfo(hashed_name)) {
237 return &info->name;
238 }
239 if (const auto* info = GetOutputVariableInfo(hashed_name)) {
240 return &info->name;
241 }
242 return nullptr;
240 } 243 }
241 244
242 const sh::Uniform* Shader::GetUniformInfo(const std::string& name) const { 245 const sh::Uniform* Shader::GetUniformInfo(const std::string& name) const {
243 UniformMap::const_iterator it = uniform_map_.find(GetTopVariableName(name)); 246 UniformMap::const_iterator it = uniform_map_.find(GetTopVariableName(name));
244 return it != uniform_map_.end() ? &it->second : NULL; 247 return it != uniform_map_.end() ? &it->second : NULL;
245 } 248 }
246 249
247 const sh::Varying* Shader::GetVaryingInfo(const std::string& name) const { 250 const sh::Varying* Shader::GetVaryingInfo(const std::string& name) const {
248 VaryingMap::const_iterator it = varying_map_.find(GetTopVariableName(name)); 251 VaryingMap::const_iterator it = varying_map_.find(GetTopVariableName(name));
249 return it != varying_map_.end() ? &it->second : NULL; 252 return it != varying_map_.end() ? &it->second : NULL;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 359
357 void ShaderManager::UnuseShader(Shader* shader) { 360 void ShaderManager::UnuseShader(Shader* shader) {
358 DCHECK(shader); 361 DCHECK(shader);
359 DCHECK(IsOwned(shader)); 362 DCHECK(IsOwned(shader));
360 shader->DecUseCount(); 363 shader->DecUseCount();
361 RemoveShader(shader); 364 RemoveShader(shader);
362 } 365 }
363 366
364 } // namespace gles2 367 } // namespace gles2
365 } // namespace gpu 368 } // 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