| Flutter Impeller |

Public Member Functions | List of all members
impeller::DriverInfoVK Class Reference

Get information about the Vulkan driver. More...

`#include <driver_info_vk.h>`

## Public Member Functions
| DriverInfoVK (const vk::PhysicalDevice &device)
| ~DriverInfoVK ()
| DriverInfoVK (const DriverInfoVK &)=delete
DriverInfoVK & | operator= (const DriverInfoVK &)=delete
const Version & | GetAPIVersion () const
| Gets the Vulkan API version. Should be at or above Vulkan 1.1 which is the Impeller baseline. More...
const VendorVK & | GetVendor () const
| Get the vendor of the Vulkan implementation. This is a broad check and includes multiple drivers and platforms. More...
const DeviceTypeVK & | GetDeviceType () const
| Get the device type. Typical use might be to check if the device is a CPU implementation. More...
const std::string & | GetDriverName () const
| Get the self-reported name of the graphics driver. More...
void | DumpToLog () const
| Dumps the current driver info to the log. More...
bool | IsEmulator () const
| Determines if the driver represents an emulator. There is no definitive way to tell if a driver is an emulator and drivers don't self identify as emulators. So take this information with a pinch of salt. More...
bool | IsKnownBadDriver () const
| Determines if the driver has been tested and determined to be non-functional. More...
std::optional< MaliGPU > | GetMaliGPUInfo () const
| Returns Mali GPU info if this is a Mali GPU, otherwise std::nullopt. More...
std::optional< AdrenoGPU > | GetAdrenoGPUInfo () const
| Returns Adreno GPU info if this is a Adreno GPU, otherwise std::nullopt. More...

## Detailed Description

Get information about the Vulkan driver.

Warning
  Be extremely cautious about the information reported here. This is self-reported information (by the driver) and may be inaccurate and or inconsistent.

Before gating features behind any of the information reported by the driver, consider alternatives (extensions checks perhaps) and try to get a reviewer buddy to convince you to avoid using this.

Definition at line 175 of file driver_info_vk.h.

## Constructor & Destructor Documentation

## ◆ DriverInfoVK() [1/2]

impeller::DriverInfoVK::DriverInfoVK | ( | const vk::PhysicalDevice & | device | ) |
| explicit

Definition at line 245 of file driver_info_vk.cc.

245 {
246 auto props = device.getProperties();
247 api_version_ = Version{VK_API_VERSION_MAJOR(props.apiVersion),
248 VK_API_VERSION_MINOR(props.apiVersion),
249 VK_API_VERSION_PATCH(props.apiVersion)};
250 vendor_ = IdentifyVendor(props.vendorID);
251 if (vendor_ == VendorVK::kUnknown) {
252 FML_LOG(WARNING) << "Unknown GPU Driver Vendor: " << props.vendorID
253 << ". This is not an error.";
254 }
255 type_ = ToDeviceType(props.deviceType);
256 if (props.deviceName.data() != nullptr) {
257 driver_name_ = props.deviceName.data();
258 }
259
260 switch (vendor_) {
261 case VendorVK::kQualcomm:
262 adreno_gpu_ = GetAdrenoVersion(driver_name_);
263 break;
264 case VendorVK::kARM:
265 mali_gpu_ = GetMaliVersion(driver_name_);
266 break;
267 default:
268 break;
269 }
270 }

References impeller::GetAdrenoVersion(), impeller::GetMaliVersion(), impeller::IdentifyVendor(), impeller::kARM, impeller::kQualcomm, impeller::kUnknown, and impeller::ToDeviceType().

## ◆ ~DriverInfoVK()

impeller::DriverInfoVK::~DriverInfoVK | ( |  | ) |
| default

## ◆ DriverInfoVK() [2/2]

impeller::DriverInfoVK::DriverInfoVK | ( | const DriverInfoVK & |  | ) |
| delete

## Member Function Documentation

## ◆ DumpToLog()

void impeller::DriverInfoVK::DumpToLog | ( |  | ) | const

Dumps the current driver info to the log.

Definition at line 290 of file driver_info_vk.cc.

290 {
291 std::vector<std::pair<std::string, std::string>> items;
292 items.emplace_back("Name", driver_name_);
293 items.emplace_back("API Version", api_version_.ToString());
294 items.emplace_back("Vendor", VendorToString(vendor_));
295 items.emplace_back("Device Type", DeviceTypeToString(type_));
296 items.emplace_back("Is Emulator", std::to_string(IsEmulator()));
297
298 size_t padding = 0;
299
300 for (const auto& item : items) {
301 padding = std::max(padding, item.first.size());
302 }
303
304 padding += 1;
305
306 std::stringstream stream;
307
308 stream << std::endl;
309
310 stream << "--- Driver Information ------------------------------------------";
311
312 stream << std::endl;
313
314 for (const auto& item : items) {
315 stream << "| " << std::setw(static_cast<int>(padding)) << item.first
316 << std::setw(0) << ": " << item.second << std::endl;
317 }
318
319 stream << "-----------------------------------------------------------------";
320
321 FML_LOG(IMPORTANT) << stream.str();
322 }

References impeller::DeviceTypeToString(), IsEmulator(), padding, impeller::Version::ToString(), and impeller::VendorToString().

## ◆ GetAdrenoGPUInfo()

std::optional< AdrenoGPU > impeller::DriverInfoVK::GetAdrenoGPUInfo | ( |  | ) | const

Returns Adreno GPU info if this is a Adreno GPU, otherwise std::nullopt.

Definition at line 369 of file driver_info_vk.cc.

369 {
370 return adreno_gpu_;
371 }

Referenced by impeller::GetWorkaroundsFromDriverInfo().

## ◆ GetAPIVersion()

const Version & impeller::DriverInfoVK::GetAPIVersion | ( |  | ) | const

Gets the Vulkan API version. Should be at or above Vulkan 1.1 which is the Impeller baseline.

Returns
  The Vulkan API version.

Definition at line 274 of file driver_info_vk.cc.

274 {
275 return api_version_;
276 }

## ◆ GetDeviceType()

const DeviceTypeVK & impeller::DriverInfoVK::GetDeviceType | ( |  | ) | const

Get the device type. Typical use might be to check if the device is a CPU implementation.

Returns
  The device type.

Definition at line 282 of file driver_info_vk.cc.

282 {
283 return type_;
284 }

## ◆ GetDriverName()

const std::string & impeller::DriverInfoVK::GetDriverName | ( |  | ) | const

Get the self-reported name of the graphics driver.

Returns
  The driver name.

Definition at line 286 of file driver_info_vk.cc.

286 {
287 return driver_name_;
288 }

## ◆ GetMaliGPUInfo()

std::optional< MaliGPU > impeller::DriverInfoVK::GetMaliGPUInfo | ( |  | ) | const

Returns Mali GPU info if this is a Mali GPU, otherwise std::nullopt.

Definition at line 365 of file driver_info_vk.cc.

365 {
366 return mali_gpu_;
367 }

Referenced by impeller::GetWorkaroundsFromDriverInfo().

## ◆ GetVendor()

const VendorVK & impeller::DriverInfoVK::GetVendor | ( |  | ) | const

Get the vendor of the Vulkan implementation. This is a broad check and includes multiple drivers and platforms.

Returns
  The vendor.

Definition at line 278 of file driver_info_vk.cc.

278 {
279 return vendor_;
280 }

## ◆ IsEmulator()

bool impeller::DriverInfoVK::IsEmulator | ( |  | ) | const

Determines if the driver represents an emulator. There is no definitive way to tell if a driver is an emulator and drivers don't self identify as emulators. So take this information with a pinch of salt.

Returns
  True if emulator, False otherwise.

Definition at line 324 of file driver_info_vk.cc.

