| Flutter Impeller |

driver_info_vk.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
7
8 #include "impeller/base/version.h"
9 #include "impeller/renderer/backend/vulkan/vk.h"
10
11 namespace impeller {
12
13 // https://en.wikipedia.org/wiki/Adreno
14 enum class AdrenoGPU {
15 // I don't think the 400 series will ever run Vulkan, but if some show up we
16 // can add them here.
17 // 500s
18 kAdreno504,
19 kAdreno505,
20 kAdreno506,
21 kAdreno508,
22 kAdreno509,
23 kAdreno510,
24 kAdreno512,
25 kAdreno530,
26 kAdreno540,
27 // 600s
28 kAdreno605,
29 kAdreno608,
30 kAdreno610,
31 kAdreno612,
32 kAdreno613,
33 kAdreno615,
34 kAdreno616,
35 kAdreno618,
36 kAdreno619L,
37 kAdreno619,
38 kAdreno620,
39 kAdreno630,
40 // The 640 is the first GPU inside an Android device with upgradable drivers.
41 // Anything before this point exhibiting broken behavior is broken forever.
42 kAdreno640,
43 kAdreno642L,
44 kAdreno642,
45 kAdreno643L,
46 kAdreno644,
47 kAdreno650,
48 kAdreno660,
49 kAdreno663,
50 kAdreno675,
51 kAdreno680,
52 kAdreno685,
53 kAdreno690,
54 kAdreno695,
55 // 700s
56 kAdreno702,
57 kAdreno710,
58 kAdreno720,
59 kAdreno725,
60 kAdreno730,
61 kAdreno732,
62 kAdreno735,
63 kAdreno740,
64 kAdreno750,
65 // X
66 kAdrenoX145,
67 kAdrenoX185,
68 // Unknown GPU, likely newer model.
69 kUnknown,
70 };
71
72 // https://en.wikipedia.org/wiki/Mali_(processor)
73 enum class MaliGPU {
74 // These might be Vulkan 1.0 Only.
75 kT760,
76 kT820,
77 kT830,
78 kT860,
79 kT880,
80
81 // Bifrost
82 kG31,
83 kG51,
84 kG71,
85 kG52,
86 kG72,
87 kG76,
88
89 // Valhall
90 // Note: there is an Immortalis-G715 a Mali-G715
91 kG57,
92 kG77,
93 kG68,
94 kG78,
95 kG310,
96 kG510,
97 kG610,
98 kG710,
99 kG615,
100 kG715,
101
102 // 5th Gen
103 kG620,
104 kG720,
105 kG625,
106 kG725,
107 kG925,
108 kUnknown,
109 };
110
111 enum class VendorVK {
112 kUnknown,
113 //----------------------------------------------------------------------------
114 /// Includes the SwiftShader CPU implementation.
115 ///
116 kGoogle,
117 kQualcomm,
118 kARM,
119 kImgTec,
120 kPowerVR = kImgTec,
121 kAMD,
122 kNvidia,
123 kIntel,
124 kHuawei,
125 kSamsung,
126 //----------------------------------------------------------------------------
127 /// Includes the LLVM Pipe CPU implementation.
128 ///
129 kMesa,
130 //----------------------------------------------------------------------------
131 /// Includes Vulkan on Metal via MoltenVK.
132 ///
133 kApple,
134 };
135
136 enum class DeviceTypeVK {
137 kUnknown,
138 //----------------------------------------------------------------------------
139 /// The device is an integrated GPU. Typically mobile GPUs.
140 ///
141 kIntegratedGPU,
142 //----------------------------------------------------------------------------
143 /// The device is a discrete GPU. Typically desktop GPUs.
144 ///
145 kDiscreteGPU,
146 //----------------------------------------------------------------------------
147 /// The device is a GPU in a virtualized environment.
148 ///
149 kVirtualGPU,
150 //----------------------------------------------------------------------------
151 /// There is no GPU. Vulkan is implemented on the CPU. This is typically
152 /// emulators like SwiftShader and LLVMPipe.
153 ///
154 kCPU,
155 };
156
157 // visible for testing.
158 AdrenoGPU GetAdrenoVersion(std::string_view version);
159
160 // visible for testing.
161 MaliGPU GetMaliVersion(std::string_view version);
162
163 //------------------------------------------------------------------------------
164 /// @brief Get information about the Vulkan driver.
165 ///
166 /// @warning Be extremely cautious about the information reported here. This
167 /// is self-reported information (by the driver) and may be
168 /// inaccurate and or inconsistent.
169 ///
170 /// Before gating features behind any of the information reported by
171 /// the driver, consider alternatives (extensions checks perhaps)
172 /// and try to get a reviewer buddy to convince you to avoid using
173 /// this.
174 ///
175 class DriverInfoVK {
176 public:
177 explicit DriverInfoVK(const vk::PhysicalDevice& device);
178
179 ~DriverInfoVK();
180
181 DriverInfoVK(const DriverInfoVK&) = delete;
182
183 DriverInfoVK& operator=(const DriverInfoVK&) = delete;
184
185 //----------------------------------------------------------------------------
186 /// @brief Gets the Vulkan API version. Should be at or above Vulkan 1.1
187 /// which is the Impeller baseline.
188 ///
189 /// @return The Vulkan API version.
190 ///
191 const Version& GetAPIVersion() const;
192
193 //----------------------------------------------------------------------------
194 /// @brief Get the vendor of the Vulkan implementation. This is a broad
195 /// check and includes multiple drivers and platforms.
196 ///
197 /// @return The vendor.
198 ///
199 const VendorVK& GetVendor() const;
200
201 //----------------------------------------------------------------------------
202 /// @brief Get the device type. Typical use might be to check if the
203 /// device is a CPU implementation.
204 ///
205 /// @return The device type.
206 ///
207 const DeviceTypeVK& GetDeviceType() const;
208
209 //----------------------------------------------------------------------------
210 /// @brief Get the self-reported name of the graphics driver.
211 ///
212 /// @return The driver name.
213 ///
214 const std::string& GetDriverName() const;
215
216 //----------------------------------------------------------------------------
217 /// @brief Dumps the current driver info to the log.
218 ///
219 void DumpToLog() const;
220
221 //----------------------------------------------------------------------------
222 /// @brief Determines if the driver represents an emulator. There is no
223 /// definitive way to tell if a driver is an emulator and drivers
224 /// don't self identify as emulators. So take this information
225 /// with a pinch of salt.
226 ///
227 /// @return True if emulator, False otherwise.
228 ///
229 bool IsEmulator() const;
230
231 //----------------------------------------------------------------------------
232 /// @brief Determines if the driver has been tested and determined to be
233 /// non-functional.
234 ///
235 /// If true, context setup should fail such that the device falls
236 /// back to OpenGLES.
237 ///
238 /// @return True if non-functional device, False otherwise.
239 ///
240 bool IsKnownBadDriver() const;
241
242 //----------------------------------------------------------------------------
243 /// @brief Returns Mali GPU info if this is a Mali GPU, otherwise
244 /// std::nullopt.
245 ///
246 std::optional<MaliGPU> GetMaliGPUInfo() const;
247
248 //----------------------------------------------------------------------------
249 /// @brief Returns Adreno GPU info if this is a Adreno GPU, otherwise
250 /// std::nullopt.
251 ///
252 std::optional<AdrenoGPU> GetAdrenoGPUInfo() const;
253
254 private:
255 bool is_valid_ = false;
256 Version api_version_;
257 VendorVK vendor_ = VendorVK::kUnknown;
258 DeviceTypeVK type_ = DeviceTypeVK::kUnknown;
259 // If the VendorVK is VendorVK::kQualcomm, this will be populated with the
260 // identified Adreno GPU.
261 std::optional<AdrenoGPU> adreno_gpu_ = std::nullopt;
262 std::optional<MaliGPU> mali_gpu_ = std::nullopt;
263 std::string driver_name_;
264 };
265
266 } // namespace impeller
267
268 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
impeller::AdrenoGPU::kAdreno685
@ kAdreno685
impeller::MaliGPU::kG51
@ kG51
impeller::MaliGPU::kG310
@ kG310
impeller::AdrenoGPU::kAdreno530
@ kAdreno530
impeller::DriverInfoVK::GetVendor
const VendorVK & GetVendor() const
Get the vendor of the Vulkan implementation. This is a broad check and includes multiple drivers and ...
Definition: driver_info_vk.cc:278
impeller::DeviceTypeVK::kDiscreteGPU
@ kDiscreteGPU
impeller::DeviceTypeVK::kIntegratedGPU
@ kIntegratedGPU
impeller::MaliGPU::kG610
@ kG610
impeller::AdrenoGPU::kAdreno619L
@ kAdreno619L
impeller::AdrenoGPU::kAdreno720
@ kAdreno720
impeller::MaliGPU::kT820
@ kT820
impeller::DriverInfoVK::~DriverInfoVK
~DriverInfoVK()
impeller::AdrenoGPU::kAdreno644
@ kAdreno644
impeller::DriverInfoVK::GetDeviceType
const DeviceTypeVK & GetDeviceType() const
Get the device type. Typical use might be to check if the device is a CPU implementation.
Definition: driver_info_vk.cc:282
impeller::MaliGPU::kG710
@ kG710
impeller::AdrenoGPU::kAdreno735
@ kAdreno735
impeller::VendorVK::kPowerVR
@ kPowerVR
impeller::DriverInfoVK::DriverInfoVK
DriverInfoVK(const vk::PhysicalDevice &device)
Definition: driver_info_vk.cc:245
impeller::DriverInfoVK
Get information about the Vulkan driver.
Definition: driver_info_vk.h:175
impeller::AdrenoGPU::kAdreno509
@ kAdreno509
impeller::DriverInfoVK::IsEmulator
bool IsEmulator() const
Determines if the driver represents an emulator. There is no definitive way to tell if a driver is an...
Definition: driver_info_vk.cc:324
impeller::MaliGPU::kG68
@ kG68
impeller::MaliGPU::kG715
@ kG715
impeller::DriverInfoVK::GetAdrenoGPUInfo
std::optional< AdrenoGPU > GetAdrenoGPUInfo() const
Returns Adreno GPU info if this is a Adreno GPU, otherwise std::nullopt.
Definition: driver_info_vk.cc:369
impeller::AdrenoGPU::kAdreno618
@ kAdreno618
impeller::AdrenoGPU::kAdreno663
@ kAdreno663
impeller::DriverInfoVK::DumpToLog
void DumpToLog() const
Dumps the current driver info to the log.
Definition: driver_info_vk.cc:290
impeller::MaliGPU::kT760
@ kT760
impeller::AdrenoGPU::kAdreno730
@ kAdreno730
impeller::AdrenoGPU::kAdreno710
@ kAdreno710
impeller::MaliGPU::kG925
@ kG925
impeller::AdrenoGPU::kAdreno660
@ kAdreno660
impeller::AdrenoGPU::kAdrenoX145
@ kAdrenoX145
impeller::GetMaliVersion
MaliGPU GetMaliVersion(std::string_view version)
Definition: driver_info_vk.cc:122
version.h
impeller::Version
Definition: version.h:16
impeller::AdrenoGPU::kAdreno642
@ kAdreno642
impeller::AdrenoGPU::kAdreno650
@ kAdreno650
impeller::MaliGPU::kG620
@ kG620
impeller::AdrenoGPU::kAdreno640
@ kAdreno640
impeller::AdrenoGPU::kAdreno725
@ kAdreno725
impeller::AdrenoGPU::kAdreno680
@ kAdreno680
impeller::MaliGPU::kG52
@ kG52
impeller::MaliGPU::kG625
@ kG625
vk.h
impeller::AdrenoGPU::kAdreno504
@ kAdreno504
impeller::AdrenoGPU
AdrenoGPU
Definition: driver_info_vk.h:14
impeller::VendorVK::kARM
@ kARM
impeller::VendorVK::kGoogle
@ kGoogle
impeller::AdrenoGPU::kAdreno615
@ kAdreno615
impeller::AdrenoGPU::kAdreno643L
@ kAdreno643L
impeller::VendorVK::kAMD
@ kAMD
impeller::MaliGPU::kG76
@ kG76
impeller::AdrenoGPU::kAdreno690
@ kAdreno690
impeller::MaliGPU
MaliGPU
Definition: driver_info_vk.h:73
impeller::AdrenoGPU::kAdreno620
@ kAdreno620
impeller::AdrenoGPU::kAdreno505
@ kAdreno505
impeller::AdrenoGPU::kAdreno675
@ kAdreno675
impeller::VendorVK::kMesa
@ kMesa
impeller::VendorVK::kApple
@ kApple
impeller::AdrenoGPU::kAdreno506
@ kAdreno506
impeller::VendorVK::kImgTec
@ kImgTec
impeller::AdrenoGPU::kAdreno613
@ kAdreno613
impeller::AdrenoGPU::kUnknown
@ kUnknown
impeller::MaliGPU::kUnknown
@ kUnknown
impeller::MaliGPU::kT830
@ kT830
impeller::AdrenoGPU::kAdreno642L
@ kAdreno642L
impeller::MaliGPU::kG720
@ kG720
impeller::MaliGPU::kG72
@ kG72
impeller::VendorVK::kQualcomm
@ kQualcomm
impeller::AdrenoGPU::kAdreno732
@ kAdreno732
impeller::DeviceTypeVK::kVirtualGPU
@ kVirtualGPU
impeller::AdrenoGPU::kAdreno512
@ kAdreno512
impeller::DriverInfoVK::GetAPIVersion
const Version & GetAPIVersion() const
Gets the Vulkan API version. Should be at or above Vulkan 1.1 which is the Impeller baseline.
Definition: driver_info_vk.cc:274
impeller::MaliGPU::kG615
@ kG615
impeller::AdrenoGPU::kAdreno608
@ kAdreno608
impeller::AdrenoGPU::kAdreno702
@ kAdreno702
impeller::AdrenoGPU::kAdreno510
@ kAdreno510
impeller::DeviceTypeVK
DeviceTypeVK
Definition: driver_info_vk.h:136
impeller::AdrenoGPU::kAdreno616
@ kAdreno616
impeller::AdrenoGPU::kAdreno619
@ kAdreno619
impeller::DeviceTypeVK::kCPU
@ kCPU
impeller::VendorVK::kIntel
@ kIntel
impeller::MaliGPU::kG57
@ kG57
impeller::VendorVK
VendorVK
Definition: driver_info_vk.h:111
impeller::AdrenoGPU::kAdreno630
@ kAdreno630
impeller::VendorVK::kUnknown
@ kUnknown
impeller::MaliGPU::kG71
@ kG71
impeller::AdrenoGPU::kAdreno508
@ kAdreno508
impeller::VendorVK::kHuawei
@ kHuawei
impeller::AdrenoGPU::kAdreno695
@ kAdreno695
impeller::AdrenoGPU::kAdreno610
@ kAdreno610
impeller::AdrenoGPU::kAdreno750
@ kAdreno750
impeller::MaliGPU::kG31
@ kG31
impeller::MaliGPU::kT860
@ kT860
impeller::GetAdrenoVersion
AdrenoGPU GetAdrenoVersion(std::string_view version)
Definition: driver_info_vk.cc:108
impeller::AdrenoGPU::kAdreno740
@ kAdreno740
impeller::VendorVK::kNvidia
@ kNvidia
impeller::AdrenoGPU::kAdrenoX185
@ kAdrenoX185
impeller::DeviceTypeVK::kUnknown
@ kUnknown
impeller::DriverInfoVK::GetDriverName
const std::string & GetDriverName() const
Get the self-reported name of the graphics driver.
Definition: driver_info_vk.cc:286
impeller::AdrenoGPU::kAdreno605
@ kAdreno605
impeller::DriverInfoVK::operator=
DriverInfoVK & operator=(const DriverInfoVK &)=delete
impeller::DriverInfoVK::GetMaliGPUInfo
std::optional< MaliGPU > GetMaliGPUInfo() const
Returns Mali GPU info if this is a Mali GPU, otherwise std::nullopt.
Definition: driver_info_vk.cc:365
impeller::MaliGPU::kG78
@ kG78
impeller::MaliGPU::kG77
@ kG77
impeller::MaliGPU::kT880
@ kT880
impeller::MaliGPU::kG510
@ kG510
impeller
Definition: allocation.cc:12
impeller::VendorVK::kSamsung
@ kSamsung
impeller::DriverInfoVK::IsKnownBadDriver
bool IsKnownBadDriver() const
Determines if the driver has been tested and determined to be non-functional.
Definition: driver_info_vk.cc:335
impeller::MaliGPU::kG725
@ kG725
impeller::AdrenoGPU::kAdreno540
@ kAdreno540
impeller::AdrenoGPU::kAdreno612
@ kAdreno612