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