| 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 | |
| 127 } // anonymous namespace. | 83 } // anonymous namespace. |
| 128 | 84 |
| 129 FeatureInfo::FeatureFlags::FeatureFlags() | 85 FeatureInfo::FeatureFlags::FeatureFlags() |
| 130 : chromium_framebuffer_multisample(false), | 86 : chromium_framebuffer_multisample(false), |
| 131 chromium_sync_query(false), | 87 chromium_sync_query(false), |
| 132 use_core_framebuffer_multisample(false), | 88 use_core_framebuffer_multisample(false), |
| 133 multisampled_render_to_texture(false), | 89 multisampled_render_to_texture(false), |
| 134 use_img_for_multisampled_render_to_texture(false), | 90 use_img_for_multisampled_render_to_texture(false), |
| 135 chromium_screen_space_antialiasing(false), | 91 chromium_screen_space_antialiasing(false), |
| 136 oes_standard_derivatives(false), | 92 oes_standard_derivatives(false), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 ext_texture_rg(false), | 130 ext_texture_rg(false), |
| 175 chromium_image_ycbcr_420v(false), | 131 chromium_image_ycbcr_420v(false), |
| 176 chromium_image_ycbcr_422(false), | 132 chromium_image_ycbcr_422(false), |
| 177 enable_subscribe_uniform(false), | 133 enable_subscribe_uniform(false), |
| 178 emulate_primitive_restart_fixed_index(false), | 134 emulate_primitive_restart_fixed_index(false), |
| 179 ext_render_buffer_format_bgra8888(false), | 135 ext_render_buffer_format_bgra8888(false), |
| 180 ext_multisample_compatibility(false), | 136 ext_multisample_compatibility(false), |
| 181 ext_blend_func_extended(false), | 137 ext_blend_func_extended(false), |
| 182 ext_read_format_bgra(false) {} | 138 ext_read_format_bgra(false) {} |
| 183 | 139 |
| 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 | |
| 196 FeatureInfo::FeatureInfo() { | 140 FeatureInfo::FeatureInfo() { |
| 197 InitializeBasicState(base::CommandLine::InitializedForCurrentProcess() | 141 InitializeBasicState(base::CommandLine::InitializedForCurrentProcess() |
| 198 ? base::CommandLine::ForCurrentProcess() | 142 ? base::CommandLine::ForCurrentProcess() |
| 199 : nullptr); | 143 : nullptr); |
| 200 } | 144 } |
| 201 | 145 |
| 202 FeatureInfo::FeatureInfo(const base::CommandLine& command_line) { | 146 FeatureInfo::FeatureInfo( |
| 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) { |
| 203 InitializeBasicState(&command_line); | 158 InitializeBasicState(&command_line); |
| 204 } | 159 } |
| 205 | 160 |
| 206 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { | 161 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { |
| 207 if (!command_line) | 162 if (!command_line) |
| 208 return; | 163 return; |
| 209 | 164 |
| 210 if (command_line->HasSwitch(switches::kGpuDriverBugWorkarounds)) { | |
| 211 std::string types = command_line->GetSwitchValueASCII( | |
| 212 switches::kGpuDriverBugWorkarounds); | |
| 213 StringToWorkarounds(types, &workarounds_); | |
| 214 } | |
| 215 feature_flags_.enable_shader_name_hashing = | 165 feature_flags_.enable_shader_name_hashing = |
| 216 !command_line->HasSwitch(switches::kDisableShaderNameHashing); | 166 !command_line->HasSwitch(switches::kDisableShaderNameHashing); |
| 217 | 167 |
| 218 feature_flags_.is_swiftshader = | 168 feature_flags_.is_swiftshader = |
| 219 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); | 169 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); |
| 220 | 170 |
| 221 feature_flags_.enable_subscribe_uniform = | 171 feature_flags_.enable_subscribe_uniform = |
| 222 command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); | 172 command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); |
| 223 | 173 |
| 224 enable_unsafe_es3_apis_switch_ = | 174 enable_unsafe_es3_apis_switch_ = |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 if (pos == std::string::npos) { | 1370 if (pos == std::string::npos) { |
| 1421 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1371 extensions_ += (extensions_.empty() ? "" : " ") + str; |
| 1422 } | 1372 } |
| 1423 } | 1373 } |
| 1424 | 1374 |
| 1425 FeatureInfo::~FeatureInfo() { | 1375 FeatureInfo::~FeatureInfo() { |
| 1426 } | 1376 } |
| 1427 | 1377 |
| 1428 } // namespace gles2 | 1378 } // namespace gles2 |
| 1429 } // namespace gpu | 1379 } // namespace gpu |
| OLD | NEW |