Flutter Engine
 
Loading...
Searching...
No Matches
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
10
11namespace impeller {
12
13// https://en.wikipedia.org/wiki/Adreno
14enum 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
27 // 600s
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.
55 // 700s
65 // X
68 // Unknown GPU, likely newer model.
70};
71
72// https://en.wikipedia.org/wiki/Mali_(processor)
73enum 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.
114enum 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
131enum class VendorVK {
132 kUnknown,
133 //----------------------------------------------------------------------------
134 /// Includes the SwiftShader CPU implementation.
135 ///
136 kGoogle,
137 kQualcomm,
138 kARM,
139 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
156enum class DeviceTypeVK {
157 kUnknown,
158 //----------------------------------------------------------------------------
159 /// The device is an integrated GPU. Typically mobile GPUs.
160 ///
162 //----------------------------------------------------------------------------
163 /// The device is a discrete GPU. Typically desktop GPUs.
164 ///
166 //----------------------------------------------------------------------------
167 /// The device is a GPU in a virtualized environment.
168 ///
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.
178AdrenoGPU GetAdrenoVersion(std::string_view version);
179
180// visible for testing.
181MaliGPU 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///
196 public:
197 explicit DriverInfoVK(const vk::PhysicalDevice& device);
198
200
201 DriverInfoVK(const DriverInfoVK&) = delete;
202
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_;
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_
Get information about the Vulkan driver.
const VendorVK & GetVendor() const
Get the vendor of the Vulkan implementation. This is a broad check and includes multiple drivers and ...
DriverInfoVK & operator=(const DriverInfoVK &)=delete
std::optional< PowerVRGPU > GetPowerVRGPUInfo() const
Returns PowerVR GPU info if this is a PowerVR GPU, otherwise std::nullopt.
bool IsKnownBadDriver() const
Determines if the driver has been tested and determined to be non-functional.
const std::string & GetDriverName() const
Get the self-reported name of the graphics driver.
std::optional< AdrenoGPU > GetAdrenoGPUInfo() const
Returns Adreno GPU info if this is a Adreno GPU, otherwise std::nullopt.
void DumpToLog() const
Dumps the current driver info to the log.
std::optional< MaliGPU > GetMaliGPUInfo() const
Returns Mali GPU info if this is a Mali GPU, otherwise std::nullopt.
DriverInfoVK(const DriverInfoVK &)=delete
bool IsEmulator() const
Determines if the driver represents an emulator. There is no definitive way to tell if a driver is an...
const DeviceTypeVK & GetDeviceType() const
Get the device type. Typical use might be to check if the device is a CPU implementation.
const Version & GetAPIVersion() const
Gets the Vulkan API version. Should be at or above Vulkan 1.1 which is the Impeller baseline.
VkDevice device
Definition main.cc:69
MaliGPU GetMaliVersion(std::string_view version)
AdrenoGPU GetAdrenoVersion(std::string_view version)