Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
foray::core::DescriptorSet Class Reference

Helps with the creation of a VkDescriptorSetLayout and VkDescriptorSet. More...

#include <foray_descriptorset.hpp>

Inheritance diagram for foray::core::DescriptorSet:
foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_DESCRIPTOR_SET > foray::core::ManagedResource foray::NoMoveDefaults

Classes

struct  DescriptorInfo
 

Public Member Functions

void Create (Context *context, std::string debugName, VkDescriptorSetLayout predefinedLayout=VK_NULL_HANDLE, VkDescriptorSetLayoutCreateFlags descriptorSetLayoutCreateFlags=0)
 Creates the VkDescriptorSet.
 
void Update ()
 Rather than reallocating the descriptorset, rewrites all bindings to the descriptor set.
 
virtual void Destroy () override
 Destroys descriptorset and layout (latter only if also allocated by this object)
 
 ~DescriptorSet ()
 
void SetDescriptorAt (uint32_t binding, const std::vector< const ManagedBuffer * > &buffers, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (buffer array)
 
void SetDescriptorAt (uint32_t binding, const ManagedBuffer &buffer, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (buffer)
 
void SetDescriptorAt (uint32_t binding, const ManagedBuffer *buffer, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (buffer)
 
void SetDescriptorAt (uint32_t binding, const std::vector< const ManagedImage * > &images, VkImageLayout layout, VkSampler sampler, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (image array)
 
void SetDescriptorAt (uint32_t binding, const ManagedImage *image, VkImageLayout layout, VkSampler sampler, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (image)
 
void SetDescriptorAt (uint32_t binding, const ManagedImage &image, VkImageLayout layout, VkSampler sampler, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (image)
 
void SetDescriptorAt (uint32_t binding, const std::vector< VkDescriptorImageInfo > &imageInfos, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (image info array)
 
void SetDescriptorAt (uint32_t binding, const std::vector< VkDescriptorBufferInfo > &bufferInfos, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (buffer info array)
 
void SetDescriptorAt (uint32_t binding, const VkDescriptorImageInfo &imageInfo, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (image info)
 
void SetDescriptorAt (uint32_t binding, const VkDescriptorBufferInfo &bufferInfo, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (buffer info)
 
void SetDescriptorAt (uint32_t binding, void *pNext, uint32_t DescriptorCount, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (custom / .pNext)
 
void SetDescriptorAt (uint32_t binding, const CombinedImageSampler &sampledImage, VkImageLayout layout, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (CombinedImageSampler)
 
void SetDescriptorAt (uint32_t binding, const CombinedImageSampler *sampledImage, VkImageLayout layout, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (CombinedImageSampler)
 
void SetDescriptorAt (uint32_t binding, const std::vector< const CombinedImageSampler * > &sampledImages, VkImageLayout layout, VkDescriptorType descriptorType, VkShaderStageFlags shaderStageFlags)
 Set a binding (CombinedImageSampler)
 
bool Exists () const override
 Return true, if the managed resource is allocated.
 
- Public Member Functions inherited from foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_DESCRIPTOR_SET >
 VulkanResource ()
 
 VulkanResource (std::string_view name)
 
virtual std::string_view GetTypeName () const
 Returns <OBJECT_TYPE> stringified.
 
- Public Member Functions inherited from foray::core::ManagedResource
 ManagedResource ()
 Default constructor registers the resource.
 
 ManagedResource (std::string_view name)
 Registers the resource and sets its name.
 
virtual ~ManagedResource ()
 Unregisters the resource.
 
std::string_view GetName () const
 Return a custom name for the object.
 
virtual void SetName (std::string_view name)
 Set a custom name for the object.
 
std::string Print () const
 Print name and type in one string.
 
- Public Member Functions inherited from foray::NoMoveDefaults
 NoMoveDefaults ()=default
 
 NoMoveDefaults (const NoMoveDefaults &other)=delete
 
 NoMoveDefaults (NoMoveDefaults &&other)=default
 
NoMoveDefaultsoperator= (const NoMoveDefaults &other)=delete
 

Protected Member Functions

void CreateDescriptorSet ()
 
void CreateDescriptorSetLayout (VkDescriptorSetLayoutCreateFlags descriptorSetLayoutCreateFlags)
 
void AssertBindingInUse (uint32_t binding)
 
void AssertHandleNotNull (void *handle, uint32_t binding)
 
- Protected Member Functions inherited from foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_DESCRIPTOR_SET >
virtual void SetObjectName (core::Context *context, const void *handle, std::string_view name, bool updateResourceName=true)
 Set the object name. Sets both ManagedResource::mName aswell as vulkan debug object name.
 

Protected Attributes

std::unordered_map< uint32_t, DescriptorInfomMapBindingToDescriptorInfo
 
ContextmContext {}
 
VkDescriptorPool mDescriptorPool {}
 
VkDescriptorSetLayout mDescriptorSetLayout {}
 
bool mExternalLayout = false
 
VkDescriptorSet mDescriptorSet {}
 
- Protected Attributes inherited from foray::core::ManagedResource
std::string mName
 This objects custom name.
 

Additional Inherited Members

- Static Public Member Functions inherited from foray::core::ManagedResource
static void sPrintAllocatedResources (bool printAsWarning)
 Print a list of all registered existing resources.
 
static const std::unordered_set< ManagedResource * > * GetTotalAllocatedResources ()
 

Detailed Description

Helps with the creation of a VkDescriptorSetLayout and VkDescriptorSet.

Not supported:

Constructor & Destructor Documentation

◆ ~DescriptorSet()

foray::core::DescriptorSet::~DescriptorSet ( )
inline

Member Function Documentation

◆ AssertBindingInUse()

void foray::core::DescriptorSet::AssertBindingInUse ( uint32_t  binding)
protected

◆ AssertHandleNotNull()

void foray::core::DescriptorSet::AssertHandleNotNull ( void *  handle,
uint32_t  binding 
)
protected

◆ Create()

void foray::core::DescriptorSet::Create ( Context context,
std::string  debugName,
VkDescriptorSetLayout  predefinedLayout = VK_NULL_HANDLE,
VkDescriptorSetLayoutCreateFlags  descriptorSetLayoutCreateFlags = 0 
)

Creates the VkDescriptorSet.

Parameters
contextRequires Device, DispatchTable
debugNameDebug object name
predefinedLayoutAllows reusing an already defined layout
descriptorSetLayoutCreateFlagsflags

◆ CreateDescriptorSet()

void foray::core::DescriptorSet::CreateDescriptorSet ( )
protected

◆ CreateDescriptorSetLayout()

void foray::core::DescriptorSet::CreateDescriptorSetLayout ( VkDescriptorSetLayoutCreateFlags  descriptorSetLayoutCreateFlags)
protected

◆ Destroy()

virtual void foray::core::DescriptorSet::Destroy ( )
overridevirtual

Destroys descriptorset and layout (latter only if also allocated by this object)

Implements foray::core::ManagedResource.

◆ Exists()

bool foray::core::DescriptorSet::Exists ( ) const
inlineoverridevirtual

Return true, if the managed resource is allocated.

Example: Vulkan object stored could be nullptr or instantiated

Implements foray::core::ManagedResource.

◆ SetDescriptorAt() [1/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const CombinedImageSampler sampledImage,
VkImageLayout  layout,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (CombinedImageSampler)

Parameters
bindingbinding index
sampledImageImage + Sampler combo
layoutImageLayout

◆ SetDescriptorAt() [2/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const CombinedImageSampler sampledImage,
VkImageLayout  layout,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (CombinedImageSampler)

Parameters
bindingbinding index
sampledImageImage + Sampler combo
layoutImageLayout

◆ SetDescriptorAt() [3/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const ManagedBuffer buffer,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (buffer)

Parameters
bindingbinding index
bufferbuffer. Is converted to a VkDescriptorBufferInfo object.

◆ SetDescriptorAt() [4/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const ManagedBuffer buffer,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (buffer)

Parameters
bindingbinding index
bufferbuffer. Is converted to a VkDescriptorBufferInfo object.

◆ SetDescriptorAt() [5/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const ManagedImage image,
VkImageLayout  layout,
VkSampler  sampler,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (image)

Parameters
bindingbinding index
imagesimage. Is converted to a VkDescriptorImageInfo object (with layout and sampler).
layoutimage layout as accessed from shader

◆ SetDescriptorAt() [6/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const ManagedImage image,
VkImageLayout  layout,
VkSampler  sampler,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (image)

Parameters
bindingbinding index
imagesimage. Is converted to a VkDescriptorImageInfo object (with layout and sampler).
layoutimage layout as accessed from shader

◆ SetDescriptorAt() [7/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const std::vector< const CombinedImageSampler * > &  sampledImages,
VkImageLayout  layout,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (CombinedImageSampler)

Parameters
bindingbinding index
sampledImageImage + Sampler vector (shared layout)
layoutImageLayout

◆ SetDescriptorAt() [8/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const std::vector< const ManagedBuffer * > &  buffers,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (buffer array)

Parameters
bindingbinding index
buffersvector of buffers. Is converted to a VkDescriptorBufferInfos vector.

◆ SetDescriptorAt() [9/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const std::vector< const ManagedImage * > &  images,
VkImageLayout  layout,
VkSampler  sampler,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (image array)

Parameters
bindingbinding index
imagesimage array. Is converted to a VkDescriptorImageInfo vector (shared layout and sampler).
layoutimage layout as accessed from shader
samplershared sampler

◆ SetDescriptorAt() [10/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const std::vector< VkDescriptorBufferInfo > &  bufferInfos,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (buffer info array)

Parameters
bindingbinding index

◆ SetDescriptorAt() [11/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const std::vector< VkDescriptorImageInfo > &  imageInfos,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (image info array)

Parameters
bindingbinding index

◆ SetDescriptorAt() [12/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const VkDescriptorBufferInfo &  bufferInfo,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (buffer info)

Parameters
bindingbinding index

◆ SetDescriptorAt() [13/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
const VkDescriptorImageInfo &  imageInfo,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (image info)

Parameters
bindingbinding index

◆ SetDescriptorAt() [14/14]

void foray::core::DescriptorSet::SetDescriptorAt ( uint32_t  binding,
void *  pNext,
uint32_t  DescriptorCount,
VkDescriptorType  descriptorType,
VkShaderStageFlags  shaderStageFlags 
)

Set a binding (custom / .pNext)

Parameters
bindingbinding index
pNextaddress assigned to VkDescriptorWrite::pNext

◆ Update()

void foray::core::DescriptorSet::Update ( )

Rather than reallocating the descriptorset, rewrites all bindings to the descriptor set.

Member Data Documentation

◆ mContext

Context* foray::core::DescriptorSet::mContext {}
protected

◆ mDescriptorPool

VkDescriptorPool foray::core::DescriptorSet::mDescriptorPool {}
protected

◆ mDescriptorSet

VkDescriptorSet foray::core::DescriptorSet::mDescriptorSet {}
protected

◆ mDescriptorSetLayout

VkDescriptorSetLayout foray::core::DescriptorSet::mDescriptorSetLayout {}
protected

◆ mExternalLayout

bool foray::core::DescriptorSet::mExternalLayout = false
protected

◆ mMapBindingToDescriptorInfo

std::unordered_map<uint32_t, DescriptorInfo> foray::core::DescriptorSet::mMapBindingToDescriptorInfo
protected

The documentation for this class was generated from the following file: