| 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 // Ordered by approximate release date. We currently don't attempt to
112 // parse the exact power VR GPU variant so newer names will fall back
113 // to OpenGL. This is acceptable for now.
114 enum class PowerVRGPU {
115 kUnknown,
116 // Not good.
117 kRogue,
118 // Vulkan may work, but not tested.
119 kAXE,
120 kAXM,
121 kAXT,
122 kBXE,
123 kBXM,
124 kBXS,
125 kBXT,
126 // First good vulkan drivers.
127 kCXT,
128 kDXT,
129 };
130
131 enum class VendorVK {
132 kUnknown,
133 //----------------------------------------------------------------------------
134 /// Includes the SwiftShader CPU implementation.
135 ///
136 kGoogle,
137 kQualcomm,
138 kARM,
139 kImgTec,
140 kPowerVR = kImgTec,
141 kAMD,
142 kNvidia,
143 kIntel,
144 kHuawei,
145 kSamsung,
146 //----------------------------------------------------------------------------
147 /// Includes the LLVM Pipe CPU implementation.
148 ///
149 kMesa,
150 //----------------------------------------------------------------------------
151 /// Includes Vulkan on Metal via MoltenVK.
152 ///
153 kApple,
154 };
155
156 enum class DeviceTypeVK {
157 kUnknown,
158 //----------------------------------------------------------------------------
159 /// The device is an integrated GPU. Typically mobile GPUs.
160 ///
161 kIntegratedGPU,
162 //----------------------------------------------------------------------------
163 /// The device is a discrete GPU. Typically desktop GPUs.
164 ///
165 kDiscreteGPU,
166 //----------------------------------------------------------------------------
167 /// The device is a GPU in a virtualized environment.
168 ///
169 kVirtualGPU,
170 //----------------------------------------------------------------------------
171 /// There is no GPU. Vulkan is implemented on the CPU. This is typically
172 /// emulators like SwiftShader and LLVMPipe.
173 ///
174 kCPU,
175 };
176
177 // visible for testing.
178 AdrenoGPU GetAdrenoVersion(std::string_view version);
179
180 // visible for testing.
181 MaliGPU GetMaliVersion(std::string_view version);
182
183 //------------------------------------------------------------------------------
184 /// @brief Get information about the Vulkan driver.
185 ///
186 /// @warning Be extremely cautious about the information reported here. This
187 /// is self-reported information (by the driver) and may be
188 /// inaccurate and or inconsistent.
189 ///
190 /// Before gating features behind any of the information reported by
191 /// the driver, consider alternatives (extensions checks perhaps)
192 /// and try to get a reviewer buddy to convince you to avoid using
193 /// this.
194 ///
195 class DriverInfoVK {
196 public:
197 explicit DriverInfoVK(const vk::PhysicalDevice& device);
198
199 ~DriverInfoVK();
200
201 DriverInfoVK(const DriverInfoVK&) = delete;
202
203 DriverInfoVK& operator=(const DriverInfoVK&) = delete;
204
205 //----------------------------------------------------------------------------
206 /// @brief Gets the Vulkan API version. Should be at or above Vulkan 1.1
207 /// which is the Impeller baseline.
208 ///
209 /// @return The Vulkan API version.
210 ///
211 const Version& GetAPIVersion() const;
212
213 //----------------------------------------------------------------------------
214 /// @brief Get the vendor of the Vulkan implementation. This is a broad
215 /// check and includes multiple drivers and platforms.
216 ///
217 /// @return The vendor.
218 ///
219 const VendorVK& GetVendor() const;
220
221 //----------------------------------------------------------------------------
222 /// @brief Get the device type. Typical use might be to check if the
223 /// device is a CPU implementation.
224 ///
225 /// @return The device type.
226 ///
227 const DeviceTypeVK& GetDeviceType() const;
228
229 //----------------------------------------------------------------------------
230 /// @brief Get the self-reported name of the graphics driver.
231 ///
232 /// @return The driver name.
233 ///
234 const std::string& GetDriverName() const;
235
236 //----------------------------------------------------------------------------
237 /// @brief Dumps the current driver info to the log.
238 ///
239 void DumpToLog() const;
240
241 //----------------------------------------------------------------------------
242 /// @brief Determines if the driver represents an emulator. There is no
243 /// definitive way to tell if a driver is an emulator and drivers
244 /// don't self identify as emulators. So take this information
245 /// with a pinch of salt.
246 ///
247 /// @return True if emulator, False otherwise.
248 ///
249 bool IsEmulator() const;
250
251 //----------------------------------------------------------------------------
252 /// @brief Determines if the driver has been tested and determined to be
253 /// non-functional.
254 ///
255 /// If true, context setup should fail such that the device falls
256 /// back to OpenGLES.
257 ///
258 /// @return True if non-functional device, False otherwise.
259 ///
260 bool IsKnownBadDriver() const;
261
262 //----------------------------------------------------------------------------
263 /// @brief Returns Mali GPU info if this is a Mali GPU, otherwise
264 /// std::nullopt.
265 ///
266 std::optional<MaliGPU> GetMaliGPUInfo() const;
267
268 //----------------------------------------------------------------------------
269 /// @brief Returns Adreno GPU info if this is a Adreno GPU, otherwise
270 /// std::nullopt.
271 ///
272 std::optional<AdrenoGPU> GetAdrenoGPUInfo() const;
273
274 //----------------------------------------------------------------------------
275 /// @brief Returns PowerVR GPU info if this is a PowerVR GPU, otherwise
276 /// std::nullopt.
277 ///
278 std::optional<PowerVRGPU> GetPowerVRGPUInfo() const;
279
280 private:
281 bool is_valid_ = false;
282 Version api_version_;
283 VendorVK vendor_ = VendorVK::kUnknown;
284 DeviceTypeVK type_ = DeviceTypeVK::kUnknown;
285 // If the VendorVK is VendorVK::kQualcomm, this will be populated with the
286 // identified Adreno GPU.
287 std::optional<AdrenoGPU> adreno_gpu_ = std::nullopt;
288 std::optional<MaliGPU> mali_gpu_ = std::nullopt;
289 std::optional<PowerVRGPU> powervr_gpu_ = std::nullopt;
290 std::string driver_name_;
291 };
292
293 } // namespace impeller
294
295 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
impeller::DriverInfoVK
Get information about the Vulkan driver.
Definition: driver_info_vk.h:195
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:303
impeller::DriverInfoVK::DriverInfoVK
DriverInfoVK(const vk::PhysicalDevice &device)
Definition: driver_info_vk.cc:267
impeller::DriverInfoVK::GetPowerVRGPUInfo
std::optional< PowerVRGPU > GetPowerVRGPUInfo() const
Returns PowerVR GPU info if this is a PowerVR GPU, otherwise std::nullopt.
Definition: driver_info_vk.cc:398
impeller::DriverInfoVK::IsKnownBadDriver
bool IsKnownBadDriver() const
Determines if the driver has been tested and determined to be non-functional.
Definition: driver_info_vk.cc:360
impeller::DriverInfoVK::~DriverInfoVK
~DriverInfoVK()
impeller::DriverInfoVK::GetDriverName
const std::string & GetDriverName() const
Get the self-reported name of the graphics driver.
Definition: driver_info_vk.cc:311
impeller::DriverInfoVK::operator=
DriverInfoVK & operator=(const DriverInfoVK &)=delete
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:394
impeller::DriverInfoVK::DumpToLog
void DumpToLog() const
Dumps the current driver info to the log.
Definition: driver_info_vk.cc:315
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:390
impeller::DriverInfoVK::DriverInfoVK
DriverInfoVK(const DriverInfoVK &)=delete
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:349
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:307
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:299
impeller
Definition: allocation.cc:12
impeller::MaliGPU
MaliGPU
Definition: driver_info_vk.h:73
impeller::MaliGPU::kG310
@ kG310
impeller::MaliGPU::kG77
@ kG77
impeller::MaliGPU::kG620
@ kG620
impeller::MaliGPU::kUnknown
@ kUnknown
impeller::MaliGPU::kT820
@ kT820
impeller::MaliGPU::kG51
@ kG51
impeller::MaliGPU::kG720
@ kG720
impeller::MaliGPU::kG725
@ kG725
impeller::MaliGPU::kG610
@ kG610
impeller::MaliGPU::kG68
@ kG68
impeller::MaliGPU::kG715
@ kG715
impeller::MaliGPU::kT830
@ kT830
impeller::MaliGPU::kG57
@ kG57
impeller::MaliGPU::kG625
@ kG625
impeller::MaliGPU::kT880
@ kT880
impeller::MaliGPU::kT860
@ kT860
impeller::MaliGPU::kG615
@ kG615
impeller::MaliGPU::kG78
@ kG78
impeller::MaliGPU::kG52
@ kG52
impeller::MaliGPU::kG925
@ kG925
impeller::MaliGPU::kG72
@ kG72
impeller::MaliGPU::kG510
@ kG510
impeller::MaliGPU::kG76
@ kG76
impeller::MaliGPU::kT760
@ kT760
impeller::MaliGPU::kG71
@ kG71
impeller::MaliGPU::kG710
@ kG710
impeller::MaliGPU::kG31
@ kG31
impeller::VendorVK
VendorVK
Definition: driver_info_vk.h:131
impeller::VendorVK::kUnknown
@ kUnknown
impeller::VendorVK::kImgTec
@ kImgTec
impeller::VendorVK::kIntel
@ kIntel
impeller::VendorVK::kSamsung
@ kSamsung
impeller::VendorVK::kGoogle
@ kGoogle
impeller::VendorVK::kPowerVR
@ kPowerVR
impeller::VendorVK::kHuawei
@ kHuawei
impeller::VendorVK::kApple
@ kApple
impeller::VendorVK::kQualcomm
@ kQualcomm
impeller::VendorVK::kNvidia
@ kNvidia
impeller::VendorVK::kMesa
@ kMesa
impeller::VendorVK::kARM
@ kARM
impeller::VendorVK::kAMD
@ kAMD
impeller::AdrenoGPU
AdrenoGPU
Definition: driver_info_vk.h:14
impeller::AdrenoGPU::kAdrenoX145
@ kAdrenoX145
impeller::AdrenoGPU::kAdreno618
@ kAdreno618
impeller::AdrenoGPU::kAdreno690
@ kAdreno690
impeller::AdrenoGPU::kAdreno630
@ kAdreno630
impeller::AdrenoGPU::kAdreno642
@ kAdreno642
impeller::AdrenoGPU::kAdreno730
@ kAdreno730
impeller::AdrenoGPU::kAdreno509
@ kAdreno509
impeller::AdrenoGPU::kAdreno642L
@ kAdreno642L
impeller::AdrenoGPU::kAdreno750
@ kAdreno750
impeller::AdrenoGPU::kUnknown
@ kUnknown
impeller::AdrenoGPU::kAdreno615
@ kAdreno615
impeller::AdrenoGPU::kAdreno510
@ kAdreno510
impeller::AdrenoGPU::kAdreno610
@ kAdreno610
impeller::AdrenoGPU::kAdreno680
@ kAdreno680
impeller::AdrenoGPU::kAdreno695
@ kAdreno695
impeller::AdrenoGPU::kAdreno725
@ kAdreno725
impeller::AdrenoGPU::kAdreno740
@ kAdreno740
impeller::AdrenoGPU::kAdreno720
@ kAdreno720
impeller::AdrenoGPU::kAdreno685
@ kAdreno685
impeller::AdrenoGPU::kAdreno613
@ kAdreno613
impeller::AdrenoGPU::kAdrenoX185
@ kAdrenoX185
impeller::AdrenoGPU::kAdreno506
@ kAdreno506
impeller::AdrenoGPU::kAdreno505
@ kAdreno505
impeller::AdrenoGPU::kAdreno702
@ kAdreno702
impeller::AdrenoGPU::kAdreno605
@ kAdreno605
impeller::AdrenoGPU::kAdreno619L
@ kAdreno619L
impeller::AdrenoGPU::kAdreno732
@ kAdreno732
impeller::AdrenoGPU::kAdreno650
@ kAdreno650
impeller::AdrenoGPU::kAdreno643L
@ kAdreno643L
impeller::AdrenoGPU::kAdreno540
@ kAdreno540
impeller::AdrenoGPU::kAdreno620
@ kAdreno620
impeller::AdrenoGPU::kAdreno530
@ kAdreno530
impeller::AdrenoGPU::kAdreno619
@ kAdreno619
impeller::AdrenoGPU::kAdreno735
@ kAdreno735
impeller::AdrenoGPU::kAdreno612
@ kAdreno612
impeller::AdrenoGPU::kAdreno710
@ kAdreno710
impeller::AdrenoGPU::kAdreno640
@ kAdreno640
impeller::AdrenoGPU::kAdreno663
@ kAdreno663
impeller::AdrenoGPU::kAdreno508
@ kAdreno508
impeller::AdrenoGPU::kAdreno675
@ kAdreno675
impeller::AdrenoGPU::kAdreno608
@ kAdreno608
impeller::AdrenoGPU::kAdreno644
@ kAdreno644
impeller::AdrenoGPU::kAdreno616
@ kAdreno616
impeller::AdrenoGPU::kAdreno660
@ kAdreno660
impeller::AdrenoGPU::kAdreno504
@ kAdreno504
impeller::AdrenoGPU::kAdreno512
@ kAdreno512
impeller::PowerVRGPU
PowerVRGPU
Definition: driver_info_vk.h:114
impeller::PowerVRGPU::kAXT
@ kAXT
impeller::PowerVRGPU::kAXM
@ kAXM
impeller::PowerVRGPU::kUnknown
@ kUnknown
impeller::PowerVRGPU::kCXT
@ kCXT
impeller::PowerVRGPU::kBXS
@ kBXS
impeller::PowerVRGPU::kBXT
@ kBXT
impeller::PowerVRGPU::kBXE
@ kBXE
impeller::PowerVRGPU::kRogue
@ kRogue
impeller::PowerVRGPU::kAXE
@ kAXE
impeller::PowerVRGPU::kDXT
@ kDXT
impeller::PowerVRGPU::kBXM
@ kBXM
impeller::GetMaliVersion
MaliGPU GetMaliVersion(std::string_view version)
Definition: driver_info_vk.cc:144
impeller::GetAdrenoVersion
AdrenoGPU GetAdrenoVersion(std::string_view version)
Definition: driver_info_vk.cc:120
impeller::DeviceTypeVK
DeviceTypeVK
Definition: driver_info_vk.h:156
impeller::DeviceTypeVK::kVirtualGPU
@ kVirtualGPU
impeller::DeviceTypeVK::kUnknown
@ kUnknown
impeller::DeviceTypeVK::kCPU
@ kCPU
impeller::DeviceTypeVK::kIntegratedGPU
@ kIntegratedGPU
impeller::DeviceTypeVK::kDiscreteGPU
@ kDiscreteGPU
impeller::Version
Definition: version.h:16
version.h
vk.h