Enumerating available instance layers
Enabling an instance layer is as easy as providing its name as a const char *
to the instance creation function. Unfortunately, not all layers exist in all implementations, and we need to check the available ones before trying to enable them.
In this recipe, you will learn how to enumerate the available instance layers and how to transform them into strings so that they are easier to manage.
Getting ready
The code snippets shown in this section are part of our Context
class.. It encapsulates most of the initialization and object creation functions.
How to do it…
Checking the available extensions is easy to do:
- First, you need to query the number of extensions using the
vkEnumerateInstanceLayerProperties
function, create an array ofVkLayerProperties
big enough to store all extensions, and request their data by issuing a call to the same function again, like this:uint32_t instanceLayerCount{0}; VK_CHECK(vkEnumerateInstanceLayerProperties...