Descriptors and Descriptor Sets in Vulkan

Descriptor sets in Vulkan are required in order to pass data to shaders.

Descriptors, as the name implies, are used to describe resources, such as buffers and images, which are going to be passed to shaders. They hold information that helps with binding data to shaders, and additionally describe any information Vulkan needs to know before executing the shader. Descriptors are not passed individually and are actually opaque to the application, but instead are bundled together in objects, known as descriptor sets.

The process of creating a descriptor set is a three-step process:
  1. Create the descriptor pool that the descriptor sets are allocated out of. This is similar to command buffers being allocated out of command pools and helps spread the cost of resource creation.
  2. Create a descriptor layout that includes information on the binding points (where in the pipeline the resource is needed) and the type of data to be passed to the shader.
  3. The descriptor sets themselves are actually initialised in two steps. First, the descriptor set is allocated out of the previously created descriptor pool and then these descriptor sets are updated to hold a pointer to the data that is going to be passed to the shader, for instance textures, uniform buffers and so on.

When creating a pipeline, a pipeline layout is created which describes all of the resources required by the pipeline. These resources include descriptor sets (via descriptor set layouts) and push constants.