| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ShCompileOptions driver_bug_workarounds) { | 110 ShCompileOptions driver_bug_workarounds) { |
| 111 // Make sure Init is called only once. | 111 // Make sure Init is called only once. |
| 112 DCHECK(compiler_ == NULL); | 112 DCHECK(compiler_ == NULL); |
| 113 DCHECK(shader_type == GL_FRAGMENT_SHADER || shader_type == GL_VERTEX_SHADER); | 113 DCHECK(shader_type == GL_FRAGMENT_SHADER || shader_type == GL_VERTEX_SHADER); |
| 114 DCHECK(shader_spec == SH_GLES2_SPEC || shader_spec == SH_WEBGL_SPEC || | 114 DCHECK(shader_spec == SH_GLES2_SPEC || shader_spec == SH_WEBGL_SPEC || |
| 115 shader_spec == SH_GLES3_SPEC || shader_spec == SH_WEBGL2_SPEC); | 115 shader_spec == SH_GLES3_SPEC || shader_spec == SH_WEBGL2_SPEC); |
| 116 DCHECK(resources != NULL); | 116 DCHECK(resources != NULL); |
| 117 | 117 |
| 118 g_translator_initializer.Get(); | 118 g_translator_initializer.Get(); |
| 119 | 119 |
| 120 ShShaderOutput shader_output = SH_ESSL_OUTPUT; | 120 ShShaderOutput shader_output; |
| 121 switch (glsl_implementation_type) { | 121 if (glsl_implementation_type == kGlslES) { |
| 122 case kGlsl: | 122 shader_output = SH_ESSL_OUTPUT; |
| 123 } else { |
| 124 // TODO(kbr): clean up the tests of shader_spec and |
| 125 // gfx::GetGLImplementation(). crbug.com/471960 |
| 126 if (shader_spec == SH_WEBGL2_SPEC || |
| 127 gfx::GetGLImplementation() == |
| 128 gfx::kGLImplementationDesktopGLCoreProfile) { |
| 129 shader_output = SH_GLSL_CORE_OUTPUT; |
| 130 } else { |
| 123 shader_output = SH_GLSL_COMPATIBILITY_OUTPUT; | 131 shader_output = SH_GLSL_COMPATIBILITY_OUTPUT; |
| 124 break; | 132 } |
| 125 case kGlslCoreProfile: | |
| 126 shader_output = SH_GLSL_CORE_OUTPUT; | |
| 127 break; | |
| 128 case kGlslES: | |
| 129 // Handled in initialization above. | |
| 130 break; | |
| 131 default: | |
| 132 NOTREACHED(); | |
| 133 break; | |
| 134 } | 133 } |
| 135 | 134 |
| 136 { | 135 { |
| 137 TRACE_EVENT0("gpu", "ShConstructCompiler"); | 136 TRACE_EVENT0("gpu", "ShConstructCompiler"); |
| 138 compiler_ = ShConstructCompiler( | 137 compiler_ = ShConstructCompiler( |
| 139 shader_type, shader_spec, shader_output, resources); | 138 shader_type, shader_spec, shader_output, resources); |
| 140 } | 139 } |
| 141 implementation_is_glsl_es_ = (glsl_implementation_type == kGlslES); | 140 implementation_is_glsl_es_ = (glsl_implementation_type == kGlslES); |
| 142 driver_bug_workarounds_ = driver_bug_workarounds; | 141 driver_bug_workarounds_ = driver_bug_workarounds; |
| 143 return compiler_ != NULL; | 142 return compiler_ != NULL; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 destruction_observers_, | 218 destruction_observers_, |
| 220 OnDestruct(this)); | 219 OnDestruct(this)); |
| 221 | 220 |
| 222 if (compiler_ != NULL) | 221 if (compiler_ != NULL) |
| 223 ShDestruct(compiler_); | 222 ShDestruct(compiler_); |
| 224 } | 223 } |
| 225 | 224 |
| 226 } // namespace gles2 | 225 } // namespace gles2 |
| 227 } // namespace gpu | 226 } // namespace gpu |
| 228 | 227 |
| OLD | NEW |