diff --git a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.cpp b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.cpp index 87d43255..77663ab8 100644 --- a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.cpp +++ b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.cpp @@ -7,32 +7,52 @@ namespace SHADE { - /*---------------------------------------------------------------------------------*/ - /* Constructor/Destructor */ - /*---------------------------------------------------------------------------------*/ - SHVkDescriptorPool::SHVkDescriptorPool(Handle device, const Config& config) - : device { device } + /*---------------------------------------------------------------------------------*/ + /* Constructor/Destructor */ + /*---------------------------------------------------------------------------------*/ + SHVkDescriptorPool::SHVkDescriptorPool(Handle device, const Config& config) + : device{ device } + { + // Create the Pool + const vk::DescriptorPoolCreateInfo POOL_CREATE_INFO { - // Create the Pool - const vk::DescriptorPoolCreateInfo POOL_CREATE_INFO - { - .flags = config.Flags, - .maxSets = config.MaxSets, - .poolSizeCount = static_cast(config.Limits.size()), - .pPoolSizes = config.Limits.data() - }; - pool = device->GetVkLogicalDevice().createDescriptorPool(POOL_CREATE_INFO); - } + .flags = config.Flags, + .maxSets = config.MaxSets, + .poolSizeCount = static_cast(config.Limits.size()), + .pPoolSizes = config.Limits.data() + }; + pool = device->GetVkLogicalDevice().createDescriptorPool(POOL_CREATE_INFO); + } - SHVkDescriptorPool::~SHVkDescriptorPool() noexcept - { - if (pool) - device->GetVkLogicalDevice().destroyDescriptorPool(pool); - } + SHVkDescriptorPool::SHVkDescriptorPool(SHVkDescriptorPool&& rhs) noexcept + : device{ rhs.device } + , pool{ rhs.pool } + { + rhs.pool = VK_NULL_HANDLE; + } - std::vector> SHVkDescriptorPool::Allocate(const std::vector>& layouts, std::vector const& variableDescCounts) - { - SHVkInstance::GetResourceManager().Create(device, GetHandle(), layouts, variableDescCounts); - return {}; - } + SHVkDescriptorPool::~SHVkDescriptorPool() noexcept + { + if (pool) + device->GetVkLogicalDevice().destroyDescriptorPool(pool); + } + + SHVkDescriptorPool& SHVkDescriptorPool::operator=(SHVkDescriptorPool&& rhs) noexcept + { + if (&rhs == this) + return *this; + + device = rhs.device; + pool = rhs.pool; + + rhs.pool = VK_NULL_HANDLE; + + return *this; + } + + std::vector> SHVkDescriptorPool::Allocate(const std::vector>& layouts, std::vector const& variableDescCounts) + { + SHVkInstance::GetResourceManager().Create(device, GetHandle(), layouts, variableDescCounts); + return {}; + } } diff --git a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.h b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.h index c3059b8b..9314d940 100644 --- a/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.h +++ b/SHADE_Engine/src/Graphics/Descriptors/SHVkDescriptorPool.h @@ -65,7 +65,7 @@ namespace SHADE /// SHVkDescriptorPool(Handle device, const Config& config = {}); SHVkDescriptorPool(const SHVkDescriptorPool&) = delete; - SHVkDescriptorPool(SHVkDescriptorPool&& rhs) noexcept = default; + SHVkDescriptorPool(SHVkDescriptorPool&& rhs) noexcept; /// /// Destructor which will unload and deallocate all resources for this Pool. /// @@ -75,7 +75,7 @@ namespace SHADE /* Overloaded Operators */ /*-----------------------------------------------------------------------------*/ SHVkDescriptorPool& operator=(const SHVkDescriptorPool&) = delete; - SHVkDescriptorPool& operator=(SHVkDescriptorPool&& rhs) noexcept = default; + SHVkDescriptorPool& operator=(SHVkDescriptorPool&& rhs) noexcept; /*-----------------------------------------------------------------------------*/ /* Getter Functions */ diff --git a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp index aa442805..0fa1c864 100644 --- a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp +++ b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.cpp @@ -509,6 +509,12 @@ namespace SHADE } + Handle SHVkLogicalDevice::CreateDescriptorPools(const SHVkDescriptorPool::Config& config /*= {}*/) noexcept + { + return SHVkInstance::GetResourceManager().Create (GetHandle(), config); + + } + /***************************************************************************/ /*! diff --git a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h index b8eec993..78108b94 100644 --- a/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h +++ b/SHADE_Engine/src/Graphics/Devices/SHVkLogicalDevice.h @@ -17,7 +17,7 @@ #include "Graphics/Pipeline/SHPipelineState.h" #include "Graphics/Pipeline/SHPipelineType.h" #include "vk_mem_alloc.h" -//#include "Graphics/DescriptorSets/SHDescriptorPool.h" +#include "Graphics/Descriptors/SHVkDescriptorPool.h" #include "Graphics/Descriptors/SHVkDescriptorSetLayout.h" namespace SHADE @@ -165,6 +165,7 @@ namespace SHADE Handle CreateRenderpass (std::span const vkDescriptions, std::span const spDescs, std::span const spDeps) noexcept; Handle CreateFramebuffer (Handle const& renderpassHdl, std::vector> const& attachments, uint32_t inWidth, uint32_t inHeight) noexcept; Handle CreateDescriptorSetLayout (std::vector const& bindings) noexcept; + Handle CreateDescriptorPools (const SHVkDescriptorPool::Config& config = {}) noexcept; Handle CreatePipelineLayout (SHPipelineLayoutParams& pipelineLayoutParams) noexcept; Handle CreateFence (void) const noexcept; Handle CreateSemaphore (void) const noexcept; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 7bc2f9ee..9c395c9d 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -86,6 +86,8 @@ namespace SHADE + descPool = device->CreateDescriptorPools(); + /*-----------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h index c3c94a6f..fabef927 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h @@ -22,6 +22,7 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics/MiddleEnd/PerFrame/SHRenderContext.h" #include "Graphics/RenderGraph/SHRenderGraph.h" #include "Engine/ECS_Base/System/SHSystem.h" +#include "Graphics/Descriptors/SHVkDescriptorPool.h" namespace SHADE { @@ -113,7 +114,8 @@ namespace SHADE Handle GetSwapchain() const { return swapchain; } Handle GetSurface() const { return surface; } Handle GetPhysicalDevice() const {return physicalDevice;} - Handle GetQueue () const {return queue;} + Handle GetQueue() const { return queue; } + Handle GetDescriptorPool() const { return descPool; } //Handle GetRenderPass() const { return renderPass; } @@ -127,6 +129,7 @@ namespace SHADE Handle surface; Handle swapchain; Handle queue; + Handle descPool; //Handle renderPass; // Potentially bring out? std::vector screenSegments; SHRenderContext renderContext;