| Flutter Impeller |

driver_info_vk.h
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 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
7
8 #include "impeller/base/version.h"
9 #include "impeller/renderer/backend/vulkan/vk.h"
10
11 namespace impeller {
12
13 enum class VendorVK {
14 kUnknown,
15 //----------------------------------------------------------------------------
16 /// Includes the SwiftShader CPU implementation.
17 ///
18 kGoogle,
19 kQualcomm,
20 kARM,
21 kImgTec,
22 kPowerVR = kImgTec,
23 kAMD,
24 kNvidia,
25 kIntel,
26 //----------------------------------------------------------------------------
27 /// Includes the LLVM Pipe CPU implementation.
28 ///
29 kMesa,
30 //----------------------------------------------------------------------------
31 /// Includes Vulkan on Metal via MoltenVK.
32 ///
33 kApple,
34 };
35
36 enum class DeviceTypeVK {
37 kUnknown,
38 //----------------------------------------------------------------------------
39 /// The device is an integrated GPU. Typically mobile GPUs.
40 ///
41 kIntegratedGPU,
42 //----------------------------------------------------------------------------
43 /// The device is a discrete GPU. Typically desktop GPUs.
44 ///
45 kDiscreteGPU,
46 //----------------------------------------------------------------------------
47 /// The device is a GPU in a virtualized environment.
48 ///
49 kVirtualGPU,
50 //----------------------------------------------------------------------------
51 /// There is no GPU. Vulkan is implemented on the CPU. This is typically
52 /// emulators like SwiftShader and LLVMPipe.
53 ///
54 kCPU,
55 };
56
57 //------------------------------------------------------------------------------
58 /// @brief Get information about the Vulkan driver.
59 ///
60 /// @warning Be extremely cautious about the information reported here. This
61 /// is self-reported information (by the driver) and may be
62 /// inaccurate and or inconsistent.
63 ///
64 /// Before gating features behind any of the information reported by
65 /// the driver, consider alternatives (extensions checks perhaps)
66 /// and try to get a reviewer buddy to convince you to avoid using
67 /// this.
68 ///
69 class DriverInfoVK {
70 public:
71 explicit DriverInfoVK(const vk::PhysicalDevice& device);
72
73 ~DriverInfoVK();
74
75 DriverInfoVK(const DriverInfoVK&) = delete;
76
77 DriverInfoVK& operator=(const DriverInfoVK&) = delete;
78
79 //----------------------------------------------------------------------------
80 /// @brief Gets the Vulkan API version. Should be at or above Vulkan 1.1
81 /// which is the Impeller baseline.
82 ///
83 /// @return The Vulkan API version.
84 ///
85 const Version& GetAPIVersion() const;
86
87 //----------------------------------------------------------------------------
88 /// @brief Get the vendor of the Vulkan implementation. This is a broad
89 /// check and includes multiple drivers and platforms.
90 ///
91 /// @return The vendor.
92 ///
93 const VendorVK& GetVendor() const;
94
95 //----------------------------------------------------------------------------
96 /// @brief Get the device type. Typical use might be to check if the
97 /// device is a CPU implementation.
98 ///
99 /// @return The device type.
100 ///
101 const DeviceTypeVK& GetDeviceType() const;
102
103 //----------------------------------------------------------------------------
104 /// @brief Get the self-reported name of the graphics driver.
105 ///
106 /// @return The driver name.
107 ///
108 const std::string& GetDriverName() const;
109
110 //----------------------------------------------------------------------------
111 /// @brief Dumps the current driver info to the log.
112 ///
113 void DumpToLog() const;
114
115 //----------------------------------------------------------------------------
116 /// @brief Determines if the driver represents an emulator. There is no
117 /// definitive way to tell if a driver is an emulator and drivers
118 /// don't self identify as emulators. So take this information
119 /// with a pinch of salt.
120 ///
121 /// @return True if emulator, False otherwise.
122 ///
123 bool IsEmulator() const;
124
125 private:
126 bool is_valid_ = false;
127 Version api_version_;
128 VendorVK vendor_ = VendorVK::kUnknown;
129 DeviceTypeVK type_ = DeviceTypeVK::kUnknown;
130 std::string driver_name_;
131 };
132
133 } // namespace impeller
134
135 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
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:130
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:134
impeller::VendorVK::kPowerVR
@ kPowerVR
impeller::DriverInfoVK::DriverInfoVK
DriverInfoVK(const vk::PhysicalDevice &device)
Definition: driver_info_vk.cc:108
impeller::DriverInfoVK
Get information about the Vulkan driver.
Definition: driver_info_vk.h:69
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:176
impeller::DriverInfoVK::DumpToLog
void DumpToLog() const
Dumps the current driver info to the log.
Definition: driver_info_vk.cc:142
version.h
impeller::Version
Definition: version.h:16
vk.h
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
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:126
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::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:138
impeller::DriverInfoVK::operator=
DriverInfoVK & operator=(const DriverInfoVK &)=delete
impeller
Definition: aiks_blend_unittests.cc:18