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

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: 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_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, AttributeList* var_list) {
75 if (!var_list)
76 return;
77 *var_list = *ShGetOutputVariables(compiler);
78 }
74 79
75 void GetNameHashingInfo(ShHandle compiler, NameMap* name_map) { 80 void GetNameHashingInfo(ShHandle compiler, NameMap* name_map) {
76 if (!name_map) 81 if (!name_map)
77 return; 82 return;
78 name_map->clear(); 83 name_map->clear();
79 84
80 typedef std::map<std::string, std::string> NameMapANGLE; 85 typedef std::map<std::string, std::string> NameMapANGLE;
81 const NameMapANGLE* angle_map = ShGetNameHashingMap(compiler); 86 const NameMapANGLE* angle_map = ShGetNameHashingMap(compiler);
82 DCHECK(angle_map); 87 DCHECK(angle_map);
83 88
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ShCompileOptions driver_bug_workarounds) { 158 ShCompileOptions driver_bug_workarounds) {
154 // Make sure Init is called only once. 159 // Make sure Init is called only once.
155 DCHECK(compiler_ == NULL); 160 DCHECK(compiler_ == NULL);
156 DCHECK(shader_type == GL_FRAGMENT_SHADER || shader_type == GL_VERTEX_SHADER); 161 DCHECK(shader_type == GL_FRAGMENT_SHADER || shader_type == GL_VERTEX_SHADER);
157 DCHECK(shader_spec == SH_GLES2_SPEC || shader_spec == SH_WEBGL_SPEC || 162 DCHECK(shader_spec == SH_GLES2_SPEC || shader_spec == SH_WEBGL_SPEC ||
158 shader_spec == SH_GLES3_SPEC || shader_spec == SH_WEBGL2_SPEC); 163 shader_spec == SH_GLES3_SPEC || shader_spec == SH_WEBGL2_SPEC);
159 DCHECK(resources != NULL); 164 DCHECK(resources != NULL);
160 165
161 g_translator_initializer.Get(); 166 g_translator_initializer.Get();
162 167
163
164 { 168 {
165 TRACE_EVENT0("gpu", "ShConstructCompiler"); 169 TRACE_EVENT0("gpu", "ShConstructCompiler");
166 compiler_ = ShConstructCompiler(shader_type, shader_spec, 170 compiler_ = ShConstructCompiler(shader_type, shader_spec,
167 shader_output_language, resources); 171 shader_output_language, resources);
168 } 172 }
169 driver_bug_workarounds_ = driver_bug_workarounds; 173 driver_bug_workarounds_ = driver_bug_workarounds;
170 return compiler_ != NULL; 174 return compiler_ != NULL;
171 } 175 }
172 176
173 int ShaderTranslator::GetCompileOptions() const { 177 int ShaderTranslator::GetCompileOptions() const {
(...skipping 11 matching lines...) Expand all
185 return compile_options; 189 return compile_options;
186 } 190 }
187 191
188 bool ShaderTranslator::Translate(const std::string& shader_source, 192 bool ShaderTranslator::Translate(const std::string& shader_source,
189 std::string* info_log, 193 std::string* info_log,
190 std::string* translated_source, 194 std::string* translated_source,
191 int* shader_version, 195 int* shader_version,
192 AttributeMap* attrib_map, 196 AttributeMap* attrib_map,
193 UniformMap* uniform_map, 197 UniformMap* uniform_map,
194 VaryingMap* varying_map, 198 VaryingMap* varying_map,
199 AttributeList* output_variable_list,
195 NameMap* name_map) const { 200 NameMap* name_map) const {
196 // Make sure this instance is initialized. 201 // Make sure this instance is initialized.
197 DCHECK(compiler_ != NULL); 202 DCHECK(compiler_ != NULL);
198 203
199 bool success = false; 204 bool success = false;
200 { 205 {
201 TRACE_EVENT0("gpu", "ShCompile"); 206 TRACE_EVENT0("gpu", "ShCompile");
202 const char* const shader_strings[] = { shader_source.c_str() }; 207 const char* const shader_strings[] = { shader_source.c_str() };
203 success = ShCompile( 208 success = ShCompile(
204 compiler_, shader_strings, 1, GetCompileOptions()); 209 compiler_, shader_strings, 1, GetCompileOptions());
205 } 210 }
206 if (success) { 211 if (success) {
207 // Get translated shader. 212 // Get translated shader.
208 if (translated_source) { 213 if (translated_source) {
209 *translated_source = ShGetObjectCode(compiler_); 214 *translated_source = ShGetObjectCode(compiler_);
210 } 215 }
211 // Get shader version. 216 // Get shader version.
212 *shader_version = ShGetShaderVersion(compiler_); 217 *shader_version = ShGetShaderVersion(compiler_);
213 // Get info for attribs, uniforms, and varyings. 218 // Get info for attribs, uniforms, varyings and output variables.
214 GetAttributes(compiler_, attrib_map); 219 GetAttributes(compiler_, attrib_map);
215 GetUniforms(compiler_, uniform_map); 220 GetUniforms(compiler_, uniform_map);
216 GetVaryings(compiler_, varying_map); 221 GetVaryings(compiler_, varying_map);
222 GetOutputVariables(compiler_, output_variable_list);
217 // Get info for name hashing. 223 // Get info for name hashing.
218 GetNameHashingInfo(compiler_, name_map); 224 GetNameHashingInfo(compiler_, name_map);
219 } 225 }
220 226
221 // Get info log. 227 // Get info log.
222 if (info_log) { 228 if (info_log) {
223 *info_log = ShGetInfoLog(compiler_); 229 *info_log = ShGetInfoLog(compiler_);
224 } 230 }
225 231
226 // We don't need results in the compiler anymore. 232 // We don't need results in the compiler anymore.
(...skipping 25 matching lines...) Expand all
252 destruction_observers_, 258 destruction_observers_,
253 OnDestruct(this)); 259 OnDestruct(this));
254 260
255 if (compiler_ != NULL) 261 if (compiler_ != NULL)
256 ShDestruct(compiler_); 262 ShDestruct(compiler_);
257 } 263 }
258 264
259 } // namespace gles2 265 } // namespace gles2
260 } // namespace gpu 266 } // namespace gpu
261 267
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698