Graphics‎ > ‎Graphic API‎ > ‎Vulkan‎ > ‎


Remember the good times when we simply did ApiInit() and that was it

Layer and Extensions is a way to extended the functionality of vulkan. A layer watch the vulkan functions used but cannot add or modify them. A extensions can modify commands and add new ones. There are two places where they can be found, on the vulkan instance and on the device.

Enumerate vulkan instance layers and extensions
To learn what layers and extensions are supported by the vulkan instance use vkEnumerateInstanceLayerProperties and vkEnumerateInstanceExtensionProperties.

Create a vulkan instance
- vkCreateInstance()
vkCreateInstance takes a VkInstanceCreateInfo structure and a VkAllocationCallbacks structure. In VkInstanceCreateInfo one sets what layers and extension to activate for the instance. The VkAllocationCallbacks structure can be used to set custom memory allocators for CPU side memory. It can be set to NULL to let vulkan handle it.

Enumerate devices - vkEnumeratePhysicalDevices()
Use vkEnumeratePhysicalDevices to learn what gpu like devices exist for vulkans use. Each one has a VkPhysicalDevice handle that are used to get more information about it or to create a device instance with it.

Enumerate device layers and extensions
With the VkPhysicalDevice handle it is possible to check what layers and extensions exist on a device. Use vkEnumerateDeviceLayerProperties and vkEnumerateDeviceExtensionProperties to query for that information.

Get information about a device
With the VkPhysicalDevice handle use the following functions to learn more about the device.
  • vkGetPhysicalDeviceProperties: Return the most basic information of the device in a VkPhysicalDeviceProperties structure. Such things as driver version, vendor and so on. In it there is also a VkPhysicalDeviceLimits structure with the limits of the device.
  • vkGetPhysicalDeviceFeatures: This call returns a VkPhysicalDeviceFeatures structure with many bools that tell what things the device supports.
Get information about the queues on a device - vkGetPhysicalDeviceQueueFamilyProperties
This return a list of the queues the device support. A index in this list are later used when creating the device (queueFamilyIndex) to select what type of queues to create. 

Create a device instance
- vkCreateDevice()
Creating a device takes a VkPhysicalDevice handle, a VkDeviceCreateInfo structure and a VkAllocationCallbacks structure. VkAllocationCallbacks can be NULL if one wish to let vulkan handle memory. VkDeviceCreateInfo contains the layers and extensions to activate and also an array of VkDeviceQueueCreateInfo that descibe the queues to create.

The VkDeviceQueueCreateInfo structure contain the queueFamilyIndex to create a queue from and a count of how many to create.

Subpages (2): Extensions Layers