mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
begenning the refactor
This commit is contained in:
41
runtime/Includes/Renderer/Descriptors/DescriptorPool.h
git.filemode.normal_file
41
runtime/Includes/Renderer/Descriptors/DescriptorPool.h
git.filemode.normal_file
@@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* DescriptorPool.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/23 18:32:43 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 23:00:29 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __VK_DESCRIPTOR_POOL__
|
||||
#define __VK_DESCRIPTOR_POOL__
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class DescriptorPool
|
||||
{
|
||||
public:
|
||||
DescriptorPool() = default;
|
||||
|
||||
void Init(std::size_t n, NonOwningPtr<VkDescriptorPoolSize> size);
|
||||
void FreeDescriptor(const class DescriptorSet& set);
|
||||
void Destroy() noexcept;
|
||||
|
||||
inline VkDescriptorPool& operator()() noexcept { return m_pool; }
|
||||
inline VkDescriptorPool& Get() noexcept { return m_pool; }
|
||||
inline std::size_t GetNumberOfSetsAllocated() const noexcept { return m_allocated_sets; }
|
||||
|
||||
inline bool IsInit() const noexcept { return m_pool != VK_NULL_HANDLE; }
|
||||
|
||||
~DescriptorPool() = default;
|
||||
|
||||
private:
|
||||
VkDescriptorPool m_pool = VK_NULL_HANDLE;
|
||||
std::size_t m_allocated_sets = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
35
runtime/Includes/Renderer/Descriptors/DescriptorPoolManager.h
git.filemode.normal_file
35
runtime/Includes/Renderer/Descriptors/DescriptorPoolManager.h
git.filemode.normal_file
@@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* DescriptorPoolManager.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/20 06:26:26 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 23:00:56 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_DESCRIPTOR_POOL_MANAGER__
|
||||
#define __MLX_DESCRIPTOR_POOL_MANAGER__
|
||||
|
||||
#include <Renderer/Descriptors/DescriptorPool.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class DescriptorPoolManager
|
||||
{
|
||||
public:
|
||||
DescriptorPoolManager() = default;
|
||||
|
||||
DescriptorPool& GetAvailablePool(); // assumes the pool is for only one set allocation, may cause some issues if this is for more than one
|
||||
void DestroyAllPools();
|
||||
|
||||
~DescriptorPoolManager() = default;
|
||||
|
||||
private:
|
||||
std::list<DescriptorPool> m_pools;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
51
runtime/Includes/Renderer/Descriptors/DescriptorSet.h
git.filemode.normal_file
51
runtime/Includes/Renderer/Descriptors/DescriptorSet.h
git.filemode.normal_file
@@ -0,0 +1,51 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* DescriptorSet.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/23 18:39:36 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 23:02:38 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __VK_DESCRIPTOR_SET__
|
||||
#define __VK_DESCRIPTOR_SET__
|
||||
|
||||
#include <Renderer/Core/RenderCore.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class DescriptorSet
|
||||
{
|
||||
public:
|
||||
DescriptorSet() = default;
|
||||
|
||||
void Init(class Renderer* renderer, class DescriptorPool* pool, class DescriptorSetLayout* layout);
|
||||
|
||||
void WriteDescriptor(int binding, NonOwningPtr<class UniformBuffer> ubo) const noexcept;
|
||||
void WriteDescriptor(int binding, const class Image& image) const noexcept;
|
||||
|
||||
inline bool IsInit() const noexcept { return m_pool != nullptr && m_renderer != nullptr; }
|
||||
|
||||
DescriptorSet Duplicate();
|
||||
|
||||
VkDescriptorSet& operator()() noexcept;
|
||||
VkDescriptorSet& Get() noexcept;
|
||||
|
||||
inline const std::array<VkDescriptorSet, MAX_FRAMES_IN_FLIGHT>& GetAllFramesDescriptorSets() const { return m_desc_set; }
|
||||
|
||||
void Destroy() noexcept;
|
||||
|
||||
~DescriptorSet() = default;
|
||||
|
||||
private:
|
||||
std::array<VkDescriptorSet, MAX_FRAMES_IN_FLIGHT> m_desc_set;
|
||||
NonOwningPtr<class DescriptorPool> p_pool;
|
||||
NonOwningPtr<class DescriptorSetLayout> p_layout;
|
||||
NonOwningPtr<class Renderer> p_renderer;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
38
runtime/Includes/Renderer/Descriptors/DescriptorSetLayout.h
git.filemode.normal_file
38
runtime/Includes/Renderer/Descriptors/DescriptorSetLayout.h
git.filemode.normal_file
@@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* DescriptorSetLayout.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/23 18:36:22 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 23:03:04 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __VK_DESCRIPTOR_SET_LAYOUT__
|
||||
#define __VK_DESCRIPTOR_SET_LAYOUT__
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class DescriptorSetLayout
|
||||
{
|
||||
public:
|
||||
DescriptorSetLayout() = default;
|
||||
|
||||
void Init(std::vector<std::pair<int, VkDescriptorType>> binds, VkShaderStageFlagBits stage);
|
||||
void Destroy() noexcept;
|
||||
|
||||
inline VkDescriptorSetLayout& operator()() noexcept { return m_layout; }
|
||||
inline VkDescriptorSetLayout& Get() noexcept { return m_layout; }
|
||||
inline const std::vector<std::pair<int, VkDescriptorType>>& GetBindings() const noexcept { return m_bindings; }
|
||||
|
||||
~DescriptorSetLayout() = default;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<int, VkDescriptorType>> m_bindings;
|
||||
VkDescriptorSetLayout m_layout = VK_NULL_HANDLE;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user