Chromium Code Reviews| 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/config/gpu_test_config.h" | 5 #include "gpu/config/gpu_test_config.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 void GPUTestConfig::set_build_type(int32_t build_type) { | 107 void GPUTestConfig::set_build_type(int32_t build_type) { |
| 108 DCHECK_EQ(0, build_type & ~(kBuildTypeRelease | kBuildTypeDebug)); | 108 DCHECK_EQ(0, build_type & ~(kBuildTypeRelease | kBuildTypeDebug)); |
| 109 build_type_ = build_type; | 109 build_type_ = build_type; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void GPUTestConfig::set_api(int32_t api) { | 112 void GPUTestConfig::set_api(int32_t api) { |
| 113 DCHECK_EQ(0, api & ~(kAPID3D9 | kAPID3D11 | kAPIGLDesktop | kAPIGLES)); | 113 DCHECK_EQ(0, api & ~(kAPID3D9 | kAPID3D11 | kAPIGLDesktop | kAPIGLES)); |
| 114 api_ = api; | 114 api_ = api; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void GPUTestConfig::set_machine_model_name( | |
| 118 const std::string& machine_model_name) { | |
| 119 machine_model_name_ = machine_model_name; | |
| 120 } | |
| 121 | |
| 117 bool GPUTestConfig::IsValid() const { | 122 bool GPUTestConfig::IsValid() const { |
| 118 if (!validate_gpu_info_) | 123 if (!validate_gpu_info_) |
| 119 return true; | 124 return true; |
| 120 if (gpu_device_id_ != 0 && (gpu_vendor_.size() != 1 || gpu_vendor_[0] == 0)) | 125 if (gpu_device_id_ != 0 && (gpu_vendor_.size() != 1 || gpu_vendor_[0] == 0)) |
| 121 return false; | 126 return false; |
| 122 return true; | 127 return true; |
| 123 } | 128 } |
| 124 | 129 |
| 125 bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const { | 130 bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const { |
| 126 DCHECK(IsValid()); | 131 DCHECK(IsValid()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 141 if (!shared) | 146 if (!shared) |
| 142 return false; | 147 return false; |
| 143 } | 148 } |
| 144 if (config.gpu_device_id_ != 0 && gpu_device_id_ != 0 && | 149 if (config.gpu_device_id_ != 0 && gpu_device_id_ != 0 && |
| 145 gpu_device_id_ != config.gpu_device_id_) | 150 gpu_device_id_ != config.gpu_device_id_) |
| 146 return false; | 151 return false; |
| 147 if (config.build_type_ != kBuildTypeUnknown && | 152 if (config.build_type_ != kBuildTypeUnknown && |
| 148 build_type_ != kBuildTypeUnknown && | 153 build_type_ != kBuildTypeUnknown && |
| 149 (build_type_ & config.build_type_) == 0) | 154 (build_type_ & config.build_type_) == 0) |
| 150 return false; | 155 return false; |
| 156 if (!config.machine_model_name_.empty() && !machine_model_name_.empty() && | |
| 157 config.machine_model_name_ != machine_model_name_) | |
|
Zhenyao Mo
2017/03/11 18:29:16
Can you add a unit test for this?
| |
| 158 return false; | |
| 151 return true; | 159 return true; |
| 152 } | 160 } |
| 153 | 161 |
| 154 void GPUTestConfig::DisableGPUInfoValidation() { | 162 void GPUTestConfig::DisableGPUInfoValidation() { |
| 155 validate_gpu_info_ = false; | 163 validate_gpu_info_ = false; |
| 156 } | 164 } |
| 157 | 165 |
| 158 void GPUTestConfig::ClearGPUVendor() { | 166 void GPUTestConfig::ClearGPUVendor() { |
| 159 gpu_vendor_.clear(); | 167 gpu_vendor_.clear(); |
| 160 } | 168 } |
| 161 | 169 |
| 162 GPUTestBotConfig::~GPUTestBotConfig() { | 170 GPUTestBotConfig::~GPUTestBotConfig() { |
| 163 } | 171 } |
| 164 | 172 |
| 165 void GPUTestBotConfig::AddGPUVendor(uint32_t gpu_vendor) { | 173 void GPUTestBotConfig::AddGPUVendor(uint32_t gpu_vendor) { |
| 166 DCHECK_EQ(0u, GPUTestConfig::gpu_vendor().size()); | 174 DCHECK_EQ(0u, GPUTestConfig::gpu_vendor().size()); |
| 167 GPUTestConfig::AddGPUVendor(gpu_vendor); | 175 GPUTestConfig::AddGPUVendor(gpu_vendor); |
| 168 } | 176 } |
| 169 | 177 |
| 170 bool GPUTestBotConfig::SetGPUInfo(const GPUInfo& gpu_info) { | 178 bool GPUTestBotConfig::SetGPUInfo(const GPUInfo& gpu_info) { |
| 171 DCHECK(validate_gpu_info_); | 179 DCHECK(validate_gpu_info_); |
| 172 if (gpu_info.gpu.device_id == 0 || gpu_info.gpu.vendor_id == 0) | 180 if (gpu_info.gpu.device_id == 0 || gpu_info.gpu.vendor_id == 0) |
| 173 return false; | 181 return false; |
| 174 ClearGPUVendor(); | 182 ClearGPUVendor(); |
| 175 AddGPUVendor(gpu_info.gpu.vendor_id); | 183 AddGPUVendor(gpu_info.gpu.vendor_id); |
| 176 set_gpu_device_id(gpu_info.gpu.device_id); | 184 set_gpu_device_id(gpu_info.gpu.device_id); |
| 185 set_machine_model_name(gpu_info.machine_model_name); | |
| 177 return true; | 186 return true; |
| 178 } | 187 } |
| 179 | 188 |
| 180 bool GPUTestBotConfig::IsValid() const { | 189 bool GPUTestBotConfig::IsValid() const { |
| 181 switch (os()) { | 190 switch (os()) { |
| 182 case kOsWinXP: | 191 case kOsWinXP: |
| 183 case kOsWinVista: | 192 case kOsWinVista: |
| 184 case kOsWin7: | 193 case kOsWin7: |
| 185 case kOsWin8: | 194 case kOsWin8: |
| 186 case kOsWin10: | 195 case kOsWin10: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 return false; | 241 return false; |
| 233 } | 242 } |
| 234 if (config.gpu_device_id() != 0 && | 243 if (config.gpu_device_id() != 0 && |
| 235 gpu_device_id() != config.gpu_device_id()) | 244 gpu_device_id() != config.gpu_device_id()) |
| 236 return false; | 245 return false; |
| 237 if (config.build_type() != kBuildTypeUnknown && | 246 if (config.build_type() != kBuildTypeUnknown && |
| 238 (build_type() & config.build_type()) == 0) | 247 (build_type() & config.build_type()) == 0) |
| 239 return false; | 248 return false; |
| 240 if (config.api() != 0 && (api() & config.api()) == 0) | 249 if (config.api() != 0 && (api() & config.api()) == 0) |
| 241 return false; | 250 return false; |
| 251 if (!config.machine_model_name().empty() && | |
|
Zhenyao Mo
2017/03/11 18:29:16
Can you add a unit test for this?
| |
| 252 machine_model_name() != config.machine_model_name()) | |
| 253 return false; | |
| 242 return true; | 254 return true; |
| 243 } | 255 } |
| 244 | 256 |
| 245 bool GPUTestBotConfig::Matches(const std::string& config_data) const { | 257 bool GPUTestBotConfig::Matches(const std::string& config_data) const { |
| 246 GPUTestExpectationsParser parser; | 258 GPUTestExpectationsParser parser; |
| 247 GPUTestConfig config; | 259 GPUTestConfig config; |
| 248 | 260 |
| 249 if (!parser.ParseConfig(config_data, &config)) | 261 if (!parser.ParseConfig(config_data, &config)) |
| 250 return false; | 262 return false; |
| 251 return Matches(config); | 263 return Matches(config); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 // Blacklist rule #79 disables all Gpu acceleration before Windows 7. | 318 // Blacklist rule #79 disables all Gpu acceleration before Windows 7. |
| 307 if (base::win::GetVersion() <= base::win::VERSION_VISTA) { | 319 if (base::win::GetVersion() <= base::win::VERSION_VISTA) { |
| 308 return true; | 320 return true; |
| 309 } | 321 } |
| 310 #endif | 322 #endif |
| 311 return false; | 323 return false; |
| 312 } | 324 } |
| 313 | 325 |
| 314 } // namespace gpu | 326 } // namespace gpu |
| 315 | 327 |
| OLD | NEW |