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/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "gpu/command_buffer/service/gpu_switches.h" | 16 #include "gpu/command_buffer/service/gpu_preferences.h" |
17 #include "gpu/command_buffer/service/texture_definition.h" | 17 #include "gpu/command_buffer/service/texture_definition.h" |
18 #include "gpu/config/gpu_switches.h" | 18 #include "gpu/config/gpu_switches.h" |
19 #include "ui/gl/gl_bindings.h" | 19 #include "ui/gl/gl_bindings.h" |
20 #include "ui/gl/gl_fence.h" | 20 #include "ui/gl/gl_fence.h" |
21 #include "ui/gl/gl_implementation.h" | 21 #include "ui/gl/gl_implementation.h" |
22 #include "ui/gl/gl_switches.h" | 22 #include "ui/gl/gl_switches.h" |
23 #include "ui/gl/gl_version_info.h" | 23 #include "ui/gl/gl_version_info.h" |
24 | 24 |
25 #if !defined(OS_MACOSX) | 25 #if !defined(OS_MACOSX) |
26 #include "ui/gl/gl_fence_egl.h" | 26 #include "ui/gl/gl_fence_egl.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return string_set_; | 76 return string_set_; |
77 } | 77 } |
78 | 78 |
79 private: | 79 private: |
80 std::set<std::string> string_set_; | 80 std::set<std::string> string_set_; |
81 }; | 81 }; |
82 | 82 |
83 // Process a string of wordaround type IDs (seperated by ',') and set up | 83 // Process a string of wordaround type IDs (seperated by ',') and set up |
84 // the corresponding Workaround flags. | 84 // the corresponding Workaround flags. |
85 void StringToWorkarounds( | 85 void StringToWorkarounds( |
86 const std::string& types, FeatureInfo::Workarounds* workarounds) { | 86 const std::set<int>& workaround_set, |
| 87 FeatureInfo::Workarounds* workarounds) { |
87 DCHECK(workarounds); | 88 DCHECK(workarounds); |
88 for (const base::StringPiece& piece : | 89 for (auto number : workaround_set) { |
89 base::SplitStringPiece( | |
90 types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | |
91 int number = 0; | |
92 bool succeed = base::StringToInt(piece, &number); | |
93 DCHECK(succeed); | |
94 switch (number) { | 90 switch (number) { |
95 #define GPU_OP(type, name) \ | 91 #define GPU_OP(type, name) \ |
96 case gpu::type: \ | 92 case gpu::type: \ |
97 workarounds->name = true; \ | 93 workarounds->name = true; \ |
98 break; | 94 break; |
99 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) | 95 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) |
100 #undef GPU_OP | 96 #undef GPU_OP |
101 default: | 97 default: |
102 NOTIMPLEMENTED(); | 98 NOTIMPLEMENTED(); |
103 } | 99 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 195 } |
200 | 196 |
201 FeatureInfo::FeatureInfo(const base::CommandLine& command_line) { | 197 FeatureInfo::FeatureInfo(const base::CommandLine& command_line) { |
202 InitializeBasicState(&command_line); | 198 InitializeBasicState(&command_line); |
203 } | 199 } |
204 | 200 |
205 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { | 201 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { |
206 if (!command_line) | 202 if (!command_line) |
207 return; | 203 return; |
208 | 204 |
209 if (command_line->HasSwitch(switches::kGpuDriverBugWorkarounds)) { | 205 const GpuPreferences* gpu_preferences = GpuPreferences::GetInstance(); |
210 std::string types = command_line->GetSwitchValueASCII( | 206 |
211 switches::kGpuDriverBugWorkarounds); | 207 StringToWorkarounds(gpu_preferences->gpu_driver_bug_workarounds, |
212 StringToWorkarounds(types, &workarounds_); | 208 &workarounds_); |
213 } | |
214 feature_flags_.enable_shader_name_hashing = | 209 feature_flags_.enable_shader_name_hashing = |
215 !command_line->HasSwitch(switches::kDisableShaderNameHashing); | 210 !gpu_preferences->disable_shader_name_hashing; |
216 | 211 |
217 feature_flags_.is_swiftshader = | 212 feature_flags_.is_swiftshader = |
218 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); | 213 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); |
219 | 214 |
220 feature_flags_.enable_subscribe_uniform = | 215 feature_flags_.enable_subscribe_uniform = |
221 command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); | 216 gpu_preferences->enable_subscribe_uniform_extension; |
222 | 217 |
223 enable_unsafe_es3_apis_switch_ = | 218 enable_unsafe_es3_apis_switch_ = gpu_preferences->enable_unsafe_es3_apis; |
224 command_line->HasSwitch(switches::kEnableUnsafeES3APIs); | |
225 | 219 |
226 enable_gl_path_rendering_switch_ = | 220 enable_gl_path_rendering_switch_ = gpu_preferences->enable_gl_path_rendering; |
227 command_line->HasSwitch(switches::kEnableGLPathRendering); | |
228 | 221 |
229 // The shader translator is needed to translate from WebGL-conformant GLES SL | 222 // The shader translator is needed to translate from WebGL-conformant GLES SL |
230 // to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to | 223 // to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to |
231 // target context GLSL, implement emulation of OpenGL ES features on OpenGL, | 224 // target context GLSL, implement emulation of OpenGL ES features on OpenGL, |
232 // etc. | 225 // etc. |
233 // The flag here is for testing only. | 226 // The flag here is for testing only. |
234 disable_shader_translator_ = | 227 disable_shader_translator_ = gpu_preferences->disable_glsl_translator; |
235 command_line->HasSwitch(switches::kDisableGLSLTranslator); | |
236 | 228 |
237 unsafe_es3_apis_enabled_ = false; | 229 unsafe_es3_apis_enabled_ = false; |
238 | 230 |
239 // Default context_type_ to a GLES2 Context. | 231 // Default context_type_ to a GLES2 Context. |
240 context_type_ = CONTEXT_TYPE_OPENGLES2; | 232 context_type_ = CONTEXT_TYPE_OPENGLES2; |
241 | 233 |
242 chromium_color_buffer_float_rgba_available_ = false; | 234 chromium_color_buffer_float_rgba_available_ = false; |
243 chromium_color_buffer_float_rgb_available_ = false; | 235 chromium_color_buffer_float_rgb_available_ = false; |
244 ext_color_buffer_float_available_ = false; | 236 ext_color_buffer_float_available_ = false; |
245 oes_texture_float_linear_available_ = false; | 237 oes_texture_float_linear_available_ = false; |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 if (pos == std::string::npos) { | 1430 if (pos == std::string::npos) { |
1439 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1431 extensions_ += (extensions_.empty() ? "" : " ") + str; |
1440 } | 1432 } |
1441 } | 1433 } |
1442 | 1434 |
1443 FeatureInfo::~FeatureInfo() { | 1435 FeatureInfo::~FeatureInfo() { |
1444 } | 1436 } |
1445 | 1437 |
1446 } // namespace gles2 | 1438 } // namespace gles2 |
1447 } // namespace gpu | 1439 } // namespace gpu |
OLD | NEW |