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 <stdint.h> 9 10 #include <string> 11 #include <vector> 12 13 #include "base/compiler_specific.h" 14 #include "gpu/gpu_export.h" 15 16 namespace gpu { 17 18 struct GPUInfo; 19 20 class GPU_EXPORT GPUTestConfig { 21 public: 22 enum OS { 23 kOsUnknown = 0, 24 kOsWinXP = 1 << 0, 25 kOsWinVista = 1 << 1, 26 kOsWin7 = 1 << 2, 27 kOsWin8 = 1 << 3, 28 kOsWin10 = 1 << 4, 29 kOsWin = kOsWinXP | kOsWinVista | kOsWin7 | kOsWin8 | kOsWin10, 30 // Jump over a few bits for future Windows versions. 31 kOsMacLeopard = 1 << 10, 32 kOsMacSnowLeopard = 1 << 11, 33 kOsMacLion = 1 << 12, 34 kOsMacMountainLion = 1 << 13, 35 kOsMacMavericks = 1 << 14, 36 kOsMacYosemite = 1 << 15, 37 kOsMacElCapitan = 1 << 16, 38 kOsMacSierra = 1 << 17, 39 kOsMacHighSierra = 1 << 18, 40 kOsMacMojave = 1 << 19, 41 kOsMacCatalina = 1 << 20, 42 kOsMacBigSur = 1 << 21, 43 kOsMac = kOsMacLeopard | kOsMacSnowLeopard | kOsMacLion | 44 kOsMacMountainLion | kOsMacMavericks | kOsMacYosemite | 45 kOsMacElCapitan | kOsMacSierra | kOsMacHighSierra | kOsMacMojave | 46 kOsMacCatalina | kOsMacBigSur, 47 // Jump over a few bits for future OSX versions. 48 kOsLinux = 1 << 25, 49 kOsChromeOS = 1 << 26, 50 kOsAndroid = 1 << 27, 51 kOsFuchsia = 1 << 28, 52 // If we run out of bits, please retire older OS versions, like WinXP, 53 // MacLeopard, etc., for which we no longer have bots. 54 }; 55 56 enum BuildType { 57 kBuildTypeUnknown = 0, 58 kBuildTypeRelease = 1 << 0, 59 kBuildTypeDebug = 1 << 1, 60 }; 61 62 enum API { 63 kAPIUnknown = 0, 64 kAPID3D9 = 1 << 0, 65 kAPID3D11 = 1 << 1, 66 kAPIGLDesktop = 1 << 2, 67 kAPIGLES = 1 << 3, 68 }; 69 70 enum CommandDecoder { 71 kCommandDecoderUnknown, 72 kCommandDecoderPassthrough = 1 << 0, 73 kCommandDecoderValidating = 1 << 1, 74 }; 75 76 GPUTestConfig(); 77 GPUTestConfig(const GPUTestConfig& other); 78 virtual ~GPUTestConfig(); 79 80 void set_os(int32_t os); 81 void set_gpu_device_id(uint32_t id); 82 void set_build_type(int32_t build_type); 83 void set_api(int32_t api); 84 void set_command_decoder(int32_t command_decoder); 85 86 virtual void AddGPUVendor(uint32_t gpu_vendor); 87 os()88 int32_t os() const { return os_; } gpu_vendor()89 const std::vector<uint32_t>& gpu_vendor() const { return gpu_vendor_; } gpu_device_id()90 uint32_t gpu_device_id() const { return gpu_device_id_; } build_type()91 int32_t build_type() const { return build_type_; } api()92 int32_t api() const { return api_; } command_decoder()93 int32_t command_decoder() const { return command_decoder_; } 94 95 // Check if the config is valid. For example, if gpu_device_id_ is set, but 96 // gpu_vendor_ is unknown, then it's invalid. 97 virtual bool IsValid() const; 98 99 // Check if two configs overlap, i.e., if there exists a config that matches 100 // both configs. 101 bool OverlapsWith(const GPUTestConfig& config) const; 102 103 protected: 104 void ClearGPUVendor(); 105 106 private: 107 // operating system. 108 int32_t os_; 109 110 // GPU vendor. 111 std::vector<uint32_t> gpu_vendor_; 112 113 // GPU device id (unique to each vendor). 114 uint32_t gpu_device_id_; 115 116 // Release or Debug. 117 int32_t build_type_; 118 119 // Back-end rendering APIs. 120 int32_t api_; 121 122 // GPU process command decoder type 123 int32_t command_decoder_; 124 }; 125 126 class GPU_EXPORT GPUTestBotConfig : public GPUTestConfig { 127 public: 128 GPUTestBotConfig() = default; 129 ~GPUTestBotConfig() override; 130 131 // This should only be called when no gpu_vendor is added. 132 void AddGPUVendor(uint32_t gpu_vendor) override; 133 134 // Return false if gpu_info does not have valid vendor_id and device_id. 135 bool SetGPUInfo(const GPUInfo& gpu_info); 136 137 // Check if the bot config is valid, i.e., if it is one valid test-bot 138 // environment. For example, if a field is unknown, or if OS is not one 139 // fully defined OS, then it's valid. 140 bool IsValid() const override; 141 142 // Check if a bot config matches a test config, i.e., the test config is a 143 // superset of the bot config. 144 bool Matches(const GPUTestConfig& config) const; 145 bool Matches(const std::string& config_data) const; 146 147 // Setup the config with the current gpu testing environment. 148 // If gpu_info is nullptr, collect GPUInfo first. 149 bool LoadCurrentConfig(const GPUInfo* gpu_info); 150 151 // Check if this bot's config matches |config_data| or any of the |configs|. 152 static bool CurrentConfigMatches(const std::string& config_data); 153 static bool CurrentConfigMatches(const std::vector<std::string>& configs); 154 155 // Check if the bot has blocklisted all GPU features. 156 static bool GpuBlocklistedOnBot(); 157 }; 158 159 } // namespace gpu 160 161 #endif // GPU_CONFIG_GPU_TEST_CONFIG_H_ 162