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

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: Created 5 years, 3 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 <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 &output_variable_list_, &name_map_);
76 &attrib_map_,
77 &uniform_map_,
78 &varying_map_,
79 &name_map_);
80 if (!success) { 76 if (!success) {
81 return; 77 return;
82 } 78 }
83 source_for_driver = translated_source_.c_str(); 79 source_for_driver = translated_source_.c_str();
84 } 80 }
85 81
86 glShaderSource(service_id_, 1, &source_for_driver, NULL); 82 glShaderSource(service_id_, 1, &source_for_driver, NULL);
87 glCompileShader(service_id_); 83 glCompileShader(service_id_);
88 if (source_type_ == kANGLE) { 84 if (source_type_ == kANGLE) {
89 GLint max_len = 0; 85 GLint max_len = 0;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 const sh::Uniform* Shader::GetUniformInfo(const std::string& name) const { 190 const sh::Uniform* Shader::GetUniformInfo(const std::string& name) const {
195 UniformMap::const_iterator it = uniform_map_.find(GetTopVariableName(name)); 191 UniformMap::const_iterator it = uniform_map_.find(GetTopVariableName(name));
196 return it != uniform_map_.end() ? &it->second : NULL; 192 return it != uniform_map_.end() ? &it->second : NULL;
197 } 193 }
198 194
199 const sh::Varying* Shader::GetVaryingInfo(const std::string& name) const { 195 const sh::Varying* Shader::GetVaryingInfo(const std::string& name) const {
200 VaryingMap::const_iterator it = varying_map_.find(GetTopVariableName(name)); 196 VaryingMap::const_iterator it = varying_map_.find(GetTopVariableName(name));
201 return it != varying_map_.end() ? &it->second : NULL; 197 return it != varying_map_.end() ? &it->second : NULL;
202 } 198 }
203 199
200 const sh::Attribute* Shader::GetOutputVariableInfo(
201 const std::string& original_name) const {
202 auto iter =
203 std::find_if(output_variable_list_.begin(), output_variable_list_.end(),
204 [original_name](const sh::Attribute& output_var) {
205 return output_var.mappedName == original_name;
Zhenyao Mo 2015/08/31 21:12:31 This looks incorrect. It should be output_var.ori
Kimmo Kinnunen 2015/09/24 13:16:28 Done.
206 });
207 return iter != output_variable_list_.end() ? &(*iter) : nullptr;
208 }
209
204 ShaderManager::ShaderManager() {} 210 ShaderManager::ShaderManager() {}
205 211
206 ShaderManager::~ShaderManager() { 212 ShaderManager::~ShaderManager() {
207 DCHECK(shaders_.empty()); 213 DCHECK(shaders_.empty());
208 } 214 }
209 215
210 void ShaderManager::Destroy(bool have_context) { 216 void ShaderManager::Destroy(bool have_context) {
211 while (!shaders_.empty()) { 217 while (!shaders_.empty()) {
212 if (have_context) { 218 if (have_context) {
213 Shader* shader = shaders_.begin()->second.get(); 219 Shader* shader = shaders_.begin()->second.get();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 292
287 void ShaderManager::UnuseShader(Shader* shader) { 293 void ShaderManager::UnuseShader(Shader* shader) {
288 DCHECK(shader); 294 DCHECK(shader);
289 DCHECK(IsOwned(shader)); 295 DCHECK(IsOwned(shader));
290 shader->DecUseCount(); 296 shader->DecUseCount();
291 RemoveShader(shader); 297 RemoveShader(shader);
292 } 298 }
293 299
294 } // namespace gles2 300 } // namespace gles2
295 } // namespace gpu 301 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698