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.hpp
Go to the documentation of this file.
1#pragma once
2#include <vulkan/vulkan.h>
3#include <vector>
4#include <stdexcept>
5
11public:
15 VulkanDescriptors() = default;
20
23
24 // Initialize descriptor system
30 void create(VkDevice device, uint32_t maxFramesInFlight = 2);
31
32 // Create layout for a uniform buffer (e.g., camera UBO)
37
42
47
48 // Allocate and update descriptor sets for a uniform buffer
54 void allocateCameraDescriptorSets(VkBuffer uniformBuffer, VkDeviceSize bufferSize);
55
67 VkDescriptorSet& descriptorSet,
68 VkImageView diffuseView, VkSampler diffuseSampler,
69 VkImageView normalView, VkSampler normalSampler,
70 VkImageView metallicView, VkSampler metallicSampler
71 );
72
77 VkDescriptorSet descriptorSet,
78 VkImageView diffuseView, VkSampler diffuseSampler,
79 VkImageView normalView, VkSampler normalSampler,
80 VkImageView metallicView, VkSampler metallicSampler
81 );
82
89 void allocateJointsDescriptorSet(VkDescriptorSet& descriptorSet, VkBuffer uniformBuffer, VkDeviceSize range);
90
91 // Cleanup
95 void destroy();
96
97 // Getters
102 VkDescriptorSetLayout getCameraDescriptorSetLayout() const { return cameraDescriptorSetLayout; }
107 VkDescriptorSetLayout getTextureDescriptorSetLayout() const { return textureDescriptorSetLayout; }
112 VkDescriptorSetLayout getJointsDescriptorSetLayout() const { return jointsDescriptorSetLayout; }
117 VkDescriptorSet getCameraDescriptorSet() const { return cameraDescriptorSet; }
122 VkDescriptorPool getDescriptorPool() const { return descriptorPool; }
123
124private:
126 VkDevice device = VK_NULL_HANDLE;
127
129 VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
131 VkDescriptorSetLayout cameraDescriptorSetLayout = VK_NULL_HANDLE;
133 VkDescriptorSetLayout textureDescriptorSetLayout = VK_NULL_HANDLE;
135 VkDescriptorSetLayout jointsDescriptorSetLayout = VK_NULL_HANDLE;
137 VkDescriptorSet cameraDescriptorSet = VK_NULL_HANDLE;
138};
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.
Definition VulkanDescriptors.cpp:163
void create(VkDevice device, uint32_t maxFramesInFlight=2)
Creates the descriptor pool.
Definition VulkanDescriptors.cpp:36
VkDescriptorSetLayout jointsDescriptorSetLayout
Descriptor set layout allocated for joints.
Definition VulkanDescriptors.hpp:135
~VulkanDescriptors()
Destroy the Vulkan Descriptors object and release descriptor resources.
Definition VulkanDescriptors.cpp:6
VkDevice device
Reference to logical device.
Definition VulkanDescriptors.hpp:126
VkDescriptorSetLayout getJointsDescriptorSetLayout() const
Gets raw joints descriptor set layout.
Definition VulkanDescriptors.hpp:112
VkDescriptorPool getDescriptorPool() const
Gets raw descriptor pool.
Definition VulkanDescriptors.hpp:122
void createCameraDescriptorSetLayout()
Creates descriptor set layouts defining resource bindings for camera.
Definition VulkanDescriptors.cpp:59
VulkanDescriptors(const VulkanDescriptors &)=delete
void destroy()
Safely destroys layout bindings and descriptor pools.
Definition VulkanDescriptors.cpp:13
void allocateCameraDescriptorSets(VkBuffer uniformBuffer, VkDeviceSize bufferSize)
Allocates and binds descriptor sets for the camera UBO.
Definition VulkanDescriptors.cpp:82
void createTextureDescriptorSetLayout()
Creates descriptor set layout for texture samplers.
Definition VulkanDescriptors.cpp:112
VulkanDescriptors()=default
Construct a new Vulkan Descriptors object.
VkDescriptorSet cameraDescriptorSet
Descriptor set allocated for camera.
Definition VulkanDescriptors.hpp:137
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).
Definition VulkanDescriptors.cpp:145
VkDescriptorSetLayout textureDescriptorSetLayout
Descriptor set layout allocated for textures.
Definition VulkanDescriptors.hpp:133
VkDescriptorSetLayout getTextureDescriptorSetLayout() const
Gets raw texture descriptor set layout.
Definition VulkanDescriptors.hpp:107
VkDescriptorSetLayout getCameraDescriptorSetLayout() const
Gets raw camera descriptor set layout.
Definition VulkanDescriptors.hpp:102
VulkanDescriptors & operator=(const VulkanDescriptors &)=delete
void allocateJointsDescriptorSet(VkDescriptorSet &descriptorSet, VkBuffer uniformBuffer, VkDeviceSize range)
Allocates and binds descriptor set for a skeleton joint matrices buffer.
Definition VulkanDescriptors.cpp:219
VkDescriptorPool descriptorPool
Descriptor pool allocator.
Definition VulkanDescriptors.hpp:129
VkDescriptorSetLayout cameraDescriptorSetLayout
Descriptor set layout allocated for camera.
Definition VulkanDescriptors.hpp:131
void createJointsDescriptorSetLayout()
Creates descriptor set layout for joints/bones matrices.
Definition VulkanDescriptors.cpp:199
VkDescriptorSet getCameraDescriptorSet() const
Gets raw camera descriptor set.
Definition VulkanDescriptors.hpp:117