Flutter Impeller
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
 
DriverInfoVKoperator= (const DriverInfoVK &)=delete
 
const VersionGetAPIVersion () const
 Gets the Vulkan API version. Should be at or above Vulkan 1.1 which is the Impeller baseline. More...
 
const VendorVKGetVendor () const
 Get the vendor of the Vulkan implementation. This is a broad check and includes multiple drivers and platforms. More...
 
const DeviceTypeVKGetDeviceType () 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< MaliGPUGetMaliGPUInfo () const
 Returns Mali GPU info if this is a Mali GPU, otherwise std::nullopt. More...
 
std::optional< AdrenoGPUGetAdrenoGPUInfo () const
 Returns Adreno GPU info if this is a Adreno GPU, otherwise std::nullopt. More...
 
std::optional< PowerVRGPUGetPowerVRGPUInfo () 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 }
constexpr VendorVK IdentifyVendor(uint32_t vendor)
MaliGPU GetMaliVersion(std::string_view version)
AdrenoGPU GetAdrenoVersion(std::string_view version)
PowerVRGPU GetPowerVRVersion(std::string_view version)
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)

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 }
bool IsEmulator() const
Determines if the driver represents an emulator. There is no definitive way to tell if a driver is an...
Vector2 padding
The halo padding in source space.
constexpr const char * VendorToString(VendorVK vendor)
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
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 394 of file driver_info_vk.cc.

394  {
395  return adreno_gpu_;
396 }

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

390  {
391  return mali_gpu_;
392 }

◆ GetPowerVRGPUInfo()

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

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

Definition at line 398 of file driver_info_vk.cc.

398  {
399  return powervr_gpu_;
400 }

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 }

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  // Disable Maleoon series GPUs, see:
362  // https://github.com/flutter/flutter/issues/156623
363  if (vendor_ == VendorVK::kHuawei) {
364  return true;
365  }
366 
367  if (vendor_ == VendorVK::kSamsung) {
368  // The first version of the Xclipse series GPU has reported
369  // bugs, unfortunately all versions of this GPU report the
370  // same driver version. Instead we use the Vulkan version
371  // as a proxy, assuming that any newer devices would not
372  // lower the supported Vulkan API level.
373  // See
374  // https://vulkan.gpuinfo.org/listreports.php?devicename=samsung+SM-S906B&platform=android
375  // https://github.com/flutter/flutter/issues/161334
376  return !api_version_.IsAtLeast(Version{1, 3, 0});
377  }
378 
379  // https://github.com/flutter/flutter/issues/161122
380  // https://github.com/flutter/flutter/issues/160960
381  // https://github.com/flutter/flutter/issues/160866
382  // https://github.com/flutter/flutter/issues/160804
383  // https://github.com/flutter/flutter/issues/160406
384  if (powervr_gpu_.has_value() && powervr_gpu_.value() < PowerVRGPU::kBXE) {
385  return true;
386  }
387  return false;
388 }
constexpr bool IsAtLeast(const Version &other) const
Definition: version.h:31

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