324 {
325 #if FML_OS_ANDROID
326 // Google SwiftShader on Android.
327 if (type_ == DeviceTypeVK::kCPU && vendor_ == VendorVK::kGoogle &&
328 driver_name_.find("SwiftShader") != std::string::npos) {
329 return true;
330 }
331 #endif // FML_OS_ANDROID
332 return false;
333 }

References impeller::kCPU, and impeller::kGoogle.

Referenced by DumpToLog().

## ◆ IsKnownBadDriver()

bool impeller::DriverInfoVK::IsKnownBadDriver | ( |  | ) | const

Determines if the driver has been tested and determined to be non-functional.

If true, context setup should fail such that the device falls back to OpenGLES.

Returns
  True if non-functional device, False otherwise.

Definition at line 335 of file driver_info_vk.cc.

335 {
336 // Disable Maleoon series GPUs, see:
337 // https://github.com/flutter/flutter/issues/156623
338 if (vendor_ == VendorVK::kHuawei) {
339 return true;
340 }
341
342 if (vendor_ == VendorVK::kSamsung) {
343 // The first version of the Xclipse series GPU has reported
344 // bugs, unfortunately all versions of this GPU report the
345 // same driver version. Instead we use the Vulkan version
346 // as a proxy, assuming that any newer devices would not
347 // lower the supported Vulkan API level.
348 // See
349 // https://vulkan.gpuinfo.org/listreports.php?devicename=samsung+SM-S906B&platform=android
350 // https://github.com/flutter/flutter/issues/161334
351 return !api_version_.IsAtLeast(Version{1, 3, 0});
352 }
353
354 // https://github.com/flutter/flutter/issues/161122
355 // https://github.com/flutter/flutter/issues/160960
356 // https://github.com/flutter/flutter/issues/160866
357 // https://github.com/flutter/flutter/issues/160804
358 // https://github.com/flutter/flutter/issues/160406
359 if (vendor_ == VendorVK::kImgTec) {
360 return true;
361 }
362 return false;
363 }

References impeller::Version::IsAtLeast(), impeller::kHuawei, impeller::kImgTec, and impeller::kSamsung.

## ◆ operator=()

DriverInfoVK& impeller::DriverInfoVK::operator= | ( | const DriverInfoVK & |  | ) |
| delete

The documentation for this class was generated from the following files:

- impeller/renderer/backend/vulkan/driver_info_vk.h
- impeller/renderer/backend/vulkan/driver_info_vk.cc

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
padding
Vector2 padding
The halo padding in source space.
Definition: gaussian_blur_filter_contents.cc:86
impeller::GetMaliVersion
MaliGPU GetMaliVersion(std::string_view version)
Definition: driver_info_vk.cc:122
impeller::VendorVK::kARM
@ kARM
impeller::VendorVK::kGoogle
@ kGoogle
impeller::Version::ToString
std::string ToString() const
Definition: version.cc:27
impeller::VendorVK::kImgTec
@ kImgTec
impeller::VendorToString
constexpr const char * VendorToString(VendorVK vendor)
Definition: driver_info_vk.cc:182
impeller::VendorVK::kQualcomm
@ kQualcomm
impeller::DeviceTypeVK::kCPU
@ kCPU
impeller::VendorVK::kUnknown
@ kUnknown
impeller::IdentifyVendor
constexpr VendorVK IdentifyVendor(uint32_t vendor)
Definition: driver_info_vk.cc:143
impeller::VendorVK::kHuawei
@ kHuawei
impeller::GetAdrenoVersion
AdrenoGPU GetAdrenoVersion(std::string_view version)
Definition: driver_info_vk.cc:108
impeller::Version::IsAtLeast
constexpr bool IsAtLeast(const Version &other) const
Definition: version.h:31
impeller::DeviceTypeToString
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
Definition: driver_info_vk.cc:212
impeller::VendorVK::kSamsung
@ kSamsung
impeller::ToDeviceType
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
Definition: driver_info_vk.cc:228