class new in Git master
#include <Magnum/Vk/DescriptorSetLayout.h>
DescriptorSetLayout 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::
#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::
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_
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::
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.