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> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 const std::set<std::string>& GetImpl() { | 75 const std::set<std::string>& GetImpl() { |
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 |
| 84 // the corresponding Workaround flags. |
| 85 void StringToWorkarounds( |
| 86 const std::string& types, FeatureInfo::Workarounds* workarounds) { |
| 87 DCHECK(workarounds); |
| 88 for (const base::StringPiece& piece : |
| 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) { |
| 95 #define GPU_OP(type, name) \ |
| 96 case gpu::type: \ |
| 97 workarounds->name = true; \ |
| 98 break; |
| 99 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) |
| 100 #undef GPU_OP |
| 101 default: |
| 102 NOTIMPLEMENTED(); |
| 103 } |
| 104 } |
| 105 if (workarounds->max_texture_size_limit_4096) |
| 106 workarounds->max_texture_size = 4096; |
| 107 if (workarounds->max_cube_map_texture_size_limit_4096) |
| 108 workarounds->max_cube_map_texture_size = 4096; |
| 109 if (workarounds->max_cube_map_texture_size_limit_1024) |
| 110 workarounds->max_cube_map_texture_size = 1024; |
| 111 if (workarounds->max_cube_map_texture_size_limit_512) |
| 112 workarounds->max_cube_map_texture_size = 512; |
| 113 |
| 114 if (workarounds->max_fragment_uniform_vectors_32) |
| 115 workarounds->max_fragment_uniform_vectors = 32; |
| 116 if (workarounds->max_varying_vectors_16) |
| 117 workarounds->max_varying_vectors = 16; |
| 118 if (workarounds->max_vertex_uniform_vectors_256) |
| 119 workarounds->max_vertex_uniform_vectors = 256; |
| 120 |
| 121 if (workarounds->max_copy_texture_chromium_size_1048576) |
| 122 workarounds->max_copy_texture_chromium_size = 1048576; |
| 123 if (workarounds->max_copy_texture_chromium_size_262144) |
| 124 workarounds->max_copy_texture_chromium_size = 262144; |
| 125 } |
| 126 |
83 } // anonymous namespace. | 127 } // anonymous namespace. |
84 | 128 |
85 FeatureInfo::FeatureFlags::FeatureFlags() | 129 FeatureInfo::FeatureFlags::FeatureFlags() |
86 : chromium_framebuffer_multisample(false), | 130 : chromium_framebuffer_multisample(false), |
87 chromium_sync_query(false), | 131 chromium_sync_query(false), |
88 use_core_framebuffer_multisample(false), | 132 use_core_framebuffer_multisample(false), |
89 multisampled_render_to_texture(false), | 133 multisampled_render_to_texture(false), |
90 use_img_for_multisampled_render_to_texture(false), | 134 use_img_for_multisampled_render_to_texture(false), |
91 chromium_screen_space_antialiasing(false), | 135 chromium_screen_space_antialiasing(false), |
92 oes_standard_derivatives(false), | 136 oes_standard_derivatives(false), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ext_texture_rg(false), | 174 ext_texture_rg(false), |
131 chromium_image_ycbcr_420v(false), | 175 chromium_image_ycbcr_420v(false), |
132 chromium_image_ycbcr_422(false), | 176 chromium_image_ycbcr_422(false), |
133 enable_subscribe_uniform(false), | 177 enable_subscribe_uniform(false), |
134 emulate_primitive_restart_fixed_index(false), | 178 emulate_primitive_restart_fixed_index(false), |
135 ext_render_buffer_format_bgra8888(false), | 179 ext_render_buffer_format_bgra8888(false), |
136 ext_multisample_compatibility(false), | 180 ext_multisample_compatibility(false), |
137 ext_blend_func_extended(false), | 181 ext_blend_func_extended(false), |
138 ext_read_format_bgra(false) {} | 182 ext_read_format_bgra(false) {} |
139 | 183 |
| 184 FeatureInfo::Workarounds::Workarounds() : |
| 185 #define GPU_OP(type, name) name(false), |
| 186 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) |
| 187 #undef GPU_OP |
| 188 max_texture_size(0), |
| 189 max_cube_map_texture_size(0), |
| 190 max_fragment_uniform_vectors(0), |
| 191 max_varying_vectors(0), |
| 192 max_vertex_uniform_vectors(0), |
| 193 max_copy_texture_chromium_size(0) { |
| 194 } |
| 195 |
140 FeatureInfo::FeatureInfo() { | 196 FeatureInfo::FeatureInfo() { |
141 InitializeBasicState(base::CommandLine::InitializedForCurrentProcess() | 197 InitializeBasicState(base::CommandLine::InitializedForCurrentProcess() |
142 ? base::CommandLine::ForCurrentProcess() | 198 ? base::CommandLine::ForCurrentProcess() |
143 : nullptr); | 199 : nullptr); |
144 } | 200 } |
145 | 201 |
146 FeatureInfo::FeatureInfo( | 202 FeatureInfo::FeatureInfo(const base::CommandLine& command_line) { |
147 const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds) | |
148 : workarounds_(gpu_driver_bug_workarounds) { | |
149 InitializeBasicState(base::CommandLine::InitializedForCurrentProcess() | |
150 ? base::CommandLine::ForCurrentProcess() | |
151 : nullptr); | |
152 } | |
153 | |
154 FeatureInfo::FeatureInfo( | |
155 const base::CommandLine& command_line, | |
156 const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds) | |
157 : workarounds_(gpu_driver_bug_workarounds) { | |
158 InitializeBasicState(&command_line); | 203 InitializeBasicState(&command_line); |
159 } | 204 } |
160 | 205 |
161 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { | 206 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { |
162 if (!command_line) | 207 if (!command_line) |
163 return; | 208 return; |
164 | 209 |
| 210 if (command_line->HasSwitch(switches::kGpuDriverBugWorkarounds)) { |
| 211 std::string types = command_line->GetSwitchValueASCII( |
| 212 switches::kGpuDriverBugWorkarounds); |
| 213 StringToWorkarounds(types, &workarounds_); |
| 214 } |
165 feature_flags_.enable_shader_name_hashing = | 215 feature_flags_.enable_shader_name_hashing = |
166 !command_line->HasSwitch(switches::kDisableShaderNameHashing); | 216 !command_line->HasSwitch(switches::kDisableShaderNameHashing); |
167 | 217 |
168 feature_flags_.is_swiftshader = | 218 feature_flags_.is_swiftshader = |
169 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); | 219 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); |
170 | 220 |
171 feature_flags_.enable_subscribe_uniform = | 221 feature_flags_.enable_subscribe_uniform = |
172 command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); | 222 command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); |
173 | 223 |
174 enable_unsafe_es3_apis_switch_ = | 224 enable_unsafe_es3_apis_switch_ = |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 if (pos == std::string::npos) { | 1424 if (pos == std::string::npos) { |
1375 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1425 extensions_ += (extensions_.empty() ? "" : " ") + str; |
1376 } | 1426 } |
1377 } | 1427 } |
1378 | 1428 |
1379 FeatureInfo::~FeatureInfo() { | 1429 FeatureInfo::~FeatureInfo() { |
1380 } | 1430 } |
1381 | 1431 |
1382 } // namespace gles2 | 1432 } // namespace gles2 |
1383 } // namespace gpu | 1433 } // namespace gpu |
OLD | NEW |