Created a descriptor pool for Graphics System

This commit is contained in:
Brandon Mak 2022-09-09 14:21:13 +08:00
parent fe954271cb
commit d7954245d6
6 changed files with 61 additions and 29 deletions

View File

@ -11,7 +11,7 @@ namespace SHADE
/* Constructor/Destructor */
/*---------------------------------------------------------------------------------*/
SHVkDescriptorPool::SHVkDescriptorPool(Handle<SHVkLogicalDevice> device, const Config& config)
: device { device }
: device{ device }
{
// Create the Pool
const vk::DescriptorPoolCreateInfo POOL_CREATE_INFO
@ -24,12 +24,32 @@ namespace SHADE
pool = device->GetVkLogicalDevice().createDescriptorPool(POOL_CREATE_INFO);
}
SHVkDescriptorPool::SHVkDescriptorPool(SHVkDescriptorPool&& rhs) noexcept
: device{ rhs.device }
, pool{ rhs.pool }
{
rhs.pool = VK_NULL_HANDLE;
}
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<Handle<SHVkDescriptorSetGroup>> SHVkDescriptorPool::Allocate(const std::vector<Handle<SHVkDescriptorSetLayout>>& layouts, std::vector<uint32_t> const& variableDescCounts)
{
SHVkInstance::GetResourceManager().Create<SHVkDescriptorSetGroup>(device, GetHandle(), layouts, variableDescCounts);

View File

@ -65,7 +65,7 @@ namespace SHADE
/// </param>
SHVkDescriptorPool(Handle<SHVkLogicalDevice> device, const Config& config = {});
SHVkDescriptorPool(const SHVkDescriptorPool&) = delete;
SHVkDescriptorPool(SHVkDescriptorPool&& rhs) noexcept = default;
SHVkDescriptorPool(SHVkDescriptorPool&& rhs) noexcept;
/// <summary>
/// Destructor which will unload and deallocate all resources for this Pool.
/// </summary>
@ -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 */

View File

@ -509,6 +509,12 @@ namespace SHADE
}
Handle<SHVkDescriptorPool> SHVkLogicalDevice::CreateDescriptorPools(const SHVkDescriptorPool::Config& config /*= {}*/) noexcept
{
return SHVkInstance::GetResourceManager().Create <SHVkDescriptorPool>(GetHandle(), config);
}
/***************************************************************************/
/*!

View File

@ -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<SHVkRenderpass> CreateRenderpass (std::span<vk::AttachmentDescription> const vkDescriptions, std::span<vk::SubpassDescription> const spDescs, std::span<vk::SubpassDependency> const spDeps) noexcept;
Handle<SHVkFramebuffer> CreateFramebuffer (Handle<SHVkRenderpass> const& renderpassHdl, std::vector<Handle<SHVkImageView>> const& attachments, uint32_t inWidth, uint32_t inHeight) noexcept;
Handle<SHVkDescriptorSetLayout> CreateDescriptorSetLayout (std::vector<SHVkDescriptorSetLayout::Binding> const& bindings) noexcept;
Handle<SHVkDescriptorPool> CreateDescriptorPools (const SHVkDescriptorPool::Config& config = {}) noexcept;
Handle<SHVkPipelineLayout> CreatePipelineLayout (SHPipelineLayoutParams& pipelineLayoutParams) noexcept;
Handle<SHVkFence> CreateFence (void) const noexcept;
Handle<SHVkSemaphore> CreateSemaphore (void) const noexcept;

View File

@ -86,6 +86,8 @@ namespace SHADE
descPool = device->CreateDescriptorPools();
/*-----------------------------------------------------------------------*/

View File

@ -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<SHVkSwapchain> GetSwapchain() const { return swapchain; }
Handle<SHVkSurface> GetSurface() const { return surface; }
Handle<SHVkPhysicalDevice> GetPhysicalDevice() const {return physicalDevice;}
Handle<SHVkQueue> GetQueue () const {return queue;}
Handle<SHVkQueue> GetQueue() const { return queue; }
Handle<SHVkDescriptorPool> GetDescriptorPool() const { return descPool; }
//Handle<SHVkRenderpass> GetRenderPass() const { return renderPass; }
@ -127,6 +129,7 @@ namespace SHADE
Handle<SHVkSurface> surface;
Handle<SHVkSwapchain> swapchain;
Handle<SHVkQueue> queue;
Handle<SHVkDescriptorPool> descPool;
//Handle<SHVkRenderpass> renderPass; // Potentially bring out?
std::vector<SHScreenSegment> screenSegments;
SHRenderContext renderContext;