Magnum::Vk::DescriptorSetLayout class new in Git master

Descriptor set layout.

Wraps a VkDescriptorSetLayout. A descriptor set layout specifies what descriptors (such as uniform buffers or samplers) can be used by shaders in a Pipeline, concrete descriptors are then bound using a DescriptorSet.

Descriptor set layout creation

The DescriptorSetLayoutCreateInfo class takes one or more DescriptorSetLayoutBinding entries, where each specifies the binding number, descriptor type, descriptor count in case of descriptor arrays and which shader stages are designed to access the binding. In the following example one uniform buffer binding 0 is accessible by any stages and one combined image/sampler binding 1 is accessed only by ShaderStage::Fragment:

#include <Magnum/Vk/DescriptorSetLayoutCreateInfo.h>



Vk::DescriptorSetLayout layout{device, Vk::DescriptorSetLayoutCreateInfo{
    {{0, Vk::DescriptorType::UniformBuffer}},
    {{1, Vk::DescriptorType::CombinedImageSampler, 1,
      Vk::ShaderStage::Fragment}}
}};

Immutable samplers

For DescriptorType::Sampler and DescriptorType::CombinedImageSampler it's possible to specify a list of immutable Samplers in place of the descriptor count argument. The descriptor count is then implicitly taken from size of the array. The above snippet with immutable samplers would look like this:

Vk::Sampler sampler{};

Vk::DescriptorSetLayout layout{device, Vk::DescriptorSetLayoutCreateInfo{
    {{0, Vk::DescriptorType::UniformBuffer}},
    {{1, Vk::DescriptorType::CombinedImageSampler, {sampler},
      Vk::ShaderStage::Fragment}}
}};

Descriptor binding flags

With Vulkan 1.2 or EXT_descriptor_indexing it's possible to specify additional flags per binding. All of them require a certain DeviceFeature to be supported and enabled, see particular DescriptorSetLayoutBinding::Flag for more information:

Vk::Device device{instance, Vk::DeviceCreateInfo{}
    
    .addEnabledExtensions<Vk::Extensions::EXT::descriptor_indexing>()
    .setEnabledFeatures(
        Vk::DeviceFeature::DescriptorBindingUniformBufferUpdateAfterBind|
        
    )
};

Vk::DescriptorSetLayout layout{device, Vk::DescriptorSetLayoutCreateInfo{
    {{0, Vk::DescriptorType::UniformBuffer, 1,
      ~Vk::ShaderStages{},
      Vk::DescriptorSetLayoutBinding::Flag::UpdateAfterBind}},
    
}};

Descriptor set layout usage

A descriptor set layout is used in a PipelineLayout creation and subsequently for DescriptorSet allocation from a DescriptorPool. See the corresponding class documentation for more information.

Public static functions

static auto wrap(Device& device, VkDescriptorSetLayout handle, HandleFlags flags = {}) -> DescriptorSetLayout
Wrap existing Vulkan handle.

Constructors, destructors, conversion operators

DescriptorSetLayout(Device& device, const DescriptorSetLayoutCreateInfo& info) explicit
Constructor.
DescriptorSetLayout(NoCreateT) explicit
Construct without creating the descriptor set layout.
DescriptorSetLayout(const DescriptorSetLayout&) deleted
Copying is not allowed.
DescriptorSetLayout(DescriptorSetLayout&& other) noexcept
Move constructor.
~DescriptorSetLayout()
Destructor.
operator VkDescriptorSetLayout()

Public functions

auto operator=(const DescriptorSetLayout&) -> DescriptorSetLayout& deleted
Copying is not allowed.
auto operator=(DescriptorSetLayout&& other) -> DescriptorSetLayout& noexcept
Move assignment.
auto handle() -> VkDescriptorSetLayout
Underlying VkDescriptorSetLayout handle.
auto handleFlags() const -> HandleFlags
Handle flags.
auto release() -> VkDescriptorSetLayout
Release the underlying Vulkan descriptor set layout.

Function documentation

static DescriptorSetLayout Magnum::Vk::DescriptorSetLayout::wrap(Device& device, VkDescriptorSetLayout handle, HandleFlags flags = {})

Wrap existing Vulkan handle.

Parameters
device Vulkan device the descriptor set layout is created on
handle The VkDescriptorSetLayout handle
flags Handle flags

The handle is expected to be originating from device. Unlike a descriptor set layout created using a constructor, the Vulkan descriptor set layout is by default not deleted on destruction, use flags for different behavior.

Magnum::Vk::DescriptorSetLayout::DescriptorSetLayout(Device& device, const DescriptorSetLayoutCreateInfo& info) explicit

Constructor.

Parameters
device Vulkan device to create the descriptor set layout on
info Descriptor set layout creation info

Magnum::Vk::DescriptorSetLayout::DescriptorSetLayout(NoCreateT) explicit

Construct without creating the descriptor set layout.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

Magnum::Vk::DescriptorSetLayout::~DescriptorSetLayout()

Destructor.

Destroys associated VkDescriptorSetLayout handle, unless the instance was created using wrap() without HandleFlag::DestroyOnDestruction specified.

Magnum::Vk::DescriptorSetLayout::operator VkDescriptorSetLayout()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

VkDescriptorSetLayout Magnum::Vk::DescriptorSetLayout::release()

Release the underlying Vulkan descriptor set layout.

Releases ownership of the Vulkan descriptor set layout and returns its handle so vkDestroyDescriptorSetLayout() is not called on destruction. The internal state is then equivalent to moved-from state.