vkGetInstanceProcAddr
and vkGetDeviceProcAddr
are completely missing from the API documentation. However they are required to perform commands with swapchains (and thus make any meaningful Vulkan app). Furthermore, the cube/tri demos that come with the SDK use them very inconsistently.
Are these two methods interchangeable, and if not, what's the difference?
vkGetInstanceProcAddress
is to get the function pointer that will always work with any device created from the instance passed in.
However the functions returned may include dispatch logic (typically to account for extensions that may or may not be enabled for the device) that may slow down the call. This is why the vkGetDeviceProcAddress
exist to get the function that doesn't have dispatch logic. You are not obliged to use them but it may help get some extra speed.
This is especially noticeable when you have activated several layers:
With the device specific function pointer the final dispatch can be removed:
images from the khonos loader and layer interface document
If you only use 1 device then the order of operations for the application would be:
get vkGetInstanceProcAddress
from the platform/loader.
load vkCreateInstance
from it and the extension and layer queries. (using null as the instance parameter)
create the instance. (you will use this as first parameter for loading the other functions)
load vkEnumeratePhysicalDevices
and related to query devices.
create the device with vkCreateDevice
specifying the extensions you want.
load all the other functions you will need with vkGetDeviceProcAddress
and passing the device as the first parameter.
Above answer is correct. I will add that for WSI extensions, the Windows,Linux and Android loaders have all stated they will export the WSI extension entry points. Thus, on these platforms vkGetInstanceProcAddr and vkGetDeviceProcAddr is NOT needed to be used to get WSI entry points. But in general extension entry points need to be retrieved via vkGet*ProcAddr in Vulkan.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With