Flutter Engine
The Flutter Engine
VulkanInterface.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 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 */
8
12
13#include <functional>
14
15namespace skgpu {
16
17#define ACQUIRE_PROC(name, instance, device) \
18 fFunctions.f##name = reinterpret_cast<PFN_vk##name>(getProc("vk" #name, instance, device))
19
20#define ACQUIRE_PROC_SUFFIX(name, suffix, instance, device) \
21 fFunctions.f##name = \
22 reinterpret_cast<PFN_vk##name##suffix>(getProc("vk" #name #suffix, instance, device))
23
25 VkInstance instance,
26 VkDevice device,
27 uint32_t instanceVersion,
28 uint32_t physicalDeviceVersion,
30 if (getProc == nullptr) {
31 return;
32 }
34
35 // Global/Loader Procs.
37 ACQUIRE_PROC(EnumerateInstanceExtensionProperties, VK_NULL_HANDLE, VK_NULL_HANDLE);
38 ACQUIRE_PROC(EnumerateInstanceLayerProperties, VK_NULL_HANDLE, VK_NULL_HANDLE);
39
40 // Instance Procs.
41 ACQUIRE_PROC(EnumeratePhysicalDevices, instance, VK_NULL_HANDLE);
42 ACQUIRE_PROC(GetPhysicalDeviceFeatures, instance, VK_NULL_HANDLE);
43 ACQUIRE_PROC(GetPhysicalDeviceFormatProperties, instance, VK_NULL_HANDLE);
44 ACQUIRE_PROC(GetPhysicalDeviceImageFormatProperties, instance, VK_NULL_HANDLE);
45 ACQUIRE_PROC(GetPhysicalDeviceProperties, instance, VK_NULL_HANDLE);
46 ACQUIRE_PROC(GetPhysicalDeviceQueueFamilyProperties, instance, VK_NULL_HANDLE);
47 ACQUIRE_PROC(GetPhysicalDeviceMemoryProperties, instance, VK_NULL_HANDLE);
48 ACQUIRE_PROC(GetPhysicalDeviceSparseImageFormatProperties, instance, VK_NULL_HANDLE);
49 ACQUIRE_PROC(DestroyInstance, instance, VK_NULL_HANDLE);
50 ACQUIRE_PROC(CreateDevice, instance, VK_NULL_HANDLE);
51 ACQUIRE_PROC(DestroyDevice, instance, VK_NULL_HANDLE);
52 ACQUIRE_PROC(EnumerateDeviceExtensionProperties, instance, VK_NULL_HANDLE);
53 ACQUIRE_PROC(EnumerateDeviceLayerProperties, instance, VK_NULL_HANDLE);
54
55 // Device Procs.
56 ACQUIRE_PROC(GetDeviceQueue, VK_NULL_HANDLE, device);
57 ACQUIRE_PROC(QueueSubmit, VK_NULL_HANDLE, device);
58 ACQUIRE_PROC(QueueWaitIdle, VK_NULL_HANDLE, device);
59 ACQUIRE_PROC(DeviceWaitIdle, VK_NULL_HANDLE, device);
60 ACQUIRE_PROC(AllocateMemory, VK_NULL_HANDLE, device);
63 ACQUIRE_PROC(UnmapMemory, VK_NULL_HANDLE, device);
64 ACQUIRE_PROC(FlushMappedMemoryRanges, VK_NULL_HANDLE, device);
65 ACQUIRE_PROC(InvalidateMappedMemoryRanges, VK_NULL_HANDLE, device);
66 ACQUIRE_PROC(GetDeviceMemoryCommitment, VK_NULL_HANDLE, device);
67 ACQUIRE_PROC(BindBufferMemory, VK_NULL_HANDLE, device);
68 ACQUIRE_PROC(BindImageMemory, VK_NULL_HANDLE, device);
69 ACQUIRE_PROC(GetBufferMemoryRequirements, VK_NULL_HANDLE, device);
70 ACQUIRE_PROC(GetImageMemoryRequirements, VK_NULL_HANDLE, device);
71 ACQUIRE_PROC(GetImageSparseMemoryRequirements, VK_NULL_HANDLE, device);
72 ACQUIRE_PROC(QueueBindSparse, VK_NULL_HANDLE, device);
73 ACQUIRE_PROC(CreateFence, VK_NULL_HANDLE, device);
74 ACQUIRE_PROC(DestroyFence, VK_NULL_HANDLE, device);
75 ACQUIRE_PROC(ResetFences, VK_NULL_HANDLE, device);
76 ACQUIRE_PROC(GetFenceStatus, VK_NULL_HANDLE, device);
77 ACQUIRE_PROC(WaitForFences, VK_NULL_HANDLE, device);
78 ACQUIRE_PROC(CreateSemaphore, VK_NULL_HANDLE, device);
79 ACQUIRE_PROC(DestroySemaphore, VK_NULL_HANDLE, device);
81 ACQUIRE_PROC(DestroyEvent, VK_NULL_HANDLE, device);
82 ACQUIRE_PROC(GetEventStatus, VK_NULL_HANDLE, device);
85 ACQUIRE_PROC(CreateQueryPool, VK_NULL_HANDLE, device);
86 ACQUIRE_PROC(DestroyQueryPool, VK_NULL_HANDLE, device);
87 ACQUIRE_PROC(GetQueryPoolResults, VK_NULL_HANDLE, device);
88 ACQUIRE_PROC(CreateBuffer, VK_NULL_HANDLE, device);
89 ACQUIRE_PROC(DestroyBuffer, VK_NULL_HANDLE, device);
90 ACQUIRE_PROC(CreateBufferView, VK_NULL_HANDLE, device);
91 ACQUIRE_PROC(DestroyBufferView, VK_NULL_HANDLE, device);
92 ACQUIRE_PROC(CreateImage, VK_NULL_HANDLE, device);
93 ACQUIRE_PROC(DestroyImage, VK_NULL_HANDLE, device);
94 ACQUIRE_PROC(GetImageSubresourceLayout, VK_NULL_HANDLE, device);
95 ACQUIRE_PROC(CreateImageView, VK_NULL_HANDLE, device);
96 ACQUIRE_PROC(DestroyImageView, VK_NULL_HANDLE, device);
97 ACQUIRE_PROC(CreateShaderModule, VK_NULL_HANDLE, device);
98 ACQUIRE_PROC(DestroyShaderModule, VK_NULL_HANDLE, device);
99 ACQUIRE_PROC(CreatePipelineCache, VK_NULL_HANDLE, device);
100 ACQUIRE_PROC(DestroyPipelineCache, VK_NULL_HANDLE, device);
101 ACQUIRE_PROC(GetPipelineCacheData, VK_NULL_HANDLE, device);
102 ACQUIRE_PROC(MergePipelineCaches, VK_NULL_HANDLE, device);
103 ACQUIRE_PROC(CreateGraphicsPipelines, VK_NULL_HANDLE, device);
104 ACQUIRE_PROC(CreateComputePipelines, VK_NULL_HANDLE, device);
105 ACQUIRE_PROC(DestroyPipeline, VK_NULL_HANDLE, device);
106 ACQUIRE_PROC(CreatePipelineLayout, VK_NULL_HANDLE, device);
107 ACQUIRE_PROC(DestroyPipelineLayout, VK_NULL_HANDLE, device);
109 ACQUIRE_PROC(DestroySampler, VK_NULL_HANDLE, device);
110 ACQUIRE_PROC(CreateDescriptorSetLayout, VK_NULL_HANDLE, device);
111 ACQUIRE_PROC(DestroyDescriptorSetLayout, VK_NULL_HANDLE, device);
112 ACQUIRE_PROC(CreateDescriptorPool, VK_NULL_HANDLE, device);
113 ACQUIRE_PROC(DestroyDescriptorPool, VK_NULL_HANDLE, device);
114 ACQUIRE_PROC(ResetDescriptorPool, VK_NULL_HANDLE, device);
115 ACQUIRE_PROC(AllocateDescriptorSets, VK_NULL_HANDLE, device);
116 ACQUIRE_PROC(FreeDescriptorSets, VK_NULL_HANDLE, device);
117 ACQUIRE_PROC(UpdateDescriptorSets, VK_NULL_HANDLE, device);
118 ACQUIRE_PROC(CreateFramebuffer, VK_NULL_HANDLE, device);
119 ACQUIRE_PROC(DestroyFramebuffer, VK_NULL_HANDLE, device);
120 ACQUIRE_PROC(CreateRenderPass, VK_NULL_HANDLE, device);
121 ACQUIRE_PROC(DestroyRenderPass, VK_NULL_HANDLE, device);
122 ACQUIRE_PROC(GetRenderAreaGranularity, VK_NULL_HANDLE, device);
123 ACQUIRE_PROC(CreateCommandPool, VK_NULL_HANDLE, device);
124 ACQUIRE_PROC(DestroyCommandPool, VK_NULL_HANDLE, device);
125 ACQUIRE_PROC(ResetCommandPool, VK_NULL_HANDLE, device);
126 ACQUIRE_PROC(AllocateCommandBuffers, VK_NULL_HANDLE, device);
127 ACQUIRE_PROC(FreeCommandBuffers, VK_NULL_HANDLE, device);
128 ACQUIRE_PROC(BeginCommandBuffer, VK_NULL_HANDLE, device);
129 ACQUIRE_PROC(EndCommandBuffer, VK_NULL_HANDLE, device);
130 ACQUIRE_PROC(ResetCommandBuffer, VK_NULL_HANDLE, device);
131 ACQUIRE_PROC(CmdBindPipeline, VK_NULL_HANDLE, device);
132 ACQUIRE_PROC(CmdSetViewport, VK_NULL_HANDLE, device);
133 ACQUIRE_PROC(CmdSetScissor, VK_NULL_HANDLE, device);
134 ACQUIRE_PROC(CmdSetLineWidth, VK_NULL_HANDLE, device);
135 ACQUIRE_PROC(CmdSetDepthBias, VK_NULL_HANDLE, device);
136 ACQUIRE_PROC(CmdSetBlendConstants, VK_NULL_HANDLE, device);
137 ACQUIRE_PROC(CmdSetDepthBounds, VK_NULL_HANDLE, device);
138 ACQUIRE_PROC(CmdSetStencilCompareMask, VK_NULL_HANDLE, device);
139 ACQUIRE_PROC(CmdSetStencilWriteMask, VK_NULL_HANDLE, device);
140 ACQUIRE_PROC(CmdSetStencilReference, VK_NULL_HANDLE, device);
141 ACQUIRE_PROC(CmdBindDescriptorSets, VK_NULL_HANDLE, device);
142 ACQUIRE_PROC(CmdBindIndexBuffer, VK_NULL_HANDLE, device);
143 ACQUIRE_PROC(CmdBindVertexBuffers, VK_NULL_HANDLE, device);
145 ACQUIRE_PROC(CmdDrawIndexed, VK_NULL_HANDLE, device);
146 ACQUIRE_PROC(CmdDrawIndirect, VK_NULL_HANDLE, device);
147 ACQUIRE_PROC(CmdDrawIndexedIndirect, VK_NULL_HANDLE, device);
148 ACQUIRE_PROC(CmdDispatch, VK_NULL_HANDLE, device);
149 ACQUIRE_PROC(CmdDispatchIndirect, VK_NULL_HANDLE, device);
150 ACQUIRE_PROC(CmdCopyBuffer, VK_NULL_HANDLE, device);
151 ACQUIRE_PROC(CmdCopyImage, VK_NULL_HANDLE, device);
152 ACQUIRE_PROC(CmdBlitImage, VK_NULL_HANDLE, device);
153 ACQUIRE_PROC(CmdCopyBufferToImage, VK_NULL_HANDLE, device);
154 ACQUIRE_PROC(CmdCopyImageToBuffer, VK_NULL_HANDLE, device);
155 ACQUIRE_PROC(CmdUpdateBuffer, VK_NULL_HANDLE, device);
156 ACQUIRE_PROC(CmdFillBuffer, VK_NULL_HANDLE, device);
157 ACQUIRE_PROC(CmdClearColorImage, VK_NULL_HANDLE, device);
158 ACQUIRE_PROC(CmdClearDepthStencilImage, VK_NULL_HANDLE, device);
159 ACQUIRE_PROC(CmdClearAttachments, VK_NULL_HANDLE, device);
160 ACQUIRE_PROC(CmdResolveImage, VK_NULL_HANDLE, device);
161 ACQUIRE_PROC(CmdSetEvent, VK_NULL_HANDLE, device);
162 ACQUIRE_PROC(CmdResetEvent, VK_NULL_HANDLE, device);
163 ACQUIRE_PROC(CmdWaitEvents, VK_NULL_HANDLE, device);
164 ACQUIRE_PROC(CmdPipelineBarrier, VK_NULL_HANDLE, device);
165 ACQUIRE_PROC(CmdBeginQuery, VK_NULL_HANDLE, device);
166 ACQUIRE_PROC(CmdEndQuery, VK_NULL_HANDLE, device);
167 ACQUIRE_PROC(CmdResetQueryPool, VK_NULL_HANDLE, device);
168 ACQUIRE_PROC(CmdWriteTimestamp, VK_NULL_HANDLE, device);
169 ACQUIRE_PROC(CmdCopyQueryPoolResults, VK_NULL_HANDLE, device);
170 ACQUIRE_PROC(CmdPushConstants, VK_NULL_HANDLE, device);
171 ACQUIRE_PROC(CmdBeginRenderPass, VK_NULL_HANDLE, device);
172 ACQUIRE_PROC(CmdNextSubpass, VK_NULL_HANDLE, device);
173 ACQUIRE_PROC(CmdEndRenderPass, VK_NULL_HANDLE, device);
174 ACQUIRE_PROC(CmdExecuteCommands, VK_NULL_HANDLE, device);
175
176 // Functions for VK_KHR_get_physical_device_properties2
177 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
178 ACQUIRE_PROC(GetPhysicalDeviceFeatures2, instance, VK_NULL_HANDLE);
179 ACQUIRE_PROC(GetPhysicalDeviceProperties2, instance, VK_NULL_HANDLE);
180 ACQUIRE_PROC(GetPhysicalDeviceFormatProperties2, instance, VK_NULL_HANDLE);
181 ACQUIRE_PROC(GetPhysicalDeviceImageFormatProperties2, instance, VK_NULL_HANDLE);
182 ACQUIRE_PROC(GetPhysicalDeviceQueueFamilyProperties2, instance, VK_NULL_HANDLE);
183 ACQUIRE_PROC(GetPhysicalDeviceMemoryProperties2, instance, VK_NULL_HANDLE);
184 ACQUIRE_PROC(GetPhysicalDeviceSparseImageFormatProperties2, instance, VK_NULL_HANDLE);
186 1)) {
187 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceFeatures2, KHR, instance, VK_NULL_HANDLE);
188 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceProperties2, KHR, instance, VK_NULL_HANDLE);
189 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceFormatProperties2, KHR, instance, VK_NULL_HANDLE);
190 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceImageFormatProperties2, KHR, instance, VK_NULL_HANDLE);
191 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceQueueFamilyProperties2, KHR, instance, VK_NULL_HANDLE);
192 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceMemoryProperties2, KHR, instance, VK_NULL_HANDLE);
193 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceSparseImageFormatProperties2, KHR, instance,
195 }
196
197 // Functions for VK_KHR_get_memory_requirements2
198 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
199 ACQUIRE_PROC(GetImageMemoryRequirements2, VK_NULL_HANDLE, device);
200 ACQUIRE_PROC(GetBufferMemoryRequirements2, VK_NULL_HANDLE, device);
201 ACQUIRE_PROC(GetImageSparseMemoryRequirements2, VK_NULL_HANDLE, device);
202 } else if (extensions->hasExtension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, 1)) {
203 ACQUIRE_PROC_SUFFIX(GetImageMemoryRequirements2, KHR, VK_NULL_HANDLE, device);
204 ACQUIRE_PROC_SUFFIX(GetBufferMemoryRequirements2, KHR, VK_NULL_HANDLE, device);
205 ACQUIRE_PROC_SUFFIX(GetImageSparseMemoryRequirements2, KHR, VK_NULL_HANDLE, device);
206 }
207
208 // Functions for VK_KHR_bind_memory2
209 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
210 ACQUIRE_PROC(BindBufferMemory2, VK_NULL_HANDLE, device);
211 ACQUIRE_PROC(BindImageMemory2, VK_NULL_HANDLE, device);
212 } else if (extensions->hasExtension(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, 1)) {
213 ACQUIRE_PROC_SUFFIX(BindBufferMemory2, KHR, VK_NULL_HANDLE, device);
214 ACQUIRE_PROC_SUFFIX(BindImageMemory2, KHR, VK_NULL_HANDLE, device);
215 }
216
217 // Functions for VK_KHR_maintenance1 or vulkan 1.1
218 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
219 ACQUIRE_PROC(TrimCommandPool, VK_NULL_HANDLE, device);
220 } else if (extensions->hasExtension(VK_KHR_MAINTENANCE1_EXTENSION_NAME, 1)) {
221 ACQUIRE_PROC_SUFFIX(TrimCommandPool, KHR, VK_NULL_HANDLE, device);
222 }
223
224 // Functions for VK_KHR_maintenance3 or vulkan 1.1
225 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
226 ACQUIRE_PROC(GetDescriptorSetLayoutSupport, VK_NULL_HANDLE, device);
227 } else if (extensions->hasExtension(VK_KHR_MAINTENANCE3_EXTENSION_NAME, 1)) {
228 ACQUIRE_PROC_SUFFIX(GetDescriptorSetLayoutSupport, KHR, VK_NULL_HANDLE, device);
229 }
230
231 // Functions for VK_KHR_external_memory_capabilities
232 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
233 ACQUIRE_PROC(GetPhysicalDeviceExternalBufferProperties, instance, VK_NULL_HANDLE);
235 ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceExternalBufferProperties, KHR, instance,
237 }
238
239 // Functions for VK_KHR_sampler_ycbcr_conversion
240 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
241 ACQUIRE_PROC(CreateSamplerYcbcrConversion, VK_NULL_HANDLE, device);
242 ACQUIRE_PROC(DestroySamplerYcbcrConversion, VK_NULL_HANDLE, device);
243 } else if (extensions->hasExtension(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, 1)) {
244 ACQUIRE_PROC_SUFFIX(CreateSamplerYcbcrConversion, KHR, VK_NULL_HANDLE, device);
245 ACQUIRE_PROC_SUFFIX(DestroySamplerYcbcrConversion, KHR, VK_NULL_HANDLE, device);
246 }
247
248 // Functions for VK_EXT_device_fault
249 if (extensions->hasExtension(VK_EXT_DEVICE_FAULT_EXTENSION_NAME, 1)) {
250 ACQUIRE_PROC_SUFFIX(GetDeviceFaultInfo, EXT, VK_NULL_HANDLE, device);
251 }
252
253#ifdef SK_BUILD_FOR_ANDROID
254 // Functions for VK_ANDROID_external_memory_android_hardware_buffer
255 if (extensions->hasExtension(
257 ACQUIRE_PROC_SUFFIX(GetAndroidHardwareBufferProperties, ANDROID, VK_NULL_HANDLE, device);
258 ACQUIRE_PROC_SUFFIX(GetMemoryAndroidHardwareBuffer, ANDROID, VK_NULL_HANDLE, device);
259 }
260#endif
261
262}
263
264#ifdef SK_DEBUG
265 constexpr int kIsDebug = 1;
266#else
267 constexpr int kIsDebug = 0;
268#endif
269
270#define RETURN_FALSE_INTERFACE \
271 if (kIsDebug) { SkDebugf("%s:%d VulkanInterface::validate() failed.\n", __FILE__, __LINE__); } \
272 return false;
273
274bool VulkanInterface::validate(uint32_t instanceVersion,
275 uint32_t physicalDeviceVersion,
276 const VulkanExtensions* extensions) const {
277 // functions that are always required
278 if (nullptr == fFunctions.fCreateInstance ||
279 nullptr == fFunctions.fDestroyInstance ||
287 nullptr == fFunctions.fCreateDevice ||
288 nullptr == fFunctions.fDestroyDevice ||
293 nullptr == fFunctions.fGetDeviceQueue ||
294 nullptr == fFunctions.fQueueSubmit ||
295 nullptr == fFunctions.fQueueWaitIdle ||
296 nullptr == fFunctions.fDeviceWaitIdle ||
297 nullptr == fFunctions.fAllocateMemory ||
298 nullptr == fFunctions.fFreeMemory ||
299 nullptr == fFunctions.fMapMemory ||
300 nullptr == fFunctions.fUnmapMemory ||
304 nullptr == fFunctions.fBindBufferMemory ||
305 nullptr == fFunctions.fBindImageMemory ||
310 nullptr == fFunctions.fQueueBindSparse ||
311 nullptr == fFunctions.fCreateFence ||
312 nullptr == fFunctions.fDestroyFence ||
313 nullptr == fFunctions.fResetFences ||
314 nullptr == fFunctions.fGetFenceStatus ||
315 nullptr == fFunctions.fWaitForFences ||
316 nullptr == fFunctions.fCreateSemaphore ||
317 nullptr == fFunctions.fDestroySemaphore ||
318 nullptr == fFunctions.fCreateEvent ||
319 nullptr == fFunctions.fDestroyEvent ||
320 nullptr == fFunctions.fGetEventStatus ||
321 nullptr == fFunctions.fSetEvent ||
322 nullptr == fFunctions.fResetEvent ||
323 nullptr == fFunctions.fCreateQueryPool ||
324 nullptr == fFunctions.fDestroyQueryPool ||
325 nullptr == fFunctions.fGetQueryPoolResults ||
326 nullptr == fFunctions.fCreateBuffer ||
327 nullptr == fFunctions.fDestroyBuffer ||
328 nullptr == fFunctions.fCreateBufferView ||
329 nullptr == fFunctions.fDestroyBufferView ||
330 nullptr == fFunctions.fCreateImage ||
331 nullptr == fFunctions.fDestroyImage ||
333 nullptr == fFunctions.fCreateImageView ||
334 nullptr == fFunctions.fDestroyImageView ||
335 nullptr == fFunctions.fCreateShaderModule ||
336 nullptr == fFunctions.fDestroyShaderModule ||
337 nullptr == fFunctions.fCreatePipelineCache ||
340 nullptr == fFunctions.fMergePipelineCaches ||
343 nullptr == fFunctions.fDestroyPipeline ||
346 nullptr == fFunctions.fCreateSampler ||
347 nullptr == fFunctions.fDestroySampler ||
352 nullptr == fFunctions.fResetDescriptorPool ||
354 nullptr == fFunctions.fFreeDescriptorSets ||
356 nullptr == fFunctions.fCreateFramebuffer ||
357 nullptr == fFunctions.fDestroyFramebuffer ||
358 nullptr == fFunctions.fCreateRenderPass ||
359 nullptr == fFunctions.fDestroyRenderPass ||
361 nullptr == fFunctions.fCreateCommandPool ||
362 nullptr == fFunctions.fDestroyCommandPool ||
363 nullptr == fFunctions.fResetCommandPool ||
365 nullptr == fFunctions.fFreeCommandBuffers ||
366 nullptr == fFunctions.fBeginCommandBuffer ||
367 nullptr == fFunctions.fEndCommandBuffer ||
368 nullptr == fFunctions.fResetCommandBuffer ||
369 nullptr == fFunctions.fCmdBindPipeline ||
370 nullptr == fFunctions.fCmdSetViewport ||
371 nullptr == fFunctions.fCmdSetScissor ||
372 nullptr == fFunctions.fCmdSetLineWidth ||
373 nullptr == fFunctions.fCmdSetDepthBias ||
375 nullptr == fFunctions.fCmdSetDepthBounds ||
380 nullptr == fFunctions.fCmdBindIndexBuffer ||
382 nullptr == fFunctions.fCmdDraw ||
383 nullptr == fFunctions.fCmdDrawIndexed ||
384 nullptr == fFunctions.fCmdDrawIndirect ||
386 nullptr == fFunctions.fCmdDispatch ||
387 nullptr == fFunctions.fCmdDispatchIndirect ||
388 nullptr == fFunctions.fCmdCopyBuffer ||
389 nullptr == fFunctions.fCmdCopyImage ||
390 nullptr == fFunctions.fCmdBlitImage ||
393 nullptr == fFunctions.fCmdUpdateBuffer ||
394 nullptr == fFunctions.fCmdFillBuffer ||
395 nullptr == fFunctions.fCmdClearColorImage ||
397 nullptr == fFunctions.fCmdClearAttachments ||
398 nullptr == fFunctions.fCmdResolveImage ||
399 nullptr == fFunctions.fCmdSetEvent ||
400 nullptr == fFunctions.fCmdResetEvent ||
401 nullptr == fFunctions.fCmdWaitEvents ||
402 nullptr == fFunctions.fCmdPipelineBarrier ||
403 nullptr == fFunctions.fCmdBeginQuery ||
404 nullptr == fFunctions.fCmdEndQuery ||
405 nullptr == fFunctions.fCmdResetQueryPool ||
406 nullptr == fFunctions.fCmdWriteTimestamp ||
408 nullptr == fFunctions.fCmdPushConstants ||
409 nullptr == fFunctions.fCmdBeginRenderPass ||
410 nullptr == fFunctions.fCmdNextSubpass ||
411 nullptr == fFunctions.fCmdEndRenderPass ||
412 nullptr == fFunctions.fCmdExecuteCommands) {
414 }
415
416 // Functions for VK_KHR_get_physical_device_properties2 or vulkan 1.1
417 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
427 }
428 }
429
430 // Functions for VK_KHR_get_memory_requirements2 or vulkan 1.1
431 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
437 }
438 }
439
440 // Functions for VK_KHR_bind_memory2
441 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
443 if (nullptr == fFunctions.fBindBufferMemory2 ||
444 nullptr == fFunctions.fBindImageMemory2) {
446 }
447 }
448
449 // Functions for VK_KHR_maintenance1 or vulkan 1.1
450 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
452 if (nullptr == fFunctions.fTrimCommandPool) {
454 }
455 }
456
457 // Functions for VK_KHR_maintenance3 or vulkan 1.1
458 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
462 }
463 }
464
465 // Functions for VK_KHR_external_memory_capabilities
466 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
470 }
471 }
472
473 // Functions for VK_KHR_sampler_ycbcr_conversion
474 if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
479 }
480 }
481
482#ifdef SK_BUILD_FOR_ANDROID
483 // Functions for VK_ANDROID_external_memory_android_hardware_buffer
484 if (extensions->hasExtension(
486 if (nullptr == fFunctions.fGetAndroidHardwareBufferProperties ||
487 nullptr == fFunctions.fGetMemoryAndroidHardwareBuffer) {
489 }
490 }
491#endif
492
493 return true;
494}
495
496} // namespace skgpu
497
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define ACQUIRE_PROC(name, instance, device)
#define ACQUIRE_PROC_SUFFIX(name, suffix, instance, device)
#define RETURN_FALSE_INTERFACE
VkDevice device
Definition: main.cc:53
VkInstance instance
Definition: main.cc:48
static vk::UniqueSampler CreateSampler(const vk::Device &device, const SamplerDescriptor &desc, const std::shared_ptr< YUVConversionVK > &yuv_conversion)
Definition: sampler_vk.cc:14
Definition: GpuTools.h:21
constexpr int kIsDebug
std::function< PFN_vkVoidFunction(const char *, VkInstance, VkDevice)> VulkanGetProc
Definition: VulkanTypes.h:30
VkPtr< PFN_vkCmdSetStencilReference > fCmdSetStencilReference
VkPtr< PFN_vkGetImageSparseMemoryRequirements2 > fGetImageSparseMemoryRequirements2
VkPtr< PFN_vkCmdDrawIndexed > fCmdDrawIndexed
VkPtr< PFN_vkDestroyPipelineCache > fDestroyPipelineCache
VkPtr< PFN_vkEnumerateInstanceExtensionProperties > fEnumerateInstanceExtensionProperties
VkPtr< PFN_vkCmdBindDescriptorSets > fCmdBindDescriptorSets
VkPtr< PFN_vkAllocateMemory > fAllocateMemory
VkPtr< PFN_vkGetPhysicalDeviceImageFormatProperties > fGetPhysicalDeviceImageFormatProperties
VkPtr< PFN_vkGetBufferMemoryRequirements > fGetBufferMemoryRequirements
VkPtr< PFN_vkCmdBeginQuery > fCmdBeginQuery
VkPtr< PFN_vkCmdNextSubpass > fCmdNextSubpass
VkPtr< PFN_vkCreateSemaphore > fCreateSemaphore
VkPtr< PFN_vkCmdUpdateBuffer > fCmdUpdateBuffer
VkPtr< PFN_vkQueueSubmit > fQueueSubmit
VkPtr< PFN_vkDestroyFramebuffer > fDestroyFramebuffer
VkPtr< PFN_vkGetPhysicalDeviceFeatures2 > fGetPhysicalDeviceFeatures2
VkPtr< PFN_vkSetEvent > fSetEvent
VkPtr< PFN_vkDestroyFence > fDestroyFence
VkPtr< PFN_vkQueueBindSparse > fQueueBindSparse
VkPtr< PFN_vkBindBufferMemory2 > fBindBufferMemory2
VkPtr< PFN_vkCmdSetLineWidth > fCmdSetLineWidth
VkPtr< PFN_vkCreateQueryPool > fCreateQueryPool
VkPtr< PFN_vkCreateSampler > fCreateSampler
VkPtr< PFN_vkDestroyDescriptorSetLayout > fDestroyDescriptorSetLayout
VkPtr< PFN_vkCmdClearDepthStencilImage > fCmdClearDepthStencilImage
VkPtr< PFN_vkCreateSamplerYcbcrConversion > fCreateSamplerYcbcrConversion
VkPtr< PFN_vkGetEventStatus > fGetEventStatus
VkPtr< PFN_vkUnmapMemory > fUnmapMemory
VkPtr< PFN_vkEnumerateInstanceLayerProperties > fEnumerateInstanceLayerProperties
VkPtr< PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 > fGetPhysicalDeviceSparseImageFormatProperties2
VkPtr< PFN_vkGetPhysicalDeviceQueueFamilyProperties > fGetPhysicalDeviceQueueFamilyProperties
VkPtr< PFN_vkCmdBeginRenderPass > fCmdBeginRenderPass
VkPtr< PFN_vkResetFences > fResetFences
VkPtr< PFN_vkCmdSetViewport > fCmdSetViewport
VkPtr< PFN_vkCmdFillBuffer > fCmdFillBuffer
VkPtr< PFN_vkCreatePipelineLayout > fCreatePipelineLayout
VkPtr< PFN_vkDestroyInstance > fDestroyInstance
VkPtr< PFN_vkAllocateDescriptorSets > fAllocateDescriptorSets
VkPtr< PFN_vkCmdClearAttachments > fCmdClearAttachments
VkPtr< PFN_vkTrimCommandPool > fTrimCommandPool
VkPtr< PFN_vkBindBufferMemory > fBindBufferMemory
VkPtr< PFN_vkDestroyImageView > fDestroyImageView
VkPtr< PFN_vkCmdResolveImage > fCmdResolveImage
VkPtr< PFN_vkCreatePipelineCache > fCreatePipelineCache
VkPtr< PFN_vkResetCommandPool > fResetCommandPool
VkPtr< PFN_vkFreeCommandBuffers > fFreeCommandBuffers
VkPtr< PFN_vkCreateComputePipelines > fCreateComputePipelines
VkPtr< PFN_vkDestroyDevice > fDestroyDevice
VkPtr< PFN_vkCreateEvent > fCreateEvent
VkPtr< PFN_vkGetFenceStatus > fGetFenceStatus
VkPtr< PFN_vkCreateDescriptorPool > fCreateDescriptorPool
VkPtr< PFN_vkCmdSetStencilCompareMask > fCmdSetStencilCompareMask
VkPtr< PFN_vkEndCommandBuffer > fEndCommandBuffer
VkPtr< PFN_vkGetPhysicalDeviceMemoryProperties > fGetPhysicalDeviceMemoryProperties
VkPtr< PFN_vkCmdDrawIndirect > fCmdDrawIndirect
VkPtr< PFN_vkCmdSetDepthBounds > fCmdSetDepthBounds
VkPtr< PFN_vkGetImageMemoryRequirements > fGetImageMemoryRequirements
VkPtr< PFN_vkCmdDispatch > fCmdDispatch
VkPtr< PFN_vkDestroySampler > fDestroySampler
VkPtr< PFN_vkCreateDescriptorSetLayout > fCreateDescriptorSetLayout
VkPtr< PFN_vkFreeMemory > fFreeMemory
VkPtr< PFN_vkFlushMappedMemoryRanges > fFlushMappedMemoryRanges
VkPtr< PFN_vkGetDescriptorSetLayoutSupport > fGetDescriptorSetLayoutSupport
VkPtr< PFN_vkCmdEndQuery > fCmdEndQuery
VkPtr< PFN_vkCreateGraphicsPipelines > fCreateGraphicsPipelines
VkPtr< PFN_vkDeviceWaitIdle > fDeviceWaitIdle
VkPtr< PFN_vkEnumeratePhysicalDevices > fEnumeratePhysicalDevices
VkPtr< PFN_vkCreateBuffer > fCreateBuffer
VkPtr< PFN_vkCmdSetEvent > fCmdSetEvent
VkPtr< PFN_vkCreateImageView > fCreateImageView
VkPtr< PFN_vkGetDeviceQueue > fGetDeviceQueue
VkPtr< PFN_vkFreeDescriptorSets > fFreeDescriptorSets
VkPtr< PFN_vkGetBufferMemoryRequirements2 > fGetBufferMemoryRequirements2
VkPtr< PFN_vkGetPhysicalDeviceFormatProperties > fGetPhysicalDeviceFormatProperties
VkPtr< PFN_vkCmdResetQueryPool > fCmdResetQueryPool
VkPtr< PFN_vkEnumerateDeviceLayerProperties > fEnumerateDeviceLayerProperties
VkPtr< PFN_vkGetPhysicalDeviceSparseImageFormatProperties > fGetPhysicalDeviceSparseImageFormatProperties
VkPtr< PFN_vkWaitForFences > fWaitForFences
VkPtr< PFN_vkResetDescriptorPool > fResetDescriptorPool
VkPtr< PFN_vkGetPhysicalDeviceFormatProperties2 > fGetPhysicalDeviceFormatProperties2
VkPtr< PFN_vkCmdPipelineBarrier > fCmdPipelineBarrier
VkPtr< PFN_vkGetPhysicalDeviceImageFormatProperties2 > fGetPhysicalDeviceImageFormatProperties2
VkPtr< PFN_vkCreateInstance > fCreateInstance
VkPtr< PFN_vkCmdSetScissor > fCmdSetScissor
VkPtr< PFN_vkDestroyQueryPool > fDestroyQueryPool
VkPtr< PFN_vkGetImageSubresourceLayout > fGetImageSubresourceLayout
VkPtr< PFN_vkCreateImage > fCreateImage
VkPtr< PFN_vkGetPipelineCacheData > fGetPipelineCacheData
VkPtr< PFN_vkGetDeviceMemoryCommitment > fGetDeviceMemoryCommitment
VkPtr< PFN_vkInvalidateMappedMemoryRanges > fInvalidateMappedMemoryRanges
VkPtr< PFN_vkUpdateDescriptorSets > fUpdateDescriptorSets
VkPtr< PFN_vkCmdResetEvent > fCmdResetEvent
VkPtr< PFN_vkCmdSetStencilWriteMask > fCmdSetStencilWriteMask
VkPtr< PFN_vkResetCommandBuffer > fResetCommandBuffer
VkPtr< PFN_vkCmdBindPipeline > fCmdBindPipeline
VkPtr< PFN_vkDestroyPipelineLayout > fDestroyPipelineLayout
VkPtr< PFN_vkCreateShaderModule > fCreateShaderModule
VkPtr< PFN_vkDestroySemaphore > fDestroySemaphore
VkPtr< PFN_vkCmdDrawIndexedIndirect > fCmdDrawIndexedIndirect
VkPtr< PFN_vkCmdEndRenderPass > fCmdEndRenderPass
VkPtr< PFN_vkDestroyDescriptorPool > fDestroyDescriptorPool
VkPtr< PFN_vkCmdCopyImageToBuffer > fCmdCopyImageToBuffer
VkPtr< PFN_vkGetPhysicalDeviceProperties > fGetPhysicalDeviceProperties
VkPtr< PFN_vkCreateDevice > fCreateDevice
VkPtr< PFN_vkEnumerateDeviceExtensionProperties > fEnumerateDeviceExtensionProperties
VkPtr< PFN_vkDestroyCommandPool > fDestroyCommandPool
VkPtr< PFN_vkGetQueryPoolResults > fGetQueryPoolResults
VkPtr< PFN_vkCreateFramebuffer > fCreateFramebuffer
VkPtr< PFN_vkGetPhysicalDeviceMemoryProperties2 > fGetPhysicalDeviceMemoryProperties2
VkPtr< PFN_vkGetImageMemoryRequirements2 > fGetImageMemoryRequirements2
VkPtr< PFN_vkGetRenderAreaGranularity > fGetRenderAreaGranularity
VkPtr< PFN_vkCreateBufferView > fCreateBufferView
VkPtr< PFN_vkCmdWaitEvents > fCmdWaitEvents
VkPtr< PFN_vkAllocateCommandBuffers > fAllocateCommandBuffers
VkPtr< PFN_vkCmdSetBlendConstants > fCmdSetBlendConstants
VkPtr< PFN_vkDestroyEvent > fDestroyEvent
VkPtr< PFN_vkCmdDraw > fCmdDraw
VkPtr< PFN_vkCmdBlitImage > fCmdBlitImage
VkPtr< PFN_vkGetPhysicalDeviceFeatures > fGetPhysicalDeviceFeatures
VkPtr< PFN_vkCmdSetDepthBias > fCmdSetDepthBias
VkPtr< PFN_vkCmdCopyImage > fCmdCopyImage
VkPtr< PFN_vkMapMemory > fMapMemory
VkPtr< PFN_vkCreateRenderPass > fCreateRenderPass
VkPtr< PFN_vkCmdBindVertexBuffers > fCmdBindVertexBuffers
VkPtr< PFN_vkGetPhysicalDeviceExternalBufferProperties > fGetPhysicalDeviceExternalBufferProperties
VkPtr< PFN_vkCmdWriteTimestamp > fCmdWriteTimestamp
VkPtr< PFN_vkResetEvent > fResetEvent
VkPtr< PFN_vkDestroyBufferView > fDestroyBufferView
VkPtr< PFN_vkDestroyRenderPass > fDestroyRenderPass
VkPtr< PFN_vkDestroyPipeline > fDestroyPipeline
VkPtr< PFN_vkCmdPushConstants > fCmdPushConstants
VkPtr< PFN_vkCmdCopyBuffer > fCmdCopyBuffer
VkPtr< PFN_vkBeginCommandBuffer > fBeginCommandBuffer
VkPtr< PFN_vkCmdCopyBufferToImage > fCmdCopyBufferToImage
VkPtr< PFN_vkCreateFence > fCreateFence
VkPtr< PFN_vkGetImageSparseMemoryRequirements > fGetImageSparseMemoryRequirements
VkPtr< PFN_vkDestroyShaderModule > fDestroyShaderModule
VkPtr< PFN_vkQueueWaitIdle > fQueueWaitIdle
VkPtr< PFN_vkBindImageMemory2 > fBindImageMemory2
VkPtr< PFN_vkGetPhysicalDeviceProperties2 > fGetPhysicalDeviceProperties2
VkPtr< PFN_vkCmdExecuteCommands > fCmdExecuteCommands
VkPtr< PFN_vkCreateCommandPool > fCreateCommandPool
VkPtr< PFN_vkCmdCopyQueryPoolResults > fCmdCopyQueryPoolResults
VkPtr< PFN_vkCmdClearColorImage > fCmdClearColorImage
VkPtr< PFN_vkDestroyBuffer > fDestroyBuffer
VkPtr< PFN_vkDestroySamplerYcbcrConversion > fDestroySamplerYcbcrConversion
VkPtr< PFN_vkDestroyImage > fDestroyImage
VkPtr< PFN_vkCmdDispatchIndirect > fCmdDispatchIndirect
VkPtr< PFN_vkBindImageMemory > fBindImageMemory
VkPtr< PFN_vkMergePipelineCaches > fMergePipelineCaches
VkPtr< PFN_vkGetPhysicalDeviceQueueFamilyProperties2 > fGetPhysicalDeviceQueueFamilyProperties2
VkPtr< PFN_vkCmdBindIndexBuffer > fCmdBindIndexBuffer
VulkanInterface(VulkanGetProc getProc, VkInstance instance, VkDevice device, uint32_t instanceVersion, uint32_t physicalDeviceVersion, const VulkanExtensions *)
struct skgpu::VulkanInterface::Functions fFunctions
bool validate(uint32_t instanceVersion, uint32_t physicalDeviceVersion, const VulkanExtensions *) const
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME
#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME
Definition: vulkan_core.h:8673
#define VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME
Definition: vulkan_core.h:9443
#define VK_KHR_MAINTENANCE3_EXTENSION_NAME
Definition: vulkan_core.h:9508
#define VK_MAKE_VERSION(major, minor, patch)
Definition: vulkan_core.h:78
#define VK_KHR_MAINTENANCE1_EXTENSION_NAME
Definition: vulkan_core.h:8638
#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME
Definition: vulkan_core.h:9396
#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
Definition: vulkan_core.h:8511
#define VK_EXT_DEVICE_FAULT_EXTENSION_NAME
#define VK_KHR_BIND_MEMORY_2_EXTENSION_NAME
Definition: vulkan_core.h:9482
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
#define CreateEvent