| 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...
std::optional< PowerVRGPU > | GetPowerVRGPUInfo () const
| Returns PowerVR GPU info if this is a PowerVR 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 195 of file driver_info_vk.h.

## Constructor & Destructor Documentation

## ◆ DriverInfoVK() [1/2]

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

Definition at line 281 of file driver_info_vk.cc.

281 {
282 auto props = device.getProperties();
283 api_version_ = Version{VK_API_VERSION_MAJOR(props.apiVersion),
284 VK_API_VERSION_MINOR(props.apiVersion),
285 VK_API_VERSION_PATCH(props.apiVersion)};
286 driver_version_ = props.driverVersion;
287 device_id_ = props.deviceID;
288 vendor_ = IdentifyVendor(props.vendorID);
289 if (vendor_ == VendorVK::kUnknown) {
290 FML_LOG(WARNING) << "Unknown GPU Driver Vendor: " << props.vendorID
291 << ". This is not an error.";
292 }
293 type_ = ToDeviceType(props.deviceType);
294 if (props.deviceName.data() != nullptr) {
295 driver_name_ = props.deviceName.data();
296 }
297
298 switch (vendor_) {
299 case VendorVK::kQualcomm:
300 adreno_gpu_ = GetAdrenoVersion(driver_name_);
301 break;
302 case VendorVK::kARM:
303 mali_gpu_ = GetMaliVersion(driver_name_);
304 break;
305 case VendorVK::kPowerVR:
306 powervr_gpu_ = GetPowerVRVersion(driver_name_);
307 break;
308 default:
309 break;
310 }
311 }
impeller::VendorVK::kUnknown
@ kUnknown
impeller::VendorVK::kPowerVR
@ kPowerVR
impeller::VendorVK::kQualcomm
@ kQualcomm
impeller::VendorVK::kARM
@ kARM
impeller::IdentifyVendor
constexpr VendorVK IdentifyVendor(uint32_t vendor)
Definition: driver_info_vk.cc:179
impeller::GetMaliVersion
MaliGPU GetMaliVersion(std::string_view version)
Definition: driver_info_vk.cc:158
impeller::GetAdrenoVersion
AdrenoGPU GetAdrenoVersion(std::string_view version)
Definition: driver_info_vk.cc:134
impeller::GetPowerVRVersion
PowerVRGPU GetPowerVRVersion(std::string_view version)
Definition: driver_info_vk.cc:148
impeller::ToDeviceType
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
Definition: driver_info_vk.cc:264

References impeller::GetAdrenoVersion(), impeller::GetMaliVersion(), impeller::GetPowerVRVersion(), impeller::IdentifyVendor(), impeller::kARM, impeller::kPowerVR, 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 331 of file driver_info_vk.cc.

331 {
332 std::vector<std::pair<std::string, std::string>> items;
333 items.emplace_back("Name", driver_name_);
334 items.emplace_back("API Version", api_version_.ToString());
335 items.emplace_back("Driver Version", std::to_string(driver_version_));
336 items.emplace_back("Vendor", VendorToString(vendor_));
337 items.emplace_back("Device Type", DeviceTypeToString(type_));
338 items.emplace_back("Is Emulator", std::to_string(IsEmulator()));
339
340 size_t padding = 0;
341
342 for (const auto& item : items) {
343 padding = std::max(padding, item.first.size());
344 }
345
346 padding += 1;
347
348 std::stringstream stream;
349
350 stream << std::endl;
351
352 stream << "--- Driver Information ------------------------------------------";
353
354 stream << std::endl;
355
356 for (const auto& item : items) {
357 stream << "| " << std::setw(static_cast<int>(padding)) << item.first
358 << std::setw(0) << ": " << item.second << std::endl;
359 }
360
361 stream << "-----------------------------------------------------------------";
362
363 FML_LOG(IMPORTANT) << stream.str();
364 }
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:366
padding
Vector2 padding
The halo padding in source space.
Definition: gaussian_blur_filter_contents.cc:87
impeller::VendorToString
constexpr const char * VendorToString(VendorVK vendor)
Definition: driver_info_vk.cc:218
impeller::DeviceTypeToString
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
Definition: driver_info_vk.cc:248
impeller::Version::ToString
std::string ToString() const
Definition: version.cc:27

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 435 of file driver_info_vk.cc.

435 {
436 return adreno_gpu_;
437 }

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 315 of file driver_info_vk.cc.

315 {
316 return api_version_;
317 }

## ◆ 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 323 of file driver_info_vk.cc.

323 {
324 return type_;
325 }

