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 
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  ///
42  //----------------------------------------------------------------------------
43  /// The device is a discrete GPU. Typically desktop GPUs.
44  ///
46  //----------------------------------------------------------------------------
47  /// The device is a GPU in a virtualized environment.
48  ///
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  private:
111  bool is_valid_ = false;
112  Version api_version_;
113  VendorVK vendor_ = VendorVK::kUnknown;
115  std::string driver_name_;
116 };
117 
118 } // namespace impeller
119 
120 #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: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::VendorVK::kPowerVR
@ kPowerVR
impeller::DriverInfoVK::DriverInfoVK
DriverInfoVK(const vk::PhysicalDevice &device)
Definition: driver_info_vk.cc:61
impeller::DriverInfoVK
Get information about the Vulkan driver.
Definition: driver_info_vk.h:69
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: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::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::DriverInfoVK::operator=
DriverInfoVK & operator=(const DriverInfoVK &)=delete
impeller
Definition: aiks_blur_unittests.cc:20