Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
VulkanDescriptors Class Reference

Manages the descriptor pool, descriptor layouts, and descriptor set allocations for UBO resources. More...

#include <VulkanDescriptors.hpp>

Public Member Functions

 VulkanDescriptors ()=default
 Construct a new Vulkan Descriptors object.
 ~VulkanDescriptors ()
 Destroy the Vulkan Descriptors object and release descriptor resources.
 VulkanDescriptors (const VulkanDescriptors &)=delete
VulkanDescriptors & operator= (const VulkanDescriptors &)=delete
void create (VkDevice device, uint32_t maxFramesInFlight=2)
 Creates the descriptor pool.
void createCameraDescriptorSetLayout ()
 Creates descriptor set layouts defining resource bindings for camera.
void createTextureDescriptorSetLayout ()
 Creates descriptor set layout for texture samplers.
void createJointsDescriptorSetLayout ()
 Creates descriptor set layout for joints/bones matrices.
void allocateCameraDescriptorSets (VkBuffer uniformBuffer, VkDeviceSize bufferSize)
 Allocates and binds descriptor sets for the camera UBO.
void allocateTextureDescriptorSet (VkDescriptorSet &descriptorSet, VkImageView diffuseView, VkSampler diffuseSampler, VkImageView normalView, VkSampler normalSampler, VkImageView metallicView, VkSampler metallicSampler)
 Allocates and binds descriptor set for texture samplers (diffuse, normal, metallic).
void updateTextureDescriptorSet (VkDescriptorSet descriptorSet, VkImageView diffuseView, VkSampler diffuseSampler, VkImageView normalView, VkSampler normalSampler, VkImageView metallicView, VkSampler metallicSampler)
 Updates an existing texture descriptor set with new sampler bindings.
void allocateJointsDescriptorSet (VkDescriptorSet &descriptorSet, VkBuffer uniformBuffer, VkDeviceSize range)
 Allocates and binds descriptor set for a skeleton joint matrices buffer.
void destroy ()
 Safely destroys layout bindings and descriptor pools.
VkDescriptorSetLayout getCameraDescriptorSetLayout () const
 Gets raw camera descriptor set layout.
VkDescriptorSetLayout getTextureDescriptorSetLayout () const
 Gets raw texture descriptor set layout.
VkDescriptorSetLayout getJointsDescriptorSetLayout () const
 Gets raw joints descriptor set layout.
VkDescriptorSet getCameraDescriptorSet () const
 Gets raw camera descriptor set.
VkDescriptorPool getDescriptorPool () const
 Gets raw descriptor pool.

Private Attributes

VkDevice device = VK_NULL_HANDLE
 Reference to logical device.
VkDescriptorPool descriptorPool = VK_NULL_HANDLE
 Descriptor pool allocator.
VkDescriptorSetLayout cameraDescriptorSetLayout = VK_NULL_HANDLE
 Descriptor set layout allocated for camera.
VkDescriptorSetLayout textureDescriptorSetLayout = VK_NULL_HANDLE
 Descriptor set layout allocated for textures.
VkDescriptorSetLayout jointsDescriptorSetLayout = VK_NULL_HANDLE
 Descriptor set layout allocated for joints.
VkDescriptorSet cameraDescriptorSet = VK_NULL_HANDLE
 Descriptor set allocated for camera.

Detailed Description

Manages the descriptor pool, descriptor layouts, and descriptor set allocations for UBO resources.

Constructor & Destructor Documentation

◆ VulkanDescriptors() [1/2]

VulkanDescriptors::VulkanDescriptors ( )
default

Construct a new Vulkan Descriptors object.

◆ ~VulkanDescriptors()

VulkanDescriptors::~VulkanDescriptors ( )

Destroy the Vulkan Descriptors object and release descriptor resources.

Destroy the Vulkan Descriptors:: Vulkan Descriptors object.

◆ VulkanDescriptors() [2/2]

VulkanDescriptors::VulkanDescriptors ( const VulkanDescriptors & )
delete

Member Function Documentation

◆ allocateCameraDescriptorSets()

void VulkanDescriptors::allocateCameraDescriptorSets ( VkBuffer uniformBuffer,
VkDeviceSize bufferSize )

Allocates and binds descriptor sets for the camera UBO.

Allocates camera descriptor set and updates layout binding.

Parameters
uniformBufferThe GPU buffer containing camera matrices.
bufferSizeSize of UBO buffer.
uniformBufferGPU uniform buffer handle.
bufferSizeSize of uniform buffer memory.

◆ allocateJointsDescriptorSet()

void VulkanDescriptors::allocateJointsDescriptorSet ( VkDescriptorSet & descriptorSet,
VkBuffer uniformBuffer,
VkDeviceSize range )

Allocates and binds descriptor set for a skeleton joint matrices buffer.

Allocates joints descriptor set and updates binding with joint matrices uniform buffer.

Parameters
descriptorSetReference to target descriptor set to allocate.
uniformBufferGPU buffer.
rangeBuffer segment size.

◆ allocateTextureDescriptorSet()

void VulkanDescriptors::allocateTextureDescriptorSet ( VkDescriptorSet & descriptorSet,
VkImageView diffuseView,
VkSampler diffuseSampler,
VkImageView normalView,
VkSampler normalSampler,
VkImageView metallicView,
VkSampler metallicSampler )

Allocates and binds descriptor set for texture samplers (diffuse, normal, metallic).

Parameters
descriptorSetReference to target descriptor set to allocate.
diffuseViewDiffuse image view.
diffuseSamplerDiffuse sampler.
normalViewNormal map image view.
normalSamplerNormal map sampler.
metallicViewMetallic map image view.
metallicSamplerMetallic map sampler.

◆ create()

void VulkanDescriptors::create ( VkDevice dev,
uint32_t maxFramesInFlight = 2 )

Creates the descriptor pool.

Allocates and initializes the Vulkan descriptor pool.

Parameters
deviceVulkan logical device context.
maxFramesInFlightAllocated size constraints for double-buffering.
devLogical device context.

◆ createCameraDescriptorSetLayout()

void VulkanDescriptors::createCameraDescriptorSetLayout ( )

Creates descriptor set layouts defining resource bindings for camera.

Configures binding requirements and instantiates layout description.

◆ createJointsDescriptorSetLayout()

void VulkanDescriptors::createJointsDescriptorSetLayout ( )

Creates descriptor set layout for joints/bones matrices.

Configures binding requirements for joint matrices and instantiates layout description.

◆ createTextureDescriptorSetLayout()

void VulkanDescriptors::createTextureDescriptorSetLayout ( )

Creates descriptor set layout for texture samplers.

Configures binding requirements for texture samplers and instantiates layout description.

◆ destroy()

void VulkanDescriptors::destroy ( )

Safely destroys layout bindings and descriptor pools.

Safely destroys descriptor pools and layouts.

◆ getCameraDescriptorSet()

VkDescriptorSet VulkanDescriptors::getCameraDescriptorSet ( ) const
inline

Gets raw camera descriptor set.

Returns
VkDescriptorSet handle.

◆ getCameraDescriptorSetLayout()

VkDescriptorSetLayout VulkanDescriptors::getCameraDescriptorSetLayout ( ) const
inline

Gets raw camera descriptor set layout.

Returns
VkDescriptorSetLayout handle.

◆ getDescriptorPool()

VkDescriptorPool VulkanDescriptors::getDescriptorPool ( ) const
inline

Gets raw descriptor pool.

Returns
VkDescriptorPool handle.

◆ getJointsDescriptorSetLayout()

VkDescriptorSetLayout VulkanDescriptors::getJointsDescriptorSetLayout ( ) const
inline

Gets raw joints descriptor set layout.

Returns
VkDescriptorSetLayout handle.

◆ getTextureDescriptorSetLayout()

VkDescriptorSetLayout VulkanDescriptors::getTextureDescriptorSetLayout ( ) const
inline

Gets raw texture descriptor set layout.

Returns
VkDescriptorSetLayout handle.

◆ operator=()

VulkanDescriptors & VulkanDescriptors::operator= ( const VulkanDescriptors & )
delete

◆ updateTextureDescriptorSet()

void VulkanDescriptors::updateTextureDescriptorSet ( VkDescriptorSet descriptorSet,
VkImageView diffuseView,
VkSampler diffuseSampler,
VkImageView normalView,
VkSampler normalSampler,
VkImageView metallicView,
VkSampler metallicSampler )

Updates an existing texture descriptor set with new sampler bindings.

Member Data Documentation

◆ cameraDescriptorSet

VkDescriptorSet VulkanDescriptors::cameraDescriptorSet = VK_NULL_HANDLE
private

Descriptor set allocated for camera.

◆ cameraDescriptorSetLayout

VkDescriptorSetLayout VulkanDescriptors::cameraDescriptorSetLayout = VK_NULL_HANDLE
private

Descriptor set layout allocated for camera.

◆ descriptorPool

VkDescriptorPool VulkanDescriptors::descriptorPool = VK_NULL_HANDLE
private

Descriptor pool allocator.

◆ device

VkDevice VulkanDescriptors::device = VK_NULL_HANDLE
private

Reference to logical device.

◆ jointsDescriptorSetLayout

VkDescriptorSetLayout VulkanDescriptors::jointsDescriptorSetLayout = VK_NULL_HANDLE
private

Descriptor set layout allocated for joints.

◆ textureDescriptorSetLayout

VkDescriptorSetLayout VulkanDescriptors::textureDescriptorSetLayout = VK_NULL_HANDLE
private

Descriptor set layout allocated for textures.


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