• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc.
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 GrVkExtensions_DEFINED
9 #define GrVkExtensions_DEFINED
10 
11 #include "include/core/SkString.h"
12 #include "include/gpu/vk/GrVkTypes.h"
13 #include "include/private/SkTArray.h"
14 
15 /**
16  * Helper class that eats in an array of extensions strings for instance and device and allows for
17  * quicker querying if an extension is present.
18  */
19 class SK_API GrVkExtensions {
20 public:
GrVkExtensions()21     GrVkExtensions() {}
22 
23     void init(GrVkGetProc, VkInstance, VkPhysicalDevice,
24               uint32_t instanceExtensionCount, const char* const* instanceExtensions,
25               uint32_t deviceExtensionCount, const char* const* deviceExtensions);
26 
27     bool hasExtension(const char[], uint32_t minVersion) const;
28 
29     struct Info {
InfoInfo30         Info() {}
InfoInfo31         Info(const char* name) : fName(name), fSpecVersion(0) {}
32 
33         SkString fName;
34         uint32_t fSpecVersion;
35 
36         struct Less {
operatorInfo::Less37             bool operator()(const Info& a, const SkString& b) const {
38                 return strcmp(a.fName.c_str(), b.c_str()) < 0;
39             }
operatorInfo::Less40             bool operator()(const SkString& a, const GrVkExtensions::Info& b) const {
41                 return strcmp(a.c_str(), b.fName.c_str()) < 0;
42             }
43         };
44     };
45 
46 #ifdef SK_DEBUG
dump()47     void dump() const {
48         SkDebugf("**Vulkan Extensions**\n");
49         for (int i = 0; i < fExtensions.count(); ++i) {
50             SkDebugf("%s. Version: %d\n",
51                      fExtensions[i].fName.c_str(), fExtensions[i].fSpecVersion);
52         }
53         SkDebugf("**End Vulkan Extensions**\n");
54     }
55 #endif
56 
57 private:
58     void getSpecVersions(GrVkGetProc getProc, VkInstance, VkPhysicalDevice);
59 
60     SkTArray<Info>  fExtensions;
61 };
62 
63 #endif
64