Home | History | Annotate | Download | only in vk
      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  */
      7 
      8 #include "GrVkInterface.h"
      9 #include "vk/GrVkBackendContext.h"
     10 #include "vk/GrVkExtensions.h"
     11 #include "vk/GrVkUtil.h"
     12 
     13 #define ACQUIRE_PROC(name, instance, device) \
     14     fFunctions.f##name = reinterpret_cast<PFN_vk##name>(getProc("vk" #name, instance, device))
     15 
     16 #define ACQUIRE_PROC_SUFFIX(name, suffix, instance, device) \
     17     fFunctions.f##name =                                    \
     18             reinterpret_cast<PFN_vk##name##suffix>(getProc("vk" #name #suffix, instance, device))
     19 
     20 GrVkInterface::GrVkInterface(GrVkGetProc getProc,
     21                              VkInstance instance,
     22                              VkDevice device,
     23                              uint32_t instanceVersion,
     24                              uint32_t physicalDeviceVersion,
     25                              const GrVkExtensions* extensions) {
     26     if (getProc == nullptr) {
     27         return;
     28     }
     29     // Global/Loader Procs.
     30     ACQUIRE_PROC(CreateInstance, VK_NULL_HANDLE, VK_NULL_HANDLE);
     31     ACQUIRE_PROC(EnumerateInstanceExtensionProperties, VK_NULL_HANDLE, VK_NULL_HANDLE);
     32     ACQUIRE_PROC(EnumerateInstanceLayerProperties, VK_NULL_HANDLE, VK_NULL_HANDLE);
     33 
     34     // Instance Procs.
     35     ACQUIRE_PROC(EnumeratePhysicalDevices, instance, VK_NULL_HANDLE);
     36     ACQUIRE_PROC(GetPhysicalDeviceFeatures, instance, VK_NULL_HANDLE);
     37     ACQUIRE_PROC(GetPhysicalDeviceFormatProperties, instance, VK_NULL_HANDLE);
     38     ACQUIRE_PROC(GetPhysicalDeviceImageFormatProperties, instance, VK_NULL_HANDLE);
     39     ACQUIRE_PROC(GetPhysicalDeviceProperties, instance, VK_NULL_HANDLE);
     40     ACQUIRE_PROC(GetPhysicalDeviceQueueFamilyProperties, instance, VK_NULL_HANDLE);
     41     ACQUIRE_PROC(GetPhysicalDeviceMemoryProperties, instance, VK_NULL_HANDLE);
     42     ACQUIRE_PROC(GetPhysicalDeviceSparseImageFormatProperties, instance, VK_NULL_HANDLE);
     43     ACQUIRE_PROC(DestroyInstance, instance, VK_NULL_HANDLE);
     44     ACQUIRE_PROC(CreateDevice, instance, VK_NULL_HANDLE);
     45     ACQUIRE_PROC(DestroyDevice, instance, VK_NULL_HANDLE);
     46     ACQUIRE_PROC(EnumerateDeviceExtensionProperties, instance, VK_NULL_HANDLE);
     47     ACQUIRE_PROC(EnumerateDeviceLayerProperties, instance, VK_NULL_HANDLE);
     48 
     49     // Device Procs.
     50     ACQUIRE_PROC(GetDeviceQueue, VK_NULL_HANDLE, device);
     51     ACQUIRE_PROC(QueueSubmit, VK_NULL_HANDLE, device);
     52     ACQUIRE_PROC(QueueWaitIdle, VK_NULL_HANDLE, device);
     53     ACQUIRE_PROC(DeviceWaitIdle, VK_NULL_HANDLE, device);
     54     ACQUIRE_PROC(AllocateMemory, VK_NULL_HANDLE, device);
     55     ACQUIRE_PROC(FreeMemory, VK_NULL_HANDLE, device);
     56     ACQUIRE_PROC(MapMemory, VK_NULL_HANDLE, device);
     57     ACQUIRE_PROC(UnmapMemory, VK_NULL_HANDLE, device);
     58     ACQUIRE_PROC(FlushMappedMemoryRanges, VK_NULL_HANDLE, device);
     59     ACQUIRE_PROC(InvalidateMappedMemoryRanges, VK_NULL_HANDLE, device);
     60     ACQUIRE_PROC(GetDeviceMemoryCommitment, VK_NULL_HANDLE, device);
     61     ACQUIRE_PROC(BindBufferMemory, VK_NULL_HANDLE, device);
     62     ACQUIRE_PROC(BindImageMemory, VK_NULL_HANDLE, device);
     63     ACQUIRE_PROC(GetBufferMemoryRequirements, VK_NULL_HANDLE, device);
     64     ACQUIRE_PROC(GetImageMemoryRequirements, VK_NULL_HANDLE, device);
     65     ACQUIRE_PROC(GetImageSparseMemoryRequirements, VK_NULL_HANDLE, device);
     66     ACQUIRE_PROC(QueueBindSparse, VK_NULL_HANDLE, device);
     67     ACQUIRE_PROC(CreateFence, VK_NULL_HANDLE, device);
     68     ACQUIRE_PROC(DestroyFence, VK_NULL_HANDLE, device);
     69     ACQUIRE_PROC(ResetFences, VK_NULL_HANDLE, device);
     70     ACQUIRE_PROC(GetFenceStatus, VK_NULL_HANDLE, device);
     71     ACQUIRE_PROC(WaitForFences, VK_NULL_HANDLE, device);
     72     ACQUIRE_PROC(CreateSemaphore, VK_NULL_HANDLE, device);
     73     ACQUIRE_PROC(DestroySemaphore, VK_NULL_HANDLE, device);
     74     ACQUIRE_PROC(CreateEvent, VK_NULL_HANDLE, device);
     75     ACQUIRE_PROC(DestroyEvent, VK_NULL_HANDLE, device);
     76     ACQUIRE_PROC(GetEventStatus, VK_NULL_HANDLE, device);
     77     ACQUIRE_PROC(SetEvent, VK_NULL_HANDLE, device);
     78     ACQUIRE_PROC(ResetEvent, VK_NULL_HANDLE, device);
     79     ACQUIRE_PROC(CreateQueryPool, VK_NULL_HANDLE, device);
     80     ACQUIRE_PROC(DestroyQueryPool, VK_NULL_HANDLE, device);
     81     ACQUIRE_PROC(GetQueryPoolResults, VK_NULL_HANDLE, device);
     82     ACQUIRE_PROC(CreateBuffer, VK_NULL_HANDLE, device);
     83     ACQUIRE_PROC(DestroyBuffer, VK_NULL_HANDLE, device);
     84     ACQUIRE_PROC(CreateBufferView, VK_NULL_HANDLE, device);
     85     ACQUIRE_PROC(DestroyBufferView, VK_NULL_HANDLE, device);
     86     ACQUIRE_PROC(CreateImage, VK_NULL_HANDLE, device);
     87     ACQUIRE_PROC(DestroyImage, VK_NULL_HANDLE, device);
     88     ACQUIRE_PROC(GetImageSubresourceLayout, VK_NULL_HANDLE, device);
     89     ACQUIRE_PROC(CreateImageView, VK_NULL_HANDLE, device);
     90     ACQUIRE_PROC(DestroyImageView, VK_NULL_HANDLE, device);
     91     ACQUIRE_PROC(CreateShaderModule, VK_NULL_HANDLE, device);
     92     ACQUIRE_PROC(DestroyShaderModule, VK_NULL_HANDLE, device);
     93     ACQUIRE_PROC(CreatePipelineCache, VK_NULL_HANDLE, device);
     94     ACQUIRE_PROC(DestroyPipelineCache, VK_NULL_HANDLE, device);
     95     ACQUIRE_PROC(GetPipelineCacheData, VK_NULL_HANDLE, device);
     96     ACQUIRE_PROC(MergePipelineCaches, VK_NULL_HANDLE, device);
     97     ACQUIRE_PROC(CreateGraphicsPipelines, VK_NULL_HANDLE, device);
     98     ACQUIRE_PROC(CreateComputePipelines, VK_NULL_HANDLE, device);
     99     ACQUIRE_PROC(DestroyPipeline, VK_NULL_HANDLE, device);
    100     ACQUIRE_PROC(CreatePipelineLayout, VK_NULL_HANDLE, device);
    101     ACQUIRE_PROC(DestroyPipelineLayout, VK_NULL_HANDLE, device);
    102     ACQUIRE_PROC(CreateSampler, VK_NULL_HANDLE, device);
    103     ACQUIRE_PROC(DestroySampler, VK_NULL_HANDLE, device);
    104     ACQUIRE_PROC(CreateDescriptorSetLayout, VK_NULL_HANDLE, device);
    105     ACQUIRE_PROC(DestroyDescriptorSetLayout, VK_NULL_HANDLE, device);
    106     ACQUIRE_PROC(CreateDescriptorPool, VK_NULL_HANDLE, device);
    107     ACQUIRE_PROC(DestroyDescriptorPool, VK_NULL_HANDLE, device);
    108     ACQUIRE_PROC(ResetDescriptorPool, VK_NULL_HANDLE, device);
    109     ACQUIRE_PROC(AllocateDescriptorSets, VK_NULL_HANDLE, device);
    110     ACQUIRE_PROC(FreeDescriptorSets, VK_NULL_HANDLE, device);
    111     ACQUIRE_PROC(UpdateDescriptorSets, VK_NULL_HANDLE, device);
    112     ACQUIRE_PROC(CreateFramebuffer, VK_NULL_HANDLE, device);
    113     ACQUIRE_PROC(DestroyFramebuffer, VK_NULL_HANDLE, device);
    114     ACQUIRE_PROC(CreateRenderPass, VK_NULL_HANDLE, device);
    115     ACQUIRE_PROC(DestroyRenderPass, VK_NULL_HANDLE, device);
    116     ACQUIRE_PROC(GetRenderAreaGranularity, VK_NULL_HANDLE, device);
    117     ACQUIRE_PROC(CreateCommandPool, VK_NULL_HANDLE, device);
    118     ACQUIRE_PROC(DestroyCommandPool, VK_NULL_HANDLE, device);
    119     ACQUIRE_PROC(ResetCommandPool, VK_NULL_HANDLE, device);
    120     ACQUIRE_PROC(AllocateCommandBuffers, VK_NULL_HANDLE, device);
    121     ACQUIRE_PROC(FreeCommandBuffers, VK_NULL_HANDLE, device);
    122     ACQUIRE_PROC(BeginCommandBuffer, VK_NULL_HANDLE, device);
    123     ACQUIRE_PROC(EndCommandBuffer, VK_NULL_HANDLE, device);
    124     ACQUIRE_PROC(ResetCommandBuffer, VK_NULL_HANDLE, device);
    125     ACQUIRE_PROC(CmdBindPipeline, VK_NULL_HANDLE, device);
    126     ACQUIRE_PROC(CmdSetViewport, VK_NULL_HANDLE, device);
    127     ACQUIRE_PROC(CmdSetScissor, VK_NULL_HANDLE, device);
    128     ACQUIRE_PROC(CmdSetLineWidth, VK_NULL_HANDLE, device);
    129     ACQUIRE_PROC(CmdSetDepthBias, VK_NULL_HANDLE, device);
    130     ACQUIRE_PROC(CmdSetBlendConstants, VK_NULL_HANDLE, device);
    131     ACQUIRE_PROC(CmdSetDepthBounds, VK_NULL_HANDLE, device);
    132     ACQUIRE_PROC(CmdSetStencilCompareMask, VK_NULL_HANDLE, device);
    133     ACQUIRE_PROC(CmdSetStencilWriteMask, VK_NULL_HANDLE, device);
    134     ACQUIRE_PROC(CmdSetStencilReference, VK_NULL_HANDLE, device);
    135     ACQUIRE_PROC(CmdBindDescriptorSets, VK_NULL_HANDLE, device);
    136     ACQUIRE_PROC(CmdBindIndexBuffer, VK_NULL_HANDLE, device);
    137     ACQUIRE_PROC(CmdBindVertexBuffers, VK_NULL_HANDLE, device);
    138     ACQUIRE_PROC(CmdDraw, VK_NULL_HANDLE, device);
    139     ACQUIRE_PROC(CmdDrawIndexed, VK_NULL_HANDLE, device);
    140     ACQUIRE_PROC(CmdDrawIndirect, VK_NULL_HANDLE, device);
    141     ACQUIRE_PROC(CmdDrawIndexedIndirect, VK_NULL_HANDLE, device);
    142     ACQUIRE_PROC(CmdDispatch, VK_NULL_HANDLE, device);
    143     ACQUIRE_PROC(CmdDispatchIndirect, VK_NULL_HANDLE, device);
    144     ACQUIRE_PROC(CmdCopyBuffer, VK_NULL_HANDLE, device);
    145     ACQUIRE_PROC(CmdCopyImage, VK_NULL_HANDLE, device);
    146     ACQUIRE_PROC(CmdBlitImage, VK_NULL_HANDLE, device);
    147     ACQUIRE_PROC(CmdCopyBufferToImage, VK_NULL_HANDLE, device);
    148     ACQUIRE_PROC(CmdCopyImageToBuffer, VK_NULL_HANDLE, device);
    149     ACQUIRE_PROC(CmdUpdateBuffer, VK_NULL_HANDLE, device);
    150     ACQUIRE_PROC(CmdFillBuffer, VK_NULL_HANDLE, device);
    151     ACQUIRE_PROC(CmdClearColorImage, VK_NULL_HANDLE, device);
    152     ACQUIRE_PROC(CmdClearDepthStencilImage, VK_NULL_HANDLE, device);
    153     ACQUIRE_PROC(CmdClearAttachments, VK_NULL_HANDLE, device);
    154     ACQUIRE_PROC(CmdResolveImage, VK_NULL_HANDLE, device);
    155     ACQUIRE_PROC(CmdSetEvent, VK_NULL_HANDLE, device);
    156     ACQUIRE_PROC(CmdResetEvent, VK_NULL_HANDLE, device);
    157     ACQUIRE_PROC(CmdWaitEvents, VK_NULL_HANDLE, device);
    158     ACQUIRE_PROC(CmdPipelineBarrier, VK_NULL_HANDLE, device);
    159     ACQUIRE_PROC(CmdBeginQuery, VK_NULL_HANDLE, device);
    160     ACQUIRE_PROC(CmdEndQuery, VK_NULL_HANDLE, device);
    161     ACQUIRE_PROC(CmdResetQueryPool, VK_NULL_HANDLE, device);
    162     ACQUIRE_PROC(CmdWriteTimestamp, VK_NULL_HANDLE, device);
    163     ACQUIRE_PROC(CmdCopyQueryPoolResults, VK_NULL_HANDLE, device);
    164     ACQUIRE_PROC(CmdPushConstants, VK_NULL_HANDLE, device);
    165     ACQUIRE_PROC(CmdBeginRenderPass, VK_NULL_HANDLE, device);
    166     ACQUIRE_PROC(CmdNextSubpass, VK_NULL_HANDLE, device);
    167     ACQUIRE_PROC(CmdEndRenderPass, VK_NULL_HANDLE, device);
    168     ACQUIRE_PROC(CmdExecuteCommands, VK_NULL_HANDLE, device);
    169 
    170     // Functions for VK_KHR_get_physical_device_properties2
    171     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
    172         ACQUIRE_PROC(GetPhysicalDeviceFeatures2, instance, VK_NULL_HANDLE);
    173         ACQUIRE_PROC(GetPhysicalDeviceProperties2, instance, VK_NULL_HANDLE);
    174         ACQUIRE_PROC(GetPhysicalDeviceFormatProperties2, instance, VK_NULL_HANDLE);
    175         ACQUIRE_PROC(GetPhysicalDeviceImageFormatProperties2, instance, VK_NULL_HANDLE);
    176         ACQUIRE_PROC(GetPhysicalDeviceQueueFamilyProperties2, instance, VK_NULL_HANDLE);
    177         ACQUIRE_PROC(GetPhysicalDeviceMemoryProperties2, instance, VK_NULL_HANDLE);
    178         ACQUIRE_PROC(GetPhysicalDeviceSparseImageFormatProperties2, instance, VK_NULL_HANDLE);
    179     } else if (extensions->hasExtension(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
    180                                         1)) {
    181         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceFeatures2, KHR, instance, VK_NULL_HANDLE);
    182         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceProperties2, KHR, instance, VK_NULL_HANDLE);
    183         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceFormatProperties2, KHR, instance, VK_NULL_HANDLE);
    184         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceImageFormatProperties2, KHR, instance, VK_NULL_HANDLE);
    185         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceQueueFamilyProperties2, KHR, instance, VK_NULL_HANDLE);
    186         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceMemoryProperties2, KHR, instance, VK_NULL_HANDLE);
    187         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceSparseImageFormatProperties2, KHR, instance,
    188                             VK_NULL_HANDLE);
    189     }
    190 
    191     // Functions for VK_KHR_get_memory_requirements2
    192     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
    193         ACQUIRE_PROC(GetImageMemoryRequirements2, VK_NULL_HANDLE, device);
    194         ACQUIRE_PROC(GetBufferMemoryRequirements2, VK_NULL_HANDLE, device);
    195         ACQUIRE_PROC(GetImageSparseMemoryRequirements2, VK_NULL_HANDLE, device);
    196     } else if (extensions->hasExtension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, 1)) {
    197         ACQUIRE_PROC_SUFFIX(GetImageMemoryRequirements2, KHR, VK_NULL_HANDLE, device);
    198         ACQUIRE_PROC_SUFFIX(GetBufferMemoryRequirements2, KHR, VK_NULL_HANDLE, device);
    199         ACQUIRE_PROC_SUFFIX(GetImageSparseMemoryRequirements2, KHR, VK_NULL_HANDLE, device);
    200     }
    201 
    202     // Functions for VK_KHR_bind_memory2
    203     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
    204         ACQUIRE_PROC(BindBufferMemory2, VK_NULL_HANDLE, device);
    205         ACQUIRE_PROC(BindImageMemory2, VK_NULL_HANDLE, device);
    206     } else if (extensions->hasExtension(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, 1)) {
    207         ACQUIRE_PROC_SUFFIX(BindBufferMemory2, KHR, VK_NULL_HANDLE, device);
    208         ACQUIRE_PROC_SUFFIX(BindImageMemory2, KHR, VK_NULL_HANDLE, device);
    209     }
    210 
    211     // Functions for VK_KHR_maintenance1 or vulkan 1.1
    212     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
    213         ACQUIRE_PROC(TrimCommandPool, VK_NULL_HANDLE, device);
    214     } else if (extensions->hasExtension(VK_KHR_MAINTENANCE1_EXTENSION_NAME, 1)) {
    215         ACQUIRE_PROC_SUFFIX(TrimCommandPool, KHR, VK_NULL_HANDLE, device);
    216     }
    217 
    218     // Functions for VK_KHR_maintenance3 or vulkan 1.1
    219     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
    220         ACQUIRE_PROC(GetDescriptorSetLayoutSupport, VK_NULL_HANDLE, device);
    221     } else if (extensions->hasExtension(VK_KHR_MAINTENANCE3_EXTENSION_NAME, 1)) {
    222         ACQUIRE_PROC_SUFFIX(GetDescriptorSetLayoutSupport, KHR, VK_NULL_HANDLE, device);
    223     }
    224 
    225     // Functions for VK_KHR_external_memory_capabilities
    226     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
    227         ACQUIRE_PROC(GetPhysicalDeviceExternalBufferProperties, instance, VK_NULL_HANDLE);
    228     } else if (extensions->hasExtension(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, 1)) {
    229         ACQUIRE_PROC_SUFFIX(GetPhysicalDeviceExternalBufferProperties, KHR, instance,
    230                             VK_NULL_HANDLE);
    231     }
    232 
    233     // Functions for VK_KHR_sampler_ycbcr_conversion
    234     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0)) {
    235         ACQUIRE_PROC(CreateSamplerYcbcrConversion, VK_NULL_HANDLE, device);
    236         ACQUIRE_PROC(DestroySamplerYcbcrConversion, VK_NULL_HANDLE, device);
    237     } else if (extensions->hasExtension(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, 1)) {
    238         ACQUIRE_PROC_SUFFIX(CreateSamplerYcbcrConversion, KHR, VK_NULL_HANDLE, device);
    239         ACQUIRE_PROC_SUFFIX(DestroySamplerYcbcrConversion, KHR, VK_NULL_HANDLE, device);
    240     }
    241 
    242 #ifdef SK_BUILD_FOR_ANDROID
    243     // Functions for VK_ANDROID_external_memory_android_hardware_buffer
    244     if (extensions->hasExtension(
    245             VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME, 2)) {
    246         ACQUIRE_PROC_SUFFIX(GetAndroidHardwareBufferProperties, ANDROID, VK_NULL_HANDLE, device);
    247         ACQUIRE_PROC_SUFFIX(GetMemoryAndroidHardwareBuffer, ANDROID, VK_NULL_HANDLE, device);
    248     }
    249 #endif
    250 
    251 }
    252 
    253 #ifdef SK_DEBUG
    254     static int kIsDebug = 1;
    255 #else
    256     static int kIsDebug = 0;
    257 #endif
    258 
    259 #define RETURN_FALSE_INTERFACE                                                                   \
    260     if (kIsDebug) { SkDebugf("%s:%d GrVkInterface::validate() failed.\n", __FILE__, __LINE__); } \
    261     return false;
    262 
    263 bool GrVkInterface::validate(uint32_t instanceVersion, uint32_t physicalDeviceVersion,
    264                              const GrVkExtensions* extensions) const {
    265     // functions that are always required
    266     if (nullptr == fFunctions.fCreateInstance ||
    267         nullptr == fFunctions.fDestroyInstance ||
    268         nullptr == fFunctions.fEnumeratePhysicalDevices ||
    269         nullptr == fFunctions.fGetPhysicalDeviceFeatures ||
    270         nullptr == fFunctions.fGetPhysicalDeviceFormatProperties ||
    271         nullptr == fFunctions.fGetPhysicalDeviceImageFormatProperties ||
    272         nullptr == fFunctions.fGetPhysicalDeviceProperties ||
    273         nullptr == fFunctions.fGetPhysicalDeviceQueueFamilyProperties ||
    274         nullptr == fFunctions.fGetPhysicalDeviceMemoryProperties ||
    275         nullptr == fFunctions.fCreateDevice ||
    276         nullptr == fFunctions.fDestroyDevice ||
    277         nullptr == fFunctions.fEnumerateInstanceExtensionProperties ||
    278         nullptr == fFunctions.fEnumerateDeviceExtensionProperties ||
    279         nullptr == fFunctions.fEnumerateInstanceLayerProperties ||
    280         nullptr == fFunctions.fEnumerateDeviceLayerProperties ||
    281         nullptr == fFunctions.fGetDeviceQueue ||
    282         nullptr == fFunctions.fQueueSubmit ||
    283         nullptr == fFunctions.fQueueWaitIdle ||
    284         nullptr == fFunctions.fDeviceWaitIdle ||
    285         nullptr == fFunctions.fAllocateMemory ||
    286         nullptr == fFunctions.fFreeMemory ||
    287         nullptr == fFunctions.fMapMemory ||
    288         nullptr == fFunctions.fUnmapMemory ||
    289         nullptr == fFunctions.fFlushMappedMemoryRanges ||
    290         nullptr == fFunctions.fInvalidateMappedMemoryRanges ||
    291         nullptr == fFunctions.fGetDeviceMemoryCommitment ||
    292         nullptr == fFunctions.fBindBufferMemory ||
    293         nullptr == fFunctions.fBindImageMemory ||
    294         nullptr == fFunctions.fGetBufferMemoryRequirements ||
    295         nullptr == fFunctions.fGetImageMemoryRequirements ||
    296         nullptr == fFunctions.fGetImageSparseMemoryRequirements ||
    297         nullptr == fFunctions.fGetPhysicalDeviceSparseImageFormatProperties ||
    298         nullptr == fFunctions.fQueueBindSparse ||
    299         nullptr == fFunctions.fCreateFence ||
    300         nullptr == fFunctions.fDestroyFence ||
    301         nullptr == fFunctions.fResetFences ||
    302         nullptr == fFunctions.fGetFenceStatus ||
    303         nullptr == fFunctions.fWaitForFences ||
    304         nullptr == fFunctions.fCreateSemaphore ||
    305         nullptr == fFunctions.fDestroySemaphore ||
    306         nullptr == fFunctions.fCreateEvent ||
    307         nullptr == fFunctions.fDestroyEvent ||
    308         nullptr == fFunctions.fGetEventStatus ||
    309         nullptr == fFunctions.fSetEvent ||
    310         nullptr == fFunctions.fResetEvent ||
    311         nullptr == fFunctions.fCreateQueryPool ||
    312         nullptr == fFunctions.fDestroyQueryPool ||
    313         nullptr == fFunctions.fGetQueryPoolResults ||
    314         nullptr == fFunctions.fCreateBuffer ||
    315         nullptr == fFunctions.fDestroyBuffer ||
    316         nullptr == fFunctions.fCreateBufferView ||
    317         nullptr == fFunctions.fDestroyBufferView ||
    318         nullptr == fFunctions.fCreateImage ||
    319         nullptr == fFunctions.fDestroyImage ||
    320         nullptr == fFunctions.fGetImageSubresourceLayout ||
    321         nullptr == fFunctions.fCreateImageView ||
    322         nullptr == fFunctions.fDestroyImageView ||
    323         nullptr == fFunctions.fCreateShaderModule ||
    324         nullptr == fFunctions.fDestroyShaderModule ||
    325         nullptr == fFunctions.fCreatePipelineCache ||
    326         nullptr == fFunctions.fDestroyPipelineCache ||
    327         nullptr == fFunctions.fGetPipelineCacheData ||
    328         nullptr == fFunctions.fMergePipelineCaches ||
    329         nullptr == fFunctions.fCreateGraphicsPipelines ||
    330         nullptr == fFunctions.fCreateComputePipelines ||
    331         nullptr == fFunctions.fDestroyPipeline ||
    332         nullptr == fFunctions.fCreatePipelineLayout ||
    333         nullptr == fFunctions.fDestroyPipelineLayout ||
    334         nullptr == fFunctions.fCreateSampler ||
    335         nullptr == fFunctions.fDestroySampler ||
    336         nullptr == fFunctions.fCreateDescriptorSetLayout ||
    337         nullptr == fFunctions.fDestroyDescriptorSetLayout ||
    338         nullptr == fFunctions.fCreateDescriptorPool ||
    339         nullptr == fFunctions.fDestroyDescriptorPool ||
    340         nullptr == fFunctions.fResetDescriptorPool ||
    341         nullptr == fFunctions.fAllocateDescriptorSets ||
    342         nullptr == fFunctions.fFreeDescriptorSets ||
    343         nullptr == fFunctions.fUpdateDescriptorSets ||
    344         nullptr == fFunctions.fCreateFramebuffer ||
    345         nullptr == fFunctions.fDestroyFramebuffer ||
    346         nullptr == fFunctions.fCreateRenderPass ||
    347         nullptr == fFunctions.fDestroyRenderPass ||
    348         nullptr == fFunctions.fGetRenderAreaGranularity ||
    349         nullptr == fFunctions.fCreateCommandPool ||
    350         nullptr == fFunctions.fDestroyCommandPool ||
    351         nullptr == fFunctions.fResetCommandPool ||
    352         nullptr == fFunctions.fAllocateCommandBuffers ||
    353         nullptr == fFunctions.fFreeCommandBuffers ||
    354         nullptr == fFunctions.fBeginCommandBuffer ||
    355         nullptr == fFunctions.fEndCommandBuffer ||
    356         nullptr == fFunctions.fResetCommandBuffer ||
    357         nullptr == fFunctions.fCmdBindPipeline ||
    358         nullptr == fFunctions.fCmdSetViewport ||
    359         nullptr == fFunctions.fCmdSetScissor ||
    360         nullptr == fFunctions.fCmdSetLineWidth ||
    361         nullptr == fFunctions.fCmdSetDepthBias ||
    362         nullptr == fFunctions.fCmdSetBlendConstants ||
    363         nullptr == fFunctions.fCmdSetDepthBounds ||
    364         nullptr == fFunctions.fCmdSetStencilCompareMask ||
    365         nullptr == fFunctions.fCmdSetStencilWriteMask ||
    366         nullptr == fFunctions.fCmdSetStencilReference ||
    367         nullptr == fFunctions.fCmdBindDescriptorSets ||
    368         nullptr == fFunctions.fCmdBindIndexBuffer ||
    369         nullptr == fFunctions.fCmdBindVertexBuffers ||
    370         nullptr == fFunctions.fCmdDraw ||
    371         nullptr == fFunctions.fCmdDrawIndexed ||
    372         nullptr == fFunctions.fCmdDrawIndirect ||
    373         nullptr == fFunctions.fCmdDrawIndexedIndirect ||
    374         nullptr == fFunctions.fCmdDispatch ||
    375         nullptr == fFunctions.fCmdDispatchIndirect ||
    376         nullptr == fFunctions.fCmdCopyBuffer ||
    377         nullptr == fFunctions.fCmdCopyImage ||
    378         nullptr == fFunctions.fCmdBlitImage ||
    379         nullptr == fFunctions.fCmdCopyBufferToImage ||
    380         nullptr == fFunctions.fCmdCopyImageToBuffer ||
    381         nullptr == fFunctions.fCmdUpdateBuffer ||
    382         nullptr == fFunctions.fCmdFillBuffer ||
    383         nullptr == fFunctions.fCmdClearColorImage ||
    384         nullptr == fFunctions.fCmdClearDepthStencilImage ||
    385         nullptr == fFunctions.fCmdClearAttachments ||
    386         nullptr == fFunctions.fCmdResolveImage ||
    387         nullptr == fFunctions.fCmdSetEvent ||
    388         nullptr == fFunctions.fCmdResetEvent ||
    389         nullptr == fFunctions.fCmdWaitEvents ||
    390         nullptr == fFunctions.fCmdPipelineBarrier ||
    391         nullptr == fFunctions.fCmdBeginQuery ||
    392         nullptr == fFunctions.fCmdEndQuery ||
    393         nullptr == fFunctions.fCmdResetQueryPool ||
    394         nullptr == fFunctions.fCmdWriteTimestamp ||
    395         nullptr == fFunctions.fCmdCopyQueryPoolResults ||
    396         nullptr == fFunctions.fCmdPushConstants ||
    397         nullptr == fFunctions.fCmdBeginRenderPass ||
    398         nullptr == fFunctions.fCmdNextSubpass ||
    399         nullptr == fFunctions.fCmdEndRenderPass ||
    400         nullptr == fFunctions.fCmdExecuteCommands) {
    401         RETURN_FALSE_INTERFACE
    402     }
    403 
    404     // Functions for VK_KHR_get_physical_device_properties2 or vulkan 1.1
    405     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
    406         extensions->hasExtension(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, 1)) {
    407         if (nullptr == fFunctions.fGetPhysicalDeviceFeatures2 ||
    408             nullptr == fFunctions.fGetPhysicalDeviceProperties2 ||
    409             nullptr == fFunctions.fGetPhysicalDeviceFormatProperties2 ||
    410             nullptr == fFunctions.fGetPhysicalDeviceImageFormatProperties2 ||
    411             nullptr == fFunctions.fGetPhysicalDeviceQueueFamilyProperties2 ||
    412             nullptr == fFunctions.fGetPhysicalDeviceMemoryProperties2 ||
    413             nullptr == fFunctions.fGetPhysicalDeviceSparseImageFormatProperties2) {
    414             RETURN_FALSE_INTERFACE
    415         }
    416     }
    417 
    418     // Functions for VK_KHR_get_memory_requirements2 or vulkan 1.1
    419     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
    420         extensions->hasExtension(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, 1)) {
    421         if (nullptr == fFunctions.fGetImageMemoryRequirements2 ||
    422             nullptr == fFunctions.fGetBufferMemoryRequirements2 ||
    423             nullptr == fFunctions.fGetImageSparseMemoryRequirements2) {
    424             RETURN_FALSE_INTERFACE
    425         }
    426     }
    427 
    428     // Functions for VK_KHR_bind_memory2
    429     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
    430         extensions->hasExtension(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, 1)) {
    431         if (nullptr == fFunctions.fBindBufferMemory2 ||
    432             nullptr == fFunctions.fBindImageMemory2) {
    433             RETURN_FALSE_INTERFACE
    434         }
    435     }
    436 
    437     // Functions for VK_KHR_maintenance1 or vulkan 1.1
    438     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
    439         extensions->hasExtension(VK_KHR_MAINTENANCE1_EXTENSION_NAME, 1)) {
    440         if (nullptr == fFunctions.fTrimCommandPool) {
    441             RETURN_FALSE_INTERFACE
    442         }
    443     }
    444 
    445     // Functions for VK_KHR_maintenance3 or vulkan 1.1
    446     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
    447         extensions->hasExtension(VK_KHR_MAINTENANCE3_EXTENSION_NAME, 1)) {
    448         if (nullptr == fFunctions.fGetDescriptorSetLayoutSupport) {
    449             RETURN_FALSE_INTERFACE
    450         }
    451     }
    452 
    453     // Functions for VK_KHR_external_memory_capabilities
    454     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
    455         extensions->hasExtension(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, 1)) {
    456         if (nullptr == fFunctions.fGetPhysicalDeviceExternalBufferProperties) {
    457             RETURN_FALSE_INTERFACE
    458         }
    459     }
    460 
    461     // Functions for VK_KHR_sampler_ycbcr_conversion
    462     if (physicalDeviceVersion >= VK_MAKE_VERSION(1, 1, 0) ||
    463         extensions->hasExtension(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, 1)) {
    464         if (nullptr == fFunctions.fCreateSamplerYcbcrConversion ||
    465             nullptr == fFunctions.fDestroySamplerYcbcrConversion) {
    466             RETURN_FALSE_INTERFACE
    467         }
    468     }
    469 
    470 #ifdef SK_BUILD_FOR_ANDROID
    471     // Functions for VK_ANDROID_external_memory_android_hardware_buffer
    472     if (extensions->hasExtension(
    473             VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME, 2)) {
    474         if (nullptr == fFunctions.fGetAndroidHardwareBufferProperties ||
    475             nullptr == fFunctions.fGetMemoryAndroidHardwareBuffer) {
    476             RETURN_FALSE_INTERFACE
    477         }
    478     }
    479 #endif
    480 
    481     return true;
    482 }
    483 
    484