mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
working on code refactor
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/06 23:18:52 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 22:09:07 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 14:20:49 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace mlx
|
||||
void Create(BufferType type, VkDeviceSize size, VkBufferUsageFlags usage, const char* name, const void* data = nullptr);
|
||||
void Destroy() noexcept;
|
||||
|
||||
inline void MapMem(void** data) noexcept { Render_Core::get().getAllocator().mapMemory(m_allocation, data); m_is_mapped = true; }
|
||||
inline void MapMem(void** data) noexcept { RenderCore::Get().GetAllocator().MapMemory(m_allocation, data); m_is_mapped = true; }
|
||||
inline bool IsMapped() const noexcept { return m_is_mapped; }
|
||||
inline void UnmapMem() noexcept { Render_Core::get().getAllocator().unmapMemory(m_allocation); m_is_mapped = false; }
|
||||
inline void UnmapMem() noexcept { RenderCore::Get().GetAllocator().UnmapMemory(m_allocation); m_is_mapped = false; }
|
||||
|
||||
void Flush(VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0);
|
||||
bool CopyFromBuffer(const Buffer& buffer) noexcept;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/06 18:45:29 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 22:15:23 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 14:23:56 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace mlx
|
||||
private:
|
||||
std::array<Buffer, MAX_FRAMES_IN_FLIGHT> m_buffers;
|
||||
std::array<void*, MAX_FRAMES_IN_FLIGHT> m_maps;
|
||||
NonOwningPtr<class Renderer> m_renderer;
|
||||
NonOwningPtr<class Renderer> p_renderer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/06 18:25:42 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 22:44:58 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 17:59:50 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace mlx
|
||||
void Destroy() noexcept;
|
||||
|
||||
void BeginRecord(VkCommandBufferUsageFlags usage = 0);
|
||||
void Submit(class Semaphore* semaphores) noexcept;
|
||||
void Submit(NonOwningPtr<class Semaphore> signal, NonOwningPtr<class Semaphore> wait) noexcept;
|
||||
void SubmitIdle(bool shouldWaitForExecution = true) noexcept; // TODO : handle `shouldWaitForExecution` as false by default (needs to modify CmdResources lifetimes to do so)
|
||||
void UpdateSubmitState() noexcept;
|
||||
inline void WaitForExecution() noexcept { m_fence.wait(); UpdateSubmitState(); m_state = CommandBufferState::Ready; }
|
||||
@@ -58,7 +58,7 @@ namespace mlx
|
||||
void PostTransferBarrier() noexcept;
|
||||
|
||||
private:
|
||||
std::vector<class CmdResource*> m_cmd_resources;
|
||||
std::vector<NonOwningPtr<class CommandResource>> m_cmd_resources;
|
||||
Fence m_fence;
|
||||
VkCommandBuffer m_cmd_buffer = VK_NULL_HANDLE;
|
||||
NonOwningPtr<class CmdPool> m_pool;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/10 21:00:37 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 22:47:32 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 18:10:56 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace mlx
|
||||
{
|
||||
public:
|
||||
DrawableResource() = default;
|
||||
virtual void Render(std::array<VkDescriptorSet, 2>& sets, class Renderer& renderer) = 0;
|
||||
virtual void Render(class Renderer& renderer) = 0;
|
||||
virtual void ResetUpdate() {}
|
||||
virtual ~DrawableResource() = default;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/08 19:03:04 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 22:48:55 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 18:44:02 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace mlx
|
||||
void Init();
|
||||
void Destroy() noexcept;
|
||||
|
||||
inline std::uint32_t GetInstanceVersion() const noexcept { return m_instance_version; }
|
||||
|
||||
inline VkInstance& operator()() noexcept { return m_instance; }
|
||||
inline VkInstance& Get() noexcept { return m_instance; }
|
||||
|
||||
@@ -29,6 +31,7 @@ namespace mlx
|
||||
|
||||
private:
|
||||
VkInstance m_instance = VK_NULL_HANDLE;
|
||||
std::uint32_t m_instance_version = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/19 14:04:25 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 22:59:00 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 19:16:25 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace mlx
|
||||
|
||||
void Init();
|
||||
void Destroy();
|
||||
|
||||
|
||||
bool CheckValidationLayerSupport();
|
||||
void PopulateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& create_info);
|
||||
|
||||
|
||||
VkResult SetDebugUtilsObjectNameEXT(VkObjectType object_type, std::uint64_t object_handle, const char* object_name);
|
||||
|
||||
~ValidationLayers() = default;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* 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 */
|
||||
/* Updated: 2024/04/23 19:36:03 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,8 +20,9 @@ namespace mlx
|
||||
public:
|
||||
DescriptorPool() = default;
|
||||
|
||||
void Init(std::size_t n, NonOwningPtr<VkDescriptorPoolSize> size);
|
||||
void FreeDescriptor(const class DescriptorSet& set);
|
||||
void Init(std::vector<VkDescriptorPoolSize> sizes);
|
||||
VkDescriptorSet AllocateDescriptorSet(class DescriptorSetLayout& layout);
|
||||
void FreeDescriptor(VkDescriptorSet set);
|
||||
void Destroy() noexcept;
|
||||
|
||||
inline VkDescriptorPool& operator()() noexcept { return m_pool; }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* 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 */
|
||||
/* Updated: 2024/04/23 19:40:22 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace mlx
|
||||
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
|
||||
DescriptorPool& GetAvailablePool();
|
||||
void DestroyAllPools();
|
||||
|
||||
~DescriptorPoolManager() = default;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* 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 */
|
||||
/* Updated: 2024/04/23 19:49:02 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#define __VK_DESCRIPTOR_SET__
|
||||
|
||||
#include <Renderer/Core/RenderCore.h>
|
||||
#include <Renderer/Descriptors/DescriptorSetLayout.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace mlx
|
||||
public:
|
||||
DescriptorSet() = default;
|
||||
|
||||
void Init(class Renderer* renderer, class DescriptorPool* pool, class DescriptorSetLayout* layout);
|
||||
void Init(NonOwningPtr<class Renderer> renderer, NonOwningPtr<class DescriptorPool> pool, DescriptorSetLayout layout);
|
||||
|
||||
void WriteDescriptor(int binding, NonOwningPtr<class UniformBuffer> ubo) const noexcept;
|
||||
void WriteDescriptor(int binding, const class Image& image) const noexcept;
|
||||
@@ -41,9 +42,9 @@ namespace mlx
|
||||
~DescriptorSet() = default;
|
||||
|
||||
private:
|
||||
DescriptorSetLayout p_layout;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* 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 */
|
||||
/* Updated: 2024/04/23 19:50:50 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/25 11:54:21 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/28 22:08:35 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 20:00:53 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace mlx
|
||||
void CreateSampler() noexcept;
|
||||
void CopyFromBuffer(class Buffer& buffer);
|
||||
void CopyToBuffer(class Buffer& buffer);
|
||||
void TransitionLayout(VkImageLayout new_layout, CmdBuffer* cmd = nullptr);
|
||||
void TransitionLayout(VkImageLayout new_layout, NonOwningPtr<CommandBuffer> cmd = nullptr);
|
||||
virtual void Destroy() noexcept;
|
||||
|
||||
inline VkImage Get() noexcept { return m_image; }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/08 02:24:58 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/28 22:11:21 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 20:03:59 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -26,15 +26,15 @@ namespace mlx
|
||||
Texture() = default;
|
||||
|
||||
void Create(std::uint8_t* pixels, std::uint32_t width, std::uint32_t height, VkFormat format, const char* name, bool dedicated_memory = false);
|
||||
void Render(std::array<VkDescriptorSet, 2>& sets, class Renderer& renderer, int x, int y);
|
||||
void Render(class Renderer& renderer, int x, int y);
|
||||
void Destroy() noexcept override;
|
||||
|
||||
void SetPixel(int x, int y, std::uint32_t color) noexcept;
|
||||
int GetPixel(int x, int y) noexcept;
|
||||
|
||||
inline void SetDescriptor(DescriptorSet&& set) noexcept { m_set = set; }
|
||||
inline VkDescriptorSet GetSet() noexcept { return m_set.isInit() ? m_set.get() : VK_NULL_HANDLE; }
|
||||
inline void UpdateSet(int binding) noexcept { m_set.writeDescriptor(binding, *this); m_has_set_been_updated = true; }
|
||||
inline VkDescriptorSet GetSet() noexcept { return m_set.IsInit() ? m_set.get() : VK_NULL_HANDLE; }
|
||||
inline void UpdateSet(int binding) noexcept { m_set.WriteDescriptor(binding, *this); m_has_set_been_updated = true; }
|
||||
inline bool HasBeenUpdated() const noexcept { return m_has_set_been_updated; }
|
||||
inline constexpr void ResetUpdate() noexcept { m_has_set_been_updated = false; }
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace mlx
|
||||
bool m_has_set_been_updated = false;
|
||||
};
|
||||
|
||||
Texture StbTextureLoad(std::filesystem::path file, int* w, int* h);
|
||||
Texture* StbTextureLoad(std::filesystem::path file, int* w, int* h);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user