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...
 

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 174 of file driver_info_vk.h.

Constructor & Destructor Documentation

◆ DriverInfoVK() [1/2]

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

Definition at line 241 of file driver_info_vk.cc.

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

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

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

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

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

270  {
271  return api_version_;
272 }

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

278  {
279  return type_;
280 }

◆ GetDriverName()

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

Get the self-reported name of the graphics driver.

Returns
The driver name.

Definition at line 282 of file driver_info_vk.cc.

282  {
283  return driver_name_;
284 }

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

274  {
275  return vendor_;
276 }

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

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

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 otherwiise.

Definition at line 331 of file driver_info_vk.cc.

331  {
332  if (adreno_gpu_.has_value()) {
333  AdrenoGPU adreno = adreno_gpu_.value();
334  // See:
335  // https://github.com/flutter/flutter/issues/154103
336  //
337  // Reports "VK_INCOMPLETE" when compiling certain entity shader with
338  // vkCreateGraphicsPipelines, which is not a valid return status.
339  // See https://github.com/flutter/flutter/issues/155185 .
340  //
341  // https://github.com/flutter/flutter/issues/155185
342  // Unknown crashes but device is not easily acquirable.
343  switch (adreno) {
366  return true;
367  default:
368  return false;
369  }
370  }
371  // Disable Maleoon series GPUs, see:
372  // https://github.com/flutter/flutter/issues/156623
373  if (vendor_ == VendorVK::kHuawei) {
374  return true;
375  }
376  return false;
377 }

References impeller::kAdreno504, impeller::kAdreno505, impeller::kAdreno506, impeller::kAdreno508, impeller::kAdreno509, impeller::kAdreno510, impeller::kAdreno512, impeller::kAdreno530, impeller::kAdreno540, impeller::kAdreno605, impeller::kAdreno608, impeller::kAdreno610, impeller::kAdreno612, impeller::kAdreno613, impeller::kAdreno615, impeller::kAdreno616, impeller::kAdreno618, impeller::kAdreno619, impeller::kAdreno619L, impeller::kAdreno620, impeller::kAdreno630, impeller::kAdreno640, and impeller::kHuawei.

◆ operator=()

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

The documentation for this class was generated from the following files:
impeller::AdrenoGPU::kAdreno530
@ kAdreno530
impeller::AdrenoGPU::kAdreno619L
@ kAdreno619L
impeller::AdrenoGPU::kAdreno509
@ kAdreno509
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:320
impeller::AdrenoGPU::kAdreno618
@ kAdreno618
padding
Vector2 padding
The halo padding in source space.
Definition: gaussian_blur_filter_contents.cc:85
impeller::GetMaliVersion
MaliGPU GetMaliVersion(std::string_view version)
Definition: driver_info_vk.cc:122
impeller::AdrenoGPU::kAdreno640
@ kAdreno640
impeller::AdrenoGPU::kAdreno504
@ kAdreno504
impeller::AdrenoGPU
AdrenoGPU
Definition: driver_info_vk.h:14
impeller::VendorVK::kARM
@ kARM
impeller::VendorVK::kGoogle
@ kGoogle
impeller::AdrenoGPU::kAdreno615
@ kAdreno615
impeller::AdrenoGPU::kAdreno620
@ kAdreno620
impeller::AdrenoGPU::kAdreno505
@ kAdreno505
impeller::Version::ToString
std::string ToString() const
Definition: version.cc:27
impeller::AdrenoGPU::kAdreno506
@ kAdreno506
impeller::AdrenoGPU::kAdreno613
@ kAdreno613
impeller::VendorToString
constexpr const char * VendorToString(VendorVK vendor)
Definition: driver_info_vk.cc:180
impeller::VendorVK::kQualcomm
@ kQualcomm
impeller::AdrenoGPU::kAdreno512
@ kAdreno512
impeller::AdrenoGPU::kAdreno608
@ kAdreno608
impeller::AdrenoGPU::kAdreno510
@ kAdreno510
impeller::AdrenoGPU::kAdreno616
@ kAdreno616
impeller::AdrenoGPU::kAdreno619
@ kAdreno619
impeller::DeviceTypeVK::kCPU
@ kCPU
impeller::AdrenoGPU::kAdreno630
@ kAdreno630
impeller::VendorVK::kUnknown
@ kUnknown
impeller::IdentifyVendor
constexpr VendorVK IdentifyVendor(uint32_t vendor)
Definition: driver_info_vk.cc:143
impeller::AdrenoGPU::kAdreno508
@ kAdreno508
impeller::VendorVK::kHuawei
@ kHuawei
impeller::AdrenoGPU::kAdreno610
@ kAdreno610
impeller::GetAdrenoVersion
AdrenoGPU GetAdrenoVersion(std::string_view version)
Definition: driver_info_vk.cc:108
impeller::AdrenoGPU::kAdreno605
@ kAdreno605
impeller::DeviceTypeToString
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
Definition: driver_info_vk.cc:208
impeller::AdrenoGPU::kAdreno540
@ kAdreno540
impeller::ToDeviceType
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
Definition: driver_info_vk.cc:224
impeller::AdrenoGPU::kAdreno612
@ kAdreno612