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 3 // found in the LICENSE file. 4 5 #ifndef GPU_CONFIG_GPU_TEST_CONFIG_H_ 6 #define GPU_CONFIG_GPU_TEST_CONFIG_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "angle_config.h" 12 13 namespace gpu { 14 15 struct GPUInfo; 16 17 class GPU_EXPORT GPUTestConfig { 18 public: 19 enum OS { 20 kOsUnknown = 0, 21 kOsWinXP = 1 << 0, 22 kOsWinVista = 1 << 1, 23 kOsWin7 = 1 << 2, 24 kOsWin8 = 1 << 3, 25 kOsMacLeopard = 1 << 4, 26 kOsMacSnowLeopard = 1 << 5, 27 kOsMacLion = 1 << 6, 28 kOsMacMountainLion = 1 << 7, 29 kOsMacMavericks = 1 << 8, 30 kOsMacYosemite = 1 << 9, 31 kOsMacElCapitan = 1 << 10, 32 kOsMac = kOsMacLeopard | kOsMacSnowLeopard | kOsMacLion | 33 kOsMacMountainLion | kOsMacMavericks | kOsMacYosemite | 34 kOsMacElCapitan, 35 kOsLinux = 1 << 11, 36 kOsChromeOS = 1 << 12, 37 kOsAndroid = 1 << 13, 38 kOsWin10 = 1 << 14, 39 kOsWin = kOsWinXP | kOsWinVista | kOsWin7 | kOsWin8 | kOsWin10, 40 }; 41 42 enum BuildType { 43 kBuildTypeUnknown = 0, 44 kBuildTypeRelease = 1 << 0, 45 kBuildTypeDebug = 1 << 1, 46 }; 47 48 enum API { 49 kAPIUnknown = 0, 50 kAPID3D9 = 1 << 0, 51 kAPID3D11 = 1 << 1, 52 kAPIGLDesktop = 1 << 2, 53 kAPIGLES = 1 << 3, 54 }; 55 56 GPUTestConfig(); 57 virtual ~GPUTestConfig(); 58 59 void set_os(int32 os); 60 void set_gpu_device_id(uint32 id); 61 void set_build_type(int32 build_type); 62 void set_api(int32 api); 63 64 virtual void AddGPUVendor(uint32 gpu_vendor); 65 os()66 int32 os() const { return os_; } gpu_vendor()67 const std::vector<uint32>& gpu_vendor() const { return gpu_vendor_; } gpu_device_id()68 uint32 gpu_device_id() const { return gpu_device_id_; } build_type()69 int32 build_type() const { return build_type_; } api()70 int32 api() const { return api_; } 71 72 // Check if the config is valid. For example, if gpu_device_id_ is set, but 73 // gpu_vendor_ is unknown, then it's invalid. 74 virtual bool IsValid() const; 75 76 // Check if two configs overlap, i.e., if there exists a config that matches 77 // both configs. 78 bool OverlapsWith(const GPUTestConfig& config) const; 79 80 // Disable validation of GPU vendor and device ids. 81 void DisableGPUInfoValidation(); 82 83 protected: 84 void ClearGPUVendor(); 85 86 // Indicates that the OS has the notion of a numeric GPU vendor and device id 87 // and this data should be validated. 88 bool validate_gpu_info_; 89 90 private: 91 // operating system. 92 int32 os_; 93 94 // GPU vendor. 95 std::vector<uint32> gpu_vendor_; 96 97 // GPU device id (unique to each vendor). 98 uint32 gpu_device_id_; 99 100 // Release or Debug. 101 int32 build_type_; 102 103 // Back-end rendering APIs. 104 int32 api_; 105 }; 106 107 class GPU_EXPORT GPUTestBotConfig : public GPUTestConfig { 108 public: GPUTestBotConfig()109 GPUTestBotConfig() { } 110 ~GPUTestBotConfig() override; 111 112 // This should only be called when no gpu_vendor is added. 113 void AddGPUVendor(uint32 gpu_vendor) override; 114 115 // Return false if gpu_info does not have valid vendor_id and device_id. 116 bool SetGPUInfo(const GPUInfo& gpu_info); 117 118 // Check if the bot config is valid, i.e., if it is one valid test-bot 119 // environment. For example, if a field is unknown, or if OS is not one 120 // fully defined OS, then it's valid. 121 bool IsValid() const override; 122 123 // Check if a bot config matches a test config, i.e., the test config is a 124 // superset of the bot config. 125 bool Matches(const GPUTestConfig& config) const; 126 bool Matches(const std::string& config_data) const; 127 128 // Setup the config with the current gpu testing environment. 129 // If gpu_info is NULL, collect GPUInfo first. 130 bool LoadCurrentConfig(const GPUInfo* gpu_info); 131 132 // Check if this bot's config matches |config_data| or any of the |configs|. 133 static bool CurrentConfigMatches(const std::string& config_data); 134 static bool CurrentConfigMatches(const std::vector<std::string>& configs); 135 }; 136 137 } // namespace gpu 138 139 #endif // GPU_CONFIG_GPU_TEST_CONFIG_H_ 140 141