10#include <unordered_map>
17const std::unordered_map<std::string_view, AdrenoGPU> kAdrenoVersions = {
72const std::unordered_map<std::string_view, MaliGPU> kMaliVersions = {
109constexpr std::array<std::pair<std::string_view, PowerVRGPU>, 6> kGpuSeriesMap =
122 auto paren_pos = version.find(
"Adreno (TM) ");
123 if (paren_pos == std::string::npos) {
126 auto version_string = version.substr(paren_pos + 12);
127 const auto& result = kAdrenoVersions.find(version_string);
128 if (result == kAdrenoVersions.end()) {
131 return result->second;
135 for (
const auto& entry : kGpuSeriesMap) {
136 if (version.find(entry.first) != std::string::npos) {
146 auto dash_pos = version.find(
"Mali-");
147 if (dash_pos == std::string::npos) {
150 auto version_string_with_trailing = version.substr(dash_pos + 5);
152 auto more_dash_pos = version_string_with_trailing.find(
"-");
153 if (more_dash_pos != std::string::npos) {
154 version_string_with_trailing =
155 version_string_with_trailing.substr(0, more_dash_pos);
158 const auto& result = kMaliVersions.find(version_string_with_trailing);
159 if (result == kMaliVersions.end()) {
162 return result->second;
196 case VK_VENDOR_ID_MESA:
215 return "ImgTec PowerVR";
239 return "Integrated GPU";
241 return "Discrete GPU";
243 return "Virtual GPU";
252 case vk::PhysicalDeviceType::eOther:
254 case vk::PhysicalDeviceType::eIntegratedGpu:
256 case vk::PhysicalDeviceType::eDiscreteGpu:
258 case vk::PhysicalDeviceType::eVirtualGpu:
260 case vk::PhysicalDeviceType::eCpu:
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)};
274 FML_LOG(WARNING) <<
"Unknown GPU Driver Vendor: " << props.vendorID
275 <<
". This is not an error.";
278 if (props.deviceName.data() !=
nullptr) {
279 driver_name_ = props.deviceName.data();
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());
321 items.emplace_back(
"Is Emulator", std::to_string(
IsEmulator()));
325 for (
const auto& item : items) {
331 std::stringstream stream;
335 stream <<
"--- Driver Information ------------------------------------------";
339 for (
const auto& item : items) {
340 stream <<
"| " << std::setw(
static_cast<int>(
padding)) << item.first
341 << std::setw(0) <<
": " << item.second << std::endl;
344 stream <<
"-----------------------------------------------------------------";
346 FML_LOG(IMPORTANT) << stream.str();
353 driver_name_.find(
"SwiftShader") != std::string::npos) {
const VendorVK & GetVendor() const
Get the vendor of the Vulkan implementation. This is a broad check and includes multiple drivers and ...
DriverInfoVK(const vk::PhysicalDevice &device)
std::optional< PowerVRGPU > GetPowerVRGPUInfo() const
Returns PowerVR GPU info if this is a PowerVR GPU, otherwise std::nullopt.
bool IsKnownBadDriver() const
Determines if the driver has been tested and determined to be non-functional.
const std::string & GetDriverName() const
Get the self-reported name of the graphics driver.
std::optional< AdrenoGPU > GetAdrenoGPUInfo() const
Returns Adreno GPU info if this is a Adreno GPU, otherwise std::nullopt.
void DumpToLog() const
Dumps the current driver info to the log.
std::optional< MaliGPU > GetMaliGPUInfo() const
Returns Mali GPU info if this is a Mali GPU, otherwise std::nullopt.
bool IsEmulator() const
Determines if the driver represents an emulator. There is no definitive way to tell if a driver is an...
const DeviceTypeVK & GetDeviceType() const
Get the device type. Typical use might be to check if the device is a CPU implementation.
const Version & GetAPIVersion() const
Gets the Vulkan API version. Should be at or above Vulkan 1.1 which is the Impeller baseline.
#define FML_LOG(severity)
#define FML_UNREACHABLE()
Vector2 padding
The halo padding in source space.
constexpr VendorVK IdentifyVendor(uint32_t vendor)
MaliGPU GetMaliVersion(std::string_view version)
AdrenoGPU GetAdrenoVersion(std::string_view version)
constexpr const char * DeviceTypeToString(DeviceTypeVK type)
PowerVRGPU GetPowerVRVersion(std::string_view version)
constexpr const char * VendorToString(VendorVK vendor)
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
constexpr bool IsAtLeast(const Version &other) const
std::string ToString() const