mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-10 22:23:34 +00:00
removing garbage file
This commit is contained in:
Binary file not shown.
BIN
macrolibpy/__pycache__/__init__.cpython-313.pyc
git.filemode.normal_file
BIN
macrolibpy/__pycache__/__init__.cpython-313.pyc
git.filemode.normal_file
Binary file not shown.
@@ -38,7 +38,7 @@ namespace mlx
|
|||||||
|
|
||||||
inline void UpdateDescriptorSet(std::shared_ptr<DescriptorSet> set)
|
inline void UpdateDescriptorSet(std::shared_ptr<DescriptorSet> set)
|
||||||
{
|
{
|
||||||
p_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool().RequestDescriptorSet(set->GetShaderLayout(), set->GetShaderType());
|
p_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool(set->GetShaderLayout(), set->GetShaderType()).RequestDescriptorSet(set->GetShaderLayout(), set->GetShaderType());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Bind(std::size_t frame_index, VkCommandBuffer cmd) = 0;
|
virtual void Bind(std::size_t frame_index, VkCommandBuffer cmd) = 0;
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ namespace mlx
|
|||||||
|
|
||||||
std::shared_ptr<class DescriptorSet> RequestDescriptorSet(const ShaderSetLayout& layout, ShaderType shader_type);
|
std::shared_ptr<class DescriptorSet> RequestDescriptorSet(const ShaderSetLayout& layout, ShaderType shader_type);
|
||||||
void ReturnDescriptorSet(std::shared_ptr<class DescriptorSet> set);
|
void ReturnDescriptorSet(std::shared_ptr<class DescriptorSet> set);
|
||||||
|
bool CanAllocate(const ShaderSetLayout& layout, ShaderType shader_type) const;
|
||||||
|
|
||||||
[[nodiscard]] inline VkDescriptorPool Get() const noexcept { return m_pool; }
|
[[nodiscard]] inline VkDescriptorPool Get() const noexcept { return m_pool; }
|
||||||
[[nodiscard]] MLX_FORCEINLINE std::size_t GetNumberOfSetsAllocated() const noexcept { return m_allocation_count; }
|
|
||||||
|
|
||||||
~DescriptorPool() = default;
|
~DescriptorPool() = default;
|
||||||
|
|
||||||
@@ -36,7 +36,6 @@ namespace mlx
|
|||||||
std::vector<std::shared_ptr<class DescriptorSet>> m_free_sets;
|
std::vector<std::shared_ptr<class DescriptorSet>> m_free_sets;
|
||||||
std::vector<std::shared_ptr<class DescriptorSet>> m_used_sets;
|
std::vector<std::shared_ptr<class DescriptorSet>> m_used_sets;
|
||||||
VkDescriptorPool m_pool;
|
VkDescriptorPool m_pool;
|
||||||
std::size_t m_allocation_count = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DescriptorPoolManager
|
class DescriptorPoolManager
|
||||||
@@ -44,7 +43,7 @@ namespace mlx
|
|||||||
public:
|
public:
|
||||||
DescriptorPoolManager() = default;
|
DescriptorPoolManager() = default;
|
||||||
|
|
||||||
DescriptorPool& GetAvailablePool();
|
DescriptorPool& GetAvailablePool(const ShaderSetLayout& layout, ShaderType shader_type);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
~DescriptorPoolManager() = default;
|
~DescriptorPoolManager() = default;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
constexpr std::size_t MAX_SETS_PER_POOL = MAX_FRAMES_IN_FLIGHT * 1024;
|
constexpr std::size_t MAX_SETS_PER_POOL = 1024;
|
||||||
|
|
||||||
void TransitionImageToCorrectLayout(Image& image, VkCommandBuffer cmd)
|
void TransitionImageToCorrectLayout(Image& image, VkCommandBuffer cmd)
|
||||||
{
|
{
|
||||||
@@ -26,19 +26,19 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
VkDescriptorPoolSize pool_sizes[] = {
|
VkDescriptorPoolSize pool_sizes[] = {
|
||||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_SETS_PER_POOL },
|
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_FRAMES_IN_FLIGHT * MAX_SETS_PER_POOL },
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MAX_SETS_PER_POOL },
|
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MAX_FRAMES_IN_FLIGHT * MAX_SETS_PER_POOL },
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MAX_SETS_PER_POOL }
|
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MAX_FRAMES_IN_FLIGHT * MAX_SETS_PER_POOL }
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo pool_info{};
|
VkDescriptorPoolCreateInfo pool_info{};
|
||||||
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
pool_info.poolSizeCount = sizeof(pool_sizes) / sizeof(pool_sizes[0]);
|
pool_info.poolSizeCount = sizeof(pool_sizes) / sizeof(pool_sizes[0]);
|
||||||
pool_info.pPoolSizes = pool_sizes;
|
pool_info.pPoolSizes = pool_sizes;
|
||||||
pool_info.maxSets = MAX_SETS_PER_POOL;
|
pool_info.maxSets = MAX_FRAMES_IN_FLIGHT * MAX_SETS_PER_POOL;
|
||||||
pool_info.flags = 0;
|
pool_info.flags = 0;
|
||||||
kvfCheckVk(RenderCore::Get().vkCreateDescriptorPool(RenderCore::Get().GetDevice(), &pool_info, nullptr, &m_pool));
|
kvfCheckVk(RenderCore::Get().vkCreateDescriptorPool(RenderCore::Get().GetDevice(), &pool_info, nullptr, &m_pool));
|
||||||
m_allocation_count = 0;
|
DebugLog("Vulkan: created new descriptor pool");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorPool::Destroy() noexcept
|
void DescriptorPool::Destroy() noexcept
|
||||||
@@ -52,7 +52,6 @@ namespace mlx
|
|||||||
kvfDestroyDescriptorSetLayout(RenderCore::Get().GetDevice(), set->m_set_layout);
|
kvfDestroyDescriptorSetLayout(RenderCore::Get().GetDevice(), set->m_set_layout);
|
||||||
RenderCore::Get().vkDestroyDescriptorPool(RenderCore::Get().GetDevice(), m_pool, nullptr);
|
RenderCore::Get().vkDestroyDescriptorPool(RenderCore::Get().GetDevice(), m_pool, nullptr);
|
||||||
m_pool = VK_NULL_HANDLE;
|
m_pool = VK_NULL_HANDLE;
|
||||||
m_allocation_count = 0;
|
|
||||||
m_free_sets.clear();
|
m_free_sets.clear();
|
||||||
m_used_sets.clear();
|
m_used_sets.clear();
|
||||||
}
|
}
|
||||||
@@ -103,7 +102,6 @@ namespace mlx
|
|||||||
alloc_info.pSetLayouts = &vulkan_layout;
|
alloc_info.pSetLayouts = &vulkan_layout;
|
||||||
VkDescriptorSet vulkan_set;
|
VkDescriptorSet vulkan_set;
|
||||||
kvfCheckVk(RenderCore::Get().vkAllocateDescriptorSets(RenderCore::Get().GetDevice(), &alloc_info, &vulkan_set));
|
kvfCheckVk(RenderCore::Get().vkAllocateDescriptorSets(RenderCore::Get().GetDevice(), &alloc_info, &vulkan_set));
|
||||||
m_allocation_count++;
|
|
||||||
vulkan_sets[i] = vulkan_set;
|
vulkan_sets[i] = vulkan_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,12 +122,23 @@ namespace mlx
|
|||||||
m_free_sets.push_back(set);
|
m_free_sets.push_back(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorPool& DescriptorPoolManager::GetAvailablePool()
|
bool DescriptorPool::CanAllocate(const ShaderSetLayout& layout, ShaderType shader_type) const
|
||||||
|
{
|
||||||
|
auto it = std::find_if(m_free_sets.begin(), m_free_sets.end(), [&](std::shared_ptr<DescriptorSet> set)
|
||||||
|
{
|
||||||
|
return shader_type == set->GetShaderType() && layout == set->GetShaderLayout();
|
||||||
|
});
|
||||||
|
if(it != m_free_sets.end())
|
||||||
|
return true;
|
||||||
|
return m_used_sets.size() + m_free_sets.size() < MAX_SETS_PER_POOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DescriptorPool& DescriptorPoolManager::GetAvailablePool(const ShaderSetLayout& layout, ShaderType shader_type)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
for(auto& pool : m_pools)
|
for(auto& pool : m_pools)
|
||||||
{
|
{
|
||||||
if(pool->GetNumberOfSetsAllocated() < MAX_SETS_PER_POOL)
|
if(pool->CanAllocate(layout, shader_type))
|
||||||
return *pool;
|
return *pool;
|
||||||
}
|
}
|
||||||
m_pools.emplace_back(std::make_unique<DescriptorPool>())->Init();
|
m_pools.emplace_back(std::make_unique<DescriptorPool>())->Init();
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ namespace mlx
|
|||||||
};
|
};
|
||||||
EventBus::RegisterListener({ functor, "mlx_2d_render_pass_" + std::to_string(reinterpret_cast<std::uintptr_t>(this)) });
|
EventBus::RegisterListener({ functor, "mlx_2d_render_pass_" + std::to_string(reinterpret_cast<std::uintptr_t>(this)) });
|
||||||
|
|
||||||
p_viewer_data_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool().RequestDescriptorSet(p_vertex_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Vertex);
|
p_viewer_data_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool(p_vertex_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Vertex).RequestDescriptorSet(p_vertex_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Vertex);
|
||||||
p_texture_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool().RequestDescriptorSet(p_fragment_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Fragment);
|
p_texture_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool(p_fragment_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Fragment).RequestDescriptorSet(p_fragment_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Fragment);
|
||||||
|
|
||||||
p_viewer_data_buffer = std::make_shared<UniformBuffer>();
|
p_viewer_data_buffer = std::make_shared<UniformBuffer>();
|
||||||
p_viewer_data_buffer->Init(sizeof(ViewerData), "mlx_2d_pass_viewer_data");
|
p_viewer_data_buffer->Init(sizeof(ViewerData), "mlx_2d_pass_viewer_data");
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace mlx
|
|||||||
};
|
};
|
||||||
EventBus::RegisterListener({ functor, "mlx_final_pass_" + std::to_string(reinterpret_cast<std::uintptr_t>(this)) });
|
EventBus::RegisterListener({ functor, "mlx_final_pass_" + std::to_string(reinterpret_cast<std::uintptr_t>(this)) });
|
||||||
|
|
||||||
p_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool().RequestDescriptorSet(p_fragment_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Fragment);
|
p_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool(p_fragment_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Fragment).RequestDescriptorSet(p_fragment_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinalPass::Pass([[maybe_unused]] Scene& scene, Renderer& renderer, Texture& render_target, NonOwningPtr<class Texture> final_target)
|
void FinalPass::Pass([[maybe_unused]] Scene& scene, Renderer& renderer, Texture& render_target, NonOwningPtr<class Texture> final_target)
|
||||||
|
|||||||
Reference in New Issue
Block a user