## ◆ GetDriverName()

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

Get the self-reported name of the graphics driver.

Returns
  The driver name.

Definition at line 327 of file driver_info_vk.cc.

327 {
328 return driver_name_;
329 }

## ◆ GetMaliGPUInfo()

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

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

Definition at line 431 of file driver_info_vk.cc.

431 {
432 return mali_gpu_;
433 }

## ◆ GetPowerVRGPUInfo()

std::optional< PowerVRGPU > impeller::DriverInfoVK::GetPowerVRGPUInfo | ( |  | ) | const

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

Definition at line 439 of file driver_info_vk.cc.

439 {
440 return powervr_gpu_;
441 }

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 319 of file driver_info_vk.cc.

319 {
320 return vendor_;
321 }

## ◆ 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 366 of file driver_info_vk.cc.

366 {
367 #if FML_OS_ANDROID
368 // Google SwiftShader on Android.
369 if (type_ == DeviceTypeVK::kCPU && vendor_ == VendorVK::kGoogle &&
370 driver_name_.find("SwiftShader") != std::string::npos) {
371 return true;
372 }
373 #endif // FML_OS_ANDROID
374 return false;
375 }
impeller::VendorVK::kGoogle
@ kGoogle
impeller::DeviceTypeVK::kCPU
@ kCPU

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 377 of file driver_info_vk.cc.

377 {
378 #if FML_OS_ANDROID
379 // Pixel 10 is identified by the PowerVR vendor and device ID 0x71061212.
380 // The driver version 25.1 or greater is required - which is device specific
381 // to 6794074 or greater.
382 if (vendor_ == VendorVK::kPowerVR && device_id_ == kPixel10DeviceID &&
383 driver_version_ < kPixel10MinDriverVersion) {
384 FML_LOG(WARNING) << "Pixel 10 driver version "
385 << std::to_string(driver_version_)
386 << " is less than 25.1. Blocking Vulkan initialization.";
387 return true;
388 }
389 #endif // FML_OS_ANDROID
390
391 // Fall back to OpenGL ES on older Adreno devices that require additional
392 // workarounds in the Impeller Vulkan back end such as disabling framebuffer
393 // fetch.
394 //
395 // See the following issues:
396 // https://github.com/flutter/flutter/issues/178285
397 // https://github.com/flutter/flutter/issues/178498
398 if (adreno_gpu_ && *adreno_gpu_ <= AdrenoGPU::kAdreno650) {
399 return true;
400 }
401
402 // Disable Maleoon series GPUs, see:
403 // https://github.com/flutter/flutter/issues/156623
404 if (vendor_ == VendorVK::kHuawei) {
405 return true;
406 }
407
408 if (vendor_ == VendorVK::kSamsung) {
409 // The first version of the Xclipse series GPU has reported
410 // bugs, unfortunately all versions of this GPU report the
411 // same driver version. Instead we use the Vulkan version
412 // as a proxy, assuming that any newer devices would not
413 // lower the supported Vulkan API level.
414 // See
415 // https://vulkan.gpuinfo.org/listreports.php?devicename=samsung+SM-S906B&platform=android
416 // https://github.com/flutter/flutter/issues/161334
417 return !api_version_.IsAtLeast(Version{1, 3, 0});
418 }
419
420 // https://github.com/flutter/flutter/issues/161122
421 // https://github.com/flutter/flutter/issues/160960
422 // https://github.com/flutter/flutter/issues/160866
423 // https://github.com/flutter/flutter/issues/160804
424 // https://github.com/flutter/flutter/issues/160406
425 if (powervr_gpu_.has_value() && powervr_gpu_.value() < PowerVRGPU::kBXE) {
426 return true;
427 }
428 return false;
429 }
impeller::VendorVK::kSamsung
@ kSamsung
impeller::VendorVK::kHuawei
@ kHuawei
impeller::AdrenoGPU::kAdreno650
@ kAdreno650
impeller::PowerVRGPU::kBXE
@ kBXE
impeller::kPixel10DeviceID
const uint32_t kPixel10DeviceID
Definition: driver_info_vk.cc:127
impeller::kPixel10MinDriverVersion
const uint32_t kPixel10MinDriverVersion
Definition: driver_info_vk.cc:132
impeller::Version::IsAtLeast
constexpr bool IsAtLeast(const Version &other) const
Definition: version.h:31

References impeller::Version::IsAtLeast(), impeller::kAdreno650, impeller::kBXE, impeller::kHuawei, impeller::kPixel10DeviceID, impeller::kPixel10MinDriverVersion, impeller::kPowerVR, 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