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

Side by Side Diff: gpu/command_buffer/service/shader_translator.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_translator.h" 5 #include "gpu/command_buffer/service/shader_translator.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <GLES2/gl2.h> 8 #include <GLES2/gl2.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void GetVaryings(ShHandle compiler, VaryingMap* var_map) { 64 void GetVaryings(ShHandle compiler, VaryingMap* var_map) {
65 if (!var_map) 65 if (!var_map)
66 return; 66 return;
67 var_map->clear(); 67 var_map->clear();
68 const std::vector<sh::Varying>* varyings = ShGetVaryings(compiler); 68 const std::vector<sh::Varying>* varyings = ShGetVaryings(compiler);
69 if (varyings) { 69 if (varyings) {
70 for (size_t ii = 0; ii < varyings->size(); ++ii) 70 for (size_t ii = 0; ii < varyings->size(); ++ii)
71 (*var_map)[(*varyings)[ii].mappedName] = (*varyings)[ii]; 71 (*var_map)[(*varyings)[ii].mappedName] = (*varyings)[ii];
72 } 72 }
73 } 73 }
74 void GetOutputVariables(ShHandle compiler, OutputVariableList* var_list) {
75 if (!var_list)
76 return;
77 *var_list = *ShGetOutputVariables(compiler);
78 }
74 79
75 void GetInterfaceBlocks(ShHandle compiler, InterfaceBlockMap* var_map) { 80 void GetInterfaceBlocks(ShHandle compiler, InterfaceBlockMap* var_map) {
76 if (!var_map) 81 if (!var_map)
77 return; 82 return;
78 var_map->clear(); 83 var_map->clear();
79 const std::vector<sh::InterfaceBlock>* interface_blocks = 84 const std::vector<sh::InterfaceBlock>* interface_blocks =
80 ShGetInterfaceBlocks(compiler); 85 ShGetInterfaceBlocks(compiler);
81 if (interface_blocks) { 86 if (interface_blocks) {
82 for (const auto& block : *interface_blocks) { 87 for (const auto& block : *interface_blocks) {
83 (*var_map)[block.mappedName] = block; 88 (*var_map)[block.mappedName] = block;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 204 }
200 205
201 bool ShaderTranslator::Translate(const std::string& shader_source, 206 bool ShaderTranslator::Translate(const std::string& shader_source,
202 std::string* info_log, 207 std::string* info_log,
203 std::string* translated_source, 208 std::string* translated_source,
204 int* shader_version, 209 int* shader_version,
205 AttributeMap* attrib_map, 210 AttributeMap* attrib_map,
206 UniformMap* uniform_map, 211 UniformMap* uniform_map,
207 VaryingMap* varying_map, 212 VaryingMap* varying_map,
208 InterfaceBlockMap* interface_block_map, 213 InterfaceBlockMap* interface_block_map,
214 OutputVariableList* output_variable_list,
209 NameMap* name_map) const { 215 NameMap* name_map) const {
210 // Make sure this instance is initialized. 216 // Make sure this instance is initialized.
211 DCHECK(compiler_ != NULL); 217 DCHECK(compiler_ != NULL);
212 218
213 bool success = false; 219 bool success = false;
214 { 220 {
215 TRACE_EVENT0("gpu", "ShCompile"); 221 TRACE_EVENT0("gpu", "ShCompile");
216 const char* const shader_strings[] = { shader_source.c_str() }; 222 const char* const shader_strings[] = { shader_source.c_str() };
217 success = ShCompile( 223 success = ShCompile(
218 compiler_, shader_strings, 1, GetCompileOptions()); 224 compiler_, shader_strings, 1, GetCompileOptions());
219 } 225 }
220 if (success) { 226 if (success) {
221 // Get translated shader. 227 // Get translated shader.
222 if (translated_source) { 228 if (translated_source) {
223 *translated_source = ShGetObjectCode(compiler_); 229 *translated_source = ShGetObjectCode(compiler_);
224 } 230 }
225 // Get shader version. 231 // Get shader version.
226 *shader_version = ShGetShaderVersion(compiler_); 232 *shader_version = ShGetShaderVersion(compiler_);
227 // Get info for attribs, uniforms, and varyings. 233 // Get info for attribs, uniforms, varyings and output variables.
228 GetAttributes(compiler_, attrib_map); 234 GetAttributes(compiler_, attrib_map);
229 GetUniforms(compiler_, uniform_map); 235 GetUniforms(compiler_, uniform_map);
230 GetVaryings(compiler_, varying_map); 236 GetVaryings(compiler_, varying_map);
231 GetInterfaceBlocks(compiler_, interface_block_map); 237 GetInterfaceBlocks(compiler_, interface_block_map);
238 GetOutputVariables(compiler_, output_variable_list);
232 // Get info for name hashing. 239 // Get info for name hashing.
233 GetNameHashingInfo(compiler_, name_map); 240 GetNameHashingInfo(compiler_, name_map);
234 } 241 }
235 242
236 // Get info log. 243 // Get info log.
237 if (info_log) { 244 if (info_log) {
238 *info_log = ShGetInfoLog(compiler_); 245 *info_log = ShGetInfoLog(compiler_);
239 } 246 }
240 247
241 // We don't need results in the compiler anymore. 248 // We don't need results in the compiler anymore.
(...skipping 25 matching lines...) Expand all
267 destruction_observers_, 274 destruction_observers_,
268 OnDestruct(this)); 275 OnDestruct(this));
269 276
270 if (compiler_ != NULL) 277 if (compiler_ != NULL)
271 ShDestruct(compiler_); 278 ShDestruct(compiler_);
272 } 279 }
273 280
274 } // namespace gles2 281 } // namespace gles2
275 } // namespace gpu 282 } // namespace gpu
276 283
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_translator.h ('k') | gpu/command_buffer/service/shader_translator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698