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

267 {
268 auto props = device.getProperties();
269 api_version_ = Version{VK_API_VERSION_MAJOR(props.apiVersion),
270 VK_API_VERSION_MINOR(props.apiVersion),
271 VK_API_VERSION_PATCH(props.apiVersion)};
272 vendor_ = IdentifyVendor(props.vendorID);
273 if (vendor_ == VendorVK::kUnknown) {
274 FML_LOG(WARNING) << "Unknown GPU Driver Vendor: " << props.vendorID
275 << ". This is not an error.";
276 }
277 type_ = ToDeviceType(props.deviceType);
278 if (props.deviceName.data() != nullptr) {
279 driver_name_ = props.deviceName.data();
280 }
281
282 switch (vendor_) {
283 case VendorVK::kQualcomm:
284 adreno_gpu_ = GetAdrenoVersion(driver_name_);
285 break;
286 case VendorVK::kARM:
287 mali_gpu_ = GetMaliVersion(driver_name_);
288 break;
289 case VendorVK::kPowerVR:
290 powervr_gpu_ = GetPowerVRVersion(driver_name_);
291 break;
292 default:
293 break;
294 }
295 }
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:165
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::GetPowerVRVersion
PowerVRGPU GetPowerVRVersion(std::string_view version)
Definition: driver_info_vk.cc:134
impeller::ToDeviceType
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
Definition: driver_info_vk.cc:250

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

315 {
316 std::vector<std::pair<std::string, std::string>> items;
317 items.emplace_back("Name", driver_name_);
318 items.emplace_back("API Version", api_version_.ToString());
319 items.emplace_back("Vendor", VendorToString(vendor_));
320 items.emplace_back("Device Type", DeviceTypeToString(type_));
321 items.emplace_back("Is Emulator", std::to_string(IsEmulator()));
322
323 size_t padding = 0;
324
325 for (const auto& item : items) {
326 padding = std::max(padding, item.first.size());
327 }
328
329 padding += 1;
330
331 std::stringstream stream;
332
333 stream << std::endl;
334
335 stream << "--- Driver Information ------------------------------------------";
336
337 stream << std::endl;
338
339 for (const auto& item : items) {
340 stream << "| " << std::setw(static_cast<int>(padding)) << item.first
341 << std::setw(0) << ": " << item.second << std::endl;
342 }
343
344 stream << "-----------------------------------------------------------------";
345
346 FML_LOG(IMPORTANT) << stream.str();
347 }
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
padding
Vector2 padding
The halo padding in source space.
Definition: gaussian_blur_filter_contents.cc:86
impeller::VendorToString
constexpr const char * VendorToString(VendorVK vendor)
Definition: driver_info_vk.cc:204
impeller::DeviceTypeToString
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
Definition: driver_info_vk.cc:234
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 401 of file driver_info_vk.cc.

401 {
402 return adreno_gpu_;
403 }

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

299 {
300 return api_version_;
301 }

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

307 {
308 return type_;
309 }

## ◆ GetDriverName()

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

Get the self-reported name of the graphics driver.

Returns
  The driver name.

Definition at line 311 of file driver_info_vk.cc.

311 {
312 return driver_name_;
313 }

## ◆ GetMaliGPUInfo()

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

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

Definition at line 397 of file driver_info_vk.cc.

397 {
398 return mali_gpu_;
399 }

## ◆ GetPowerVRGPUInfo()

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

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

Definition at line 405 of file driver_info_vk.cc.

405 {
406 return powervr_gpu_;
407 }

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

303 {
304 return vendor_;
305 }

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

349 {
350 #if FML_OS_ANDROID
351 // Google SwiftShader on Android.
352 if (type_ == DeviceTypeVK::kCPU && vendor_ == VendorVK::kGoogle &&
353 driver_name_.find("SwiftShader") != std::string::npos) {
354 return true;
355 }
356 #endif // FML_OS_ANDROID
357 return false;
358 }
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 360 of file driver_info_vk.cc.

360 {
361 // Fall back to OpenGL ES on older Adreno devices that require additional
362 // workarounds in the Impeller Vulkan back end such as disabling framebuffer
363 // fetch.
364 if (adreno_gpu_ && *adreno_gpu_ <= AdrenoGPU::kAdreno630) {
365 return true;
366 }
367
368 // Disable Maleoon series GPUs, see:
369 // https://github.com/flutter/flutter/issues/156623
370 if (vendor_ == VendorVK::kHuawei) {
371 return true;
372 }
373
374 if (vendor_ == VendorVK::kSamsung) {
375 // The first version of the Xclipse series GPU has reported
376 // bugs, unfortunately all versions of this GPU report the
377 // same driver version. Instead we use the Vulkan version
378 // as a proxy, assuming that any newer devices would not
379 // lower the supported Vulkan API level.
380 // See
381 // https://vulkan.gpuinfo.org/listreports.php?devicename=samsung+SM-S906B&platform=android
382 // https://github.com/flutter/flutter/issues/161334
383 return !api_version_.IsAtLeast(Version{1, 3, 0});
384 }
385
386 // https://github.com/flutter/flutter/issues/161122
387 // https://github.com/flutter/flutter/issues/160960
388 // https://github.com/flutter/flutter/issues/160866
389 // https://github.com/flutter/flutter/issues/160804
390 // https://github.com/flutter/flutter/issues/160406
391 if (powervr_gpu_.has_value() && powervr_gpu_.value() < PowerVRGPU::kBXE) {
392 return true;
393 }
394 return false;
395 }
impeller::VendorVK::kSamsung
@ kSamsung
impeller::VendorVK::kHuawei
@ kHuawei
impeller::AdrenoGPU::kAdreno630
@ kAdreno630
impeller::PowerVRGPU::kBXE
@ kBXE
impeller::Version::IsAtLeast
constexpr bool IsAtLeast(const Version &other) const
Definition: version.h:31

References impeller::Version::IsAtLeast(), impeller::kAdreno630, impeller::kBXE, impeller::kHuawei, 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