| OLD | NEW |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 compile_options |= SH_INTERMEDIATE_TREE; | 153 compile_options |= SH_INTERMEDIATE_TREE; |
| 154 | 154 |
| 155 compile_options |= driver_bug_workarounds_; | 155 compile_options |= driver_bug_workarounds_; |
| 156 | 156 |
| 157 return compile_options; | 157 return compile_options; |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool ShaderTranslator::Translate(const std::string& shader_source, | 160 bool ShaderTranslator::Translate(const std::string& shader_source, |
| 161 std::string* info_log, | 161 std::string* info_log, |
| 162 std::string* translated_source, | 162 std::string* translated_source, |
| 163 int* shader_version, |
| 163 AttributeMap* attrib_map, | 164 AttributeMap* attrib_map, |
| 164 UniformMap* uniform_map, | 165 UniformMap* uniform_map, |
| 165 VaryingMap* varying_map, | 166 VaryingMap* varying_map, |
| 166 NameMap* name_map) const { | 167 NameMap* name_map) const { |
| 167 // Make sure this instance is initialized. | 168 // Make sure this instance is initialized. |
| 168 DCHECK(compiler_ != NULL); | 169 DCHECK(compiler_ != NULL); |
| 169 | 170 |
| 170 bool success = false; | 171 bool success = false; |
| 171 { | 172 { |
| 172 TRACE_EVENT0("gpu", "ShCompile"); | 173 TRACE_EVENT0("gpu", "ShCompile"); |
| 173 const char* const shader_strings[] = { shader_source.c_str() }; | 174 const char* const shader_strings[] = { shader_source.c_str() }; |
| 174 success = ShCompile( | 175 success = ShCompile( |
| 175 compiler_, shader_strings, 1, GetCompileOptions()); | 176 compiler_, shader_strings, 1, GetCompileOptions()); |
| 176 } | 177 } |
| 177 if (success) { | 178 if (success) { |
| 178 // Get translated shader. | 179 // Get translated shader. |
| 179 if (translated_source) { | 180 if (translated_source) { |
| 180 *translated_source = ShGetObjectCode(compiler_); | 181 *translated_source = ShGetObjectCode(compiler_); |
| 181 } | 182 } |
| 183 // Get shader version. |
| 184 *shader_version = ShGetShaderVersion(compiler_); |
| 182 // Get info for attribs, uniforms, and varyings. | 185 // Get info for attribs, uniforms, and varyings. |
| 183 GetAttributes(compiler_, attrib_map); | 186 GetAttributes(compiler_, attrib_map); |
| 184 GetUniforms(compiler_, uniform_map); | 187 GetUniforms(compiler_, uniform_map); |
| 185 GetVaryings(compiler_, varying_map); | 188 GetVaryings(compiler_, varying_map); |
| 186 // Get info for name hashing. | 189 // Get info for name hashing. |
| 187 GetNameHashingInfo(compiler_, name_map); | 190 GetNameHashingInfo(compiler_, name_map); |
| 188 } | 191 } |
| 189 | 192 |
| 190 // Get info log. | 193 // Get info log. |
| 191 if (info_log) { | 194 if (info_log) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 218 destruction_observers_, | 221 destruction_observers_, |
| 219 OnDestruct(this)); | 222 OnDestruct(this)); |
| 220 | 223 |
| 221 if (compiler_ != NULL) | 224 if (compiler_ != NULL) |
| 222 ShDestruct(compiler_); | 225 ShDestruct(compiler_); |
| 223 } | 226 } |
| 224 | 227 |
| 225 } // namespace gles2 | 228 } // namespace gles2 |
| 226 } // namespace gpu | 229 } // namespace gpu |
| 227 | 230 |
| OLD | NEW |