OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrRadInterface_DEFINED | 8 #ifndef GrRadInterface_DEFINED |
9 #define GrRadInterface_DEFINED | 9 #define GrRadInterface_DEFINED |
10 | 10 |
11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
12 | 12 |
13 #include "GrVkExtensions.h" | |
14 | |
15 #include "vulkan/vulkan.h" | 13 #include "vulkan/vulkan.h" |
16 | 14 |
17 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
18 | 16 |
19 /** | 17 /** |
20 * The default interface is returned by GrVkDefaultInterface. This function's | 18 * The default interface is returned by GrVkDefaultInterface. This function's |
21 * implementation is platform-specific. | 19 * implementation is platform-specific. |
22 */ | 20 */ |
23 | 21 |
24 struct GrVkInterface; | 22 struct GrVkInterface; |
25 | 23 |
26 /** | 24 /** |
27 * Creates a GrVkInterface. | 25 * Creates a GrVkInterface. |
28 */ | 26 */ |
29 const GrVkInterface* GrVkCreateInterface(VkInstance instance, VkPhysicalDevice p
hysDev, | 27 const GrVkInterface* GrVkCreateInterface(VkInstance instance, VkDevice device, |
30 VkDevice device); | 28 uint32_t extensionFlags); |
31 | 29 |
32 | 30 |
33 /** | 31 /** |
34 * GrContext uses the following interface to make all calls into Vulkan. When a | 32 * GrContext uses the following interface to make all calls into Vulkan. When a |
35 * GrContext is created it is given a GrVkInterface. All functions that should b
e | 33 * GrContext is created it is given a GrVkInterface. All functions that should b
e |
36 * available based on the Vulkan's version must be non-NULL or GrContext creatio
n | 34 * available based on the Vulkan's version must be non-NULL or GrContext creatio
n |
37 * will fail. This can be tested with the validate() method. | 35 * will fail. This can be tested with the validate() method. |
38 */ | 36 */ |
39 struct SK_API GrVkInterface : public SkRefCnt { | 37 struct SK_API GrVkInterface : public SkRefCnt { |
40 private: | 38 private: |
41 // simple wrapper class that exists only to initialize a pointer to NULL | 39 // simple wrapper class that exists only to initialize a pointer to NULL |
42 template <typename FNPTR_TYPE> class VkPtr { | 40 template <typename FNPTR_TYPE> class VkPtr { |
43 public: | 41 public: |
44 VkPtr() : fPtr(NULL) {} | 42 VkPtr() : fPtr(NULL) {} |
45 VkPtr operator=(FNPTR_TYPE ptr) { fPtr = ptr; return *this; } | 43 VkPtr operator=(FNPTR_TYPE ptr) { fPtr = ptr; return *this; } |
46 operator FNPTR_TYPE() const { return fPtr; } | 44 operator FNPTR_TYPE() const { return fPtr; } |
47 private: | 45 private: |
48 FNPTR_TYPE fPtr; | 46 FNPTR_TYPE fPtr; |
49 }; | 47 }; |
50 | 48 |
51 typedef SkRefCnt INHERITED; | 49 typedef SkRefCnt INHERITED; |
52 | 50 |
53 public: | 51 public: |
54 GrVkInterface(); | 52 GrVkInterface(); |
55 | 53 |
56 // Validates that the GrVkInterface supports its advertised standard. This m
eans the necessary | 54 // Validates that the GrVkInterface supports its advertised standard. This m
eans the necessary |
57 // function pointers have been initialized for Vulkan version. | 55 // function pointers have been initialized for Vulkan version. |
58 bool validate() const; | 56 bool validate() const; |
59 | 57 |
60 GrVkExtensions fExtensions; | |
61 | |
62 bool hasInstanceExtension(const char ext[]) const { | |
63 return fExtensions.hasInstanceExtension(ext); | |
64 } | |
65 bool hasDeviceExtension(const char ext[]) const { | |
66 return fExtensions.hasDeviceExtension(ext); | |
67 } | |
68 bool hasInstanceLayer(const char ext[]) const { | |
69 return fExtensions.hasInstanceLayer(ext); | |
70 } | |
71 bool hasDeviceLayer(const char ext[]) const { | |
72 return fExtensions.hasDeviceLayer(ext); | |
73 } | |
74 | |
75 /** | 58 /** |
76 * The function pointers are in a struct so that we can have a compiler gene
rated assignment | 59 * The function pointers are in a struct so that we can have a compiler gene
rated assignment |
77 * operator. | 60 * operator. |
78 */ | 61 */ |
79 struct Functions { | 62 struct Functions { |
80 VkPtr<PFN_vkCreateInstance> fCreateInstance; | 63 VkPtr<PFN_vkCreateInstance> fCreateInstance; |
81 VkPtr<PFN_vkDestroyInstance> fDestroyInstance; | 64 VkPtr<PFN_vkDestroyInstance> fDestroyInstance; |
82 VkPtr<PFN_vkEnumeratePhysicalDevices> fEnumeratePhysicalDevices; | 65 VkPtr<PFN_vkEnumeratePhysicalDevices> fEnumeratePhysicalDevices; |
83 VkPtr<PFN_vkGetPhysicalDeviceFeatures> fGetPhysicalDeviceFeatures; | 66 VkPtr<PFN_vkGetPhysicalDeviceFeatures> fGetPhysicalDeviceFeatures; |
84 VkPtr<PFN_vkGetPhysicalDeviceFormatProperties> fGetPhysicalDeviceFormatP
roperties; | 67 VkPtr<PFN_vkGetPhysicalDeviceFormatProperties> fGetPhysicalDeviceFormatP
roperties; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 VkPtr<PFN_vkCreateDisplayPlaneSurfaceKHR> fCreateDisplayPlaneSurfaceKHR; | 214 VkPtr<PFN_vkCreateDisplayPlaneSurfaceKHR> fCreateDisplayPlaneSurfaceKHR; |
232 VkPtr<PFN_vkCreateSharedSwapchainsKHR> fCreateSharedSwapchainsKHR; | 215 VkPtr<PFN_vkCreateSharedSwapchainsKHR> fCreateSharedSwapchainsKHR; |
233 VkPtr<PFN_vkCreateDebugReportCallbackEXT> fCreateDebugReportCallbackEXT; | 216 VkPtr<PFN_vkCreateDebugReportCallbackEXT> fCreateDebugReportCallbackEXT; |
234 VkPtr<PFN_vkDebugReportMessageEXT> fDebugReportMessageEXT; | 217 VkPtr<PFN_vkDebugReportMessageEXT> fDebugReportMessageEXT; |
235 VkPtr<PFN_vkDestroyDebugReportCallbackEXT> fDestroyDebugReportCallbackEX
T; | 218 VkPtr<PFN_vkDestroyDebugReportCallbackEXT> fDestroyDebugReportCallbackEX
T; |
236 } fFunctions; | 219 } fFunctions; |
237 | 220 |
238 }; | 221 }; |
239 | 222 |
240 #endif | 223 #endif |
OLD | NEW |