VkDeviceobject, which in turn needs a
VkPhysicalDeviceobject to indicate on which hardware or software implementation that device object is supposed to run.
Querying the list of physical devices can be done in much the same way as instance layers and extensions were queried, with minor differences.
uint32_t physicalDeviceCount = 0; VkPhysicalDevice* physicalDevices = NULL; if ( physicalDeviceCount ) RETURN_ERROR(-1,"No valid physical device found"); result = vkEnumeratePhysicalDevices ( renderer->instance, &physicalDeviceCount, NULL ); if ( result != VK_SUCCESS ) RETURN_ERROR(-1,"vkEnumeratePhysicalDevices failed (0x%08X)", (uint32_t)result); physicalDevices = _alloca ( physicalDeviceCount * sizeof ( VkPhysicalDevice ) ); result = vkEnumeratePhysicalDevices ( renderer->instance, &physicalDeviceCount, physicalDevices ); if ( result != VK_SUCCESS ) RETURN_ERROR(-1,"vkEnumerateInstanceLayerProperties failed (0x%08X)", (uint32_t)result);
Similar to the layers and extensions, we first query the amount of physical devices, after which we allocate space for the device data to be stored, and the final call to obtain the data for the devices.
Data for the physical device can be queried through
vkGetPhysicalDeviceProperties. This function will list the name of the device and its capabilities. It can be beneficial to make yourself roughly familiar with the data obtained in order to prevent surprises when encountering a hardware limit.
On top of instance layers and instance extensions, there are also device layers and device extensions. The process of obtaining these is virtually identical to the process of obtaining the instance layers and extensions, the main difference being the function call to
vkEnumerateDeviceExtensionProperties rather than
Note that device layers have been deprecated soon after Vulkan 1.0 is released, and might no longer be present in future releases. All functionality of device layers is now under the responsibility of the instance layers. It is recommended to still attempt to enable device layers when they are present, but not fail when they are not present in the query, as device layers may be removed down the line.