Featured Article

Vulkan Descriptor Heap Example: Unlocking Graphics Potential

Cynthia Jul 13, 2026

Vulkan, a powerful and low-overhead graphics and computing API, introduces the concept of descriptor heaps to manage shader resources efficiently. Understanding how to use descriptor heaps is crucial for making the most out of Vulkan's capabilities. Let's dive into an example to illustrate their usage.

the layers of an active volcano diagram with labeled labels on white background - stock image
the layers of an active volcano diagram with labeled labels on white background - stock image

Descriptor heaps in Vulkan are used to store and manage descriptors, which reference buffers and images used by shaders. They are a critical aspect of the descriptor system, enabling efficient allocation and binding of descriptor sets.

the structure of a volcano is shown in this graphic above it's main features
the structure of a volcano is shown in this graphic above it's main features

Initializing Descriptor Heap

Before creating a descriptor set, you must first initialize a descriptor heap. Here's an example of doing so using the Vulkan C++ API:

Igneous Rocks
Igneous Rocks

VkDescriptorPoolSize pool_sizes[] = { {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 100}, {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 100}, }; VkDescriptorPoolCreateInfo pool_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, nullptr, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1000, 2, pool_sizes }; if (vkCreateDescriptorPool(m_device, &pool_info, nullptr, &descriptor_pool) != VK_SUCCESS) { throw std::runtime_error("Failed to create descriptor pool!"); }

What are Descriptor Pools?

the cross section of a volcano
the cross section of a volcano

A descriptor pool is a reserved block of descriptors. They allow you to allocate multiple descriptor sets at once, improving performance by reducing the number of individual requests.

In the example above, we create a descriptor pool that can allocate up to 1000 descriptors and supports up to 2 types of descriptors – uniform buffers and combined image samplers.

Allocated Descriptor Sets

different types of volcanos are shown in this diagram, including the top and bottom layers
different types of volcanos are shown in this diagram, including the top and bottom layers

After creating a descriptor pool, you can allocate descriptor sets from it. Here's an example of allocating a descriptor set for a single layout:

VkDescriptorSetAllocateInfo alloc_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, nullptr, descriptor_pool, 0, &descriptor_set_layout }; if (vkAllocateDescriptorSets(m_device, &alloc_info, &descriptor_set) != VK_SUCCESS) { throw std::runtime_error("Failed to allocate descriptor set!"); }

Updating Descriptor Set

what is a volcano? info poster with information about the structure and its main features
what is a volcano? info poster with information about the structure and its main features

Once allocated, you can update the descriptor set with values. Here's an example of updating a descriptor set with a buffer:

VkDescriptorBufferInfo buffer_info = { 0, Seasons::Memory::Buffer::image_uniform_buffer(), 0 }; VkWriteDescriptorSet write = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, nullptr, descriptor_set, 0, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, nullptr, &buffer_info, nullptr }; vkUpdateDescriptorSets(m_device, 1, &write, 0, nullptr);

different types of volcanos with names and pictures on the front page, labeled in red
different types of volcanos with names and pictures on the front page, labeled in red
parts of a volcano
parts of a volcano
Teaching resources
Teaching resources
an image of a volcano labeled in different parts of the earth and its main features
an image of a volcano labeled in different parts of the earth and its main features
an image of the inside of a volcano
an image of the inside of a volcano
Vulkanen
Vulkanen
Knowledge Encyclopedia ( PDFDrive )
Knowledge Encyclopedia ( PDFDrive )
Volcanoes image
Volcanoes image
The 4 Types Of Volcano
The 4 Types Of Volcano

Descriptor Buffer Info

The VkDescriptorBufferInfo structure defines a buffer that will be bound as a shader resource. In this case, we're binding a uniform buffer for our shader.

VkWriteDescriptorSet is used to update the descriptor set. Here, we update a single descriptor in the set, binding it to a uniform buffer at the specified descriptor index.

Updating Descriptor Sets with Images

Similar to buffers, you can update descriptor sets with images. Here's an example:

VkDescriptorImageInfo image_info = { VK_NULL_HANDLE, // Sampler Seasons::Memory::Texture::image_handle(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }; VkWriteDescriptorSet write = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, nullptr, descriptor_set, 1, 0, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, nullptr, nullptr, &image_info }; vkUpdateDescriptorSets(m_device, 1, &write, 0, nullptr);

In this example, we're binding a combined image sampler to a descriptor, allowing us to use an image as a shader resource.

Descriptor heaps are a powerful tool in Vulkan for managing shader resources. With careful management, they can help improve performance and reduce overhead. To learn more about optimizing Vulkan usage, consider exploring more examples and best practices.