Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
VulkanExtensions.cpp File Reference
#include "include/gpu/vk/VulkanExtensions.h"
#include "src/base/SkTSearch.h"
#include "src/base/SkTSort.h"

Go to the source code of this file.

Namespaces

namespace  skgpu
 

Macros

#define GET_PROC(F, inst)    PFN_vk##F grVk##F = (PFN_vk ## F) getProc("vk" #F, inst, VK_NULL_HANDLE)
 

Functions

static int skgpu::find_info (const TArray< VulkanExtensions::Info > &infos, const char ext[])
 

Macro Definition Documentation

◆ GET_PROC

#define GET_PROC (   F,
  inst 
)     PFN_vk##F grVk##F = (PFN_vk ## F) getProc("vk" #F, inst, VK_NULL_HANDLE)

Definition at line 62 of file VulkanExtensions.cpp.

66 {
67 // We grab all the extensions for the VkInstance and VkDevice so we can look up what spec
68 // version each of the supported extensions are. We do not grab the extensions for layers
69 // because we don't know what layers the client has enabled and in general we don't do anything
70 // special for those extensions.
71
72 if (instance == VK_NULL_HANDLE) {
73 return;
74 }
75 GET_PROC(EnumerateInstanceExtensionProperties, VK_NULL_HANDLE);
76 SkASSERT(grVkEnumerateInstanceExtensionProperties);
77
78 VkResult res;
79 // instance extensions
80 uint32_t extensionCount = 0;
81 res = grVkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
82 if (VK_SUCCESS != res) {
83 return;
84 }
86 res = grVkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions);
87 if (VK_SUCCESS != res) {
88 delete[] extensions;
89 return;
90 }
91 for (uint32_t i = 0; i < extensionCount; ++i) {
92 int idx = find_info(fExtensions, extensions[i].extensionName);
93 if (idx >= 0) {
94 fExtensions[idx].fSpecVersion = extensions[i].specVersion;
95 }
96 }
97 delete[] extensions;
98
99 if (physDevice == VK_NULL_HANDLE) {
100 return;
101 }
102 GET_PROC(EnumerateDeviceExtensionProperties, instance);
103 SkASSERT(grVkEnumerateDeviceExtensionProperties);
104
105 // device extensions
106 extensionCount = 0;
107 res = grVkEnumerateDeviceExtensionProperties(physDevice, nullptr, &extensionCount, nullptr);
108 if (VK_SUCCESS != res) {
109 return;
110 }
111 extensions = new VkExtensionProperties[extensionCount];
112 res = grVkEnumerateDeviceExtensionProperties(physDevice, nullptr, &extensionCount, extensions);
113 if (VK_SUCCESS != res) {
114 delete[] extensions;
115 return;
116 }
117 for (uint32_t i = 0; i < extensionCount; ++i) {
118 int idx = find_info(fExtensions, extensions[i].extensionName);
119 if (idx >= 0) {
120 fExtensions[idx].fSpecVersion = extensions[i].specVersion;
121 }
122 }
123 delete[] extensions;
124}
125
126bool VulkanExtensions::hasExtension(const char ext[], uint32_t minVersion) const {
127 int idx = find_info(fExtensions, ext);
128 return idx >= 0 && fExtensions[idx].fSpecVersion >= minVersion;
129}
130
131} // namespace skgpu
#define SkASSERT(cond)
Definition SkAssert.h:116
#define GET_PROC(F, inst)
VkInstance instance
Definition main.cc:48
static int find_info(const TArray< VulkanExtensions::Info > &infos, const char ext[])
VkResult
@ VK_SUCCESS
#define VK_NULL_HANDLE
Definition vulkan_core.h:46