/src/skia/include/gpu/vk/VulkanExtensions.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2022 Google LLC. |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license that can be |
5 | | * found in the LICENSE file. |
6 | | */ |
7 | | |
8 | | #ifndef skgpu_VulkanExtensions_DEFINED |
9 | | #define skgpu_VulkanExtensions_DEFINED |
10 | | |
11 | | #include "include/core/SkString.h" |
12 | | #include "include/gpu/vk/VulkanTypes.h" |
13 | | #include "include/private/base/SkAPI.h" |
14 | | #include "include/private/base/SkDebug.h" |
15 | | #include "include/private/base/SkTArray.h" |
16 | | #include "include/private/gpu/vk/SkiaVulkan.h" |
17 | | |
18 | | #include <cstdint> |
19 | | #include <cstring> |
20 | | |
21 | | namespace skgpu { |
22 | | |
23 | | /** |
24 | | * Helper class that eats in an array of extensions strings for instance and device and allows for |
25 | | * quicker querying if an extension is present. |
26 | | */ |
27 | | class SK_API VulkanExtensions { |
28 | | public: |
29 | 0 | VulkanExtensions() {} |
30 | | |
31 | | void init(VulkanGetProc, VkInstance, VkPhysicalDevice, |
32 | | uint32_t instanceExtensionCount, const char* const* instanceExtensions, |
33 | | uint32_t deviceExtensionCount, const char* const* deviceExtensions); |
34 | | |
35 | | bool hasExtension(const char[], uint32_t minVersion) const; |
36 | | |
37 | | struct Info { |
38 | 0 | Info() {} |
39 | 0 | Info(const char* name) : fName(name), fSpecVersion(0) {} |
40 | | |
41 | | SkString fName; |
42 | | uint32_t fSpecVersion; |
43 | | |
44 | | struct Less { |
45 | 0 | bool operator()(const Info& a, const SkString& b) const { |
46 | 0 | return std::strcmp(a.fName.c_str(), b.c_str()) < 0; |
47 | 0 | } |
48 | 0 | bool operator()(const SkString& a, const VulkanExtensions::Info& b) const { |
49 | 0 | return std::strcmp(a.c_str(), b.fName.c_str()) < 0; |
50 | 0 | } |
51 | | }; |
52 | | }; |
53 | | |
54 | | #ifdef SK_DEBUG |
55 | 0 | void dump() const { |
56 | 0 | SkDebugf("**Vulkan Extensions**\n"); |
57 | 0 | for (int i = 0; i < fExtensions.size(); ++i) { |
58 | 0 | SkDebugf("%s. Version: %u\n", |
59 | 0 | fExtensions[i].fName.c_str(), fExtensions[i].fSpecVersion); |
60 | 0 | } |
61 | 0 | SkDebugf("**End Vulkan Extensions**\n"); |
62 | 0 | } |
63 | | #endif |
64 | | |
65 | | private: |
66 | | void getSpecVersions(const VulkanGetProc& getProc, VkInstance, VkPhysicalDevice); |
67 | | |
68 | | skia_private::TArray<Info> fExtensions; |
69 | | }; |
70 | | |
71 | | } // namespace skgpu |
72 | | |
73 | | #endif // skgpu_VulkanExtensions_DEFINED |