removing garbage file

This commit is contained in:
2025-11-04 20:33:04 +01:00
parent ba0398092a
commit ec019ba45c
7 changed files with 25 additions and 17 deletions

Binary file not shown.

View File

@@ -38,7 +38,7 @@ namespace mlx
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;

View File

@@ -26,9 +26,9 @@ namespace mlx
std::shared_ptr<class DescriptorSet> RequestDescriptorSet(const ShaderSetLayout& layout, ShaderType shader_type);
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]] MLX_FORCEINLINE std::size_t GetNumberOfSetsAllocated() const noexcept { return m_allocation_count; }
~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_used_sets;
VkDescriptorPool m_pool;
std::size_t m_allocation_count = 0;
};
class DescriptorPoolManager
@@ -44,7 +43,7 @@ namespace mlx
public:
DescriptorPoolManager() = default;
DescriptorPool& GetAvailablePool();
DescriptorPool& GetAvailablePool(const ShaderSetLayout& layout, ShaderType shader_type);
void Destroy();
~DescriptorPoolManager() = default;

View File

@@ -9,7 +9,7 @@
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)
{
@@ -26,19 +26,19 @@ namespace mlx
{
MLX_PROFILE_FUNCTION();
VkDescriptorPoolSize pool_sizes[] = {
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_SETS_PER_POOL },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MAX_SETS_PER_POOL },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MAX_SETS_PER_POOL }
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_FRAMES_IN_FLIGHT * MAX_SETS_PER_POOL },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MAX_FRAMES_IN_FLIGHT * MAX_SETS_PER_POOL },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MAX_FRAMES_IN_FLIGHT * MAX_SETS_PER_POOL }
};
VkDescriptorPoolCreateInfo pool_info{};
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
pool_info.poolSizeCount = sizeof(pool_sizes) / sizeof(pool_sizes[0]);
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;
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
@@ -52,7 +52,6 @@ namespace mlx
kvfDestroyDescriptorSetLayout(RenderCore::Get().GetDevice(), set->m_set_layout);
RenderCore::Get().vkDestroyDescriptorPool(RenderCore::Get().GetDevice(), m_pool, nullptr);
m_pool = VK_NULL_HANDLE;
m_allocation_count = 0;
m_free_sets.clear();
m_used_sets.clear();
}
@@ -103,7 +102,6 @@ namespace mlx
alloc_info.pSetLayouts = &vulkan_layout;
VkDescriptorSet vulkan_set;
kvfCheckVk(RenderCore::Get().vkAllocateDescriptorSets(RenderCore::Get().GetDevice(), &alloc_info, &vulkan_set));
m_allocation_count++;
vulkan_sets[i] = vulkan_set;
}
@@ -124,12 +122,23 @@ namespace mlx
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();
for(auto& pool : m_pools)
{
if(pool->GetNumberOfSetsAllocated() < MAX_SETS_PER_POOL)
if(pool->CanAllocate(layout, shader_type))
return *pool;
}
m_pools.emplace_back(std::make_unique<DescriptorPool>())->Init();

View File

@@ -52,8 +52,8 @@ namespace mlx
};
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_texture_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool().RequestDescriptorSet(p_fragment_shader->GetShaderLayout().set_layouts[0].second, ShaderType::Fragment);
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(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->Init(sizeof(ViewerData), "mlx_2d_pass_viewer_data");

View File

@@ -38,7 +38,7 @@ namespace mlx
};
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)