| Flutter Impeller |

driver_info_vk.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/renderer/backend/vulkan/driver_info_vk.h"
6
7 namespace impeller {
8
9 constexpr VendorVK IdentifyVendor(uint32_t vendor) {
10 // Check if the vendor has a PCI ID:
11 // https://pcisig.com/membership/member-companies
12 switch (vendor) {
13 case 0x1AE0:
14 return VendorVK::kGoogle;
15 case 0x168C:
16 case 0x17CB:
17 case 0x1969:
18 case 0x5143:
19 return VendorVK::kQualcomm;
20 case 0x13B5:
21 return VendorVK::kARM;
22 case 0x1010:
23 return VendorVK::kImgTec;
24 case 0x1002:
25 case 0x1022:
26 return VendorVK::kAMD;
27 case 0x10DE:
28 return VendorVK::kNvidia;
29 case 0x8086: // :)
30 return VendorVK::kIntel;
31 case 0x106B:
32 return VendorVK::kApple;
33 }
34 // Check if the ID is a known Khronos vendor.
35 switch (vendor) {
36 case VK_VENDOR_ID_MESA:
37 return VendorVK::kMesa;
38 // There are others but have never been observed. These can be added as
39 // needed.
40 }
41 return VendorVK::kUnknown;
42 }
43
44 constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType& type) {
45 switch (type) {
46 case vk::PhysicalDeviceType::eOther:
47 return DeviceTypeVK::kUnknown;
48 case vk::PhysicalDeviceType::eIntegratedGpu:
49 return DeviceTypeVK::kIntegratedGPU;
50 case vk::PhysicalDeviceType::eDiscreteGpu:
51 return DeviceTypeVK::kDiscreteGPU;
52 case vk::PhysicalDeviceType::eVirtualGpu:
53 return DeviceTypeVK::kVirtualGPU;
54 case vk::PhysicalDeviceType::eCpu:
55 return DeviceTypeVK::kCPU;
56 break;
57 }
58 return DeviceTypeVK::kUnknown;
59 }
60
61 DriverInfoVK::DriverInfoVK(const vk::PhysicalDevice& device) {
62 auto props = device.getProperties();
63 api_version_ = Version{VK_API_VERSION_MAJOR(props.apiVersion),
64 VK_API_VERSION_MINOR(props.apiVersion),
65 VK_API_VERSION_PATCH(props.apiVersion)};
66 vendor_ = IdentifyVendor(props.vendorID);
67 if (vendor_ == VendorVK::kUnknown) {
68 FML_LOG(WARNING) << "Unknown GPU Driver Vendor: " << props.vendorID
69 << ". This is not an error.";
70 }
71 type_ = ToDeviceType(props.deviceType);
72 if (props.deviceName.data() != nullptr) {
73 driver_name_ = props.deviceName.data();
74 }
75 }
76
77 DriverInfoVK::~DriverInfoVK() = default;
78
79 const Version& DriverInfoVK::GetAPIVersion() const {
80 return api_version_;
81 }
82
83 const VendorVK& DriverInfoVK::GetVendor() const {
84 return vendor_;
85 }
86
87 const DeviceTypeVK& DriverInfoVK::GetDeviceType() const {
88 return type_;
89 }
90
91 const std::string& DriverInfoVK::GetDriverName() const {
92 return driver_name_;
93 }
94
95 } // namespace impeller
impeller::DriverInfoVK::GetVendor
const VendorVK & GetVendor() const
Get the vendor of the Vulkan implementation. This is a broad check and includes multiple drivers and ...
Definition: driver_info_vk.cc:83
impeller::DeviceTypeVK::kDiscreteGPU
@ kDiscreteGPU
impeller::DeviceTypeVK::kIntegratedGPU
@ kIntegratedGPU
impeller::DriverInfoVK::~DriverInfoVK
~DriverInfoVK()
impeller::DriverInfoVK::GetDeviceType
const DeviceTypeVK & GetDeviceType() const
Get the device type. Typical use might be to check if the device is a CPU implementation.
Definition: driver_info_vk.cc:87
impeller::DriverInfoVK::DriverInfoVK
DriverInfoVK(const vk::PhysicalDevice &device)
Definition: driver_info_vk.cc:61
impeller::Version
Definition: version.h:16
impeller::VendorVK::kARM
@ kARM
impeller::VendorVK::kGoogle
@ kGoogle
impeller::VendorVK::kAMD
@ kAMD
impeller::VendorVK::kMesa
@ kMesa
impeller::VendorVK::kApple
@ kApple
impeller::VendorVK::kImgTec
@ kImgTec
impeller::VendorVK::kQualcomm
@ kQualcomm
impeller::DeviceTypeVK::kVirtualGPU
@ kVirtualGPU
driver_info_vk.h
impeller::DriverInfoVK::GetAPIVersion
const Version & GetAPIVersion() const
Gets the Vulkan API version. Should be at or above Vulkan 1.1 which is the Impeller baseline.
Definition: driver_info_vk.cc:79
impeller::DeviceTypeVK
DeviceTypeVK
Definition: driver_info_vk.h:36
impeller::DeviceTypeVK::kCPU
@ kCPU
impeller::VendorVK::kIntel
@ kIntel
impeller::VendorVK
VendorVK
Definition: driver_info_vk.h:13
impeller::VendorVK::kUnknown
@ kUnknown
impeller::IdentifyVendor
constexpr VendorVK IdentifyVendor(uint32_t vendor)
Definition: driver_info_vk.cc:9
impeller::VendorVK::kNvidia
@ kNvidia
impeller::DeviceTypeVK::kUnknown
@ kUnknown
impeller::DriverInfoVK::GetDriverName
const std::string & GetDriverName() const
Get the self-reported name of the graphics driver.
Definition: driver_info_vk.cc:91
impeller
Definition: aiks_blur_unittests.cc:20
impeller::ToDeviceType
constexpr DeviceTypeVK ToDeviceType(const vk::PhysicalDeviceType &type)
Definition: driver_info_vk.cc:44