Flutter Engine
The Flutter Engine
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
 
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...
 

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

Constructor & Destructor Documentation

◆ DriverInfoVK() [1/2]

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

Definition at line 108 of file driver_info_vk.cc.

108 {
109 auto props = device.getProperties();
110 api_version_ = Version{VK_API_VERSION_MAJOR(props.apiVersion),
111 VK_API_VERSION_MINOR(props.apiVersion),
112 VK_API_VERSION_PATCH(props.apiVersion)};
113 vendor_ = IdentifyVendor(props.vendorID);
114 if (vendor_ == VendorVK::kUnknown) {
115 FML_LOG(WARNING) << "Unknown GPU Driver Vendor: " << props.vendorID
116 << ". This is not an error.";
117 }
118 type_ = ToDeviceType(props.deviceType);
119 if (props.deviceName.data() != nullptr) {
120 driver_name_ = props.deviceName.data();
121 }
122}
Version
VkDevice device
Definition: main.cc:53
#define FML_LOG(severity)
Definition: logging.h:82
constexpr VendorVK IdentifyVendor(uint32_t vendor)
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
#define VK_API_VERSION_PATCH(version)
Definition: vulkan_core.h:93
#define VK_API_VERSION_MINOR(version)
Definition: vulkan_core.h:92
#define VK_API_VERSION_MAJOR(version)
Definition: vulkan_core.h:91

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

142 {
143 std::vector<std::pair<std::string, std::string>> items;
144 items.emplace_back("Name", driver_name_);
145 items.emplace_back("API Version", api_version_.ToString());
146 items.emplace_back("Vendor", VendorToString(vendor_));
147 items.emplace_back("Device Type", DeviceTypeToString(type_));
148 items.emplace_back("Is Emulator", std::to_string(IsEmulator()));
149
150 size_t padding = 0;
151
152 for (const auto& item : items) {
153 padding = std::max(padding, item.first.size());
154 }
155
156 padding += 1;
157
158 std::stringstream stream;
159
160 stream << std::endl;
161
162 stream << "--- Driver Information ------------------------------------------";
163
164 stream << std::endl;
165
166 for (const auto& item : items) {
167 stream << "| " << std::setw(static_cast<int>(padding)) << item.first
168 << std::setw(0) << ": " << item.second << std::endl;
169 }
170
171 stream << "-----------------------------------------------------------------";
172
173 FML_LOG(IMPORTANT) << stream.str();
174}
bool IsEmulator() const
Determines if the driver represents an emulator. There is no definitive way to tell if a driver is an...
static float max(float r, float g, float b)
Definition: hsl.cpp:49
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
constexpr const char * VendorToString(VendorVK vendor)
static SkString to_string(int n)
Definition: nanobench.cpp:119
std::string ToString() const

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

126 {
127 return api_version_;
128}

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

134 {
135 return type_;
136}

◆ GetDriverName()

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

Get the self-reported name of the graphics driver.

Returns
The driver name.

Definition at line 138 of file driver_info_vk.cc.

138 {
139 return driver_name_;
140}

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

130 {
131 return vendor_;
132}

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

176 {
177#if FML_OS_ANDROID
178 // Google SwiftShader on Android.
179 if (type_ == DeviceTypeVK::kCPU && vendor_ == VendorVK::kGoogle &&
180 driver_name_.find("SwiftShader") != std::string::npos) {
181 return true;
182 }
183#endif // FML_OS_ANDROID
184 return false;
185}

◆ operator=()

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

The documentation for this class was generated from the following files: