Flutter Engine
The Flutter Engine
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
11namespace impeller {
12
13enum class VendorVK {
14 kUnknown,
15 //----------------------------------------------------------------------------
16 /// Includes the SwiftShader CPU implementation.
17 ///
18 kGoogle,
20 kARM,
21 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
36enum 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///
70 public:
71 explicit DriverInfoVK(const vk::PhysicalDevice& device);
72
74
75 DriverInfoVK(const DriverInfoVK&) = delete;
76
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_;
130 std::string driver_name_;
131};
132
133} // namespace impeller
134
135#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DRIVER_INFO_VK_H_
Get information about the Vulkan driver.
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)
DriverInfoVK & operator=(const DriverInfoVK &)=delete
const std::string & GetDriverName() const
Get the self-reported name of the graphics driver.
void DumpToLog() const
Dumps the current driver info to the log.
DriverInfoVK(const DriverInfoVK &)=delete
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.
VkDevice device
Definition: main.cc:53