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