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

256 {
257 auto props = device.getProperties();
258 api_version_ = Version{VK_API_VERSION_MAJOR(props.apiVersion),
259 VK_API_VERSION_MINOR(props.apiVersion),
260 VK_API_VERSION_PATCH(props.apiVersion)};
261 vendor_ = IdentifyVendor(props.vendorID);
262 if (vendor_ == VendorVK::kUnknown) {
263 FML_LOG(WARNING) << "Unknown GPU Driver Vendor: " << props.vendorID
264 << ". This is not an error.";
265 }
266 type_ = ToDeviceType(props.deviceType);
267 if (props.deviceName.data() != nullptr) {
268 driver_name_ = props.deviceName.data();
269 }
270
271 switch (vendor_) {
272 case VendorVK::kQualcomm:
273 adreno_gpu_ = GetAdrenoVersion(driver_name_);
274 break;
275 case VendorVK::kARM:
276 mali_gpu_ = GetMaliVersion(driver_name_);
277 break;
278 case VendorVK::kPowerVR:
279 powervr_gpu_ = GetPowerVRVersion(driver_name_);
280 break;
281 default:
282 break;
283 }
284 }
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:154
impeller::GetMaliVersion
MaliGPU GetMaliVersion(std::string_view version)
Definition: driver_info_vk.cc:133
impeller::GetAdrenoVersion
AdrenoGPU GetAdrenoVersion(std::string_view version)
Definition: driver_info_vk.cc:108
impeller::GetPowerVRVersion
PowerVRGPU GetPowerVRVersion(std::string_view version)
Definition: driver_info_vk.cc:122
impeller::ToDeviceType
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
Definition: driver_info_vk.cc:239

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

304 {
305 std::vector<std::pair<std::string, std::string>> items;
306 items.emplace_back("Name", driver_name_);
307 items.emplace_back("API Version", api_version_.ToString());
308 items.emplace_back("Vendor", VendorToString(vendor_));
309 items.emplace_back("Device Type", DeviceTypeToString(type_));
310 items.emplace_back("Is Emulator", std::to_string(IsEmulator()));
311
312 size_t padding = 0;
313
314 for (const auto& item : items) {
315 padding = std::max(padding, item.first.size());
316 }
317
318 padding += 1;
319
320 std::stringstream stream;
321
322 stream << std::endl;
323
324 stream << "--- Driver Information ------------------------------------------";
325
326 stream << std::endl;
327
328 for (const auto& item : items) {
329 stream << "| " << std::setw(static_cast<int>(padding)) << item.first
330 << std::setw(0) << ": " << item.second << std::endl;
331 }
332
333 stream << "-----------------------------------------------------------------";
334
335 FML_LOG(IMPORTANT) << stream.str();
336 }
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:338
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:193
impeller::DeviceTypeToString
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
Definition: driver_info_vk.cc:223
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 383 of file driver_info_vk.cc.

383 {
384 return adreno_gpu_;
385 }

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

288 {
289 return api_version_;
290 }

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

296 {
297 return type_;
298 }

## ◆ GetDriverName()

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

Get the self-reported name of the graphics driver.

Returns
  The driver name.

Definition at line 300 of file driver_info_vk.cc.

300 {
301 return driver_name_;
302 }

## ◆ GetMaliGPUInfo()

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

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

Definition at line 379 of file driver_info_vk.cc.

379 {
380 return mali_gpu_;
381 }

## ◆ GetPowerVRGPUInfo()

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

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

Definition at line 387 of file driver_info_vk.cc.

387 {
388 return powervr_gpu_;
389 }

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

292 {
293 return vendor_;
294 }

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

338 {
339 #if FML_OS_ANDROID
340 // Google SwiftShader on Android.
341 if (type_ == DeviceTypeVK::kCPU && vendor_ == VendorVK::kGoogle &&
342 driver_name_.find("SwiftShader") != std::string::npos) {
343 return true;
344 }
345 #endif // FML_OS_ANDROID
346 return false;
347 }
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 349 of file driver_info_vk.cc.

349 {
350 // Disable Maleoon series GPUs, see:
351 // https://github.com/flutter/flutter/issues/156623
352 if (vendor_ == VendorVK::kHuawei) {
353 return true;
354 }
355
356 if (vendor_ == VendorVK::kSamsung) {
357 // The first version of the Xclipse series GPU has reported
358 // bugs, unfortunately all versions of this GPU report the
359 // same driver version. Instead we use the Vulkan version
360 // as a proxy, assuming that any newer devices would not
361 // lower the supported Vulkan API level.
362 // See
363 // https://vulkan.gpuinfo.org/listreports.php?devicename=samsung+SM-S906B&platform=android
364 // https://github.com/flutter/flutter/issues/161334
365 return !api_version_.IsAtLeast(Version{1, 3, 0});
366 }
367
368 // https://github.com/flutter/flutter/issues/161122
369 // https://github.com/flutter/flutter/issues/160960
370 // https://github.com/flutter/flutter/issues/160866
371 // https://github.com/flutter/flutter/issues/160804
372 // https://github.com/flutter/flutter/issues/160406
373 if (powervr_gpu_.has_value() && powervr_gpu_.value() < PowerVRGPU::kCXT) {
374 return true;
375 }
376 return false;
377 }
impeller::VendorVK::kSamsung
@ kSamsung
impeller::VendorVK::kHuawei
@ kHuawei
impeller::PowerVRGPU::kCXT
@ kCXT
impeller::Version::IsAtLeast
constexpr bool IsAtLeast(const Version &other) const
Definition: version.h:31

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