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