Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: content/browser/gpu/gpu_blacklist.cc

Issue 11047011: Figure out whether we have enough information to make the final GPU blacklisting decision. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/gpu/gpu_blacklist.h ('k') | content/browser/gpu/gpu_blacklist_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/gpu/gpu_blacklist.h" 5 #include "content/browser/gpu/gpu_blacklist.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/cpu.h" 8 #include "base/cpu.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 return false; 1006 return false;
1007 break; 1007 break;
1008 case kMultiGpuCategorySecondary: 1008 case kMultiGpuCategorySecondary:
1009 if (is_not_secondary_gpu) 1009 if (is_not_secondary_gpu)
1010 return false; 1010 return false;
1011 break; 1011 break;
1012 case kMultiGpuCategoryAny: 1012 case kMultiGpuCategoryAny:
1013 if (is_not_primary_gpu && is_not_secondary_gpu) 1013 if (is_not_primary_gpu && is_not_secondary_gpu)
1014 return false; 1014 return false;
1015 break; 1015 break;
1016 default: 1016 case kMultiGpuCategoryNone:
1017 break; 1017 break;
1018 } 1018 }
1019 switch (multi_gpu_style_) { 1019 switch (multi_gpu_style_) {
1020 case kMultiGpuStyleOptimus: 1020 case kMultiGpuStyleOptimus:
1021 if (!gpu_info.optimus) 1021 if (!gpu_info.optimus)
1022 return false; 1022 return false;
1023 break; 1023 break;
1024 case kMultiGpuStyleAMDSwitchable: 1024 case kMultiGpuStyleAMDSwitchable:
1025 if (!gpu_info.amd_switchable) 1025 if (!gpu_info.amd_switchable)
1026 return false; 1026 return false;
1027 break; 1027 break;
1028 default: 1028 case kMultiGpuStyleNone:
1029 break; 1029 break;
1030 } 1030 }
1031 if (driver_vendor_info_.get() != NULL && 1031 if (driver_vendor_info_.get() != NULL && !gpu_info.driver_vendor.empty() &&
1032 !driver_vendor_info_->Contains(gpu_info.driver_vendor)) 1032 !driver_vendor_info_->Contains(gpu_info.driver_vendor))
1033 return false; 1033 return false;
1034 if (driver_version_info_.get() != NULL) { 1034 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) {
1035 std::string processed_driver_version; 1035 std::string processed_driver_version;
1036 if (driver_version_info_->IsLexical()) 1036 if (driver_version_info_->IsLexical())
1037 processed_driver_version = NumericalToLexical(gpu_info.driver_version); 1037 processed_driver_version = NumericalToLexical(gpu_info.driver_version);
1038 else 1038 else
1039 processed_driver_version = gpu_info.driver_version; 1039 processed_driver_version = gpu_info.driver_version;
1040 Version driver_version(processed_driver_version); 1040 Version driver_version(processed_driver_version);
1041 if (!driver_version.IsValid() || 1041 if (!driver_version.IsValid() ||
1042 !driver_version_info_->Contains(driver_version)) 1042 !driver_version_info_->Contains(driver_version))
1043 return false; 1043 return false;
1044 } 1044 }
1045 if (driver_date_info_.get() != NULL) { 1045 if (driver_date_info_.get() != NULL && !gpu_info.driver_date.empty()) {
1046 Version driver_date; 1046 Version driver_date;
1047 GetDateFromString(gpu_info.driver_date, &driver_date); 1047 GetDateFromString(gpu_info.driver_date, &driver_date);
1048 if (!driver_date.IsValid() || !driver_date_info_->Contains(driver_date)) 1048 if (!driver_date.IsValid() || !driver_date_info_->Contains(driver_date))
1049 return false; 1049 return false;
1050 } 1050 }
1051 if (gl_vendor_info_.get() != NULL && 1051 if (gl_vendor_info_.get() != NULL && !gpu_info.gl_vendor.empty() &&
1052 !gl_vendor_info_->Contains(gpu_info.gl_vendor)) 1052 !gl_vendor_info_->Contains(gpu_info.gl_vendor))
1053 return false; 1053 return false;
1054 if (gl_renderer_info_.get() != NULL && 1054 if (gl_renderer_info_.get() != NULL && !gpu_info.gl_renderer.empty() &&
1055 !gl_renderer_info_->Contains(gpu_info.gl_renderer)) 1055 !gl_renderer_info_->Contains(gpu_info.gl_renderer))
1056 return false; 1056 return false;
1057 if (perf_graphics_info_.get() != NULL && 1057 if (perf_graphics_info_.get() != NULL &&
1058 (gpu_info.performance_stats.graphics == 0.0 || 1058 (gpu_info.performance_stats.graphics == 0.0 ||
1059 !perf_graphics_info_->Contains(gpu_info.performance_stats.graphics))) 1059 !perf_graphics_info_->Contains(gpu_info.performance_stats.graphics)))
1060 return false; 1060 return false;
1061 if (perf_gaming_info_.get() != NULL && 1061 if (perf_gaming_info_.get() != NULL &&
1062 (gpu_info.performance_stats.gaming == 0.0 || 1062 (gpu_info.performance_stats.gaming == 0.0 ||
1063 !perf_gaming_info_->Contains(gpu_info.performance_stats.gaming))) 1063 !perf_gaming_info_->Contains(gpu_info.performance_stats.gaming)))
1064 return false; 1064 return false;
1065 if (perf_overall_info_.get() != NULL && 1065 if (perf_overall_info_.get() != NULL &&
1066 (gpu_info.performance_stats.overall == 0.0 || 1066 (gpu_info.performance_stats.overall == 0.0 ||
1067 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) 1067 !perf_overall_info_->Contains(gpu_info.performance_stats.overall)))
1068 return false; 1068 return false;
1069 if (machine_model_info_.get() != NULL && 1069 if (machine_model_info_.get() != NULL &&
1070 !machine_model_info_->Contains(machine_model_name, machine_model_version)) 1070 !machine_model_info_->Contains(machine_model_name, machine_model_version))
1071 return false; 1071 return false;
1072 if (gpu_count_info_.get() != NULL && 1072 if (gpu_count_info_.get() != NULL &&
1073 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) 1073 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1))
1074 return false; 1074 return false;
1075 if (cpu_brand_.get() != NULL) { 1075 if (cpu_brand_.get() != NULL) {
1076 base::CPU cpu_info; 1076 base::CPU cpu_info;
1077 if (!cpu_brand_->Contains(cpu_info.cpu_brand())) 1077 if (!cpu_brand_->Contains(cpu_info.cpu_brand()))
1078 return false; 1078 return false;
1079 } 1079 }
1080 1080
1081 for (size_t i = 0; i < exceptions_.size(); ++i) { 1081 for (size_t i = 0; i < exceptions_.size(); ++i) {
1082 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name, 1082 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name,
1083 machine_model_version, gpu_info)) 1083 machine_model_version, gpu_info) &&
1084 !exceptions_[i]->NeedsMoreInfo(gpu_info))
1084 return false; 1085 return false;
1085 } 1086 }
1086 return true; 1087 return true;
1087 } 1088 }
1088 1089
1090 bool GpuBlacklist::GpuBlacklistEntry::NeedsMoreInfo(
1091 const content::GPUInfo& gpu_info) const {
1092 // We only check for missing info that might be collected with a gl context.
1093 // If certain info is missing due to some error, say, we fail to collect
1094 // vendor_id/device_id, then even if we launch GPU process and create a gl
1095 // context, we won't gather such missing info, so we still return false.
1096 if (driver_vendor_info_.get() && gpu_info.driver_vendor.empty())
1097 return true;
1098 if (driver_version_info_.get() && gpu_info.driver_version.empty())
1099 return true;
1100 if (gl_vendor_info_.get() && gpu_info.gl_vendor.empty())
1101 return true;
1102 if (gl_renderer_info_.get() && gpu_info.gl_renderer.empty())
1103 return true;
1104 for (size_t i = 0; i < exceptions_.size(); ++i) {
1105 if (exceptions_[i]->NeedsMoreInfo(gpu_info))
1106 return true;
1107 }
1108 return false;
1109 }
1110
1089 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { 1111 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const {
1090 if (os_info_.get() == NULL) 1112 if (os_info_.get() == NULL)
1091 return kOsAny; 1113 return kOsAny;
1092 return os_info_->type(); 1114 return os_info_->type();
1093 } 1115 }
1094 1116
1095 uint32 GpuBlacklist::GpuBlacklistEntry::id() const { 1117 uint32 GpuBlacklist::GpuBlacklistEntry::id() const {
1096 return id_; 1118 return id_;
1097 } 1119 }
1098 1120
1099 bool GpuBlacklist::GpuBlacklistEntry::disabled() const { 1121 bool GpuBlacklist::GpuBlacklistEntry::disabled() const {
1100 return disabled_; 1122 return disabled_;
1101 } 1123 }
1102 1124
1103 GpuFeatureType GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureType() const { 1125 GpuFeatureType GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureType() const {
1104 return decision_.blacklisted_features; 1126 return decision_.blacklisted_features;
1105 } 1127 }
1106 1128
1107 GpuSwitchingOption 1129 GpuSwitchingOption
1108 GpuBlacklist::GpuBlacklistEntry::GetGpuSwitchingOption() const { 1130 GpuBlacklist::GpuBlacklistEntry::GetGpuSwitchingOption() const {
1109 return decision_.gpu_switching; 1131 return decision_.gpu_switching;
1110 } 1132 }
1111 1133
1112 GpuBlacklist::GpuBlacklist() 1134 GpuBlacklist::GpuBlacklist()
1113 : max_entry_id_(0), 1135 : max_entry_id_(0),
1114 contains_unknown_fields_(false) { 1136 contains_unknown_fields_(false),
1137 needs_more_info_(false) {
1115 } 1138 }
1116 1139
1117 GpuBlacklist::~GpuBlacklist() { 1140 GpuBlacklist::~GpuBlacklist() {
1118 Clear(); 1141 Clear();
1119 } 1142 }
1120 1143
1121 bool GpuBlacklist::LoadGpuBlacklist( 1144 bool GpuBlacklist::LoadGpuBlacklist(
1122 const std::string& json_context, GpuBlacklist::OsFilter os_filter) { 1145 const std::string& json_context, GpuBlacklist::OsFilter os_filter) {
1123 const std::string browser_version_string = "0"; 1146 const std::string browser_version_string = "0";
1124 return LoadGpuBlacklist(browser_version_string, json_context, os_filter); 1147 return LoadGpuBlacklist(browser_version_string, json_context, os_filter);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1225 }
1203 1226
1204 GpuBlacklist::Decision GpuBlacklist::MakeBlacklistDecision( 1227 GpuBlacklist::Decision GpuBlacklist::MakeBlacklistDecision(
1205 GpuBlacklist::OsType os, 1228 GpuBlacklist::OsType os,
1206 Version* os_version, 1229 Version* os_version,
1207 const content::GPUInfo& gpu_info) { 1230 const content::GPUInfo& gpu_info) {
1208 active_entries_.clear(); 1231 active_entries_.clear();
1209 int type = 0; 1232 int type = 0;
1210 GpuSwitchingOption switching = content::GPU_SWITCHING_OPTION_UNKNOWN; 1233 GpuSwitchingOption switching = content::GPU_SWITCHING_OPTION_UNKNOWN;
1211 1234
1235 needs_more_info_ = false;
1236 int possible_type = 0;
1237 GpuSwitchingOption possible_switching = content::GPU_SWITCHING_OPTION_UNKNOWN;
1238
1212 if (os == kOsAny) 1239 if (os == kOsAny)
1213 os = GetOsType(); 1240 os = GetOsType();
1214 scoped_ptr<Version> my_os_version; 1241 scoped_ptr<Version> my_os_version;
1215 if (os_version == NULL) { 1242 if (os_version == NULL) {
1216 std::string version_string = base::SysInfo::OperatingSystemVersion(); 1243 std::string version_string = base::SysInfo::OperatingSystemVersion();
1217 size_t pos = version_string.find_first_not_of("0123456789."); 1244 size_t pos = version_string.find_first_not_of("0123456789.");
1218 if (pos != std::string::npos) 1245 if (pos != std::string::npos)
1219 version_string = version_string.substr(0, pos); 1246 version_string = version_string.substr(0, pos);
1220 my_os_version.reset(new Version(version_string)); 1247 my_os_version.reset(new Version(version_string));
1221 os_version = my_os_version.get(); 1248 os_version = my_os_version.get();
1222 } 1249 }
1223 DCHECK(os_version != NULL); 1250 DCHECK(os_version != NULL);
1224 1251
1225 CollectCurrentMachineModelInfo(); 1252 CollectCurrentMachineModelInfo();
1226 for (size_t i = 0; i < blacklist_.size(); ++i) { 1253 for (size_t i = 0; i < blacklist_.size(); ++i) {
1227 if (blacklist_[i]->Contains(os, *os_version, current_machine_model_name_, 1254 if (blacklist_[i]->Contains(os, *os_version, current_machine_model_name_,
1228 *current_machine_model_version_, gpu_info)) { 1255 *current_machine_model_version_, gpu_info)) {
1229 if (!blacklist_[i]->disabled()) { 1256 if (!blacklist_[i]->disabled()) {
1230 type |= blacklist_[i]->GetGpuFeatureType(); 1257 bool not_final = blacklist_[i]->NeedsMoreInfo(gpu_info);
1258 if (not_final)
1259 possible_type |= blacklist_[i]->GetGpuFeatureType();
1260 else
1261 type |= blacklist_[i]->GetGpuFeatureType();
1231 if (blacklist_[i]->GetGpuSwitchingOption() != 1262 if (blacklist_[i]->GetGpuSwitchingOption() !=
1232 content::GPU_SWITCHING_OPTION_UNKNOWN) 1263 content::GPU_SWITCHING_OPTION_UNKNOWN) {
1233 switching = blacklist_[i]->GetGpuSwitchingOption(); 1264 if (not_final)
1265 possible_switching = blacklist_[i]->GetGpuSwitchingOption();
1266 else
1267 switching = blacklist_[i]->GetGpuSwitchingOption();
1268 }
1234 } 1269 }
1235 active_entries_.push_back(blacklist_[i]); 1270 active_entries_.push_back(blacklist_[i]);
1236 } 1271 }
1237 } 1272 }
1273
1274 if ((possible_type != 0 && (possible_type | type) != type) ||
1275 (possible_switching != content::GPU_SWITCHING_OPTION_UNKNOWN &&
1276 switching == content::GPU_SWITCHING_OPTION_UNKNOWN))
1277 needs_more_info_ = true;
1278
1238 Decision decision; 1279 Decision decision;
1239 decision.blacklisted_features = static_cast<GpuFeatureType>(type); 1280 decision.blacklisted_features = static_cast<GpuFeatureType>(type);
1240 decision.gpu_switching = switching; 1281 decision.gpu_switching = switching;
1241 return decision; 1282 return decision;
1242 } 1283 }
1243 1284
1244 void GpuBlacklist::GetDecisionEntries( 1285 void GpuBlacklist::GetDecisionEntries(
1245 std::vector<uint32>& entry_ids, bool disabled) const { 1286 std::vector<uint32>& entry_ids, bool disabled) const {
1246 entry_ids.clear(); 1287 entry_ids.clear();
1247 for (size_t i = 0; i < active_entries_.size(); ++i) { 1288 for (size_t i = 0; i < active_entries_.size(); ++i) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 if (op == ">") 1417 if (op == ">")
1377 return kGT; 1418 return kGT;
1378 if (op == ">=") 1419 if (op == ">=")
1379 return kGE; 1420 return kGE;
1380 if (op == "any") 1421 if (op == "any")
1381 return kAny; 1422 return kAny;
1382 if (op == "between") 1423 if (op == "between")
1383 return kBetween; 1424 return kBetween;
1384 return kUnknown; 1425 return kUnknown;
1385 } 1426 }
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_blacklist.h ('k') | content/browser/gpu/gpu_blacklist_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698