-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improving descriptor sets and pools management (#41)
- Loading branch information
Showing
17 changed files
with
186 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
*.ilk | ||
*.pdb | ||
*.exe | ||
*vgcore | ||
.gdb_history | ||
.vs/ | ||
.xmake/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* descriptor_pool_manager.cpp :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/20 06:51:47 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/20 08:18:27 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <renderer/core/render_core.h> | ||
#include <renderer/descriptors/descriptor_pool_manager.h> | ||
|
||
namespace mlx | ||
{ | ||
DescriptorPool& DescriptorPoolManager::getAvailablePool() | ||
{ | ||
for(auto& pool : _pools) | ||
{ | ||
if(pool.getNumberOfSetsAllocated() < MAX_SETS_PER_POOL) | ||
return pool; | ||
} | ||
VkDescriptorPoolSize pool_sizes[] = { | ||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, (MAX_FRAMES_IN_FLIGHT * NUMBER_OF_UNIFORM_BUFFERS) }, | ||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_SETS_PER_POOL - (MAX_FRAMES_IN_FLIGHT * NUMBER_OF_UNIFORM_BUFFERS) } | ||
}; | ||
_pools.emplace_front().init((sizeof(pool_sizes) / sizeof(VkDescriptorPoolSize)), pool_sizes); | ||
return _pools.front(); | ||
} | ||
|
||
void DescriptorPoolManager::destroyAllPools() | ||
{ | ||
for(auto& pool : _pools) | ||
pool.destroy(); | ||
_pools.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* descriptor_pool_manager.h :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/20 06:26:26 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/20 08:23:04 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef __MLX_DESCRIPTOR_POOL_MANAGER__ | ||
#define __MLX_DESCRIPTOR_POOL_MANAGER__ | ||
|
||
#include <renderer/descriptors/vk_descriptor_pool.h> | ||
#include <list> | ||
|
||
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> _pools; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.