mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
adding shaders compilation in makefile
This commit is contained in:
@@ -17,31 +17,69 @@ namespace mlx
|
||||
std::uint32_t binding;
|
||||
};
|
||||
|
||||
class DescriptorPool
|
||||
{
|
||||
public:
|
||||
DescriptorPool() = default;
|
||||
|
||||
void Init() noexcept;
|
||||
void Destroy() noexcept;
|
||||
|
||||
VkDescriptorSet AllocateDescriptorSet(std::uint32_t frame_index, VkDescriptorSetLayout layout);
|
||||
|
||||
void ResetPoolFromFrameIndex(std::size_t frame_index);
|
||||
|
||||
[[nodiscard]] inline VkDescriptorPool Get(std::uint32_t index) const noexcept { return m_pools[index]; }
|
||||
[[nodiscard]] MLX_FORCEINLINE std::size_t GetNumberOfSetsAllocated() const noexcept { return m_allocation_count; }
|
||||
|
||||
~DescriptorPool() = default;
|
||||
|
||||
private:
|
||||
std::array<VkDescriptorPool, MAX_FRAMES_IN_FLIGHT> m_pools;
|
||||
std::size_t m_allocation_count = 0;
|
||||
};
|
||||
|
||||
class DescriptorPoolManager
|
||||
{
|
||||
public:
|
||||
DescriptorPoolManager() = default;
|
||||
|
||||
void ResetPoolsFromFrameIndex(std::size_t frame_index);
|
||||
DescriptorPool& GetAvailablePool();
|
||||
void Destroy();
|
||||
|
||||
~DescriptorPoolManager() = default;
|
||||
|
||||
private:
|
||||
std::list<DescriptorPool> m_pools;
|
||||
};
|
||||
|
||||
class DescriptorSet
|
||||
{
|
||||
public:
|
||||
DescriptorSet() { m_set.fill(VK_NULL_HANDLE); }
|
||||
DescriptorSet(const ShaderSetLayout& layout, VkDescriptorSetLayout vklayout, ShaderType shader_type);
|
||||
DescriptorSet(DescriptorPoolManager& pools_manager, const ShaderSetLayout& layout, VkDescriptorSetLayout vklayout, ShaderType shader_type);
|
||||
|
||||
void SetImage(std::size_t i, std::uint32_t binding, class Image& image);
|
||||
void SetStorageBuffer(std::size_t i, std::uint32_t binding, class GPUBuffer& buffer);
|
||||
void SetUniformBuffer(std::size_t i, std::uint32_t binding, class GPUBuffer& buffer);
|
||||
void Update(std::size_t i, VkCommandBuffer cmd = VK_NULL_HANDLE) noexcept;
|
||||
void Reallocate() noexcept;
|
||||
void Reallocate(std::size_t frame_index) noexcept;
|
||||
|
||||
[[nodiscard]] inline VkDescriptorSet GetSet(std::size_t i) const noexcept { return m_set[i]; }
|
||||
[[nodiscard]] inline DescriptorSet Duplicate() const { return DescriptorSet{ m_set_layout, m_descriptors }; }
|
||||
[[nodiscard]] inline DescriptorSet Duplicate() const { return DescriptorSet{ *p_pools_manager, m_set_layout, m_descriptors }; }
|
||||
[[nodiscard]] inline bool IsInit() const noexcept { return m_set[0] != VK_NULL_HANDLE; }
|
||||
|
||||
~DescriptorSet() = default;
|
||||
|
||||
private:
|
||||
DescriptorSet(VkDescriptorSetLayout layout, const std::vector<Descriptor>& descriptors);
|
||||
DescriptorSet(DescriptorPoolManager& pools_manager, VkDescriptorSetLayout layout, const std::vector<Descriptor>& descriptors);
|
||||
|
||||
private:
|
||||
std::vector<Descriptor> m_descriptors;
|
||||
std::array<VkDescriptorSet, MAX_FRAMES_IN_FLIGHT> m_set;
|
||||
VkDescriptorSetLayout m_set_layout;
|
||||
NonOwningPtr<DescriptorPoolManager> p_pools_manager;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace mlx
|
||||
MLX_PROFILE_FUNCTION();
|
||||
std::vector<VkFormat> candidates = { VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT };
|
||||
VkFormat format = kvfFindSupportFormatInCandidates(RenderCore::Get().GetDevice(), candidates.data(), candidates.size(), VK_IMAGE_TILING_OPTIMAL, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
||||
Image::Init(ImageType::Depth, width, height, format, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, is_multisampled, std::move(debug_name));
|
||||
Image::Init(ImageType::Depth, width, height, format, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, is_multisampled, std::move(debug_name));
|
||||
Image::CreateImageView(VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
Image::TransitionLayout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace mlx
|
||||
public:
|
||||
GraphicPipeline() = default;
|
||||
|
||||
void Init(const GraphicPipelineDescriptor& descriptor);
|
||||
void Init(const GraphicPipelineDescriptor& descriptor, std::string_view debug_name);
|
||||
bool BindPipeline(VkCommandBuffer command_buffer, std::size_t framebuffer_index, std::array<float, 4> clear) noexcept;
|
||||
void EndPipeline(VkCommandBuffer command_buffer) noexcept override;
|
||||
void Destroy() noexcept;
|
||||
@@ -46,6 +46,9 @@ namespace mlx
|
||||
std::vector<NonOwningPtr<Texture>> m_attachments;
|
||||
std::vector<VkFramebuffer> m_framebuffers;
|
||||
std::vector<VkClearValue> m_clears;
|
||||
#ifdef DEBUG
|
||||
std::string m_debug_name;
|
||||
#endif
|
||||
std::shared_ptr<Shader> p_vertex_shader;
|
||||
std::shared_ptr<Shader> p_fragment_shader;
|
||||
VkRenderPass m_renderpass = VK_NULL_HANDLE;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mlx
|
||||
{
|
||||
public:
|
||||
Render2DPass() = default;
|
||||
void Init();
|
||||
void Init(class Renderer& renderer);
|
||||
void Pass(class Scene& scene, class Renderer& renderer, class Texture& render_target);
|
||||
void Destroy();
|
||||
~Render2DPass() = default;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mlx
|
||||
{
|
||||
public:
|
||||
FinalPass() = default;
|
||||
void Init();
|
||||
void Init(class Renderer& renderer);
|
||||
void Pass(class Scene& scene, class Renderer& renderer, class Texture& render_target);
|
||||
void Destroy();
|
||||
~FinalPass() = default;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mlx
|
||||
{
|
||||
public:
|
||||
RenderPasses() = default;
|
||||
void Init();
|
||||
void Init(class Renderer& renderer);
|
||||
void Pass(class Scene& scene, class Renderer& renderer);
|
||||
void Destroy();
|
||||
~RenderPasses() = default;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <Utils/NonOwningPtr.h>
|
||||
#include <Renderer/RenderCore.h>
|
||||
#include <Renderer/Image.h>
|
||||
#include <Renderer/Descriptor.h>
|
||||
#include <Core/EventBus.h>
|
||||
|
||||
namespace mlx
|
||||
@@ -31,6 +32,7 @@ namespace mlx
|
||||
[[nodiscard]] inline std::size_t GetSwapchainImageIndex() const noexcept { return m_swapchain_image_index; }
|
||||
[[nodiscard]] inline std::size_t GetCurrentFrameIndex() const noexcept { return m_current_frame_index; }
|
||||
[[nodiscard]] inline NonOwningPtr<Window> GetWindow() const noexcept { return p_window; }
|
||||
[[nodiscard]] inline DescriptorPoolManager& GetDescriptorPoolManager() noexcept { return m_descriptor_pool_manager; }
|
||||
|
||||
MLX_FORCEINLINE constexpr void RequireFramebufferResize() noexcept { m_framebuffers_resize = true; }
|
||||
|
||||
@@ -43,6 +45,7 @@ namespace mlx
|
||||
void DestroySwapchain();
|
||||
|
||||
private:
|
||||
DescriptorPoolManager m_descriptor_pool_manager;
|
||||
std::array<VkSemaphore, MAX_FRAMES_IN_FLIGHT> m_image_available_semaphores;
|
||||
std::array<VkSemaphore, MAX_FRAMES_IN_FLIGHT> m_render_finished_semaphores;
|
||||
std::array<VkCommandBuffer, MAX_FRAMES_IN_FLIGHT> m_cmd_buffers;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace mlx
|
||||
{
|
||||
public:
|
||||
SceneRenderer() = default;
|
||||
void Init();
|
||||
void Init(class Renderer& renderer);
|
||||
void Render(class Scene& scene, class Renderer& renderer); // TODO : add RTT support
|
||||
void Destroy();
|
||||
~SceneRenderer() = default;
|
||||
|
||||
Reference in New Issue
Block a user