| 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 |
| 11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
| 12 #include "base/command_line.h" |
| 12 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "ui/gl/gl_switches.h" |
| 16 | 18 |
| 17 namespace gpu { | 19 namespace gpu { |
| 18 namespace gles2 { | 20 namespace gles2 { |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 class ShaderTranslatorInitializer { | 24 class ShaderTranslatorInitializer { |
| 23 public: | 25 public: |
| 24 ShaderTranslatorInitializer() { | 26 ShaderTranslatorInitializer() { |
| 25 TRACE_EVENT0("gpu", "ShInitialize"); | 27 TRACE_EVENT0("gpu", "ShInitialize"); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 driver_bug_workarounds_ = driver_bug_workarounds; | 128 driver_bug_workarounds_ = driver_bug_workarounds; |
| 127 return compiler_ != NULL; | 129 return compiler_ != NULL; |
| 128 } | 130 } |
| 129 | 131 |
| 130 int ShaderTranslator::GetCompileOptions() const { | 132 int ShaderTranslator::GetCompileOptions() const { |
| 131 int compile_options = | 133 int compile_options = |
| 132 SH_OBJECT_CODE | SH_VARIABLES | SH_ENFORCE_PACKING_RESTRICTIONS | | 134 SH_OBJECT_CODE | SH_VARIABLES | SH_ENFORCE_PACKING_RESTRICTIONS | |
| 133 SH_LIMIT_EXPRESSION_COMPLEXITY | SH_LIMIT_CALL_STACK_DEPTH | | 135 SH_LIMIT_EXPRESSION_COMPLEXITY | SH_LIMIT_CALL_STACK_DEPTH | |
| 134 SH_CLAMP_INDIRECT_ARRAY_BOUNDS; | 136 SH_CLAMP_INDIRECT_ARRAY_BOUNDS; |
| 135 | 137 |
| 138 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 139 switches::kGLShaderIntermOutput)) |
| 140 compile_options |= SH_INTERMEDIATE_TREE; |
| 141 |
| 136 compile_options |= driver_bug_workarounds_; | 142 compile_options |= driver_bug_workarounds_; |
| 137 | 143 |
| 138 return compile_options; | 144 return compile_options; |
| 139 } | 145 } |
| 140 | 146 |
| 141 bool ShaderTranslator::Translate(const std::string& shader_source, | 147 bool ShaderTranslator::Translate(const std::string& shader_source, |
| 142 std::string* info_log, | 148 std::string* info_log, |
| 143 std::string* translated_source, | 149 std::string* translated_source, |
| 144 AttributeMap* attrib_map, | 150 AttributeMap* attrib_map, |
| 145 UniformMap* uniform_map, | 151 UniformMap* uniform_map, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 destruction_observers_, | 205 destruction_observers_, |
| 200 OnDestruct(this)); | 206 OnDestruct(this)); |
| 201 | 207 |
| 202 if (compiler_ != NULL) | 208 if (compiler_ != NULL) |
| 203 ShDestruct(compiler_); | 209 ShDestruct(compiler_); |
| 204 } | 210 } |
| 205 | 211 |
| 206 } // namespace gles2 | 212 } // namespace gles2 |
| 207 } // namespace gpu | 213 } // namespace gpu |
| 208 | 214 |
| OLD | NEW |