• 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 "../private/SkTArray.h"
12 #include "SkString.h"
13 #include "vk/GrVkDefines.h"
14 #include "vk/GrVkInterface.h"
15 
16 /**
17  * This helper queries the Vulkan driver for available extensions and layers, remembers them,
18  * and can be queried. It supports queries for both instance and device extensions and layers.
19  */
20 class SK_API GrVkExtensions {
21 public:
GrVkExtensions(GrVkInterface::GetProc getProc)22     GrVkExtensions(GrVkInterface::GetProc getProc)
23                      : fGetProc(getProc)
24                      , fInstanceExtensionStrings(new SkTArray<SkString>)
25                      , fDeviceExtensionStrings(new SkTArray<SkString>)
26                      , fInstanceLayerStrings(new SkTArray<SkString>)
27                      , fDeviceLayerStrings(new SkTArray<SkString>) {}
28 
29     bool initInstance(uint32_t specVersion);
30     bool initDevice(uint32_t specVersion, VkInstance, VkPhysicalDevice);
31 
32     /**
33      * Queries whether an extension or layer is present. Will fail if not initialized.
34      */
35     bool hasInstanceExtension(const char[]) const;
36     bool hasDeviceExtension(const char[]) const;
37     bool hasInstanceLayer(const char[]) const;
38     bool hasDeviceLayer(const char[]) const;
39 
40     void print(const char* sep = "\n") const;
41 
42 private:
43     GrVkInterface::GetProc fGetProc;
44     std::unique_ptr<SkTArray<SkString>>  fInstanceExtensionStrings;
45     std::unique_ptr<SkTArray<SkString>>  fDeviceExtensionStrings;
46     std::unique_ptr<SkTArray<SkString>>  fInstanceLayerStrings;
47     std::unique_ptr<SkTArray<SkString>>  fDeviceLayerStrings;
48 };
49 
50 #endif
51