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 <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 using gpu::gles2::ShaderTranslator; | 17 using gpu::gles2::ShaderTranslator; |
18 | 18 |
| 19 static bool g_shader_initalized = false; |
| 20 |
19 void FinalizeShaderTranslator(void* /* dummy */) { | 21 void FinalizeShaderTranslator(void* /* dummy */) { |
20 TRACE_EVENT0("gpu", "ShFinalize"); | 22 TRACE_EVENT0("gpu", "ShFinalize"); |
21 ShFinalize(); | 23 ShFinalize(); |
| 24 DCHECK(g_shader_initalized); |
| 25 g_shader_initalized = false; |
22 } | 26 } |
23 | 27 |
24 bool InitializeShaderTranslator() { | 28 bool InitializeShaderTranslator() { |
25 static bool initialized = false; | 29 if (!g_shader_initalized) { |
26 if (!initialized) { | |
27 TRACE_EVENT0("gpu", "ShInitialize"); | 30 TRACE_EVENT0("gpu", "ShInitialize"); |
28 CHECK(ShInitialize()); | 31 CHECK(ShInitialize()); |
29 base::AtExitManager::RegisterCallback(&FinalizeShaderTranslator, NULL); | 32 base::AtExitManager::RegisterCallback(&FinalizeShaderTranslator, NULL); |
30 initialized = true; | 33 g_shader_initalized = true; |
31 } | 34 } |
32 return initialized; | 35 return g_shader_initalized; |
33 } | 36 } |
34 | 37 |
35 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | 38 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 |
36 typedef int ANGLEGetInfoType; | 39 typedef int ANGLEGetInfoType; |
37 #else | 40 #else |
38 typedef size_t ANGLEGetInfoType; | 41 typedef size_t ANGLEGetInfoType; |
39 #endif | 42 #endif |
40 | 43 |
41 void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type, | 44 void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type, |
42 ShaderTranslator::VariableMap* var_map) { | 45 ShaderTranslator::VariableMap* var_map) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 translated_shader_.reset(); | 312 translated_shader_.reset(); |
310 info_log_.reset(); | 313 info_log_.reset(); |
311 attrib_map_.clear(); | 314 attrib_map_.clear(); |
312 uniform_map_.clear(); | 315 uniform_map_.clear(); |
313 name_map_.clear(); | 316 name_map_.clear(); |
314 } | 317 } |
315 | 318 |
316 } // namespace gles2 | 319 } // namespace gles2 |
317 } // namespace gpu | 320 } // namespace gpu |
318 | 321 |
OLD | NEW |